1 diff -NurpP --minimal linux-2.6.37/arch/alpha/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/alpha/Kconfig
2 --- linux-2.6.37/arch/alpha/Kconfig 2011-01-05 21:48:40.000000000 +0100
3 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/alpha/Kconfig 2010-11-23 02:09:40.000000000 +0100
4 @@ -677,6 +677,8 @@ config DUMMY_CONSOLE
8 +source "kernel/vserver/Kconfig"
10 source "security/Kconfig"
12 source "crypto/Kconfig"
13 diff -NurpP --minimal linux-2.6.37/arch/alpha/kernel/entry.S linux-2.6.37-vs2.3.0.37-rc2/arch/alpha/kernel/entry.S
14 --- linux-2.6.37/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
15 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/alpha/kernel/entry.S 2010-11-23 02:09:40.000000000 +0100
16 @@ -860,24 +860,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.37/arch/alpha/kernel/ptrace.c linux-2.6.37-vs2.3.0.37-rc2/arch/alpha/kernel/ptrace.c
49 --- linux-2.6.37/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
50 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/alpha/kernel/ptrace.c 2010-11-23 02:09:40.000000000 +0100
52 #include <linux/user.h>
53 #include <linux/security.h>
54 #include <linux/signal.h>
55 +#include <linux/vs_base.h>
57 #include <asm/uaccess.h>
58 #include <asm/pgtable.h>
59 diff -NurpP --minimal linux-2.6.37/arch/alpha/kernel/systbls.S linux-2.6.37-vs2.3.0.37-rc2/arch/alpha/kernel/systbls.S
60 --- linux-2.6.37/arch/alpha/kernel/systbls.S 2010-10-21 13:06:46.000000000 +0200
61 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/alpha/kernel/systbls.S 2010-11-23 02:09:40.000000000 +0100
62 @@ -446,7 +446,7 @@ sys_call_table:
63 .quad sys_stat64 /* 425 */
66 - .quad sys_ni_syscall /* sys_vserver */
67 + .quad sys_vserver /* sys_vserver */
68 .quad sys_ni_syscall /* sys_mbind */
69 .quad sys_ni_syscall /* sys_get_mempolicy */
70 .quad sys_ni_syscall /* sys_set_mempolicy */
71 diff -NurpP --minimal linux-2.6.37/arch/alpha/kernel/traps.c linux-2.6.37-vs2.3.0.37-rc2/arch/alpha/kernel/traps.c
72 --- linux-2.6.37/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
73 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/alpha/kernel/traps.c 2010-11-23 02:09:40.000000000 +0100
74 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
76 printk("CPU %d ", hard_smp_processor_id());
78 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
79 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
80 + task_pid_nr(current), current->xid, str, err);
81 dik_show_regs(regs, r9_15);
83 dik_show_trace((unsigned long *)(regs+1));
84 diff -NurpP --minimal linux-2.6.37/arch/arm/include/asm/tlb.h linux-2.6.37-vs2.3.0.37-rc2/arch/arm/include/asm/tlb.h
85 --- linux-2.6.37/arch/arm/include/asm/tlb.h 2009-09-10 15:25:15.000000000 +0200
86 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/arm/include/asm/tlb.h 2010-11-23 02:09:40.000000000 +0100
89 #else /* !CONFIG_MMU */
91 +#include <linux/vs_memory.h>
92 #include <asm/pgalloc.h>
95 diff -NurpP --minimal linux-2.6.37/arch/arm/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/arm/Kconfig
96 --- linux-2.6.37/arch/arm/Kconfig 2011-01-05 21:48:40.000000000 +0100
97 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/arm/Kconfig 2011-01-05 22:30:25.000000000 +0100
98 @@ -1854,6 +1854,8 @@ source "fs/Kconfig"
100 source "arch/arm/Kconfig.debug"
102 +source "kernel/vserver/Kconfig"
104 source "security/Kconfig"
106 source "crypto/Kconfig"
107 diff -NurpP --minimal linux-2.6.37/arch/arm/kernel/calls.S linux-2.6.37-vs2.3.0.37-rc2/arch/arm/kernel/calls.S
108 --- linux-2.6.37/arch/arm/kernel/calls.S 2010-10-21 13:06:46.000000000 +0200
109 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/arm/kernel/calls.S 2010-11-23 02:09:40.000000000 +0100
111 /* 310 */ CALL(sys_request_key)
113 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
114 -/* vserver */ CALL(sys_ni_syscall)
117 /* 315 */ CALL(sys_ioprio_get)
118 CALL(sys_inotify_init)
119 diff -NurpP --minimal linux-2.6.37/arch/arm/kernel/process.c linux-2.6.37-vs2.3.0.37-rc2/arch/arm/kernel/process.c
120 --- linux-2.6.37/arch/arm/kernel/process.c 2011-01-05 21:48:42.000000000 +0100
121 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/arm/kernel/process.c 2010-11-23 02:09:40.000000000 +0100
122 @@ -315,7 +315,8 @@ void __show_regs(struct pt_regs *regs)
123 void show_regs(struct pt_regs * regs)
126 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
127 + printk("Pid: %d[#%u], comm: %20s\n",
128 + task_pid_nr(current), current->xid, current->comm);
132 diff -NurpP --minimal linux-2.6.37/arch/arm/kernel/traps.c linux-2.6.37-vs2.3.0.37-rc2/arch/arm/kernel/traps.c
133 --- linux-2.6.37/arch/arm/kernel/traps.c 2011-01-05 21:48:42.000000000 +0100
134 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/arm/kernel/traps.c 2010-11-23 02:09:40.000000000 +0100
135 @@ -241,8 +241,8 @@ static int __die(const char *str, int er
139 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
140 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
141 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
142 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
144 if (!user_mode(regs) || in_interrupt()) {
145 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
146 diff -NurpP --minimal linux-2.6.37/arch/cris/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/cris/Kconfig
147 --- linux-2.6.37/arch/cris/Kconfig 2011-01-05 21:48:58.000000000 +0100
148 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/cris/Kconfig 2010-11-23 02:09:40.000000000 +0100
149 @@ -687,6 +687,8 @@ source "drivers/staging/Kconfig"
151 source "arch/cris/Kconfig.debug"
153 +source "kernel/vserver/Kconfig"
155 source "security/Kconfig"
157 source "crypto/Kconfig"
158 diff -NurpP --minimal linux-2.6.37/arch/frv/kernel/kernel_thread.S linux-2.6.37-vs2.3.0.37-rc2/arch/frv/kernel/kernel_thread.S
159 --- linux-2.6.37/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
160 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/frv/kernel/kernel_thread.S 2010-11-23 02:09:40.000000000 +0100
161 @@ -37,7 +37,7 @@ kernel_thread:
163 # start by forking the current process, but with shared VM
164 setlos.p #__NR_clone,gr7 ; syscall number
165 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
166 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
167 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
169 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
170 diff -NurpP --minimal linux-2.6.37/arch/h8300/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/h8300/Kconfig
171 --- linux-2.6.37/arch/h8300/Kconfig 2011-01-05 21:48:59.000000000 +0100
172 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/h8300/Kconfig 2010-11-23 02:09:40.000000000 +0100
173 @@ -219,6 +219,8 @@ source "fs/Kconfig"
175 source "arch/h8300/Kconfig.debug"
177 +source "kernel/vserver/Kconfig"
179 source "security/Kconfig"
181 source "crypto/Kconfig"
182 diff -NurpP --minimal linux-2.6.37/arch/ia64/include/asm/tlb.h linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/include/asm/tlb.h
183 --- linux-2.6.37/arch/ia64/include/asm/tlb.h 2010-02-25 11:51:26.000000000 +0100
184 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/include/asm/tlb.h 2010-11-23 02:09:40.000000000 +0100
186 #include <linux/mm.h>
187 #include <linux/pagemap.h>
188 #include <linux/swap.h>
189 +#include <linux/vs_memory.h>
191 #include <asm/pgalloc.h>
192 #include <asm/processor.h>
193 diff -NurpP --minimal linux-2.6.37/arch/ia64/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/Kconfig
194 --- linux-2.6.37/arch/ia64/Kconfig 2011-01-05 21:48:59.000000000 +0100
195 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/Kconfig 2010-11-23 02:09:40.000000000 +0100
196 @@ -670,6 +670,8 @@ source "fs/Kconfig"
198 source "arch/ia64/Kconfig.debug"
200 +source "kernel/vserver/Kconfig"
202 source "security/Kconfig"
204 source "crypto/Kconfig"
205 diff -NurpP --minimal linux-2.6.37/arch/ia64/kernel/entry.S linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/kernel/entry.S
206 --- linux-2.6.37/arch/ia64/kernel/entry.S 2010-10-21 13:06:52.000000000 +0200
207 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/kernel/entry.S 2010-11-23 02:09:40.000000000 +0100
208 @@ -1714,7 +1714,7 @@ sys_call_table:
210 data8 sys_mq_getsetattr
212 - data8 sys_ni_syscall // reserved for vserver
214 data8 sys_waitid // 1270
216 data8 sys_request_key
217 diff -NurpP --minimal linux-2.6.37/arch/ia64/kernel/perfmon.c linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/kernel/perfmon.c
218 --- linux-2.6.37/arch/ia64/kernel/perfmon.c 2011-01-05 21:48:59.000000000 +0100
219 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/kernel/perfmon.c 2010-11-23 02:09:40.000000000 +0100
221 #include <linux/completion.h>
222 #include <linux/tracehook.h>
223 #include <linux/slab.h>
224 +#include <linux/vs_memory.h>
226 #include <asm/errno.h>
227 #include <asm/intrinsics.h>
228 diff -NurpP --minimal linux-2.6.37/arch/ia64/kernel/process.c linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/kernel/process.c
229 --- linux-2.6.37/arch/ia64/kernel/process.c 2010-10-21 13:06:52.000000000 +0200
230 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/kernel/process.c 2010-11-23 02:09:40.000000000 +0100
231 @@ -113,8 +113,8 @@ show_regs (struct pt_regs *regs)
232 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
235 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
236 - smp_processor_id(), current->comm);
237 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
238 + current->xid, smp_processor_id(), current->comm);
239 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
240 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
241 init_utsname()->release);
242 diff -NurpP --minimal linux-2.6.37/arch/ia64/kernel/ptrace.c linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/kernel/ptrace.c
243 --- linux-2.6.37/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
244 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/kernel/ptrace.c 2010-11-23 02:09:40.000000000 +0100
246 #include <linux/regset.h>
247 #include <linux/elf.h>
248 #include <linux/tracehook.h>
249 +#include <linux/vs_base.h>
251 #include <asm/pgtable.h>
252 #include <asm/processor.h>
253 diff -NurpP --minimal linux-2.6.37/arch/ia64/kernel/traps.c linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/kernel/traps.c
254 --- linux-2.6.37/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
255 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/kernel/traps.c 2010-11-23 02:09:40.000000000 +0100
256 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
259 if (++die.lock_owner_depth < 3) {
260 - printk("%s[%d]: %s %ld [%d]\n",
261 - current->comm, task_pid_nr(current), str, err, ++die_counter);
262 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
263 + current->comm, task_pid_nr(current), current->xid,
264 + str, err, ++die_counter);
265 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
268 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
269 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
270 last.time = current_jiffies + 5 * HZ;
272 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
273 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
274 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
275 + current->comm, task_pid_nr(current), current->xid,
276 + regs->cr_iip + ia64_psr(regs)->ri, isr);
280 diff -NurpP --minimal linux-2.6.37/arch/ia64/mm/fault.c linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/mm/fault.c
281 --- linux-2.6.37/arch/ia64/mm/fault.c 2010-08-02 16:52:04.000000000 +0200
282 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/ia64/mm/fault.c 2010-11-23 02:09:40.000000000 +0100
284 #include <linux/interrupt.h>
285 #include <linux/kprobes.h>
286 #include <linux/kdebug.h>
287 +#include <linux/vs_memory.h>
289 #include <asm/pgtable.h>
290 #include <asm/processor.h>
291 diff -NurpP --minimal linux-2.6.37/arch/m32r/kernel/traps.c linux-2.6.37-vs2.3.0.37-rc2/arch/m32r/kernel/traps.c
292 --- linux-2.6.37/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
293 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/m32r/kernel/traps.c 2010-11-23 02:09:40.000000000 +0100
294 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
296 printk("SPI: %08lx\n", sp);
298 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
299 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
300 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
301 + current->comm, task_pid_nr(current), current->xid,
302 + 0xffff & i, 4096+(unsigned long)current);
305 * When in-kernel, we also print out the stack and code at the
306 diff -NurpP --minimal linux-2.6.37/arch/m68k/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/m68k/Kconfig
307 --- linux-2.6.37/arch/m68k/Kconfig 2011-01-05 21:49:00.000000000 +0100
308 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/m68k/Kconfig 2010-11-23 02:09:40.000000000 +0100
309 @@ -610,6 +610,8 @@ source "fs/Kconfig"
311 source "arch/m68k/Kconfig.debug"
313 +source "kernel/vserver/Kconfig"
315 source "security/Kconfig"
317 source "crypto/Kconfig"
318 diff -NurpP --minimal linux-2.6.37/arch/m68k/kernel/ptrace.c linux-2.6.37-vs2.3.0.37-rc2/arch/m68k/kernel/ptrace.c
319 --- linux-2.6.37/arch/m68k/kernel/ptrace.c 2011-01-05 21:49:01.000000000 +0100
320 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/m68k/kernel/ptrace.c 2010-11-23 02:09:40.000000000 +0100
322 #include <linux/ptrace.h>
323 #include <linux/user.h>
324 #include <linux/signal.h>
325 +#include <linux/vs_base.h>
327 #include <asm/uaccess.h>
328 #include <asm/page.h>
329 @@ -255,6 +256,8 @@ long arch_ptrace(struct task_struct *chi
330 ret = ptrace_request(child, request, addr, data);
333 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
338 diff -NurpP --minimal linux-2.6.37/arch/m68k/kernel/traps.c linux-2.6.37-vs2.3.0.37-rc2/arch/m68k/kernel/traps.c
339 --- linux-2.6.37/arch/m68k/kernel/traps.c 2010-08-02 16:52:04.000000000 +0200
340 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/m68k/kernel/traps.c 2010-11-23 02:09:40.000000000 +0100
341 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
342 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
343 regs->d4, regs->d5, regs->a0, regs->a1);
345 - printk("Process %s (pid: %d, task=%p)\n",
346 - current->comm, task_pid_nr(current), current);
347 + printk("Process %s (pid: %d[#%u], task=%p)\n",
348 + current->comm, task_pid_nr(current), current->xid, current);
349 addr = (unsigned long)&fp->un;
350 printk("Frame format=%X ", regs->format);
351 switch (regs->format) {
352 diff -NurpP --minimal linux-2.6.37/arch/m68knommu/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/m68knommu/Kconfig
353 --- linux-2.6.37/arch/m68knommu/Kconfig 2011-01-05 21:49:01.000000000 +0100
354 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/m68knommu/Kconfig 2010-11-23 02:09:40.000000000 +0100
355 @@ -732,6 +732,8 @@ source "fs/Kconfig"
357 source "arch/m68knommu/Kconfig.debug"
359 +source "kernel/vserver/Kconfig"
361 source "security/Kconfig"
363 source "crypto/Kconfig"
364 diff -NurpP --minimal linux-2.6.37/arch/m68knommu/kernel/traps.c linux-2.6.37-vs2.3.0.37-rc2/arch/m68knommu/kernel/traps.c
365 --- linux-2.6.37/arch/m68knommu/kernel/traps.c 2011-01-05 21:49:01.000000000 +0100
366 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/m68knommu/kernel/traps.c 2010-11-23 02:09:40.000000000 +0100
367 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
368 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
369 fp->d4, fp->d5, fp->a0, fp->a1);
371 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
372 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
373 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
374 + current->comm, task_pid_nr(current), current->xid,
375 + PAGE_SIZE+(unsigned long)current);
376 show_stack(NULL, (unsigned long *)(fp + 1));
377 add_taint(TAINT_DIE);
379 diff -NurpP --minimal linux-2.6.37/arch/mips/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/mips/Kconfig
380 --- linux-2.6.37/arch/mips/Kconfig 2011-01-05 21:49:03.000000000 +0100
381 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/mips/Kconfig 2011-01-05 22:30:26.000000000 +0100
382 @@ -2396,6 +2396,8 @@ source "fs/Kconfig"
384 source "arch/mips/Kconfig.debug"
386 +source "kernel/vserver/Kconfig"
388 source "security/Kconfig"
390 source "crypto/Kconfig"
391 diff -NurpP --minimal linux-2.6.37/arch/mips/kernel/ptrace.c linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/ptrace.c
392 --- linux-2.6.37/arch/mips/kernel/ptrace.c 2011-01-05 21:49:06.000000000 +0100
393 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/ptrace.c 2010-11-23 02:09:40.000000000 +0100
395 #include <linux/security.h>
396 #include <linux/audit.h>
397 #include <linux/seccomp.h>
398 +#include <linux/vs_base.h>
400 #include <asm/byteorder.h>
402 @@ -263,6 +264,9 @@ long arch_ptrace(struct task_struct *chi
403 void __user *datavp = (void __user *) data;
404 unsigned long __user *datalp = (void __user *) data;
406 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
410 /* when I and D space are separate, these will need to be fixed. */
411 case PTRACE_PEEKTEXT: /* read word at location addr. */
412 diff -NurpP --minimal linux-2.6.37/arch/mips/kernel/scall32-o32.S linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/scall32-o32.S
413 --- linux-2.6.37/arch/mips/kernel/scall32-o32.S 2010-10-21 13:06:54.000000000 +0200
414 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/scall32-o32.S 2010-11-23 02:09:40.000000000 +0100
415 @@ -524,7 +524,7 @@ einval: li v0, -ENOSYS
416 sys sys_mq_timedreceive 5
417 sys sys_mq_notify 2 /* 4275 */
418 sys sys_mq_getsetattr 3
419 - sys sys_ni_syscall 0 /* sys_vserver */
422 sys sys_ni_syscall 0 /* available, was setaltroot */
423 sys sys_add_key 5 /* 4280 */
424 diff -NurpP --minimal linux-2.6.37/arch/mips/kernel/scall64-64.S linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/scall64-64.S
425 --- linux-2.6.37/arch/mips/kernel/scall64-64.S 2010-10-21 13:06:54.000000000 +0200
426 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/scall64-64.S 2010-11-23 02:09:40.000000000 +0100
427 @@ -363,7 +363,7 @@ sys_call_table:
428 PTR sys_mq_timedreceive
430 PTR sys_mq_getsetattr /* 5235 */
431 - PTR sys_ni_syscall /* sys_vserver */
434 PTR sys_ni_syscall /* available, was setaltroot */
436 diff -NurpP --minimal linux-2.6.37/arch/mips/kernel/scall64-n32.S linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/scall64-n32.S
437 --- linux-2.6.37/arch/mips/kernel/scall64-n32.S 2010-10-21 13:06:54.000000000 +0200
438 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/scall64-n32.S 2010-11-23 02:09:40.000000000 +0100
439 @@ -362,7 +362,7 @@ EXPORT(sysn32_call_table)
440 PTR compat_sys_mq_timedreceive
441 PTR compat_sys_mq_notify
442 PTR compat_sys_mq_getsetattr
443 - PTR sys_ni_syscall /* 6240, sys_vserver */
444 + PTR sys32_vserver /* 6240 */
445 PTR compat_sys_waitid
446 PTR sys_ni_syscall /* available, was setaltroot */
448 diff -NurpP --minimal linux-2.6.37/arch/mips/kernel/scall64-o32.S linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/scall64-o32.S
449 --- linux-2.6.37/arch/mips/kernel/scall64-o32.S 2010-10-21 13:06:54.000000000 +0200
450 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/scall64-o32.S 2010-11-23 02:09:40.000000000 +0100
451 @@ -481,7 +481,7 @@ sys_call_table:
452 PTR compat_sys_mq_timedreceive
453 PTR compat_sys_mq_notify /* 4275 */
454 PTR compat_sys_mq_getsetattr
455 - PTR sys_ni_syscall /* sys_vserver */
458 PTR sys_ni_syscall /* available, was setaltroot */
459 PTR sys_add_key /* 4280 */
460 diff -NurpP --minimal linux-2.6.37/arch/mips/kernel/traps.c linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/traps.c
461 --- linux-2.6.37/arch/mips/kernel/traps.c 2011-01-05 21:49:06.000000000 +0100
462 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/mips/kernel/traps.c 2011-01-05 22:30:26.000000000 +0100
463 @@ -343,9 +343,10 @@ void show_registers(struct pt_regs *regs
467 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
468 - current->comm, current->pid, current_thread_info(), current,
469 - field, current_thread_info()->tp_value);
470 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
471 + current->comm, task_pid_nr(current), current->xid,
472 + current_thread_info(), current,
473 + field, current_thread_info()->tp_value);
474 if (cpu_has_userlocal) {
477 diff -NurpP --minimal linux-2.6.37/arch/parisc/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/parisc/Kconfig
478 --- linux-2.6.37/arch/parisc/Kconfig 2011-01-05 21:49:08.000000000 +0100
479 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/parisc/Kconfig 2010-11-23 02:09:40.000000000 +0100
480 @@ -293,6 +293,8 @@ source "fs/Kconfig"
482 source "arch/parisc/Kconfig.debug"
484 +source "kernel/vserver/Kconfig"
486 source "security/Kconfig"
488 source "crypto/Kconfig"
489 diff -NurpP --minimal linux-2.6.37/arch/parisc/kernel/syscall_table.S linux-2.6.37-vs2.3.0.37-rc2/arch/parisc/kernel/syscall_table.S
490 --- linux-2.6.37/arch/parisc/kernel/syscall_table.S 2011-01-05 21:49:09.000000000 +0100
491 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/parisc/kernel/syscall_table.S 2010-11-23 02:09:40.000000000 +0100
493 ENTRY_COMP(mbind) /* 260 */
494 ENTRY_COMP(get_mempolicy)
495 ENTRY_COMP(set_mempolicy)
496 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
497 + ENTRY_DIFF(vserver)
499 ENTRY_SAME(request_key) /* 265 */
501 diff -NurpP --minimal linux-2.6.37/arch/parisc/kernel/traps.c linux-2.6.37-vs2.3.0.37-rc2/arch/parisc/kernel/traps.c
502 --- linux-2.6.37/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
503 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/parisc/kernel/traps.c 2010-11-23 02:09:40.000000000 +0100
504 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
508 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
509 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
510 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
511 + current->comm, task_pid_nr(current), current->xid,
512 + str, err, regs->iaoq[0]);
513 #ifdef PRINT_USER_FAULTS
514 /* XXX for debugging only */
516 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
517 pdc_console_restart();
520 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
521 - current->comm, task_pid_nr(current), str, err);
522 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
523 + current->comm, task_pid_nr(current), current->xid, str, err);
525 /* Wot's wrong wif bein' racy? */
526 if (current->thread.flags & PARISC_KERNEL_DEATH) {
527 diff -NurpP --minimal linux-2.6.37/arch/parisc/mm/fault.c linux-2.6.37-vs2.3.0.37-rc2/arch/parisc/mm/fault.c
528 --- linux-2.6.37/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
529 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/parisc/mm/fault.c 2010-11-23 02:09:40.000000000 +0100
530 @@ -237,8 +237,9 @@ bad_area:
532 #ifdef PRINT_USER_FAULTS
533 printk(KERN_DEBUG "\n");
534 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
535 - task_pid_nr(tsk), tsk->comm, code, address);
536 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
537 + "command='%s' type=%lu address=0x%08lx\n",
538 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
540 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
541 vma->vm_start, vma->vm_end);
542 diff -NurpP --minimal linux-2.6.37/arch/powerpc/include/asm/unistd.h linux-2.6.37-vs2.3.0.37-rc2/arch/powerpc/include/asm/unistd.h
543 --- linux-2.6.37/arch/powerpc/include/asm/unistd.h 2011-01-05 21:49:10.000000000 +0100
544 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/powerpc/include/asm/unistd.h 2010-11-23 02:09:40.000000000 +0100
547 #define __NR_rtas 255
548 #define __NR_sys_debug_setcontext 256
549 -/* Number 257 is reserved for vserver */
550 +#define __NR_vserver 257
551 #define __NR_migrate_pages 258
552 #define __NR_mbind 259
553 #define __NR_get_mempolicy 260
554 diff -NurpP --minimal linux-2.6.37/arch/powerpc/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/powerpc/Kconfig
555 --- linux-2.6.37/arch/powerpc/Kconfig 2011-01-05 21:49:09.000000000 +0100
556 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/powerpc/Kconfig 2010-11-23 02:09:40.000000000 +0100
557 @@ -976,6 +976,8 @@ source "lib/Kconfig"
559 source "arch/powerpc/Kconfig.debug"
561 +source "kernel/vserver/Kconfig"
563 source "security/Kconfig"
566 diff -NurpP --minimal linux-2.6.37/arch/powerpc/kernel/process.c linux-2.6.37-vs2.3.0.37-rc2/arch/powerpc/kernel/process.c
567 --- linux-2.6.37/arch/powerpc/kernel/process.c 2011-01-05 21:49:11.000000000 +0100
568 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/powerpc/kernel/process.c 2010-11-23 02:09:40.000000000 +0100
569 @@ -633,8 +633,9 @@ void show_regs(struct pt_regs * regs)
571 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
573 - printk("TASK = %p[%d] '%s' THREAD: %p",
574 - current, task_pid_nr(current), current->comm, task_thread_info(current));
575 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
576 + current, task_pid_nr(current), current->xid,
577 + current->comm, task_thread_info(current));
580 printk(" CPU: %d", raw_smp_processor_id());
581 diff -NurpP --minimal linux-2.6.37/arch/powerpc/kernel/traps.c linux-2.6.37-vs2.3.0.37-rc2/arch/powerpc/kernel/traps.c
582 --- linux-2.6.37/arch/powerpc/kernel/traps.c 2011-01-05 21:49:11.000000000 +0100
583 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/powerpc/kernel/traps.c 2010-11-23 02:09:40.000000000 +0100
584 @@ -1053,8 +1053,9 @@ void nonrecoverable_exception(struct pt_
586 void trace_syscall(struct pt_regs *regs)
588 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
589 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
590 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
591 + current, task_pid_nr(current), current->xid,
592 + regs->nip, regs->link, regs->gpr[0],
593 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
596 diff -NurpP --minimal linux-2.6.37/arch/powerpc/kernel/vdso.c linux-2.6.37-vs2.3.0.37-rc2/arch/powerpc/kernel/vdso.c
597 --- linux-2.6.37/arch/powerpc/kernel/vdso.c 2011-01-05 21:49:11.000000000 +0100
598 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/powerpc/kernel/vdso.c 2010-11-23 02:09:40.000000000 +0100
600 #include <linux/security.h>
601 #include <linux/bootmem.h>
602 #include <linux/memblock.h>
603 +#include <linux/vs_memory.h>
605 #include <asm/pgtable.h>
606 #include <asm/system.h>
607 diff -NurpP --minimal linux-2.6.37/arch/s390/include/asm/tlb.h linux-2.6.37-vs2.3.0.37-rc2/arch/s390/include/asm/tlb.h
608 --- linux-2.6.37/arch/s390/include/asm/tlb.h 2011-01-05 21:49:13.000000000 +0100
609 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/s390/include/asm/tlb.h 2010-11-23 02:09:40.000000000 +0100
612 #include <linux/mm.h>
613 #include <linux/swap.h>
614 +#include <linux/vs_memory.h>
616 #include <asm/processor.h>
617 #include <asm/pgalloc.h>
619 diff -NurpP --minimal linux-2.6.37/arch/s390/include/asm/unistd.h linux-2.6.37-vs2.3.0.37-rc2/arch/s390/include/asm/unistd.h
620 --- linux-2.6.37/arch/s390/include/asm/unistd.h 2010-10-21 13:06:58.000000000 +0200
621 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/s390/include/asm/unistd.h 2010-11-23 02:09:40.000000000 +0100
623 #define __NR_clock_gettime (__NR_timer_create+6)
624 #define __NR_clock_getres (__NR_timer_create+7)
625 #define __NR_clock_nanosleep (__NR_timer_create+8)
626 -/* Number 263 is reserved for vserver */
627 +#define __NR_vserver 263
628 #define __NR_statfs64 265
629 #define __NR_fstatfs64 266
630 #define __NR_remap_file_pages 267
631 diff -NurpP --minimal linux-2.6.37/arch/s390/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/s390/Kconfig
632 --- linux-2.6.37/arch/s390/Kconfig 2011-01-05 21:49:12.000000000 +0100
633 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/s390/Kconfig 2010-11-23 02:09:40.000000000 +0100
634 @@ -640,6 +640,8 @@ source "fs/Kconfig"
636 source "arch/s390/Kconfig.debug"
638 +source "kernel/vserver/Kconfig"
640 source "security/Kconfig"
642 source "crypto/Kconfig"
643 diff -NurpP --minimal linux-2.6.37/arch/s390/kernel/ptrace.c linux-2.6.37-vs2.3.0.37-rc2/arch/s390/kernel/ptrace.c
644 --- linux-2.6.37/arch/s390/kernel/ptrace.c 2011-01-05 21:49:13.000000000 +0100
645 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/s390/kernel/ptrace.c 2010-11-23 02:09:40.000000000 +0100
647 #include <linux/regset.h>
648 #include <linux/tracehook.h>
649 #include <linux/seccomp.h>
650 +#include <linux/vs_base.h>
651 #include <trace/syscall.h>
652 #include <asm/compat.h>
653 #include <asm/segment.h>
654 diff -NurpP --minimal linux-2.6.37/arch/s390/kernel/syscalls.S linux-2.6.37-vs2.3.0.37-rc2/arch/s390/kernel/syscalls.S
655 --- linux-2.6.37/arch/s390/kernel/syscalls.S 2010-10-21 13:06:58.000000000 +0200
656 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/s390/kernel/syscalls.S 2010-11-23 02:09:40.000000000 +0100
657 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
658 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
659 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
660 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
661 -NI_SYSCALL /* reserved for vserver */
662 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
663 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
664 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
665 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
666 diff -NurpP --minimal linux-2.6.37/arch/sh/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/sh/Kconfig
667 --- linux-2.6.37/arch/sh/Kconfig 2011-01-05 21:49:13.000000000 +0100
668 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/sh/Kconfig 2011-01-05 22:30:27.000000000 +0100
669 @@ -883,6 +883,8 @@ source "fs/Kconfig"
671 source "arch/sh/Kconfig.debug"
673 +source "kernel/vserver/Kconfig"
675 source "security/Kconfig"
677 source "crypto/Kconfig"
678 diff -NurpP --minimal linux-2.6.37/arch/sh/kernel/irq.c linux-2.6.37-vs2.3.0.37-rc2/arch/sh/kernel/irq.c
679 --- linux-2.6.37/arch/sh/kernel/irq.c 2011-01-05 21:49:16.000000000 +0100
680 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/sh/kernel/irq.c 2010-11-23 02:09:40.000000000 +0100
682 #include <linux/seq_file.h>
683 #include <linux/ftrace.h>
684 #include <linux/delay.h>
685 +// #include <linux/vs_context.h>
686 #include <asm/processor.h>
687 #include <asm/machvec.h>
688 #include <asm/uaccess.h>
689 diff -NurpP --minimal linux-2.6.37/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.37-vs2.3.0.37-rc2/arch/sh/kernel/vsyscall/vsyscall.c
690 --- linux-2.6.37/arch/sh/kernel/vsyscall/vsyscall.c 2010-07-07 18:31:10.000000000 +0200
691 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/sh/kernel/vsyscall/vsyscall.c 2010-11-23 02:09:40.000000000 +0100
693 #include <linux/elf.h>
694 #include <linux/sched.h>
695 #include <linux/err.h>
696 +#include <linux/vs_memory.h>
699 * Should the kernel map a VDSO page into processes and pass its
700 diff -NurpP --minimal linux-2.6.37/arch/sparc/include/asm/tlb_64.h linux-2.6.37-vs2.3.0.37-rc2/arch/sparc/include/asm/tlb_64.h
701 --- linux-2.6.37/arch/sparc/include/asm/tlb_64.h 2009-09-10 15:25:45.000000000 +0200
702 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/sparc/include/asm/tlb_64.h 2010-11-23 02:09:40.000000000 +0100
705 #include <linux/swap.h>
706 #include <linux/pagemap.h>
707 +#include <linux/vs_memory.h>
708 #include <asm/pgalloc.h>
709 #include <asm/tlbflush.h>
710 #include <asm/mmu_context.h>
711 diff -NurpP --minimal linux-2.6.37/arch/sparc/include/asm/unistd.h linux-2.6.37-vs2.3.0.37-rc2/arch/sparc/include/asm/unistd.h
712 --- linux-2.6.37/arch/sparc/include/asm/unistd.h 2010-10-21 13:06:58.000000000 +0200
713 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/sparc/include/asm/unistd.h 2010-11-23 02:09:40.000000000 +0100
715 #define __NR_timer_getoverrun 264
716 #define __NR_timer_delete 265
717 #define __NR_timer_create 266
718 -/* #define __NR_vserver 267 Reserved for VSERVER */
719 +#define __NR_vserver 267
720 #define __NR_io_setup 268
721 #define __NR_io_destroy 269
722 #define __NR_io_submit 270
723 diff -NurpP --minimal linux-2.6.37/arch/sparc/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/sparc/Kconfig
724 --- linux-2.6.37/arch/sparc/Kconfig 2011-01-05 21:49:17.000000000 +0100
725 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/sparc/Kconfig 2010-11-23 02:09:40.000000000 +0100
726 @@ -560,6 +560,8 @@ source "fs/Kconfig"
728 source "arch/sparc/Kconfig.debug"
730 +source "kernel/vserver/Kconfig"
732 source "security/Kconfig"
734 source "crypto/Kconfig"
735 diff -NurpP --minimal linux-2.6.37/arch/sparc/kernel/systbls_32.S linux-2.6.37-vs2.3.0.37-rc2/arch/sparc/kernel/systbls_32.S
736 --- linux-2.6.37/arch/sparc/kernel/systbls_32.S 2010-10-21 13:06:59.000000000 +0200
737 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/sparc/kernel/systbls_32.S 2010-11-23 02:09:40.000000000 +0100
738 @@ -70,7 +70,7 @@ sys_call_table:
739 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
740 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
741 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
742 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
743 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
744 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
745 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
746 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
747 diff -NurpP --minimal linux-2.6.37/arch/sparc/kernel/systbls_64.S linux-2.6.37-vs2.3.0.37-rc2/arch/sparc/kernel/systbls_64.S
748 --- linux-2.6.37/arch/sparc/kernel/systbls_64.S 2010-10-21 13:06:59.000000000 +0200
749 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/sparc/kernel/systbls_64.S 2010-11-23 02:09:41.000000000 +0100
750 @@ -71,7 +71,7 @@ sys_call_table32:
751 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
752 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
753 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
754 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
755 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
756 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
757 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
758 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
759 @@ -147,7 +147,7 @@ sys_call_table:
760 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
761 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
762 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
763 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
764 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
765 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
766 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
767 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
768 diff -NurpP --minimal linux-2.6.37/arch/um/include/asm/tlb.h linux-2.6.37-vs2.3.0.37-rc2/arch/um/include/asm/tlb.h
769 --- linux-2.6.37/arch/um/include/asm/tlb.h 2009-09-10 15:25:46.000000000 +0200
770 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/um/include/asm/tlb.h 2010-11-23 02:09:41.000000000 +0100
773 #include <linux/pagemap.h>
774 #include <linux/swap.h>
775 +#include <linux/vs_memory.h>
776 #include <asm/percpu.h>
777 #include <asm/pgalloc.h>
778 #include <asm/tlbflush.h>
779 diff -NurpP --minimal linux-2.6.37/arch/um/include/shared/kern_constants.h linux-2.6.37-vs2.3.0.37-rc2/arch/um/include/shared/kern_constants.h
780 --- linux-2.6.37/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
781 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/um/include/shared/kern_constants.h 2010-11-23 02:09:41.000000000 +0100
783 +#include "../../../../include/generated/asm-offsets.h"
784 diff -NurpP --minimal linux-2.6.37/arch/um/include/shared/user_constants.h linux-2.6.37-vs2.3.0.37-rc2/arch/um/include/shared/user_constants.h
785 --- linux-2.6.37/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
786 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/um/include/shared/user_constants.h 2010-11-23 02:09:41.000000000 +0100
791 + * This file was generated by arch/um/Makefile
795 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2) # */
796 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err) # */
797 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno) # */
798 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long) # */
799 +#define HOST_RBX 5 /* RBX # */
800 +#define HOST_RCX 11 /* RCX # */
801 +#define HOST_RDI 14 /* RDI # */
802 +#define HOST_RSI 13 /* RSI # */
803 +#define HOST_RDX 12 /* RDX # */
804 +#define HOST_RBP 4 /* RBP # */
805 +#define HOST_RAX 10 /* RAX # */
806 +#define HOST_R8 9 /* R8 # */
807 +#define HOST_R9 8 /* R9 # */
808 +#define HOST_R10 7 /* R10 # */
809 +#define HOST_R11 6 /* R11 # */
810 +#define HOST_R12 3 /* R12 # */
811 +#define HOST_R13 2 /* R13 # */
812 +#define HOST_R14 1 /* R14 # */
813 +#define HOST_R15 0 /* R15 # */
814 +#define HOST_ORIG_RAX 15 /* ORIG_RAX # */
815 +#define HOST_CS 17 /* CS # */
816 +#define HOST_SS 20 /* SS # */
817 +#define HOST_EFLAGS 18 /* EFLAGS # */
818 +#define HOST_IP 16 /* RIP # */
819 +#define HOST_SP 19 /* RSP # */
820 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct) # */
821 +#define UM_POLLIN 1 /* POLLIN # */
822 +#define UM_POLLPRI 2 /* POLLPRI # */
823 +#define UM_POLLOUT 4 /* POLLOUT # */
824 +#define UM_PROT_READ 1 /* PROT_READ # */
825 +#define UM_PROT_WRITE 2 /* PROT_WRITE # */
826 +#define UM_PROT_EXEC 4 /* PROT_EXEC # */
828 diff -NurpP --minimal linux-2.6.37/arch/um/Kconfig.rest linux-2.6.37-vs2.3.0.37-rc2/arch/um/Kconfig.rest
829 --- linux-2.6.37/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
830 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/um/Kconfig.rest 2010-11-23 02:09:41.000000000 +0100
831 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
835 +source "kernel/vserver/Kconfig"
837 source "security/Kconfig"
839 source "crypto/Kconfig"
840 diff -NurpP --minimal linux-2.6.37/arch/x86/ia32/ia32entry.S linux-2.6.37-vs2.3.0.37-rc2/arch/x86/ia32/ia32entry.S
841 --- linux-2.6.37/arch/x86/ia32/ia32entry.S 2010-10-21 13:06:59.000000000 +0200
842 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/x86/ia32/ia32entry.S 2010-11-23 02:09:41.000000000 +0100
843 @@ -783,7 +783,7 @@ ia32_sys_call_table:
844 .quad sys_tgkill /* 270 */
845 .quad compat_sys_utimes
846 .quad sys32_fadvise64_64
847 - .quad quiet_ni_syscall /* sys_vserver */
848 + .quad sys32_vserver
850 .quad compat_sys_get_mempolicy /* 275 */
851 .quad sys_set_mempolicy
852 diff -NurpP --minimal linux-2.6.37/arch/x86/include/asm/unistd_64.h linux-2.6.37-vs2.3.0.37-rc2/arch/x86/include/asm/unistd_64.h
853 --- linux-2.6.37/arch/x86/include/asm/unistd_64.h 2010-10-21 13:06:59.000000000 +0200
854 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/x86/include/asm/unistd_64.h 2010-11-23 02:09:41.000000000 +0100
855 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
856 #define __NR_utimes 235
857 __SYSCALL(__NR_utimes, sys_utimes)
858 #define __NR_vserver 236
859 -__SYSCALL(__NR_vserver, sys_ni_syscall)
860 +__SYSCALL(__NR_vserver, sys_vserver)
861 #define __NR_mbind 237
862 __SYSCALL(__NR_mbind, sys_mbind)
863 #define __NR_set_mempolicy 238
864 diff -NurpP --minimal linux-2.6.37/arch/x86/Kconfig linux-2.6.37-vs2.3.0.37-rc2/arch/x86/Kconfig
865 --- linux-2.6.37/arch/x86/Kconfig 2011-01-05 21:49:19.000000000 +0100
866 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/x86/Kconfig 2011-01-05 22:30:27.000000000 +0100
867 @@ -2119,6 +2119,8 @@ source "fs/Kconfig"
869 source "arch/x86/Kconfig.debug"
871 +source "kernel/vserver/Kconfig"
873 source "security/Kconfig"
875 source "crypto/Kconfig"
876 diff -NurpP --minimal linux-2.6.37/arch/x86/kernel/syscall_table_32.S linux-2.6.37-vs2.3.0.37-rc2/arch/x86/kernel/syscall_table_32.S
877 --- linux-2.6.37/arch/x86/kernel/syscall_table_32.S 2010-10-21 13:07:00.000000000 +0200
878 +++ linux-2.6.37-vs2.3.0.37-rc2/arch/x86/kernel/syscall_table_32.S 2010-11-23 02:09:41.000000000 +0100
879 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
880 .long sys_tgkill /* 270 */
882 .long sys_fadvise64_64
883 - .long sys_ni_syscall /* sys_vserver */
886 .long sys_get_mempolicy
887 .long sys_set_mempolicy
888 diff -NurpP --minimal linux-2.6.37/Documentation/vserver/debug.txt linux-2.6.37-vs2.3.0.37-rc2/Documentation/vserver/debug.txt
889 --- linux-2.6.37/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
890 +++ linux-2.6.37-vs2.3.0.37-rc2/Documentation/vserver/debug.txt 2010-11-23 02:09:40.000000000 +0100
895 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
896 + "vx_rmap_tgid: %p/%llx: %d -> %d"
900 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
901 + "FREE (%p,#%d)%c inode"
902 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
903 + "FREE (%p,#%d)%c %lld bytes"
904 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
905 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
906 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
907 + "rcu_free_dl_info(%p)"
908 + 4 10 "alloc_dl_info(%p,%d) = %p"
909 + "dealloc_dl_info(%p)"
910 + "get_dl_info(%p[#%d.%d])"
911 + "put_dl_info(%p[#%d.%d])"
912 + 5 20 "alloc_dl_info(%p,%d)*"
913 + 6 40 "__hash_dl_info: %p[#%d]"
914 + "__unhash_dl_info: %p[#%d]"
915 + 7 80 "locate_dl_info(%p,#%d) = %p"
919 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
920 + "new_dqhash: %p [#0x%08x]"
921 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
922 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
923 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
924 + "vroot_get_real_bdev not set"
925 + 1 2 "cow_break_link(»%s«)"
927 + 2 4 "dentry_open(new): %p"
928 + "dentry_open(old): %p"
929 + "lookup_create(new): %p"
931 + "path_lookup(old): %d"
932 + "vfs_create(new): %d"
935 + 3 8 "fput(new_file=%p[#%d])"
936 + "fput(old_file=%p[#%d])"
937 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
938 + "vx_info_kill(%p[#%d],%d,%d)*"
939 + 5 20 "vs_reboot(%p[#%d],%d)"
940 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
944 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
945 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
946 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
947 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
948 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
949 + 6 40 "sk,egf: %p [#%d] (from %d)"
950 + "sk,egn: %p [#%d] (from %d)"
951 + "sk,req: %p [#%d] (from %d)"
952 + "sk: %p [#%d] (from %d)"
953 + "tw: %p [#%d] (from %d)"
954 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
955 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
959 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
960 + "alloc_nx_info(%d) = %p"
961 + "create_nx_info(%d) (dynamic rejected)"
962 + "create_nx_info(%d) = %p (already there)"
963 + "create_nx_info(%d) = %p (new)"
964 + "dealloc_nx_info(%p)"
965 + 1 2 "alloc_nx_info(%d)*"
966 + "create_nx_info(%d)*"
967 + 2 4 "get_nx_info(%p[#%d.%d])"
968 + "put_nx_info(%p[#%d.%d])"
969 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
970 + "clr_nx_info(%p[#%d.%d])"
971 + "init_nx_info(%p[#%d.%d])"
972 + "release_nx_info(%p[#%d.%d.%d]) %p"
973 + "set_nx_info(%p[#%d.%d])"
974 + 4 10 "__hash_nx_info: %p[#%d]"
975 + "__nx_dynamic_id: [#%d]"
976 + "__unhash_nx_info: %p[#%d.%d.%d]"
977 + 5 20 "moved task %p into nxi:%p[#%d]"
978 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
979 + "task_get_nx_info(%p)"
980 + 6 40 "nx_clear_persistent(%p[#%d])"
984 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
985 + 1 2 "quota_sync_dqh(%p,%d)"
986 + "sync_dquots(%p,%d)"
987 + "sync_dquots_dqh(%p,%d)"
988 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
992 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
993 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
994 + 4 10 "%s: (%s %s) returned %s with %d"
998 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
999 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
1003 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
1004 + "alloc_vx_info(%d) = %p"
1005 + "alloc_vx_info(%d)*"
1006 + "create_vx_info(%d) (dynamic rejected)"
1007 + "create_vx_info(%d) = %p (already there)"
1008 + "create_vx_info(%d) = %p (new)"
1009 + "dealloc_vx_info(%p)"
1010 + "loc_vx_info(%d) = %p (found)"
1011 + "loc_vx_info(%d) = %p (new)"
1012 + "loc_vx_info(%d) = %p (not available)"
1013 + 1 2 "create_vx_info(%d)*"
1014 + "loc_vx_info(%d)*"
1015 + 2 4 "get_vx_info(%p[#%d.%d])"
1016 + "put_vx_info(%p[#%d.%d])"
1017 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
1018 + "clr_vx_info(%p[#%d.%d])"
1019 + "init_vx_info(%p[#%d.%d])"
1020 + "release_vx_info(%p[#%d.%d.%d]) %p"
1021 + "set_vx_info(%p[#%d.%d])"
1022 + 4 10 "__hash_vx_info: %p[#%d]"
1023 + "__unhash_vx_info: %p[#%d.%d.%d]"
1024 + "__vx_dynamic_id: [#%d]"
1025 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
1026 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
1027 + "moved task %p into vxi:%p[#%d]"
1028 + "task_get_vx_info(%p)"
1029 + "vx_migrate_task(%p,%p[#%d.%d])"
1030 + 6 40 "vx_clear_persistent(%p[#%d])"
1031 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
1032 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
1033 + "vx_set_persistent(%p[#%d])"
1034 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
1035 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
1040 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
1041 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1043 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
1044 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
1045 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1046 diff -NurpP --minimal linux-2.6.37/drivers/block/Kconfig linux-2.6.37-vs2.3.0.37-rc2/drivers/block/Kconfig
1047 --- linux-2.6.37/drivers/block/Kconfig 2011-01-05 21:49:25.000000000 +0100
1048 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/block/Kconfig 2010-11-23 02:09:41.000000000 +0100
1049 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
1051 source "drivers/block/drbd/Kconfig"
1053 +config BLK_DEV_VROOT
1054 + tristate "Virtual Root device support"
1055 + depends on QUOTACTL
1057 + Saying Y here will allow you to use quota/fs ioctls on a shared
1058 + partition within a virtual server without compromising security.
1061 tristate "Network block device support"
1063 diff -NurpP --minimal linux-2.6.37/drivers/block/loop.c linux-2.6.37-vs2.3.0.37-rc2/drivers/block/loop.c
1064 --- linux-2.6.37/drivers/block/loop.c 2011-01-05 21:49:25.000000000 +0100
1065 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/block/loop.c 2010-11-23 02:15:37.000000000 +0100
1067 #include <linux/kthread.h>
1068 #include <linux/splice.h>
1069 #include <linux/sysfs.h>
1070 +#include <linux/vs_context.h>
1072 #include <asm/uaccess.h>
1074 @@ -907,6 +908,7 @@ static int loop_set_fd(struct loop_devic
1075 lo->lo_blocksize = lo_blocksize;
1076 lo->lo_device = bdev;
1077 lo->lo_flags = lo_flags;
1078 + lo->lo_xid = vx_current_xid();
1079 lo->lo_backing_file = file;
1080 lo->transfer = transfer_none;
1082 @@ -1037,6 +1039,7 @@ static int loop_clr_fd(struct loop_devic
1083 lo->lo_encrypt_key_size = 0;
1085 lo->lo_thread = NULL;
1087 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1088 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1089 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1090 @@ -1075,7 +1078,7 @@ loop_set_status(struct loop_device *lo,
1092 if (lo->lo_encrypt_key_size &&
1093 lo->lo_key_owner != uid &&
1094 - !capable(CAP_SYS_ADMIN))
1095 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1097 if (lo->lo_state != Lo_bound)
1099 @@ -1159,7 +1162,8 @@ loop_get_status(struct loop_device *lo,
1100 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1101 info->lo_encrypt_type =
1102 lo->lo_encryption ? lo->lo_encryption->number : 0;
1103 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1104 + if (lo->lo_encrypt_key_size &&
1105 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1106 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1107 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1108 lo->lo_encrypt_key_size);
1109 @@ -1505,6 +1509,9 @@ static int lo_open(struct block_device *
1111 struct loop_device *lo = bdev->bd_disk->private_data;
1113 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1116 mutex_lock(&loop_mutex);
1117 mutex_lock(&lo->lo_ctl_mutex);
1119 diff -NurpP --minimal linux-2.6.37/drivers/block/Makefile linux-2.6.37-vs2.3.0.37-rc2/drivers/block/Makefile
1120 --- linux-2.6.37/drivers/block/Makefile 2011-01-05 21:49:25.000000000 +0100
1121 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/block/Makefile 2010-11-23 02:09:41.000000000 +0100
1122 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
1123 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1124 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1125 obj-$(CONFIG_BLK_DEV_HD) += hd.o
1126 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1128 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1129 obj-$(CONFIG_BLK_DEV_DRBD) += drbd/
1130 diff -NurpP --minimal linux-2.6.37/drivers/block/vroot.c linux-2.6.37-vs2.3.0.37-rc2/drivers/block/vroot.c
1131 --- linux-2.6.37/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1132 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/block/vroot.c 2011-01-08 04:12:17.000000000 +0100
1135 + * linux/drivers/block/vroot.c
1137 + * written by Herbert Pötzl, 9/11/2002
1138 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1140 + * based on the loop.c code by Theodore Ts'o.
1142 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1143 + * Redistribution of this file is permitted under the
1144 + * GNU General Public License.
1148 +#include <linux/module.h>
1149 +#include <linux/moduleparam.h>
1150 +#include <linux/file.h>
1151 +#include <linux/major.h>
1152 +#include <linux/blkdev.h>
1153 +#include <linux/slab.h>
1155 +#include <linux/vroot.h>
1156 +#include <linux/vs_context.h>
1159 +static int max_vroot = 8;
1161 +static struct vroot_device *vroot_dev;
1162 +static struct gendisk **disks;
1165 +static int vroot_set_dev(
1166 + struct vroot_device *vr,
1167 + struct block_device *bdev,
1170 + struct block_device *real_bdev;
1171 + struct file *file;
1172 + struct inode *inode;
1176 + if (vr->vr_state != Vr_unbound)
1185 + inode = file->f_dentry->d_inode;
1188 + if (S_ISBLK(inode->i_mode)) {
1189 + real_bdev = inode->i_bdev;
1190 + vr->vr_device = real_bdev;
1191 + __iget(real_bdev->bd_inode);
1195 + vxdprintk(VXD_CBIT(misc, 0),
1196 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1197 + vr->vr_number, VXD_DEV(real_bdev));
1199 + vr->vr_state = Vr_bound;
1208 +static int vroot_clr_dev(
1209 + struct vroot_device *vr,
1210 + struct block_device *bdev)
1212 + struct block_device *real_bdev;
1214 + if (vr->vr_state != Vr_bound)
1216 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1219 + real_bdev = vr->vr_device;
1221 + vxdprintk(VXD_CBIT(misc, 0),
1222 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1223 + vr->vr_number, VXD_DEV(real_bdev));
1226 + vr->vr_state = Vr_unbound;
1227 + vr->vr_device = NULL;
1232 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1233 + unsigned int cmd, unsigned long arg)
1235 + struct vroot_device *vr = bdev->bd_disk->private_data;
1238 + down(&vr->vr_ctl_mutex);
1240 + case VROOT_SET_DEV:
1241 + err = vroot_set_dev(vr, bdev, arg);
1243 + case VROOT_CLR_DEV:
1244 + err = vroot_clr_dev(vr, bdev);
1250 + up(&vr->vr_ctl_mutex);
1254 +static int vr_open(struct block_device *bdev, fmode_t mode)
1256 + struct vroot_device *vr = bdev->bd_disk->private_data;
1258 + down(&vr->vr_ctl_mutex);
1260 + up(&vr->vr_ctl_mutex);
1264 +static int vr_release(struct gendisk *disk, fmode_t mode)
1266 + struct vroot_device *vr = disk->private_data;
1268 + down(&vr->vr_ctl_mutex);
1270 + up(&vr->vr_ctl_mutex);
1274 +static struct block_device_operations vr_fops = {
1275 + .owner = THIS_MODULE,
1277 + .release = vr_release,
1278 + .ioctl = vr_ioctl,
1281 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1283 + struct inode *inode = bdev->bd_inode;
1284 + struct vroot_device *vr;
1285 + struct block_device *real_bdev;
1286 + int minor = iminor(inode);
1288 + vr = &vroot_dev[minor];
1289 + real_bdev = vr->vr_device;
1291 + vxdprintk(VXD_CBIT(misc, 0),
1292 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1293 + vr->vr_number, VXD_DEV(real_bdev));
1295 + if (vr->vr_state != Vr_bound)
1296 + return ERR_PTR(-ENXIO);
1298 + __iget(real_bdev->bd_inode);
1303 + * And now the modules code and kernel interface.
1306 +module_param(max_vroot, int, 0);
1308 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1309 +MODULE_LICENSE("GPL");
1310 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1312 +MODULE_AUTHOR ("Herbert Pötzl");
1313 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1316 +int __init vroot_init(void)
1320 + if (max_vroot < 1 || max_vroot > 256) {
1321 + max_vroot = MAX_VROOT_DEFAULT;
1322 + printk(KERN_WARNING "vroot: invalid max_vroot "
1323 + "(must be between 1 and 256), "
1324 + "using default (%d)\n", max_vroot);
1327 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1331 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1334 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1336 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1340 + for (i = 0; i < max_vroot; i++) {
1341 + disks[i] = alloc_disk(1);
1344 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1345 + if (!disks[i]->queue)
1349 + for (i = 0; i < max_vroot; i++) {
1350 + struct vroot_device *vr = &vroot_dev[i];
1351 + struct gendisk *disk = disks[i];
1353 + memset(vr, 0, sizeof(*vr));
1354 + sema_init(&vr->vr_ctl_mutex, 1);
1355 + vr->vr_number = i;
1356 + disk->major = VROOT_MAJOR;
1357 + disk->first_minor = i;
1358 + disk->fops = &vr_fops;
1359 + sprintf(disk->disk_name, "vroot%d", i);
1360 + disk->private_data = vr;
1363 + err = register_vroot_grb(&__vroot_get_real_bdev);
1367 + for (i = 0; i < max_vroot; i++)
1368 + add_disk(disks[i]);
1369 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1374 + put_disk(disks[i]);
1379 + unregister_blkdev(VROOT_MAJOR, "vroot");
1380 + printk(KERN_ERR "vroot: ran out of memory\n");
1384 +void vroot_exit(void)
1388 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1389 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1391 + for (i = 0; i < max_vroot; i++) {
1392 + del_gendisk(disks[i]);
1393 + put_disk(disks[i]);
1395 + unregister_blkdev(VROOT_MAJOR, "vroot");
1401 +module_init(vroot_init);
1402 +module_exit(vroot_exit);
1406 +static int __init max_vroot_setup(char *str)
1408 + max_vroot = simple_strtol(str, NULL, 0);
1412 +__setup("max_vroot=", max_vroot_setup);
1416 diff -NurpP --minimal linux-2.6.37/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/r100_reg_safe.h
1417 --- linux-2.6.37/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1418 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/r100_reg_safe.h 2010-11-23 02:09:41.000000000 +0100
1420 +static const unsigned r100_reg_safe_bm[102] = {
1421 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1422 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1423 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1424 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1425 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1426 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1427 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1428 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1429 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1430 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1431 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1432 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1433 + 0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1434 + 0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1435 + 0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
1436 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1437 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
1438 + 0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
1439 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1440 + 0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1441 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1442 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1443 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1444 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1445 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1446 + 0xFFFFFFFF, 0xFFFFFFEF,
1448 diff -NurpP --minimal linux-2.6.37/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/r200_reg_safe.h
1449 --- linux-2.6.37/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1450 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/r200_reg_safe.h 2010-11-23 02:09:41.000000000 +0100
1452 +static const unsigned r200_reg_safe_bm[102] = {
1453 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1454 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1455 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1456 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1457 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1458 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1459 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1460 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1461 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1462 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1463 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1464 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1465 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1466 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1467 + 0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
1468 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1469 + 0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
1470 + 0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
1471 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1472 + 0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1473 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1474 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1475 + 0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
1476 + 0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
1477 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1478 + 0xFFFFFE3F, 0xFFFFFFEF,
1480 diff -NurpP --minimal linux-2.6.37/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/r300_reg_safe.h
1481 --- linux-2.6.37/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1482 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/r300_reg_safe.h 2010-11-23 02:09:41.000000000 +0100
1484 +static const unsigned r300_reg_safe_bm[159] = {
1485 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1486 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1487 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1488 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1489 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1490 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1491 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1492 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1493 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1494 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1495 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1496 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1497 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1498 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1499 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1500 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1501 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1502 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1503 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1504 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1505 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1506 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1507 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1508 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1509 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1510 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1511 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1512 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1513 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1514 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1515 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1516 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1517 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1518 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1519 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1520 + 0x00000000, 0x0000C100, 0x00000000, 0x00000000,
1521 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1522 + 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
1523 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1524 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1526 diff -NurpP --minimal linux-2.6.37/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/r420_reg_safe.h
1527 --- linux-2.6.37/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1528 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/r420_reg_safe.h 2010-11-23 02:09:41.000000000 +0100
1530 +static const unsigned r420_reg_safe_bm[159] = {
1531 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1532 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1533 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1534 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1535 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1536 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1537 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1538 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1539 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1540 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1541 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1542 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1543 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1544 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1545 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1546 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1547 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1548 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1549 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1550 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1551 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1552 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1553 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1554 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1555 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1556 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1557 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1558 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1559 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1560 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1561 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1562 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1563 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1564 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1565 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1566 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1567 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1568 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1569 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1570 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
1572 diff -NurpP --minimal linux-2.6.37/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/rn50_reg_safe.h
1573 --- linux-2.6.37/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1574 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/rn50_reg_safe.h 2010-11-23 02:09:41.000000000 +0100
1576 +static const unsigned rn50_reg_safe_bm[102] = {
1577 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1578 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1579 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1580 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1581 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1582 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1583 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1584 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1585 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1586 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1587 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1588 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1589 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1590 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1591 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1592 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1593 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1594 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1595 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1596 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1597 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1598 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1599 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1600 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1601 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1602 + 0xFFFFFFFF, 0xFFFFFFFF,
1604 diff -NurpP --minimal linux-2.6.37/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/rs600_reg_safe.h
1605 --- linux-2.6.37/drivers/gpu/drm/radeon/rs600_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1606 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/rs600_reg_safe.h 2010-11-23 02:09:41.000000000 +0100
1608 +static const unsigned rs600_reg_safe_bm[219] = {
1609 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1610 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1611 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1612 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1613 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1614 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1615 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1616 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1617 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1618 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1619 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1620 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1621 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1622 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1623 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1624 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1625 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1626 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1627 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1628 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1629 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1630 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1631 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1632 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1633 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1634 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1635 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1636 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1637 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1638 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1639 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1640 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1641 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
1642 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
1643 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1644 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
1645 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1646 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
1647 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1648 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
1649 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1650 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1651 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1652 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1653 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1654 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1655 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1656 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1657 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1658 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1659 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1660 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1661 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1662 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1663 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1665 diff -NurpP --minimal linux-2.6.37/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/rv515_reg_safe.h
1666 --- linux-2.6.37/drivers/gpu/drm/radeon/rv515_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
1667 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/gpu/drm/radeon/rv515_reg_safe.h 2010-11-23 02:09:41.000000000 +0100
1669 +static const unsigned rv515_reg_safe_bm[219] = {
1670 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1671 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1672 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1673 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1674 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1675 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1676 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1677 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1678 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1679 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1680 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
1681 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
1682 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1683 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1684 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
1685 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1686 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
1687 + 0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
1688 + 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
1689 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1690 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1691 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1692 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1693 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1694 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1695 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1696 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1697 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1698 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1699 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1700 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1701 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1702 + 0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
1703 + 0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
1704 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
1705 + 0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
1706 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1707 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
1708 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1709 + 0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
1710 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1711 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1712 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1713 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1714 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1715 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1716 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1717 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1718 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1719 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1720 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1721 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1722 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1723 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1724 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
1726 diff -NurpP --minimal linux-2.6.37/drivers/infiniband/core/addr.c linux-2.6.37-vs2.3.0.37-rc2/drivers/infiniband/core/addr.c
1727 --- linux-2.6.37/drivers/infiniband/core/addr.c 2010-10-21 13:07:05.000000000 +0200
1728 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/infiniband/core/addr.c 2010-11-23 02:09:41.000000000 +0100
1729 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
1731 if (ipv6_addr_any(&fl.fl6_src)) {
1732 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1733 - &fl.fl6_dst, 0, &fl.fl6_src);
1734 + &fl.fl6_dst, 0, &fl.fl6_src, NULL);
1738 diff -NurpP --minimal linux-2.6.37/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.37-vs2.3.0.37-rc2/drivers/infiniband/hw/ipath/ipath_user_pages.c
1739 --- linux-2.6.37/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-07-07 18:31:19.000000000 +0200
1740 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-11-23 02:09:41.000000000 +0100
1742 #include <linux/device.h>
1743 #include <linux/slab.h>
1744 #include <linux/sched.h>
1745 +#include <linux/vs_memory.h>
1747 #include "ipath_kernel.h"
1749 diff -NurpP --minimal linux-2.6.37/drivers/md/dm.c linux-2.6.37-vs2.3.0.37-rc2/drivers/md/dm.c
1750 --- linux-2.6.37/drivers/md/dm.c 2011-01-05 21:49:35.000000000 +0100
1751 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/md/dm.c 2010-11-23 02:18:36.000000000 +0100
1753 #include <linux/idr.h>
1754 #include <linux/hdreg.h>
1755 #include <linux/delay.h>
1756 +#include <linux/vs_base.h>
1758 #include <trace/events/block.h>
1760 @@ -120,6 +121,7 @@ struct mapped_device {
1763 atomic_t open_count;
1766 unsigned long flags;
1768 @@ -327,6 +329,7 @@ int dm_deleting_md(struct mapped_device
1769 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1771 struct mapped_device *md;
1774 mutex_lock(&dm_mutex);
1775 spin_lock(&_minor_lock);
1776 @@ -336,19 +339,20 @@ static int dm_blk_open(struct block_devi
1779 if (test_bit(DMF_FREEING, &md->flags) ||
1780 - dm_deleting_md(md)) {
1782 + dm_deleting_md(md))
1786 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1791 atomic_inc(&md->open_count);
1795 spin_unlock(&_minor_lock);
1796 mutex_unlock(&dm_mutex);
1798 - return md ? 0 : -ENXIO;
1802 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1803 @@ -566,6 +570,14 @@ int dm_set_geometry(struct mapped_device
1808 + * Get the xid associated with a dm device
1810 +xid_t dm_get_xid(struct mapped_device *md)
1815 /*-----------------------------------------------------------------
1817 * A more elegant soln is in the works that uses the queue
1818 @@ -1859,6 +1871,7 @@ static struct mapped_device *alloc_dev(i
1819 INIT_LIST_HEAD(&md->uevent_list);
1820 spin_lock_init(&md->uevent_lock);
1822 + md->xid = vx_current_xid();
1823 md->queue = blk_alloc_queue(GFP_KERNEL);
1826 diff -NurpP --minimal linux-2.6.37/drivers/md/dm.h linux-2.6.37-vs2.3.0.37-rc2/drivers/md/dm.h
1827 --- linux-2.6.37/drivers/md/dm.h 2010-10-21 13:07:07.000000000 +0200
1828 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/md/dm.h 2010-11-23 02:09:41.000000000 +0100
1829 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1831 struct dm_md_mempools;
1833 +xid_t dm_get_xid(struct mapped_device *md);
1835 /*-----------------------------------------------------------------
1836 * Internal table functions.
1837 *---------------------------------------------------------------*/
1838 diff -NurpP --minimal linux-2.6.37/drivers/md/dm-ioctl.c linux-2.6.37-vs2.3.0.37-rc2/drivers/md/dm-ioctl.c
1839 --- linux-2.6.37/drivers/md/dm-ioctl.c 2011-01-05 21:49:35.000000000 +0100
1840 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/md/dm-ioctl.c 2010-11-23 02:09:41.000000000 +0100
1842 #include <linux/dm-ioctl.h>
1843 #include <linux/hdreg.h>
1844 #include <linux/compat.h>
1845 +#include <linux/vs_context.h>
1847 #include <asm/uaccess.h>
1849 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1850 unsigned int h = hash_str(str);
1852 list_for_each_entry (hc, _name_buckets + h, name_list)
1853 - if (!strcmp(hc->name, str)) {
1854 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1855 + !strcmp(hc->name, str)) {
1859 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1860 unsigned int h = hash_str(str);
1862 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1863 - if (!strcmp(hc->uuid, str)) {
1864 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1865 + !strcmp(hc->uuid, str)) {
1869 @@ -377,6 +380,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1871 static int remove_all(struct dm_ioctl *param, size_t param_size)
1873 + if (!vx_check(0, VS_ADMIN))
1876 dm_hash_remove_all(1);
1877 param->data_size = 0;
1879 @@ -424,6 +430,8 @@ static int list_devices(struct dm_ioctl
1881 for (i = 0; i < NUM_BUCKETS; i++) {
1882 list_for_each_entry (hc, _name_buckets + i, name_list) {
1883 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1885 needed += sizeof(struct dm_name_list);
1886 needed += strlen(hc->name) + 1;
1887 needed += ALIGN_MASK;
1888 @@ -447,6 +455,8 @@ static int list_devices(struct dm_ioctl
1890 for (i = 0; i < NUM_BUCKETS; i++) {
1891 list_for_each_entry (hc, _name_buckets + i, name_list) {
1892 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1895 old_nl->next = (uint32_t) ((void *) nl -
1897 @@ -681,10 +691,11 @@ static struct hash_cell *__find_device_h
1901 - mdptr = dm_get_mdptr(md);
1902 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1903 + mdptr = dm_get_mdptr(md);
1911 @@ -1513,8 +1524,8 @@ static int ctl_ioctl(uint command, struc
1915 - /* only root can play with this */
1916 - if (!capable(CAP_SYS_ADMIN))
1917 + /* only root and certain contexts can play with this */
1918 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1921 if (_IOC_TYPE(command) != DM_IOCTL)
1922 diff -NurpP --minimal linux-2.6.37/drivers/net/tun.c linux-2.6.37-vs2.3.0.37-rc2/drivers/net/tun.c
1923 --- linux-2.6.37/drivers/net/tun.c 2010-10-21 13:07:15.000000000 +0200
1924 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/net/tun.c 2010-11-23 02:09:41.000000000 +0100
1926 #include <linux/nsproxy.h>
1927 #include <linux/virtio_net.h>
1928 #include <linux/rcupdate.h>
1929 +#include <linux/vs_network.h>
1930 #include <net/net_namespace.h>
1931 #include <net/netns/generic.h>
1932 #include <net/rtnetlink.h>
1933 @@ -103,6 +104,7 @@ struct tun_struct {
1939 struct net_device *dev;
1940 struct fasync_struct *fasync;
1941 @@ -853,6 +855,7 @@ static void tun_setup(struct net_device
1945 + tun->nid = current->nid;
1947 dev->ethtool_ops = &tun_ethtool_ops;
1948 dev->destructor = tun_free_netdev;
1949 @@ -1003,7 +1006,7 @@ static int tun_set_iff(struct net *net,
1951 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1952 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1953 - !capable(CAP_NET_ADMIN))
1954 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1956 err = security_tun_dev_attach(tun->socket.sk);
1958 @@ -1017,7 +1020,7 @@ static int tun_set_iff(struct net *net,
1960 unsigned long flags = 0;
1962 - if (!capable(CAP_NET_ADMIN))
1963 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1965 err = security_tun_dev_create();
1967 @@ -1087,6 +1090,9 @@ static int tun_set_iff(struct net *net,
1969 sk->sk_destruct = tun_sock_destruct;
1971 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1974 err = tun_attach(tun, file);
1977 @@ -1278,6 +1284,16 @@ static long __tun_chr_ioctl(struct file
1978 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
1982 + if (!capable(CAP_CONTEXT))
1985 + /* Set nid owner of the device */
1986 + tun->nid = (nid_t) arg;
1988 + DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
1992 /* Only allow setting the type when the interface is down */
1993 if (tun->dev->flags & IFF_UP) {
1994 diff -NurpP --minimal linux-2.6.37/drivers/tty/sysrq.c linux-2.6.37-vs2.3.0.37-rc2/drivers/tty/sysrq.c
1995 --- linux-2.6.37/drivers/tty/sysrq.c 2011-01-05 21:50:13.000000000 +0100
1996 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/tty/sysrq.c 2010-11-23 02:09:41.000000000 +0100
1998 #include <linux/oom.h>
1999 #include <linux/slab.h>
2000 #include <linux/input.h>
2001 +#include <linux/vserver/debug.h>
2003 #include <asm/ptrace.h>
2004 #include <asm/irq_regs.h>
2005 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
2006 .enable_mask = SYSRQ_ENABLE_RTNICE,
2010 +#ifdef CONFIG_VSERVER_DEBUG
2011 +static void sysrq_handle_vxinfo(int key)
2013 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
2016 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2017 + .handler = sysrq_handle_vxinfo,
2018 + .help_msg = "conteXt",
2019 + .action_msg = "Show Context Info",
2020 + .enable_mask = SYSRQ_ENABLE_DUMP,
2024 /* Key Operations table and lock */
2025 static DEFINE_SPINLOCK(sysrq_key_table_lock);
2027 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
2029 &sysrq_showstate_blocked_op, /* w */
2030 /* x: May be registered on ppc/powerpc for xmon */
2031 +#ifdef CONFIG_VSERVER_DEBUG
2032 + &sysrq_showvxinfo_op, /* x */
2036 /* y: May be registered on sparc64 for global register dump */
2038 &sysrq_ftrace_dump_op, /* z */
2039 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
2041 else if ((key >= 'a') && (key <= 'z'))
2042 retval = key + 10 - 'a';
2043 + else if ((key >= 'A') && (key <= 'Z'))
2044 + retval = key + 10 - 'A';
2048 diff -NurpP --minimal linux-2.6.37/drivers/tty/tty_io.c linux-2.6.37-vs2.3.0.37-rc2/drivers/tty/tty_io.c
2049 --- linux-2.6.37/drivers/tty/tty_io.c 2011-01-05 21:50:13.000000000 +0100
2050 +++ linux-2.6.37-vs2.3.0.37-rc2/drivers/tty/tty_io.c 2011-01-05 22:30:36.000000000 +0100
2053 #include <linux/kmod.h>
2054 #include <linux/nsproxy.h>
2055 +#include <linux/vs_pid.h>
2057 #undef TTY_DEBUG_HANGUP
2059 @@ -2057,7 +2058,8 @@ static int tiocsti(struct tty_struct *tt
2061 struct tty_ldisc *ld;
2063 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
2064 + if (((current->signal->tty != tty) &&
2065 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
2067 if (get_user(ch, p))
2069 @@ -2345,6 +2347,7 @@ static int tiocspgrp(struct tty_struct *
2071 if (get_user(pgrp_nr, p))
2073 + pgrp_nr = vx_rmap_pid(pgrp_nr);
2077 diff -NurpP --minimal linux-2.6.37/fs/attr.c linux-2.6.37-vs2.3.0.37-rc2/fs/attr.c
2078 --- linux-2.6.37/fs/attr.c 2010-10-21 13:07:47.000000000 +0200
2079 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/attr.c 2010-11-23 02:09:41.000000000 +0100
2081 #include <linux/fsnotify.h>
2082 #include <linux/fcntl.h>
2083 #include <linux/security.h>
2084 +#include <linux/proc_fs.h>
2085 +#include <linux/devpts_fs.h>
2086 +#include <linux/vs_tag.h>
2089 * inode_change_ok - check if attribute changes to an inode are allowed
2090 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
2094 + /* check for inode tag permission */
2095 + if (dx_permission(inode, MAY_WRITE))
2100 EXPORT_SYMBOL(inode_change_ok);
2101 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
2102 inode->i_uid = attr->ia_uid;
2103 if (ia_valid & ATTR_GID)
2104 inode->i_gid = attr->ia_gid;
2105 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2106 + inode->i_tag = attr->ia_tag;
2107 if (ia_valid & ATTR_ATIME)
2108 inode->i_atime = timespec_trunc(attr->ia_atime,
2109 inode->i_sb->s_time_gran);
2110 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
2111 struct timespec now;
2112 unsigned int ia_valid = attr->ia_valid;
2114 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
2115 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
2116 + ATTR_TAG | ATTR_TIMES_SET)) {
2117 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2120 diff -NurpP --minimal linux-2.6.37/fs/binfmt_aout.c linux-2.6.37-vs2.3.0.37-rc2/fs/binfmt_aout.c
2121 --- linux-2.6.37/fs/binfmt_aout.c 2010-10-21 13:07:47.000000000 +0200
2122 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/binfmt_aout.c 2010-11-23 02:09:41.000000000 +0100
2124 #include <linux/init.h>
2125 #include <linux/coredump.h>
2126 #include <linux/slab.h>
2127 +#include <linux/vs_memory.h>
2129 #include <asm/system.h>
2130 #include <asm/uaccess.h>
2131 diff -NurpP --minimal linux-2.6.37/fs/binfmt_elf.c linux-2.6.37-vs2.3.0.37-rc2/fs/binfmt_elf.c
2132 --- linux-2.6.37/fs/binfmt_elf.c 2011-01-05 21:50:20.000000000 +0100
2133 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/binfmt_elf.c 2010-11-23 02:09:41.000000000 +0100
2135 #include <linux/elf.h>
2136 #include <linux/utsname.h>
2137 #include <linux/coredump.h>
2138 +#include <linux/vs_memory.h>
2139 #include <asm/uaccess.h>
2140 #include <asm/param.h>
2141 #include <asm/page.h>
2142 diff -NurpP --minimal linux-2.6.37/fs/binfmt_flat.c linux-2.6.37-vs2.3.0.37-rc2/fs/binfmt_flat.c
2143 --- linux-2.6.37/fs/binfmt_flat.c 2010-08-02 16:52:47.000000000 +0200
2144 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/binfmt_flat.c 2010-11-23 02:09:41.000000000 +0100
2146 #include <linux/init.h>
2147 #include <linux/flat.h>
2148 #include <linux/syscalls.h>
2149 +#include <linux/vs_memory.h>
2151 #include <asm/byteorder.h>
2152 #include <asm/system.h>
2153 diff -NurpP --minimal linux-2.6.37/fs/binfmt_som.c linux-2.6.37-vs2.3.0.37-rc2/fs/binfmt_som.c
2154 --- linux-2.6.37/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
2155 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/binfmt_som.c 2010-11-23 02:09:41.000000000 +0100
2157 #include <linux/shm.h>
2158 #include <linux/personality.h>
2159 #include <linux/init.h>
2160 +#include <linux/vs_memory.h>
2162 #include <asm/uaccess.h>
2163 #include <asm/pgtable.h>
2164 diff -NurpP --minimal linux-2.6.37/fs/block_dev.c linux-2.6.37-vs2.3.0.37-rc2/fs/block_dev.c
2165 --- linux-2.6.37/fs/block_dev.c 2011-01-05 21:50:20.000000000 +0100
2166 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/block_dev.c 2010-11-23 02:09:41.000000000 +0100
2168 #include <linux/namei.h>
2169 #include <linux/log2.h>
2170 #include <linux/kmemleak.h>
2171 +#include <linux/vs_device.h>
2172 #include <asm/uaccess.h>
2173 #include "internal.h"
2175 @@ -544,6 +545,7 @@ struct block_device *bdget(dev_t dev)
2176 bdev->bd_invalidated = 0;
2177 inode->i_mode = S_IFBLK;
2178 inode->i_rdev = dev;
2179 + inode->i_mdev = dev;
2180 inode->i_bdev = bdev;
2181 inode->i_data.a_ops = &def_blk_aops;
2182 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2183 @@ -590,6 +592,11 @@ EXPORT_SYMBOL(bdput);
2184 static struct block_device *bd_acquire(struct inode *inode)
2186 struct block_device *bdev;
2189 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2191 + inode->i_mdev = mdev;
2193 spin_lock(&bdev_lock);
2194 bdev = inode->i_bdev;
2195 @@ -600,7 +607,7 @@ static struct block_device *bd_acquire(s
2197 spin_unlock(&bdev_lock);
2199 - bdev = bdget(inode->i_rdev);
2200 + bdev = bdget(mdev);
2202 spin_lock(&bdev_lock);
2203 if (!inode->i_bdev) {
2204 diff -NurpP --minimal linux-2.6.37/fs/btrfs/ctree.h linux-2.6.37-vs2.3.0.37-rc2/fs/btrfs/ctree.h
2205 --- linux-2.6.37/fs/btrfs/ctree.h 2011-01-05 21:50:20.000000000 +0100
2206 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/btrfs/ctree.h 2011-01-05 22:30:38.000000000 +0100
2207 @@ -574,11 +574,14 @@ struct btrfs_inode_item {
2208 /* modification sequence number for NFS */
2213 * a little future expansion, for more than this we can
2214 * just grow the inode item and version it
2216 - __le64 reserved[4];
2217 + __le16 reserved16;
2218 + __le32 reserved32;
2219 + __le64 reserved[3];
2220 struct btrfs_timespec atime;
2221 struct btrfs_timespec ctime;
2222 struct btrfs_timespec mtime;
2223 @@ -1236,6 +1239,8 @@ struct btrfs_root {
2224 #define BTRFS_MOUNT_CLEAR_CACHE (1 << 13)
2225 #define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14)
2227 +#define BTRFS_MOUNT_TAGGED (1 << 24)
2229 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
2230 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
2231 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2232 @@ -1456,6 +1461,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
2233 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
2234 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
2235 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
2236 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
2237 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
2238 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
2239 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
2240 @@ -1517,6 +1523,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
2242 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
2244 +#define BTRFS_INODE_IXUNLINK (1 << 24)
2245 +#define BTRFS_INODE_BARRIER (1 << 25)
2246 +#define BTRFS_INODE_COW (1 << 26)
2249 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
2251 @@ -2510,6 +2520,7 @@ extern const struct dentry_operations bt
2252 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
2253 void btrfs_update_iflags(struct inode *inode);
2254 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
2255 +int btrfs_sync_flags(struct inode *inode, int, int);
2258 int btrfs_sync_file(struct file *file, int datasync);
2259 diff -NurpP --minimal linux-2.6.37/fs/btrfs/disk-io.c linux-2.6.37-vs2.3.0.37-rc2/fs/btrfs/disk-io.c
2260 --- linux-2.6.37/fs/btrfs/disk-io.c 2011-01-05 21:50:20.000000000 +0100
2261 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/btrfs/disk-io.c 2011-01-05 22:30:38.000000000 +0100
2262 @@ -1733,6 +1733,9 @@ struct btrfs_root *open_ctree(struct sup
2266 + if (btrfs_test_opt(tree_root, TAGGED))
2267 + sb->s_flags |= MS_TAGGED;
2269 features = btrfs_super_incompat_flags(disk_super) &
2270 ~BTRFS_FEATURE_INCOMPAT_SUPP;
2272 diff -NurpP --minimal linux-2.6.37/fs/btrfs/inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/btrfs/inode.c
2273 --- linux-2.6.37/fs/btrfs/inode.c 2011-01-05 21:50:21.000000000 +0100
2274 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/btrfs/inode.c 2011-01-05 22:30:38.000000000 +0100
2276 #include <linux/posix_acl.h>
2277 #include <linux/falloc.h>
2278 #include <linux/slab.h>
2279 +#include <linux/vs_tag.h>
2283 #include "disk-io.h"
2284 @@ -2440,6 +2442,8 @@ static void btrfs_read_locked_inode(stru
2286 u64 alloc_group_block;
2292 path = btrfs_alloc_path();
2293 @@ -2456,8 +2460,13 @@ static void btrfs_read_locked_inode(stru
2295 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2296 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
2297 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2298 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2300 + uid = btrfs_inode_uid(leaf, inode_item);
2301 + gid = btrfs_inode_gid(leaf, inode_item);
2302 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2303 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2304 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2305 + btrfs_inode_tag(leaf, inode_item));
2306 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
2308 tspec = btrfs_inode_atime(inode_item);
2309 @@ -2539,8 +2548,15 @@ static void fill_inode_item(struct btrfs
2310 struct btrfs_inode_item *item,
2311 struct inode *inode)
2313 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
2314 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
2315 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2316 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2318 + btrfs_set_inode_uid(leaf, item, uid);
2319 + btrfs_set_inode_gid(leaf, item, gid);
2320 +#ifdef CONFIG_TAGGING_INTERN
2321 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
2324 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
2325 btrfs_set_inode_mode(leaf, item, inode->i_mode);
2326 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
2327 @@ -7228,6 +7244,7 @@ static const struct inode_operations btr
2328 .listxattr = btrfs_listxattr,
2329 .removexattr = btrfs_removexattr,
2330 .permission = btrfs_permission,
2331 + .sync_flags = btrfs_sync_flags,
2333 static const struct inode_operations btrfs_dir_ro_inode_operations = {
2334 .lookup = btrfs_lookup,
2335 @@ -7303,6 +7320,7 @@ static const struct inode_operations btr
2336 .permission = btrfs_permission,
2337 .fallocate = btrfs_fallocate,
2338 .fiemap = btrfs_fiemap,
2339 + .sync_flags = btrfs_sync_flags,
2341 static const struct inode_operations btrfs_special_inode_operations = {
2342 .getattr = btrfs_getattr,
2343 diff -NurpP --minimal linux-2.6.37/fs/btrfs/ioctl.c linux-2.6.37-vs2.3.0.37-rc2/fs/btrfs/ioctl.c
2344 --- linux-2.6.37/fs/btrfs/ioctl.c 2011-01-05 21:50:21.000000000 +0100
2345 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/btrfs/ioctl.c 2011-01-05 22:30:39.000000000 +0100
2346 @@ -68,10 +68,13 @@ static unsigned int btrfs_flags_to_ioctl
2348 unsigned int iflags = 0;
2350 - if (flags & BTRFS_INODE_SYNC)
2351 - iflags |= FS_SYNC_FL;
2352 if (flags & BTRFS_INODE_IMMUTABLE)
2353 iflags |= FS_IMMUTABLE_FL;
2354 + if (flags & BTRFS_INODE_IXUNLINK)
2355 + iflags |= FS_IXUNLINK_FL;
2357 + if (flags & BTRFS_INODE_SYNC)
2358 + iflags |= FS_SYNC_FL;
2359 if (flags & BTRFS_INODE_APPEND)
2360 iflags |= FS_APPEND_FL;
2361 if (flags & BTRFS_INODE_NODUMP)
2362 @@ -81,28 +84,78 @@ static unsigned int btrfs_flags_to_ioctl
2363 if (flags & BTRFS_INODE_DIRSYNC)
2364 iflags |= FS_DIRSYNC_FL;
2366 + if (flags & BTRFS_INODE_BARRIER)
2367 + iflags |= FS_BARRIER_FL;
2368 + if (flags & BTRFS_INODE_COW)
2369 + iflags |= FS_COW_FL;
2374 - * Update inode->i_flags based on the btrfs internal flags.
2375 + * Update inode->i_(v)flags based on the btrfs internal flags.
2377 void btrfs_update_iflags(struct inode *inode)
2379 struct btrfs_inode *ip = BTRFS_I(inode);
2381 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2382 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2383 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2385 - if (ip->flags & BTRFS_INODE_SYNC)
2386 - inode->i_flags |= S_SYNC;
2387 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2388 inode->i_flags |= S_IMMUTABLE;
2389 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2390 + inode->i_flags |= S_IXUNLINK;
2392 + if (ip->flags & BTRFS_INODE_SYNC)
2393 + inode->i_flags |= S_SYNC;
2394 if (ip->flags & BTRFS_INODE_APPEND)
2395 inode->i_flags |= S_APPEND;
2396 if (ip->flags & BTRFS_INODE_NOATIME)
2397 inode->i_flags |= S_NOATIME;
2398 if (ip->flags & BTRFS_INODE_DIRSYNC)
2399 inode->i_flags |= S_DIRSYNC;
2401 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2403 + if (ip->flags & BTRFS_INODE_BARRIER)
2404 + inode->i_vflags |= V_BARRIER;
2405 + if (ip->flags & BTRFS_INODE_COW)
2406 + inode->i_vflags |= V_COW;
2410 + * Update btrfs internal flags from inode->i_(v)flags.
2412 +void btrfs_update_flags(struct inode *inode)
2414 + struct btrfs_inode *ip = BTRFS_I(inode);
2416 + unsigned int flags = inode->i_flags;
2417 + unsigned int vflags = inode->i_vflags;
2419 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2420 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2421 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2422 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2424 + if (flags & S_IMMUTABLE)
2425 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2426 + if (flags & S_IXUNLINK)
2427 + ip->flags |= BTRFS_INODE_IXUNLINK;
2429 + if (flags & S_SYNC)
2430 + ip->flags |= BTRFS_INODE_SYNC;
2431 + if (flags & S_APPEND)
2432 + ip->flags |= BTRFS_INODE_APPEND;
2433 + if (flags & S_NOATIME)
2434 + ip->flags |= BTRFS_INODE_NOATIME;
2435 + if (flags & S_DIRSYNC)
2436 + ip->flags |= BTRFS_INODE_DIRSYNC;
2438 + if (vflags & V_BARRIER)
2439 + ip->flags |= BTRFS_INODE_BARRIER;
2440 + if (vflags & V_COW)
2441 + ip->flags |= BTRFS_INODE_COW;
2445 @@ -120,7 +173,7 @@ void btrfs_inherit_iflags(struct inode *
2446 flags = BTRFS_I(dir)->flags;
2448 if (S_ISREG(inode->i_mode))
2449 - flags &= ~BTRFS_INODE_DIRSYNC;
2450 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2451 else if (!S_ISDIR(inode->i_mode))
2452 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2454 @@ -128,6 +181,30 @@ void btrfs_inherit_iflags(struct inode *
2455 btrfs_update_iflags(inode);
2458 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2460 + struct btrfs_inode *ip = BTRFS_I(inode);
2461 + struct btrfs_root *root = ip->root;
2462 + struct btrfs_trans_handle *trans;
2465 + trans = btrfs_join_transaction(root, 1);
2468 + inode->i_flags = flags;
2469 + inode->i_vflags = vflags;
2470 + btrfs_update_flags(inode);
2472 + ret = btrfs_update_inode(trans, root, inode);
2475 + btrfs_update_iflags(inode);
2476 + inode->i_ctime = CURRENT_TIME;
2477 + btrfs_end_transaction(trans, root);
2482 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2484 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2485 @@ -150,6 +227,7 @@ static int btrfs_ioctl_setflags(struct f
2486 if (copy_from_user(&flags, arg, sizeof(flags)))
2489 + /* maybe add FS_IXUNLINK_FL ? */
2490 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
2491 FS_NOATIME_FL | FS_NODUMP_FL | \
2492 FS_SYNC_FL | FS_DIRSYNC_FL))
2493 @@ -162,7 +240,8 @@ static int btrfs_ioctl_setflags(struct f
2495 flags = btrfs_mask_flags(inode->i_mode, flags);
2496 oldflags = btrfs_flags_to_ioctl(ip->flags);
2497 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2498 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2499 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2500 if (!capable(CAP_LINUX_IMMUTABLE)) {
2503 @@ -173,14 +252,19 @@ static int btrfs_ioctl_setflags(struct f
2507 - if (flags & FS_SYNC_FL)
2508 - ip->flags |= BTRFS_INODE_SYNC;
2510 - ip->flags &= ~BTRFS_INODE_SYNC;
2511 if (flags & FS_IMMUTABLE_FL)
2512 ip->flags |= BTRFS_INODE_IMMUTABLE;
2514 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2515 + if (flags & FS_IXUNLINK_FL)
2516 + ip->flags |= BTRFS_INODE_IXUNLINK;
2518 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2520 + if (flags & FS_SYNC_FL)
2521 + ip->flags |= BTRFS_INODE_SYNC;
2523 + ip->flags &= ~BTRFS_INODE_SYNC;
2524 if (flags & FS_APPEND_FL)
2525 ip->flags |= BTRFS_INODE_APPEND;
2527 diff -NurpP --minimal linux-2.6.37/fs/btrfs/super.c linux-2.6.37-vs2.3.0.37-rc2/fs/btrfs/super.c
2528 --- linux-2.6.37/fs/btrfs/super.c 2011-01-05 21:50:21.000000000 +0100
2529 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/btrfs/super.c 2011-01-05 23:28:17.000000000 +0100
2530 @@ -70,8 +70,9 @@ enum {
2531 Opt_nodatacow, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, Opt_ssd,
2532 Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress,
2533 Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
2534 - Opt_discard, Opt_space_cache, Opt_clear_cache, Opt_err,
2535 + Opt_discard, Opt_space_cache, Opt_clear_cache,
2536 Opt_user_subvol_rm_allowed,
2537 + Opt_tag, Opt_notag, Opt_tagid, Opt_err,
2540 static match_table_t tokens = {
2541 @@ -98,6 +99,9 @@ static match_table_t tokens = {
2542 {Opt_space_cache, "space_cache"},
2543 {Opt_clear_cache, "clear_cache"},
2544 {Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"},
2546 + {Opt_notag, "notag"},
2547 + {Opt_tagid, "tagid=%u"},
2551 @@ -252,6 +256,22 @@ int btrfs_parse_options(struct btrfs_roo
2552 case Opt_user_subvol_rm_allowed:
2553 btrfs_set_opt(info->mount_opt, USER_SUBVOL_RM_ALLOWED);
2555 +#ifndef CONFIG_TAGGING_NONE
2557 + printk(KERN_INFO "btrfs: use tagging\n");
2558 + btrfs_set_opt(info->mount_opt, TAGGED);
2561 + printk(KERN_INFO "btrfs: disabled tagging\n");
2562 + btrfs_clear_opt(info->mount_opt, TAGGED);
2565 +#ifdef CONFIG_PROPAGATE
2568 + btrfs_set_opt(info->mount_opt, TAGGED);
2572 printk(KERN_INFO "btrfs: unrecognized mount option "
2574 @@ -724,6 +744,12 @@ static int btrfs_remount(struct super_bl
2578 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2579 + printk("btrfs: %s: tagging not permitted on remount.\n",
2584 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2587 diff -NurpP --minimal linux-2.6.37/fs/char_dev.c linux-2.6.37-vs2.3.0.37-rc2/fs/char_dev.c
2588 --- linux-2.6.37/fs/char_dev.c 2011-01-05 21:50:22.000000000 +0100
2589 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/char_dev.c 2010-11-23 02:09:41.000000000 +0100
2591 #include <linux/mutex.h>
2592 #include <linux/backing-dev.h>
2593 #include <linux/tty.h>
2594 +#include <linux/vs_context.h>
2595 +#include <linux/vs_device.h>
2597 #include "internal.h"
2599 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2601 struct cdev *new = NULL;
2605 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2607 + inode->i_mdev = mdev;
2609 spin_lock(&cdev_lock);
2612 struct kobject *kobj;
2615 spin_unlock(&cdev_lock);
2616 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2618 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2621 new = container_of(kobj, struct cdev, kobj);
2622 diff -NurpP --minimal linux-2.6.37/fs/dcache.c linux-2.6.37-vs2.3.0.37-rc2/fs/dcache.c
2623 --- linux-2.6.37/fs/dcache.c 2011-01-05 21:50:22.000000000 +0100
2624 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/dcache.c 2010-11-23 03:34:02.000000000 +0100
2626 #include <linux/bootmem.h>
2627 #include <linux/fs_struct.h>
2628 #include <linux/hardirq.h>
2629 +#include <linux/vs_limit.h>
2630 #include "internal.h"
2632 int sysctl_vfs_cache_pressure __read_mostly = 100;
2633 @@ -236,6 +237,8 @@ repeat:
2637 + vx_dentry_dec(dentry);
2640 * AV: ->d_delete() is _NOT_ allowed to block now.
2642 @@ -330,6 +333,7 @@ static inline struct dentry * __dget_loc
2644 atomic_inc(&dentry->d_count);
2645 dentry_lru_del(dentry);
2646 + vx_dentry_inc(dentry);
2650 @@ -940,6 +944,9 @@ struct dentry *d_alloc(struct dentry * p
2651 struct dentry *dentry;
2654 + if (!vx_dentry_avail(1))
2657 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2660 @@ -961,6 +968,7 @@ struct dentry *d_alloc(struct dentry * p
2661 dname[name->len] = 0;
2663 atomic_set(&dentry->d_count, 1);
2664 + vx_dentry_inc(dentry);
2665 dentry->d_flags = DCACHE_UNHASHED;
2666 spin_lock_init(&dentry->d_lock);
2667 dentry->d_inode = NULL;
2668 @@ -1445,6 +1453,7 @@ struct dentry * __d_lookup(struct dentry
2671 atomic_inc(&dentry->d_count);
2672 + vx_dentry_inc(dentry);
2674 spin_unlock(&dentry->d_lock);
2676 diff -NurpP --minimal linux-2.6.37/fs/devpts/inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/devpts/inode.c
2677 --- linux-2.6.37/fs/devpts/inode.c 2011-01-05 21:50:22.000000000 +0100
2678 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/devpts/inode.c 2010-11-23 02:09:41.000000000 +0100
2680 #include <linux/parser.h>
2681 #include <linux/fsnotify.h>
2682 #include <linux/seq_file.h>
2683 +#include <linux/vs_base.h>
2685 #define DEVPTS_DEFAULT_MODE 0600
2688 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2689 #define PTMX_MINOR 2
2691 +static int devpts_permission(struct inode *inode, int mask)
2693 + int ret = -EACCES;
2695 + /* devpts is xid tagged */
2696 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2697 + ret = generic_permission(inode, mask, NULL);
2701 +static struct inode_operations devpts_file_inode_operations = {
2702 + .permission = devpts_permission,
2705 extern int pty_limit; /* Config limit on Unix98 ptys */
2706 static DEFINE_MUTEX(allocated_ptys_lock);
2708 @@ -263,6 +278,25 @@ static int devpts_show_options(struct se
2712 +static int devpts_filter(struct dentry *de)
2714 + /* devpts is xid tagged */
2715 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2718 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2720 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2723 +static struct file_operations devpts_dir_operations = {
2724 + .open = dcache_dir_open,
2725 + .release = dcache_dir_close,
2726 + .llseek = dcache_dir_lseek,
2727 + .read = generic_read_dir,
2728 + .readdir = devpts_readdir,
2731 static const struct super_operations devpts_sops = {
2732 .statfs = simple_statfs,
2733 .remount_fs = devpts_remount,
2734 @@ -302,12 +336,15 @@ devpts_fill_super(struct super_block *s,
2735 inode = new_inode(s);
2740 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2741 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2742 inode->i_op = &simple_dir_inode_operations;
2743 - inode->i_fop = &simple_dir_operations;
2744 + inode->i_fop = &devpts_dir_operations;
2746 + /* devpts is xid tagged */
2747 + inode->i_tag = (tag_t)vx_current_xid();
2749 s->s_root = d_alloc_root(inode);
2751 @@ -493,6 +530,9 @@ int devpts_pty_new(struct inode *ptmx_in
2752 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2753 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2754 init_special_inode(inode, S_IFCHR|opts->mode, device);
2755 + /* devpts is xid tagged */
2756 + inode->i_tag = (tag_t)vx_current_xid();
2757 + inode->i_op = &devpts_file_inode_operations;
2758 inode->i_private = tty;
2759 tty->driver_data = inode;
2761 diff -NurpP --minimal linux-2.6.37/fs/ext2/balloc.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/balloc.c
2762 --- linux-2.6.37/fs/ext2/balloc.c 2011-01-05 21:50:22.000000000 +0100
2763 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/balloc.c 2010-11-23 02:09:41.000000000 +0100
2764 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2766 end = EXT2_BLOCKS_PER_GROUP(sb);
2769 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2772 diff -NurpP --minimal linux-2.6.37/fs/ext2/ext2.h linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/ext2.h
2773 --- linux-2.6.37/fs/ext2/ext2.h 2011-01-05 21:50:22.000000000 +0100
2774 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/ext2.h 2010-11-23 02:09:41.000000000 +0100
2775 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
2776 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2777 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2778 u64 start, u64 len);
2779 +extern int ext2_sync_flags(struct inode *, int, int);
2782 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2783 diff -NurpP --minimal linux-2.6.37/fs/ext2/file.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/file.c
2784 --- linux-2.6.37/fs/ext2/file.c 2010-08-02 16:52:48.000000000 +0200
2785 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/file.c 2010-11-23 02:09:41.000000000 +0100
2786 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2787 .setattr = ext2_setattr,
2788 .check_acl = ext2_check_acl,
2789 .fiemap = ext2_fiemap,
2790 + .sync_flags = ext2_sync_flags,
2792 diff -NurpP --minimal linux-2.6.37/fs/ext2/ialloc.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/ialloc.c
2793 --- linux-2.6.37/fs/ext2/ialloc.c 2010-10-21 13:07:48.000000000 +0200
2794 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/ialloc.c 2010-11-23 02:09:41.000000000 +0100
2796 #include <linux/backing-dev.h>
2797 #include <linux/buffer_head.h>
2798 #include <linux/random.h>
2799 +#include <linux/vs_tag.h>
2803 @@ -548,6 +549,7 @@ got:
2804 inode->i_mode = mode;
2805 inode->i_uid = current_fsuid();
2806 inode->i_gid = dir->i_gid;
2807 + inode->i_tag = dx_current_fstag(sb);
2809 inode_init_owner(inode, dir, mode);
2811 diff -NurpP --minimal linux-2.6.37/fs/ext2/inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/inode.c
2812 --- linux-2.6.37/fs/ext2/inode.c 2011-01-05 21:50:22.000000000 +0100
2813 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/inode.c 2010-11-23 02:09:41.000000000 +0100
2815 #include <linux/mpage.h>
2816 #include <linux/fiemap.h>
2817 #include <linux/namei.h>
2818 +#include <linux/vs_tag.h>
2822 @@ -1169,7 +1170,7 @@ static void ext2_truncate_blocks(struct
2824 if (ext2_inode_is_fast_symlink(inode))
2826 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2827 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2829 __ext2_truncate_blocks(inode, offset);
2831 @@ -1258,36 +1259,61 @@ void ext2_set_inode_flags(struct inode *
2833 unsigned int flags = EXT2_I(inode)->i_flags;
2835 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2836 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2837 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2840 + if (flags & EXT2_IMMUTABLE_FL)
2841 + inode->i_flags |= S_IMMUTABLE;
2842 + if (flags & EXT2_IXUNLINK_FL)
2843 + inode->i_flags |= S_IXUNLINK;
2845 if (flags & EXT2_SYNC_FL)
2846 inode->i_flags |= S_SYNC;
2847 if (flags & EXT2_APPEND_FL)
2848 inode->i_flags |= S_APPEND;
2849 - if (flags & EXT2_IMMUTABLE_FL)
2850 - inode->i_flags |= S_IMMUTABLE;
2851 if (flags & EXT2_NOATIME_FL)
2852 inode->i_flags |= S_NOATIME;
2853 if (flags & EXT2_DIRSYNC_FL)
2854 inode->i_flags |= S_DIRSYNC;
2856 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2858 + if (flags & EXT2_BARRIER_FL)
2859 + inode->i_vflags |= V_BARRIER;
2860 + if (flags & EXT2_COW_FL)
2861 + inode->i_vflags |= V_COW;
2864 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2865 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2867 unsigned int flags = ei->vfs_inode.i_flags;
2868 + unsigned int vflags = ei->vfs_inode.i_vflags;
2870 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2871 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2872 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2873 + EXT2_BARRIER_FL | EXT2_COW_FL);
2875 + if (flags & S_IMMUTABLE)
2876 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2877 + if (flags & S_IXUNLINK)
2878 + ei->i_flags |= EXT2_IXUNLINK_FL;
2880 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2881 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2883 ei->i_flags |= EXT2_SYNC_FL;
2884 if (flags & S_APPEND)
2885 ei->i_flags |= EXT2_APPEND_FL;
2886 - if (flags & S_IMMUTABLE)
2887 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2888 if (flags & S_NOATIME)
2889 ei->i_flags |= EXT2_NOATIME_FL;
2890 if (flags & S_DIRSYNC)
2891 ei->i_flags |= EXT2_DIRSYNC_FL;
2893 + if (vflags & V_BARRIER)
2894 + ei->i_flags |= EXT2_BARRIER_FL;
2895 + if (vflags & V_COW)
2896 + ei->i_flags |= EXT2_COW_FL;
2899 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2900 @@ -1297,6 +1323,8 @@ struct inode *ext2_iget (struct super_bl
2901 struct ext2_inode *raw_inode;
2902 struct inode *inode;
2908 inode = iget_locked(sb, ino);
2909 @@ -1315,12 +1343,17 @@ struct inode *ext2_iget (struct super_bl
2912 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2913 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2914 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2915 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2916 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2917 if (!(test_opt (inode->i_sb, NO_UID32))) {
2918 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2919 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2920 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2921 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2923 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2924 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2925 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2926 + le16_to_cpu(raw_inode->i_raw_tag));
2928 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2929 inode->i_size = le32_to_cpu(raw_inode->i_size);
2930 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2931 @@ -1418,8 +1451,8 @@ static int __ext2_write_inode(struct ino
2932 struct ext2_inode_info *ei = EXT2_I(inode);
2933 struct super_block *sb = inode->i_sb;
2934 ino_t ino = inode->i_ino;
2935 - uid_t uid = inode->i_uid;
2936 - gid_t gid = inode->i_gid;
2937 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2938 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2939 struct buffer_head * bh;
2940 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2942 @@ -1455,6 +1488,9 @@ static int __ext2_write_inode(struct ino
2943 raw_inode->i_uid_high = 0;
2944 raw_inode->i_gid_high = 0;
2946 +#ifdef CONFIG_TAGGING_INTERN
2947 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2949 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2950 raw_inode->i_size = cpu_to_le32(inode->i_size);
2951 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2952 @@ -1535,7 +1571,8 @@ int ext2_setattr(struct dentry *dentry,
2953 if (is_quota_modification(inode, iattr))
2954 dquot_initialize(inode);
2955 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2956 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2957 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2958 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2959 error = dquot_transfer(inode, iattr);
2962 diff -NurpP --minimal linux-2.6.37/fs/ext2/ioctl.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/ioctl.c
2963 --- linux-2.6.37/fs/ext2/ioctl.c 2009-09-10 15:26:21.000000000 +0200
2964 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/ioctl.c 2010-11-23 02:09:41.000000000 +0100
2966 #include <asm/uaccess.h>
2969 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2971 + inode->i_flags = flags;
2972 + inode->i_vflags = vflags;
2973 + ext2_get_inode_flags(EXT2_I(inode));
2974 + inode->i_ctime = CURRENT_TIME_SEC;
2975 + mark_inode_dirty(inode);
2979 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2981 struct inode *inode = filp->f_dentry->d_inode;
2982 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2984 flags = ext2_mask_flags(inode->i_mode, flags);
2986 + if (IS_BARRIER(inode)) {
2987 + vxwprintk_task(1, "messing with the barrier.");
2991 mutex_lock(&inode->i_mutex);
2992 /* Is it quota file? Do not allow user to mess with it */
2993 if (IS_NOQUOTA(inode)) {
2994 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2996 * This test looks nicer. Thanks to Pauline Middelink
2998 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2999 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3000 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3001 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
3002 if (!capable(CAP_LINUX_IMMUTABLE)) {
3003 mutex_unlock(&inode->i_mutex);
3005 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
3009 - flags = flags & EXT2_FL_USER_MODIFIABLE;
3010 + flags &= EXT2_FL_USER_MODIFIABLE;
3011 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
3012 ei->i_flags = flags;
3013 mutex_unlock(&inode->i_mutex);
3014 diff -NurpP --minimal linux-2.6.37/fs/ext2/namei.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/namei.c
3015 --- linux-2.6.37/fs/ext2/namei.c 2011-01-05 21:50:22.000000000 +0100
3016 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/namei.c 2010-11-23 02:09:41.000000000 +0100
3019 #include <linux/pagemap.h>
3020 #include <linux/quotaops.h>
3021 +#include <linux/vs_tag.h>
3025 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
3026 return ERR_PTR(-EIO);
3028 return ERR_CAST(inode);
3029 + dx_propagate_tag(nd, inode);
3033 @@ -418,6 +420,7 @@ const struct inode_operations ext2_dir_i
3035 .setattr = ext2_setattr,
3036 .check_acl = ext2_check_acl,
3037 + .sync_flags = ext2_sync_flags,
3040 const struct inode_operations ext2_special_inode_operations = {
3041 diff -NurpP --minimal linux-2.6.37/fs/ext2/super.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/super.c
3042 --- linux-2.6.37/fs/ext2/super.c 2011-01-05 21:50:22.000000000 +0100
3043 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext2/super.c 2010-11-23 02:09:41.000000000 +0100
3044 @@ -378,7 +378,8 @@ enum {
3045 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3046 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3047 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3048 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3049 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3050 + Opt_tag, Opt_notag, Opt_tagid
3053 static const match_table_t tokens = {
3054 @@ -406,6 +407,9 @@ static const match_table_t tokens = {
3056 {Opt_noacl, "noacl"},
3059 + {Opt_notag, "notag"},
3060 + {Opt_tagid, "tagid=%u"},
3061 {Opt_grpquota, "grpquota"},
3062 {Opt_ignore, "noquota"},
3063 {Opt_quota, "quota"},
3064 @@ -476,6 +480,20 @@ static int parse_options(char *options,
3066 set_opt (sbi->s_mount_opt, NO_UID32);
3068 +#ifndef CONFIG_TAGGING_NONE
3070 + set_opt (sbi->s_mount_opt, TAGGED);
3073 + clear_opt (sbi->s_mount_opt, TAGGED);
3076 +#ifdef CONFIG_PROPAGATE
3079 + set_opt (sbi->s_mount_opt, TAGGED);
3083 clear_opt (sbi->s_mount_opt, CHECK);
3085 @@ -834,6 +852,8 @@ static int ext2_fill_super(struct super_
3086 if (!parse_options((char *) data, sb))
3089 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3090 + sb->s_flags |= MS_TAGGED;
3091 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3092 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3094 @@ -1207,6 +1227,14 @@ static int ext2_remount (struct super_bl
3098 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3099 + !(sb->s_flags & MS_TAGGED)) {
3100 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3103 + goto restore_opts;
3106 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3107 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3109 diff -NurpP --minimal linux-2.6.37/fs/ext3/file.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/file.c
3110 --- linux-2.6.37/fs/ext3/file.c 2010-07-07 18:31:51.000000000 +0200
3111 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/file.c 2010-11-23 02:09:41.000000000 +0100
3112 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
3114 .check_acl = ext3_check_acl,
3115 .fiemap = ext3_fiemap,
3116 + .sync_flags = ext3_sync_flags,
3119 diff -NurpP --minimal linux-2.6.37/fs/ext3/ialloc.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/ialloc.c
3120 --- linux-2.6.37/fs/ext3/ialloc.c 2011-01-05 21:50:22.000000000 +0100
3121 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/ialloc.c 2010-11-23 02:09:41.000000000 +0100
3123 #include <linux/buffer_head.h>
3124 #include <linux/random.h>
3125 #include <linux/bitops.h>
3126 +#include <linux/vs_tag.h>
3128 #include <asm/byteorder.h>
3130 @@ -531,6 +532,7 @@ got:
3131 inode->i_mode = mode;
3132 inode->i_uid = current_fsuid();
3133 inode->i_gid = dir->i_gid;
3134 + inode->i_tag = dx_current_fstag(sb);
3136 inode_init_owner(inode, dir, mode);
3138 diff -NurpP --minimal linux-2.6.37/fs/ext3/inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/inode.c
3139 --- linux-2.6.37/fs/ext3/inode.c 2011-01-05 21:50:22.000000000 +0100
3140 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/inode.c 2010-11-23 02:09:41.000000000 +0100
3142 #include <linux/bio.h>
3143 #include <linux/fiemap.h>
3144 #include <linux/namei.h>
3145 +#include <linux/vs_tag.h>
3149 @@ -2392,7 +2393,7 @@ static void ext3_free_branches(handle_t
3151 int ext3_can_truncate(struct inode *inode)
3153 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3154 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3156 if (S_ISREG(inode->i_mode))
3158 @@ -2776,36 +2777,60 @@ void ext3_set_inode_flags(struct inode *
3160 unsigned int flags = EXT3_I(inode)->i_flags;
3162 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3163 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3164 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3166 + if (flags & EXT3_IMMUTABLE_FL)
3167 + inode->i_flags |= S_IMMUTABLE;
3168 + if (flags & EXT3_IXUNLINK_FL)
3169 + inode->i_flags |= S_IXUNLINK;
3171 if (flags & EXT3_SYNC_FL)
3172 inode->i_flags |= S_SYNC;
3173 if (flags & EXT3_APPEND_FL)
3174 inode->i_flags |= S_APPEND;
3175 - if (flags & EXT3_IMMUTABLE_FL)
3176 - inode->i_flags |= S_IMMUTABLE;
3177 if (flags & EXT3_NOATIME_FL)
3178 inode->i_flags |= S_NOATIME;
3179 if (flags & EXT3_DIRSYNC_FL)
3180 inode->i_flags |= S_DIRSYNC;
3182 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3184 + if (flags & EXT3_BARRIER_FL)
3185 + inode->i_vflags |= V_BARRIER;
3186 + if (flags & EXT3_COW_FL)
3187 + inode->i_vflags |= V_COW;
3190 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
3191 void ext3_get_inode_flags(struct ext3_inode_info *ei)
3193 unsigned int flags = ei->vfs_inode.i_flags;
3194 + unsigned int vflags = ei->vfs_inode.i_vflags;
3196 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
3197 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
3198 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
3199 + EXT3_BARRIER_FL | EXT3_COW_FL);
3201 + if (flags & S_IMMUTABLE)
3202 + ei->i_flags |= EXT3_IMMUTABLE_FL;
3203 + if (flags & S_IXUNLINK)
3204 + ei->i_flags |= EXT3_IXUNLINK_FL;
3206 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
3207 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
3209 ei->i_flags |= EXT3_SYNC_FL;
3210 if (flags & S_APPEND)
3211 ei->i_flags |= EXT3_APPEND_FL;
3212 - if (flags & S_IMMUTABLE)
3213 - ei->i_flags |= EXT3_IMMUTABLE_FL;
3214 if (flags & S_NOATIME)
3215 ei->i_flags |= EXT3_NOATIME_FL;
3216 if (flags & S_DIRSYNC)
3217 ei->i_flags |= EXT3_DIRSYNC_FL;
3219 + if (vflags & V_BARRIER)
3220 + ei->i_flags |= EXT3_BARRIER_FL;
3221 + if (vflags & V_COW)
3222 + ei->i_flags |= EXT3_COW_FL;
3225 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
3226 @@ -2819,6 +2844,8 @@ struct inode *ext3_iget(struct super_blo
3227 transaction_t *transaction;
3233 inode = iget_locked(sb, ino);
3235 @@ -2835,12 +2862,17 @@ struct inode *ext3_iget(struct super_blo
3237 raw_inode = ext3_raw_inode(&iloc);
3238 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3239 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3240 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3241 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3242 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3243 if(!(test_opt (inode->i_sb, NO_UID32))) {
3244 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3245 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3246 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3247 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3249 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3250 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3251 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3252 + le16_to_cpu(raw_inode->i_raw_tag));
3254 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3255 inode->i_size = le32_to_cpu(raw_inode->i_size);
3256 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3257 @@ -2995,6 +3027,8 @@ static int ext3_do_update_inode(handle_t
3258 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3259 struct ext3_inode_info *ei = EXT3_I(inode);
3260 struct buffer_head *bh = iloc->bh;
3261 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3262 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3263 int err = 0, rc, block;
3266 @@ -3009,29 +3043,32 @@ again:
3267 ext3_get_inode_flags(ei);
3268 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3269 if(!(test_opt(inode->i_sb, NO_UID32))) {
3270 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3271 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3272 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3273 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3275 * Fix up interoperability with old kernels. Otherwise, old inodes get
3276 * re-used with the upper 16 bits of the uid/gid intact
3279 raw_inode->i_uid_high =
3280 - cpu_to_le16(high_16_bits(inode->i_uid));
3281 + cpu_to_le16(high_16_bits(uid));
3282 raw_inode->i_gid_high =
3283 - cpu_to_le16(high_16_bits(inode->i_gid));
3284 + cpu_to_le16(high_16_bits(gid));
3286 raw_inode->i_uid_high = 0;
3287 raw_inode->i_gid_high = 0;
3290 raw_inode->i_uid_low =
3291 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3292 + cpu_to_le16(fs_high2lowuid(uid));
3293 raw_inode->i_gid_low =
3294 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3295 + cpu_to_le16(fs_high2lowgid(gid));
3296 raw_inode->i_uid_high = 0;
3297 raw_inode->i_gid_high = 0;
3299 +#ifdef CONFIG_TAGGING_INTERN
3300 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3302 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3303 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3304 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3305 @@ -3191,7 +3228,8 @@ int ext3_setattr(struct dentry *dentry,
3306 if (is_quota_modification(inode, attr))
3307 dquot_initialize(inode);
3308 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3309 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3310 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3311 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3314 /* (user+group)*(old+new) structure, inode write (sb,
3315 @@ -3213,6 +3251,8 @@ int ext3_setattr(struct dentry *dentry,
3316 inode->i_uid = attr->ia_uid;
3317 if (attr->ia_valid & ATTR_GID)
3318 inode->i_gid = attr->ia_gid;
3319 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3320 + inode->i_tag = attr->ia_tag;
3321 error = ext3_mark_inode_dirty(handle, inode);
3322 ext3_journal_stop(handle);
3324 diff -NurpP --minimal linux-2.6.37/fs/ext3/ioctl.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/ioctl.c
3325 --- linux-2.6.37/fs/ext3/ioctl.c 2009-06-11 17:13:03.000000000 +0200
3326 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/ioctl.c 2010-11-23 02:09:41.000000000 +0100
3330 #include <linux/fs.h>
3331 +#include <linux/mount.h>
3332 #include <linux/jbd.h>
3333 #include <linux/capability.h>
3334 #include <linux/ext3_fs.h>
3336 #include <linux/compat.h>
3337 #include <asm/uaccess.h>
3340 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
3342 + handle_t *handle = NULL;
3343 + struct ext3_iloc iloc;
3346 + handle = ext3_journal_start(inode, 1);
3347 + if (IS_ERR(handle))
3348 + return PTR_ERR(handle);
3350 + if (IS_SYNC(inode))
3351 + handle->h_sync = 1;
3352 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3356 + inode->i_flags = flags;
3357 + inode->i_vflags = vflags;
3358 + ext3_get_inode_flags(EXT3_I(inode));
3359 + inode->i_ctime = CURRENT_TIME_SEC;
3361 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3363 + ext3_journal_stop(handle);
3367 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3369 struct inode *inode = filp->f_dentry->d_inode;
3370 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
3372 flags = ext3_mask_flags(inode->i_mode, flags);
3374 + if (IS_BARRIER(inode)) {
3375 + vxwprintk_task(1, "messing with the barrier.");
3379 mutex_lock(&inode->i_mutex);
3381 /* Is it quota file? Do not allow user to mess with it */
3382 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3384 * This test looks nicer. Thanks to Pauline Middelink
3386 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3387 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3388 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3389 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3390 if (!capable(CAP_LINUX_IMMUTABLE))
3393 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3397 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3398 + flags &= EXT3_FL_USER_MODIFIABLE;
3399 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3400 ei->i_flags = flags;
3402 diff -NurpP --minimal linux-2.6.37/fs/ext3/namei.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/namei.c
3403 --- linux-2.6.37/fs/ext3/namei.c 2011-01-05 21:50:22.000000000 +0100
3404 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/namei.c 2010-11-23 02:09:41.000000000 +0100
3406 #include <linux/quotaops.h>
3407 #include <linux/buffer_head.h>
3408 #include <linux/bio.h>
3409 +#include <linux/vs_tag.h>
3413 @@ -912,6 +913,7 @@ restart:
3415 ll_rw_block(READ_META, 1, &bh);
3417 + dx_propagate_tag(nd, inode);
3419 if ((bh = bh_use[ra_ptr++]) == NULL)
3421 @@ -2465,6 +2467,7 @@ const struct inode_operations ext3_dir_i
3422 .removexattr = generic_removexattr,
3424 .check_acl = ext3_check_acl,
3425 + .sync_flags = ext3_sync_flags,
3428 const struct inode_operations ext3_special_inode_operations = {
3429 diff -NurpP --minimal linux-2.6.37/fs/ext3/super.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/super.c
3430 --- linux-2.6.37/fs/ext3/super.c 2011-01-05 21:50:23.000000000 +0100
3431 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext3/super.c 2010-11-23 02:09:41.000000000 +0100
3432 @@ -796,7 +796,8 @@ enum {
3433 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3434 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
3435 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
3436 - Opt_resize, Opt_usrquota, Opt_grpquota
3437 + Opt_resize, Opt_usrquota, Opt_grpquota,
3438 + Opt_tag, Opt_notag, Opt_tagid
3441 static const match_table_t tokens = {
3442 @@ -853,6 +854,9 @@ static const match_table_t tokens = {
3443 {Opt_barrier, "barrier"},
3444 {Opt_nobarrier, "nobarrier"},
3445 {Opt_resize, "resize"},
3447 + {Opt_notag, "notag"},
3448 + {Opt_tagid, "tagid=%u"},
3452 @@ -1005,6 +1009,20 @@ static int parse_options (char *options,
3454 set_opt (sbi->s_mount_opt, NO_UID32);
3456 +#ifndef CONFIG_TAGGING_NONE
3458 + set_opt (sbi->s_mount_opt, TAGGED);
3461 + clear_opt (sbi->s_mount_opt, TAGGED);
3464 +#ifdef CONFIG_PROPAGATE
3467 + set_opt (sbi->s_mount_opt, TAGGED);
3471 clear_opt (sbi->s_mount_opt, CHECK);
3473 @@ -1691,6 +1709,9 @@ static int ext3_fill_super (struct super
3477 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3478 + sb->s_flags |= MS_TAGGED;
3480 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3481 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3483 @@ -2575,6 +2596,14 @@ static int ext3_remount (struct super_bl
3484 if (test_opt(sb, ABORT))
3485 ext3_abort(sb, __func__, "Abort forced by user");
3487 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3488 + !(sb->s_flags & MS_TAGGED)) {
3489 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3492 + goto restore_opts;
3495 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3496 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3498 diff -NurpP --minimal linux-2.6.37/fs/ext4/ext4.h linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/ext4.h
3499 --- linux-2.6.37/fs/ext4/ext4.h 2011-01-05 21:50:23.000000000 +0100
3500 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/ext4.h 2011-01-05 22:32:19.000000000 +0100
3501 @@ -347,8 +347,12 @@ struct flex_groups {
3502 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3503 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3504 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3505 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3506 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3508 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3509 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3511 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3512 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3514 @@ -617,7 +621,8 @@ struct ext4_inode {
3515 __le16 l_i_file_acl_high;
3516 __le16 l_i_uid_high; /* these 2 fields */
3517 __le16 l_i_gid_high; /* were reserved2[0] */
3518 - __u32 l_i_reserved2;
3519 + __le16 l_i_tag; /* Context Tag */
3520 + __u16 l_i_reserved2;
3523 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3524 @@ -731,6 +736,7 @@ do { \
3525 #define i_gid_low i_gid
3526 #define i_uid_high osd2.linux2.l_i_uid_high
3527 #define i_gid_high osd2.linux2.l_i_gid_high
3528 +#define i_raw_tag osd2.linux2.l_i_tag
3529 #define i_reserved2 osd2.linux2.l_i_reserved2
3531 #elif defined(__GNU__)
3532 @@ -903,6 +909,7 @@ struct ext4_inode_info {
3533 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3534 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3535 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3536 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3537 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3538 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3539 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3540 @@ -2054,6 +2061,7 @@ extern int ext4_map_blocks(handle_t *han
3541 struct ext4_map_blocks *map, int flags);
3542 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3543 __u64 start, __u64 len);
3544 +extern int ext4_sync_flags(struct inode *, int, int);
3546 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3547 __u64 start_orig, __u64 start_donor,
3548 diff -NurpP --minimal linux-2.6.37/fs/ext4/file.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/file.c
3549 --- linux-2.6.37/fs/ext4/file.c 2011-01-05 21:50:23.000000000 +0100
3550 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/file.c 2010-11-23 02:09:41.000000000 +0100
3551 @@ -203,5 +203,6 @@ const struct inode_operations ext4_file_
3552 .check_acl = ext4_check_acl,
3553 .fallocate = ext4_fallocate,
3554 .fiemap = ext4_fiemap,
3555 + .sync_flags = ext4_sync_flags,
3558 diff -NurpP --minimal linux-2.6.37/fs/ext4/ialloc.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/ialloc.c
3559 --- linux-2.6.37/fs/ext4/ialloc.c 2011-01-05 21:50:23.000000000 +0100
3560 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/ialloc.c 2010-11-23 02:09:41.000000000 +0100
3562 #include <linux/random.h>
3563 #include <linux/bitops.h>
3564 #include <linux/blkdev.h>
3565 +#include <linux/vs_tag.h>
3566 #include <asm/byteorder.h>
3569 @@ -991,6 +992,7 @@ got:
3570 inode->i_mode = mode;
3571 inode->i_uid = current_fsuid();
3572 inode->i_gid = dir->i_gid;
3573 + inode->i_tag = dx_current_fstag(sb);
3575 inode_init_owner(inode, dir, mode);
3577 diff -NurpP --minimal linux-2.6.37/fs/ext4/inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/inode.c
3578 --- linux-2.6.37/fs/ext4/inode.c 2011-01-05 21:50:23.000000000 +0100
3579 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/inode.c 2011-01-05 22:30:39.000000000 +0100
3581 #include <linux/workqueue.h>
3582 #include <linux/kernel.h>
3583 #include <linux/slab.h>
3584 +#include <linux/vs_tag.h>
3586 #include "ext4_jbd2.h"
3588 @@ -4415,7 +4416,7 @@ static void ext4_free_branches(handle_t
3590 int ext4_can_truncate(struct inode *inode)
3592 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3593 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3595 if (S_ISREG(inode->i_mode))
3597 @@ -4766,41 +4767,64 @@ void ext4_set_inode_flags(struct inode *
3599 unsigned int flags = EXT4_I(inode)->i_flags;
3601 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3602 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3603 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3605 + if (flags & EXT4_IMMUTABLE_FL)
3606 + inode->i_flags |= S_IMMUTABLE;
3607 + if (flags & EXT4_IXUNLINK_FL)
3608 + inode->i_flags |= S_IXUNLINK;
3610 if (flags & EXT4_SYNC_FL)
3611 inode->i_flags |= S_SYNC;
3612 if (flags & EXT4_APPEND_FL)
3613 inode->i_flags |= S_APPEND;
3614 - if (flags & EXT4_IMMUTABLE_FL)
3615 - inode->i_flags |= S_IMMUTABLE;
3616 if (flags & EXT4_NOATIME_FL)
3617 inode->i_flags |= S_NOATIME;
3618 if (flags & EXT4_DIRSYNC_FL)
3619 inode->i_flags |= S_DIRSYNC;
3621 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3623 + if (flags & EXT4_BARRIER_FL)
3624 + inode->i_vflags |= V_BARRIER;
3625 + if (flags & EXT4_COW_FL)
3626 + inode->i_vflags |= V_COW;
3629 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3630 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3632 - unsigned int vfs_fl;
3633 + unsigned int vfs_fl, vfs_vf;
3634 unsigned long old_fl, new_fl;
3637 vfs_fl = ei->vfs_inode.i_flags;
3638 + vfs_vf = ei->vfs_inode.i_vflags;
3639 old_fl = ei->i_flags;
3640 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3641 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3643 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3646 + if (vfs_fl & S_IMMUTABLE)
3647 + new_fl |= EXT4_IMMUTABLE_FL;
3648 + if (vfs_fl & S_IXUNLINK)
3649 + new_fl |= EXT4_IXUNLINK_FL;
3651 if (vfs_fl & S_SYNC)
3652 new_fl |= EXT4_SYNC_FL;
3653 if (vfs_fl & S_APPEND)
3654 new_fl |= EXT4_APPEND_FL;
3655 - if (vfs_fl & S_IMMUTABLE)
3656 - new_fl |= EXT4_IMMUTABLE_FL;
3657 if (vfs_fl & S_NOATIME)
3658 new_fl |= EXT4_NOATIME_FL;
3659 if (vfs_fl & S_DIRSYNC)
3660 new_fl |= EXT4_DIRSYNC_FL;
3662 + if (vfs_vf & V_BARRIER)
3663 + new_fl |= EXT4_BARRIER_FL;
3664 + if (vfs_vf & V_COW)
3665 + new_fl |= EXT4_COW_FL;
3666 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3669 @@ -4836,6 +4860,8 @@ struct inode *ext4_iget(struct super_blo
3670 journal_t *journal = EXT4_SB(sb)->s_journal;
3676 inode = iget_locked(sb, ino);
3678 @@ -4851,12 +4877,16 @@ struct inode *ext4_iget(struct super_blo
3680 raw_inode = ext4_raw_inode(&iloc);
3681 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3682 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3683 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3684 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3685 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3686 if (!(test_opt(inode->i_sb, NO_UID32))) {
3687 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3688 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3689 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3690 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3692 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3693 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3694 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3695 + le16_to_cpu(raw_inode->i_raw_tag));
3696 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3698 ei->i_state_flags = 0;
3699 @@ -5075,6 +5105,8 @@ static int ext4_do_update_inode(handle_t
3700 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3701 struct ext4_inode_info *ei = EXT4_I(inode);
3702 struct buffer_head *bh = iloc->bh;
3703 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3704 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3705 int err = 0, rc, block;
3707 /* For fields not not tracking in the in-memory inode,
3708 @@ -5085,29 +5117,32 @@ static int ext4_do_update_inode(handle_t
3709 ext4_get_inode_flags(ei);
3710 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3711 if (!(test_opt(inode->i_sb, NO_UID32))) {
3712 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3713 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3714 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3715 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3717 * Fix up interoperability with old kernels. Otherwise, old inodes get
3718 * re-used with the upper 16 bits of the uid/gid intact
3721 raw_inode->i_uid_high =
3722 - cpu_to_le16(high_16_bits(inode->i_uid));
3723 + cpu_to_le16(high_16_bits(uid));
3724 raw_inode->i_gid_high =
3725 - cpu_to_le16(high_16_bits(inode->i_gid));
3726 + cpu_to_le16(high_16_bits(gid));
3728 raw_inode->i_uid_high = 0;
3729 raw_inode->i_gid_high = 0;
3732 raw_inode->i_uid_low =
3733 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3734 + cpu_to_le16(fs_high2lowuid(uid));
3735 raw_inode->i_gid_low =
3736 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3737 + cpu_to_le16(fs_high2lowgid(gid));
3738 raw_inode->i_uid_high = 0;
3739 raw_inode->i_gid_high = 0;
3741 +#ifdef CONFIG_TAGGING_INTERN
3742 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3744 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3746 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3747 @@ -5293,7 +5328,8 @@ int ext4_setattr(struct dentry *dentry,
3748 if (is_quota_modification(inode, attr))
3749 dquot_initialize(inode);
3750 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3751 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3752 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3753 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3756 /* (user+group)*(old+new) structure, inode write (sb,
3757 @@ -5315,6 +5351,8 @@ int ext4_setattr(struct dentry *dentry,
3758 inode->i_uid = attr->ia_uid;
3759 if (attr->ia_valid & ATTR_GID)
3760 inode->i_gid = attr->ia_gid;
3761 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3762 + inode->i_tag = attr->ia_tag;
3763 error = ext4_mark_inode_dirty(handle, inode);
3764 ext4_journal_stop(handle);
3766 diff -NurpP --minimal linux-2.6.37/fs/ext4/ioctl.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/ioctl.c
3767 --- linux-2.6.37/fs/ext4/ioctl.c 2011-01-05 21:50:23.000000000 +0100
3768 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/ioctl.c 2010-11-23 02:09:41.000000000 +0100
3770 #include <linux/compat.h>
3771 #include <linux/mount.h>
3772 #include <linux/file.h>
3773 +#include <linux/vs_tag.h>
3774 #include <asm/uaccess.h>
3775 #include "ext4_jbd2.h"
3779 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3781 + handle_t *handle = NULL;
3782 + struct ext4_iloc iloc;
3785 + handle = ext4_journal_start(inode, 1);
3786 + if (IS_ERR(handle))
3787 + return PTR_ERR(handle);
3789 + if (IS_SYNC(inode))
3790 + ext4_handle_sync(handle);
3791 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3795 + inode->i_flags = flags;
3796 + inode->i_vflags = vflags;
3797 + ext4_get_inode_flags(EXT4_I(inode));
3798 + inode->i_ctime = ext4_current_time(inode);
3800 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3802 + ext4_journal_stop(handle);
3806 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3808 struct inode *inode = filp->f_dentry->d_inode;
3809 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3811 flags = ext4_mask_flags(inode->i_mode, flags);
3813 + if (IS_BARRIER(inode)) {
3814 + vxwprintk_task(1, "messing with the barrier.");
3819 mutex_lock(&inode->i_mutex);
3820 /* Is it quota file? Do not allow user to mess with it */
3821 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3823 * This test looks nicer. Thanks to Pauline Middelink
3825 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3826 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3827 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3828 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3829 if (!capable(CAP_LINUX_IMMUTABLE))
3832 diff -NurpP --minimal linux-2.6.37/fs/ext4/namei.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/namei.c
3833 --- linux-2.6.37/fs/ext4/namei.c 2011-01-05 21:50:23.000000000 +0100
3834 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/namei.c 2011-01-05 22:30:39.000000000 +0100
3836 #include <linux/quotaops.h>
3837 #include <linux/buffer_head.h>
3838 #include <linux/bio.h>
3839 +#include <linux/vs_tag.h>
3841 #include "ext4_jbd2.h"
3843 @@ -923,6 +924,7 @@ restart:
3845 ll_rw_block(READ_META, 1, &bh);
3847 + dx_propagate_tag(nd, inode);
3849 if ((bh = bh_use[ra_ptr++]) == NULL)
3851 @@ -2513,6 +2515,7 @@ const struct inode_operations ext4_dir_i
3853 .check_acl = ext4_check_acl,
3854 .fiemap = ext4_fiemap,
3855 + .sync_flags = ext4_sync_flags,
3858 const struct inode_operations ext4_special_inode_operations = {
3859 diff -NurpP --minimal linux-2.6.37/fs/ext4/super.c linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/super.c
3860 --- linux-2.6.37/fs/ext4/super.c 2011-01-05 21:50:23.000000000 +0100
3861 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ext4/super.c 2011-01-05 22:30:39.000000000 +0100
3862 @@ -1247,6 +1247,7 @@ enum {
3863 Opt_dioread_nolock, Opt_dioread_lock,
3864 Opt_discard, Opt_nodiscard,
3865 Opt_init_inode_table, Opt_noinit_inode_table,
3866 + Opt_tag, Opt_notag, Opt_tagid
3869 static const match_table_t tokens = {
3870 @@ -1322,6 +1323,9 @@ static const match_table_t tokens = {
3871 {Opt_init_inode_table, "init_itable=%u"},
3872 {Opt_init_inode_table, "init_itable"},
3873 {Opt_noinit_inode_table, "noinit_itable"},
3875 + {Opt_notag, "notag"},
3876 + {Opt_tagid, "tagid=%u"},
3880 @@ -1490,6 +1494,20 @@ static int parse_options(char *options,
3882 set_opt(sbi->s_mount_opt, NO_UID32);
3884 +#ifndef CONFIG_TAGGING_NONE
3886 + set_opt (sbi->s_mount_opt, TAGGED);
3889 + clear_opt (sbi->s_mount_opt, TAGGED);
3892 +#ifdef CONFIG_PROPAGATE
3895 + set_opt (sbi->s_mount_opt, TAGGED);
3899 set_opt(sbi->s_mount_opt, DEBUG);
3901 @@ -3134,6 +3152,9 @@ static int ext4_fill_super(struct super_
3902 &journal_ioprio, NULL, 0))
3905 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3906 + sb->s_flags |= MS_TAGGED;
3908 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3909 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3911 @@ -4211,6 +4232,14 @@ static int ext4_remount(struct super_blo
3912 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3913 ext4_abort(sb, "Abort forced by user");
3915 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3916 + !(sb->s_flags & MS_TAGGED)) {
3917 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3920 + goto restore_opts;
3923 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3924 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3926 diff -NurpP --minimal linux-2.6.37/fs/fcntl.c linux-2.6.37-vs2.3.0.37-rc2/fs/fcntl.c
3927 --- linux-2.6.37/fs/fcntl.c 2011-01-05 21:50:23.000000000 +0100
3928 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/fcntl.c 2010-11-23 02:09:41.000000000 +0100
3930 #include <linux/signal.h>
3931 #include <linux/rcupdate.h>
3932 #include <linux/pid_namespace.h>
3933 +#include <linux/vs_limit.h>
3935 #include <asm/poll.h>
3936 #include <asm/siginfo.h>
3937 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3940 filp_close(tofree, files);
3942 + vx_openfd_inc(newfd); /* fd was unused */
3946 @@ -434,6 +437,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3950 + if (!vx_files_avail(1))
3953 err = security_file_fcntl(filp, cmd, arg);
3955 diff -NurpP --minimal linux-2.6.37/fs/file.c linux-2.6.37-vs2.3.0.37-rc2/fs/file.c
3956 --- linux-2.6.37/fs/file.c 2010-10-21 13:07:48.000000000 +0200
3957 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/file.c 2010-11-23 02:09:41.000000000 +0100
3959 #include <linux/spinlock.h>
3960 #include <linux/rcupdate.h>
3961 #include <linux/workqueue.h>
3962 +#include <linux/vs_limit.h>
3964 struct fdtable_defer {
3966 @@ -355,6 +356,8 @@ struct files_struct *dup_fd(struct files
3967 struct file *f = *old_fds++;
3970 + /* TODO: sum it first for check and performance */
3971 + vx_openfd_inc(open_files - i);
3974 * The fd may be claimed in the fd bitmap but not yet
3975 @@ -462,6 +465,7 @@ repeat:
3977 FD_CLR(fd, fdt->close_on_exec);
3979 + vx_openfd_inc(fd);
3982 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3983 diff -NurpP --minimal linux-2.6.37/fs/file_table.c linux-2.6.37-vs2.3.0.37-rc2/fs/file_table.c
3984 --- linux-2.6.37/fs/file_table.c 2011-01-05 21:50:23.000000000 +0100
3985 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/file_table.c 2010-11-23 02:09:41.000000000 +0100
3987 #include <linux/percpu_counter.h>
3988 #include <linux/percpu.h>
3989 #include <linux/ima.h>
3990 +#include <linux/vs_limit.h>
3991 +#include <linux/vs_context.h>
3993 #include <asm/atomic.h>
3995 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
3996 spin_lock_init(&f->f_lock);
3997 eventpoll_init_file(f);
3998 /* f->f_version: 0 */
3999 + f->f_xid = vx_current_xid();
4004 @@ -250,6 +254,8 @@ static void __fput(struct file *file)
4005 cdev_put(inode->i_cdev);
4006 fops_put(file->f_op);
4007 put_pid(file->f_owner.pid);
4008 + vx_files_dec(file);
4010 file_sb_list_del(file);
4011 if (file->f_mode & FMODE_WRITE)
4012 drop_file_write_access(file);
4013 @@ -333,6 +339,8 @@ void put_filp(struct file *file)
4015 if (atomic_long_dec_and_test(&file->f_count)) {
4016 security_file_free(file);
4017 + vx_files_dec(file);
4019 file_sb_list_del(file);
4022 diff -NurpP --minimal linux-2.6.37/fs/fs_struct.c linux-2.6.37-vs2.3.0.37-rc2/fs/fs_struct.c
4023 --- linux-2.6.37/fs/fs_struct.c 2010-10-21 13:07:48.000000000 +0200
4024 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/fs_struct.c 2010-11-23 02:09:41.000000000 +0100
4026 #include <linux/path.h>
4027 #include <linux/slab.h>
4028 #include <linux/fs_struct.h>
4029 +#include <linux/vserver/global.h>
4032 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
4033 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
4035 path_put(&fs->root);
4037 + atomic_dec(&vs_global_fs);
4038 kmem_cache_free(fs_cachep, fs);
4041 @@ -107,6 +109,7 @@ struct fs_struct *copy_fs_struct(struct
4042 spin_lock_init(&fs->lock);
4043 fs->umask = old->umask;
4044 get_fs_root_and_pwd(old, &fs->root, &fs->pwd);
4045 + atomic_inc(&vs_global_fs);
4049 diff -NurpP --minimal linux-2.6.37/fs/gfs2/file.c linux-2.6.37-vs2.3.0.37-rc2/fs/gfs2/file.c
4050 --- linux-2.6.37/fs/gfs2/file.c 2011-01-05 21:50:23.000000000 +0100
4051 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/gfs2/file.c 2010-11-23 02:09:41.000000000 +0100
4052 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
4053 [7] = GFS2_DIF_NOATIME,
4054 [12] = GFS2_DIF_EXHASH,
4055 [14] = GFS2_DIF_INHERIT_JDATA,
4056 + [27] = GFS2_DIF_IXUNLINK,
4057 + [26] = GFS2_DIF_BARRIER,
4058 + [29] = GFS2_DIF_COW,
4061 static const u32 gfs2_to_fsflags[32] = {
4062 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
4063 [gfs2fl_NoAtime] = FS_NOATIME_FL,
4064 [gfs2fl_ExHash] = FS_INDEX_FL,
4065 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
4066 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
4067 + [gfs2fl_Barrier] = FS_BARRIER_FL,
4068 + [gfs2fl_Cow] = FS_COW_FL,
4071 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
4072 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
4074 struct gfs2_inode *ip = GFS2_I(inode);
4075 unsigned int flags = inode->i_flags;
4076 + unsigned int vflags = inode->i_vflags;
4078 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4079 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4081 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4082 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
4083 flags |= S_IMMUTABLE;
4084 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
4085 + flags |= S_IXUNLINK;
4087 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
4089 if (ip->i_diskflags & GFS2_DIF_NOATIME)
4090 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
4091 if (ip->i_diskflags & GFS2_DIF_SYNC)
4093 inode->i_flags = flags;
4095 + vflags &= ~(V_BARRIER | V_COW);
4097 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
4098 + vflags |= V_BARRIER;
4099 + if (ip->i_diskflags & GFS2_DIF_COW)
4101 + inode->i_vflags = vflags;
4104 +void gfs2_get_inode_flags(struct inode *inode)
4106 + struct gfs2_inode *ip = GFS2_I(inode);
4107 + unsigned int flags = inode->i_flags;
4108 + unsigned int vflags = inode->i_vflags;
4110 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
4111 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
4112 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
4113 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
4115 + if (flags & S_IMMUTABLE)
4116 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
4117 + if (flags & S_IXUNLINK)
4118 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
4120 + if (flags & S_APPEND)
4121 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
4122 + if (flags & S_NOATIME)
4123 + ip->i_diskflags |= GFS2_DIF_NOATIME;
4124 + if (flags & S_SYNC)
4125 + ip->i_diskflags |= GFS2_DIF_SYNC;
4127 + if (vflags & V_BARRIER)
4128 + ip->i_diskflags |= GFS2_DIF_BARRIER;
4129 + if (vflags & V_COW)
4130 + ip->i_diskflags |= GFS2_DIF_COW;
4133 /* Flags that can be set by user space */
4134 @@ -293,6 +342,37 @@ static int gfs2_set_flags(struct file *f
4135 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
4138 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
4140 + struct gfs2_inode *ip = GFS2_I(inode);
4141 + struct gfs2_sbd *sdp = GFS2_SB(inode);
4142 + struct buffer_head *bh;
4143 + struct gfs2_holder gh;
4146 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
4149 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
4152 + error = gfs2_meta_inode_buffer(ip, &bh);
4154 + goto out_trans_end;
4155 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
4156 + inode->i_flags = flags;
4157 + inode->i_vflags = vflags;
4158 + gfs2_get_inode_flags(inode);
4159 + gfs2_dinode_out(ip, bh->b_data);
4161 + gfs2_set_aops(inode);
4163 + gfs2_trans_end(sdp);
4165 + gfs2_glock_dq_uninit(&gh);
4169 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4172 diff -NurpP --minimal linux-2.6.37/fs/gfs2/inode.h linux-2.6.37-vs2.3.0.37-rc2/fs/gfs2/inode.h
4173 --- linux-2.6.37/fs/gfs2/inode.h 2011-01-05 21:50:23.000000000 +0100
4174 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/gfs2/inode.h 2010-11-23 02:09:41.000000000 +0100
4175 @@ -126,6 +126,7 @@ extern const struct file_operations gfs2
4176 extern const struct file_operations gfs2_dir_fops_nolock;
4178 extern void gfs2_set_inode_flags(struct inode *inode);
4179 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
4181 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
4182 extern const struct file_operations gfs2_file_fops;
4183 diff -NurpP --minimal linux-2.6.37/fs/gfs2/ops_inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/gfs2/ops_inode.c
4184 --- linux-2.6.37/fs/gfs2/ops_inode.c 2011-01-05 21:50:23.000000000 +0100
4185 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/gfs2/ops_inode.c 2010-11-23 02:09:41.000000000 +0100
4186 @@ -1594,6 +1594,8 @@ const struct inode_operations gfs2_dir_i
4187 .listxattr = gfs2_listxattr,
4188 .removexattr = gfs2_removexattr,
4189 .fiemap = gfs2_fiemap,
4190 + .sync_flags = gfs2_sync_flags,
4191 + .sync_flags = gfs2_sync_flags,
4194 const struct inode_operations gfs2_symlink_iops = {
4195 diff -NurpP --minimal linux-2.6.37/fs/inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/inode.c
4196 --- linux-2.6.37/fs/inode.c 2011-01-05 21:50:24.000000000 +0100
4197 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/inode.c 2010-11-23 03:34:25.000000000 +0100
4199 #include <linux/async.h>
4200 #include <linux/posix_acl.h>
4201 #include <linux/ima.h>
4202 +#include <linux/vs_tag.h>
4205 * This is needed for the following functions:
4206 @@ -162,6 +163,9 @@ int inode_init_always(struct super_block
4207 struct address_space *const mapping = &inode->i_data;
4211 + /* essential because of inode slab reuse */
4213 inode->i_blkbits = sb->s_blocksize_bits;
4215 atomic_set(&inode->i_count, 1);
4216 @@ -182,6 +186,7 @@ int inode_init_always(struct super_block
4217 inode->i_bdev = NULL;
4218 inode->i_cdev = NULL;
4220 + inode->i_mdev = 0;
4221 inode->dirtied_when = 0;
4223 if (security_inode_alloc(inode))
4224 @@ -408,6 +413,8 @@ static void __remove_inode_hash(struct i
4225 hlist_del_init(&inode->i_hash);
4228 +EXPORT_SYMBOL_GPL(__iget);
4231 * remove_inode_hash - remove an inode from the hash
4232 * @inode: inode to unhash
4233 @@ -1675,9 +1682,11 @@ void init_special_inode(struct inode *in
4234 if (S_ISCHR(mode)) {
4235 inode->i_fop = &def_chr_fops;
4236 inode->i_rdev = rdev;
4237 + inode->i_mdev = rdev;
4238 } else if (S_ISBLK(mode)) {
4239 inode->i_fop = &def_blk_fops;
4240 inode->i_rdev = rdev;
4241 + inode->i_mdev = rdev;
4242 } else if (S_ISFIFO(mode))
4243 inode->i_fop = &def_fifo_fops;
4244 else if (S_ISSOCK(mode))
4245 @@ -1706,5 +1715,6 @@ void inode_init_owner(struct inode *inod
4247 inode->i_gid = current_fsgid();
4248 inode->i_mode = mode;
4249 + inode->i_tag = dx_current_fstag(inode->i_sb);
4251 EXPORT_SYMBOL(inode_init_owner);
4252 diff -NurpP --minimal linux-2.6.37/fs/ioctl.c linux-2.6.37-vs2.3.0.37-rc2/fs/ioctl.c
4253 --- linux-2.6.37/fs/ioctl.c 2011-01-05 21:50:24.000000000 +0100
4254 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ioctl.c 2010-11-23 02:09:41.000000000 +0100
4256 #include <linux/writeback.h>
4257 #include <linux/buffer_head.h>
4258 #include <linux/falloc.h>
4259 +#include <linux/proc_fs.h>
4260 +#include <linux/vserver/inode.h>
4261 +#include <linux/vs_tag.h>
4263 #include <asm/ioctls.h>
4265 diff -NurpP --minimal linux-2.6.37/fs/ioprio.c linux-2.6.37-vs2.3.0.37-rc2/fs/ioprio.c
4266 --- linux-2.6.37/fs/ioprio.c 2011-01-05 21:50:24.000000000 +0100
4267 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ioprio.c 2011-01-05 22:30:39.000000000 +0100
4269 #include <linux/syscalls.h>
4270 #include <linux/security.h>
4271 #include <linux/pid_namespace.h>
4272 +#include <linux/vs_base.h>
4274 int set_task_ioprio(struct task_struct *task, int ioprio)
4276 @@ -119,6 +120,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
4278 pgrp = find_vpid(who);
4279 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4280 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4282 ret = set_task_ioprio(p, ioprio);
4285 @@ -208,6 +211,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
4287 pgrp = find_vpid(who);
4288 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
4289 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4291 tmpio = get_task_ioprio(p);
4294 diff -NurpP --minimal linux-2.6.37/fs/jfs/file.c linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/file.c
4295 --- linux-2.6.37/fs/jfs/file.c 2010-10-21 13:07:50.000000000 +0200
4296 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/file.c 2010-11-23 02:09:41.000000000 +0100
4297 @@ -102,7 +102,8 @@ int jfs_setattr(struct dentry *dentry, s
4298 if (is_quota_modification(inode, iattr))
4299 dquot_initialize(inode);
4300 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4301 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4302 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4303 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4304 rc = dquot_transfer(inode, iattr);
4307 @@ -133,6 +134,7 @@ const struct inode_operations jfs_file_i
4308 #ifdef CONFIG_JFS_POSIX_ACL
4309 .check_acl = jfs_check_acl,
4311 + .sync_flags = jfs_sync_flags,
4314 const struct file_operations jfs_file_operations = {
4315 diff -NurpP --minimal linux-2.6.37/fs/jfs/ioctl.c linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/ioctl.c
4316 --- linux-2.6.37/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
4317 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/ioctl.c 2010-11-23 02:09:41.000000000 +0100
4319 #include <linux/mount.h>
4320 #include <linux/time.h>
4321 #include <linux/sched.h>
4322 +#include <linux/mount.h>
4323 #include <asm/current.h>
4324 #include <asm/uaccess.h>
4326 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
4330 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
4332 + inode->i_flags = flags;
4333 + inode->i_vflags = vflags;
4334 + jfs_get_inode_flags(JFS_IP(inode));
4335 + inode->i_ctime = CURRENT_TIME_SEC;
4336 + mark_inode_dirty(inode);
4340 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4342 struct inode *inode = filp->f_dentry->d_inode;
4343 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
4344 if (!S_ISDIR(inode->i_mode))
4345 flags &= ~JFS_DIRSYNC_FL;
4347 + if (IS_BARRIER(inode)) {
4348 + vxwprintk_task(1, "messing with the barrier.");
4352 /* Is it quota file? Do not allow user to mess with it */
4353 if (IS_NOQUOTA(inode)) {
4355 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
4356 * the relevant capability.
4358 if ((oldflags & JFS_IMMUTABLE_FL) ||
4359 - ((flags ^ oldflags) &
4360 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4361 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4362 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
4363 if (!capable(CAP_LINUX_IMMUTABLE)) {
4364 mutex_unlock(&inode->i_mutex);
4366 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
4370 - flags = flags & JFS_FL_USER_MODIFIABLE;
4371 + flags &= JFS_FL_USER_MODIFIABLE;
4372 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
4373 jfs_inode->mode2 = flags;
4375 diff -NurpP --minimal linux-2.6.37/fs/jfs/jfs_dinode.h linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/jfs_dinode.h
4376 --- linux-2.6.37/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
4377 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/jfs_dinode.h 2010-11-23 02:09:41.000000000 +0100
4378 @@ -161,9 +161,13 @@ struct dinode {
4380 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4381 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4382 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4384 -#define JFS_FL_USER_VISIBLE 0x03F80000
4385 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
4386 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4387 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
4389 +#define JFS_FL_USER_VISIBLE 0x07F80000
4390 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
4391 #define JFS_FL_INHERIT 0x03C80000
4393 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4394 diff -NurpP --minimal linux-2.6.37/fs/jfs/jfs_filsys.h linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/jfs_filsys.h
4395 --- linux-2.6.37/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
4396 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/jfs_filsys.h 2010-11-23 02:09:41.000000000 +0100
4398 #define JFS_NAME_MAX 255
4399 #define JFS_PATH_MAX BPSIZE
4401 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4404 * file system state (superblock state)
4405 diff -NurpP --minimal linux-2.6.37/fs/jfs/jfs_imap.c linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/jfs_imap.c
4406 --- linux-2.6.37/fs/jfs/jfs_imap.c 2011-01-05 21:50:24.000000000 +0100
4407 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/jfs_imap.c 2010-11-23 02:09:41.000000000 +0100
4409 #include <linux/pagemap.h>
4410 #include <linux/quotaops.h>
4411 #include <linux/slab.h>
4412 +#include <linux/vs_tag.h>
4414 #include "jfs_incore.h"
4415 #include "jfs_inode.h"
4416 @@ -3060,6 +3061,8 @@ static int copy_from_dinode(struct dinod
4418 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4419 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4423 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4424 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4425 @@ -3080,14 +3083,18 @@ static int copy_from_dinode(struct dinod
4427 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4429 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4430 + uid = le32_to_cpu(dip->di_uid);
4431 + gid = le32_to_cpu(dip->di_gid);
4432 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4434 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4436 ip->i_uid = jfs_ip->saved_uid;
4438 ip->i_uid = sbi->uid;
4441 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4442 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4444 ip->i_gid = jfs_ip->saved_gid;
4446 @@ -3152,14 +3159,12 @@ static void copy_to_dinode(struct dinode
4447 dip->di_size = cpu_to_le64(ip->i_size);
4448 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4449 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4450 - if (sbi->uid == -1)
4451 - dip->di_uid = cpu_to_le32(ip->i_uid);
4453 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4454 - if (sbi->gid == -1)
4455 - dip->di_gid = cpu_to_le32(ip->i_gid);
4457 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4459 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4460 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4461 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4462 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4464 jfs_get_inode_flags(jfs_ip);
4466 * mode2 is only needed for storing the higher order bits.
4467 diff -NurpP --minimal linux-2.6.37/fs/jfs/jfs_inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/jfs_inode.c
4468 --- linux-2.6.37/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
4469 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/jfs_inode.c 2010-11-23 02:09:41.000000000 +0100
4472 #include <linux/fs.h>
4473 #include <linux/quotaops.h>
4474 +#include <linux/vs_tag.h>
4475 #include "jfs_incore.h"
4476 #include "jfs_inode.h"
4477 #include "jfs_filsys.h"
4478 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4480 unsigned int flags = JFS_IP(inode)->mode2;
4482 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4483 - S_NOATIME | S_DIRSYNC | S_SYNC);
4484 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4485 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4487 if (flags & JFS_IMMUTABLE_FL)
4488 inode->i_flags |= S_IMMUTABLE;
4489 + if (flags & JFS_IXUNLINK_FL)
4490 + inode->i_flags |= S_IXUNLINK;
4492 + if (flags & JFS_SYNC_FL)
4493 + inode->i_flags |= S_SYNC;
4494 if (flags & JFS_APPEND_FL)
4495 inode->i_flags |= S_APPEND;
4496 if (flags & JFS_NOATIME_FL)
4497 inode->i_flags |= S_NOATIME;
4498 if (flags & JFS_DIRSYNC_FL)
4499 inode->i_flags |= S_DIRSYNC;
4500 - if (flags & JFS_SYNC_FL)
4501 - inode->i_flags |= S_SYNC;
4503 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4505 + if (flags & JFS_BARRIER_FL)
4506 + inode->i_vflags |= V_BARRIER;
4507 + if (flags & JFS_COW_FL)
4508 + inode->i_vflags |= V_COW;
4511 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4513 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4514 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4516 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4517 + JFS_APPEND_FL | JFS_NOATIME_FL |
4518 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4519 + JFS_BARRIER_FL | JFS_COW_FL);
4521 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4522 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4523 if (flags & S_IMMUTABLE)
4524 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4525 + if (flags & S_IXUNLINK)
4526 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4528 if (flags & S_APPEND)
4529 jfs_ip->mode2 |= JFS_APPEND_FL;
4530 if (flags & S_NOATIME)
4531 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4532 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4534 jfs_ip->mode2 |= JFS_SYNC_FL;
4536 + if (vflags & V_BARRIER)
4537 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4538 + if (vflags & V_COW)
4539 + jfs_ip->mode2 |= JFS_COW_FL;
4543 diff -NurpP --minimal linux-2.6.37/fs/jfs/jfs_inode.h linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/jfs_inode.h
4544 --- linux-2.6.37/fs/jfs/jfs_inode.h 2010-10-21 13:07:50.000000000 +0200
4545 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/jfs_inode.h 2010-11-23 02:09:41.000000000 +0100
4546 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4547 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4548 int fh_len, int fh_type);
4549 extern void jfs_set_inode_flags(struct inode *);
4550 +extern int jfs_sync_flags(struct inode *, int, int);
4551 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4552 extern int jfs_setattr(struct dentry *, struct iattr *);
4554 diff -NurpP --minimal linux-2.6.37/fs/jfs/namei.c linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/namei.c
4555 --- linux-2.6.37/fs/jfs/namei.c 2011-01-05 21:50:24.000000000 +0100
4556 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/namei.c 2010-11-23 02:09:41.000000000 +0100
4558 #include <linux/ctype.h>
4559 #include <linux/quotaops.h>
4560 #include <linux/exportfs.h>
4561 +#include <linux/vs_tag.h>
4562 #include "jfs_incore.h"
4563 #include "jfs_superblock.h"
4564 #include "jfs_inode.h"
4565 @@ -1491,6 +1492,7 @@ static struct dentry *jfs_lookup(struct
4566 return ERR_CAST(ip);
4569 + dx_propagate_tag(nd, ip);
4570 dentry = d_splice_alias(ip, dentry);
4572 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
4573 @@ -1560,6 +1562,7 @@ const struct inode_operations jfs_dir_in
4574 #ifdef CONFIG_JFS_POSIX_ACL
4575 .check_acl = jfs_check_acl,
4577 + .sync_flags = jfs_sync_flags,
4580 const struct file_operations jfs_dir_operations = {
4581 diff -NurpP --minimal linux-2.6.37/fs/jfs/super.c linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/super.c
4582 --- linux-2.6.37/fs/jfs/super.c 2011-01-05 21:50:24.000000000 +0100
4583 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/jfs/super.c 2010-11-23 03:40:34.000000000 +0100
4584 @@ -190,7 +190,8 @@ static void jfs_put_super(struct super_b
4586 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4587 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4588 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4589 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4590 + Opt_tag, Opt_notag, Opt_tagid
4593 static const match_table_t tokens = {
4594 @@ -200,6 +201,10 @@ static const match_table_t tokens = {
4595 {Opt_resize, "resize=%u"},
4596 {Opt_resize_nosize, "resize"},
4597 {Opt_errors, "errors=%s"},
4599 + {Opt_notag, "notag"},
4600 + {Opt_tagid, "tagid=%u"},
4601 + {Opt_tag, "tagxid"},
4602 {Opt_ignore, "noquota"},
4603 {Opt_ignore, "quota"},
4604 {Opt_usrquota, "usrquota"},
4605 @@ -334,6 +339,20 @@ static int parse_options(char *options,
4609 +#ifndef CONFIG_TAGGING_NONE
4611 + *flag |= JFS_TAGGED;
4614 + *flag &= JFS_TAGGED;
4617 +#ifdef CONFIG_PROPAGATE
4620 + *flag |= JFS_TAGGED;
4624 printk("jfs: Unrecognized mount option \"%s\" "
4625 " or missing value\n", p);
4626 @@ -365,6 +384,12 @@ static int jfs_remount(struct super_bloc
4630 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4631 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4637 if (sb->s_flags & MS_RDONLY) {
4639 @@ -447,6 +472,9 @@ static int jfs_fill_super(struct super_b
4640 #ifdef CONFIG_JFS_POSIX_ACL
4641 sb->s_flags |= MS_POSIXACL;
4643 + /* map mount option tagxid */
4644 + if (sbi->flag & JFS_TAGGED)
4645 + sb->s_flags |= MS_TAGGED;
4648 printk(KERN_ERR "resize option for remount only\n");
4649 diff -NurpP --minimal linux-2.6.37/fs/libfs.c linux-2.6.37-vs2.3.0.37-rc2/fs/libfs.c
4650 --- linux-2.6.37/fs/libfs.c 2011-01-05 21:50:24.000000000 +0100
4651 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/libfs.c 2010-11-23 02:09:41.000000000 +0100
4652 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
4653 * both impossible due to the lock on directory.
4656 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4657 +static inline int do_dcache_readdir_filter(struct file *filp,
4658 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4660 struct dentry *dentry = filp->f_path.dentry;
4661 struct dentry *cursor = filp->private_data;
4662 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
4663 next = list_entry(p, struct dentry, d_u.d_child);
4664 if (d_unhashed(next) || !next->d_inode)
4666 + if (filter && !filter(next))
4669 spin_unlock(&dcache_lock);
4670 if (filldir(dirent, next->d_name.name,
4671 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
4675 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4677 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4680 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4681 + int (*filter)(struct dentry *))
4683 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4687 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4690 @@ -948,6 +963,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4691 EXPORT_SYMBOL(dcache_dir_lseek);
4692 EXPORT_SYMBOL(dcache_dir_open);
4693 EXPORT_SYMBOL(dcache_readdir);
4694 +EXPORT_SYMBOL(dcache_readdir_filter);
4695 EXPORT_SYMBOL(generic_read_dir);
4696 EXPORT_SYMBOL(mount_pseudo);
4697 EXPORT_SYMBOL(simple_write_begin);
4698 diff -NurpP --minimal linux-2.6.37/fs/locks.c linux-2.6.37-vs2.3.0.37-rc2/fs/locks.c
4699 --- linux-2.6.37/fs/locks.c 2011-01-05 21:50:24.000000000 +0100
4700 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/locks.c 2010-11-23 03:38:48.000000000 +0100
4702 #include <linux/time.h>
4703 #include <linux/rcupdate.h>
4704 #include <linux/pid_namespace.h>
4705 +#include <linux/vs_base.h>
4706 +#include <linux/vs_limit.h>
4708 #include <asm/uaccess.h>
4710 @@ -164,6 +166,8 @@ static struct kmem_cache *filelock_cache
4711 /* Allocate an empty lock structure. */
4712 struct file_lock *locks_alloc_lock(void)
4714 + if (!vx_locks_avail(1))
4716 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4718 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4719 @@ -191,6 +195,7 @@ void locks_free_lock(struct file_lock *f
4720 BUG_ON(!list_empty(&fl->fl_block));
4721 BUG_ON(!list_empty(&fl->fl_link));
4724 locks_release_private(fl);
4725 kmem_cache_free(filelock_cache, fl);
4727 @@ -212,6 +217,7 @@ void locks_init_lock(struct file_lock *f
4728 fl->fl_start = fl->fl_end = 0;
4730 fl->fl_lmops = NULL;
4734 EXPORT_SYMBOL(locks_init_lock);
4735 @@ -263,6 +269,7 @@ void locks_copy_lock(struct file_lock *n
4736 new->fl_file = fl->fl_file;
4737 new->fl_ops = fl->fl_ops;
4738 new->fl_lmops = fl->fl_lmops;
4739 + new->fl_xid = fl->fl_xid;
4741 locks_copy_private(new, fl);
4743 @@ -301,6 +308,11 @@ static int flock_make_lock(struct file *
4744 fl->fl_flags = FL_FLOCK;
4746 fl->fl_end = OFFSET_MAX;
4748 + vxd_assert(filp->f_xid == vx_current_xid(),
4749 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4750 + fl->fl_xid = filp->f_xid;
4755 @@ -466,6 +478,7 @@ static int lease_init(struct file *filp,
4757 fl->fl_owner = current->files;
4758 fl->fl_pid = current->tgid;
4759 + fl->fl_xid = vx_current_xid();
4762 fl->fl_flags = FL_LEASE;
4763 @@ -485,6 +498,11 @@ static struct file_lock *lease_alloc(str
4765 return ERR_PTR(error);
4767 + fl->fl_xid = vx_current_xid();
4769 + vxd_assert(filp->f_xid == fl->fl_xid,
4770 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4772 error = lease_init(filp, type, fl);
4774 locks_free_lock(fl);
4775 @@ -786,6 +804,7 @@ static int flock_lock_file(struct file *
4779 + new_fl->fl_xid = -1;
4781 for_each_lock(inode, before) {
4782 struct file_lock *fl = *before;
4783 @@ -806,6 +825,7 @@ find_conflict:
4785 locks_copy_lock(new_fl, request);
4786 locks_insert_lock(before, new_fl);
4787 + vx_locks_inc(new_fl);
4791 @@ -816,7 +836,8 @@ out:
4795 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4796 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4797 + struct file_lock *conflock, xid_t xid)
4799 struct file_lock *fl;
4800 struct file_lock *new_fl = NULL;
4801 @@ -826,6 +847,8 @@ static int __posix_lock_file(struct inod
4802 struct file_lock **before;
4803 int error, added = 0;
4805 + vxd_assert(xid == vx_current_xid(),
4806 + "xid(%d) == current(%d)", xid, vx_current_xid());
4808 * We may need two file_lock structures for this operation,
4809 * so we get them in advance to avoid races.
4810 @@ -836,7 +859,11 @@ static int __posix_lock_file(struct inod
4811 (request->fl_type != F_UNLCK ||
4812 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4813 new_fl = locks_alloc_lock();
4814 + new_fl->fl_xid = xid;
4815 + vx_locks_inc(new_fl);
4816 new_fl2 = locks_alloc_lock();
4817 + new_fl2->fl_xid = xid;
4818 + vx_locks_inc(new_fl2);
4822 @@ -1035,7 +1062,8 @@ static int __posix_lock_file(struct inod
4823 int posix_lock_file(struct file *filp, struct file_lock *fl,
4824 struct file_lock *conflock)
4826 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4827 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4828 + fl, conflock, filp->f_xid);
4830 EXPORT_SYMBOL(posix_lock_file);
4832 @@ -1125,7 +1153,7 @@ int locks_mandatory_area(int read_write,
4833 fl.fl_end = offset + count - 1;
4836 - error = __posix_lock_file(inode, &fl, NULL);
4837 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4838 if (error != FILE_LOCK_DEFERRED)
4840 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4841 @@ -1438,6 +1466,7 @@ int generic_setlease(struct file *filp,
4844 locks_insert_lock(before, lease);
4845 + vx_locks_inc(lease);
4849 @@ -1822,6 +1851,11 @@ int fcntl_setlk(unsigned int fd, struct
4850 if (file_lock == NULL)
4853 + vxd_assert(filp->f_xid == vx_current_xid(),
4854 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4855 + file_lock->fl_xid = filp->f_xid;
4856 + vx_locks_inc(file_lock);
4859 * This might block, so we do it before checking the inode.
4861 @@ -1940,6 +1974,11 @@ int fcntl_setlk64(unsigned int fd, struc
4862 if (file_lock == NULL)
4865 + vxd_assert(filp->f_xid == vx_current_xid(),
4866 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4867 + file_lock->fl_xid = filp->f_xid;
4868 + vx_locks_inc(file_lock);
4871 * This might block, so we do it before checking the inode.
4873 @@ -2205,8 +2244,11 @@ static int locks_show(struct seq_file *f
4875 lock_get_status(f, fl, *((loff_t *)f->private), "");
4877 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4878 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4879 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4881 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4886 diff -NurpP --minimal linux-2.6.37/fs/namei.c linux-2.6.37-vs2.3.0.37-rc2/fs/namei.c
4887 --- linux-2.6.37/fs/namei.c 2011-01-05 21:50:24.000000000 +0100
4888 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/namei.c 2011-01-05 22:30:39.000000000 +0100
4890 #include <linux/fcntl.h>
4891 #include <linux/device_cgroup.h>
4892 #include <linux/fs_struct.h>
4893 +#include <linux/proc_fs.h>
4894 +#include <linux/vserver/inode.h>
4895 +#include <linux/vs_base.h>
4896 +#include <linux/vs_tag.h>
4897 +#include <linux/vs_cowbl.h>
4898 +#include <linux/vs_device.h>
4899 +#include <linux/vs_context.h>
4900 +#include <linux/pid_namespace.h>
4901 #include <asm/uaccess.h>
4903 #include "internal.h"
4904 @@ -166,6 +174,84 @@ void putname(const char *name)
4905 EXPORT_SYMBOL(putname);
4908 +static inline int dx_barrier(const struct inode *inode)
4910 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4911 + vxwprintk_task(1, "did hit the barrier.");
4917 +static int __dx_permission(const struct inode *inode, int mask)
4919 + if (dx_barrier(inode))
4922 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4923 + /* devpts is xid tagged */
4924 + if (S_ISDIR(inode->i_mode) ||
4925 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4928 + /* just pretend we didn't find anything */
4931 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4932 + struct proc_dir_entry *de = PDE(inode);
4934 + if (de && !vx_hide_check(0, de->vx_flags))
4937 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4939 + struct task_struct *tsk;
4941 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4942 + vx_flags(VXF_STATE_SETUP, 0))
4945 + pid = PROC_I(inode)->pid;
4949 + tsk = pid_task(pid, PIDTYPE_PID);
4950 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4951 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4952 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
4956 + /* FIXME: Should we block some entries here? */
4961 + if (dx_notagcheck(inode->i_sb) ||
4962 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4971 +int dx_permission(const struct inode *inode, int mask)
4973 + int ret = __dx_permission(inode, mask);
4974 + if (unlikely(ret)) {
4975 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4976 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4979 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4980 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4987 * This does basic POSIX ACL permission checking
4989 @@ -266,10 +352,14 @@ int inode_permission(struct inode *inode
4991 * Nobody gets write access to an immutable file.
4993 - if (IS_IMMUTABLE(inode))
4994 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4998 + retval = dx_permission(inode, mask);
5002 if (inode->i_op->permission)
5003 retval = inode->i_op->permission(inode, mask);
5005 @@ -463,6 +553,9 @@ static int exec_permission(struct inode
5009 + if (dx_barrier(inode))
5012 if (inode->i_op->permission) {
5013 ret = inode->i_op->permission(inode, MAY_EXEC);
5015 @@ -672,7 +765,8 @@ static __always_inline void follow_dotdo
5017 if (nd->path.dentry == nd->root.dentry &&
5018 nd->path.mnt == nd->root.mnt) {
5020 + /* for sane '/' avoid follow_mount() */
5023 if (nd->path.dentry != nd->path.mnt->mnt_root) {
5024 /* rare case of legitimate dget_parent()... */
5025 @@ -725,7 +819,7 @@ static int do_lookup(struct nameidata *n
5027 struct vfsmount *mnt = nd->path.mnt;
5028 struct dentry *dentry, *parent;
5029 - struct inode *dir;
5030 + struct inode *dir, *inode;
5032 * See if the low-level filesystem might want
5033 * to use its own hash..
5034 @@ -747,12 +841,31 @@ static int do_lookup(struct nameidata *n
5036 if (dentry->d_op && dentry->d_op->d_revalidate)
5037 goto need_revalidate;
5039 + inode = dentry->d_inode;
5043 + if (__dx_permission(inode, MAY_ACCESS))
5047 path->dentry = dentry;
5048 __follow_mount(path);
5052 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
5053 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
5056 + "did lookup hidden %s:%p[#%d,%lu] " VS_Q("%s/%.*s") ".",
5057 + inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
5058 + vxd_path(&nd->path), name->len, name->name);
5064 parent = nd->path.dentry;
5065 dir = parent->d_inode;
5066 @@ -1301,7 +1414,7 @@ static int may_delete(struct inode *dir,
5069 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5070 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5071 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
5074 if (!S_ISDIR(victim->d_inode->i_mode))
5075 @@ -1424,6 +1537,14 @@ int may_open(struct path *path, int acc_
5079 +#ifdef CONFIG_VSERVER_COWBL
5080 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5081 + if (IS_COW_LINK(inode))
5083 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
5084 + mark_inode_dirty(inode);
5087 error = inode_permission(inode, acc_mode);
5090 @@ -1532,7 +1653,8 @@ static int open_will_truncate(int flag,
5093 static struct file *finish_open(struct nameidata *nd,
5094 - int open_flag, int acc_mode)
5095 + int open_flag, int acc_mode,
5096 + const char *pathname)
5100 @@ -1545,6 +1667,23 @@ static struct file *finish_open(struct n
5103 error = may_open(&nd->path, acc_mode, open_flag);
5104 +#ifdef CONFIG_VSERVER_COWBL
5105 + if (error == -EMLINK) {
5106 + struct dentry *dentry;
5107 + dentry = cow_break_link(pathname);
5108 + if (IS_ERR(dentry)) {
5109 + error = PTR_ERR(dentry);
5113 + if (will_truncate)
5114 + mnt_drop_write(nd->path.mnt);
5115 + release_open_intent(nd);
5116 + path_put(&nd->path);
5117 + return ERR_PTR(-EMLINK);
5123 mnt_drop_write(nd->path.mnt);
5124 @@ -1715,7 +1854,7 @@ static struct file *do_last(struct namei
5125 if (S_ISDIR(path->dentry->d_inode->i_mode))
5128 - filp = finish_open(nd, open_flag, acc_mode);
5129 + filp = finish_open(nd, open_flag, acc_mode, pathname);
5133 @@ -1744,7 +1883,11 @@ struct file *do_filp_open(int dfd, const
5135 int flag = open_to_namei_flags(open_flag);
5136 int force_reval = 0;
5138 +#ifdef CONFIG_VSERVER_COWBL
5143 if (!(open_flag & O_CREAT))
5146 @@ -1813,6 +1956,13 @@ reval:
5147 if (!(open_flag & O_NOFOLLOW))
5148 nd.flags |= LOOKUP_FOLLOW;
5149 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
5150 +#ifdef CONFIG_VSERVER_COWBL
5151 + if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
5157 while (unlikely(!filp)) { /* trailing symlink */
5159 struct inode *inode = path.dentry->d_inode;
5160 @@ -1851,6 +2001,13 @@ reval:
5162 nd.flags &= ~LOOKUP_PARENT;
5163 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
5164 +#ifdef CONFIG_VSERVER_COWBL
5165 + if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
5171 if (inode->i_op->put_link)
5172 inode->i_op->put_link(holder.dentry, &nd, cookie);
5174 @@ -1951,9 +2108,17 @@ int vfs_mknod(struct inode *dir, struct
5178 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
5179 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
5182 + if (!capable(CAP_MKNOD))
5185 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
5187 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
5190 if (!dir->i_op->mknod)
5193 @@ -2418,7 +2583,7 @@ int vfs_link(struct dentry *old_dentry,
5195 * A link to an append-only or immutable file cannot be created.
5197 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5198 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5200 if (!dir->i_op->link)
5202 @@ -2790,6 +2955,222 @@ int vfs_follow_link(struct nameidata *nd
5203 return __vfs_follow_link(nd, link);
5207 +#ifdef CONFIG_VSERVER_COWBL
5209 +#include <linux/file.h>
5212 +long do_cow_splice(struct file *in, struct file *out, size_t len)
5216 + return do_splice_direct(in, &ppos, out, len, 0);
5219 +struct dentry *cow_break_link(const char *pathname)
5221 + int ret, mode, pathlen, redo = 0;
5222 + struct nameidata old_nd, dir_nd;
5223 + struct path old_path, new_path;
5224 + struct dentry *dir, *res = NULL;
5225 + struct file *old_file;
5226 + struct file *new_file;
5227 + char *to, *path, pad='\251';
5230 + vxdprintk(VXD_CBIT(misc, 1),
5231 + "cow_break_link(" VS_Q("%s") ")", pathname);
5232 + path = kmalloc(PATH_MAX, GFP_KERNEL);
5237 + /* old_nd will have refs to dentry and mnt */
5238 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5239 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
5241 + goto out_free_path;
5243 + old_path = old_nd.path;
5244 + mode = old_path.dentry->d_inode->i_mode;
5246 + to = d_path(&old_path, path, PATH_MAX-2);
5247 + pathlen = strlen(to);
5248 + vxdprintk(VXD_CBIT(misc, 2),
5249 + "old path " VS_Q("%s") " [" VS_Q("%.*s") ":%d]", to,
5250 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5251 + old_path.dentry->d_name.len);
5253 + to[pathlen + 1] = 0;
5255 + to[pathlen] = pad--;
5257 + if (pad <= '\240')
5260 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
5261 + /* dir_nd will have refs to dentry and mnt */
5262 + ret = path_lookup(to,
5263 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
5264 + vxdprintk(VXD_CBIT(misc, 2),
5265 + "path_lookup(new): %d", ret);
5269 + /* this puppy downs the inode mutex */
5270 + new_path.dentry = lookup_create(&dir_nd, 0);
5271 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
5272 + vxdprintk(VXD_CBIT(misc, 2),
5273 + "lookup_create(new): %p", new_path.dentry);
5274 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
5275 + path_put(&dir_nd.path);
5278 + vxdprintk(VXD_CBIT(misc, 2),
5279 + "lookup_create(new): %p [" VS_Q("%.*s") ":%d]",
5281 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5282 + new_path.dentry->d_name.len);
5283 + dir = dir_nd.path.dentry;
5285 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
5286 + vxdprintk(VXD_CBIT(misc, 2),
5287 + "vfs_create(new): %d", ret);
5288 + if (ret == -EEXIST) {
5289 + mutex_unlock(&dir->d_inode->i_mutex);
5290 + dput(new_path.dentry);
5291 + path_put(&dir_nd.path);
5295 + goto out_unlock_new;
5297 + /* drop out early, ret passes ENOENT */
5299 + if ((redo = d_unhashed(old_path.dentry)))
5300 + goto out_unlock_new;
5302 + new_path.mnt = dir_nd.path.mnt;
5303 + dget(old_path.dentry);
5304 + mntget(old_path.mnt);
5305 + /* this one cleans up the dentry/mnt in case of failure */
5306 + old_file = dentry_open(old_path.dentry, old_path.mnt,
5307 + O_RDONLY, current_cred());
5308 + vxdprintk(VXD_CBIT(misc, 2),
5309 + "dentry_open(old): %p", old_file);
5310 + if (!old_file || IS_ERR(old_file)) {
5311 + res = IS_ERR(old_file) ? (void *) old_file : res;
5312 + goto out_unlock_new;
5315 + dget(new_path.dentry);
5316 + mntget(new_path.mnt);
5317 + /* this one cleans up the dentry/mnt in case of failure */
5318 + new_file = dentry_open(new_path.dentry, new_path.mnt,
5319 + O_WRONLY, current_cred());
5320 + vxdprintk(VXD_CBIT(misc, 2),
5321 + "dentry_open(new): %p", new_file);
5323 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
5324 + if (!new_file || IS_ERR(new_file))
5325 + goto out_fput_old;
5327 + size = i_size_read(old_file->f_dentry->d_inode);
5328 + ret = do_cow_splice(old_file, new_file, size);
5329 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
5331 + goto out_fput_both;
5332 + } else if (ret < size) {
5334 + goto out_fput_both;
5336 + struct inode *old_inode = old_path.dentry->d_inode;
5337 + struct inode *new_inode = new_path.dentry->d_inode;
5338 + struct iattr attr = {
5339 + .ia_uid = old_inode->i_uid,
5340 + .ia_gid = old_inode->i_gid,
5341 + .ia_valid = ATTR_UID | ATTR_GID
5344 + setattr_copy(new_inode, &attr);
5345 + mark_inode_dirty(new_inode);
5348 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5350 + /* drop out late */
5352 + if ((redo = d_unhashed(old_path.dentry)))
5355 + vxdprintk(VXD_CBIT(misc, 2),
5356 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
5357 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5358 + new_path.dentry->d_name.len,
5359 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
5360 + old_path.dentry->d_name.len);
5361 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
5362 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
5363 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
5364 + res = new_path.dentry;
5367 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
5370 + vxdprintk(VXD_CBIT(misc, 3),
5371 + "fput(new_file=%p[#%ld])", new_file,
5372 + atomic_long_read(&new_file->f_count));
5376 + vxdprintk(VXD_CBIT(misc, 3),
5377 + "fput(old_file=%p[#%ld])", old_file,
5378 + atomic_long_read(&old_file->f_count));
5382 + mutex_unlock(&dir->d_inode->i_mutex);
5386 + /* error path cleanup */
5387 + vfs_unlink(dir->d_inode, new_path.dentry);
5388 + dput(new_path.dentry);
5392 + goto out_rel_both;
5393 + /* lookup dentry once again */
5394 + path_put(&old_nd.path);
5395 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
5397 + goto out_rel_both;
5399 + new_path.dentry = old_nd.path.dentry;
5400 + vxdprintk(VXD_CBIT(misc, 2),
5401 + "path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
5403 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
5404 + new_path.dentry->d_name.len);
5405 + dget(new_path.dentry);
5406 + res = new_path.dentry;
5409 + path_put(&dir_nd.path);
5411 + path_put(&old_nd.path);
5416 + res = ERR_PTR(ret);
5422 /* get the link contents into pagecache */
5423 static char *page_getlink(struct dentry * dentry, struct page **ppage)
5425 diff -NurpP --minimal linux-2.6.37/fs/namespace.c linux-2.6.37-vs2.3.0.37-rc2/fs/namespace.c
5426 --- linux-2.6.37/fs/namespace.c 2011-01-05 21:50:24.000000000 +0100
5427 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/namespace.c 2010-11-23 02:09:41.000000000 +0100
5429 #include <linux/idr.h>
5430 #include <linux/fs_struct.h>
5431 #include <linux/fsnotify.h>
5432 +#include <linux/vs_base.h>
5433 +#include <linux/vs_context.h>
5434 +#include <linux/vs_tag.h>
5435 +#include <linux/vserver/space.h>
5436 +#include <linux/vserver/global.h>
5437 #include <asm/uaccess.h>
5438 #include <asm/unistd.h>
5440 @@ -600,6 +605,7 @@ static struct vfsmount *clone_mnt(struct
5441 mnt->mnt_root = dget(root);
5442 mnt->mnt_mountpoint = mnt->mnt_root;
5443 mnt->mnt_parent = mnt;
5444 + mnt->mnt_tag = old->mnt_tag;
5446 if (flag & CL_SLAVE) {
5447 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5448 @@ -698,6 +704,31 @@ static inline void mangle(struct seq_fil
5449 seq_escape(m, s, " \t\n\\");
5452 +static int mnt_is_reachable(struct vfsmount *mnt)
5455 + struct dentry *point;
5458 + if (mnt == mnt->mnt_ns->root)
5461 + br_read_lock(vfsmount_lock);
5462 + root = current->fs->root;
5463 + point = root.dentry;
5465 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5466 + point = mnt->mnt_mountpoint;
5467 + mnt = mnt->mnt_parent;
5470 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5472 + br_read_unlock(vfsmount_lock);
5478 * Simple .show_options callback for filesystems which don't want to
5479 * implement more complex mount option showing.
5480 @@ -800,6 +831,8 @@ static int show_sb_opts(struct seq_file
5481 { MS_SYNCHRONOUS, ",sync" },
5482 { MS_DIRSYNC, ",dirsync" },
5483 { MS_MANDLOCK, ",mand" },
5484 + { MS_TAGGED, ",tag" },
5485 + { MS_NOTAGCHECK, ",notagcheck" },
5488 const struct proc_fs_info *fs_infop;
5489 @@ -846,10 +879,20 @@ static int show_vfsmnt(struct seq_file *
5491 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5493 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5495 - seq_path(m, &mnt_path, " \t\n\\");
5497 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5499 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5502 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5503 + mnt == current->fs->root.mnt) {
5504 + seq_puts(m, "/dev/root / ");
5506 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5508 + seq_path(m, &mnt_path, " \t\n\\");
5511 show_type(m, mnt->mnt_sb);
5512 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5513 err = show_sb_opts(m, mnt->mnt_sb);
5514 @@ -879,6 +922,11 @@ static int show_mountinfo(struct seq_fil
5515 struct path root = p->root;
5518 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5520 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5523 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5524 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5525 seq_dentry(m, mnt->mnt_root, " \t\n\\");
5526 @@ -937,17 +985,27 @@ static int show_vfsstat(struct seq_file
5527 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5531 - if (mnt->mnt_devname) {
5532 - seq_puts(m, "device ");
5533 - mangle(m, mnt->mnt_devname);
5535 - seq_puts(m, "no device");
5536 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5538 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5542 - seq_puts(m, " mounted on ");
5543 - seq_path(m, &mnt_path, " \t\n\\");
5545 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5546 + mnt == current->fs->root.mnt) {
5547 + seq_puts(m, "device /dev/root mounted on / ");
5550 + if (mnt->mnt_devname) {
5551 + seq_puts(m, "device ");
5552 + mangle(m, mnt->mnt_devname);
5554 + seq_puts(m, "no device");
5557 + seq_puts(m, " mounted on ");
5558 + seq_path(m, &mnt_path, " \t\n\\");
5562 /* file system type */
5563 seq_puts(m, "with fstype ");
5564 @@ -1193,7 +1251,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5568 - if (!capable(CAP_SYS_ADMIN))
5569 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5572 retval = do_umount(path.mnt, flags);
5573 @@ -1219,7 +1277,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5575 static int mount_is_safe(struct path *path)
5577 - if (capable(CAP_SYS_ADMIN))
5578 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5582 @@ -1509,7 +1567,7 @@ static int do_change_type(struct path *p
5586 - if (!capable(CAP_SYS_ADMIN))
5587 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5590 if (path->dentry != path->mnt->mnt_root)
5591 @@ -1540,11 +1598,13 @@ static int do_change_type(struct path *p
5592 * do loopback mount.
5594 static int do_loopback(struct path *path, char *old_name,
5596 + tag_t tag, unsigned long flags, int mnt_flags)
5598 struct path old_path;
5599 struct vfsmount *mnt = NULL;
5600 int err = mount_is_safe(path);
5601 + int recurse = flags & MS_REC;
5605 if (!old_name || !*old_name)
5606 @@ -1579,6 +1639,7 @@ static int do_loopback(struct path *path
5607 br_write_unlock(vfsmount_lock);
5608 release_mounts(&umount_list);
5610 + mnt->mnt_flags = mnt_flags;
5613 up_write(&namespace_sem);
5614 @@ -1609,12 +1670,12 @@ static int change_mount_flags(struct vfs
5615 * on it - tough luck.
5617 static int do_remount(struct path *path, int flags, int mnt_flags,
5619 + void *data, xid_t xid)
5622 struct super_block *sb = path->mnt->mnt_sb;
5624 - if (!capable(CAP_SYS_ADMIN))
5625 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5628 if (!check_mnt(path->mnt))
5629 @@ -1658,7 +1719,7 @@ static int do_move_mount(struct path *pa
5630 struct path old_path, parent_path;
5633 - if (!capable(CAP_SYS_ADMIN))
5634 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5636 if (!old_name || !*old_name)
5638 @@ -1740,7 +1801,7 @@ static int do_new_mount(struct path *pat
5641 /* we need capabilities... */
5642 - if (!capable(CAP_SYS_ADMIN))
5643 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5646 mnt = do_kern_mount(type, flags, name, data);
5647 @@ -2006,6 +2067,7 @@ long do_mount(char *dev_name, char *dir_
5654 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5655 @@ -2033,6 +2095,12 @@ long do_mount(char *dev_name, char *dir_
5656 if (!(flags & MS_NOATIME))
5657 mnt_flags |= MNT_RELATIME;
5659 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5660 + /* FIXME: bind and re-mounts get the tag flag? */
5661 + if (flags & (MS_BIND|MS_REMOUNT))
5662 + flags |= MS_TAGID;
5665 /* Separate the per-mountpoint flags */
5666 if (flags & MS_NOSUID)
5667 mnt_flags |= MNT_NOSUID;
5668 @@ -2049,15 +2117,17 @@ long do_mount(char *dev_name, char *dir_
5669 if (flags & MS_RDONLY)
5670 mnt_flags |= MNT_READONLY;
5672 + if (!capable(CAP_SYS_ADMIN))
5673 + mnt_flags |= MNT_NODEV;
5674 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5675 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5678 if (flags & MS_REMOUNT)
5679 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5682 else if (flags & MS_BIND)
5683 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5684 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5685 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5686 retval = do_change_type(&path, flags);
5687 else if (flags & MS_MOVE)
5688 @@ -2136,6 +2206,7 @@ static struct mnt_namespace *dup_mnt_ns(
5689 q = next_mnt(q, new_ns->root);
5691 up_write(&namespace_sem);
5692 + atomic_inc(&vs_global_mnt_ns);
5696 @@ -2277,9 +2348,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5697 down_write(&namespace_sem);
5698 mutex_lock(&old.dentry->d_inode->i_mutex);
5700 - if (IS_MNT_SHARED(old.mnt) ||
5701 + if ((IS_MNT_SHARED(old.mnt) ||
5702 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5703 - IS_MNT_SHARED(root.mnt->mnt_parent))
5704 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5705 + !vx_flags(VXF_STATE_SETUP, 0))
5707 if (!check_mnt(root.mnt))
5709 @@ -2412,6 +2484,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5710 br_write_unlock(vfsmount_lock);
5711 up_write(&namespace_sem);
5712 release_mounts(&umount_list);
5713 + atomic_dec(&vs_global_mnt_ns);
5716 EXPORT_SYMBOL(put_mnt_ns);
5717 diff -NurpP --minimal linux-2.6.37/fs/nfs/client.c linux-2.6.37-vs2.3.0.37-rc2/fs/nfs/client.c
5718 --- linux-2.6.37/fs/nfs/client.c 2011-01-05 21:50:24.000000000 +0100
5719 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/nfs/client.c 2010-11-23 02:09:41.000000000 +0100
5720 @@ -747,6 +747,9 @@ static int nfs_init_server_rpcclient(str
5721 if (server->flags & NFS_MOUNT_SOFT)
5722 server->client->cl_softrtry = 1;
5724 + server->client->cl_tag = 0;
5725 + if (server->flags & NFS_MOUNT_TAGGED)
5726 + server->client->cl_tag = 1;
5730 @@ -920,6 +923,10 @@ static void nfs_server_set_fsinfo(struct
5731 server->acdirmin = server->acdirmax = 0;
5734 + /* FIXME: needs fsinfo
5735 + if (server->flags & NFS_MOUNT_TAGGED)
5736 + sb->s_flags |= MS_TAGGED; */
5738 server->maxfilesize = fsinfo->maxfilesize;
5740 server->time_delta = fsinfo->time_delta;
5741 diff -NurpP --minimal linux-2.6.37/fs/nfs/dir.c linux-2.6.37-vs2.3.0.37-rc2/fs/nfs/dir.c
5742 --- linux-2.6.37/fs/nfs/dir.c 2011-01-05 21:50:25.000000000 +0100
5743 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/nfs/dir.c 2011-01-05 22:30:39.000000000 +0100
5745 #include <linux/sched.h>
5746 #include <linux/vmalloc.h>
5747 #include <linux/kmemleak.h>
5748 +#include <linux/vs_tag.h>
5750 #include "delegation.h"
5752 @@ -1221,6 +1222,7 @@ static struct dentry *nfs_lookup(struct
5754 goto out_unblock_sillyrename;
5756 + dx_propagate_tag(nd, inode);
5758 res = d_materialise_unique(dentry, inode);
5760 diff -NurpP --minimal linux-2.6.37/fs/nfs/inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/nfs/inode.c
5761 --- linux-2.6.37/fs/nfs/inode.c 2011-01-05 21:50:25.000000000 +0100
5762 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/nfs/inode.c 2011-01-05 22:30:39.000000000 +0100
5764 #include <linux/inet.h>
5765 #include <linux/nfs_xdr.h>
5766 #include <linux/slab.h>
5767 +#include <linux/vs_tag.h>
5769 #include <asm/system.h>
5770 #include <asm/uaccess.h>
5771 @@ -265,6 +266,8 @@ nfs_fhget(struct super_block *sb, struct
5772 if (inode->i_state & I_NEW) {
5773 struct nfs_inode *nfsi = NFS_I(inode);
5774 unsigned long now = jiffies;
5778 /* We set i_ino for the few things that still rely on it,
5779 * such as stat(2) */
5780 @@ -313,8 +316,8 @@ nfs_fhget(struct super_block *sb, struct
5781 nfsi->change_attr = 0;
5784 - inode->i_uid = -2;
5785 - inode->i_gid = -2;
5788 inode->i_blocks = 0;
5789 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5791 @@ -351,13 +354,13 @@ nfs_fhget(struct super_block *sb, struct
5792 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5793 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5794 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5795 - inode->i_uid = fattr->uid;
5797 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5798 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5799 | NFS_INO_INVALID_ACCESS
5800 | NFS_INO_INVALID_ACL;
5801 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5802 - inode->i_gid = fattr->gid;
5804 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5805 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5806 | NFS_INO_INVALID_ACCESS
5807 @@ -370,6 +373,11 @@ nfs_fhget(struct super_block *sb, struct
5809 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5811 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5812 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5813 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5814 + /* maybe fattr->xid someday */
5816 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5817 nfsi->attrtimeo_timestamp = now;
5818 nfsi->access_cache = RB_ROOT;
5819 @@ -486,6 +494,8 @@ void nfs_setattr_update_inode(struct ino
5820 inode->i_uid = attr->ia_uid;
5821 if ((attr->ia_valid & ATTR_GID) != 0)
5822 inode->i_gid = attr->ia_gid;
5823 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5824 + inode->i_tag = attr->ia_tag;
5825 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5826 spin_unlock(&inode->i_lock);
5828 @@ -926,6 +936,9 @@ static int nfs_check_inode_attributes(st
5829 struct nfs_inode *nfsi = NFS_I(inode);
5830 loff_t cur_size, new_isize;
5831 unsigned long invalid = 0;
5837 /* Has the inode gone and changed behind our back? */
5838 @@ -949,13 +962,18 @@ static int nfs_check_inode_attributes(st
5839 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5842 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5843 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5844 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5846 /* Have any file permissions changed? */
5847 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5848 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5849 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5850 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5851 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5852 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5853 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5854 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5855 + /* maybe check for tag too? */
5857 /* Has the link count changed? */
5858 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5859 @@ -1190,6 +1208,9 @@ static int nfs_update_inode(struct inode
5860 unsigned long invalid = 0;
5861 unsigned long now = jiffies;
5862 unsigned long save_cache_validity;
5867 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5868 __func__, inode->i_sb->s_id, inode->i_ino,
5869 @@ -1292,6 +1313,9 @@ static int nfs_update_inode(struct inode
5870 | NFS_INO_REVAL_PAGECACHE
5871 | NFS_INO_REVAL_FORCED);
5873 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5874 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5875 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5877 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5878 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5879 @@ -1313,9 +1337,9 @@ static int nfs_update_inode(struct inode
5880 | NFS_INO_REVAL_FORCED);
5882 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5883 - if (inode->i_uid != fattr->uid) {
5884 + if (uid != fattr->uid) {
5885 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5886 - inode->i_uid = fattr->uid;
5889 } else if (server->caps & NFS_CAP_OWNER)
5890 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5891 @@ -1324,9 +1348,9 @@ static int nfs_update_inode(struct inode
5892 | NFS_INO_REVAL_FORCED);
5894 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5895 - if (inode->i_gid != fattr->gid) {
5896 + if (gid != fattr->gid) {
5897 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5898 - inode->i_gid = fattr->gid;
5901 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5902 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5903 @@ -1334,6 +1358,10 @@ static int nfs_update_inode(struct inode
5904 | NFS_INO_INVALID_ACL
5905 | NFS_INO_REVAL_FORCED);
5907 + inode->i_uid = uid;
5908 + inode->i_gid = gid;
5909 + inode->i_tag = tag;
5911 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5912 if (inode->i_nlink != fattr->nlink) {
5913 invalid |= NFS_INO_INVALID_ATTR;
5914 diff -NurpP --minimal linux-2.6.37/fs/nfs/nfs3xdr.c linux-2.6.37-vs2.3.0.37-rc2/fs/nfs/nfs3xdr.c
5915 --- linux-2.6.37/fs/nfs/nfs3xdr.c 2011-01-05 21:50:25.000000000 +0100
5916 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/nfs/nfs3xdr.c 2011-01-05 22:30:39.000000000 +0100
5918 #include <linux/nfs3.h>
5919 #include <linux/nfs_fs.h>
5920 #include <linux/nfsacl.h>
5921 +#include <linux/vs_tag.h>
5922 #include "internal.h"
5924 #define NFSDBG_FACILITY NFSDBG_XDR
5925 @@ -205,7 +206,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
5928 static inline __be32 *
5929 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
5930 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
5932 if (attr->ia_valid & ATTR_MODE) {
5934 @@ -213,15 +214,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
5938 - if (attr->ia_valid & ATTR_UID) {
5939 + if (attr->ia_valid & ATTR_UID ||
5940 + (tag && (attr->ia_valid & ATTR_TAG))) {
5942 - *p++ = htonl(attr->ia_uid);
5943 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
5947 - if (attr->ia_valid & ATTR_GID) {
5948 + if (attr->ia_valid & ATTR_GID ||
5949 + (tag && (attr->ia_valid & ATTR_TAG))) {
5951 - *p++ = htonl(attr->ia_gid);
5952 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
5956 @@ -328,7 +331,8 @@ static int
5957 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
5959 p = xdr_encode_fhandle(p, args->fh);
5960 - p = xdr_encode_sattr(p, args->sattr);
5961 + p = xdr_encode_sattr(p, args->sattr,
5962 + req->rq_task->tk_client->cl_tag);
5963 *p++ = htonl(args->guard);
5965 p = xdr_encode_time3(p, &args->guardtime);
5966 @@ -433,7 +437,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
5967 *p++ = args->verifier[0];
5968 *p++ = args->verifier[1];
5970 - p = xdr_encode_sattr(p, args->sattr);
5971 + p = xdr_encode_sattr(p, args->sattr,
5972 + req->rq_task->tk_client->cl_tag);
5974 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5976 @@ -447,7 +452,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
5978 p = xdr_encode_fhandle(p, args->fh);
5979 p = xdr_encode_array(p, args->name, args->len);
5980 - p = xdr_encode_sattr(p, args->sattr);
5981 + p = xdr_encode_sattr(p, args->sattr,
5982 + req->rq_task->tk_client->cl_tag);
5983 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5986 @@ -460,7 +466,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
5988 p = xdr_encode_fhandle(p, args->fromfh);
5989 p = xdr_encode_array(p, args->fromname, args->fromlen);
5990 - p = xdr_encode_sattr(p, args->sattr);
5991 + p = xdr_encode_sattr(p, args->sattr,
5992 + req->rq_task->tk_client->cl_tag);
5993 *p++ = htonl(args->pathlen);
5994 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
5996 @@ -478,7 +485,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
5997 p = xdr_encode_fhandle(p, args->fh);
5998 p = xdr_encode_array(p, args->name, args->len);
5999 *p++ = htonl(args->type);
6000 - p = xdr_encode_sattr(p, args->sattr);
6001 + p = xdr_encode_sattr(p, args->sattr,
6002 + req->rq_task->tk_client->cl_tag);
6003 if (args->type == NF3CHR || args->type == NF3BLK) {
6004 *p++ = htonl(MAJOR(args->rdev));
6005 *p++ = htonl(MINOR(args->rdev));
6006 diff -NurpP --minimal linux-2.6.37/fs/nfs/super.c linux-2.6.37-vs2.3.0.37-rc2/fs/nfs/super.c
6007 --- linux-2.6.37/fs/nfs/super.c 2011-01-05 21:50:25.000000000 +0100
6008 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/nfs/super.c 2011-01-05 23:44:00.000000000 +0100
6010 #include <linux/nfs_xdr.h>
6011 #include <linux/magic.h>
6012 #include <linux/parser.h>
6013 +#include <linux/vs_tag.h>
6015 #include <asm/system.h>
6016 #include <asm/uaccess.h>
6017 @@ -86,6 +87,7 @@ enum {
6018 Opt_sharecache, Opt_nosharecache,
6019 Opt_resvport, Opt_noresvport,
6020 Opt_fscache, Opt_nofscache,
6021 + Opt_tag, Opt_notag,
6023 /* Mount options that take integer arguments */
6025 @@ -99,6 +101,7 @@ enum {
6031 /* Mount options that take string arguments */
6032 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
6033 @@ -179,6 +182,10 @@ static const match_table_t nfs_mount_opt
6034 { Opt_fscache_uniq, "fsc=%s" },
6035 { Opt_local_lock, "local_lock=%s" },
6037 + { Opt_tag, "tag" },
6038 + { Opt_notag, "notag" },
6039 + { Opt_tagid, "tagid=%u" },
6044 @@ -640,6 +647,7 @@ static void nfs_show_mount_options(struc
6045 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6046 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
6047 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
6048 + { NFS_MOUNT_TAGGED, ",tag", "" },
6051 const struct proc_nfs_info *nfs_infop;
6052 @@ -1120,6 +1128,14 @@ static int nfs_parse_mount_options(char
6053 kfree(mnt->fscache_uniq);
6054 mnt->fscache_uniq = NULL;
6056 +#ifndef CONFIG_TAGGING_NONE
6058 + mnt->flags |= NFS_MOUNT_TAGGED;
6061 + mnt->flags &= ~NFS_MOUNT_TAGGED;
6066 * options that take numeric values
6067 @@ -1304,6 +1320,12 @@ static int nfs_parse_mount_options(char
6068 goto out_invalid_value;
6069 mnt->minorversion = option;
6071 +#ifdef CONFIG_PROPAGATE
6074 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6079 * options that take text values
6080 diff -NurpP --minimal linux-2.6.37/fs/nfsd/auth.c linux-2.6.37-vs2.3.0.37-rc2/fs/nfsd/auth.c
6081 --- linux-2.6.37/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
6082 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/nfsd/auth.c 2010-11-23 02:09:41.000000000 +0100
6084 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
6086 #include <linux/sched.h>
6087 +#include <linux/vs_tag.h>
6091 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6093 new->fsuid = rqstp->rq_cred.cr_uid;
6094 new->fsgid = rqstp->rq_cred.cr_gid;
6095 + /* FIXME: this desperately needs a tag :)
6096 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6099 rqgi = rqstp->rq_cred.cr_group_info;
6101 diff -NurpP --minimal linux-2.6.37/fs/nfsd/nfs3xdr.c linux-2.6.37-vs2.3.0.37-rc2/fs/nfsd/nfs3xdr.c
6102 --- linux-2.6.37/fs/nfsd/nfs3xdr.c 2011-01-05 21:50:25.000000000 +0100
6103 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/nfsd/nfs3xdr.c 2011-01-05 22:30:39.000000000 +0100
6107 #include <linux/namei.h>
6108 +#include <linux/vs_tag.h>
6112 @@ -95,6 +96,8 @@ static __be32 *
6113 decode_sattr3(__be32 *p, struct iattr *iap)
6121 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6124 iap->ia_valid |= ATTR_UID;
6125 - iap->ia_uid = ntohl(*p++);
6126 + uid = ntohl(*p++);
6129 iap->ia_valid |= ATTR_GID;
6130 - iap->ia_gid = ntohl(*p++);
6131 + gid = ntohl(*p++);
6133 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6134 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6135 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6139 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6140 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6141 *p++ = htonl((u32) stat->mode);
6142 *p++ = htonl((u32) stat->nlink);
6143 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6144 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6145 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6146 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6147 + stat->uid, stat->tag)));
6148 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6149 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6150 + stat->gid, stat->tag)));
6151 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6152 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6154 diff -NurpP --minimal linux-2.6.37/fs/nfsd/nfs4xdr.c linux-2.6.37-vs2.3.0.37-rc2/fs/nfsd/nfs4xdr.c
6155 --- linux-2.6.37/fs/nfsd/nfs4xdr.c 2011-01-05 21:50:25.000000000 +0100
6156 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/nfsd/nfs4xdr.c 2010-11-23 02:09:41.000000000 +0100
6158 #include <linux/nfsd_idmap.h>
6159 #include <linux/nfs4_acl.h>
6160 #include <linux/sunrpc/svcauth_gss.h>
6161 +#include <linux/vs_tag.h>
6165 @@ -2063,14 +2064,18 @@ out_acl:
6166 WRITE32(stat.nlink);
6168 if (bmval1 & FATTR4_WORD1_OWNER) {
6169 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
6170 + status = nfsd4_encode_user(rqstp,
6171 + TAGINO_UID(DX_TAG(dentry->d_inode),
6172 + stat.uid, stat.tag), &p, &buflen);
6173 if (status == nfserr_resource)
6178 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
6179 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
6180 + status = nfsd4_encode_group(rqstp,
6181 + TAGINO_GID(DX_TAG(dentry->d_inode),
6182 + stat.gid, stat.tag), &p, &buflen);
6183 if (status == nfserr_resource)
6186 diff -NurpP --minimal linux-2.6.37/fs/nfsd/nfsxdr.c linux-2.6.37-vs2.3.0.37-rc2/fs/nfsd/nfsxdr.c
6187 --- linux-2.6.37/fs/nfsd/nfsxdr.c 2010-02-25 11:52:05.000000000 +0100
6188 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/nfsd/nfsxdr.c 2010-11-23 02:09:41.000000000 +0100
6193 +#include <linux/vs_tag.h>
6195 #define NFSDDBG_FACILITY NFSDDBG_XDR
6197 @@ -88,6 +89,8 @@ static __be32 *
6198 decode_sattr(__be32 *p, struct iattr *iap)
6206 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
6208 if ((tmp = ntohl(*p++)) != (u32)-1) {
6209 iap->ia_valid |= ATTR_UID;
6210 - iap->ia_uid = tmp;
6213 if ((tmp = ntohl(*p++)) != (u32)-1) {
6214 iap->ia_valid |= ATTR_GID;
6215 - iap->ia_gid = tmp;
6218 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6219 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6220 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6221 if ((tmp = ntohl(*p++)) != (u32)-1) {
6222 iap->ia_valid |= ATTR_SIZE;
6224 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
6225 *p++ = htonl(nfs_ftypes[type >> 12]);
6226 *p++ = htonl((u32) stat->mode);
6227 *p++ = htonl((u32) stat->nlink);
6228 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6229 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6230 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6231 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
6232 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6233 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
6235 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
6236 *p++ = htonl(NFS_MAXPATHLEN);
6237 diff -NurpP --minimal linux-2.6.37/fs/ocfs2/dlmglue.c linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/dlmglue.c
6238 --- linux-2.6.37/fs/ocfs2/dlmglue.c 2011-01-05 21:50:26.000000000 +0100
6239 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/dlmglue.c 2010-11-23 02:09:41.000000000 +0100
6240 @@ -2114,6 +2114,7 @@ static void __ocfs2_stuff_meta_lvb(struc
6241 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
6242 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
6243 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
6244 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
6245 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
6246 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
6247 lvb->lvb_iatime_packed =
6248 @@ -2168,6 +2169,7 @@ static void ocfs2_refresh_inode_from_lvb
6250 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
6251 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
6252 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
6253 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
6254 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
6255 ocfs2_unpack_timespec(&inode->i_atime,
6256 diff -NurpP --minimal linux-2.6.37/fs/ocfs2/dlmglue.h linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/dlmglue.h
6257 --- linux-2.6.37/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
6258 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/dlmglue.h 2010-11-23 02:09:41.000000000 +0100
6259 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
6262 __be32 lvb_igeneration;
6263 - __be32 lvb_reserved2;
6265 + __be16 lvb_reserved2;
6268 #define OCFS2_QINFO_LVB_VERSION 1
6269 diff -NurpP --minimal linux-2.6.37/fs/ocfs2/file.c linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/file.c
6270 --- linux-2.6.37/fs/ocfs2/file.c 2011-01-05 21:50:26.000000000 +0100
6271 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/file.c 2011-01-05 22:30:39.000000000 +0100
6272 @@ -1126,13 +1126,15 @@ int ocfs2_setattr(struct dentry *dentry,
6273 mlog(0, "uid change: %d\n", attr->ia_uid);
6274 if (attr->ia_valid & ATTR_GID)
6275 mlog(0, "gid change: %d\n", attr->ia_gid);
6276 + if (attr->ia_valid & ATTR_TAG)
6277 + mlog(0, "tag change: %d\n", attr->ia_tag);
6278 if (attr->ia_valid & ATTR_SIZE)
6279 mlog(0, "size change...\n");
6280 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
6281 mlog(0, "time change...\n");
6283 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
6284 - | ATTR_GID | ATTR_UID | ATTR_MODE)
6285 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
6286 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
6287 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
6289 diff -NurpP --minimal linux-2.6.37/fs/ocfs2/inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/inode.c
6290 --- linux-2.6.37/fs/ocfs2/inode.c 2011-01-05 21:50:26.000000000 +0100
6291 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/inode.c 2010-11-23 02:09:41.000000000 +0100
6293 #include <linux/highmem.h>
6294 #include <linux/pagemap.h>
6295 #include <linux/quotaops.h>
6296 +#include <linux/vs_tag.h>
6298 #include <asm/byteorder.h>
6300 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
6302 unsigned int flags = OCFS2_I(inode)->ip_attr;
6304 - inode->i_flags &= ~(S_IMMUTABLE |
6305 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6306 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6308 if (flags & OCFS2_IMMUTABLE_FL)
6309 inode->i_flags |= S_IMMUTABLE;
6310 + if (flags & OCFS2_IXUNLINK_FL)
6311 + inode->i_flags |= S_IXUNLINK;
6313 if (flags & OCFS2_SYNC_FL)
6314 inode->i_flags |= S_SYNC;
6315 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
6316 inode->i_flags |= S_NOATIME;
6317 if (flags & OCFS2_DIRSYNC_FL)
6318 inode->i_flags |= S_DIRSYNC;
6320 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6322 + if (flags & OCFS2_BARRIER_FL)
6323 + inode->i_vflags |= V_BARRIER;
6324 + if (flags & OCFS2_COW_FL)
6325 + inode->i_vflags |= V_COW;
6328 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
6329 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
6331 unsigned int flags = oi->vfs_inode.i_flags;
6332 + unsigned int vflags = oi->vfs_inode.i_vflags;
6334 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
6335 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
6336 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
6337 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
6339 + if (flags & S_IMMUTABLE)
6340 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6341 + if (flags & S_IXUNLINK)
6342 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
6344 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
6345 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
6347 oi->ip_attr |= OCFS2_SYNC_FL;
6348 if (flags & S_APPEND)
6349 oi->ip_attr |= OCFS2_APPEND_FL;
6350 - if (flags & S_IMMUTABLE)
6351 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
6352 if (flags & S_NOATIME)
6353 oi->ip_attr |= OCFS2_NOATIME_FL;
6354 if (flags & S_DIRSYNC)
6355 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6357 + if (vflags & V_BARRIER)
6358 + oi->ip_attr |= OCFS2_BARRIER_FL;
6359 + if (vflags & V_COW)
6360 + oi->ip_attr |= OCFS2_COW_FL;
6363 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6364 @@ -245,6 +267,8 @@ void ocfs2_populate_inode(struct inode *
6365 struct super_block *sb;
6366 struct ocfs2_super *osb;
6371 mlog_entry("(0x%p, size:%llu)\n", inode,
6372 (unsigned long long)le64_to_cpu(fe->i_size));
6373 @@ -276,8 +300,12 @@ void ocfs2_populate_inode(struct inode *
6374 inode->i_generation = le32_to_cpu(fe->i_generation);
6375 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6376 inode->i_mode = le16_to_cpu(fe->i_mode);
6377 - inode->i_uid = le32_to_cpu(fe->i_uid);
6378 - inode->i_gid = le32_to_cpu(fe->i_gid);
6379 + uid = le32_to_cpu(fe->i_uid);
6380 + gid = le32_to_cpu(fe->i_gid);
6381 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6382 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6383 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6384 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6386 /* Fast symlinks will have i_size but no allocated clusters. */
6387 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6388 diff -NurpP --minimal linux-2.6.37/fs/ocfs2/inode.h linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/inode.h
6389 --- linux-2.6.37/fs/ocfs2/inode.h 2011-01-05 21:50:26.000000000 +0100
6390 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/inode.h 2010-11-23 02:09:41.000000000 +0100
6391 @@ -151,6 +151,7 @@ struct buffer_head *ocfs2_bread(struct i
6393 void ocfs2_set_inode_flags(struct inode *inode);
6394 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6395 +int ocfs2_sync_flags(struct inode *inode, int, int);
6397 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6399 diff -NurpP --minimal linux-2.6.37/fs/ocfs2/ioctl.c linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/ioctl.c
6400 --- linux-2.6.37/fs/ocfs2/ioctl.c 2011-01-05 21:50:26.000000000 +0100
6401 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/ioctl.c 2010-11-23 02:09:41.000000000 +0100
6402 @@ -63,7 +63,41 @@ static int ocfs2_get_inode_attr(struct i
6406 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6407 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6409 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6410 + struct buffer_head *bh = NULL;
6411 + handle_t *handle = NULL;
6414 + status = ocfs2_inode_lock(inode, &bh, 1);
6416 + mlog_errno(status);
6419 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6420 + if (IS_ERR(handle)) {
6421 + status = PTR_ERR(handle);
6422 + mlog_errno(status);
6426 + inode->i_flags = flags;
6427 + inode->i_vflags = vflags;
6428 + ocfs2_get_inode_flags(OCFS2_I(inode));
6430 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6432 + mlog_errno(status);
6434 + ocfs2_commit_trans(osb, handle);
6436 + ocfs2_inode_unlock(inode, 1);
6441 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6444 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6445 @@ -88,6 +122,11 @@ static int ocfs2_set_inode_attr(struct i
6446 if (!S_ISDIR(inode->i_mode))
6447 flags &= ~OCFS2_DIRSYNC_FL;
6449 + if (IS_BARRIER(inode)) {
6450 + vxwprintk_task(1, "messing with the barrier.");
6454 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6455 if (IS_ERR(handle)) {
6456 status = PTR_ERR(handle);
6457 @@ -451,6 +490,7 @@ bail:
6462 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6464 struct inode *inode = filp->f_path.dentry->d_inode;
6465 diff -NurpP --minimal linux-2.6.37/fs/ocfs2/namei.c linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/namei.c
6466 --- linux-2.6.37/fs/ocfs2/namei.c 2011-01-05 21:50:26.000000000 +0100
6467 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/namei.c 2010-11-23 02:09:41.000000000 +0100
6469 #include <linux/slab.h>
6470 #include <linux/highmem.h>
6471 #include <linux/quotaops.h>
6472 +#include <linux/vs_tag.h>
6474 #define MLOG_MASK_PREFIX ML_NAMEI
6475 #include <cluster/masklog.h>
6476 @@ -487,6 +488,7 @@ static int __ocfs2_mknod_locked(struct i
6477 struct ocfs2_dinode *fe = NULL;
6478 struct ocfs2_extent_list *fel;
6484 @@ -524,8 +526,11 @@ static int __ocfs2_mknod_locked(struct i
6485 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
6486 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6487 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6488 - fe->i_uid = cpu_to_le32(inode->i_uid);
6489 - fe->i_gid = cpu_to_le32(inode->i_gid);
6491 + tag = dx_current_fstag(osb->sb);
6492 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6493 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6494 + inode->i_tag = tag;
6495 fe->i_mode = cpu_to_le16(inode->i_mode);
6496 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6497 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6498 diff -NurpP --minimal linux-2.6.37/fs/ocfs2/ocfs2_fs.h linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/ocfs2_fs.h
6499 --- linux-2.6.37/fs/ocfs2/ocfs2_fs.h 2011-01-05 21:50:26.000000000 +0100
6500 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/ocfs2_fs.h 2011-01-05 22:30:39.000000000 +0100
6501 @@ -266,6 +266,11 @@
6502 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
6503 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
6505 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6507 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6508 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6510 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
6511 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
6513 diff -NurpP --minimal linux-2.6.37/fs/ocfs2/ocfs2.h linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/ocfs2.h
6514 --- linux-2.6.37/fs/ocfs2/ocfs2.h 2011-01-05 21:50:26.000000000 +0100
6515 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/ocfs2.h 2011-01-05 22:30:39.000000000 +0100
6516 @@ -267,6 +267,7 @@ enum ocfs2_mount_options
6518 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
6519 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
6520 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
6523 #define OCFS2_OSB_SOFT_RO 0x0001
6524 diff -NurpP --minimal linux-2.6.37/fs/ocfs2/super.c linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/super.c
6525 --- linux-2.6.37/fs/ocfs2/super.c 2011-01-05 21:50:26.000000000 +0100
6526 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/ocfs2/super.c 2010-11-23 03:14:32.000000000 +0100
6527 @@ -181,6 +181,7 @@ enum {
6531 + Opt_tag, Opt_notag, Opt_tagid,
6535 @@ -212,6 +213,9 @@ static const match_table_t tokens = {
6536 {Opt_coherency_full, "coherency=full"},
6537 {Opt_resv_level, "resv_level=%u"},
6538 {Opt_dir_resv_level, "dir_resv_level=%u"},
6540 + {Opt_notag, "notag"},
6541 + {Opt_tagid, "tagid=%u"},
6545 @@ -659,6 +663,13 @@ static int ocfs2_remount(struct super_bl
6549 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6550 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6552 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6556 /* We're going to/from readonly mode. */
6557 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
6558 /* Disable quota accounting before remounting RO */
6559 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
6561 ocfs2_complete_mount_recovery(osb);
6563 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6564 + sb->s_flags |= MS_TAGGED;
6566 if (ocfs2_mount_local(osb))
6567 snprintf(nodestr, sizeof(nodestr), "local");
6569 @@ -1499,6 +1513,20 @@ static int ocfs2_parse_options(struct su
6570 option < OCFS2_MAX_RESV_LEVEL)
6571 mopt->dir_resv_level = option;
6573 +#ifndef CONFIG_TAGGING_NONE
6575 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6578 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6581 +#ifdef CONFIG_PROPAGATE
6584 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6589 "Unrecognized mount option \"%s\" "
6590 diff -NurpP --minimal linux-2.6.37/fs/open.c linux-2.6.37-vs2.3.0.37-rc2/fs/open.c
6591 --- linux-2.6.37/fs/open.c 2011-01-05 21:50:26.000000000 +0100
6592 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/open.c 2010-11-23 02:09:41.000000000 +0100
6594 #include <linux/fs_struct.h>
6595 #include <linux/ima.h>
6596 #include <linux/dnotify.h>
6597 +#include <linux/vs_base.h>
6598 +#include <linux/vs_limit.h>
6599 +#include <linux/vs_tag.h>
6600 +#include <linux/vs_cowbl.h>
6601 +#include <linux/vserver/dlimit.h>
6603 #include "internal.h"
6605 @@ -481,6 +486,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6606 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6610 +#ifdef CONFIG_VSERVER_COWBL
6611 + error = cow_check_and_break(&path);
6613 + goto dput_and_out;
6615 inode = path.dentry->d_inode;
6617 error = mnt_want_write(path.mnt);
6618 @@ -518,11 +529,11 @@ static int chown_common(struct path *pat
6619 newattrs.ia_valid = ATTR_CTIME;
6620 if (user != (uid_t) -1) {
6621 newattrs.ia_valid |= ATTR_UID;
6622 - newattrs.ia_uid = user;
6623 + newattrs.ia_uid = dx_map_uid(user);
6625 if (group != (gid_t) -1) {
6626 newattrs.ia_valid |= ATTR_GID;
6627 - newattrs.ia_gid = group;
6628 + newattrs.ia_gid = dx_map_gid(group);
6630 if (!S_ISDIR(inode->i_mode))
6631 newattrs.ia_valid |=
6632 @@ -547,6 +558,10 @@ SYSCALL_DEFINE3(chown, const char __user
6633 error = mnt_want_write(path.mnt);
6636 +#ifdef CONFIG_VSERVER_COWBL
6637 + error = cow_check_and_break(&path);
6640 error = chown_common(&path, user, group);
6641 mnt_drop_write(path.mnt);
6643 @@ -572,6 +587,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6644 error = mnt_want_write(path.mnt);
6647 +#ifdef CONFIG_VSERVER_COWBL
6648 + error = cow_check_and_break(&path);
6651 error = chown_common(&path, user, group);
6652 mnt_drop_write(path.mnt);
6654 @@ -591,6 +610,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6655 error = mnt_want_write(path.mnt);
6658 +#ifdef CONFIG_VSERVER_COWBL
6659 + error = cow_check_and_break(&path);
6662 error = chown_common(&path, user, group);
6663 mnt_drop_write(path.mnt);
6665 @@ -837,6 +860,7 @@ static void __put_unused_fd(struct files
6666 __FD_CLR(fd, fdt->open_fds);
6667 if (fd < files->next_fd)
6668 files->next_fd = fd;
6669 + vx_openfd_dec(fd);
6672 void put_unused_fd(unsigned int fd)
6673 diff -NurpP --minimal linux-2.6.37/fs/proc/array.c linux-2.6.37-vs2.3.0.37-rc2/fs/proc/array.c
6674 --- linux-2.6.37/fs/proc/array.c 2010-08-02 16:52:51.000000000 +0200
6675 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/proc/array.c 2010-11-23 02:09:41.000000000 +0100
6677 #include <linux/pid_namespace.h>
6678 #include <linux/ptrace.h>
6679 #include <linux/tracehook.h>
6680 +#include <linux/vs_context.h>
6681 +#include <linux/vs_network.h>
6683 #include <asm/pgtable.h>
6684 #include <asm/processor.h>
6685 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6687 ppid = pid_alive(p) ?
6688 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6689 + if (unlikely(vx_current_initpid(p->pid)))
6694 struct task_struct *tracer = tracehook_tracer_task(p);
6695 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6698 static void render_cap_t(struct seq_file *m, const char *header,
6700 + struct vx_info *vxi, kernel_cap_t *a)
6704 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6705 cap_bset = cred->cap_bset;
6708 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6709 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6710 - render_cap_t(m, "CapEff:\t", &cap_effective);
6711 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6712 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6713 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6714 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6715 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6716 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6719 static inline void task_context_switch_counts(struct seq_file *m,
6720 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6721 seq_printf(m, "\n");
6724 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6725 + struct pid *pid, struct task_struct *task)
6727 + seq_printf(m, "Proxy:\t%p(%c)\n"
6735 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6736 + atomic_read(&task->nsproxy->count),
6737 + task->nsproxy->uts_ns,
6738 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6739 + task->nsproxy->ipc_ns,
6740 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6741 + task->nsproxy->mnt_ns,
6742 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6743 + task->nsproxy->pid_ns,
6744 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6745 + task->nsproxy->net_ns,
6746 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6750 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6752 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6755 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6756 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6760 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6761 struct pid *pid, struct task_struct *task)
6763 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6765 task_cpus_allowed(m, task);
6766 cpuset_task_status_allowed(m, task);
6767 + task_vs_id(m, task);
6768 #if defined(CONFIG_S390)
6769 task_show_regs(m, task);
6771 @@ -465,6 +508,17 @@ static int do_task_stat(struct seq_file
6772 /* convert nsec -> ticks */
6773 start_time = nsec_to_clock_t(start_time);
6775 + /* fixup start time for virt uptime */
6776 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6777 + unsigned long long bias =
6778 + current->vx_info->cvirt.bias_clock;
6780 + if (start_time > bias)
6781 + start_time -= bias;
6786 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6787 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6788 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6789 diff -NurpP --minimal linux-2.6.37/fs/proc/base.c linux-2.6.37-vs2.3.0.37-rc2/fs/proc/base.c
6790 --- linux-2.6.37/fs/proc/base.c 2011-01-05 21:50:26.000000000 +0100
6791 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/proc/base.c 2011-01-05 22:30:39.000000000 +0100
6793 #include <linux/pid_namespace.h>
6794 #include <linux/fs_struct.h>
6795 #include <linux/slab.h>
6796 +#include <linux/vs_context.h>
6797 +#include <linux/vs_network.h>
6798 #include "internal.h"
6801 @@ -1056,11 +1058,16 @@ static ssize_t oom_adjust_write(struct f
6805 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6806 + if (oom_adjust < task->signal->oom_adj &&
6807 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6812 + /* prevent guest processes from circumventing the oom killer */
6813 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6814 + oom_adjust = OOM_ADJUST_MIN;
6816 if (oom_adjust != task->signal->oom_adj) {
6817 if (oom_adjust == OOM_DISABLE)
6818 atomic_inc(&task->mm->oom_disable_count);
6819 @@ -1227,7 +1234,7 @@ static ssize_t proc_loginuid_write(struc
6823 - if (!capable(CAP_AUDIT_CONTROL))
6824 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6828 @@ -1666,6 +1673,8 @@ static struct inode *proc_pid_make_inode
6829 inode->i_gid = cred->egid;
6832 + /* procfs is xid tagged */
6833 + inode->i_tag = (tag_t)vx_task_xid(task);
6834 security_task_to_inode(task, inode);
6837 @@ -2219,6 +2228,13 @@ static struct dentry *proc_pident_lookup
6841 + /* TODO: maybe we can come up with a generic approach? */
6842 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6843 + (dentry->d_name.len == 5) &&
6844 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6845 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6849 * Yes, it does not scale. And it should not. Don't add
6850 * new entries into /proc/<tgid>/ without very good reasons.
6851 @@ -2628,7 +2644,7 @@ out_iput:
6852 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6854 struct dentry *error;
6855 - struct task_struct *task = get_proc_task(dir);
6856 + struct task_struct *task = get_proc_task_real(dir);
6857 const struct pid_entry *p, *last;
6859 error = ERR_PTR(-ENOENT);
6860 @@ -2718,6 +2734,9 @@ static int proc_pid_personality(struct s
6861 static const struct file_operations proc_task_operations;
6862 static const struct inode_operations proc_task_inode_operations;
6864 +extern int proc_pid_vx_info(struct task_struct *, char *);
6865 +extern int proc_pid_nx_info(struct task_struct *, char *);
6867 static const struct pid_entry tgid_base_stuff[] = {
6868 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6869 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6870 @@ -2777,6 +2796,8 @@ static const struct pid_entry tgid_base_
6871 #ifdef CONFIG_CGROUPS
6872 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6874 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6875 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6876 INF("oom_score", S_IRUGO, proc_oom_score),
6877 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6878 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6879 @@ -2793,6 +2814,7 @@ static const struct pid_entry tgid_base_
6880 #ifdef CONFIG_TASK_IO_ACCOUNTING
6881 INF("io", S_IRUGO, proc_tgid_io_accounting),
6883 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6886 static int proc_tgid_base_readdir(struct file * filp,
6887 @@ -2985,7 +3007,7 @@ retry:
6889 pid = find_ge_pid(iter.tgid, ns);
6891 - iter.tgid = pid_nr_ns(pid, ns);
6892 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6893 iter.task = pid_task(pid, PIDTYPE_PID);
6894 /* What we to know is if the pid we have find is the
6895 * pid of a thread_group_leader. Testing for task
6896 @@ -3015,7 +3037,7 @@ static int proc_pid_fill_cache(struct fi
6897 struct tgid_iter iter)
6899 char name[PROC_NUMBUF];
6900 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6901 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6902 return proc_fill_cache(filp, dirent, filldir, name, len,
6903 proc_pid_instantiate, iter.task, NULL);
6905 @@ -3024,7 +3046,7 @@ static int proc_pid_fill_cache(struct fi
6906 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
6908 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6909 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
6910 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6911 struct tgid_iter iter;
6912 struct pid_namespace *ns;
6914 @@ -3044,6 +3066,8 @@ int proc_pid_readdir(struct file * filp,
6916 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6917 filp->f_pos = iter.tgid + TGID_OFFSET;
6918 + if (!vx_proc_task_visible(iter.task))
6920 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6921 put_task_struct(iter.task);
6923 @@ -3193,6 +3217,8 @@ static struct dentry *proc_task_lookup(s
6924 tid = name_to_int(dentry);
6927 + if (vx_current_initpid(tid))
6930 ns = dentry->d_sb->s_fs_info;
6932 diff -NurpP --minimal linux-2.6.37/fs/proc/generic.c linux-2.6.37-vs2.3.0.37-rc2/fs/proc/generic.c
6933 --- linux-2.6.37/fs/proc/generic.c 2010-10-21 13:07:51.000000000 +0200
6934 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/proc/generic.c 2010-11-23 02:09:41.000000000 +0100
6936 #include <linux/bitops.h>
6937 #include <linux/spinlock.h>
6938 #include <linux/completion.h>
6939 +#include <linux/vserver/inode.h>
6940 #include <asm/uaccess.h>
6942 #include "internal.h"
6943 @@ -424,6 +425,8 @@ struct dentry *proc_lookup_de(struct pro
6944 for (de = de->subdir; de ; de = de->next) {
6945 if (de->namelen != dentry->d_name.len)
6947 + if (!vx_hide_check(0, de->vx_flags))
6949 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6952 @@ -432,6 +435,8 @@ struct dentry *proc_lookup_de(struct pro
6953 spin_unlock(&proc_subdir_lock);
6955 inode = proc_get_inode(dir->i_sb, ino, de);
6956 + /* generic proc entries belong to the host */
6961 @@ -509,6 +514,8 @@ int proc_readdir_de(struct proc_dir_entr
6963 /* filldir passes info to user space */
6965 + if (!vx_hide_check(0, de->vx_flags))
6967 spin_unlock(&proc_subdir_lock);
6968 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6969 de->low_ino, de->mode >> 12) < 0) {
6970 @@ -516,6 +523,7 @@ int proc_readdir_de(struct proc_dir_entr
6973 spin_lock(&proc_subdir_lock);
6978 @@ -630,6 +638,7 @@ static struct proc_dir_entry *__proc_cre
6980 atomic_set(&ent->count, 1);
6982 + ent->vx_flags = IATTR_PROC_DEFAULT;
6983 spin_lock_init(&ent->pde_unload_lock);
6984 ent->pde_unload_completion = NULL;
6985 INIT_LIST_HEAD(&ent->pde_openers);
6986 @@ -653,7 +662,8 @@ struct proc_dir_entry *proc_symlink(cons
6992 + ent->vx_flags = IATTR_PROC_SYMLINK;
6996 diff -NurpP --minimal linux-2.6.37/fs/proc/inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/proc/inode.c
6997 --- linux-2.6.37/fs/proc/inode.c 2011-01-05 21:50:26.000000000 +0100
6998 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/proc/inode.c 2010-11-23 02:09:41.000000000 +0100
6999 @@ -427,6 +427,8 @@ struct inode *proc_get_inode(struct supe
7000 inode->i_uid = de->uid;
7001 inode->i_gid = de->gid;
7004 + PROC_I(inode)->vx_flags = de->vx_flags;
7006 inode->i_size = de->size;
7008 diff -NurpP --minimal linux-2.6.37/fs/proc/internal.h linux-2.6.37-vs2.3.0.37-rc2/fs/proc/internal.h
7009 --- linux-2.6.37/fs/proc/internal.h 2010-02-25 11:52:06.000000000 +0100
7010 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/proc/internal.h 2010-11-23 02:09:41.000000000 +0100
7014 #include <linux/proc_fs.h>
7015 +#include <linux/vs_pid.h>
7017 extern struct proc_dir_entry proc_root;
7018 #ifdef CONFIG_PROC_SYSCTL
7019 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
7020 struct pid *pid, struct task_struct *task);
7021 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
7022 struct pid *pid, struct task_struct *task);
7023 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
7024 + struct pid *pid, struct task_struct *task);
7026 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
7028 extern const struct file_operations proc_maps_operations;
7029 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
7030 return PROC_I(inode)->pid;
7033 -static inline struct task_struct *get_proc_task(struct inode *inode)
7034 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
7036 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
7039 +static inline struct task_struct *get_proc_task(struct inode *inode)
7041 + return vx_get_proc_task(inode, proc_pid(inode));
7044 static inline int proc_fd(struct inode *inode)
7046 return PROC_I(inode)->fd;
7047 diff -NurpP --minimal linux-2.6.37/fs/proc/loadavg.c linux-2.6.37-vs2.3.0.37-rc2/fs/proc/loadavg.c
7048 --- linux-2.6.37/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
7049 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/proc/loadavg.c 2010-11-23 02:09:41.000000000 +0100
7052 static int loadavg_proc_show(struct seq_file *m, void *v)
7054 + unsigned long running;
7055 + unsigned int threads;
7056 unsigned long avnrun[3];
7058 get_avenrun(avnrun, FIXED_1/200, 0);
7060 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
7061 + struct vx_info *vxi = current_vx_info();
7063 + running = atomic_read(&vxi->cvirt.nr_running);
7064 + threads = atomic_read(&vxi->cvirt.nr_threads);
7066 + running = nr_running();
7067 + threads = nr_threads;
7070 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
7071 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
7072 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
7073 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
7074 - nr_running(), nr_threads,
7076 task_active_pid_ns(current)->last_pid);
7079 diff -NurpP --minimal linux-2.6.37/fs/proc/meminfo.c linux-2.6.37-vs2.3.0.37-rc2/fs/proc/meminfo.c
7080 --- linux-2.6.37/fs/proc/meminfo.c 2009-12-03 20:02:53.000000000 +0100
7081 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/proc/meminfo.c 2010-11-23 02:09:41.000000000 +0100
7082 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
7083 allowed = ((totalram_pages - hugetlb_total_pages())
7084 * sysctl_overcommit_ratio / 100) + total_swap_pages;
7086 - cached = global_page_state(NR_FILE_PAGES) -
7087 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
7088 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
7089 total_swapcache_pages - i.bufferram;
7092 diff -NurpP --minimal linux-2.6.37/fs/proc/root.c linux-2.6.37-vs2.3.0.37-rc2/fs/proc/root.c
7093 --- linux-2.6.37/fs/proc/root.c 2011-01-05 21:50:26.000000000 +0100
7094 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/proc/root.c 2010-11-23 02:09:41.000000000 +0100
7096 #include <linux/bitops.h>
7097 #include <linux/mount.h>
7098 #include <linux/pid_namespace.h>
7099 +#include <linux/vserver/inode.h>
7101 #include "internal.h"
7103 +struct proc_dir_entry *proc_virtual;
7105 +extern void proc_vx_init(void);
7107 static int proc_test_super(struct super_block *sb, void *data)
7109 return sb->s_fs_info == data;
7110 @@ -134,6 +139,7 @@ void __init proc_root_init(void)
7112 proc_mkdir("bus", NULL);
7117 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
7118 @@ -202,6 +208,7 @@ struct proc_dir_entry proc_root = {
7119 .proc_iops = &proc_root_inode_operations,
7120 .proc_fops = &proc_root_operations,
7121 .parent = &proc_root,
7122 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
7125 int pid_ns_prepare_proc(struct pid_namespace *ns)
7126 diff -NurpP --minimal linux-2.6.37/fs/proc/uptime.c linux-2.6.37-vs2.3.0.37-rc2/fs/proc/uptime.c
7127 --- linux-2.6.37/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
7128 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/proc/uptime.c 2010-11-23 02:09:41.000000000 +0100
7130 #include <linux/sched.h>
7131 #include <linux/seq_file.h>
7132 #include <linux/time.h>
7133 -#include <linux/kernel_stat.h>
7134 +#include <linux/vserver/cvirt.h>
7135 #include <asm/cputime.h>
7137 static int uptime_proc_show(struct seq_file *m, void *v)
7139 struct timespec uptime;
7140 struct timespec idle;
7142 - cputime_t idletime = cputime_zero;
7144 - for_each_possible_cpu(i)
7145 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
7146 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
7148 do_posix_clock_monotonic_gettime(&uptime);
7149 monotonic_to_bootbased(&uptime);
7150 cputime_to_timespec(idletime, &idle);
7152 + if (vx_flags(VXF_VIRT_UPTIME, 0))
7153 + vx_vsi_uptime(&uptime, &idle);
7155 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
7156 (unsigned long) uptime.tv_sec,
7157 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
7158 diff -NurpP --minimal linux-2.6.37/fs/quota/dquot.c linux-2.6.37-vs2.3.0.37-rc2/fs/quota/dquot.c
7159 --- linux-2.6.37/fs/quota/dquot.c 2011-01-05 21:50:26.000000000 +0100
7160 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/quota/dquot.c 2010-11-23 02:09:41.000000000 +0100
7161 @@ -1541,6 +1541,9 @@ int __dquot_alloc_space(struct inode *in
7162 int reserve = flags & DQUOT_SPACE_RESERVE;
7163 int nofail = flags & DQUOT_SPACE_NOFAIL;
7165 + if ((ret = dl_alloc_space(inode, number)))
7169 * First test before acquiring mutex - solves deadlocks when we
7170 * re-enter the quota code and are already holding the mutex
7171 @@ -1595,6 +1598,9 @@ int dquot_alloc_inode(const struct inode
7173 char warntype[MAXQUOTAS];
7175 + if ((ret = dl_alloc_inode(inode)))
7178 /* First test before acquiring mutex - solves deadlocks when we
7179 * re-enter the quota code and are already holding the mutex */
7180 if (!dquot_active(inode))
7181 @@ -1665,6 +1671,8 @@ void __dquot_free_space(struct inode *in
7182 char warntype[MAXQUOTAS];
7183 int reserve = flags & DQUOT_SPACE_RESERVE;
7185 + dl_free_space(inode, number);
7187 /* First test before acquiring mutex - solves deadlocks when we
7188 * re-enter the quota code and are already holding the mutex */
7189 if (!dquot_active(inode)) {
7190 @@ -1703,6 +1711,8 @@ void dquot_free_inode(const struct inode
7192 char warntype[MAXQUOTAS];
7194 + dl_free_inode(inode);
7196 /* First test before acquiring mutex - solves deadlocks when we
7197 * re-enter the quota code and are already holding the mutex */
7198 if (!dquot_active(inode))
7199 diff -NurpP --minimal linux-2.6.37/fs/quota/quota.c linux-2.6.37-vs2.3.0.37-rc2/fs/quota/quota.c
7200 --- linux-2.6.37/fs/quota/quota.c 2010-08-02 16:52:51.000000000 +0200
7201 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/quota/quota.c 2010-11-23 02:09:41.000000000 +0100
7203 #include <linux/fs.h>
7204 #include <linux/namei.h>
7205 #include <linux/slab.h>
7206 +#include <linux/vs_context.h>
7207 #include <asm/current.h>
7208 #include <asm/uaccess.h>
7209 #include <linux/kernel.h>
7210 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
7214 - if (!capable(CAP_SYS_ADMIN))
7215 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
7219 @@ -296,6 +297,46 @@ static int do_quotactl(struct super_bloc
7223 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7225 +#include <linux/vroot.h>
7226 +#include <linux/major.h>
7227 +#include <linux/module.h>
7228 +#include <linux/kallsyms.h>
7229 +#include <linux/vserver/debug.h>
7231 +static vroot_grb_func *vroot_get_real_bdev = NULL;
7233 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
7235 +int register_vroot_grb(vroot_grb_func *func) {
7238 + spin_lock(&vroot_grb_lock);
7239 + if (!vroot_get_real_bdev) {
7240 + vroot_get_real_bdev = func;
7243 + spin_unlock(&vroot_grb_lock);
7246 +EXPORT_SYMBOL(register_vroot_grb);
7248 +int unregister_vroot_grb(vroot_grb_func *func) {
7249 + int ret = -EINVAL;
7251 + spin_lock(&vroot_grb_lock);
7252 + if (vroot_get_real_bdev) {
7253 + vroot_get_real_bdev = NULL;
7256 + spin_unlock(&vroot_grb_lock);
7259 +EXPORT_SYMBOL(unregister_vroot_grb);
7264 * look up a superblock on which quota ops will be performed
7265 * - use the name of a block device to find the superblock thereon
7266 @@ -313,6 +354,22 @@ static struct super_block *quotactl_bloc
7269 return ERR_CAST(bdev);
7270 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
7271 + if (bdev && bdev->bd_inode &&
7272 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
7273 + struct block_device *bdnew = (void *)-EINVAL;
7275 + if (vroot_get_real_bdev)
7276 + bdnew = vroot_get_real_bdev(bdev);
7278 + vxdprintk(VXD_CBIT(misc, 0),
7279 + "vroot_get_real_bdev not set");
7281 + if (IS_ERR(bdnew))
7282 + return ERR_PTR(PTR_ERR(bdnew));
7286 sb = get_super(bdev);
7289 diff -NurpP --minimal linux-2.6.37/fs/reiserfs/file.c linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/file.c
7290 --- linux-2.6.37/fs/reiserfs/file.c 2011-01-05 21:50:26.000000000 +0100
7291 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/file.c 2010-11-23 02:09:41.000000000 +0100
7292 @@ -312,4 +312,5 @@ const struct inode_operations reiserfs_f
7293 .listxattr = reiserfs_listxattr,
7294 .removexattr = reiserfs_removexattr,
7295 .permission = reiserfs_permission,
7296 + .sync_flags = reiserfs_sync_flags,
7298 diff -NurpP --minimal linux-2.6.37/fs/reiserfs/inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/inode.c
7299 --- linux-2.6.37/fs/reiserfs/inode.c 2011-01-05 21:50:26.000000000 +0100
7300 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/inode.c 2010-11-23 02:09:41.000000000 +0100
7302 #include <linux/writeback.h>
7303 #include <linux/quotaops.h>
7304 #include <linux/swap.h>
7305 +#include <linux/vs_tag.h>
7307 int reiserfs_commit_write(struct file *f, struct page *page,
7308 unsigned from, unsigned to);
7309 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
7310 struct buffer_head *bh;
7311 struct item_head *ih;
7315 //int version = ITEM_VERSION_1;
7317 bh = PATH_PLAST_BUFFER(path);
7318 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
7319 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7320 unsigned long blocks;
7322 + uid = sd_v1_uid(sd);
7323 + gid = sd_v1_gid(sd);
7325 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7326 set_inode_sd_version(inode, STAT_DATA_V1);
7327 inode->i_mode = sd_v1_mode(sd);
7328 inode->i_nlink = sd_v1_nlink(sd);
7329 - inode->i_uid = sd_v1_uid(sd);
7330 - inode->i_gid = sd_v1_gid(sd);
7331 inode->i_size = sd_v1_size(sd);
7332 inode->i_atime.tv_sec = sd_v1_atime(sd);
7333 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7334 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
7335 // (directories and symlinks)
7336 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7338 + uid = sd_v2_uid(sd);
7339 + gid = sd_v2_gid(sd);
7341 inode->i_mode = sd_v2_mode(sd);
7342 inode->i_nlink = sd_v2_nlink(sd);
7343 - inode->i_uid = sd_v2_uid(sd);
7344 inode->i_size = sd_v2_size(sd);
7345 - inode->i_gid = sd_v2_gid(sd);
7346 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7347 inode->i_atime.tv_sec = sd_v2_atime(sd);
7348 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7349 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
7350 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7353 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7354 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7355 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7358 if (S_ISREG(inode->i_mode)) {
7359 inode->i_op = &reiserfs_file_inode_operations;
7360 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
7361 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7363 struct stat_data *sd_v2 = (struct stat_data *)sd;
7364 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7365 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7368 + set_sd_v2_uid(sd_v2, uid);
7369 + set_sd_v2_gid(sd_v2, gid);
7370 set_sd_v2_mode(sd_v2, inode->i_mode);
7371 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7372 - set_sd_v2_uid(sd_v2, inode->i_uid);
7373 set_sd_v2_size(sd_v2, size);
7374 - set_sd_v2_gid(sd_v2, inode->i_gid);
7375 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7376 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7377 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7378 @@ -2858,14 +2869,19 @@ int reiserfs_commit_write(struct file *f
7379 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7381 if (reiserfs_attrs(inode->i_sb)) {
7382 - if (sd_attrs & REISERFS_SYNC_FL)
7383 - inode->i_flags |= S_SYNC;
7385 - inode->i_flags &= ~S_SYNC;
7386 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7387 inode->i_flags |= S_IMMUTABLE;
7389 inode->i_flags &= ~S_IMMUTABLE;
7390 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7391 + inode->i_flags |= S_IXUNLINK;
7393 + inode->i_flags &= ~S_IXUNLINK;
7395 + if (sd_attrs & REISERFS_SYNC_FL)
7396 + inode->i_flags |= S_SYNC;
7398 + inode->i_flags &= ~S_SYNC;
7399 if (sd_attrs & REISERFS_APPEND_FL)
7400 inode->i_flags |= S_APPEND;
7402 @@ -2878,6 +2894,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7403 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7405 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7407 + if (sd_attrs & REISERFS_BARRIER_FL)
7408 + inode->i_vflags |= V_BARRIER;
7410 + inode->i_vflags &= ~V_BARRIER;
7411 + if (sd_attrs & REISERFS_COW_FL)
7412 + inode->i_vflags |= V_COW;
7414 + inode->i_vflags &= ~V_COW;
7418 @@ -2888,6 +2913,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7419 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7421 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7422 + if (inode->i_flags & S_IXUNLINK)
7423 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7425 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7427 if (inode->i_flags & S_SYNC)
7428 *sd_attrs |= REISERFS_SYNC_FL;
7430 @@ -2900,6 +2930,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7431 *sd_attrs |= REISERFS_NOTAIL_FL;
7433 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7435 + if (inode->i_vflags & V_BARRIER)
7436 + *sd_attrs |= REISERFS_BARRIER_FL;
7438 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7439 + if (inode->i_vflags & V_COW)
7440 + *sd_attrs |= REISERFS_COW_FL;
7442 + *sd_attrs &= ~REISERFS_COW_FL;
7446 @@ -3143,7 +3182,8 @@ int reiserfs_setattr(struct dentry *dent
7449 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7450 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7451 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7452 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7453 struct reiserfs_transaction_handle th;
7456 @@ -3172,6 +3212,9 @@ int reiserfs_setattr(struct dentry *dent
7457 inode->i_uid = attr->ia_uid;
7458 if (attr->ia_valid & ATTR_GID)
7459 inode->i_gid = attr->ia_gid;
7460 + if ((attr->ia_valid & ATTR_TAG) &&
7462 + inode->i_tag = attr->ia_tag;
7463 mark_inode_dirty(inode);
7464 error = journal_end(&th, inode->i_sb, jbegin_count);
7466 diff -NurpP --minimal linux-2.6.37/fs/reiserfs/ioctl.c linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/ioctl.c
7467 --- linux-2.6.37/fs/reiserfs/ioctl.c 2011-01-05 21:50:26.000000000 +0100
7468 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/ioctl.c 2011-01-05 22:30:39.000000000 +0100
7470 #include <linux/pagemap.h>
7471 #include <linux/compat.h>
7474 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7476 + __u16 sd_attrs = 0;
7478 + inode->i_flags = flags;
7479 + inode->i_vflags = vflags;
7481 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7482 + REISERFS_I(inode)->i_attrs = sd_attrs;
7483 + inode->i_ctime = CURRENT_TIME_SEC;
7484 + mark_inode_dirty(inode);
7489 * reiserfs_ioctl - handler for ioctl for inode
7490 * supported commands:
7492 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7494 struct inode *inode = filp->f_path.dentry->d_inode;
7495 - unsigned int flags;
7496 + unsigned int flags, oldflags;
7499 reiserfs_write_lock(inode->i_sb);
7500 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7502 flags = REISERFS_I(inode)->i_attrs;
7503 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7504 + flags &= REISERFS_FL_USER_VISIBLE;
7505 err = put_user(flags, (int __user *)arg);
7507 case REISERFS_IOC_SETFLAGS:{
7508 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7512 + if (IS_BARRIER(inode)) {
7513 + vxwprintk_task(1, "messing with the barrier.");
7517 * Is it quota file? Do not allow user to mess with it
7519 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7524 + oldflags = REISERFS_I(inode)->i_attrs;
7525 + flags &= REISERFS_FL_USER_MODIFIABLE;
7526 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7527 sd_attrs_to_i_attrs(flags, inode);
7528 REISERFS_I(inode)->i_attrs = flags;
7529 inode->i_ctime = CURRENT_TIME_SEC;
7530 diff -NurpP --minimal linux-2.6.37/fs/reiserfs/namei.c linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/namei.c
7531 --- linux-2.6.37/fs/reiserfs/namei.c 2011-01-05 21:50:26.000000000 +0100
7532 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/namei.c 2010-11-23 02:09:41.000000000 +0100
7534 #include <linux/reiserfs_acl.h>
7535 #include <linux/reiserfs_xattr.h>
7536 #include <linux/quotaops.h>
7537 +#include <linux/vs_tag.h>
7539 #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; }
7540 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7541 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7542 if (retval == IO_ERROR) {
7543 return ERR_PTR(-EIO);
7545 + dx_propagate_tag(nd, inode);
7547 return d_splice_alias(inode, dentry);
7549 @@ -1532,6 +1534,7 @@ const struct inode_operations reiserfs_d
7550 .listxattr = reiserfs_listxattr,
7551 .removexattr = reiserfs_removexattr,
7552 .permission = reiserfs_permission,
7553 + .sync_flags = reiserfs_sync_flags,
7557 diff -NurpP --minimal linux-2.6.37/fs/reiserfs/super.c linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/super.c
7558 --- linux-2.6.37/fs/reiserfs/super.c 2011-01-05 21:50:26.000000000 +0100
7559 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/super.c 2010-11-23 02:09:41.000000000 +0100
7560 @@ -892,6 +892,14 @@ static int reiserfs_parse_options(struct
7561 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7562 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7564 +#ifndef CONFIG_TAGGING_NONE
7565 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7566 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7567 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7569 +#ifdef CONFIG_PROPAGATE
7570 + {"tag",.arg_required = 'T',.values = NULL},
7572 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7573 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7574 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7575 @@ -1201,6 +1209,14 @@ static int reiserfs_remount(struct super
7576 handle_quota_files(s, qf_names, &qfmt);
7579 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7580 + !(s->s_flags & MS_TAGGED)) {
7581 + reiserfs_warning(s, "super-vs01",
7582 + "reiserfs: tagging not permitted on remount.");
7589 /* Add options that are safe here */
7590 @@ -1683,6 +1699,10 @@ static int reiserfs_fill_super(struct su
7594 + /* map mount option tagxid */
7595 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7596 + s->s_flags |= MS_TAGGED;
7598 rs = SB_DISK_SUPER_BLOCK(s);
7599 /* Let's do basic sanity check to verify that underlying device is not
7600 smaller than the filesystem. If the check fails then abort and scream,
7601 diff -NurpP --minimal linux-2.6.37/fs/reiserfs/xattr.c linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/xattr.c
7602 --- linux-2.6.37/fs/reiserfs/xattr.c 2011-01-05 21:50:26.000000000 +0100
7603 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/reiserfs/xattr.c 2010-11-23 02:09:41.000000000 +0100
7605 #include <linux/errno.h>
7606 #include <linux/gfp.h>
7607 #include <linux/fs.h>
7608 +#include <linux/mount.h>
7609 #include <linux/file.h>
7610 #include <linux/pagemap.h>
7611 #include <linux/xattr.h>
7612 diff -NurpP --minimal linux-2.6.37/fs/stat.c linux-2.6.37-vs2.3.0.37-rc2/fs/stat.c
7613 --- linux-2.6.37/fs/stat.c 2010-10-21 13:07:51.000000000 +0200
7614 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/stat.c 2010-11-23 02:09:41.000000000 +0100
7615 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7616 stat->nlink = inode->i_nlink;
7617 stat->uid = inode->i_uid;
7618 stat->gid = inode->i_gid;
7619 + stat->tag = inode->i_tag;
7620 stat->rdev = inode->i_rdev;
7621 stat->atime = inode->i_atime;
7622 stat->mtime = inode->i_mtime;
7623 diff -NurpP --minimal linux-2.6.37/fs/statfs.c linux-2.6.37-vs2.3.0.37-rc2/fs/statfs.c
7624 --- linux-2.6.37/fs/statfs.c 2010-10-21 13:07:51.000000000 +0200
7625 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/statfs.c 2010-11-23 02:09:41.000000000 +0100
7627 #include <linux/statfs.h>
7628 #include <linux/security.h>
7629 #include <linux/uaccess.h>
7630 +#include <linux/vs_base.h>
7631 +#include <linux/vs_dlimit.h>
7633 static int flags_by_mnt(int mnt_flags)
7635 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
7636 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7637 if (retval == 0 && buf->f_frsize == 0)
7638 buf->f_frsize = buf->f_bsize;
7639 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7640 + vx_vsi_statfs(dentry->d_sb, buf);
7644 diff -NurpP --minimal linux-2.6.37/fs/super.c linux-2.6.37-vs2.3.0.37-rc2/fs/super.c
7645 --- linux-2.6.37/fs/super.c 2011-01-05 21:50:27.000000000 +0100
7646 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/super.c 2010-11-23 03:09:36.000000000 +0100
7648 #include <linux/idr.h>
7649 #include <linux/mutex.h>
7650 #include <linux/backing-dev.h>
7651 +#include <linux/devpts_fs.h>
7652 +#include <linux/proc_fs.h>
7653 +#include <linux/vs_context.h>
7654 #include "internal.h"
7657 @@ -956,6 +959,7 @@ struct vfsmount *
7658 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
7660 struct vfsmount *mnt;
7661 + struct super_block *sb;
7662 struct dentry *root;
7663 char *secdata = NULL;
7665 @@ -963,6 +967,11 @@ vfs_kern_mount(struct file_system_type *
7667 return ERR_PTR(-ENODEV);
7670 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
7671 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
7675 mnt = alloc_vfsmnt(name);
7677 @@ -994,11 +1003,19 @@ vfs_kern_mount(struct file_system_type *
7679 goto out_free_secdata;
7681 - BUG_ON(!mnt->mnt_sb);
7682 - WARN_ON(!mnt->mnt_sb->s_bdi);
7686 + WARN_ON(!sb->s_bdi);
7687 mnt->mnt_sb->s_flags |= MS_BORN;
7689 - error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
7691 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
7692 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7693 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7696 + error = security_sb_kern_mount(sb, flags, secdata);
7700 diff -NurpP --minimal linux-2.6.37/fs/sysfs/mount.c linux-2.6.37-vs2.3.0.37-rc2/fs/sysfs/mount.c
7701 --- linux-2.6.37/fs/sysfs/mount.c 2011-01-05 21:50:27.000000000 +0100
7702 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/sysfs/mount.c 2010-11-23 02:09:41.000000000 +0100
7703 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7705 sb->s_blocksize = PAGE_CACHE_SIZE;
7706 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7707 - sb->s_magic = SYSFS_MAGIC;
7708 + sb->s_magic = SYSFS_SUPER_MAGIC;
7709 sb->s_op = &sysfs_ops;
7710 sb->s_time_gran = 1;
7712 diff -NurpP --minimal linux-2.6.37/fs/utimes.c linux-2.6.37-vs2.3.0.37-rc2/fs/utimes.c
7713 --- linux-2.6.37/fs/utimes.c 2010-10-21 13:07:51.000000000 +0200
7714 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/utimes.c 2010-11-23 02:09:41.000000000 +0100
7716 #include <linux/stat.h>
7717 #include <linux/utime.h>
7718 #include <linux/syscalls.h>
7719 +#include <linux/mount.h>
7720 +#include <linux/vs_cowbl.h>
7721 #include <asm/uaccess.h>
7722 #include <asm/unistd.h>
7724 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7727 struct iattr newattrs;
7728 - struct inode *inode = path->dentry->d_inode;
7729 + struct inode *inode;
7731 error = mnt_want_write(path->mnt);
7735 + error = cow_check_and_break(path);
7737 + goto mnt_drop_write_and_out;
7739 + inode = path->dentry->d_inode;
7741 if (times && times[0].tv_nsec == UTIME_NOW &&
7742 times[1].tv_nsec == UTIME_NOW)
7744 diff -NurpP --minimal linux-2.6.37/fs/xattr.c linux-2.6.37-vs2.3.0.37-rc2/fs/xattr.c
7745 --- linux-2.6.37/fs/xattr.c 2010-08-02 16:52:52.000000000 +0200
7746 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xattr.c 2010-11-23 02:09:41.000000000 +0100
7748 #include <linux/module.h>
7749 #include <linux/fsnotify.h>
7750 #include <linux/audit.h>
7751 +#include <linux/mount.h>
7752 #include <asm/uaccess.h>
7755 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7756 * The trusted.* namespace can only be accessed by a privileged user.
7758 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
7759 - return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
7760 + return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
7762 /* In user.* namespace, only regular files and directories can have
7763 * extended attributes. For sticky directories, only the owner and
7764 diff -NurpP --minimal linux-2.6.37/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/linux-2.6/xfs_ioctl.c
7765 --- linux-2.6.37/fs/xfs/linux-2.6/xfs_ioctl.c 2011-01-05 21:50:27.000000000 +0100
7766 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/linux-2.6/xfs_ioctl.c 2010-11-23 02:09:41.000000000 +0100
7768 #include "xfs_bmap_btree.h"
7769 #include "xfs_dinode.h"
7770 #include "xfs_inode.h"
7771 -#include "xfs_ioctl.h"
7772 +// #include "xfs_ioctl.h"
7773 #include "xfs_rtalloc.h"
7774 #include "xfs_itable.h"
7775 #include "xfs_error.h"
7776 @@ -738,6 +738,10 @@ xfs_merge_ioc_xflags(
7777 xflags |= XFS_XFLAG_IMMUTABLE;
7779 xflags &= ~XFS_XFLAG_IMMUTABLE;
7780 + if (flags & FS_IXUNLINK_FL)
7781 + xflags |= XFS_XFLAG_IXUNLINK;
7783 + xflags &= ~XFS_XFLAG_IXUNLINK;
7784 if (flags & FS_APPEND_FL)
7785 xflags |= XFS_XFLAG_APPEND;
7787 @@ -766,6 +770,8 @@ xfs_di2lxflags(
7789 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7790 flags |= FS_IMMUTABLE_FL;
7791 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7792 + flags |= FS_IXUNLINK_FL;
7793 if (di_flags & XFS_DIFLAG_APPEND)
7794 flags |= FS_APPEND_FL;
7795 if (di_flags & XFS_DIFLAG_SYNC)
7796 @@ -826,6 +832,8 @@ xfs_set_diflags(
7797 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7798 if (xflags & XFS_XFLAG_IMMUTABLE)
7799 di_flags |= XFS_DIFLAG_IMMUTABLE;
7800 + if (xflags & XFS_XFLAG_IXUNLINK)
7801 + di_flags |= XFS_DIFLAG_IXUNLINK;
7802 if (xflags & XFS_XFLAG_APPEND)
7803 di_flags |= XFS_DIFLAG_APPEND;
7804 if (xflags & XFS_XFLAG_SYNC)
7805 @@ -868,6 +876,10 @@ xfs_diflags_to_linux(
7806 inode->i_flags |= S_IMMUTABLE;
7808 inode->i_flags &= ~S_IMMUTABLE;
7809 + if (xflags & XFS_XFLAG_IXUNLINK)
7810 + inode->i_flags |= S_IXUNLINK;
7812 + inode->i_flags &= ~S_IXUNLINK;
7813 if (xflags & XFS_XFLAG_APPEND)
7814 inode->i_flags |= S_APPEND;
7816 @@ -1342,10 +1354,18 @@ xfs_file_ioctl(
7817 case XFS_IOC_FSGETXATTRA:
7818 return xfs_ioc_fsgetxattr(ip, 1, arg);
7819 case XFS_IOC_FSSETXATTR:
7820 + if (IS_BARRIER(inode)) {
7821 + vxwprintk_task(1, "messing with the barrier.");
7822 + return -XFS_ERROR(EACCES);
7824 return xfs_ioc_fssetxattr(ip, filp, arg);
7825 case XFS_IOC_GETXFLAGS:
7826 return xfs_ioc_getxflags(ip, arg);
7827 case XFS_IOC_SETXFLAGS:
7828 + if (IS_BARRIER(inode)) {
7829 + vxwprintk_task(1, "messing with the barrier.");
7830 + return -XFS_ERROR(EACCES);
7832 return xfs_ioc_setxflags(ip, filp, arg);
7834 case XFS_IOC_FSSETDM: {
7835 diff -NurpP --minimal linux-2.6.37/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/linux-2.6/xfs_ioctl.h
7836 --- linux-2.6.37/fs/xfs/linux-2.6/xfs_ioctl.h 2010-07-07 18:31:54.000000000 +0200
7837 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/linux-2.6/xfs_ioctl.h 2010-11-23 02:09:41.000000000 +0100
7838 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7839 void __user *uhandle,
7844 + struct inode *inode,
7851 diff -NurpP --minimal linux-2.6.37/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/linux-2.6/xfs_iops.c
7852 --- linux-2.6.37/fs/xfs/linux-2.6/xfs_iops.c 2011-01-05 21:50:27.000000000 +0100
7853 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/linux-2.6/xfs_iops.c 2010-11-23 02:09:41.000000000 +0100
7855 #include "xfs_bmap_btree.h"
7856 #include "xfs_dinode.h"
7857 #include "xfs_inode.h"
7858 +#include "xfs_ioctl.h"
7859 #include "xfs_bmap.h"
7860 #include "xfs_rtalloc.h"
7861 #include "xfs_error.h"
7863 #include <linux/falloc.h>
7864 #include <linux/fiemap.h>
7865 #include <linux/slab.h>
7866 +#include <linux/vs_tag.h>
7869 * Bring the timestamps in the XFS inode uptodate.
7870 @@ -464,6 +466,7 @@ xfs_vn_getattr(
7871 stat->nlink = ip->i_d.di_nlink;
7872 stat->uid = ip->i_d.di_uid;
7873 stat->gid = ip->i_d.di_gid;
7874 + stat->tag = ip->i_d.di_tag;
7875 stat->ino = ip->i_ino;
7876 stat->atime = inode->i_atime;
7877 stat->mtime = inode->i_mtime;
7878 @@ -652,6 +655,7 @@ static const struct inode_operations xfs
7879 .listxattr = xfs_vn_listxattr,
7880 .fallocate = xfs_vn_fallocate,
7881 .fiemap = xfs_vn_fiemap,
7882 + .sync_flags = xfs_sync_flags,
7885 static const struct inode_operations xfs_dir_inode_operations = {
7886 @@ -677,6 +681,7 @@ static const struct inode_operations xfs
7887 .getxattr = generic_getxattr,
7888 .removexattr = generic_removexattr,
7889 .listxattr = xfs_vn_listxattr,
7890 + .sync_flags = xfs_sync_flags,
7893 static const struct inode_operations xfs_dir_ci_inode_operations = {
7894 @@ -726,6 +731,10 @@ xfs_diflags_to_iflags(
7895 inode->i_flags |= S_IMMUTABLE;
7897 inode->i_flags &= ~S_IMMUTABLE;
7898 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7899 + inode->i_flags |= S_IXUNLINK;
7901 + inode->i_flags &= ~S_IXUNLINK;
7902 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7903 inode->i_flags |= S_APPEND;
7905 @@ -738,6 +747,15 @@ xfs_diflags_to_iflags(
7906 inode->i_flags |= S_NOATIME;
7908 inode->i_flags &= ~S_NOATIME;
7910 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7911 + inode->i_vflags |= V_BARRIER;
7913 + inode->i_vflags &= ~V_BARRIER;
7914 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7915 + inode->i_vflags |= V_COW;
7917 + inode->i_vflags &= ~V_COW;
7921 @@ -769,6 +787,7 @@ xfs_setup_inode(
7922 inode->i_nlink = ip->i_d.di_nlink;
7923 inode->i_uid = ip->i_d.di_uid;
7924 inode->i_gid = ip->i_d.di_gid;
7925 + inode->i_tag = ip->i_d.di_tag;
7927 switch (inode->i_mode & S_IFMT) {
7929 diff -NurpP --minimal linux-2.6.37/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/linux-2.6/xfs_linux.h
7930 --- linux-2.6.37/fs/xfs/linux-2.6/xfs_linux.h 2011-01-05 21:50:27.000000000 +0100
7931 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/linux-2.6/xfs_linux.h 2010-11-23 03:28:16.000000000 +0100
7934 #define current_cpu() (raw_smp_processor_id())
7935 #define current_pid() (current->pid)
7936 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7937 #define current_test_flags(f) (current->flags & (f))
7938 #define current_set_flags_nested(sp, f) \
7939 (*(sp) = current->flags, current->flags |= (f))
7940 diff -NurpP --minimal linux-2.6.37/fs/xfs/linux-2.6/xfs_super.c linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/linux-2.6/xfs_super.c
7941 --- linux-2.6.37/fs/xfs/linux-2.6/xfs_super.c 2011-01-05 21:50:27.000000000 +0100
7942 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/linux-2.6/xfs_super.c 2010-11-23 02:09:41.000000000 +0100
7943 @@ -112,6 +112,9 @@ mempool_t *xfs_ioend_pool;
7944 #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
7945 #define MNTOPT_DELAYLOG "delaylog" /* Delayed loging enabled */
7946 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed loging disabled */
7947 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7948 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7949 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7952 * Table driven mount option parser.
7953 @@ -120,10 +123,14 @@ mempool_t *xfs_ioend_pool;
7954 * in the future, too.
7957 + Opt_tag, Opt_notag,
7958 Opt_barrier, Opt_nobarrier, Opt_err
7961 static const match_table_t tokens = {
7962 + {Opt_tag, "tagxid"},
7964 + {Opt_notag, "notag"},
7965 {Opt_barrier, "barrier"},
7966 {Opt_nobarrier, "nobarrier"},
7968 @@ -367,6 +374,19 @@ xfs_parseargs(
7969 } else if (!strcmp(this_char, "irixsgid")) {
7971 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
7972 +#ifndef CONFIG_TAGGING_NONE
7973 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7974 + mp->m_flags |= XFS_MOUNT_TAGGED;
7975 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7976 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7977 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7978 + mp->m_flags |= XFS_MOUNT_TAGGED;
7980 +#ifdef CONFIG_PROPAGATE
7981 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7983 + mp->m_flags |= XFS_MOUNT_TAGGED;
7987 "XFS: unknown mount option [%s].", this_char);
7988 @@ -1312,6 +1332,16 @@ xfs_fs_remount(
7990 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7993 + if (!(sb->s_flags & MS_TAGGED)) {
7995 + "XFS: %s: tagging not permitted on remount.\n",
8004 * Logically we would return an error here to prevent
8005 @@ -1540,6 +1570,9 @@ xfs_fs_fill_super(
8007 goto out_filestream_unmount;
8009 + if (mp->m_flags & XFS_MOUNT_TAGGED)
8010 + sb->s_flags |= MS_TAGGED;
8012 sb->s_magic = XFS_SB_MAGIC;
8013 sb->s_blocksize = mp->m_sb.sb_blocksize;
8014 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
8015 diff -NurpP --minimal linux-2.6.37/fs/xfs/xfs_dinode.h linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_dinode.h
8016 --- linux-2.6.37/fs/xfs/xfs_dinode.h 2011-01-05 21:50:28.000000000 +0100
8017 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_dinode.h 2010-11-23 03:21:21.000000000 +0100
8018 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
8019 __be32 di_nlink; /* number of links to file */
8020 __be16 di_projid_lo; /* lower part of owner's project id */
8021 __be16 di_projid_hi; /* higher part owner's project id */
8022 - __u8 di_pad[6]; /* unused, zeroed space */
8023 + __u8 di_pad[2]; /* unused, zeroed space */
8024 + __be16 di_tag; /* context tagging */
8025 + __be16 di_vflags; /* vserver specific flags */
8026 __be16 di_flushiter; /* incremented on flush */
8027 xfs_timestamp_t di_atime; /* time last accessed */
8028 xfs_timestamp_t di_mtime; /* time last modified */
8029 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
8030 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
8031 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
8032 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
8033 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
8035 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
8036 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
8037 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
8038 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
8039 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
8040 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
8041 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
8042 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
8044 #ifdef CONFIG_XFS_RT
8045 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
8046 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
8047 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
8048 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
8049 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
8050 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
8051 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
8052 + XFS_DIFLAG_IXUNLINK)
8054 +#define XFS_DIVFLAG_BARRIER 0x01
8055 +#define XFS_DIVFLAG_COW 0x02
8057 #endif /* __XFS_DINODE_H__ */
8058 diff -NurpP --minimal linux-2.6.37/fs/xfs/xfs_fs.h linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_fs.h
8059 --- linux-2.6.37/fs/xfs/xfs_fs.h 2011-01-05 21:50:28.000000000 +0100
8060 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_fs.h 2010-11-23 03:16:13.000000000 +0100
8061 @@ -67,6 +67,9 @@ struct fsxattr {
8062 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
8063 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
8064 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
8065 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
8066 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
8067 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
8068 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
8071 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
8072 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
8073 __u16 bs_forkoff; /* inode fork offset in bytes */
8074 __u16 bs_projid_hi; /* higher part of project id */
8075 - unsigned char bs_pad[10]; /* pad space, unused */
8076 + unsigned char bs_pad[8]; /* pad space, unused */
8077 + __u16 bs_tag; /* context tagging */
8078 __u32 bs_dmevmask; /* DMIG event mask */
8079 __u16 bs_dmstate; /* DMIG state info */
8080 __u16 bs_aextents; /* attribute number of extents */
8081 diff -NurpP --minimal linux-2.6.37/fs/xfs/xfs_ialloc.c linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_ialloc.c
8082 --- linux-2.6.37/fs/xfs/xfs_ialloc.c 2011-01-05 21:50:28.000000000 +0100
8083 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_ialloc.c 2010-11-23 02:09:41.000000000 +0100
8085 #include "xfs_error.h"
8086 #include "xfs_bmap.h"
8090 * Allocation group level functions.
8092 diff -NurpP --minimal linux-2.6.37/fs/xfs/xfs_inode.c linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_inode.c
8093 --- linux-2.6.37/fs/xfs/xfs_inode.c 2011-01-05 21:50:28.000000000 +0100
8094 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_inode.c 2010-11-23 03:28:30.000000000 +0100
8095 @@ -245,6 +245,7 @@ xfs_inotobp(
8099 +#include <linux/vs_tag.h>
8102 * This routine is called to map an inode to the buffer containing
8103 @@ -650,15 +651,25 @@ xfs_iformat_btree(
8105 xfs_dinode_from_disk(
8107 - xfs_dinode_t *from)
8108 + xfs_dinode_t *from,
8111 + uint32_t uid, gid, tag;
8113 to->di_magic = be16_to_cpu(from->di_magic);
8114 to->di_mode = be16_to_cpu(from->di_mode);
8115 to->di_version = from ->di_version;
8116 to->di_format = from->di_format;
8117 to->di_onlink = be16_to_cpu(from->di_onlink);
8118 - to->di_uid = be32_to_cpu(from->di_uid);
8119 - to->di_gid = be32_to_cpu(from->di_gid);
8121 + uid = be32_to_cpu(from->di_uid);
8122 + gid = be32_to_cpu(from->di_gid);
8123 + tag = be16_to_cpu(from->di_tag);
8125 + to->di_uid = INOTAG_UID(tagged, uid, gid);
8126 + to->di_gid = INOTAG_GID(tagged, uid, gid);
8127 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
8129 to->di_nlink = be32_to_cpu(from->di_nlink);
8130 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
8131 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
8132 @@ -680,21 +691,26 @@ xfs_dinode_from_disk(
8133 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
8134 to->di_dmstate = be16_to_cpu(from->di_dmstate);
8135 to->di_flags = be16_to_cpu(from->di_flags);
8136 + to->di_vflags = be16_to_cpu(from->di_vflags);
8137 to->di_gen = be32_to_cpu(from->di_gen);
8143 - xfs_icdinode_t *from)
8144 + xfs_icdinode_t *from,
8147 to->di_magic = cpu_to_be16(from->di_magic);
8148 to->di_mode = cpu_to_be16(from->di_mode);
8149 to->di_version = from ->di_version;
8150 to->di_format = from->di_format;
8151 to->di_onlink = cpu_to_be16(from->di_onlink);
8152 - to->di_uid = cpu_to_be32(from->di_uid);
8153 - to->di_gid = cpu_to_be32(from->di_gid);
8155 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
8156 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
8157 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
8159 to->di_nlink = cpu_to_be32(from->di_nlink);
8160 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
8161 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
8162 @@ -716,12 +732,14 @@ xfs_dinode_to_disk(
8163 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
8164 to->di_dmstate = cpu_to_be16(from->di_dmstate);
8165 to->di_flags = cpu_to_be16(from->di_flags);
8166 + to->di_vflags = cpu_to_be16(from->di_vflags);
8167 to->di_gen = cpu_to_be32(from->di_gen);
8172 - __uint16_t di_flags)
8173 + __uint16_t di_flags,
8174 + __uint16_t di_vflags)
8178 @@ -732,6 +750,8 @@ _xfs_dic2xflags(
8179 flags |= XFS_XFLAG_PREALLOC;
8180 if (di_flags & XFS_DIFLAG_IMMUTABLE)
8181 flags |= XFS_XFLAG_IMMUTABLE;
8182 + if (di_flags & XFS_DIFLAG_IXUNLINK)
8183 + flags |= XFS_XFLAG_IXUNLINK;
8184 if (di_flags & XFS_DIFLAG_APPEND)
8185 flags |= XFS_XFLAG_APPEND;
8186 if (di_flags & XFS_DIFLAG_SYNC)
8187 @@ -756,6 +776,10 @@ _xfs_dic2xflags(
8188 flags |= XFS_XFLAG_FILESTREAM;
8191 + if (di_vflags & XFS_DIVFLAG_BARRIER)
8192 + flags |= FS_BARRIER_FL;
8193 + if (di_vflags & XFS_DIVFLAG_COW)
8194 + flags |= FS_COW_FL;
8198 @@ -765,7 +789,7 @@ xfs_ip2xflags(
8200 xfs_icdinode_t *dic = &ip->i_d;
8202 - return _xfs_dic2xflags(dic->di_flags) |
8203 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
8204 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
8207 @@ -773,7 +797,8 @@ uint
8211 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
8212 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
8213 + be16_to_cpu(dip->di_vflags)) |
8214 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
8217 @@ -806,7 +831,6 @@ xfs_iread(
8220 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
8223 * If we got something that isn't an inode it means someone
8224 * (nfs or dmi) has a stale handle.
8225 @@ -831,7 +855,8 @@ xfs_iread(
8226 * Otherwise, just get the truly permanent information.
8229 - xfs_dinode_from_disk(&ip->i_d, dip);
8230 + xfs_dinode_from_disk(&ip->i_d, dip,
8231 + mp->m_flags & XFS_MOUNT_TAGGED);
8232 error = xfs_iformat(ip, dip);
8235 @@ -1028,6 +1053,7 @@ xfs_ialloc(
8236 ASSERT(ip->i_d.di_nlink == nlink);
8237 ip->i_d.di_uid = current_fsuid();
8238 ip->i_d.di_gid = current_fsgid();
8239 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
8240 xfs_set_projid(ip, prid);
8241 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
8243 @@ -1088,6 +1114,7 @@ xfs_ialloc(
8244 ip->i_d.di_dmevmask = 0;
8245 ip->i_d.di_dmstate = 0;
8246 ip->i_d.di_flags = 0;
8247 + ip->i_d.di_vflags = 0;
8248 flags = XFS_ILOG_CORE;
8249 switch (mode & S_IFMT) {
8251 @@ -2106,6 +2133,7 @@ xfs_ifree(
8253 ip->i_d.di_mode = 0; /* mark incore inode as free */
8254 ip->i_d.di_flags = 0;
8255 + ip->i_d.di_vflags = 0;
8256 ip->i_d.di_dmevmask = 0;
8257 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
8258 ip->i_df.if_ext_max =
8259 @@ -2976,7 +3004,8 @@ xfs_iflush_int(
8260 * because if the inode is dirty at all the core must
8263 - xfs_dinode_to_disk(dip, &ip->i_d);
8264 + xfs_dinode_to_disk(dip, &ip->i_d,
8265 + mp->m_flags & XFS_MOUNT_TAGGED);
8267 /* Wrap, we never let the log put out DI_MAX_FLUSH */
8268 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
8269 diff -NurpP --minimal linux-2.6.37/fs/xfs/xfs_inode.h linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_inode.h
8270 --- linux-2.6.37/fs/xfs/xfs_inode.h 2011-01-05 21:50:28.000000000 +0100
8271 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_inode.h 2010-11-23 03:29:08.000000000 +0100
8272 @@ -136,7 +136,9 @@ typedef struct xfs_icdinode {
8273 __uint32_t di_nlink; /* number of links to file */
8274 __uint16_t di_projid_lo; /* lower part of owner's project id */
8275 __uint16_t di_projid_hi; /* higher part of owner's project id */
8276 - __uint8_t di_pad[6]; /* unused, zeroed space */
8277 + __uint8_t di_pad[2]; /* unused, zeroed space */
8278 + __uint16_t di_tag; /* context tagging */
8279 + __uint16_t di_vflags; /* vserver specific flags */
8280 __uint16_t di_flushiter; /* incremented on flush */
8281 xfs_ictimestamp_t di_atime; /* time last accessed */
8282 xfs_ictimestamp_t di_mtime; /* time last modified */
8283 @@ -527,7 +529,7 @@ int xfs_itobp(struct xfs_mount *, struc
8284 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
8285 struct xfs_inode *, uint);
8286 void xfs_dinode_to_disk(struct xfs_dinode *,
8287 - struct xfs_icdinode *);
8288 + struct xfs_icdinode *, int);
8289 void xfs_idestroy_fork(struct xfs_inode *, int);
8290 void xfs_idata_realloc(struct xfs_inode *, int, int);
8291 void xfs_iroot_realloc(struct xfs_inode *, int, int);
8292 diff -NurpP --minimal linux-2.6.37/fs/xfs/xfs_itable.c linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_itable.c
8293 --- linux-2.6.37/fs/xfs/xfs_itable.c 2011-01-05 21:50:28.000000000 +0100
8294 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_itable.c 2010-11-23 02:09:41.000000000 +0100
8295 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
8296 buf->bs_mode = dic->di_mode;
8297 buf->bs_uid = dic->di_uid;
8298 buf->bs_gid = dic->di_gid;
8299 + buf->bs_tag = dic->di_tag;
8300 buf->bs_size = dic->di_size;
8303 diff -NurpP --minimal linux-2.6.37/fs/xfs/xfs_log_recover.c linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_log_recover.c
8304 --- linux-2.6.37/fs/xfs/xfs_log_recover.c 2011-01-05 21:50:28.000000000 +0100
8305 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_log_recover.c 2010-11-23 02:09:41.000000000 +0100
8306 @@ -2451,7 +2451,8 @@ xlog_recover_do_inode_trans(
8309 /* The core is in in-core format */
8310 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
8311 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
8312 + mp->m_flags & XFS_MOUNT_TAGGED);
8314 /* the rest is in on-disk format */
8315 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
8316 diff -NurpP --minimal linux-2.6.37/fs/xfs/xfs_mount.h linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_mount.h
8317 --- linux-2.6.37/fs/xfs/xfs_mount.h 2011-01-05 21:50:28.000000000 +0100
8318 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_mount.h 2010-11-23 02:09:41.000000000 +0100
8319 @@ -239,6 +239,7 @@ typedef struct xfs_mount {
8321 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
8323 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
8326 * Default minimum read and write sizes.
8327 diff -NurpP --minimal linux-2.6.37/fs/xfs/xfs_vnodeops.c linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_vnodeops.c
8328 --- linux-2.6.37/fs/xfs/xfs_vnodeops.c 2011-01-05 21:50:28.000000000 +0100
8329 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_vnodeops.c 2011-01-06 00:07:49.000000000 +0100
8331 #include "xfs_vnodeops.h"
8332 #include "xfs_trace.h"
8336 +xfs_get_inode_flags(
8339 + struct inode *inode = VFS_I(ip);
8340 + unsigned int flags = inode->i_flags;
8341 + unsigned int vflags = inode->i_vflags;
8343 + if (flags & S_IMMUTABLE)
8344 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
8346 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
8347 + if (flags & S_IXUNLINK)
8348 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8350 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8352 + if (vflags & V_BARRIER)
8353 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8355 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8356 + if (vflags & V_COW)
8357 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8359 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8364 + struct inode *inode,
8368 + struct xfs_inode *ip = XFS_I(inode);
8369 + struct xfs_mount *mp = ip->i_mount;
8370 + struct xfs_trans *tp;
8371 + unsigned int lock_flags = 0;
8374 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8375 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8379 + xfs_ilock(ip, XFS_ILOCK_EXCL);
8381 + xfs_trans_ijoin(tp, ip);
8383 + inode->i_flags = flags;
8384 + inode->i_vflags = vflags;
8385 + xfs_get_inode_flags(ip);
8387 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8388 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
8390 + XFS_STATS_INC(xs_ig_attrchg);
8392 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8393 + xfs_trans_set_sync(tp);
8394 + code = xfs_trans_commit(tp, 0);
8395 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8399 + xfs_trans_cancel(tp, 0);
8401 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8408 struct xfs_inode *ip,
8409 @@ -65,6 +137,7 @@ xfs_setattr(
8410 uint commit_flags=0;
8411 uid_t uid=0, iuid=0;
8412 gid_t gid=0, igid=0;
8413 + tag_t tag=0, itag=0;
8414 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8415 int need_iolock = 1;
8417 @@ -147,7 +220,7 @@ xfs_setattr(
8419 * Change file ownership. Must be the owner or privileged.
8421 - if (mask & (ATTR_UID|ATTR_GID)) {
8422 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8424 * These IDs could have changed since we last looked at them.
8425 * But, we're assured that if the ownership did change
8426 @@ -156,8 +229,10 @@ xfs_setattr(
8428 iuid = ip->i_d.di_uid;
8429 igid = ip->i_d.di_gid;
8430 + itag = ip->i_d.di_tag;
8431 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8432 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8433 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8436 * Do a quota reservation only if uid/gid is actually
8437 @@ -165,7 +240,8 @@ xfs_setattr(
8439 if (XFS_IS_QUOTA_RUNNING(mp) &&
8440 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8441 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8442 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8443 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8445 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8446 capable(CAP_FOWNER) ?
8447 @@ -329,7 +405,7 @@ xfs_setattr(
8449 * Change file ownership. Must be the owner or privileged.
8451 - if (mask & (ATTR_UID|ATTR_GID)) {
8452 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8454 * CAP_FSETID overrides the following restrictions:
8456 @@ -345,6 +421,10 @@ xfs_setattr(
8457 * Change the ownerships and register quota modifications
8458 * in the transaction.
8460 + if (itag != tag) {
8461 + ip->i_d.di_tag = tag;
8462 + inode->i_tag = tag;
8465 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8466 ASSERT(mask & ATTR_UID);
8467 diff -NurpP --minimal linux-2.6.37/fs/xfs/xfs_vnodeops.h linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_vnodeops.h
8468 --- linux-2.6.37/fs/xfs/xfs_vnodeops.h 2011-01-05 21:50:28.000000000 +0100
8469 +++ linux-2.6.37-vs2.3.0.37-rc2/fs/xfs/xfs_vnodeops.h 2010-11-23 02:09:41.000000000 +0100
8470 @@ -13,6 +13,7 @@ struct xfs_inode;
8474 +int xfs_sync_xflags(struct xfs_inode *ip);
8475 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8476 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8477 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8478 diff -NurpP --minimal linux-2.6.37/include/asm-generic/tlb.h linux-2.6.37-vs2.3.0.37-rc2/include/asm-generic/tlb.h
8479 --- linux-2.6.37/include/asm-generic/tlb.h 2009-09-10 15:26:24.000000000 +0200
8480 +++ linux-2.6.37-vs2.3.0.37-rc2/include/asm-generic/tlb.h 2010-11-23 02:09:41.000000000 +0100
8482 #define _ASM_GENERIC__TLB_H
8484 #include <linux/swap.h>
8485 +#include <linux/vs_memory.h>
8486 #include <asm/pgalloc.h>
8487 #include <asm/tlbflush.h>
8489 diff -NurpP --minimal linux-2.6.37/include/linux/capability.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/capability.h
8490 --- linux-2.6.37/include/linux/capability.h 2010-10-21 13:07:52.000000000 +0200
8491 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/capability.h 2011-01-06 01:44:43.000000000 +0100
8492 @@ -280,6 +280,7 @@ struct cpu_vfs_cap_data {
8493 arbitrary SCSI commands */
8494 /* Allow setting encryption key on loopback filesystem */
8495 /* Allow setting zone reclaim policy */
8496 +/* Allow the selection of a security context */
8498 #define CAP_SYS_ADMIN 21
8500 @@ -354,7 +355,12 @@ struct cpu_vfs_cap_data {
8502 #define CAP_LAST_CAP CAP_MAC_ADMIN
8504 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8505 +/* Allow context manipulations */
8506 +/* Allow changing context info on files */
8508 +#define CAP_CONTEXT 63
8510 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
8513 * Bit location of each capability (used by user-space library and kernel)
8514 diff -NurpP --minimal linux-2.6.37/include/linux/cred.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/cred.h
8515 --- linux-2.6.37/include/linux/cred.h 2011-01-05 21:50:29.000000000 +0100
8516 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/cred.h 2011-01-08 03:33:34.000000000 +0100
8517 @@ -208,6 +208,31 @@ static inline void validate_process_cred
8521 +static inline void set_cred_subscribers(struct cred *cred, int n)
8523 +#ifdef CONFIG_DEBUG_CREDENTIALS
8524 + atomic_set(&cred->subscribers, n);
8528 +static inline int read_cred_subscribers(const struct cred *cred)
8530 +#ifdef CONFIG_DEBUG_CREDENTIALS
8531 + return atomic_read(&cred->subscribers);
8537 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
8539 +#ifdef CONFIG_DEBUG_CREDENTIALS
8540 + struct cred *cred = (struct cred *) _cred;
8542 + atomic_add(n, &cred->subscribers);
8547 * get_new_cred - Get a reference on a new set of credentials
8548 * @cred: The new credentials to reference
8549 diff -NurpP --minimal linux-2.6.37/include/linux/devpts_fs.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/devpts_fs.h
8550 --- linux-2.6.37/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8551 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/devpts_fs.h 2010-11-23 02:09:41.000000000 +0100
8552 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8557 #endif /* _LINUX_DEVPTS_FS_H */
8558 diff -NurpP --minimal linux-2.6.37/include/linux/ext2_fs.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/ext2_fs.h
8559 --- linux-2.6.37/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
8560 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/ext2_fs.h 2010-11-23 02:09:41.000000000 +0100
8561 @@ -189,8 +189,12 @@ struct ext2_group_desc
8562 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8563 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8564 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8565 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8566 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8568 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8569 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8571 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8572 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8574 @@ -274,7 +278,8 @@ struct ext2_inode {
8576 __le16 l_i_uid_high; /* these 2 fields */
8577 __le16 l_i_gid_high; /* were reserved2[0] */
8578 - __u32 l_i_reserved2;
8579 + __le16 l_i_tag; /* Context Tag */
8580 + __u16 l_i_reserved2;
8583 __u8 h_i_frag; /* Fragment number */
8584 @@ -303,6 +308,7 @@ struct ext2_inode {
8585 #define i_gid_low i_gid
8586 #define i_uid_high osd2.linux2.l_i_uid_high
8587 #define i_gid_high osd2.linux2.l_i_gid_high
8588 +#define i_raw_tag osd2.linux2.l_i_tag
8589 #define i_reserved2 osd2.linux2.l_i_reserved2
8592 @@ -347,6 +353,7 @@ struct ext2_inode {
8593 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8594 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8595 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8596 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8599 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8600 diff -NurpP --minimal linux-2.6.37/include/linux/ext3_fs.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/ext3_fs.h
8601 --- linux-2.6.37/include/linux/ext3_fs.h 2010-10-21 13:07:53.000000000 +0200
8602 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/ext3_fs.h 2010-11-23 02:09:41.000000000 +0100
8603 @@ -173,10 +173,14 @@ struct ext3_group_desc
8604 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8605 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8606 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8607 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8608 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8610 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8611 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8612 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8613 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8615 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8616 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8618 /* Flags that should be inherited by new inodes from their parent. */
8619 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8620 @@ -312,7 +316,8 @@ struct ext3_inode {
8622 __le16 l_i_uid_high; /* these 2 fields */
8623 __le16 l_i_gid_high; /* were reserved2[0] */
8624 - __u32 l_i_reserved2;
8625 + __le16 l_i_tag; /* Context Tag */
8626 + __u16 l_i_reserved2;
8629 __u8 h_i_frag; /* Fragment number */
8630 @@ -343,6 +348,7 @@ struct ext3_inode {
8631 #define i_gid_low i_gid
8632 #define i_uid_high osd2.linux2.l_i_uid_high
8633 #define i_gid_high osd2.linux2.l_i_gid_high
8634 +#define i_raw_tag osd2.linux2.l_i_tag
8635 #define i_reserved2 osd2.linux2.l_i_reserved2
8637 #elif defined(__GNU__)
8638 @@ -405,6 +411,7 @@ struct ext3_inode {
8639 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8640 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8641 * error in ordered mode */
8642 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8644 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8645 #ifndef _LINUX_EXT2_FS_H
8646 @@ -908,6 +915,7 @@ extern void ext3_get_inode_flags(struct
8647 extern void ext3_set_aops(struct inode *inode);
8648 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8649 u64 start, u64 len);
8650 +extern int ext3_sync_flags(struct inode *, int, int);
8653 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8654 diff -NurpP --minimal linux-2.6.37/include/linux/fs.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/fs.h
8655 --- linux-2.6.37/include/linux/fs.h 2011-01-05 21:50:30.000000000 +0100
8656 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/fs.h 2011-01-05 22:30:40.000000000 +0100
8657 @@ -214,6 +214,9 @@ struct inodes_stat_t {
8658 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8659 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8660 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8661 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8662 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8663 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8664 #define MS_BORN (1<<29)
8665 #define MS_ACTIVE (1<<30)
8666 #define MS_NOUSER (1<<31)
8667 @@ -242,6 +245,14 @@ struct inodes_stat_t {
8668 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8669 #define S_PRIVATE 512 /* Inode is fs-internal */
8670 #define S_IMA 1024 /* Inode has an associated IMA struct */
8671 +#define S_IXUNLINK 2048 /* Immutable Invert on unlink */
8673 +/* Linux-VServer related Inode flags */
8677 +#define V_BARRIER 4 /* Barrier for chroot() */
8678 +#define V_COW 8 /* Copy on Write */
8681 * Note that nosuid etc flags are inode-specific: setting some file-system
8682 @@ -264,12 +275,15 @@ struct inodes_stat_t {
8683 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8684 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8685 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8686 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8687 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8688 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8689 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8690 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8692 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8693 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8694 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8695 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8696 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8697 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8699 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8700 @@ -278,6 +292,16 @@ struct inodes_stat_t {
8701 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8702 #define IS_IMA(inode) ((inode)->i_flags & S_IMA)
8704 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8706 +#ifdef CONFIG_VSERVER_COWBL
8707 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8708 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8710 +# define IS_COW(inode) (0)
8711 +# define IS_COW_LINK(inode) (0)
8714 /* the read-only stuff doesn't really belong here, but any other place is
8715 probably as bad and I don't want to create yet another include file. */
8717 @@ -362,11 +386,14 @@ struct inodes_stat_t {
8718 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8719 #define FS_EXTENT_FL 0x00080000 /* Extents */
8720 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8721 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8722 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8724 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8725 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8726 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8727 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8729 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8730 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8732 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8733 #define SYNC_FILE_RANGE_WRITE 2
8734 @@ -446,6 +473,7 @@ typedef void (dio_iodone_t)(struct kiocb
8735 #define ATTR_KILL_PRIV (1 << 14)
8736 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8737 #define ATTR_TIMES_SET (1 << 16)
8738 +#define ATTR_TAG (1 << 17)
8741 * This is the Inode Attributes structure, used for notify_change(). It
8742 @@ -461,6 +489,7 @@ struct iattr {
8748 struct timespec ia_atime;
8749 struct timespec ia_mtime;
8750 @@ -474,6 +503,9 @@ struct iattr {
8751 struct file *ia_file;
8754 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8755 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8758 * Includes for diskquotas.
8760 @@ -743,7 +775,9 @@ struct inode {
8761 unsigned int i_nlink;
8767 unsigned int i_blkbits;
8770 @@ -785,7 +819,8 @@ struct inode {
8771 unsigned long i_state;
8772 unsigned long dirtied_when; /* jiffies of first dirtying */
8774 - unsigned int i_flags;
8775 + unsigned short i_flags;
8776 + unsigned short i_vflags;
8779 /* protected by i_lock */
8780 @@ -882,12 +917,12 @@ static inline void i_size_write(struct i
8782 static inline unsigned iminor(const struct inode *inode)
8784 - return MINOR(inode->i_rdev);
8785 + return MINOR(inode->i_mdev);
8788 static inline unsigned imajor(const struct inode *inode)
8790 - return MAJOR(inode->i_rdev);
8791 + return MAJOR(inode->i_mdev);
8794 extern struct block_device *I_BDEV(struct inode *inode);
8795 @@ -949,6 +984,7 @@ struct file {
8797 struct fown_struct f_owner;
8798 const struct cred *f_cred;
8800 struct file_ra_state f_ra;
8803 @@ -1087,6 +1123,7 @@ struct file_lock {
8804 struct file *fl_file;
8809 struct fasync_struct * fl_fasync; /* for lease break notifications */
8810 unsigned long fl_break_time; /* for nonblocking lease breaks */
8811 @@ -1568,6 +1605,7 @@ struct inode_operations {
8812 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8813 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8814 int (*removexattr) (struct dentry *, const char *);
8815 + int (*sync_flags) (struct inode *, int, int);
8816 void (*truncate_range)(struct inode *, loff_t, loff_t);
8817 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
8819 @@ -1588,6 +1626,7 @@ extern ssize_t vfs_readv(struct file *,
8820 unsigned long, loff_t *);
8821 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8822 unsigned long, loff_t *);
8823 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8825 struct super_operations {
8826 struct inode *(*alloc_inode)(struct super_block *sb);
8827 @@ -2389,6 +2428,7 @@ extern int dcache_dir_open(struct inode
8828 extern int dcache_dir_close(struct inode *, struct file *);
8829 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8830 extern int dcache_readdir(struct file *, void *, filldir_t);
8831 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8832 extern int simple_setattr(struct dentry *, struct iattr *);
8833 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8834 extern int simple_statfs(struct dentry *, struct kstatfs *);
8835 diff -NurpP --minimal linux-2.6.37/include/linux/gfs2_ondisk.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/gfs2_ondisk.h
8836 --- linux-2.6.37/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8837 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/gfs2_ondisk.h 2010-11-23 02:09:41.000000000 +0100
8838 @@ -211,6 +211,9 @@ enum {
8842 + gfs2fl_IXUnlink = 16,
8843 + gfs2fl_Barrier = 17,
8845 gfs2fl_TruncInProg = 29,
8846 gfs2fl_InheritDirectio = 30,
8847 gfs2fl_InheritJdata = 31,
8848 @@ -227,6 +230,9 @@ enum {
8849 #define GFS2_DIF_NOATIME 0x00000080
8850 #define GFS2_DIF_SYNC 0x00000100
8851 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8852 +#define GFS2_DIF_IXUNLINK 0x00010000
8853 +#define GFS2_DIF_BARRIER 0x00020000
8854 +#define GFS2_DIF_COW 0x00040000
8855 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8856 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8857 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8858 diff -NurpP --minimal linux-2.6.37/include/linux/if_tun.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/if_tun.h
8859 --- linux-2.6.37/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8860 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/if_tun.h 2010-11-23 02:09:41.000000000 +0100
8862 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8863 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8864 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8865 +#define TUNSETNID _IOW('T', 217, int)
8867 /* TUNSETIFF ifr flags */
8868 #define IFF_TUN 0x0001
8869 diff -NurpP --minimal linux-2.6.37/include/linux/init_task.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/init_task.h
8870 --- linux-2.6.37/include/linux/init_task.h 2011-01-05 21:50:30.000000000 +0100
8871 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/init_task.h 2010-11-23 02:09:41.000000000 +0100
8872 @@ -178,6 +178,10 @@ extern struct cred init_cred;
8874 INIT_TRACE_RECURSION \
8875 INIT_TASK_RCU_PREEMPT(tsk) \
8877 + .vx_info = NULL, \
8879 + .nx_info = NULL, \
8883 diff -NurpP --minimal linux-2.6.37/include/linux/ipc.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/ipc.h
8884 --- linux-2.6.37/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8885 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/ipc.h 2010-11-23 02:09:41.000000000 +0100
8886 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8894 diff -NurpP --minimal linux-2.6.37/include/linux/Kbuild linux-2.6.37-vs2.3.0.37-rc2/include/linux/Kbuild
8895 --- linux-2.6.37/include/linux/Kbuild 2011-01-05 21:50:28.000000000 +0100
8896 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/Kbuild 2010-11-23 02:09:41.000000000 +0100
8897 @@ -15,6 +15,7 @@ header-y += netfilter_bridge/
8898 header-y += netfilter_ipv4/
8899 header-y += netfilter_ipv6/
8901 +header-y += vserver/
8904 objhdr-y += version.h
8905 diff -NurpP --minimal linux-2.6.37/include/linux/loop.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/loop.h
8906 --- linux-2.6.37/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
8907 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/loop.h 2010-11-23 02:09:41.000000000 +0100
8908 @@ -45,6 +45,7 @@ struct loop_device {
8909 struct loop_func_table *lo_encryption;
8911 uid_t lo_key_owner; /* Who set the key */
8913 int (*ioctl)(struct loop_device *, int cmd,
8916 diff -NurpP --minimal linux-2.6.37/include/linux/magic.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/magic.h
8917 --- linux-2.6.37/include/linux/magic.h 2011-01-05 21:50:30.000000000 +0100
8918 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/magic.h 2010-11-23 02:09:41.000000000 +0100
8921 #define ADFS_SUPER_MAGIC 0xadf5
8922 #define AFFS_SUPER_MAGIC 0xadff
8923 -#define AFS_SUPER_MAGIC 0x5346414F
8924 +#define AFS_SUPER_MAGIC 0x5346414F
8925 #define AUTOFS_SUPER_MAGIC 0x0187
8926 #define CODA_SUPER_MAGIC 0x73757245
8927 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8929 #define NFS_SUPER_MAGIC 0x6969
8930 #define OPENPROM_SUPER_MAGIC 0x9fa1
8931 #define PROC_SUPER_MAGIC 0x9fa0
8932 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8933 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8935 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8936 diff -NurpP --minimal linux-2.6.37/include/linux/major.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/major.h
8937 --- linux-2.6.37/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8938 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/major.h 2010-11-23 02:09:41.000000000 +0100
8940 #define HD_MAJOR IDE0_MAJOR
8941 #define PTY_SLAVE_MAJOR 3
8943 +#define VROOT_MAJOR 4
8944 #define TTYAUX_MAJOR 5
8947 diff -NurpP --minimal linux-2.6.37/include/linux/memcontrol.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/memcontrol.h
8948 --- linux-2.6.37/include/linux/memcontrol.h 2010-10-21 13:07:53.000000000 +0200
8949 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/memcontrol.h 2010-11-23 02:09:41.000000000 +0100
8950 @@ -77,6 +77,13 @@ int task_in_mem_cgroup(struct task_struc
8951 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
8952 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8954 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8955 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8957 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8958 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8959 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8962 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8964 diff -NurpP --minimal linux-2.6.37/include/linux/mm_types.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/mm_types.h
8965 --- linux-2.6.37/include/linux/mm_types.h 2011-01-05 21:50:31.000000000 +0100
8966 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/mm_types.h 2010-11-23 02:09:41.000000000 +0100
8967 @@ -269,6 +269,7 @@ struct mm_struct {
8969 /* Architecture-specific MM context */
8970 mm_context_t context;
8971 + struct vx_info *mm_vx_info;
8973 /* Swap token stuff */
8975 diff -NurpP --minimal linux-2.6.37/include/linux/mount.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/mount.h
8976 --- linux-2.6.37/include/linux/mount.h 2010-10-21 13:07:53.000000000 +0200
8977 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/mount.h 2010-11-23 02:09:41.000000000 +0100
8978 @@ -46,6 +46,9 @@ struct mnt_namespace;
8980 #define MNT_INTERNAL 0x4000
8982 +#define MNT_TAGID 0x10000
8983 +#define MNT_NOTAG 0x20000
8986 struct list_head mnt_hash;
8987 struct vfsmount *mnt_parent; /* fs we are mounted on */
8988 @@ -84,6 +87,7 @@ struct vfsmount {
8992 + tag_t mnt_tag; /* tagging used for vfsmount */
8995 static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
8996 diff -NurpP --minimal linux-2.6.37/include/linux/net.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/net.h
8997 --- linux-2.6.37/include/linux/net.h 2011-01-05 21:50:31.000000000 +0100
8998 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/net.h 2010-11-23 02:09:41.000000000 +0100
8999 @@ -71,6 +71,7 @@ struct net;
9000 #define SOCK_NOSPACE 2
9001 #define SOCK_PASSCRED 3
9002 #define SOCK_PASSSEC 4
9003 +#define SOCK_USER_SOCKET 5
9005 #ifndef ARCH_HAS_SOCKET_TYPES
9007 diff -NurpP --minimal linux-2.6.37/include/linux/nfs_mount.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/nfs_mount.h
9008 --- linux-2.6.37/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
9009 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/nfs_mount.h 2010-11-23 02:09:41.000000000 +0100
9010 @@ -63,7 +63,8 @@ struct nfs_mount_data {
9011 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9012 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9013 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9014 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9015 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9016 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9018 /* The following are for internal use only */
9019 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
9020 diff -NurpP --minimal linux-2.6.37/include/linux/nsproxy.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/nsproxy.h
9021 --- linux-2.6.37/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
9022 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/nsproxy.h 2010-11-23 02:09:41.000000000 +0100
9025 #include <linux/spinlock.h>
9026 #include <linux/sched.h>
9027 +#include <linux/vserver/debug.h>
9029 struct mnt_namespace;
9030 struct uts_namespace;
9031 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
9034 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9035 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9036 void exit_task_namespaces(struct task_struct *tsk);
9037 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9038 void free_nsproxy(struct nsproxy *ns);
9039 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9040 struct fs_struct *);
9042 -static inline void put_nsproxy(struct nsproxy *ns)
9043 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9045 +static inline void __get_nsproxy(struct nsproxy *ns,
9046 + const char *_file, int _line)
9048 - if (atomic_dec_and_test(&ns->count)) {
9051 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9052 + ns, atomic_read(&ns->count), _file, _line);
9053 + atomic_inc(&ns->count);
9056 -static inline void get_nsproxy(struct nsproxy *ns)
9057 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9059 +static inline void __put_nsproxy(struct nsproxy *ns,
9060 + const char *_file, int _line)
9062 - atomic_inc(&ns->count);
9063 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9064 + ns, atomic_read(&ns->count), _file, _line);
9065 + if (atomic_dec_and_test(&ns->count)) {
9070 #ifdef CONFIG_CGROUP_NS
9071 diff -NurpP --minimal linux-2.6.37/include/linux/pid.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/pid.h
9072 --- linux-2.6.37/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
9073 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/pid.h 2010-11-23 02:09:41.000000000 +0100
9074 @@ -8,7 +8,8 @@ enum pid_type
9084 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9087 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9088 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9089 pid_t pid_vnr(struct pid *pid);
9091 #define do_each_pid_task(pid, type, task) \
9092 diff -NurpP --minimal linux-2.6.37/include/linux/proc_fs.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/proc_fs.h
9093 --- linux-2.6.37/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
9094 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/proc_fs.h 2010-11-23 02:09:41.000000000 +0100
9095 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9101 const struct inode_operations *proc_iops;
9103 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
9104 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
9111 int (*proc_get_link)(struct inode *, struct path *);
9112 int (*proc_read)(struct task_struct *task, char *page);
9113 int (*proc_show)(struct seq_file *m,
9114 struct pid_namespace *ns, struct pid *pid,
9115 struct task_struct *task);
9116 + int (*proc_vs_read)(char *page);
9117 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9118 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9121 struct ctl_table_header;
9122 @@ -263,6 +270,7 @@ struct ctl_table;
9129 struct proc_dir_entry *pde;
9130 diff -NurpP --minimal linux-2.6.37/include/linux/quotaops.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/quotaops.h
9131 --- linux-2.6.37/include/linux/quotaops.h 2010-10-21 13:07:54.000000000 +0200
9132 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/quotaops.h 2010-11-23 02:09:41.000000000 +0100
9134 #define _LINUX_QUOTAOPS_
9136 #include <linux/fs.h>
9137 +#include <linux/vs_dlimit.h>
9139 #define DQUOT_SPACE_WARN 0x1
9140 #define DQUOT_SPACE_RESERVE 0x2
9141 @@ -205,11 +206,12 @@ static inline void dquot_drop(struct ino
9143 static inline int dquot_alloc_inode(const struct inode *inode)
9146 + return dl_alloc_inode(inode);
9149 static inline void dquot_free_inode(const struct inode *inode)
9151 + dl_free_inode(inode);
9154 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
9155 @@ -220,6 +222,10 @@ static inline int dquot_transfer(struct
9156 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
9161 + if ((ret = dl_alloc_space(inode, number)))
9163 if (!(flags & DQUOT_SPACE_RESERVE))
9164 inode_add_bytes(inode, number);
9166 @@ -230,6 +236,7 @@ static inline void __dquot_free_space(st
9168 if (!(flags & DQUOT_SPACE_RESERVE))
9169 inode_sub_bytes(inode, number);
9170 + dl_free_space(inode, number);
9173 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
9174 diff -NurpP --minimal linux-2.6.37/include/linux/reboot.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/reboot.h
9175 --- linux-2.6.37/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
9176 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/reboot.h 2010-11-23 02:09:41.000000000 +0100
9178 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9179 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9180 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9181 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9185 diff -NurpP --minimal linux-2.6.37/include/linux/reiserfs_fs.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/reiserfs_fs.h
9186 --- linux-2.6.37/include/linux/reiserfs_fs.h 2011-01-05 21:50:32.000000000 +0100
9187 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/reiserfs_fs.h 2010-11-23 02:09:41.000000000 +0100
9188 @@ -976,6 +976,11 @@ struct stat_data_v1 {
9189 #define REISERFS_COMPR_FL FS_COMPR_FL
9190 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9192 +/* unfortunately reiserfs sdattr is only 16 bit */
9193 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9194 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9195 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9197 /* persistent flags that file inherits from the parent directory */
9198 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9199 REISERFS_SYNC_FL | \
9200 @@ -985,6 +990,9 @@ struct stat_data_v1 {
9201 REISERFS_COMPR_FL | \
9202 REISERFS_NOTAIL_FL )
9204 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9205 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9207 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9210 @@ -2070,6 +2078,7 @@ static inline void reiserfs_update_sd(st
9211 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9212 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9213 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9214 +int reiserfs_sync_flags(struct inode *inode, int, int);
9216 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
9218 diff -NurpP --minimal linux-2.6.37/include/linux/reiserfs_fs_sb.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/reiserfs_fs_sb.h
9219 --- linux-2.6.37/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
9220 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/reiserfs_fs_sb.h 2010-11-23 02:09:41.000000000 +0100
9221 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
9222 REISERFS_EXPOSE_PRIVROOT,
9223 REISERFS_BARRIER_NONE,
9224 REISERFS_BARRIER_FLUSH,
9227 /* Actions on error */
9228 REISERFS_ERROR_PANIC,
9229 diff -NurpP --minimal linux-2.6.37/include/linux/sched.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/sched.h
9230 --- linux-2.6.37/include/linux/sched.h 2011-01-05 21:50:32.000000000 +0100
9231 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/sched.h 2011-01-05 22:30:40.000000000 +0100
9232 @@ -1357,6 +1357,14 @@ struct task_struct {
9236 +/* vserver context data */
9237 + struct vx_info *vx_info;
9238 + struct nx_info *nx_info;
9244 /* Thread group tracking */
9247 @@ -1591,6 +1599,11 @@ struct pid_namespace;
9248 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9249 struct pid_namespace *ns);
9251 +#include <linux/vserver/base.h>
9252 +#include <linux/vserver/context.h>
9253 +#include <linux/vserver/debug.h>
9254 +#include <linux/vserver/pid.h>
9256 static inline pid_t task_pid_nr(struct task_struct *tsk)
9259 @@ -1604,7 +1617,8 @@ static inline pid_t task_pid_nr_ns(struc
9261 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9263 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9264 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9265 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9269 @@ -1617,7 +1631,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9271 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9273 - return pid_vnr(task_tgid(tsk));
9274 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9278 diff -NurpP --minimal linux-2.6.37/include/linux/shmem_fs.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/shmem_fs.h
9279 --- linux-2.6.37/include/linux/shmem_fs.h 2010-10-21 13:07:55.000000000 +0200
9280 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/shmem_fs.h 2010-11-23 02:09:41.000000000 +0100
9283 #define SHMEM_NR_DIRECT 16
9285 +#define TMPFS_SUPER_MAGIC 0x01021994
9288 struct shmem_inode_info {
9290 unsigned long flags;
9291 diff -NurpP --minimal linux-2.6.37/include/linux/stat.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/stat.h
9292 --- linux-2.6.37/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9293 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/stat.h 2010-11-23 02:09:41.000000000 +0100
9294 @@ -66,6 +66,7 @@ struct kstat {
9301 struct timespec atime;
9302 diff -NurpP --minimal linux-2.6.37/include/linux/sunrpc/auth.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/sunrpc/auth.h
9303 --- linux-2.6.37/include/linux/sunrpc/auth.h 2011-01-05 21:50:33.000000000 +0100
9304 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/sunrpc/auth.h 2010-11-23 02:09:41.000000000 +0100
9310 struct group_info *group_info;
9311 unsigned char machine_cred : 1;
9313 diff -NurpP --minimal linux-2.6.37/include/linux/sunrpc/clnt.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/sunrpc/clnt.h
9314 --- linux-2.6.37/include/linux/sunrpc/clnt.h 2011-01-05 21:50:33.000000000 +0100
9315 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/sunrpc/clnt.h 2010-11-23 02:09:41.000000000 +0100
9316 @@ -49,7 +49,8 @@ struct rpc_clnt {
9317 unsigned int cl_softrtry : 1,/* soft timeouts */
9318 cl_discrtry : 1,/* disconnect before retry */
9319 cl_autobind : 1,/* use getport() */
9320 - cl_chatty : 1;/* be verbose */
9321 + cl_chatty : 1,/* be verbose */
9322 + cl_tag : 1;/* context tagging */
9324 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9325 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9326 diff -NurpP --minimal linux-2.6.37/include/linux/syscalls.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/syscalls.h
9327 --- linux-2.6.37/include/linux/syscalls.h 2011-01-05 21:50:34.000000000 +0100
9328 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/syscalls.h 2010-11-23 02:09:41.000000000 +0100
9329 @@ -478,6 +478,8 @@ asmlinkage long sys_symlink(const char _
9330 asmlinkage long sys_unlink(const char __user *pathname);
9331 asmlinkage long sys_rename(const char __user *oldname,
9332 const char __user *newname);
9333 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9335 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9336 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9338 diff -NurpP --minimal linux-2.6.37/include/linux/sysctl.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/sysctl.h
9339 --- linux-2.6.37/include/linux/sysctl.h 2010-08-02 16:52:56.000000000 +0200
9340 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/sysctl.h 2010-11-23 02:09:41.000000000 +0100
9341 @@ -60,6 +60,7 @@ enum
9342 CTL_ABI=9, /* Binary emulation */
9343 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9344 CTL_ARLAN=254, /* arlan wireless driver */
9345 + CTL_VSERVER=4242, /* Linux-VServer debug */
9346 CTL_S390DBF=5677, /* s390 debug */
9347 CTL_SUNRPC=7249, /* sunrpc debug */
9348 CTL_PM=9899, /* frv power management */
9349 @@ -94,6 +95,7 @@ enum
9351 KERN_PANIC=15, /* int: panic timeout */
9352 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9353 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9355 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9356 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9357 diff -NurpP --minimal linux-2.6.37/include/linux/sysfs.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/sysfs.h
9358 --- linux-2.6.37/include/linux/sysfs.h 2011-01-05 21:50:34.000000000 +0100
9359 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/sysfs.h 2010-11-23 02:09:41.000000000 +0100
9361 #include <linux/kobject_ns.h>
9362 #include <asm/atomic.h>
9364 +#define SYSFS_SUPER_MAGIC 0x62656572
9369 diff -NurpP --minimal linux-2.6.37/include/linux/time.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/time.h
9370 --- linux-2.6.37/include/linux/time.h 2010-10-21 13:07:55.000000000 +0200
9371 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/time.h 2010-11-23 02:09:41.000000000 +0100
9372 @@ -252,6 +252,9 @@ static __always_inline void timespec_add
9373 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9377 +#include <linux/vs_time.h>
9379 #endif /* __KERNEL__ */
9381 #define NFDBITS __NFDBITS
9382 diff -NurpP --minimal linux-2.6.37/include/linux/types.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/types.h
9383 --- linux-2.6.37/include/linux/types.h 2011-01-05 21:50:34.000000000 +0100
9384 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/types.h 2010-11-23 02:09:41.000000000 +0100
9385 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
9386 typedef __kernel_gid32_t gid_t;
9387 typedef __kernel_uid16_t uid16_t;
9388 typedef __kernel_gid16_t gid16_t;
9389 +typedef unsigned int xid_t;
9390 +typedef unsigned int nid_t;
9391 +typedef unsigned int tag_t;
9393 typedef unsigned long uintptr_t;
9395 diff -NurpP --minimal linux-2.6.37/include/linux/vroot.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vroot.h
9396 --- linux-2.6.37/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9397 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vroot.h 2010-11-23 02:09:41.000000000 +0100
9401 + * include/linux/vroot.h
9403 + * written by Herbert Pötzl, 9/11/2002
9404 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9406 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9407 + * Redistribution of this file is permitted under the
9408 + * GNU General Public License.
9411 +#ifndef _LINUX_VROOT_H
9412 +#define _LINUX_VROOT_H
9417 +/* Possible states of device */
9423 +struct vroot_device {
9427 + struct semaphore vr_ctl_mutex;
9428 + struct block_device *vr_device;
9433 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9435 +extern int register_vroot_grb(vroot_grb_func *);
9436 +extern int unregister_vroot_grb(vroot_grb_func *);
9438 +#endif /* __KERNEL__ */
9440 +#define MAX_VROOT_DEFAULT 8
9443 + * IOCTL commands --- we will commandeer 0x56 ('V')
9446 +#define VROOT_SET_DEV 0x5600
9447 +#define VROOT_CLR_DEV 0x5601
9449 +#endif /* _LINUX_VROOT_H */
9450 diff -NurpP --minimal linux-2.6.37/include/linux/vs_base.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_base.h
9451 --- linux-2.6.37/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9452 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_base.h 2010-11-23 02:09:41.000000000 +0100
9457 +#include "vserver/base.h"
9458 +#include "vserver/check.h"
9459 +#include "vserver/debug.h"
9462 +#warning duplicate inclusion
9464 diff -NurpP --minimal linux-2.6.37/include/linux/vs_context.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_context.h
9465 --- linux-2.6.37/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9466 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_context.h 2010-11-23 02:09:41.000000000 +0100
9468 +#ifndef _VS_CONTEXT_H
9469 +#define _VS_CONTEXT_H
9471 +#include "vserver/base.h"
9472 +#include "vserver/check.h"
9473 +#include "vserver/context.h"
9474 +#include "vserver/history.h"
9475 +#include "vserver/debug.h"
9477 +#include <linux/sched.h>
9480 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9482 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9483 + const char *_file, int _line, void *_here)
9488 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9489 + vxi, vxi ? vxi->vx_id : 0,
9490 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9492 + __vxh_get_vx_info(vxi, _here);
9494 + atomic_inc(&vxi->vx_usecnt);
9499 +extern void free_vx_info(struct vx_info *);
9501 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9503 +static inline void __put_vx_info(struct vx_info *vxi,
9504 + const char *_file, int _line, void *_here)
9509 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9510 + vxi, vxi ? vxi->vx_id : 0,
9511 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9513 + __vxh_put_vx_info(vxi, _here);
9515 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9516 + free_vx_info(vxi);
9520 +#define init_vx_info(p, i) \
9521 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9523 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9524 + const char *_file, int _line, void *_here)
9527 + vxlprintk(VXD_CBIT(xid, 3),
9528 + "init_vx_info(%p[#%d.%d])",
9529 + vxi, vxi ? vxi->vx_id : 0,
9530 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9532 + __vxh_init_vx_info(vxi, vxp, _here);
9534 + atomic_inc(&vxi->vx_usecnt);
9540 +#define set_vx_info(p, i) \
9541 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9543 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9544 + const char *_file, int _line, void *_here)
9546 + struct vx_info *vxo;
9551 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9552 + vxi, vxi ? vxi->vx_id : 0,
9553 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9555 + __vxh_set_vx_info(vxi, vxp, _here);
9557 + atomic_inc(&vxi->vx_usecnt);
9558 + vxo = xchg(vxp, vxi);
9563 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9565 +static inline void __clr_vx_info(struct vx_info **vxp,
9566 + const char *_file, int _line, void *_here)
9568 + struct vx_info *vxo;
9570 + vxo = xchg(vxp, NULL);
9574 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9575 + vxo, vxo ? vxo->vx_id : 0,
9576 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9578 + __vxh_clr_vx_info(vxo, vxp, _here);
9580 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9581 + free_vx_info(vxo);
9585 +#define claim_vx_info(v, p) \
9586 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9588 +static inline void __claim_vx_info(struct vx_info *vxi,
9589 + struct task_struct *task,
9590 + const char *_file, int _line, void *_here)
9592 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9593 + vxi, vxi ? vxi->vx_id : 0,
9594 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9595 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9596 + task, _file, _line);
9597 + __vxh_claim_vx_info(vxi, task, _here);
9599 + atomic_inc(&vxi->vx_tasks);
9603 +extern void unhash_vx_info(struct vx_info *);
9605 +#define release_vx_info(v, p) \
9606 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9608 +static inline void __release_vx_info(struct vx_info *vxi,
9609 + struct task_struct *task,
9610 + const char *_file, int _line, void *_here)
9612 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9613 + vxi, vxi ? vxi->vx_id : 0,
9614 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9615 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9616 + task, _file, _line);
9617 + __vxh_release_vx_info(vxi, task, _here);
9621 + if (atomic_dec_and_test(&vxi->vx_tasks))
9622 + unhash_vx_info(vxi);
9626 +#define task_get_vx_info(p) \
9627 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9629 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9630 + const char *_file, int _line, void *_here)
9632 + struct vx_info *vxi;
9635 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9637 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9643 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9645 + if (waitqueue_active(&vxi->vx_wait))
9646 + wake_up_interruptible(&vxi->vx_wait);
9650 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9652 +static inline void __enter_vx_info(struct vx_info *vxi,
9653 + struct vx_info_save *vxis, const char *_file, int _line)
9655 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9656 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9657 + current->xid, current->vx_info, _file, _line);
9658 + vxis->vxi = xchg(¤t->vx_info, vxi);
9659 + vxis->xid = current->xid;
9660 + current->xid = vxi ? vxi->vx_id : 0;
9663 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9665 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9666 + const char *_file, int _line)
9668 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9669 + vxis, vxis->xid, vxis->vxi, current,
9670 + current->xid, current->vx_info, _file, _line);
9671 + (void)xchg(¤t->vx_info, vxis->vxi);
9672 + current->xid = vxis->xid;
9676 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9678 + vxis->vxi = xchg(¤t->vx_info, NULL);
9679 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9682 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9684 + (void)xchg(¤t->xid, vxis->xid);
9685 + (void)xchg(¤t->vx_info, vxis->vxi);
9688 +#define task_is_init(p) \
9689 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9691 +static inline int __task_is_init(struct task_struct *p,
9692 + const char *_file, int _line, void *_here)
9694 + int is_init = is_global_init(p);
9698 + is_init = p->vx_info->vx_initpid == p->pid;
9703 +extern void exit_vx_info(struct task_struct *, int);
9704 +extern void exit_vx_info_early(struct task_struct *, int);
9708 +#warning duplicate inclusion
9710 diff -NurpP --minimal linux-2.6.37/include/linux/vs_cowbl.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_cowbl.h
9711 --- linux-2.6.37/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9712 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_cowbl.h 2010-11-23 02:09:41.000000000 +0100
9714 +#ifndef _VS_COWBL_H
9715 +#define _VS_COWBL_H
9717 +#include <linux/fs.h>
9718 +#include <linux/dcache.h>
9719 +#include <linux/namei.h>
9720 +#include <linux/slab.h>
9722 +extern struct dentry *cow_break_link(const char *pathname);
9724 +static inline int cow_check_and_break(struct path *path)
9726 + struct inode *inode = path->dentry->d_inode;
9729 + /* do we need this check? */
9730 + if (IS_RDONLY(inode))
9733 + if (IS_COW(inode)) {
9734 + if (IS_COW_LINK(inode)) {
9735 + struct dentry *new_dentry, *old_dentry = path->dentry;
9738 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9742 + pp = d_path(path, buf, PATH_MAX);
9743 + new_dentry = cow_break_link(pp);
9745 + if (!IS_ERR(new_dentry)) {
9746 + path->dentry = new_dentry;
9749 + error = PTR_ERR(new_dentry);
9751 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9752 + inode->i_ctime = CURRENT_TIME;
9753 + mark_inode_dirty(inode);
9760 +#warning duplicate inclusion
9762 diff -NurpP --minimal linux-2.6.37/include/linux/vs_cvirt.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_cvirt.h
9763 --- linux-2.6.37/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9764 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_cvirt.h 2010-11-23 02:09:41.000000000 +0100
9766 +#ifndef _VS_CVIRT_H
9767 +#define _VS_CVIRT_H
9769 +#include "vserver/cvirt.h"
9770 +#include "vserver/context.h"
9771 +#include "vserver/base.h"
9772 +#include "vserver/check.h"
9773 +#include "vserver/debug.h"
9776 +static inline void vx_activate_task(struct task_struct *p)
9778 + struct vx_info *vxi;
9780 + if ((vxi = p->vx_info)) {
9781 + vx_update_load(vxi);
9782 + atomic_inc(&vxi->cvirt.nr_running);
9786 +static inline void vx_deactivate_task(struct task_struct *p)
9788 + struct vx_info *vxi;
9790 + if ((vxi = p->vx_info)) {
9791 + vx_update_load(vxi);
9792 + atomic_dec(&vxi->cvirt.nr_running);
9796 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9798 + struct vx_info *vxi;
9800 + if ((vxi = p->vx_info))
9801 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9804 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9806 + struct vx_info *vxi;
9808 + if ((vxi = p->vx_info))
9809 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9814 +#warning duplicate inclusion
9816 diff -NurpP --minimal linux-2.6.37/include/linux/vs_device.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_device.h
9817 --- linux-2.6.37/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9818 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_device.h 2010-11-23 02:09:41.000000000 +0100
9820 +#ifndef _VS_DEVICE_H
9821 +#define _VS_DEVICE_H
9823 +#include "vserver/base.h"
9824 +#include "vserver/device.h"
9825 +#include "vserver/debug.h"
9828 +#ifdef CONFIG_VSERVER_DEVICE
9830 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9832 +#define vs_device_perm(v, d, m, p) \
9833 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9838 +int vs_map_device(struct vx_info *vxi,
9839 + dev_t device, dev_t *target, umode_t mode)
9846 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9851 +#define vs_map_chrdev(d, t, p) \
9852 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9853 +#define vs_map_blkdev(d, t, p) \
9854 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9856 +#define vs_chrdev_perm(d, p) \
9857 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9858 +#define vs_blkdev_perm(d, p) \
9859 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9863 +#warning duplicate inclusion
9865 diff -NurpP --minimal linux-2.6.37/include/linux/vs_dlimit.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_dlimit.h
9866 --- linux-2.6.37/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9867 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_dlimit.h 2010-11-23 02:09:41.000000000 +0100
9869 +#ifndef _VS_DLIMIT_H
9870 +#define _VS_DLIMIT_H
9872 +#include <linux/fs.h>
9874 +#include "vserver/dlimit.h"
9875 +#include "vserver/base.h"
9876 +#include "vserver/debug.h"
9879 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9881 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9882 + const char *_file, int _line)
9886 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9887 + dli, dli ? dli->dl_tag : 0,
9888 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9890 + atomic_inc(&dli->dl_usecnt);
9895 +#define free_dl_info(i) \
9896 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9898 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9900 +static inline void __put_dl_info(struct dl_info *dli,
9901 + const char *_file, int _line)
9905 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9906 + dli, dli ? dli->dl_tag : 0,
9907 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9909 + if (atomic_dec_and_test(&dli->dl_usecnt))
9910 + free_dl_info(dli);
9914 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9916 +static inline int __dl_alloc_space(struct super_block *sb,
9917 + tag_t tag, dlsize_t nr, const char *file, int line)
9919 + struct dl_info *dli = NULL;
9924 + dli = locate_dl_info(sb, tag);
9928 + spin_lock(&dli->dl_lock);
9929 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9931 + dli->dl_space_used += nr;
9932 + spin_unlock(&dli->dl_lock);
9935 + vxlprintk(VXD_CBIT(dlim, 1),
9936 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9937 + sb, tag, __dlimit_char(dli), (long long)nr,
9939 + return ret ? -ENOSPC : 0;
9942 +static inline void __dl_free_space(struct super_block *sb,
9943 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9945 + struct dl_info *dli = NULL;
9949 + dli = locate_dl_info(sb, tag);
9953 + spin_lock(&dli->dl_lock);
9954 + if (dli->dl_space_used > nr)
9955 + dli->dl_space_used -= nr;
9957 + dli->dl_space_used = 0;
9958 + spin_unlock(&dli->dl_lock);
9961 + vxlprintk(VXD_CBIT(dlim, 1),
9962 + "FREE (%p,#%d)%c %lld bytes",
9963 + sb, tag, __dlimit_char(dli), (long long)nr,
9967 +static inline int __dl_alloc_inode(struct super_block *sb,
9968 + tag_t tag, const char *_file, int _line)
9970 + struct dl_info *dli;
9973 + dli = locate_dl_info(sb, tag);
9977 + spin_lock(&dli->dl_lock);
9978 + dli->dl_inodes_used++;
9979 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9980 + spin_unlock(&dli->dl_lock);
9983 + vxlprintk(VXD_CBIT(dlim, 0),
9984 + "ALLOC (%p,#%d)%c inode (%d)",
9985 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9986 + return ret ? -ENOSPC : 0;
9989 +static inline void __dl_free_inode(struct super_block *sb,
9990 + tag_t tag, const char *_file, int _line)
9992 + struct dl_info *dli;
9994 + dli = locate_dl_info(sb, tag);
9998 + spin_lock(&dli->dl_lock);
9999 + if (dli->dl_inodes_used > 1)
10000 + dli->dl_inodes_used--;
10002 + dli->dl_inodes_used = 0;
10003 + spin_unlock(&dli->dl_lock);
10004 + put_dl_info(dli);
10006 + vxlprintk(VXD_CBIT(dlim, 0),
10007 + "FREE (%p,#%d)%c inode",
10008 + sb, tag, __dlimit_char(dli), _file, _line);
10011 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10012 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10013 + const char *_file, int _line)
10015 + struct dl_info *dli;
10016 + uint64_t broot, bfree;
10018 + dli = locate_dl_info(sb, tag);
10022 + spin_lock(&dli->dl_lock);
10023 + broot = (dli->dl_space_total -
10024 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10025 + >> sb->s_blocksize_bits;
10026 + bfree = (dli->dl_space_total - dli->dl_space_used)
10027 + >> sb->s_blocksize_bits;
10028 + spin_unlock(&dli->dl_lock);
10030 + vxlprintk(VXD_CBIT(dlim, 2),
10031 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10032 + (long long)bfree, (long long)broot,
10033 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10035 + if (free_blocks) {
10036 + if (*free_blocks > bfree)
10037 + *free_blocks = bfree;
10039 + if (root_blocks) {
10040 + if (*root_blocks > broot)
10041 + *root_blocks = broot;
10043 + put_dl_info(dli);
10046 +#define dl_prealloc_space(in, bytes) \
10047 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10048 + __FILE__, __LINE__ )
10050 +#define dl_alloc_space(in, bytes) \
10051 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10052 + __FILE__, __LINE__ )
10054 +#define dl_reserve_space(in, bytes) \
10055 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10056 + __FILE__, __LINE__ )
10058 +#define dl_claim_space(in, bytes) (0)
10060 +#define dl_release_space(in, bytes) \
10061 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10062 + __FILE__, __LINE__ )
10064 +#define dl_free_space(in, bytes) \
10065 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10066 + __FILE__, __LINE__ )
10070 +#define dl_alloc_inode(in) \
10071 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10073 +#define dl_free_inode(in) \
10074 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10077 +#define dl_adjust_block(sb, tag, fb, rb) \
10078 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10082 +#warning duplicate inclusion
10084 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/base.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/base.h
10085 --- linux-2.6.37/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10086 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/base.h 2010-11-23 02:09:41.000000000 +0100
10088 +#ifndef _VX_BASE_H
10089 +#define _VX_BASE_H
10092 +/* context state changes */
10104 +#define vx_task_xid(t) ((t)->xid)
10106 +#define vx_current_xid() vx_task_xid(current)
10108 +#define current_vx_info() (current->vx_info)
10111 +#define nx_task_nid(t) ((t)->nid)
10113 +#define nx_current_nid() nx_task_nid(current)
10115 +#define current_nx_info() (current->nx_info)
10118 +/* generic flag merging */
10120 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10122 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10124 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10126 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10129 +/* context flags */
10131 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10133 +#define vx_current_flags() __vx_flags(current_vx_info())
10135 +#define vx_info_flags(v, m, f) \
10136 + vs_check_flags(__vx_flags(v), m, f)
10138 +#define task_vx_flags(t, m, f) \
10139 + ((t) && vx_info_flags((t)->vx_info, m, f))
10141 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10144 +/* context caps */
10146 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10148 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10150 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10152 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10156 +/* network flags */
10158 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10160 +#define nx_current_flags() __nx_flags(current_nx_info())
10162 +#define nx_info_flags(n, m, f) \
10163 + vs_check_flags(__nx_flags(n), m, f)
10165 +#define task_nx_flags(t, m, f) \
10166 + ((t) && nx_info_flags((t)->nx_info, m, f))
10168 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10171 +/* network caps */
10173 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10175 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10177 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10179 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10182 +/* context mask capabilities */
10184 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10186 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10188 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10191 +/* context bcap mask */
10193 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10195 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10198 +/* mask given bcaps */
10200 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10202 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10205 +/* masked cap_bset */
10207 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10209 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10212 +#define vx_info_mbcap(v, b) \
10213 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10214 + vx_info_bcaps(v, b) : (b))
10216 +#define task_vx_mbcap(t, b) \
10217 + vx_info_mbcap((t)->vx_info, (t)->b)
10219 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10222 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10224 +#define vx_capable(b, c) (capable(b) || \
10225 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10227 +#define nx_capable(b, c) (capable(b) || \
10228 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10230 +#define vx_task_initpid(t, n) \
10231 + ((t)->vx_info && \
10232 + ((t)->vx_info->vx_initpid == (n)))
10234 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10237 +/* context unshare mask */
10239 +#define __vx_umask(v) ((v)->vx_umask)
10241 +#define vx_current_umask() __vx_umask(current_vx_info())
10243 +#define vx_can_unshare(b, f) (capable(b) || \
10244 + (cap_raised(current_cap(), b) && \
10245 + !((f) & ~vx_current_umask())))
10248 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10250 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10253 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10255 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10258 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cacct_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cacct_cmd.h
10259 --- linux-2.6.37/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10260 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cacct_cmd.h 2010-11-23 02:09:41.000000000 +0100
10262 +#ifndef _VX_CACCT_CMD_H
10263 +#define _VX_CACCT_CMD_H
10266 +/* virtual host info name commands */
10268 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10270 +struct vcmd_sock_stat_v0 {
10272 + uint32_t count[3];
10273 + uint64_t total[3];
10279 +#include <linux/compiler.h>
10281 +extern int vc_sock_stat(struct vx_info *, void __user *);
10283 +#endif /* __KERNEL__ */
10284 +#endif /* _VX_CACCT_CMD_H */
10285 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cacct_def.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cacct_def.h
10286 --- linux-2.6.37/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10287 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cacct_def.h 2010-11-23 02:09:41.000000000 +0100
10289 +#ifndef _VX_CACCT_DEF_H
10290 +#define _VX_CACCT_DEF_H
10292 +#include <asm/atomic.h>
10293 +#include <linux/vserver/cacct.h>
10296 +struct _vx_sock_acc {
10297 + atomic_long_t count;
10298 + atomic_long_t total;
10301 +/* context sub struct */
10303 +struct _vx_cacct {
10304 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10305 + atomic_t slab[8];
10306 + atomic_t page[6][8];
10309 +#ifdef CONFIG_VSERVER_DEBUG
10311 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10315 + printk("\t_vx_cacct:");
10316 + for (i = 0; i < 6; i++) {
10317 + struct _vx_sock_acc *ptr = cacct->sock[i];
10319 + printk("\t [%d] =", i);
10320 + for (j = 0; j < 3; j++) {
10321 + printk(" [%d] = %8lu, %8lu", j,
10322 + atomic_long_read(&ptr[j].count),
10323 + atomic_long_read(&ptr[j].total));
10331 +#endif /* _VX_CACCT_DEF_H */
10332 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cacct.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cacct.h
10333 --- linux-2.6.37/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10334 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cacct.h 2010-11-23 02:09:41.000000000 +0100
10336 +#ifndef _VX_CACCT_H
10337 +#define _VX_CACCT_H
10340 +enum sock_acc_field {
10341 + VXA_SOCK_UNSPEC = 0,
10347 + VXA_SOCK_SIZE /* array size */
10350 +#endif /* _VX_CACCT_H */
10351 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cacct_int.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cacct_int.h
10352 --- linux-2.6.37/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10353 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cacct_int.h 2010-11-23 02:09:41.000000000 +0100
10355 +#ifndef _VX_CACCT_INT_H
10356 +#define _VX_CACCT_INT_H
10362 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10364 + return atomic_long_read(&cacct->sock[type][pos].count);
10369 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10371 + return atomic_long_read(&cacct->sock[type][pos].total);
10374 +#endif /* __KERNEL__ */
10375 +#endif /* _VX_CACCT_INT_H */
10376 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/check.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/check.h
10377 --- linux-2.6.37/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10378 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/check.h 2010-11-23 02:09:41.000000000 +0100
10380 +#ifndef _VS_CHECK_H
10381 +#define _VS_CHECK_H
10384 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10386 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10387 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10389 +#define MIN_D_CONTEXT 65536
10392 +/* check conditions */
10394 +#define VS_ADMIN 0x0001
10395 +#define VS_WATCH 0x0002
10396 +#define VS_HIDE 0x0004
10397 +#define VS_HOSTID 0x0008
10399 +#define VS_IDENT 0x0010
10400 +#define VS_EQUIV 0x0020
10401 +#define VS_PARENT 0x0040
10402 +#define VS_CHILD 0x0080
10404 +#define VS_ARG_MASK 0x00F0
10406 +#define VS_DYNAMIC 0x0100
10407 +#define VS_STATIC 0x0200
10409 +#define VS_ATR_MASK 0x0F00
10411 +#ifdef CONFIG_VSERVER_PRIVACY
10412 +#define VS_ADMIN_P (0)
10413 +#define VS_WATCH_P (0)
10415 +#define VS_ADMIN_P VS_ADMIN
10416 +#define VS_WATCH_P VS_WATCH
10419 +#define VS_HARDIRQ 0x1000
10420 +#define VS_SOFTIRQ 0x2000
10421 +#define VS_IRQ 0x4000
10423 +#define VS_IRQ_MASK 0xF000
10425 +#include <linux/hardirq.h>
10428 + * check current context for ADMIN/WATCH and
10429 + * optionally against supplied argument
10431 +static inline int __vs_check(int cid, int id, unsigned int mode)
10433 + if (mode & VS_ARG_MASK) {
10434 + if ((mode & VS_IDENT) && (id == cid))
10437 + if (mode & VS_ATR_MASK) {
10438 + if ((mode & VS_DYNAMIC) &&
10439 + (id >= MIN_D_CONTEXT) &&
10440 + (id <= MAX_S_CONTEXT))
10442 + if ((mode & VS_STATIC) &&
10443 + (id > 1) && (id < MIN_D_CONTEXT))
10446 + if (mode & VS_IRQ_MASK) {
10447 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10449 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10451 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10454 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10455 + ((mode & VS_WATCH) && (cid == 1)) ||
10456 + ((mode & VS_HOSTID) && (id == 0)));
10459 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10461 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10464 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10466 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10469 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/context_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/context_cmd.h
10470 --- linux-2.6.37/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10471 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/context_cmd.h 2010-11-23 02:09:41.000000000 +0100
10473 +#ifndef _VX_CONTEXT_CMD_H
10474 +#define _VX_CONTEXT_CMD_H
10477 +/* vinfo commands */
10479 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10482 +extern int vc_task_xid(uint32_t);
10484 +#endif /* __KERNEL__ */
10486 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10488 +struct vcmd_vx_info_v0 {
10490 + uint32_t initpid;
10491 + /* more to come */
10495 +extern int vc_vx_info(struct vx_info *, void __user *);
10497 +#endif /* __KERNEL__ */
10499 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10501 +struct vcmd_ctx_stat_v0 {
10504 + /* more to come */
10508 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10510 +#endif /* __KERNEL__ */
10512 +/* context commands */
10514 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10515 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10517 +struct vcmd_ctx_create {
10518 + uint64_t flagword;
10521 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10522 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10524 +struct vcmd_ctx_migrate {
10525 + uint64_t flagword;
10529 +extern int vc_ctx_create(uint32_t, void __user *);
10530 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10532 +#endif /* __KERNEL__ */
10535 +/* flag commands */
10537 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10538 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10540 +struct vcmd_ctx_flags_v0 {
10541 + uint64_t flagword;
10546 +extern int vc_get_cflags(struct vx_info *, void __user *);
10547 +extern int vc_set_cflags(struct vx_info *, void __user *);
10549 +#endif /* __KERNEL__ */
10552 +/* context caps commands */
10554 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10555 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10557 +struct vcmd_ctx_caps_v1 {
10563 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10564 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10566 +#endif /* __KERNEL__ */
10569 +/* bcaps commands */
10571 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10572 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10574 +struct vcmd_bcaps {
10580 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10581 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10583 +#endif /* __KERNEL__ */
10586 +/* umask commands */
10588 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
10589 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
10591 +struct vcmd_umask {
10597 +extern int vc_get_umask(struct vx_info *, void __user *);
10598 +extern int vc_set_umask(struct vx_info *, void __user *);
10600 +#endif /* __KERNEL__ */
10605 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10606 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10608 +struct vcmd_badness_v0 {
10613 +extern int vc_get_badness(struct vx_info *, void __user *);
10614 +extern int vc_set_badness(struct vx_info *, void __user *);
10616 +#endif /* __KERNEL__ */
10617 +#endif /* _VX_CONTEXT_CMD_H */
10618 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/context.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/context.h
10619 --- linux-2.6.37/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10620 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/context.h 2011-01-08 03:34:09.000000000 +0100
10622 +#ifndef _VX_CONTEXT_H
10623 +#define _VX_CONTEXT_H
10625 +#include <linux/types.h>
10626 +#include <linux/capability.h>
10629 +/* context flags */
10631 +#define VXF_INFO_SCHED 0x00000002
10632 +#define VXF_INFO_NPROC 0x00000004
10633 +#define VXF_INFO_PRIVATE 0x00000008
10635 +#define VXF_INFO_INIT 0x00000010
10636 +#define VXF_INFO_HIDE 0x00000020
10637 +#define VXF_INFO_ULIMIT 0x00000040
10638 +#define VXF_INFO_NSPACE 0x00000080
10640 +#define VXF_SCHED_HARD 0x00000100
10641 +#define VXF_SCHED_PRIO 0x00000200
10642 +#define VXF_SCHED_PAUSE 0x00000400
10644 +#define VXF_VIRT_MEM 0x00010000
10645 +#define VXF_VIRT_UPTIME 0x00020000
10646 +#define VXF_VIRT_CPU 0x00040000
10647 +#define VXF_VIRT_LOAD 0x00080000
10648 +#define VXF_VIRT_TIME 0x00100000
10650 +#define VXF_HIDE_MOUNT 0x01000000
10651 +/* was VXF_HIDE_NETIF 0x02000000 */
10652 +#define VXF_HIDE_VINFO 0x04000000
10654 +#define VXF_STATE_SETUP (1ULL << 32)
10655 +#define VXF_STATE_INIT (1ULL << 33)
10656 +#define VXF_STATE_ADMIN (1ULL << 34)
10658 +#define VXF_SC_HELPER (1ULL << 36)
10659 +#define VXF_REBOOT_KILL (1ULL << 37)
10660 +#define VXF_PERSISTENT (1ULL << 38)
10662 +#define VXF_FORK_RSS (1ULL << 48)
10663 +#define VXF_PROLIFIC (1ULL << 49)
10665 +#define VXF_IGNEG_NICE (1ULL << 52)
10667 +#define VXF_ONE_TIME (0x0007ULL << 32)
10669 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10672 +/* context migration */
10674 +#define VXM_SET_INIT 0x00000001
10675 +#define VXM_SET_REAPER 0x00000002
10677 +/* context caps */
10679 +#define VXC_CAP_MASK 0x00000000
10681 +#define VXC_SET_UTSNAME 0x00000001
10682 +#define VXC_SET_RLIMIT 0x00000002
10683 +#define VXC_FS_SECURITY 0x00000004
10684 +#define VXC_FS_TRUSTED 0x00000008
10685 +#define VXC_TIOCSTI 0x00000010
10687 +/* was VXC_RAW_ICMP 0x00000100 */
10688 +#define VXC_SYSLOG 0x00001000
10689 +#define VXC_OOM_ADJUST 0x00002000
10690 +#define VXC_AUDIT_CONTROL 0x00004000
10692 +#define VXC_SECURE_MOUNT 0x00010000
10693 +#define VXC_SECURE_REMOUNT 0x00020000
10694 +#define VXC_BINARY_MOUNT 0x00040000
10696 +#define VXC_QUOTA_CTL 0x00100000
10697 +#define VXC_ADMIN_MAPPER 0x00200000
10698 +#define VXC_ADMIN_CLOOP 0x00400000
10700 +#define VXC_KTHREAD 0x01000000
10701 +#define VXC_NAMESPACE 0x02000000
10706 +#include <linux/list.h>
10707 +#include <linux/spinlock.h>
10708 +#include <linux/rcupdate.h>
10710 +#include "limit_def.h"
10711 +#include "sched_def.h"
10712 +#include "cvirt_def.h"
10713 +#include "cacct_def.h"
10714 +#include "device_def.h"
10716 +#define VX_SPACES 2
10718 +struct _vx_info_pc {
10719 + struct _vx_sched_pc sched_pc;
10720 + struct _vx_cvirt_pc cvirt_pc;
10723 +struct _vx_space {
10724 + unsigned long vx_nsmask; /* assignment mask */
10725 + struct nsproxy *vx_nsproxy; /* private namespaces */
10726 + struct fs_struct *vx_fs; /* private namespace fs */
10727 +// const struct cred *vx_real_cred; /* real task credentials */
10728 +// const struct cred *vx_cred; /* task credentials */
10732 + struct hlist_node vx_hlist; /* linked list of contexts */
10733 + xid_t vx_id; /* context id */
10734 + atomic_t vx_usecnt; /* usage count */
10735 + atomic_t vx_tasks; /* tasks count */
10736 + struct vx_info *vx_parent; /* parent context */
10737 + int vx_state; /* context state */
10739 + struct _vx_space space[VX_SPACES]; /* namespace store */
10741 + uint64_t vx_flags; /* context flags */
10742 + uint64_t vx_ccaps; /* context caps (vserver) */
10743 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10744 + unsigned long vx_umask; /* unshare mask (guest) */
10746 + struct task_struct *vx_reaper; /* guest reaper process */
10747 + pid_t vx_initpid; /* PID of guest init */
10748 + int64_t vx_badness_bias; /* OOM points bias */
10750 + struct _vx_limit limit; /* vserver limits */
10751 + struct _vx_sched sched; /* vserver scheduler */
10752 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10753 + struct _vx_cacct cacct; /* context accounting */
10755 + struct _vx_device dmap; /* default device map targets */
10757 +#ifndef CONFIG_SMP
10758 + struct _vx_info_pc info_pc; /* per cpu data */
10760 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10763 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10764 + int reboot_cmd; /* last sys_reboot() cmd */
10765 + int exit_code; /* last process exit code */
10767 + char vx_name[65]; /* vserver name */
10770 +#ifndef CONFIG_SMP
10771 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10772 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10774 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10775 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10778 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10781 +struct vx_info_save {
10782 + struct vx_info *vxi;
10787 +/* status flags */
10789 +#define VXS_HASHED 0x0001
10790 +#define VXS_PAUSED 0x0010
10791 +#define VXS_SHUTDOWN 0x0100
10792 +#define VXS_HELPER 0x1000
10793 +#define VXS_RELEASED 0x8000
10796 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10797 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10799 +extern struct vx_info *lookup_vx_info(int);
10800 +extern struct vx_info *lookup_or_create_vx_info(int);
10802 +extern int get_xid_list(int, unsigned int *, int);
10803 +extern int xid_is_hashed(xid_t);
10805 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10807 +extern long vs_state_change(struct vx_info *, unsigned int);
10810 +#endif /* __KERNEL__ */
10811 +#endif /* _VX_CONTEXT_H */
10812 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cvirt_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cvirt_cmd.h
10813 --- linux-2.6.37/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
10814 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cvirt_cmd.h 2010-11-23 02:09:41.000000000 +0100
10816 +#ifndef _VX_CVIRT_CMD_H
10817 +#define _VX_CVIRT_CMD_H
10820 +/* virtual host info name commands */
10822 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
10823 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
10825 +struct vcmd_vhi_name_v0 {
10831 +enum vhi_name_field {
10832 + VHIN_CONTEXT = 0,
10844 +#include <linux/compiler.h>
10846 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10847 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10849 +#endif /* __KERNEL__ */
10851 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
10853 +struct vcmd_virt_stat_v0 {
10856 + uint32_t nr_threads;
10857 + uint32_t nr_running;
10858 + uint32_t nr_uninterruptible;
10859 + uint32_t nr_onhold;
10860 + uint32_t nr_forks;
10861 + uint32_t load[3];
10865 +extern int vc_virt_stat(struct vx_info *, void __user *);
10867 +#endif /* __KERNEL__ */
10868 +#endif /* _VX_CVIRT_CMD_H */
10869 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cvirt_def.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cvirt_def.h
10870 --- linux-2.6.37/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
10871 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cvirt_def.h 2010-11-23 02:09:41.000000000 +0100
10873 +#ifndef _VX_CVIRT_DEF_H
10874 +#define _VX_CVIRT_DEF_H
10876 +#include <linux/jiffies.h>
10877 +#include <linux/spinlock.h>
10878 +#include <linux/wait.h>
10879 +#include <linux/time.h>
10880 +#include <asm/atomic.h>
10883 +struct _vx_usage_stat {
10887 + uint64_t softirq;
10893 +struct _vx_syslog {
10894 + wait_queue_head_t log_wait;
10895 + spinlock_t logbuf_lock; /* lock for the log buffer */
10897 + unsigned long log_start; /* next char to be read by syslog() */
10898 + unsigned long con_start; /* next char to be sent to consoles */
10899 + unsigned long log_end; /* most-recently-written-char + 1 */
10900 + unsigned long logged_chars; /* #chars since last read+clear operation */
10902 + char log_buf[1024];
10906 +/* context sub struct */
10908 +struct _vx_cvirt {
10909 + atomic_t nr_threads; /* number of current threads */
10910 + atomic_t nr_running; /* number of running threads */
10911 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10913 + atomic_t nr_onhold; /* processes on hold */
10914 + uint32_t onhold_last; /* jiffies when put on hold */
10916 + struct timespec bias_ts; /* time offset to the host */
10917 + struct timespec bias_idle;
10918 + struct timespec bias_uptime; /* context creation point */
10919 + uint64_t bias_clock; /* offset in clock_t */
10921 + spinlock_t load_lock; /* lock for the load averages */
10922 + atomic_t load_updates; /* nr of load updates done so far */
10923 + uint32_t load_last; /* last time load was calculated */
10924 + uint32_t load[3]; /* load averages 1,5,15 */
10926 + atomic_t total_forks; /* number of forks so far */
10928 + struct _vx_syslog syslog;
10931 +struct _vx_cvirt_pc {
10932 + struct _vx_usage_stat cpustat;
10936 +#ifdef CONFIG_VSERVER_DEBUG
10938 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
10940 + printk("\t_vx_cvirt:\n");
10941 + printk("\t threads: %4d, %4d, %4d, %4d\n",
10942 + atomic_read(&cvirt->nr_threads),
10943 + atomic_read(&cvirt->nr_running),
10944 + atomic_read(&cvirt->nr_uninterruptible),
10945 + atomic_read(&cvirt->nr_onhold));
10946 + /* add rest here */
10947 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
10952 +#endif /* _VX_CVIRT_DEF_H */
10953 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cvirt.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cvirt.h
10954 --- linux-2.6.37/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
10955 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/cvirt.h 2010-11-23 02:09:41.000000000 +0100
10957 +#ifndef _VX_CVIRT_H
10958 +#define _VX_CVIRT_H
10965 +void vx_vsi_uptime(struct timespec *, struct timespec *);
10970 +void vx_update_load(struct vx_info *);
10973 +int vx_do_syslog(int, char __user *, int);
10975 +#endif /* __KERNEL__ */
10976 +#endif /* _VX_CVIRT_H */
10977 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/debug_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/debug_cmd.h
10978 --- linux-2.6.37/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
10979 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/debug_cmd.h 2010-11-23 02:09:41.000000000 +0100
10981 +#ifndef _VX_DEBUG_CMD_H
10982 +#define _VX_DEBUG_CMD_H
10985 +/* debug commands */
10987 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
10989 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
10990 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
10992 +struct vcmd_read_history_v0 {
10995 + char __user *data;
10998 +struct vcmd_read_monitor_v0 {
11001 + char __user *data;
11007 +#ifdef CONFIG_COMPAT
11009 +#include <asm/compat.h>
11011 +struct vcmd_read_history_v0_x32 {
11014 + compat_uptr_t data_ptr;
11017 +struct vcmd_read_monitor_v0_x32 {
11020 + compat_uptr_t data_ptr;
11023 +#endif /* CONFIG_COMPAT */
11025 +extern int vc_dump_history(uint32_t);
11027 +extern int vc_read_history(uint32_t, void __user *);
11028 +extern int vc_read_monitor(uint32_t, void __user *);
11030 +#ifdef CONFIG_COMPAT
11032 +extern int vc_read_history_x32(uint32_t, void __user *);
11033 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11035 +#endif /* CONFIG_COMPAT */
11037 +#endif /* __KERNEL__ */
11038 +#endif /* _VX_DEBUG_CMD_H */
11039 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/debug.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/debug.h
11040 --- linux-2.6.37/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11041 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/debug.h 2010-11-23 02:09:41.000000000 +0100
11043 +#ifndef _VX_DEBUG_H
11044 +#define _VX_DEBUG_H
11047 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11048 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11049 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11051 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11052 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11053 +#define VXF_DEV "%p[%lu,%d:%d]"
11055 +#if defined(CONFIG_QUOTES_UTF8)
11056 +#define VS_Q_LQM "\xc2\xbb"
11057 +#define VS_Q_RQM "\xc2\xab"
11058 +#elif defined(CONFIG_QUOTES_ASCII)
11059 +#define VS_Q_LQM "\x27"
11060 +#define VS_Q_RQM "\x27"
11062 +#define VS_Q_LQM "\xbb"
11063 +#define VS_Q_RQM "\xab"
11066 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11069 +#define vxd_path(p) \
11070 + ({ static char _buffer[PATH_MAX]; \
11071 + d_path(p, _buffer, sizeof(_buffer)); })
11073 +#define vxd_cond_path(n) \
11074 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11077 +#ifdef CONFIG_VSERVER_DEBUG
11079 +extern unsigned int vx_debug_switch;
11080 +extern unsigned int vx_debug_xid;
11081 +extern unsigned int vx_debug_nid;
11082 +extern unsigned int vx_debug_tag;
11083 +extern unsigned int vx_debug_net;
11084 +extern unsigned int vx_debug_limit;
11085 +extern unsigned int vx_debug_cres;
11086 +extern unsigned int vx_debug_dlim;
11087 +extern unsigned int vx_debug_quota;
11088 +extern unsigned int vx_debug_cvirt;
11089 +extern unsigned int vx_debug_space;
11090 +extern unsigned int vx_debug_misc;
11093 +#define VX_LOGLEVEL "vxD: "
11094 +#define VX_PROC_FMT "%p: "
11095 +#define VX_PROCESS current
11097 +#define vxdprintk(c, f, x...) \
11100 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11101 + VX_PROCESS , ##x); \
11104 +#define vxlprintk(c, f, x...) \
11107 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11110 +#define vxfprintk(c, f, x...) \
11113 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11119 +void dump_vx_info(struct vx_info *, int);
11120 +void dump_vx_info_inactive(int);
11122 +#else /* CONFIG_VSERVER_DEBUG */
11124 +#define vx_debug_switch 0
11125 +#define vx_debug_xid 0
11126 +#define vx_debug_nid 0
11127 +#define vx_debug_tag 0
11128 +#define vx_debug_net 0
11129 +#define vx_debug_limit 0
11130 +#define vx_debug_cres 0
11131 +#define vx_debug_dlim 0
11132 +#define vx_debug_cvirt 0
11134 +#define vxdprintk(x...) do { } while (0)
11135 +#define vxlprintk(x...) do { } while (0)
11136 +#define vxfprintk(x...) do { } while (0)
11138 +#endif /* CONFIG_VSERVER_DEBUG */
11141 +#ifdef CONFIG_VSERVER_WARN
11143 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11144 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
11145 +#define VX_WARN_XID "[xid #%u] "
11146 +#define VX_WARN_NID "[nid #%u] "
11147 +#define VX_WARN_TAG "[tag #%u] "
11149 +#define vxwprintk(c, f, x...) \
11152 + printk(VX_WARNLEVEL f "\n", ##x); \
11155 +#else /* CONFIG_VSERVER_WARN */
11157 +#define vxwprintk(x...) do { } while (0)
11159 +#endif /* CONFIG_VSERVER_WARN */
11161 +#define vxwprintk_task(c, f, x...) \
11162 + vxwprintk(c, VX_WARN_TASK f, \
11163 + current->comm, current->pid, \
11164 + current->xid, current->nid, current->tag, ##x)
11165 +#define vxwprintk_xid(c, f, x...) \
11166 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11167 +#define vxwprintk_nid(c, f, x...) \
11168 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11169 +#define vxwprintk_tag(c, f, x...) \
11170 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11172 +#ifdef CONFIG_VSERVER_DEBUG
11173 +#define vxd_assert_lock(l) assert_spin_locked(l)
11174 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11175 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11177 +#define vxd_assert_lock(l) do { } while (0)
11178 +#define vxd_assert(c, f, x...) do { } while (0)
11182 +#endif /* _VX_DEBUG_H */
11183 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/device_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/device_cmd.h
11184 --- linux-2.6.37/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11185 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/device_cmd.h 2010-11-23 02:09:41.000000000 +0100
11187 +#ifndef _VX_DEVICE_CMD_H
11188 +#define _VX_DEVICE_CMD_H
11191 +/* device vserver commands */
11193 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11194 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11196 +struct vcmd_set_mapping_v0 {
11197 + const char __user *device;
11198 + const char __user *target;
11205 +#ifdef CONFIG_COMPAT
11207 +#include <asm/compat.h>
11209 +struct vcmd_set_mapping_v0_x32 {
11210 + compat_uptr_t device_ptr;
11211 + compat_uptr_t target_ptr;
11215 +#endif /* CONFIG_COMPAT */
11217 +#include <linux/compiler.h>
11219 +extern int vc_set_mapping(struct vx_info *, void __user *);
11220 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11222 +#ifdef CONFIG_COMPAT
11224 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11225 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11227 +#endif /* CONFIG_COMPAT */
11229 +#endif /* __KERNEL__ */
11230 +#endif /* _VX_DEVICE_CMD_H */
11231 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/device_def.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/device_def.h
11232 --- linux-2.6.37/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11233 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/device_def.h 2010-11-23 02:09:41.000000000 +0100
11235 +#ifndef _VX_DEVICE_DEF_H
11236 +#define _VX_DEVICE_DEF_H
11238 +#include <linux/types.h>
11240 +struct vx_dmap_target {
11245 +struct _vx_device {
11246 +#ifdef CONFIG_VSERVER_DEVICE
11247 + struct vx_dmap_target targets[2];
11251 +#endif /* _VX_DEVICE_DEF_H */
11252 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/device.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/device.h
11253 --- linux-2.6.37/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11254 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/device.h 2010-11-23 02:09:41.000000000 +0100
11256 +#ifndef _VX_DEVICE_H
11257 +#define _VX_DEVICE_H
11260 +#define DATTR_CREATE 0x00000001
11261 +#define DATTR_OPEN 0x00000002
11263 +#define DATTR_REMAP 0x00000010
11265 +#define DATTR_MASK 0x00000013
11268 +#else /* _VX_DEVICE_H */
11269 +#warning duplicate inclusion
11270 +#endif /* _VX_DEVICE_H */
11271 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/dlimit_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/dlimit_cmd.h
11272 --- linux-2.6.37/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11273 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/dlimit_cmd.h 2010-11-23 02:09:41.000000000 +0100
11275 +#ifndef _VX_DLIMIT_CMD_H
11276 +#define _VX_DLIMIT_CMD_H
11279 +/* dlimit vserver commands */
11281 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11282 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11284 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11285 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11287 +struct vcmd_ctx_dlimit_base_v0 {
11288 + const char __user *name;
11292 +struct vcmd_ctx_dlimit_v0 {
11293 + const char __user *name;
11294 + uint32_t space_used; /* used space in kbytes */
11295 + uint32_t space_total; /* maximum space in kbytes */
11296 + uint32_t inodes_used; /* used inodes */
11297 + uint32_t inodes_total; /* maximum inodes */
11298 + uint32_t reserved; /* reserved for root in % */
11302 +#define CDLIM_UNSET ((uint32_t)0UL)
11303 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11304 +#define CDLIM_KEEP ((uint32_t)~1UL)
11306 +#define DLIME_UNIT 0
11307 +#define DLIME_KILO 1
11308 +#define DLIME_MEGA 2
11309 +#define DLIME_GIGA 3
11311 +#define DLIMF_SHIFT 0x10
11313 +#define DLIMS_USED 0
11314 +#define DLIMS_TOTAL 2
11317 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
11319 + int exp = (flags & DLIMF_SHIFT) ?
11320 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
11321 + return ((uint64_t)val) << (10 * exp);
11325 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
11329 + if (*flags & DLIMF_SHIFT) {
11330 + while (val > (1LL << 32) && (exp < 3)) {
11334 + *flags &= ~(DLIME_GIGA << shift);
11335 + *flags |= exp << shift;
11343 +#ifdef CONFIG_COMPAT
11345 +#include <asm/compat.h>
11347 +struct vcmd_ctx_dlimit_base_v0_x32 {
11348 + compat_uptr_t name_ptr;
11352 +struct vcmd_ctx_dlimit_v0_x32 {
11353 + compat_uptr_t name_ptr;
11354 + uint32_t space_used; /* used space in kbytes */
11355 + uint32_t space_total; /* maximum space in kbytes */
11356 + uint32_t inodes_used; /* used inodes */
11357 + uint32_t inodes_total; /* maximum inodes */
11358 + uint32_t reserved; /* reserved for root in % */
11362 +#endif /* CONFIG_COMPAT */
11364 +#include <linux/compiler.h>
11366 +extern int vc_add_dlimit(uint32_t, void __user *);
11367 +extern int vc_rem_dlimit(uint32_t, void __user *);
11369 +extern int vc_set_dlimit(uint32_t, void __user *);
11370 +extern int vc_get_dlimit(uint32_t, void __user *);
11372 +#ifdef CONFIG_COMPAT
11374 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11375 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11377 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11378 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11380 +#endif /* CONFIG_COMPAT */
11382 +#endif /* __KERNEL__ */
11383 +#endif /* _VX_DLIMIT_CMD_H */
11384 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/dlimit.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/dlimit.h
11385 --- linux-2.6.37/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11386 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/dlimit.h 2010-11-23 02:09:41.000000000 +0100
11388 +#ifndef _VX_DLIMIT_H
11389 +#define _VX_DLIMIT_H
11391 +#include "switch.h"
11396 +/* keep in sync with CDLIM_INFINITY */
11398 +#define DLIM_INFINITY (~0ULL)
11400 +#include <linux/spinlock.h>
11401 +#include <linux/rcupdate.h>
11403 +struct super_block;
11406 + struct hlist_node dl_hlist; /* linked list of contexts */
11407 + struct rcu_head dl_rcu; /* the rcu head */
11408 + tag_t dl_tag; /* context tag */
11409 + atomic_t dl_usecnt; /* usage count */
11410 + atomic_t dl_refcnt; /* reference count */
11412 + struct super_block *dl_sb; /* associated superblock */
11414 + spinlock_t dl_lock; /* protect the values */
11416 + unsigned long long dl_space_used; /* used space in bytes */
11417 + unsigned long long dl_space_total; /* maximum space in bytes */
11418 + unsigned long dl_inodes_used; /* used inodes */
11419 + unsigned long dl_inodes_total; /* maximum inodes */
11421 + unsigned int dl_nrlmult; /* non root limit mult */
11426 +extern void rcu_free_dl_info(struct rcu_head *);
11427 +extern void unhash_dl_info(struct dl_info *);
11429 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11434 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11436 +typedef uint64_t dlsize_t;
11438 +#endif /* __KERNEL__ */
11439 +#else /* _VX_DLIMIT_H */
11440 +#warning duplicate inclusion
11441 +#endif /* _VX_DLIMIT_H */
11442 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/global.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/global.h
11443 --- linux-2.6.37/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11444 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/global.h 2010-11-23 02:09:41.000000000 +0100
11446 +#ifndef _VX_GLOBAL_H
11447 +#define _VX_GLOBAL_H
11450 +extern atomic_t vx_global_ctotal;
11451 +extern atomic_t vx_global_cactive;
11453 +extern atomic_t nx_global_ctotal;
11454 +extern atomic_t nx_global_cactive;
11456 +extern atomic_t vs_global_nsproxy;
11457 +extern atomic_t vs_global_fs;
11458 +extern atomic_t vs_global_mnt_ns;
11459 +extern atomic_t vs_global_uts_ns;
11460 +extern atomic_t vs_global_user_ns;
11461 +extern atomic_t vs_global_pid_ns;
11464 +#endif /* _VX_GLOBAL_H */
11465 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/history.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/history.h
11466 --- linux-2.6.37/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11467 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/history.h 2010-11-23 02:09:41.000000000 +0100
11469 +#ifndef _VX_HISTORY_H
11470 +#define _VX_HISTORY_H
11475 + VXH_THROW_OOPS = 1,
11479 + VXH_INIT_VX_INFO,
11482 + VXH_CLAIM_VX_INFO,
11483 + VXH_RELEASE_VX_INFO,
11484 + VXH_ALLOC_VX_INFO,
11485 + VXH_DEALLOC_VX_INFO,
11486 + VXH_HASH_VX_INFO,
11487 + VXH_UNHASH_VX_INFO,
11489 + VXH_LOOKUP_VX_INFO,
11490 + VXH_CREATE_VX_INFO,
11493 +struct _vxhe_vxi {
11494 + struct vx_info *ptr;
11500 +struct _vxhe_set_clr {
11504 +struct _vxhe_loc_lookup {
11508 +struct _vx_hist_entry {
11510 + unsigned short seq;
11511 + unsigned short type;
11512 + struct _vxhe_vxi vxi;
11514 + struct _vxhe_set_clr sc;
11515 + struct _vxhe_loc_lookup ll;
11519 +#ifdef CONFIG_VSERVER_HISTORY
11521 +extern unsigned volatile int vxh_active;
11523 +struct _vx_hist_entry *vxh_advance(void *loc);
11527 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11529 + entry->vxi.ptr = vxi;
11531 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11532 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11533 + entry->vxi.xid = vxi->vx_id;
11538 +#define __HERE__ current_text_addr()
11540 +#define __VXH_BODY(__type, __data, __here) \
11541 + struct _vx_hist_entry *entry; \
11543 + preempt_disable(); \
11544 + entry = vxh_advance(__here); \
11546 + entry->type = __type; \
11547 + preempt_enable();
11550 + /* pass vxi only */
11552 +#define __VXH_SMPL \
11553 + __vxh_copy_vxi(entry, vxi)
11556 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11558 + __VXH_BODY(__type, __VXH_SMPL, __here)
11561 + /* pass vxi and data (void *) */
11563 +#define __VXH_DATA \
11564 + __vxh_copy_vxi(entry, vxi); \
11565 + entry->sc.data = data
11568 +void __vxh_data(struct vx_info *vxi, void *data,
11569 + int __type, void *__here)
11571 + __VXH_BODY(__type, __VXH_DATA, __here)
11574 + /* pass vxi and arg (long) */
11576 +#define __VXH_LONG \
11577 + __vxh_copy_vxi(entry, vxi); \
11578 + entry->ll.arg = arg
11581 +void __vxh_long(struct vx_info *vxi, long arg,
11582 + int __type, void *__here)
11584 + __VXH_BODY(__type, __VXH_LONG, __here)
11589 +void __vxh_throw_oops(void *__here)
11591 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11592 + /* prevent further acquisition */
11597 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11599 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11600 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11602 +#define __vxh_init_vx_info(v, d, h) \
11603 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11604 +#define __vxh_set_vx_info(v, d, h) \
11605 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11606 +#define __vxh_clr_vx_info(v, d, h) \
11607 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11609 +#define __vxh_claim_vx_info(v, d, h) \
11610 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11611 +#define __vxh_release_vx_info(v, d, h) \
11612 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11614 +#define vxh_alloc_vx_info(v) \
11615 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11616 +#define vxh_dealloc_vx_info(v) \
11617 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11619 +#define vxh_hash_vx_info(v) \
11620 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11621 +#define vxh_unhash_vx_info(v) \
11622 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11624 +#define vxh_loc_vx_info(v, l) \
11625 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11626 +#define vxh_lookup_vx_info(v, l) \
11627 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11628 +#define vxh_create_vx_info(v, l) \
11629 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11631 +extern void vxh_dump_history(void);
11634 +#else /* CONFIG_VSERVER_HISTORY */
11636 +#define __HERE__ 0
11638 +#define vxh_throw_oops() do { } while (0)
11640 +#define __vxh_get_vx_info(v, h) do { } while (0)
11641 +#define __vxh_put_vx_info(v, h) do { } while (0)
11643 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11644 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11645 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11647 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11648 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11650 +#define vxh_alloc_vx_info(v) do { } while (0)
11651 +#define vxh_dealloc_vx_info(v) do { } while (0)
11653 +#define vxh_hash_vx_info(v) do { } while (0)
11654 +#define vxh_unhash_vx_info(v) do { } while (0)
11656 +#define vxh_loc_vx_info(v, l) do { } while (0)
11657 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11658 +#define vxh_create_vx_info(v, l) do { } while (0)
11660 +#define vxh_dump_history() do { } while (0)
11663 +#endif /* CONFIG_VSERVER_HISTORY */
11665 +#endif /* _VX_HISTORY_H */
11666 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/inode_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/inode_cmd.h
11667 --- linux-2.6.37/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11668 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/inode_cmd.h 2010-11-23 02:09:41.000000000 +0100
11670 +#ifndef _VX_INODE_CMD_H
11671 +#define _VX_INODE_CMD_H
11674 +/* inode vserver commands */
11676 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11677 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11679 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11680 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11682 +struct vcmd_ctx_iattr_v1 {
11683 + const char __user *name;
11689 +struct vcmd_ctx_fiattr_v0 {
11699 +#ifdef CONFIG_COMPAT
11701 +#include <asm/compat.h>
11703 +struct vcmd_ctx_iattr_v1_x32 {
11704 + compat_uptr_t name_ptr;
11710 +#endif /* CONFIG_COMPAT */
11712 +#include <linux/compiler.h>
11714 +extern int vc_get_iattr(void __user *);
11715 +extern int vc_set_iattr(void __user *);
11717 +extern int vc_fget_iattr(uint32_t, void __user *);
11718 +extern int vc_fset_iattr(uint32_t, void __user *);
11720 +#ifdef CONFIG_COMPAT
11722 +extern int vc_get_iattr_x32(void __user *);
11723 +extern int vc_set_iattr_x32(void __user *);
11725 +#endif /* CONFIG_COMPAT */
11727 +#endif /* __KERNEL__ */
11728 +#endif /* _VX_INODE_CMD_H */
11729 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/inode.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/inode.h
11730 --- linux-2.6.37/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11731 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/inode.h 2010-11-23 02:09:41.000000000 +0100
11733 +#ifndef _VX_INODE_H
11734 +#define _VX_INODE_H
11737 +#define IATTR_TAG 0x01000000
11739 +#define IATTR_ADMIN 0x00000001
11740 +#define IATTR_WATCH 0x00000002
11741 +#define IATTR_HIDE 0x00000004
11742 +#define IATTR_FLAGS 0x00000007
11744 +#define IATTR_BARRIER 0x00010000
11745 +#define IATTR_IXUNLINK 0x00020000
11746 +#define IATTR_IMMUTABLE 0x00040000
11747 +#define IATTR_COW 0x00080000
11752 +#ifdef CONFIG_VSERVER_PROC_SECURE
11753 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11754 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11756 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11757 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11760 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11762 +#endif /* __KERNEL__ */
11764 +/* inode ioctls */
11766 +#define FIOC_GETXFLG _IOR('x', 5, long)
11767 +#define FIOC_SETXFLG _IOW('x', 6, long)
11769 +#else /* _VX_INODE_H */
11770 +#warning duplicate inclusion
11771 +#endif /* _VX_INODE_H */
11772 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/Kbuild linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/Kbuild
11773 --- linux-2.6.37/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11774 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/Kbuild 2010-11-23 02:09:41.000000000 +0100
11777 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11778 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11779 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11780 + debug_cmd.h device_cmd.h
11782 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11784 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/limit_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/limit_cmd.h
11785 --- linux-2.6.37/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11786 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/limit_cmd.h 2010-11-23 02:09:41.000000000 +0100
11788 +#ifndef _VX_LIMIT_CMD_H
11789 +#define _VX_LIMIT_CMD_H
11792 +/* rlimit vserver commands */
11794 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
11795 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
11796 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
11797 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
11798 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
11800 +struct vcmd_ctx_rlimit_v0 {
11802 + uint64_t minimum;
11803 + uint64_t softlimit;
11804 + uint64_t maximum;
11807 +struct vcmd_ctx_rlimit_mask_v0 {
11808 + uint32_t minimum;
11809 + uint32_t softlimit;
11810 + uint32_t maximum;
11813 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
11815 +struct vcmd_rlimit_stat_v0 {
11819 + uint64_t minimum;
11820 + uint64_t maximum;
11823 +#define CRLIM_UNSET (0ULL)
11824 +#define CRLIM_INFINITY (~0ULL)
11825 +#define CRLIM_KEEP (~1ULL)
11829 +#ifdef CONFIG_IA32_EMULATION
11831 +struct vcmd_ctx_rlimit_v0_x32 {
11833 + uint64_t minimum;
11834 + uint64_t softlimit;
11835 + uint64_t maximum;
11836 +} __attribute__ ((packed));
11838 +#endif /* CONFIG_IA32_EMULATION */
11840 +#include <linux/compiler.h>
11842 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11843 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11844 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11845 +extern int vc_reset_hits(struct vx_info *, void __user *);
11846 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11848 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11850 +#ifdef CONFIG_IA32_EMULATION
11852 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11853 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11855 +#endif /* CONFIG_IA32_EMULATION */
11857 +#endif /* __KERNEL__ */
11858 +#endif /* _VX_LIMIT_CMD_H */
11859 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/limit_def.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/limit_def.h
11860 --- linux-2.6.37/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
11861 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/limit_def.h 2010-11-23 02:09:41.000000000 +0100
11863 +#ifndef _VX_LIMIT_DEF_H
11864 +#define _VX_LIMIT_DEF_H
11866 +#include <asm/atomic.h>
11867 +#include <asm/resource.h>
11869 +#include "limit.h"
11872 +struct _vx_res_limit {
11873 + rlim_t soft; /* Context soft limit */
11874 + rlim_t hard; /* Context hard limit */
11876 + rlim_atomic_t rcur; /* Current value */
11877 + rlim_t rmin; /* Context minimum */
11878 + rlim_t rmax; /* Context maximum */
11880 + atomic_t lhit; /* Limit hits */
11883 +/* context sub struct */
11885 +struct _vx_limit {
11886 + struct _vx_res_limit res[NUM_LIMITS];
11889 +#ifdef CONFIG_VSERVER_DEBUG
11891 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11895 + printk("\t_vx_limit:");
11896 + for (i = 0; i < NUM_LIMITS; i++) {
11897 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11898 + i, (unsigned long)__rlim_get(limit, i),
11899 + (unsigned long)__rlim_rmin(limit, i),
11900 + (unsigned long)__rlim_rmax(limit, i),
11901 + (long)__rlim_soft(limit, i),
11902 + (long)__rlim_hard(limit, i),
11903 + atomic_read(&__rlim_lhit(limit, i)));
11909 +#endif /* _VX_LIMIT_DEF_H */
11910 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/limit.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/limit.h
11911 --- linux-2.6.37/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
11912 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/limit.h 2010-11-23 02:09:41.000000000 +0100
11914 +#ifndef _VX_LIMIT_H
11915 +#define _VX_LIMIT_H
11917 +#define VLIMIT_NSOCK 16
11918 +#define VLIMIT_OPENFD 17
11919 +#define VLIMIT_ANON 18
11920 +#define VLIMIT_SHMEM 19
11921 +#define VLIMIT_SEMARY 20
11922 +#define VLIMIT_NSEMS 21
11923 +#define VLIMIT_DENTRY 22
11924 +#define VLIMIT_MAPPED 23
11929 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11931 +/* keep in sync with CRLIM_INFINITY */
11933 +#define VLIM_INFINITY (~0ULL)
11935 +#include <asm/atomic.h>
11936 +#include <asm/resource.h>
11938 +#ifndef RLIM_INFINITY
11939 +#warning RLIM_INFINITY is undefined
11942 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11944 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
11945 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
11947 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
11948 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
11949 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
11951 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
11952 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
11954 +typedef atomic_long_t rlim_atomic_t;
11955 +typedef unsigned long rlim_t;
11957 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
11958 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
11959 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
11960 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
11961 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
11962 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
11965 +#if (RLIM_INFINITY == VLIM_INFINITY)
11966 +#define VX_VLIM(r) ((long long)(long)(r))
11967 +#define VX_RLIM(v) ((rlim_t)(v))
11969 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
11970 + ? VLIM_INFINITY : (long long)(r))
11971 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
11972 + ? RLIM_INFINITY : (rlim_t)(v))
11977 +void vx_vsi_meminfo(struct sysinfo *);
11978 +void vx_vsi_swapinfo(struct sysinfo *);
11979 +long vx_vsi_cached(struct sysinfo *);
11981 +#define NUM_LIMITS 24
11983 +#endif /* __KERNEL__ */
11984 +#endif /* _VX_LIMIT_H */
11985 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/limit_int.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/limit_int.h
11986 --- linux-2.6.37/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
11987 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/limit_int.h 2010-11-23 02:09:41.000000000 +0100
11989 +#ifndef _VX_LIMIT_INT_H
11990 +#define _VX_LIMIT_INT_H
11992 +#include "context.h"
11996 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
11997 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
11999 +extern const char *vlimit_name[NUM_LIMITS];
12001 +static inline void __vx_acc_cres(struct vx_info *vxi,
12002 + int res, int dir, void *_data, char *_file, int _line)
12004 + if (VXD_RCRES_COND(res))
12005 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12006 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12007 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12008 + (dir > 0) ? "++" : "--", _data, _file, _line);
12013 + __rlim_inc(&vxi->limit, res);
12015 + __rlim_dec(&vxi->limit, res);
12018 +static inline void __vx_add_cres(struct vx_info *vxi,
12019 + int res, int amount, void *_data, char *_file, int _line)
12021 + if (VXD_RCRES_COND(res))
12022 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12023 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12024 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12025 + amount, _data, _file, _line);
12030 + __rlim_add(&vxi->limit, res, amount);
12034 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12036 + int cond = (value > __rlim_rmax(limit, res));
12039 + __rlim_rmax(limit, res) = value;
12044 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12046 + int cond = (value < __rlim_rmin(limit, res));
12049 + __rlim_rmin(limit, res) = value;
12054 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12056 + if (!__vx_cres_adjust_max(limit, res, value))
12057 + __vx_cres_adjust_min(limit, res, value);
12062 + +1 ... no limit hit
12063 + -1 ... over soft limit
12064 + 0 ... over hard limit */
12066 +static inline int __vx_cres_avail(struct vx_info *vxi,
12067 + int res, int num, char *_file, int _line)
12069 + struct _vx_limit *limit;
12072 + if (VXD_RLIMIT_COND(res))
12073 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12074 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12075 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12076 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12077 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12078 + num, _file, _line);
12082 + limit = &vxi->limit;
12083 + value = __rlim_get(limit, res);
12085 + if (!__vx_cres_adjust_max(limit, res, value))
12086 + __vx_cres_adjust_min(limit, res, value);
12091 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12093 + if (value + num <= __rlim_soft(limit, res))
12096 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12098 + if (value + num <= __rlim_hard(limit, res))
12101 + __rlim_hit(limit, res);
12106 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12109 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12111 + rlim_t value, sum = 0;
12114 + while ((res = *array++)) {
12115 + value = __rlim_get(limit, res);
12116 + __vx_cres_fixup(limit, res, value);
12123 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12125 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12126 + int res = *array;
12128 + if (value == __rlim_get(limit, res))
12131 + __rlim_set(limit, res, value);
12132 + /* now adjust min/max */
12133 + if (!__vx_cres_adjust_max(limit, res, value))
12134 + __vx_cres_adjust_min(limit, res, value);
12139 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12140 + const int *array, int num, char *_file, int _line)
12142 + struct _vx_limit *limit;
12143 + rlim_t value = 0;
12151 + limit = &vxi->limit;
12153 + value = __vx_cres_array_sum(limit, array + 1);
12155 + __rlim_set(limit, res, value);
12156 + __vx_cres_fixup(limit, res, value);
12158 + return __vx_cres_avail(vxi, res, num, _file, _line);
12162 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12167 + /* complex resources first */
12168 + if ((id < 0) || (id == RLIMIT_RSS))
12169 + __vx_cres_array_fixup(limit, VLA_RSS);
12171 + for (res = 0; res < NUM_LIMITS; res++) {
12172 + if ((id > 0) && (res != id))
12175 + value = __rlim_get(limit, res);
12176 + __vx_cres_fixup(limit, res, value);
12178 + /* not supposed to happen, maybe warn? */
12179 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12180 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12185 +#endif /* __KERNEL__ */
12186 +#endif /* _VX_LIMIT_INT_H */
12187 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/monitor.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/monitor.h
12188 --- linux-2.6.37/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12189 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/monitor.h 2010-11-23 02:09:41.000000000 +0100
12191 +#ifndef _VX_MONITOR_H
12192 +#define _VX_MONITOR_H
12194 +#include <linux/types.h>
12201 + VXM_UPDATE = 0x20,
12205 + VXM_RQINFO_1 = 0x24,
12208 + VXM_ACTIVATE = 0x40,
12215 + VXM_MIGRATE = 0x48,
12218 + /* all other bits are flags */
12219 + VXM_SCHED = 0x80,
12222 +struct _vxm_update_1 {
12223 + uint32_t tokens_max;
12224 + uint32_t fill_rate;
12225 + uint32_t interval;
12228 +struct _vxm_update_2 {
12229 + uint32_t tokens_min;
12230 + uint32_t fill_rate;
12231 + uint32_t interval;
12234 +struct _vxm_rqinfo_1 {
12235 + uint16_t running;
12239 + uint32_t idle_tokens;
12242 +struct _vxm_rqinfo_2 {
12243 + uint32_t norm_time;
12244 + uint32_t idle_time;
12245 + uint32_t idle_skip;
12248 +struct _vxm_sched {
12250 + uint32_t norm_time;
12251 + uint32_t idle_time;
12254 +struct _vxm_task {
12259 +struct _vxm_event {
12268 + struct _vxm_task tsk;
12272 +struct _vx_mon_entry {
12276 + struct _vxm_event ev;
12277 + struct _vxm_sched sd;
12278 + struct _vxm_update_1 u1;
12279 + struct _vxm_update_2 u2;
12280 + struct _vxm_rqinfo_1 q1;
12281 + struct _vxm_rqinfo_2 q2;
12286 +#endif /* _VX_MONITOR_H */
12287 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/network_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/network_cmd.h
12288 --- linux-2.6.37/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12289 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/network_cmd.h 2010-11-23 02:09:41.000000000 +0100
12291 +#ifndef _VX_NETWORK_CMD_H
12292 +#define _VX_NETWORK_CMD_H
12295 +/* vinfo commands */
12297 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12300 +extern int vc_task_nid(uint32_t);
12302 +#endif /* __KERNEL__ */
12304 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12306 +struct vcmd_nx_info_v0 {
12308 + /* more to come */
12312 +extern int vc_nx_info(struct nx_info *, void __user *);
12314 +#endif /* __KERNEL__ */
12316 +#include <linux/in.h>
12317 +#include <linux/in6.h>
12319 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12320 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12322 +struct vcmd_net_create {
12323 + uint64_t flagword;
12326 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12328 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12329 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12331 +struct vcmd_net_addr_v0 {
12334 + struct in_addr ip[4];
12335 + struct in_addr mask[4];
12338 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12339 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12341 +struct vcmd_net_addr_ipv4_v1 {
12344 + struct in_addr ip;
12345 + struct in_addr mask;
12348 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12349 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12351 +struct vcmd_net_addr_ipv6_v1 {
12355 + struct in6_addr ip;
12356 + struct in6_addr mask;
12359 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12360 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12362 +struct vcmd_match_ipv4_v0 {
12367 + struct in_addr ip;
12368 + struct in_addr ip2;
12369 + struct in_addr mask;
12372 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12373 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12375 +struct vcmd_match_ipv6_v0 {
12380 + struct in6_addr ip;
12381 + struct in6_addr ip2;
12382 + struct in6_addr mask;
12387 +extern int vc_net_create(uint32_t, void __user *);
12388 +extern int vc_net_migrate(struct nx_info *, void __user *);
12390 +extern int vc_net_add(struct nx_info *, void __user *);
12391 +extern int vc_net_remove(struct nx_info *, void __user *);
12393 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12394 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12396 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12397 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12399 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12400 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12402 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12403 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12405 +#endif /* __KERNEL__ */
12408 +/* flag commands */
12410 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12411 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12413 +struct vcmd_net_flags_v0 {
12414 + uint64_t flagword;
12419 +extern int vc_get_nflags(struct nx_info *, void __user *);
12420 +extern int vc_set_nflags(struct nx_info *, void __user *);
12422 +#endif /* __KERNEL__ */
12425 +/* network caps commands */
12427 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12428 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12430 +struct vcmd_net_caps_v0 {
12436 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12437 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12439 +#endif /* __KERNEL__ */
12440 +#endif /* _VX_CONTEXT_CMD_H */
12441 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/network.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/network.h
12442 --- linux-2.6.37/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12443 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/network.h 2010-11-23 02:09:41.000000000 +0100
12445 +#ifndef _VX_NETWORK_H
12446 +#define _VX_NETWORK_H
12448 +#include <linux/types.h>
12451 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12454 +/* network flags */
12456 +#define NXF_INFO_PRIVATE 0x00000008
12458 +#define NXF_SINGLE_IP 0x00000100
12459 +#define NXF_LBACK_REMAP 0x00000200
12460 +#define NXF_LBACK_ALLOW 0x00000400
12462 +#define NXF_HIDE_NETIF 0x02000000
12463 +#define NXF_HIDE_LBACK 0x04000000
12465 +#define NXF_STATE_SETUP (1ULL << 32)
12466 +#define NXF_STATE_ADMIN (1ULL << 34)
12468 +#define NXF_SC_HELPER (1ULL << 36)
12469 +#define NXF_PERSISTENT (1ULL << 38)
12471 +#define NXF_ONE_TIME (0x0005ULL << 32)
12474 +#define NXF_INIT_SET (__nxf_init_set())
12476 +static inline uint64_t __nxf_init_set(void) {
12477 + return NXF_STATE_ADMIN
12478 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12479 + | NXF_LBACK_REMAP
12482 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12485 + | NXF_HIDE_NETIF;
12489 +/* network caps */
12491 +#define NXC_TUN_CREATE 0x00000001
12493 +#define NXC_RAW_ICMP 0x00000100
12496 +/* address types */
12498 +#define NXA_TYPE_IPV4 0x0001
12499 +#define NXA_TYPE_IPV6 0x0002
12501 +#define NXA_TYPE_NONE 0x0000
12502 +#define NXA_TYPE_ANY 0x00FF
12504 +#define NXA_TYPE_ADDR 0x0010
12505 +#define NXA_TYPE_MASK 0x0020
12506 +#define NXA_TYPE_RANGE 0x0040
12508 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12510 +#define NXA_MOD_BCAST 0x0100
12511 +#define NXA_MOD_LBACK 0x0200
12513 +#define NXA_LOOPBACK 0x1000
12515 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12516 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12520 +#include <linux/list.h>
12521 +#include <linux/spinlock.h>
12522 +#include <linux/rcupdate.h>
12523 +#include <linux/in.h>
12524 +#include <linux/in6.h>
12525 +#include <asm/atomic.h>
12527 +struct nx_addr_v4 {
12528 + struct nx_addr_v4 *next;
12529 + struct in_addr ip[2];
12530 + struct in_addr mask;
12535 +struct nx_addr_v6 {
12536 + struct nx_addr_v6 *next;
12537 + struct in6_addr ip;
12538 + struct in6_addr mask;
12545 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12546 + nid_t nx_id; /* vnet id */
12547 + atomic_t nx_usecnt; /* usage count */
12548 + atomic_t nx_tasks; /* tasks count */
12549 + int nx_state; /* context state */
12551 + uint64_t nx_flags; /* network flag word */
12552 + uint64_t nx_ncaps; /* network capabilities */
12554 + struct in_addr v4_lback; /* Loopback address */
12555 + struct in_addr v4_bcast; /* Broadcast address */
12556 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12557 +#ifdef CONFIG_IPV6
12558 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12560 + char nx_name[65]; /* network context name */
12564 +/* status flags */
12566 +#define NXS_HASHED 0x0001
12567 +#define NXS_SHUTDOWN 0x0100
12568 +#define NXS_RELEASED 0x8000
12570 +extern struct nx_info *lookup_nx_info(int);
12572 +extern int get_nid_list(int, unsigned int *, int);
12573 +extern int nid_is_hashed(nid_t);
12575 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12577 +extern long vs_net_change(struct nx_info *, unsigned int);
12582 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12583 +#ifdef CONFIG_IPV6
12584 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12586 +#define NX_IPV6(n) (0)
12589 +#endif /* __KERNEL__ */
12590 +#endif /* _VX_NETWORK_H */
12591 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/percpu.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/percpu.h
12592 --- linux-2.6.37/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12593 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/percpu.h 2010-11-23 02:09:41.000000000 +0100
12595 +#ifndef _VX_PERCPU_H
12596 +#define _VX_PERCPU_H
12598 +#include "cvirt_def.h"
12599 +#include "sched_def.h"
12601 +struct _vx_percpu {
12602 + struct _vx_cvirt_pc cvirt;
12603 + struct _vx_sched_pc sched;
12606 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12608 +#endif /* _VX_PERCPU_H */
12609 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/pid.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/pid.h
12610 --- linux-2.6.37/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12611 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/pid.h 2010-11-23 02:09:41.000000000 +0100
12613 +#ifndef _VSERVER_PID_H
12614 +#define _VSERVER_PID_H
12616 +/* pid faking stuff */
12618 +#define vx_info_map_pid(v, p) \
12619 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12620 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12621 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
12622 +#define vx_map_tgid(p) vx_map_pid(p)
12624 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12625 + const char *func, const char *file, int line)
12627 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12628 + vxfprintk(VXD_CBIT(cvirt, 2),
12629 + "vx_map_tgid: %p/%llx: %d -> %d",
12630 + vxi, (long long)vxi->vx_flags, pid,
12631 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12632 + func, file, line);
12635 + if (pid == vxi->vx_initpid)
12641 +#define vx_info_rmap_pid(v, p) \
12642 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12643 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
12644 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12646 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12647 + const char *func, const char *file, int line)
12649 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12650 + vxfprintk(VXD_CBIT(cvirt, 2),
12651 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12652 + vxi, (long long)vxi->vx_flags, pid,
12653 + (pid == 1) ? vxi->vx_initpid : pid,
12654 + func, file, line);
12655 + if ((pid == 1) && vxi->vx_initpid)
12656 + return vxi->vx_initpid;
12657 + if (pid == vxi->vx_initpid)
12664 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/sched_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/sched_cmd.h
12665 --- linux-2.6.37/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12666 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/sched_cmd.h 2010-11-23 02:09:41.000000000 +0100
12668 +#ifndef _VX_SCHED_CMD_H
12669 +#define _VX_SCHED_CMD_H
12672 +struct vcmd_prio_bias {
12674 + int32_t prio_bias;
12677 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
12678 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
12682 +#include <linux/compiler.h>
12684 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
12685 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
12687 +#endif /* __KERNEL__ */
12688 +#endif /* _VX_SCHED_CMD_H */
12689 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/sched_def.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/sched_def.h
12690 --- linux-2.6.37/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12691 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/sched_def.h 2010-11-23 02:09:41.000000000 +0100
12693 +#ifndef _VX_SCHED_DEF_H
12694 +#define _VX_SCHED_DEF_H
12696 +#include <linux/spinlock.h>
12697 +#include <linux/jiffies.h>
12698 +#include <linux/cpumask.h>
12699 +#include <asm/atomic.h>
12700 +#include <asm/param.h>
12703 +/* context sub struct */
12705 +struct _vx_sched {
12706 + int prio_bias; /* bias offset for priority */
12708 + cpumask_t update; /* CPUs which should update */
12711 +struct _vx_sched_pc {
12712 + int prio_bias; /* bias offset for priority */
12714 + uint64_t user_ticks; /* token tick events */
12715 + uint64_t sys_ticks; /* token tick events */
12716 + uint64_t hold_ticks; /* token ticks paused */
12720 +#ifdef CONFIG_VSERVER_DEBUG
12722 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12724 + printk("\t_vx_sched:\n");
12725 + printk("\t priority = %4d\n", sched->prio_bias);
12730 +#endif /* _VX_SCHED_DEF_H */
12731 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/sched.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/sched.h
12732 --- linux-2.6.37/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
12733 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/sched.h 2010-11-23 02:09:41.000000000 +0100
12735 +#ifndef _VX_SCHED_H
12736 +#define _VX_SCHED_H
12743 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12748 +void vx_update_load(struct vx_info *);
12751 +void vx_update_sched_param(struct _vx_sched *sched,
12752 + struct _vx_sched_pc *sched_pc);
12754 +#endif /* __KERNEL__ */
12755 +#else /* _VX_SCHED_H */
12756 +#warning duplicate inclusion
12757 +#endif /* _VX_SCHED_H */
12758 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/signal_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/signal_cmd.h
12759 --- linux-2.6.37/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
12760 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/signal_cmd.h 2010-11-23 02:09:41.000000000 +0100
12762 +#ifndef _VX_SIGNAL_CMD_H
12763 +#define _VX_SIGNAL_CMD_H
12766 +/* signalling vserver commands */
12768 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
12769 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
12771 +struct vcmd_ctx_kill_v0 {
12776 +struct vcmd_wait_exit_v0 {
12777 + int32_t reboot_cmd;
12778 + int32_t exit_code;
12783 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12784 +extern int vc_wait_exit(struct vx_info *, void __user *);
12786 +#endif /* __KERNEL__ */
12788 +/* process alteration commands */
12790 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
12791 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
12793 +struct vcmd_pflags_v0 {
12794 + uint32_t flagword;
12800 +extern int vc_get_pflags(uint32_t pid, void __user *);
12801 +extern int vc_set_pflags(uint32_t pid, void __user *);
12803 +#endif /* __KERNEL__ */
12804 +#endif /* _VX_SIGNAL_CMD_H */
12805 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/signal.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/signal.h
12806 --- linux-2.6.37/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
12807 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/signal.h 2010-11-23 02:09:41.000000000 +0100
12809 +#ifndef _VX_SIGNAL_H
12810 +#define _VX_SIGNAL_H
12817 +int vx_info_kill(struct vx_info *, int, int);
12819 +#endif /* __KERNEL__ */
12820 +#else /* _VX_SIGNAL_H */
12821 +#warning duplicate inclusion
12822 +#endif /* _VX_SIGNAL_H */
12823 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/space_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/space_cmd.h
12824 --- linux-2.6.37/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
12825 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/space_cmd.h 2010-11-23 02:09:41.000000000 +0100
12827 +#ifndef _VX_SPACE_CMD_H
12828 +#define _VX_SPACE_CMD_H
12831 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
12832 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
12833 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
12835 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
12836 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
12837 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
12839 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
12841 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
12842 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
12845 +struct vcmd_space_mask_v1 {
12849 +struct vcmd_space_mask_v2 {
12857 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
12858 +extern int vc_set_space_v1(struct vx_info *, void __user *);
12859 +extern int vc_enter_space(struct vx_info *, void __user *);
12860 +extern int vc_set_space(struct vx_info *, void __user *);
12861 +extern int vc_get_space_mask(void __user *, int);
12863 +#endif /* __KERNEL__ */
12864 +#endif /* _VX_SPACE_CMD_H */
12865 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/space.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/space.h
12866 --- linux-2.6.37/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
12867 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/space.h 2010-11-23 02:09:41.000000000 +0100
12869 +#ifndef _VX_SPACE_H
12870 +#define _VX_SPACE_H
12872 +#include <linux/types.h>
12876 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
12878 +#else /* _VX_SPACE_H */
12879 +#warning duplicate inclusion
12880 +#endif /* _VX_SPACE_H */
12881 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/switch.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/switch.h
12882 --- linux-2.6.37/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
12883 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/switch.h 2010-11-23 02:09:41.000000000 +0100
12885 +#ifndef _VX_SWITCH_H
12886 +#define _VX_SWITCH_H
12888 +#include <linux/types.h>
12891 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
12892 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
12893 +#define VC_VERSION(c) ((c) & 0xFFF)
12895 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
12896 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
12900 + Syscall Matrix V2.8
12902 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
12903 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
12904 + |INFO |SETUP | |MOVE | | | | | |
12905 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12906 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
12907 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
12908 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12909 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
12910 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
12911 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12912 + MEMORY | | | | |MEMCTRL| | |SWAP | |
12913 + | 16| 17| 18| 19| 20| 21| | 22| 23|
12914 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12915 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
12916 + | 24| 25| 26| 27| 28| 29| | 30| 31|
12917 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12918 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
12919 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
12920 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12921 + OTHER |VSTAT | | | | | | |VINFO | |
12922 + | 40| 41| 42| 43| 44| 45| | 46| 47|
12923 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
12924 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
12925 + | 48| 49| 50| 51| 52| 53| | 54| 55|
12926 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12927 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
12928 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
12929 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12933 +#define VC_CAT_VERSION 0
12935 +#define VC_CAT_VSETUP 1
12936 +#define VC_CAT_VHOST 2
12938 +#define VC_CAT_DEVICE 6
12940 +#define VC_CAT_VPROC 9
12941 +#define VC_CAT_PROCALT 10
12942 +#define VC_CAT_PROCMIG 11
12943 +#define VC_CAT_PROCTRL 12
12945 +#define VC_CAT_SCHED 14
12946 +#define VC_CAT_MEMCTRL 20
12948 +#define VC_CAT_VNET 25
12949 +#define VC_CAT_NETALT 26
12950 +#define VC_CAT_NETMIG 27
12951 +#define VC_CAT_NETCTRL 28
12953 +#define VC_CAT_TAGMIG 35
12954 +#define VC_CAT_DLIMIT 36
12955 +#define VC_CAT_INODE 38
12957 +#define VC_CAT_VSTAT 40
12958 +#define VC_CAT_VINFO 46
12959 +#define VC_CAT_EVENT 48
12961 +#define VC_CAT_FLAGS 52
12962 +#define VC_CAT_VSPACE 54
12963 +#define VC_CAT_DEBUG 56
12964 +#define VC_CAT_RLIMIT 60
12966 +#define VC_CAT_SYSTEST 61
12967 +#define VC_CAT_COMPAT 63
12969 +/* query version */
12971 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
12972 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
12977 +#include <linux/errno.h>
12979 +#endif /* __KERNEL__ */
12981 +#endif /* _VX_SWITCH_H */
12983 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/tag_cmd.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/tag_cmd.h
12984 --- linux-2.6.37/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
12985 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/tag_cmd.h 2010-11-23 02:09:41.000000000 +0100
12987 +#ifndef _VX_TAG_CMD_H
12988 +#define _VX_TAG_CMD_H
12991 +/* vinfo commands */
12993 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
12996 +extern int vc_task_tag(uint32_t);
12998 +#endif /* __KERNEL__ */
13000 +/* context commands */
13002 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13005 +extern int vc_tag_migrate(uint32_t);
13007 +#endif /* __KERNEL__ */
13008 +#endif /* _VX_TAG_CMD_H */
13009 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/tag.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/tag.h
13010 --- linux-2.6.37/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13011 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vserver/tag.h 2010-11-23 02:09:41.000000000 +0100
13016 +#include <linux/types.h>
13019 +#define DX_TAG(in) (IS_TAGGED(in))
13022 +#ifdef CONFIG_TAG_NFSD
13023 +#define DX_TAG_NFSD 1
13025 +#define DX_TAG_NFSD 0
13029 +#ifdef CONFIG_TAGGING_NONE
13031 +#define MAX_UID 0xFFFFFFFF
13032 +#define MAX_GID 0xFFFFFFFF
13034 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13036 +#define TAGINO_UID(cond, uid, tag) (uid)
13037 +#define TAGINO_GID(cond, gid, tag) (gid)
13042 +#ifdef CONFIG_TAGGING_GID16
13044 +#define MAX_UID 0xFFFFFFFF
13045 +#define MAX_GID 0x0000FFFF
13047 +#define INOTAG_TAG(cond, uid, gid, tag) \
13048 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13050 +#define TAGINO_UID(cond, uid, tag) (uid)
13051 +#define TAGINO_GID(cond, gid, tag) \
13052 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13057 +#ifdef CONFIG_TAGGING_ID24
13059 +#define MAX_UID 0x00FFFFFF
13060 +#define MAX_GID 0x00FFFFFF
13062 +#define INOTAG_TAG(cond, uid, gid, tag) \
13063 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13065 +#define TAGINO_UID(cond, uid, tag) \
13066 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13067 +#define TAGINO_GID(cond, gid, tag) \
13068 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13073 +#ifdef CONFIG_TAGGING_UID16
13075 +#define MAX_UID 0x0000FFFF
13076 +#define MAX_GID 0xFFFFFFFF
13078 +#define INOTAG_TAG(cond, uid, gid, tag) \
13079 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13081 +#define TAGINO_UID(cond, uid, tag) \
13082 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13083 +#define TAGINO_GID(cond, gid, tag) (gid)
13088 +#ifdef CONFIG_TAGGING_INTERN
13090 +#define MAX_UID 0xFFFFFFFF
13091 +#define MAX_GID 0xFFFFFFFF
13093 +#define INOTAG_TAG(cond, uid, gid, tag) \
13094 + ((cond) ? (tag) : 0)
13096 +#define TAGINO_UID(cond, uid, tag) (uid)
13097 +#define TAGINO_GID(cond, gid, tag) (gid)
13102 +#ifndef CONFIG_TAGGING_NONE
13103 +#define dx_current_fstag(sb) \
13104 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13106 +#define dx_current_fstag(sb) (0)
13109 +#ifndef CONFIG_TAGGING_INTERN
13110 +#define TAGINO_TAG(cond, tag) (0)
13112 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13115 +#define INOTAG_UID(cond, uid, gid) \
13116 + ((cond) ? ((uid) & MAX_UID) : (uid))
13117 +#define INOTAG_GID(cond, uid, gid) \
13118 + ((cond) ? ((gid) & MAX_GID) : (gid))
13121 +static inline uid_t dx_map_uid(uid_t uid)
13123 + if ((uid > MAX_UID) && (uid != -1))
13125 + return (uid & MAX_UID);
13128 +static inline gid_t dx_map_gid(gid_t gid)
13130 + if ((gid > MAX_GID) && (gid != -1))
13132 + return (gid & MAX_GID);
13140 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13142 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13143 + unsigned long *flags);
13145 +#ifdef CONFIG_PROPAGATE
13147 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13149 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13152 +#define dx_propagate_tag(n, i) do { } while (0)
13155 +#endif /* _DX_TAG_H */
13156 diff -NurpP --minimal linux-2.6.37/include/linux/vs_inet6.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_inet6.h
13157 --- linux-2.6.37/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13158 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_inet6.h 2010-11-23 02:09:41.000000000 +0100
13160 +#ifndef _VS_INET6_H
13161 +#define _VS_INET6_H
13163 +#include "vserver/base.h"
13164 +#include "vserver/network.h"
13165 +#include "vserver/debug.h"
13167 +#include <net/ipv6.h>
13169 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
13170 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
13173 +#ifdef CONFIG_IPV6
13176 +int v6_addr_match(struct nx_addr_v6 *nxa,
13177 + const struct in6_addr *addr, uint16_t mask)
13181 + switch (nxa->type & mask) {
13182 + case NXA_TYPE_MASK:
13183 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13185 + case NXA_TYPE_ADDR:
13186 + ret = ipv6_addr_equal(&nxa->ip, addr);
13188 + case NXA_TYPE_ANY:
13192 + vxdprintk(VXD_CBIT(net, 0),
13193 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
13194 + nxa, NXAV6(nxa), addr, mask, ret);
13199 +int v6_addr_in_nx_info(struct nx_info *nxi,
13200 + const struct in6_addr *addr, uint16_t mask)
13202 + struct nx_addr_v6 *nxa;
13207 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13208 + if (v6_addr_match(nxa, addr, mask))
13212 + vxdprintk(VXD_CBIT(net, 0),
13213 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
13214 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
13219 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13221 + /* FIXME: needs full range checks */
13222 + return v6_addr_match(nxa, &addr->ip, mask);
13226 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13228 + struct nx_addr_v6 *ptr;
13230 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13231 + if (v6_nx_addr_match(ptr, nxa, mask))
13238 + * Check if a given address matches for a socket
13240 + * nxi: the socket's nx_info if any
13241 + * addr: to be verified address
13244 +int v6_sock_addr_match (
13245 + struct nx_info *nxi,
13246 + struct inet_sock *inet,
13247 + struct in6_addr *addr)
13249 + struct sock *sk = &inet->sk;
13250 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13252 + if (!ipv6_addr_any(addr) &&
13253 + ipv6_addr_equal(saddr, addr))
13255 + if (ipv6_addr_any(saddr))
13256 + return v6_addr_in_nx_info(nxi, addr, -1);
13261 + * check if address is covered by socket
13263 + * sk: the socket to check against
13264 + * addr: the address in question (must be != 0)
13268 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13270 + struct nx_info *nxi = sk->sk_nx_info;
13271 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13273 + vxdprintk(VXD_CBIT(net, 5),
13274 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
13275 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
13276 + (sk->sk_socket?sk->sk_socket->flags:0));
13278 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13279 + return v6_addr_match(nxa, saddr, -1);
13280 + } else if (nxi) { /* match against nx_info */
13281 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13282 + } else { /* unrestricted any socket */
13288 +/* inet related checks and helpers */
13292 +struct net_device;
13296 +#include <linux/netdevice.h>
13297 +#include <linux/inetdevice.h>
13298 +#include <net/inet_timewait_sock.h>
13301 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13302 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13303 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13308 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13314 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13318 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13320 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13321 + nxi, nxi ? nxi->nx_id : 0, ifa,
13322 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13324 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13326 + if (v6_ifa_in_nx_info(ifa, nxi))
13332 +struct nx_v6_sock_addr {
13333 + struct in6_addr saddr; /* Address used for validation */
13334 + struct in6_addr baddr; /* Address used for socket bind */
13338 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13339 + struct nx_v6_sock_addr *nsa)
13341 + // struct sock *sk = &inet->sk;
13342 + // struct nx_info *nxi = sk->sk_nx_info;
13343 + struct in6_addr saddr = addr->sin6_addr;
13344 + struct in6_addr baddr = saddr;
13346 + nsa->saddr = saddr;
13347 + nsa->baddr = baddr;
13352 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13354 + // struct sock *sk = &inet->sk;
13355 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13357 + // *saddr = nsa->baddr;
13358 + // inet->inet_saddr = nsa->baddr;
13362 +int nx_info_has_v6(struct nx_info *nxi)
13366 + if (NX_IPV6(nxi))
13371 +#else /* CONFIG_IPV6 */
13374 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13381 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13387 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13393 +int nx_info_has_v6(struct nx_info *nxi)
13398 +#endif /* CONFIG_IPV6 */
13400 +#define current_nx_info_has_v6() \
13401 + nx_info_has_v6(current_nx_info())
13404 +#warning duplicate inclusion
13406 diff -NurpP --minimal linux-2.6.37/include/linux/vs_inet.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_inet.h
13407 --- linux-2.6.37/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13408 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_inet.h 2010-11-23 02:09:41.000000000 +0100
13410 +#ifndef _VS_INET_H
13411 +#define _VS_INET_H
13413 +#include "vserver/base.h"
13414 +#include "vserver/network.h"
13415 +#include "vserver/debug.h"
13417 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13419 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13420 + NIPQUAD((a)->mask), (a)->type
13421 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13423 +#define NIPQUAD(addr) \
13424 + ((unsigned char *)&addr)[0], \
13425 + ((unsigned char *)&addr)[1], \
13426 + ((unsigned char *)&addr)[2], \
13427 + ((unsigned char *)&addr)[3]
13429 +#define NIPQUAD_FMT "%u.%u.%u.%u"
13433 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13435 + __be32 ip = nxa->ip[0].s_addr;
13436 + __be32 mask = nxa->mask.s_addr;
13437 + __be32 bcast = ip | ~mask;
13440 + switch (nxa->type & tmask) {
13441 + case NXA_TYPE_MASK:
13442 + ret = (ip == (addr & mask));
13444 + case NXA_TYPE_ADDR:
13448 + /* fall through to broadcast */
13449 + case NXA_MOD_BCAST:
13450 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13452 + case NXA_TYPE_RANGE:
13453 + ret = ((nxa->ip[0].s_addr <= addr) &&
13454 + (nxa->ip[1].s_addr > addr));
13456 + case NXA_TYPE_ANY:
13461 + vxdprintk(VXD_CBIT(net, 0),
13462 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13463 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13468 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13470 + struct nx_addr_v4 *nxa;
13477 + /* allow 127.0.0.1 when remapping lback */
13478 + if ((tmask & NXA_LOOPBACK) &&
13479 + (addr == IPI_LOOPBACK) &&
13480 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13483 + /* check for lback address */
13484 + if ((tmask & NXA_MOD_LBACK) &&
13485 + (nxi->v4_lback.s_addr == addr))
13488 + /* check for broadcast address */
13489 + if ((tmask & NXA_MOD_BCAST) &&
13490 + (nxi->v4_bcast.s_addr == addr))
13493 + /* check for v4 addresses */
13494 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13495 + if (v4_addr_match(nxa, addr, tmask))
13499 + vxdprintk(VXD_CBIT(net, 0),
13500 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13501 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13506 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13508 + /* FIXME: needs full range checks */
13509 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13513 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13515 + struct nx_addr_v4 *ptr;
13517 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13518 + if (v4_nx_addr_match(ptr, nxa, mask))
13523 +#include <net/inet_sock.h>
13526 + * Check if a given address matches for a socket
13528 + * nxi: the socket's nx_info if any
13529 + * addr: to be verified address
13532 +int v4_sock_addr_match (
13533 + struct nx_info *nxi,
13534 + struct inet_sock *inet,
13537 + __be32 saddr = inet->inet_rcv_saddr;
13538 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13540 + if (addr && (saddr == addr || bcast == addr))
13543 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13548 +/* inet related checks and helpers */
13552 +struct net_device;
13555 +#ifdef CONFIG_INET
13557 +#include <linux/netdevice.h>
13558 +#include <linux/inetdevice.h>
13559 +#include <net/inet_sock.h>
13560 +#include <net/inet_timewait_sock.h>
13563 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13564 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13565 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13569 + * check if address is covered by socket
13571 + * sk: the socket to check against
13572 + * addr: the address in question (must be != 0)
13576 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13578 + struct nx_info *nxi = sk->sk_nx_info;
13579 + __be32 saddr = inet_rcv_saddr(sk);
13581 + vxdprintk(VXD_CBIT(net, 5),
13582 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13583 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13584 + (sk->sk_socket?sk->sk_socket->flags:0));
13586 + if (saddr) { /* direct address match */
13587 + return v4_addr_match(nxa, saddr, -1);
13588 + } else if (nxi) { /* match against nx_info */
13589 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13590 + } else { /* unrestricted any socket */
13598 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13600 + vxdprintk(VXD_CBIT(net, 1),
13601 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
13602 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13603 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13605 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13607 + if (dev_in_nx_info(dev, nxi))
13614 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13620 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13624 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13626 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13627 + nxi, nxi ? nxi->nx_id : 0, ifa,
13628 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13630 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13632 + if (v4_ifa_in_nx_info(ifa, nxi))
13638 +struct nx_v4_sock_addr {
13639 + __be32 saddr; /* Address used for validation */
13640 + __be32 baddr; /* Address used for socket bind */
13644 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13645 + struct nx_v4_sock_addr *nsa)
13647 + struct sock *sk = &inet->sk;
13648 + struct nx_info *nxi = sk->sk_nx_info;
13649 + __be32 saddr = addr->sin_addr.s_addr;
13650 + __be32 baddr = saddr;
13652 + vxdprintk(VXD_CBIT(net, 3),
13653 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13654 + sk, sk->sk_nx_info, sk->sk_socket,
13655 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13659 + if (saddr == INADDR_ANY) {
13660 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13661 + baddr = nxi->v4.ip[0].s_addr;
13662 + } else if (saddr == IPI_LOOPBACK) {
13663 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13664 + baddr = nxi->v4_lback.s_addr;
13665 + } else { /* normal address bind */
13666 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13667 + return -EADDRNOTAVAIL;
13671 + vxdprintk(VXD_CBIT(net, 3),
13672 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13673 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13675 + nsa->saddr = saddr;
13676 + nsa->baddr = baddr;
13681 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
13683 + inet->inet_saddr = nsa->baddr;
13684 + inet->inet_rcv_saddr = nsa->baddr;
13689 + * helper to simplify inet_lookup_listener
13691 + * nxi: the socket's nx_info if any
13692 + * addr: to be verified address
13693 + * saddr: socket address
13695 +static inline int v4_inet_addr_match (
13696 + struct nx_info *nxi,
13700 + if (addr && (saddr == addr))
13703 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
13707 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
13709 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
13710 + (addr == nxi->v4_lback.s_addr))
13711 + return IPI_LOOPBACK;
13716 +int nx_info_has_v4(struct nx_info *nxi)
13720 + if (NX_IPV4(nxi))
13722 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13727 +#else /* CONFIG_INET */
13730 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
13736 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13742 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13748 +int nx_info_has_v4(struct nx_info *nxi)
13753 +#endif /* CONFIG_INET */
13755 +#define current_nx_info_has_v4() \
13756 + nx_info_has_v4(current_nx_info())
13759 +// #warning duplicate inclusion
13761 diff -NurpP --minimal linux-2.6.37/include/linux/vs_limit.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_limit.h
13762 --- linux-2.6.37/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
13763 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_limit.h 2010-11-23 02:09:41.000000000 +0100
13765 +#ifndef _VS_LIMIT_H
13766 +#define _VS_LIMIT_H
13768 +#include "vserver/limit.h"
13769 +#include "vserver/base.h"
13770 +#include "vserver/context.h"
13771 +#include "vserver/debug.h"
13772 +#include "vserver/context.h"
13773 +#include "vserver/limit_int.h"
13776 +#define vx_acc_cres(v, d, p, r) \
13777 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13779 +#define vx_acc_cres_cond(x, d, p, r) \
13780 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13781 + r, d, p, __FILE__, __LINE__)
13784 +#define vx_add_cres(v, a, p, r) \
13785 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13786 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13788 +#define vx_add_cres_cond(x, a, p, r) \
13789 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13790 + r, a, p, __FILE__, __LINE__)
13791 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13794 +/* process and file limits */
13796 +#define vx_nproc_inc(p) \
13797 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13799 +#define vx_nproc_dec(p) \
13800 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13802 +#define vx_files_inc(f) \
13803 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13805 +#define vx_files_dec(f) \
13806 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13808 +#define vx_locks_inc(l) \
13809 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13811 +#define vx_locks_dec(l) \
13812 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13814 +#define vx_openfd_inc(f) \
13815 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
13817 +#define vx_openfd_dec(f) \
13818 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
13821 +#define vx_cres_avail(v, n, r) \
13822 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13825 +#define vx_nproc_avail(n) \
13826 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
13828 +#define vx_files_avail(n) \
13829 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
13831 +#define vx_locks_avail(n) \
13832 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
13834 +#define vx_openfd_avail(n) \
13835 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
13838 +/* dentry limits */
13840 +#define vx_dentry_inc(d) do { \
13841 + if (atomic_read(&d->d_count) == 1) \
13842 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
13845 +#define vx_dentry_dec(d) do { \
13846 + if (atomic_read(&d->d_count) == 0) \
13847 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
13850 +#define vx_dentry_avail(n) \
13851 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
13854 +/* socket limits */
13856 +#define vx_sock_inc(s) \
13857 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
13859 +#define vx_sock_dec(s) \
13860 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
13862 +#define vx_sock_avail(n) \
13863 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
13866 +/* ipc resource limits */
13868 +#define vx_ipcmsg_add(v, u, a) \
13869 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
13871 +#define vx_ipcmsg_sub(v, u, a) \
13872 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
13874 +#define vx_ipcmsg_avail(v, a) \
13875 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
13878 +#define vx_ipcshm_add(v, k, a) \
13879 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13881 +#define vx_ipcshm_sub(v, k, a) \
13882 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13884 +#define vx_ipcshm_avail(v, a) \
13885 + vx_cres_avail(v, a, VLIMIT_SHMEM)
13888 +#define vx_semary_inc(a) \
13889 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
13891 +#define vx_semary_dec(a) \
13892 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
13895 +#define vx_nsems_add(a,n) \
13896 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
13898 +#define vx_nsems_sub(a,n) \
13899 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
13903 +#warning duplicate inclusion
13905 diff -NurpP --minimal linux-2.6.37/include/linux/vs_memory.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_memory.h
13906 --- linux-2.6.37/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
13907 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_memory.h 2010-11-23 02:09:41.000000000 +0100
13909 +#ifndef _VS_MEMORY_H
13910 +#define _VS_MEMORY_H
13912 +#include "vserver/limit.h"
13913 +#include "vserver/base.h"
13914 +#include "vserver/context.h"
13915 +#include "vserver/debug.h"
13916 +#include "vserver/context.h"
13917 +#include "vserver/limit_int.h"
13920 + VXPT_UNKNOWN = 0,
13929 +#define vx_page_fault(mm, vma, type, ret)
13933 +void __vx_page_fault(struct mm_struct *mm,
13934 + struct vm_area_struct *vma, int type, int ret)
13936 + struct vx_info *vxi = mm->mm_vx_info;
13939 + static char *page_type[6] =
13940 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
13941 + static char *page_what[4] =
13942 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
13948 + what = (ret & 0x3);
13950 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
13951 + type, what, ret, page_type[type], page_what[what]);
13953 + if (ret & VM_FAULT_WRITE)
13955 + atomic_inc(&vxi->cacct.page[type][what]);
13958 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
13962 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
13965 +#warning duplicate inclusion
13967 diff -NurpP --minimal linux-2.6.37/include/linux/vs_network.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_network.h
13968 --- linux-2.6.37/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
13969 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_network.h 2010-11-23 02:09:41.000000000 +0100
13971 +#ifndef _NX_VS_NETWORK_H
13972 +#define _NX_VS_NETWORK_H
13974 +#include "vserver/context.h"
13975 +#include "vserver/network.h"
13976 +#include "vserver/base.h"
13977 +#include "vserver/check.h"
13978 +#include "vserver/debug.h"
13980 +#include <linux/sched.h>
13983 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
13985 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
13986 + const char *_file, int _line)
13991 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
13992 + nxi, nxi ? nxi->nx_id : 0,
13993 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13996 + atomic_inc(&nxi->nx_usecnt);
14001 +extern void free_nx_info(struct nx_info *);
14003 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14005 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14010 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14011 + nxi, nxi ? nxi->nx_id : 0,
14012 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14015 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14016 + free_nx_info(nxi);
14020 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14022 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14023 + const char *_file, int _line)
14026 + vxlprintk(VXD_CBIT(nid, 3),
14027 + "init_nx_info(%p[#%d.%d])",
14028 + nxi, nxi ? nxi->nx_id : 0,
14029 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14032 + atomic_inc(&nxi->nx_usecnt);
14038 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14040 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14041 + const char *_file, int _line)
14043 + struct nx_info *nxo;
14048 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14049 + nxi, nxi ? nxi->nx_id : 0,
14050 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14053 + atomic_inc(&nxi->nx_usecnt);
14054 + nxo = xchg(nxp, nxi);
14058 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14060 +static inline void __clr_nx_info(struct nx_info **nxp,
14061 + const char *_file, int _line)
14063 + struct nx_info *nxo;
14065 + nxo = xchg(nxp, NULL);
14069 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14070 + nxo, nxo ? nxo->nx_id : 0,
14071 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14074 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14075 + free_nx_info(nxo);
14079 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14081 +static inline void __claim_nx_info(struct nx_info *nxi,
14082 + struct task_struct *task, const char *_file, int _line)
14084 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14085 + nxi, nxi ? nxi->nx_id : 0,
14086 + nxi?atomic_read(&nxi->nx_usecnt):0,
14087 + nxi?atomic_read(&nxi->nx_tasks):0,
14088 + task, _file, _line);
14090 + atomic_inc(&nxi->nx_tasks);
14094 +extern void unhash_nx_info(struct nx_info *);
14096 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14098 +static inline void __release_nx_info(struct nx_info *nxi,
14099 + struct task_struct *task, const char *_file, int _line)
14101 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14102 + nxi, nxi ? nxi->nx_id : 0,
14103 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14104 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14105 + task, _file, _line);
14109 + if (atomic_dec_and_test(&nxi->nx_tasks))
14110 + unhash_nx_info(nxi);
14114 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14116 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14117 + const char *_file, int _line)
14119 + struct nx_info *nxi;
14122 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14123 + p, _file, _line);
14124 + nxi = __get_nx_info(p->nx_info, _file, _line);
14130 +static inline void exit_nx_info(struct task_struct *p)
14133 + release_nx_info(p->nx_info, p);
14138 +#warning duplicate inclusion
14140 diff -NurpP --minimal linux-2.6.37/include/linux/vs_pid.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_pid.h
14141 --- linux-2.6.37/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14142 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_pid.h 2010-11-23 02:09:41.000000000 +0100
14147 +#include "vserver/base.h"
14148 +#include "vserver/check.h"
14149 +#include "vserver/context.h"
14150 +#include "vserver/debug.h"
14151 +#include "vserver/pid.h"
14152 +#include <linux/pid_namespace.h>
14155 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14158 +int vx_proc_task_visible(struct task_struct *task)
14160 + if ((task->pid == 1) &&
14161 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14162 + /* show a blend through init */
14164 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14171 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14176 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14178 + struct task_struct *task = find_task_by_real_pid(pid);
14180 + if (task && !vx_proc_task_visible(task)) {
14181 + vxdprintk(VXD_CBIT(misc, 6),
14182 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14183 + task, task->xid, task->pid,
14184 + current, current->xid, current->pid);
14193 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14195 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14197 + if (task && !vx_proc_task_visible(task)) {
14198 + vxdprintk(VXD_CBIT(misc, 6),
14199 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14200 + task, task->xid, task->pid,
14201 + current, current->xid, current->pid);
14202 + put_task_struct(task);
14211 +struct task_struct *vx_child_reaper(struct task_struct *p)
14213 + struct vx_info *vxi = p->vx_info;
14214 + struct task_struct *reaper = child_reaper(p);
14219 + BUG_ON(!p->vx_info->vx_reaper);
14221 + /* child reaper for the guest reaper */
14222 + if (vxi->vx_reaper == p)
14225 + reaper = vxi->vx_reaper;
14227 + vxdprintk(VXD_CBIT(xid, 7),
14228 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14229 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14237 +#warning duplicate inclusion
14239 diff -NurpP --minimal linux-2.6.37/include/linux/vs_sched.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_sched.h
14240 --- linux-2.6.37/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14241 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_sched.h 2010-11-23 02:09:41.000000000 +0100
14243 +#ifndef _VS_SCHED_H
14244 +#define _VS_SCHED_H
14246 +#include "vserver/base.h"
14247 +#include "vserver/context.h"
14248 +#include "vserver/sched.h"
14251 +#define MAX_PRIO_BIAS 20
14252 +#define MIN_PRIO_BIAS -20
14255 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14257 + struct vx_info *vxi = p->vx_info;
14260 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14264 +static inline void vx_account_user(struct vx_info *vxi,
14265 + cputime_t cputime, int nice)
14269 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14272 +static inline void vx_account_system(struct vx_info *vxi,
14273 + cputime_t cputime, int idle)
14277 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14281 +#warning duplicate inclusion
14283 diff -NurpP --minimal linux-2.6.37/include/linux/vs_socket.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_socket.h
14284 --- linux-2.6.37/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14285 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_socket.h 2010-11-23 02:09:41.000000000 +0100
14287 +#ifndef _VS_SOCKET_H
14288 +#define _VS_SOCKET_H
14290 +#include "vserver/debug.h"
14291 +#include "vserver/base.h"
14292 +#include "vserver/cacct.h"
14293 +#include "vserver/context.h"
14294 +#include "vserver/tag.h"
14297 +/* socket accounting */
14299 +#include <linux/socket.h>
14301 +static inline int vx_sock_type(int family)
14303 + switch (family) {
14305 + return VXA_SOCK_UNSPEC;
14307 + return VXA_SOCK_UNIX;
14309 + return VXA_SOCK_INET;
14311 + return VXA_SOCK_INET6;
14313 + return VXA_SOCK_PACKET;
14315 + return VXA_SOCK_OTHER;
14319 +#define vx_acc_sock(v, f, p, s) \
14320 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14322 +static inline void __vx_acc_sock(struct vx_info *vxi,
14323 + int family, int pos, int size, char *file, int line)
14326 + int type = vx_sock_type(family);
14328 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14329 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14333 +#define vx_sock_recv(sk, s) \
14334 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14335 +#define vx_sock_send(sk, s) \
14336 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14337 +#define vx_sock_fail(sk, s) \
14338 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14341 +#define sock_vx_init(s) do { \
14342 + (s)->sk_xid = 0; \
14343 + (s)->sk_vx_info = NULL; \
14346 +#define sock_nx_init(s) do { \
14347 + (s)->sk_nid = 0; \
14348 + (s)->sk_nx_info = NULL; \
14352 +#warning duplicate inclusion
14354 diff -NurpP --minimal linux-2.6.37/include/linux/vs_tag.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_tag.h
14355 --- linux-2.6.37/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14356 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_tag.h 2010-11-23 02:09:41.000000000 +0100
14361 +#include <linux/vserver/tag.h>
14363 +/* check conditions */
14365 +#define DX_ADMIN 0x0001
14366 +#define DX_WATCH 0x0002
14367 +#define DX_HOSTID 0x0008
14369 +#define DX_IDENT 0x0010
14371 +#define DX_ARG_MASK 0x0010
14374 +#define dx_task_tag(t) ((t)->tag)
14376 +#define dx_current_tag() dx_task_tag(current)
14378 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14380 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14384 + * check current context for ADMIN/WATCH and
14385 + * optionally against supplied argument
14387 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14389 + if (mode & DX_ARG_MASK) {
14390 + if ((mode & DX_IDENT) && (id == cid))
14393 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14394 + ((mode & DX_WATCH) && (cid == 1)) ||
14395 + ((mode & DX_HOSTID) && (id == 0)));
14399 +int dx_permission(const struct inode *inode, int mask);
14403 +#warning duplicate inclusion
14405 diff -NurpP --minimal linux-2.6.37/include/linux/vs_time.h linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_time.h
14406 --- linux-2.6.37/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14407 +++ linux-2.6.37-vs2.3.0.37-rc2/include/linux/vs_time.h 2010-11-23 02:09:41.000000000 +0100
14409 +#ifndef _VS_TIME_H
14410 +#define _VS_TIME_H
14413 +/* time faking stuff */
14415 +#ifdef CONFIG_VSERVER_VTIME
14417 +extern void vx_adjust_timespec(struct timespec *ts);
14418 +extern int vx_settimeofday(struct timespec *ts);
14421 +#define vx_adjust_timespec(t) do { } while (0)
14422 +#define vx_settimeofday(t) do_settimeofday(t)
14426 +#warning duplicate inclusion
14428 diff -NurpP --minimal linux-2.6.37/include/net/addrconf.h linux-2.6.37-vs2.3.0.37-rc2/include/net/addrconf.h
14429 --- linux-2.6.37/include/net/addrconf.h 2011-01-05 21:50:35.000000000 +0100
14430 +++ linux-2.6.37-vs2.3.0.37-rc2/include/net/addrconf.h 2010-11-23 02:09:41.000000000 +0100
14431 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14432 struct net_device *dev,
14433 const struct in6_addr *daddr,
14434 unsigned int srcprefs,
14435 - struct in6_addr *saddr);
14436 + struct in6_addr *saddr,
14437 + struct nx_info *nxi);
14438 extern int ipv6_get_lladdr(struct net_device *dev,
14439 struct in6_addr *addr,
14440 unsigned char banned_flags);
14441 diff -NurpP --minimal linux-2.6.37/include/net/af_unix.h linux-2.6.37-vs2.3.0.37-rc2/include/net/af_unix.h
14442 --- linux-2.6.37/include/net/af_unix.h 2011-01-05 21:50:35.000000000 +0100
14443 +++ linux-2.6.37-vs2.3.0.37-rc2/include/net/af_unix.h 2011-01-05 22:30:40.000000000 +0100
14445 #include <linux/socket.h>
14446 #include <linux/un.h>
14447 #include <linux/mutex.h>
14448 +#include <linux/vs_base.h>
14449 #include <net/sock.h>
14451 extern void unix_inflight(struct file *fp);
14452 diff -NurpP --minimal linux-2.6.37/include/net/inet_timewait_sock.h linux-2.6.37-vs2.3.0.37-rc2/include/net/inet_timewait_sock.h
14453 --- linux-2.6.37/include/net/inet_timewait_sock.h 2010-08-02 16:52:56.000000000 +0200
14454 +++ linux-2.6.37-vs2.3.0.37-rc2/include/net/inet_timewait_sock.h 2010-11-23 02:09:41.000000000 +0100
14455 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
14456 #define tw_hash __tw_common.skc_hash
14457 #define tw_prot __tw_common.skc_prot
14458 #define tw_net __tw_common.skc_net
14459 +#define tw_xid __tw_common.skc_xid
14460 +#define tw_vx_info __tw_common.skc_vx_info
14461 +#define tw_nid __tw_common.skc_nid
14462 +#define tw_nx_info __tw_common.skc_nx_info
14464 volatile unsigned char tw_substate;
14465 /* 3 bits hole, try to pack */
14466 diff -NurpP --minimal linux-2.6.37/include/net/route.h linux-2.6.37-vs2.3.0.37-rc2/include/net/route.h
14467 --- linux-2.6.37/include/net/route.h 2010-10-21 13:07:56.000000000 +0200
14468 +++ linux-2.6.37-vs2.3.0.37-rc2/include/net/route.h 2010-11-23 02:09:41.000000000 +0100
14469 @@ -145,6 +145,9 @@ static inline void ip_rt_put(struct rtab
14470 dst_release(&rt->dst);
14473 +#include <linux/vs_base.h>
14474 +#include <linux/vs_inet.h>
14476 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14478 extern const __u8 ip_tos2prio[16];
14479 @@ -154,6 +157,9 @@ static inline char rt_tos2priority(u8 to
14480 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14483 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14484 + struct rtable **, struct flowi *);
14486 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14487 __be32 src, u32 tos, int oif, u8 protocol,
14488 __be16 sport, __be16 dport, struct sock *sk,
14489 @@ -171,11 +177,24 @@ static inline int ip_route_connect(struc
14492 struct net *net = sock_net(sk);
14493 + struct nx_info *nx_info = current_nx_info();
14495 if (inet_sk(sk)->transparent)
14496 fl.flags |= FLOWI_FLAG_ANYSRC;
14498 - if (!dst || !src) {
14500 + nx_info = sk->sk_nx_info;
14502 + vxdprintk(VXD_CBIT(net, 4),
14503 + "ip_route_connect(%p) %p,%p;%lx",
14504 + sk, nx_info, sk->sk_socket,
14505 + (sk->sk_socket?sk->sk_socket->flags:0));
14507 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14511 + if (!fl.fl4_dst || !fl.fl4_src) {
14512 err = __ip_route_output_key(net, rp, &fl);
14515 diff -NurpP --minimal linux-2.6.37/include/net/sock.h linux-2.6.37-vs2.3.0.37-rc2/include/net/sock.h
14516 --- linux-2.6.37/include/net/sock.h 2011-01-05 21:50:36.000000000 +0100
14517 +++ linux-2.6.37-vs2.3.0.37-rc2/include/net/sock.h 2011-01-05 22:30:42.000000000 +0100
14518 @@ -150,6 +150,10 @@ struct sock_common {
14519 #ifdef CONFIG_NET_NS
14520 struct net *skc_net;
14523 + struct vx_info *skc_vx_info;
14525 + struct nx_info *skc_nx_info;
14529 @@ -241,6 +245,10 @@ struct sock {
14530 #define sk_bind_node __sk_common.skc_bind_node
14531 #define sk_prot __sk_common.skc_prot
14532 #define sk_net __sk_common.skc_net
14533 +#define sk_xid __sk_common.skc_xid
14534 +#define sk_vx_info __sk_common.skc_vx_info
14535 +#define sk_nid __sk_common.skc_nid
14536 +#define sk_nx_info __sk_common.skc_nx_info
14537 kmemcheck_bitfield_begin(flags);
14538 unsigned int sk_shutdown : 2,
14540 diff -NurpP --minimal linux-2.6.37/init/Kconfig linux-2.6.37-vs2.3.0.37-rc2/init/Kconfig
14541 --- linux-2.6.37/init/Kconfig 2011-01-05 21:50:37.000000000 +0100
14542 +++ linux-2.6.37-vs2.3.0.37-rc2/init/Kconfig 2011-01-05 22:30:42.000000000 +0100
14543 @@ -503,6 +503,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14545 boolean "Control Group support"
14549 This option adds support for grouping sets of processes together, for
14550 use with process control subsystems such as Cpusets, CFS, memory
14551 @@ -528,6 +529,7 @@ config CGROUP_DEBUG
14554 bool "Namespace cgroup subsystem"
14557 Provides a simple namespace cgroup subsystem to
14558 provide hierarchical naming of sets of namespaces,
14559 diff -NurpP --minimal linux-2.6.37/init/main.c linux-2.6.37-vs2.3.0.37-rc2/init/main.c
14560 --- linux-2.6.37/init/main.c 2011-01-05 21:50:37.000000000 +0100
14561 +++ linux-2.6.37-vs2.3.0.37-rc2/init/main.c 2010-11-23 02:09:41.000000000 +0100
14563 #include <linux/sfi.h>
14564 #include <linux/shmem_fs.h>
14565 #include <linux/slab.h>
14566 +#include <linux/vserver/percpu.h>
14568 #include <asm/io.h>
14569 #include <asm/bugs.h>
14570 diff -NurpP --minimal linux-2.6.37/ipc/mqueue.c linux-2.6.37-vs2.3.0.37-rc2/ipc/mqueue.c
14571 --- linux-2.6.37/ipc/mqueue.c 2011-01-05 21:50:37.000000000 +0100
14572 +++ linux-2.6.37-vs2.3.0.37-rc2/ipc/mqueue.c 2010-11-23 02:09:41.000000000 +0100
14574 #include <linux/pid.h>
14575 #include <linux/ipc_namespace.h>
14576 #include <linux/slab.h>
14577 +#include <linux/vs_context.h>
14578 +#include <linux/vs_limit.h>
14580 #include <net/sock.h>
14582 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14583 struct sigevent notify;
14584 struct pid* notify_owner;
14585 struct user_struct *user; /* user who created, for accounting */
14586 + struct vx_info *vxi;
14587 struct sock *notify_sock;
14588 struct sk_buff *notify_cookie;
14590 @@ -126,6 +129,7 @@ static struct inode *mqueue_get_inode(st
14591 if (S_ISREG(mode)) {
14592 struct mqueue_inode_info *info;
14593 struct task_struct *p = current;
14594 + struct vx_info *vxi = p->vx_info;
14595 unsigned long mq_bytes, mq_msg_tblsz;
14597 inode->i_fop = &mqueue_file_operations;
14598 @@ -139,6 +143,7 @@ static struct inode *mqueue_get_inode(st
14599 info->notify_owner = NULL;
14601 info->user = NULL; /* set when all is ok */
14602 + info->vxi = NULL;
14603 memset(&info->attr, 0, sizeof(info->attr));
14604 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14605 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14606 @@ -157,16 +162,19 @@ static struct inode *mqueue_get_inode(st
14607 spin_lock(&mq_lock);
14608 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14609 u->mq_bytes + mq_bytes >
14610 - task_rlimit(p, RLIMIT_MSGQUEUE)) {
14611 + task_rlimit(p, RLIMIT_MSGQUEUE) ||
14612 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14613 spin_unlock(&mq_lock);
14614 /* mqueue_evict_inode() releases info->messages */
14617 u->mq_bytes += mq_bytes;
14618 + vx_ipcmsg_add(vxi, u, mq_bytes);
14619 spin_unlock(&mq_lock);
14622 info->user = get_uid(u);
14623 + info->vxi = get_vx_info(vxi);
14624 } else if (S_ISDIR(mode)) {
14626 /* Some things misbehave if size == 0 on a directory */
14627 @@ -268,8 +276,11 @@ static void mqueue_evict_inode(struct in
14628 + info->attr.mq_msgsize);
14631 + struct vx_info *vxi = info->vxi;
14633 spin_lock(&mq_lock);
14634 user->mq_bytes -= mq_bytes;
14635 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14637 * get_ns_from_inode() ensures that the
14638 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14639 @@ -279,6 +290,7 @@ static void mqueue_evict_inode(struct in
14641 ipc_ns->mq_queues_count--;
14642 spin_unlock(&mq_lock);
14643 + put_vx_info(vxi);
14647 diff -NurpP --minimal linux-2.6.37/ipc/msg.c linux-2.6.37-vs2.3.0.37-rc2/ipc/msg.c
14648 --- linux-2.6.37/ipc/msg.c 2010-08-02 16:52:57.000000000 +0200
14649 +++ linux-2.6.37-vs2.3.0.37-rc2/ipc/msg.c 2010-11-23 02:09:41.000000000 +0100
14651 #include <linux/rwsem.h>
14652 #include <linux/nsproxy.h>
14653 #include <linux/ipc_namespace.h>
14654 +#include <linux/vs_base.h>
14656 #include <asm/current.h>
14657 #include <asm/uaccess.h>
14658 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14660 msq->q_perm.mode = msgflg & S_IRWXUGO;
14661 msq->q_perm.key = key;
14662 + msq->q_perm.xid = vx_current_xid();
14664 msq->q_perm.security = NULL;
14665 retval = security_msg_queue_alloc(msq);
14666 diff -NurpP --minimal linux-2.6.37/ipc/namespace.c linux-2.6.37-vs2.3.0.37-rc2/ipc/namespace.c
14667 --- linux-2.6.37/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
14668 +++ linux-2.6.37-vs2.3.0.37-rc2/ipc/namespace.c 2010-11-23 02:09:41.000000000 +0100
14670 #include <linux/slab.h>
14671 #include <linux/fs.h>
14672 #include <linux/mount.h>
14673 +#include <linux/vs_base.h>
14674 +#include <linux/vserver/global.h>
14678 diff -NurpP --minimal linux-2.6.37/ipc/sem.c linux-2.6.37-vs2.3.0.37-rc2/ipc/sem.c
14679 --- linux-2.6.37/ipc/sem.c 2010-10-21 13:07:56.000000000 +0200
14680 +++ linux-2.6.37-vs2.3.0.37-rc2/ipc/sem.c 2010-11-23 02:09:41.000000000 +0100
14682 #include <linux/rwsem.h>
14683 #include <linux/nsproxy.h>
14684 #include <linux/ipc_namespace.h>
14685 +#include <linux/vs_base.h>
14686 +#include <linux/vs_limit.h>
14688 #include <asm/uaccess.h>
14690 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
14692 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14693 sma->sem_perm.key = key;
14694 + sma->sem_perm.xid = vx_current_xid();
14696 sma->sem_perm.security = NULL;
14697 retval = security_sem_alloc(sma);
14698 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
14701 ns->used_sems += nsems;
14702 + /* FIXME: obsoleted? */
14703 + vx_semary_inc(sma);
14704 + vx_nsems_add(sma, nsems);
14706 sma->sem_base = (struct sem *) &sma[1];
14708 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
14710 wake_up_sem_queue_do(&tasks);
14711 ns->used_sems -= sma->sem_nsems;
14712 + /* FIXME: obsoleted? */
14713 + vx_nsems_sub(sma, sma->sem_nsems);
14714 + vx_semary_dec(sma);
14715 security_sem_free(sma);
14716 ipc_rcu_putref(sma);
14718 diff -NurpP --minimal linux-2.6.37/ipc/shm.c linux-2.6.37-vs2.3.0.37-rc2/ipc/shm.c
14719 --- linux-2.6.37/ipc/shm.c 2011-01-05 21:50:37.000000000 +0100
14720 +++ linux-2.6.37-vs2.3.0.37-rc2/ipc/shm.c 2010-11-23 02:09:41.000000000 +0100
14722 #include <linux/nsproxy.h>
14723 #include <linux/mount.h>
14724 #include <linux/ipc_namespace.h>
14725 +#include <linux/vs_context.h>
14726 +#include <linux/vs_limit.h>
14728 #include <asm/uaccess.h>
14730 @@ -173,7 +175,12 @@ static void shm_open(struct vm_area_stru
14732 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14734 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14735 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14736 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14738 + vx_ipcshm_sub(vxi, shp, numpages);
14739 + ns->shm_tot -= numpages;
14743 if (!is_file_hugepages(shp->shm_file))
14744 @@ -183,6 +190,7 @@ static void shm_destroy(struct ipc_names
14746 fput (shp->shm_file);
14747 security_shm_free(shp);
14748 + put_vx_info(vxi);
14749 ipc_rcu_putref(shp);
14752 @@ -355,11 +363,15 @@ static int newseg(struct ipc_namespace *
14753 if (ns->shm_tot + numpages > ns->shm_ctlall)
14756 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14759 shp = ipc_rcu_alloc(sizeof(*shp));
14763 shp->shm_perm.key = key;
14764 + shp->shm_perm.xid = vx_current_xid();
14765 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14766 shp->mlock_user = NULL;
14768 @@ -413,6 +425,7 @@ static int newseg(struct ipc_namespace *
14769 ns->shm_tot += numpages;
14770 error = shp->shm_perm.id;
14772 + vx_ipcshm_add(current_vx_info(), key, numpages);
14776 diff -NurpP --minimal linux-2.6.37/kernel/capability.c linux-2.6.37-vs2.3.0.37-rc2/kernel/capability.c
14777 --- linux-2.6.37/kernel/capability.c 2010-08-02 16:52:57.000000000 +0200
14778 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/capability.c 2010-11-23 02:09:41.000000000 +0100
14780 #include <linux/security.h>
14781 #include <linux/syscalls.h>
14782 #include <linux/pid_namespace.h>
14783 +#include <linux/vs_context.h>
14784 #include <asm/uaccess.h>
14787 @@ -119,6 +120,7 @@ static int cap_validate_magic(cap_user_h
14793 * The only thing that can change the capabilities of the current
14794 * process is the current process. As such, we can't be in this code
14795 @@ -289,6 +291,8 @@ error:
14799 +#include <linux/vserver/base.h>
14802 * capable - Determine if the current task has a superior capability in effect
14803 * @cap: The capability to be tested for
14804 @@ -301,6 +305,9 @@ error:
14806 int capable(int cap)
14808 + /* here for now so we don't require task locking */
14809 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
14811 if (unlikely(!cap_valid(cap))) {
14812 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
14814 diff -NurpP --minimal linux-2.6.37/kernel/compat.c linux-2.6.37-vs2.3.0.37-rc2/kernel/compat.c
14815 --- linux-2.6.37/kernel/compat.c 2010-10-21 13:07:56.000000000 +0200
14816 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/compat.c 2010-11-23 02:09:41.000000000 +0100
14817 @@ -914,7 +914,7 @@ asmlinkage long compat_sys_stime(compat_
14821 - do_settimeofday(&tv);
14822 + vx_settimeofday(&tv);
14826 diff -NurpP --minimal linux-2.6.37/kernel/cred.c linux-2.6.37-vs2.3.0.37-rc2/kernel/cred.c
14827 --- linux-2.6.37/kernel/cred.c 2011-01-05 21:50:37.000000000 +0100
14828 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/cred.c 2011-01-08 03:33:34.000000000 +0100
14829 @@ -60,31 +60,6 @@ struct cred init_cred = {
14833 -static inline void set_cred_subscribers(struct cred *cred, int n)
14835 -#ifdef CONFIG_DEBUG_CREDENTIALS
14836 - atomic_set(&cred->subscribers, n);
14840 -static inline int read_cred_subscribers(const struct cred *cred)
14842 -#ifdef CONFIG_DEBUG_CREDENTIALS
14843 - return atomic_read(&cred->subscribers);
14849 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14851 -#ifdef CONFIG_DEBUG_CREDENTIALS
14852 - struct cred *cred = (struct cred *) _cred;
14854 - atomic_add(n, &cred->subscribers);
14859 * Dispose of the shared task group credentials
14861 diff -NurpP --minimal linux-2.6.37/kernel/exit.c linux-2.6.37-vs2.3.0.37-rc2/kernel/exit.c
14862 --- linux-2.6.37/kernel/exit.c 2011-01-05 21:50:37.000000000 +0100
14863 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/exit.c 2011-01-05 22:30:42.000000000 +0100
14865 #include <linux/fs_struct.h>
14866 #include <linux/init_task.h>
14867 #include <linux/perf_event.h>
14868 +#include <linux/vs_limit.h>
14869 +#include <linux/vs_context.h>
14870 +#include <linux/vs_network.h>
14871 +#include <linux/vs_pid.h>
14872 #include <trace/events/sched.h>
14873 #include <linux/hw_breakpoint.h>
14874 #include <linux/oom.h>
14875 @@ -494,9 +498,11 @@ static void close_files(struct files_str
14876 filp_close(file, files);
14879 + vx_openfd_dec(i);
14887 @@ -1043,11 +1049,16 @@ NORET_TYPE void do_exit(long code)
14889 validate_creds_for_do_exit(tsk);
14891 + /* needs to stay after exit_notify() */
14892 + exit_vx_info(tsk, code);
14893 + exit_nx_info(tsk);
14897 /* causes final put_task_struct in finish_task_switch(). */
14898 tsk->state = TASK_DEAD;
14900 + printk("bad task: %p [%lx]\n", current, current->state);
14902 /* Avoid "noreturn function does return". */
14904 diff -NurpP --minimal linux-2.6.37/kernel/fork.c linux-2.6.37-vs2.3.0.37-rc2/kernel/fork.c
14905 --- linux-2.6.37/kernel/fork.c 2011-01-05 21:50:37.000000000 +0100
14906 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/fork.c 2011-01-05 22:30:42.000000000 +0100
14908 #include <linux/posix-timers.h>
14909 #include <linux/user-return-notifier.h>
14910 #include <linux/oom.h>
14911 +#include <linux/vs_context.h>
14912 +#include <linux/vs_network.h>
14913 +#include <linux/vs_limit.h>
14914 +#include <linux/vs_memory.h>
14916 #include <asm/pgtable.h>
14917 #include <asm/pgalloc.h>
14918 @@ -161,6 +165,8 @@ void free_task(struct task_struct *tsk)
14919 account_kernel_stack(tsk->stack, -1);
14920 free_thread_info(tsk->stack);
14921 rt_mutex_debug_task_free(tsk);
14922 + clr_vx_info(&tsk->vx_info);
14923 + clr_nx_info(&tsk->nx_info);
14924 ftrace_graph_exit_task(tsk);
14925 free_task_struct(tsk);
14927 @@ -495,6 +501,7 @@ static struct mm_struct * mm_init(struct
14928 if (likely(!mm_alloc_pgd(mm))) {
14930 mmu_notifier_mm_init(mm);
14931 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14935 @@ -528,6 +535,7 @@ void __mmdrop(struct mm_struct *mm)
14937 destroy_context(mm);
14938 mmu_notifier_mm_destroy(mm);
14939 + clr_vx_info(&mm->mm_vx_info);
14942 EXPORT_SYMBOL_GPL(__mmdrop);
14943 @@ -663,6 +671,7 @@ struct mm_struct *dup_mm(struct task_str
14946 memcpy(mm, oldmm, sizeof(*mm));
14947 + mm->mm_vx_info = NULL;
14949 /* Initializing for Swap token stuff */
14950 mm->token_priority = 0;
14951 @@ -701,6 +710,7 @@ fail_nocontext:
14952 * If init_new_context() failed, we cannot use mmput() to free the mm
14953 * because it calls destroy_context()
14955 + clr_vx_info(&mm->mm_vx_info);
14959 @@ -980,6 +990,8 @@ static struct task_struct *copy_process(
14961 struct task_struct *p;
14962 int cgroup_callbacks_done = 0;
14963 + struct vx_info *vxi;
14964 + struct nx_info *nxi;
14966 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14967 return ERR_PTR(-EINVAL);
14968 @@ -1026,7 +1038,12 @@ static struct task_struct *copy_process(
14969 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14970 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14972 + init_vx_info(&p->vx_info, current_vx_info());
14973 + init_nx_info(&p->nx_info, current_nx_info());
14976 + if (!vx_nproc_avail(1))
14977 + goto bad_fork_free;
14978 if (atomic_read(&p->real_cred->user->processes) >=
14979 task_rlimit(p, RLIMIT_NPROC)) {
14980 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14981 @@ -1291,6 +1308,18 @@ static struct task_struct *copy_process(
14984 spin_unlock(¤t->sighand->siglock);
14986 + /* p is copy of current */
14987 + vxi = p->vx_info;
14989 + claim_vx_info(vxi, p);
14990 + atomic_inc(&vxi->cvirt.nr_threads);
14991 + atomic_inc(&vxi->cvirt.total_forks);
14994 + nxi = p->nx_info;
14996 + claim_nx_info(nxi, p);
14997 write_unlock_irq(&tasklist_lock);
14998 proc_fork_connector(p);
14999 cgroup_post_fork(p);
15000 diff -NurpP --minimal linux-2.6.37/kernel/kthread.c linux-2.6.37-vs2.3.0.37-rc2/kernel/kthread.c
15001 --- linux-2.6.37/kernel/kthread.c 2011-01-05 21:50:38.000000000 +0100
15002 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/kthread.c 2011-01-05 22:30:42.000000000 +0100
15004 #include <linux/mutex.h>
15005 #include <linux/slab.h>
15006 #include <linux/freezer.h>
15007 +#include <linux/vs_pid.h>
15008 #include <trace/events/sched.h>
15010 static DEFINE_SPINLOCK(kthread_create_lock);
15011 diff -NurpP --minimal linux-2.6.37/kernel/Makefile linux-2.6.37-vs2.3.0.37-rc2/kernel/Makefile
15012 --- linux-2.6.37/kernel/Makefile 2011-01-05 21:50:37.000000000 +0100
15013 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/Makefile 2010-11-23 02:09:41.000000000 +0100
15014 @@ -25,6 +25,7 @@ CFLAGS_REMOVE_perf_event.o = -pg
15015 CFLAGS_REMOVE_irq_work.o = -pg
15019 obj-$(CONFIG_FREEZER) += freezer.o
15020 obj-$(CONFIG_PROFILING) += profile.o
15021 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15022 diff -NurpP --minimal linux-2.6.37/kernel/nsproxy.c linux-2.6.37-vs2.3.0.37-rc2/kernel/nsproxy.c
15023 --- linux-2.6.37/kernel/nsproxy.c 2010-07-07 18:31:57.000000000 +0200
15024 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/nsproxy.c 2010-11-23 02:09:41.000000000 +0100
15026 #include <linux/mnt_namespace.h>
15027 #include <linux/utsname.h>
15028 #include <linux/pid_namespace.h>
15029 +#include <linux/vserver/global.h>
15030 +#include <linux/vserver/debug.h>
15031 #include <net/net_namespace.h>
15032 #include <linux/ipc_namespace.h>
15034 @@ -43,8 +45,11 @@ static inline struct nsproxy *create_nsp
15035 struct nsproxy *nsproxy;
15037 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15040 atomic_set(&nsproxy->count, 1);
15041 + atomic_inc(&vs_global_nsproxy);
15043 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15047 @@ -53,41 +58,52 @@ static inline struct nsproxy *create_nsp
15048 * Return the newly created nsproxy. Do not attach this to the task,
15049 * leave it to the caller to do proper locking and attach it to task.
15051 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15052 - struct task_struct *tsk, struct fs_struct *new_fs)
15053 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15054 + struct nsproxy *orig, struct fs_struct *new_fs)
15056 struct nsproxy *new_nsp;
15059 + vxdprintk(VXD_CBIT(space, 4),
15060 + "unshare_namespaces(0x%08lx,%p,%p)",
15061 + flags, orig, new_fs);
15063 new_nsp = create_nsproxy();
15065 return ERR_PTR(-ENOMEM);
15067 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15068 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15069 if (IS_ERR(new_nsp->mnt_ns)) {
15070 err = PTR_ERR(new_nsp->mnt_ns);
15074 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15075 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15076 if (IS_ERR(new_nsp->uts_ns)) {
15077 err = PTR_ERR(new_nsp->uts_ns);
15081 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15082 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15083 if (IS_ERR(new_nsp->ipc_ns)) {
15084 err = PTR_ERR(new_nsp->ipc_ns);
15088 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15089 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15090 if (IS_ERR(new_nsp->pid_ns)) {
15091 err = PTR_ERR(new_nsp->pid_ns);
15095 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15097 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15098 + if (IS_ERR(new_nsp->user_ns)) {
15099 + err = PTR_ERR(new_nsp->user_ns);
15103 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15104 if (IS_ERR(new_nsp->net_ns)) {
15105 err = PTR_ERR(new_nsp->net_ns);
15107 @@ -112,6 +128,38 @@ out_ns:
15108 return ERR_PTR(err);
15111 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15112 + struct fs_struct *new_fs)
15114 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15118 + * copies the nsproxy, setting refcount to 1, and grabbing a
15119 + * reference to all contained namespaces.
15121 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15123 + struct nsproxy *ns = create_nsproxy();
15126 + memcpy(ns, orig, sizeof(struct nsproxy));
15127 + atomic_set(&ns->count, 1);
15130 + get_mnt_ns(ns->mnt_ns);
15132 + get_uts_ns(ns->uts_ns);
15134 + get_ipc_ns(ns->ipc_ns);
15136 + get_pid_ns(ns->pid_ns);
15138 + get_net(ns->net_ns);
15144 * called from clone. This now handles copy for nsproxy and all
15145 * namespaces therein.
15146 @@ -119,9 +167,12 @@ out_ns:
15147 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15149 struct nsproxy *old_ns = tsk->nsproxy;
15150 - struct nsproxy *new_ns;
15151 + struct nsproxy *new_ns = NULL;
15154 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15155 + flags, tsk, old_ns);
15160 @@ -131,7 +182,7 @@ int copy_namespaces(unsigned long flags,
15161 CLONE_NEWPID | CLONE_NEWNET)))
15164 - if (!capable(CAP_SYS_ADMIN)) {
15165 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15169 @@ -158,6 +209,9 @@ int copy_namespaces(unsigned long flags,
15172 put_nsproxy(old_ns);
15173 + vxdprintk(VXD_CBIT(space, 3),
15174 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15175 + flags, tsk, old_ns, err, new_ns);
15179 @@ -171,7 +225,9 @@ void free_nsproxy(struct nsproxy *ns)
15180 put_ipc_ns(ns->ipc_ns);
15182 put_pid_ns(ns->pid_ns);
15183 - put_net(ns->net_ns);
15185 + put_net(ns->net_ns);
15186 + atomic_dec(&vs_global_nsproxy);
15187 kmem_cache_free(nsproxy_cachep, ns);
15190 @@ -184,11 +240,15 @@ int unshare_nsproxy_namespaces(unsigned
15194 + vxdprintk(VXD_CBIT(space, 4),
15195 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15196 + unshare_flags, current->nsproxy);
15198 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15202 - if (!capable(CAP_SYS_ADMIN))
15203 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15206 *new_nsp = create_new_namespaces(unshare_flags, current,
15207 diff -NurpP --minimal linux-2.6.37/kernel/pid.c linux-2.6.37-vs2.3.0.37-rc2/kernel/pid.c
15208 --- linux-2.6.37/kernel/pid.c 2011-01-05 21:50:38.000000000 +0100
15209 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/pid.c 2010-11-23 02:37:26.000000000 +0100
15211 #include <linux/pid_namespace.h>
15212 #include <linux/init_task.h>
15213 #include <linux/syscalls.h>
15214 +#include <linux/vs_pid.h>
15216 #define pid_hashfn(nr, ns) \
15217 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15218 @@ -339,7 +340,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15220 struct pid *find_vpid(int nr)
15222 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15223 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15225 EXPORT_SYMBOL_GPL(find_vpid);
15227 @@ -399,6 +400,9 @@ void transfer_pid(struct task_struct *ol
15228 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15230 struct task_struct *result = NULL;
15232 + if (type == PIDTYPE_REALPID)
15233 + type = PIDTYPE_PID;
15235 struct hlist_node *first;
15236 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
15237 @@ -417,7 +421,7 @@ EXPORT_SYMBOL(pid_task);
15238 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15240 rcu_lockdep_assert(rcu_read_lock_held());
15241 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15242 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15245 struct task_struct *find_task_by_vpid(pid_t vnr)
15246 @@ -459,7 +463,7 @@ struct pid *find_get_pid(pid_t nr)
15248 EXPORT_SYMBOL_GPL(find_get_pid);
15250 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15251 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15255 @@ -472,6 +476,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15259 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15261 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15264 pid_t pid_vnr(struct pid *pid)
15266 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15267 diff -NurpP --minimal linux-2.6.37/kernel/pid_namespace.c linux-2.6.37-vs2.3.0.37-rc2/kernel/pid_namespace.c
15268 --- linux-2.6.37/kernel/pid_namespace.c 2010-07-07 18:31:57.000000000 +0200
15269 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/pid_namespace.c 2010-11-23 02:09:41.000000000 +0100
15271 #include <linux/err.h>
15272 #include <linux/acct.h>
15273 #include <linux/slab.h>
15274 +#include <linux/vserver/global.h>
15276 #define BITS_PER_PAGE (PAGE_SIZE*8)
15278 @@ -87,6 +88,7 @@ static struct pid_namespace *create_pid_
15281 kref_init(&ns->kref);
15282 + atomic_inc(&vs_global_pid_ns);
15284 ns->parent = get_pid_ns(parent_pid_ns);
15286 @@ -112,6 +114,7 @@ static void destroy_pid_namespace(struct
15288 for (i = 0; i < PIDMAP_ENTRIES; i++)
15289 kfree(ns->pidmap[i].page);
15290 + atomic_dec(&vs_global_pid_ns);
15291 kmem_cache_free(pid_ns_cachep, ns);
15294 diff -NurpP --minimal linux-2.6.37/kernel/posix-timers.c linux-2.6.37-vs2.3.0.37-rc2/kernel/posix-timers.c
15295 --- linux-2.6.37/kernel/posix-timers.c 2010-10-21 13:07:57.000000000 +0200
15296 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/posix-timers.c 2010-11-23 02:09:41.000000000 +0100
15298 #include <linux/wait.h>
15299 #include <linux/workqueue.h>
15300 #include <linux/module.h>
15301 +#include <linux/vs_context.h>
15304 * Management arrays for POSIX timers. Timers are kept in slab memory
15305 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
15307 struct task_struct *task;
15308 int shared, ret = -1;
15311 * FIXME: if ->sigq is queued we can race with
15312 * dequeue_signal()->do_schedule_next_timer().
15313 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
15315 task = pid_task(timr->it_pid, PIDTYPE_PID);
15317 + struct vx_info_save vxis;
15318 + struct vx_info *vxi;
15320 + vxi = get_vx_info(task->vx_info);
15321 + enter_vx_info(vxi, &vxis);
15322 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15323 ret = send_sigqueue(timr->sigq, task, shared);
15324 + leave_vx_info(&vxis);
15325 + put_vx_info(vxi);
15329 /* If we failed to send the signal the timer stops. */
15332 diff -NurpP --minimal linux-2.6.37/kernel/printk.c linux-2.6.37-vs2.3.0.37-rc2/kernel/printk.c
15333 --- linux-2.6.37/kernel/printk.c 2011-01-05 21:50:38.000000000 +0100
15334 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/printk.c 2011-01-05 22:30:42.000000000 +0100
15336 #include <linux/syslog.h>
15337 #include <linux/cpu.h>
15338 #include <linux/notifier.h>
15339 +#include <linux/vs_cvirt.h>
15341 #include <asm/uaccess.h>
15343 @@ -272,18 +273,19 @@ int do_syslog(int type, char __user *buf
15344 unsigned i, j, limit, count;
15351 * If this is from /proc/kmsg we only do the capabilities checks
15354 if (type == SYSLOG_ACTION_OPEN || !from_file) {
15355 - if (dmesg_restrict && !capable(CAP_SYS_ADMIN))
15356 + if (dmesg_restrict &&
15357 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
15359 if ((type != SYSLOG_ACTION_READ_ALL &&
15360 type != SYSLOG_ACTION_SIZE_BUFFER) &&
15361 - !capable(CAP_SYS_ADMIN))
15362 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
15366 @@ -291,12 +293,9 @@ int do_syslog(int type, char __user *buf
15371 - case SYSLOG_ACTION_CLOSE: /* Close log */
15373 - case SYSLOG_ACTION_OPEN: /* Open log */
15375 - case SYSLOG_ACTION_READ: /* Read from log */
15376 + if ((type == SYSLOG_ACTION_READ) ||
15377 + (type == SYSLOG_ACTION_READ_ALL) ||
15378 + (type == SYSLOG_ACTION_READ_CLEAR)) {
15380 if (!buf || len < 0)
15382 @@ -307,6 +306,16 @@ int do_syslog(int type, char __user *buf
15387 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15388 + return vx_do_syslog(type, buf, len);
15391 + case SYSLOG_ACTION_CLOSE: /* Close log */
15393 + case SYSLOG_ACTION_OPEN: /* Open log */
15395 + case SYSLOG_ACTION_READ: /* Read from log */
15396 error = wait_event_interruptible(log_wait,
15397 (log_start - log_end));
15399 @@ -333,16 +342,6 @@ int do_syslog(int type, char __user *buf
15401 /* Read last kernel messages */
15402 case SYSLOG_ACTION_READ_ALL:
15404 - if (!buf || len < 0)
15409 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15414 if (count > log_buf_len)
15415 count = log_buf_len;
15416 diff -NurpP --minimal linux-2.6.37/kernel/ptrace.c linux-2.6.37-vs2.3.0.37-rc2/kernel/ptrace.c
15417 --- linux-2.6.37/kernel/ptrace.c 2011-01-05 21:50:38.000000000 +0100
15418 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/ptrace.c 2010-11-23 02:09:41.000000000 +0100
15420 #include <linux/syscalls.h>
15421 #include <linux/uaccess.h>
15422 #include <linux/regset.h>
15423 +#include <linux/vs_context.h>
15427 @@ -150,6 +151,11 @@ int __ptrace_may_access(struct task_stru
15428 dumpable = get_dumpable(task->mm);
15429 if (!dumpable && !capable(CAP_SYS_PTRACE))
15431 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15433 + if (!vx_check(task->xid, VS_IDENT) &&
15434 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15437 return security_ptrace_access_check(task, mode);
15439 @@ -713,6 +719,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
15444 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15445 + goto out_put_task_struct;
15447 if (request == PTRACE_ATTACH) {
15448 ret = ptrace_attach(child);
15450 diff -NurpP --minimal linux-2.6.37/kernel/sched.c linux-2.6.37-vs2.3.0.37-rc2/kernel/sched.c
15451 --- linux-2.6.37/kernel/sched.c 2011-01-05 21:50:38.000000000 +0100
15452 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/sched.c 2011-01-05 22:30:42.000000000 +0100
15454 #include <linux/ctype.h>
15455 #include <linux/ftrace.h>
15456 #include <linux/slab.h>
15457 +#include <linux/vs_sched.h>
15458 +#include <linux/vs_cvirt.h>
15460 #include <asm/tlb.h>
15461 #include <asm/irq_regs.h>
15462 @@ -3361,9 +3363,17 @@ static void calc_global_nohz(unsigned lo
15464 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15466 - loads[0] = (avenrun[0] + offset) << shift;
15467 - loads[1] = (avenrun[1] + offset) << shift;
15468 - loads[2] = (avenrun[2] + offset) << shift;
15469 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15470 + struct vx_info *vxi = current_vx_info();
15472 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15473 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15474 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15476 + loads[0] = (avenrun[0] + offset) << shift;
15477 + loads[1] = (avenrun[1] + offset) << shift;
15478 + loads[2] = (avenrun[2] + offset) << shift;
15483 @@ -3651,16 +3661,19 @@ void account_user_time(struct task_struc
15484 cputime_t cputime_scaled)
15486 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15487 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15489 + int nice = (TASK_NICE(p) > 0);
15491 /* Add user time to process. */
15492 p->utime = cputime_add(p->utime, cputime);
15493 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15494 + vx_account_user(vxi, cputime, nice);
15495 account_group_user_time(p, cputime);
15497 /* Add user time to cpustat. */
15498 tmp = cputime_to_cputime64(cputime);
15499 - if (TASK_NICE(p) > 0)
15501 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15503 cpustat->user = cputime64_add(cpustat->user, tmp);
15504 @@ -3711,6 +3724,7 @@ void account_system_time(struct task_str
15505 cputime_t cputime, cputime_t cputime_scaled)
15507 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15508 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15511 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
15512 @@ -3721,6 +3735,7 @@ void account_system_time(struct task_str
15513 /* Add system time to process. */
15514 p->stime = cputime_add(p->stime, cputime);
15515 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15516 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15517 account_group_system_time(p, cputime);
15519 /* Add system time to cpustat. */
15520 @@ -4804,7 +4819,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15523 if (increment < 0 && !can_nice(current, nice))
15525 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15527 retval = security_task_setnice(current, nice);
15529 diff -NurpP --minimal linux-2.6.37/kernel/sched_fair.c linux-2.6.37-vs2.3.0.37-rc2/kernel/sched_fair.c
15530 --- linux-2.6.37/kernel/sched_fair.c 2011-01-05 21:50:38.000000000 +0100
15531 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/sched_fair.c 2011-01-05 22:30:42.000000000 +0100
15532 @@ -782,6 +782,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15533 check_spread(cfs_rq, se);
15534 if (se != cfs_rq->curr)
15535 __enqueue_entity(cfs_rq, se);
15537 + if (entity_is_task(se))
15538 + vx_activate_task(task_of(se));
15541 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
15542 @@ -825,6 +828,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15544 if (se != cfs_rq->curr)
15545 __dequeue_entity(cfs_rq, se);
15546 + if (entity_is_task(se))
15547 + vx_deactivate_task(task_of(se));
15548 account_entity_dequeue(cfs_rq, se);
15549 update_min_vruntime(cfs_rq);
15551 diff -NurpP --minimal linux-2.6.37/kernel/signal.c linux-2.6.37-vs2.3.0.37-rc2/kernel/signal.c
15552 --- linux-2.6.37/kernel/signal.c 2011-01-05 21:50:38.000000000 +0100
15553 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/signal.c 2010-11-23 02:09:41.000000000 +0100
15555 #include <linux/freezer.h>
15556 #include <linux/pid_namespace.h>
15557 #include <linux/nsproxy.h>
15558 +#include <linux/vs_context.h>
15559 +#include <linux/vs_pid.h>
15560 #define CREATE_TRACE_POINTS
15561 #include <trace/events/signal.h>
15563 @@ -646,9 +648,18 @@ static int check_kill_permission(int sig
15567 + vxdprintk(VXD_CBIT(misc, 7),
15568 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15569 + sig, info, t, vx_task_xid(t), t->pid);
15571 if (!valid_signal(sig))
15574 +/* FIXME: needed? if so, why?
15575 + if ((info != SEND_SIG_NOINFO) &&
15576 + (is_si_special(info) || !si_fromuser(info)))
15579 if (!si_fromuser(info))
15582 @@ -678,6 +689,20 @@ static int check_kill_permission(int sig
15587 + if (t->pid == 1 && current->xid)
15591 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15592 + loops, maybe ENOENT or EACCES? */
15593 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15594 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15595 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15596 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15600 return security_task_kill(t, info, sig, 0);
15603 @@ -1171,7 +1196,7 @@ int kill_pid_info(int sig, struct siginf
15606 p = pid_task(pid, PIDTYPE_PID);
15608 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15609 error = group_send_sig_info(sig, info, p);
15610 if (unlikely(error == -ESRCH))
15612 @@ -1211,7 +1236,7 @@ int kill_pid_info_as_uid(int sig, struct
15615 p = pid_task(pid, PIDTYPE_PID);
15617 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15621 @@ -1266,8 +1291,10 @@ static int kill_something_info(int sig,
15622 struct task_struct * p;
15624 for_each_process(p) {
15625 - if (task_pid_vnr(p) > 1 &&
15626 - !same_thread_group(p, current)) {
15627 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15628 + task_pid_vnr(p) > 1 &&
15629 + !same_thread_group(p, current) &&
15630 + !vx_current_initpid(p->pid)) {
15631 int err = group_send_sig_info(sig, info, p);
15634 @@ -1936,6 +1963,11 @@ relock:
15635 !sig_kernel_only(signr))
15638 + /* virtual init is protected against user signals */
15639 + if ((info->si_code == SI_USER) &&
15640 + vx_current_initpid(current->pid))
15643 if (sig_kernel_stop(signr)) {
15645 * The default action is to stop all threads in
15646 diff -NurpP --minimal linux-2.6.37/kernel/softirq.c linux-2.6.37-vs2.3.0.37-rc2/kernel/softirq.c
15647 --- linux-2.6.37/kernel/softirq.c 2011-01-05 21:50:38.000000000 +0100
15648 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/softirq.c 2010-11-23 02:09:41.000000000 +0100
15650 #include <linux/ftrace.h>
15651 #include <linux/smp.h>
15652 #include <linux/tick.h>
15653 +#include <linux/vs_context.h>
15655 #define CREATE_TRACE_POINTS
15656 #include <trace/events/irq.h>
15657 diff -NurpP --minimal linux-2.6.37/kernel/sys.c linux-2.6.37-vs2.3.0.37-rc2/kernel/sys.c
15658 --- linux-2.6.37/kernel/sys.c 2010-10-21 13:07:57.000000000 +0200
15659 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/sys.c 2010-11-23 02:09:41.000000000 +0100
15661 #include <linux/syscalls.h>
15662 #include <linux/kprobes.h>
15663 #include <linux/user_namespace.h>
15664 +#include <linux/vs_pid.h>
15666 #include <asm/uaccess.h>
15667 #include <asm/io.h>
15668 @@ -131,7 +132,10 @@ static int set_one_prio(struct task_stru
15671 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15673 + if (vx_flags(VXF_IGNEG_NICE, 0))
15679 no_nice = security_task_setnice(p, niceval);
15680 @@ -181,6 +185,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15682 pgrp = task_pgrp(current);
15683 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15684 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15686 error = set_one_prio(p, niceval, error);
15687 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15689 @@ -244,6 +250,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15691 pgrp = task_pgrp(current);
15692 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15693 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15695 niceval = 20 - task_nice(p);
15696 if (niceval > retval)
15698 @@ -357,6 +365,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15700 static DEFINE_MUTEX(reboot_mutex);
15702 +long vs_reboot(unsigned int, void __user *);
15705 * Reboot system call: for obvious reasons only root may call it,
15706 * and even root needs to set up some magic numbers in the registers
15707 @@ -389,6 +399,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15708 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15709 cmd = LINUX_REBOOT_CMD_HALT;
15711 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15712 + return vs_reboot(cmd, arg);
15714 mutex_lock(&reboot_mutex);
15716 case LINUX_REBOOT_CMD_RESTART:
15717 @@ -1169,7 +1182,7 @@ SYSCALL_DEFINE2(sethostname, char __user
15719 char tmp[__NEW_UTS_LEN];
15721 - if (!capable(CAP_SYS_ADMIN))
15722 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15724 if (len < 0 || len > __NEW_UTS_LEN)
15726 @@ -1218,7 +1231,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
15728 char tmp[__NEW_UTS_LEN];
15730 - if (!capable(CAP_SYS_ADMIN))
15731 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15733 if (len < 0 || len > __NEW_UTS_LEN)
15735 @@ -1334,7 +1347,7 @@ int do_prlimit(struct task_struct *tsk,
15736 task_lock(tsk->group_leader);
15738 if (new_rlim->rlim_max > rlim->rlim_max &&
15739 - !capable(CAP_SYS_RESOURCE))
15740 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15743 retval = security_task_setrlimit(tsk->group_leader,
15744 @@ -1383,7 +1396,7 @@ static int check_prlimit_permission(stru
15745 cred->gid != tcred->egid ||
15746 cred->gid != tcred->sgid ||
15747 cred->gid != tcred->gid) &&
15748 - !capable(CAP_SYS_RESOURCE)) {
15749 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT)) {
15753 diff -NurpP --minimal linux-2.6.37/kernel/sysctl_binary.c linux-2.6.37-vs2.3.0.37-rc2/kernel/sysctl_binary.c
15754 --- linux-2.6.37/kernel/sysctl_binary.c 2010-08-02 16:52:57.000000000 +0200
15755 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/sysctl_binary.c 2010-11-23 02:09:41.000000000 +0100
15756 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15758 { CTL_INT, KERN_PANIC, "panic" },
15759 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15760 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15762 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15763 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15764 diff -NurpP --minimal linux-2.6.37/kernel/sysctl.c linux-2.6.37-vs2.3.0.37-rc2/kernel/sysctl.c
15765 --- linux-2.6.37/kernel/sysctl.c 2011-01-05 21:50:39.000000000 +0100
15766 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/sysctl.c 2010-11-23 02:09:41.000000000 +0100
15768 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15769 #include <linux/lockdep.h>
15771 +extern char vshelper_path[];
15772 #ifdef CONFIG_CHR_DEV_SG
15773 #include <scsi/sg.h>
15775 @@ -571,6 +572,13 @@ static struct ctl_table kern_table[] = {
15776 .proc_handler = proc_dostring,
15780 + .procname = "vshelper",
15781 + .data = &vshelper_path,
15784 + .proc_handler = &proc_dostring,
15786 #ifdef CONFIG_CHR_DEV_SG
15788 .procname = "sg-big-buff",
15789 diff -NurpP --minimal linux-2.6.37/kernel/time/timekeeping.c linux-2.6.37-vs2.3.0.37-rc2/kernel/time/timekeeping.c
15790 --- linux-2.6.37/kernel/time/timekeeping.c 2010-10-21 13:07:57.000000000 +0200
15791 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/time/timekeeping.c 2010-11-23 02:09:41.000000000 +0100
15792 @@ -229,6 +229,7 @@ void getnstimeofday(struct timespec *ts)
15793 } while (read_seqretry(&xtime_lock, seq));
15795 timespec_add_ns(ts, nsecs);
15796 + vx_adjust_timespec(ts);
15799 EXPORT_SYMBOL(getnstimeofday);
15800 diff -NurpP --minimal linux-2.6.37/kernel/time.c linux-2.6.37-vs2.3.0.37-rc2/kernel/time.c
15801 --- linux-2.6.37/kernel/time.c 2010-10-21 13:07:57.000000000 +0200
15802 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/time.c 2010-11-23 02:09:41.000000000 +0100
15803 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15807 - do_settimeofday(&tv);
15808 + vx_settimeofday(&tv);
15812 @@ -177,7 +177,7 @@ int do_sys_settimeofday(struct timespec
15813 /* SMP safe, again the code in arch/foo/time.c should
15814 * globally block out interrupts when it runs.
15816 - return do_settimeofday(tv);
15817 + return vx_settimeofday(tv);
15821 diff -NurpP --minimal linux-2.6.37/kernel/timer.c linux-2.6.37-vs2.3.0.37-rc2/kernel/timer.c
15822 --- linux-2.6.37/kernel/timer.c 2011-01-05 21:50:39.000000000 +0100
15823 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/timer.c 2011-01-05 22:30:42.000000000 +0100
15825 #include <linux/irq_work.h>
15826 #include <linux/sched.h>
15827 #include <linux/slab.h>
15828 +#include <linux/vs_base.h>
15829 +#include <linux/vs_cvirt.h>
15830 +#include <linux/vs_pid.h>
15831 +#include <linux/vserver/sched.h>
15833 #include <asm/uaccess.h>
15834 #include <asm/unistd.h>
15835 @@ -1341,12 +1345,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15842 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15843 - * should be moved into arch/i386 instead?
15847 * sys_getpid - return the thread group id of the current process
15848 @@ -1375,10 +1373,23 @@ SYSCALL_DEFINE0(getppid)
15850 pid = task_tgid_vnr(current->real_parent);
15852 + return vx_map_pid(pid);
15859 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15862 +asmlinkage long do_getxpid(long *ppid)
15864 + *ppid = sys_getppid();
15865 + return sys_getpid();
15868 +#else /* _alpha_ */
15870 SYSCALL_DEFINE0(getuid)
15872 /* Only we change this so SMP safe */
15873 diff -NurpP --minimal linux-2.6.37/kernel/user_namespace.c linux-2.6.37-vs2.3.0.37-rc2/kernel/user_namespace.c
15874 --- linux-2.6.37/kernel/user_namespace.c 2010-10-21 13:07:57.000000000 +0200
15875 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/user_namespace.c 2010-11-23 02:09:41.000000000 +0100
15877 #include <linux/user_namespace.h>
15878 #include <linux/highuid.h>
15879 #include <linux/cred.h>
15880 +#include <linux/vserver/global.h>
15883 * Create a new user namespace, deriving the creator from the user in the
15884 @@ -31,6 +32,7 @@ int create_user_ns(struct cred *new)
15887 kref_init(&ns->kref);
15888 + atomic_inc(&vs_global_user_ns);
15890 for (n = 0; n < UIDHASH_SZ; ++n)
15891 INIT_HLIST_HEAD(ns->uidhash_table + n);
15892 @@ -79,6 +81,8 @@ void free_user_ns(struct kref *kref)
15893 struct user_namespace *ns =
15894 container_of(kref, struct user_namespace, kref);
15896 + /* FIXME: maybe move into destroyer? */
15897 + atomic_dec(&vs_global_user_ns);
15898 INIT_WORK(&ns->destroyer, free_user_ns_work);
15899 schedule_work(&ns->destroyer);
15901 diff -NurpP --minimal linux-2.6.37/kernel/utsname.c linux-2.6.37-vs2.3.0.37-rc2/kernel/utsname.c
15902 --- linux-2.6.37/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
15903 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/utsname.c 2010-11-23 02:09:41.000000000 +0100
15904 @@ -14,14 +14,17 @@
15905 #include <linux/utsname.h>
15906 #include <linux/err.h>
15907 #include <linux/slab.h>
15908 +#include <linux/vserver/global.h>
15910 static struct uts_namespace *create_uts_ns(void)
15912 struct uts_namespace *uts_ns;
15914 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15917 kref_init(&uts_ns->kref);
15918 + atomic_inc(&vs_global_uts_ns);
15923 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
15924 struct uts_namespace *ns;
15926 ns = container_of(kref, struct uts_namespace, kref);
15927 + atomic_dec(&vs_global_uts_ns);
15930 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cacct.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cacct.c
15931 --- linux-2.6.37/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
15932 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cacct.c 2010-11-23 02:09:41.000000000 +0100
15935 + * linux/kernel/vserver/cacct.c
15937 + * Virtual Server: Context Accounting
15939 + * Copyright (C) 2006-2007 Herbert Pötzl
15941 + * V0.01 added accounting stats
15945 +#include <linux/types.h>
15946 +#include <linux/vs_context.h>
15947 +#include <linux/vserver/cacct_cmd.h>
15948 +#include <linux/vserver/cacct_int.h>
15950 +#include <asm/errno.h>
15951 +#include <asm/uaccess.h>
15954 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15956 + struct vcmd_sock_stat_v0 vc_data;
15959 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15962 + field = vc_data.field;
15963 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15966 + for (j = 0; j < 3; j++) {
15967 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15968 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15971 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15976 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cacct_init.h linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cacct_init.h
15977 --- linux-2.6.37/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
15978 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cacct_init.h 2010-11-23 02:09:41.000000000 +0100
15982 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15987 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15988 + for (j = 0; j < 3; j++) {
15989 + atomic_long_set(&cacct->sock[i][j].count, 0);
15990 + atomic_long_set(&cacct->sock[i][j].total, 0);
15993 + for (i = 0; i < 8; i++)
15994 + atomic_set(&cacct->slab[i], 0);
15995 + for (i = 0; i < 5; i++)
15996 + for (j = 0; j < 4; j++)
15997 + atomic_set(&cacct->page[i][j], 0);
16000 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16005 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cacct_proc.h linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cacct_proc.h
16006 --- linux-2.6.37/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16007 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cacct_proc.h 2010-11-23 02:09:41.000000000 +0100
16009 +#ifndef _VX_CACCT_PROC_H
16010 +#define _VX_CACCT_PROC_H
16012 +#include <linux/vserver/cacct_int.h>
16015 +#define VX_SOCKA_TOP \
16016 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16018 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16020 + int i, j, length = 0;
16021 + static char *type[VXA_SOCK_SIZE] = {
16022 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16025 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16026 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16027 + length += sprintf(buffer + length, "%s:", type[i]);
16028 + for (j = 0; j < 3; j++) {
16029 + length += sprintf(buffer + length,
16030 + "\t%10lu/%-10lu",
16031 + vx_sock_count(cacct, i, j),
16032 + vx_sock_total(cacct, i, j));
16034 + buffer[length++] = '\n';
16037 + length += sprintf(buffer + length, "\n");
16038 + length += sprintf(buffer + length,
16039 + "slab:\t %8u %8u %8u %8u\n",
16040 + atomic_read(&cacct->slab[1]),
16041 + atomic_read(&cacct->slab[4]),
16042 + atomic_read(&cacct->slab[0]),
16043 + atomic_read(&cacct->slab[2]));
16045 + length += sprintf(buffer + length, "\n");
16046 + for (i = 0; i < 5; i++) {
16047 + length += sprintf(buffer + length,
16048 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16049 + atomic_read(&cacct->page[i][0]),
16050 + atomic_read(&cacct->page[i][1]),
16051 + atomic_read(&cacct->page[i][2]),
16052 + atomic_read(&cacct->page[i][3]),
16053 + atomic_read(&cacct->page[i][4]),
16054 + atomic_read(&cacct->page[i][5]),
16055 + atomic_read(&cacct->page[i][6]),
16056 + atomic_read(&cacct->page[i][7]));
16061 +#endif /* _VX_CACCT_PROC_H */
16062 diff -NurpP --minimal linux-2.6.37/kernel/vserver/context.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/context.c
16063 --- linux-2.6.37/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16064 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/context.c 2011-01-08 03:38:49.000000000 +0100
16067 + * linux/kernel/vserver/context.c
16069 + * Virtual Server: Context Support
16071 + * Copyright (C) 2003-2010 Herbert Pötzl
16073 + * V0.01 context helper
16074 + * V0.02 vx_ctx_kill syscall command
16075 + * V0.03 replaced context_info calls
16076 + * V0.04 redesign of struct (de)alloc
16077 + * V0.05 rlimit basic implementation
16078 + * V0.06 task_xid and info commands
16079 + * V0.07 context flags and caps
16080 + * V0.08 switch to RCU based hash
16081 + * V0.09 revert to non RCU for now
16082 + * V0.10 and back to working RCU hash
16083 + * V0.11 and back to locking again
16084 + * V0.12 referenced context store
16085 + * V0.13 separate per cpu data
16086 + * V0.14 changed vcmds to vxi arg
16087 + * V0.15 added context stat
16088 + * V0.16 have __create claim() the vxi
16089 + * V0.17 removed older and legacy stuff
16090 + * V0.18 added user credentials
16094 +#include <linux/slab.h>
16095 +#include <linux/types.h>
16096 +#include <linux/security.h>
16097 +#include <linux/pid_namespace.h>
16099 +#include <linux/vserver/context.h>
16100 +#include <linux/vserver/network.h>
16101 +#include <linux/vserver/debug.h>
16102 +#include <linux/vserver/limit.h>
16103 +#include <linux/vserver/limit_int.h>
16104 +#include <linux/vserver/space.h>
16105 +#include <linux/init_task.h>
16106 +#include <linux/fs_struct.h>
16107 +#include <linux/cred.h>
16109 +#include <linux/vs_context.h>
16110 +#include <linux/vs_limit.h>
16111 +#include <linux/vs_pid.h>
16112 +#include <linux/vserver/context_cmd.h>
16114 +#include "cvirt_init.h"
16115 +#include "cacct_init.h"
16116 +#include "limit_init.h"
16117 +#include "sched_init.h"
16120 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16121 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16124 +/* now inactive context structures */
16126 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16128 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
16131 +/* __alloc_vx_info()
16133 + * allocate an initialized vx_info struct
16134 + * doesn't make it visible (hash) */
16136 +static struct vx_info *__alloc_vx_info(xid_t xid)
16138 + struct vx_info *new = NULL;
16141 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16143 + /* would this benefit from a slab cache? */
16144 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16148 + memset(new, 0, sizeof(struct vx_info));
16150 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16151 + if (!new->ptr_pc)
16154 + new->vx_id = xid;
16155 + INIT_HLIST_NODE(&new->vx_hlist);
16156 + atomic_set(&new->vx_usecnt, 0);
16157 + atomic_set(&new->vx_tasks, 0);
16158 + new->vx_parent = NULL;
16159 + new->vx_state = 0;
16160 + init_waitqueue_head(&new->vx_wait);
16162 + /* prepare reaper */
16163 + get_task_struct(init_pid_ns.child_reaper);
16164 + new->vx_reaper = init_pid_ns.child_reaper;
16165 + new->vx_badness_bias = 0;
16167 + /* rest of init goes here */
16168 + vx_info_init_limit(&new->limit);
16169 + vx_info_init_sched(&new->sched);
16170 + vx_info_init_cvirt(&new->cvirt);
16171 + vx_info_init_cacct(&new->cacct);
16173 + /* per cpu data structures */
16174 + for_each_possible_cpu(cpu) {
16175 + vx_info_init_sched_pc(
16176 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16177 + vx_info_init_cvirt_pc(
16178 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16181 + new->vx_flags = VXF_INIT_SET;
16182 + cap_set_init_eff(new->vx_bcaps);
16183 + new->vx_ccaps = 0;
16184 + new->vx_umask = 0;
16186 + new->reboot_cmd = 0;
16187 + new->exit_code = 0;
16189 + // preconfig spaces
16190 + for (index = 0; index < VX_SPACES; index++) {
16191 + struct _vx_space *space = &new->space[index];
16194 + spin_lock(&init_fs.lock);
16196 + spin_unlock(&init_fs.lock);
16197 + space->vx_fs = &init_fs;
16199 + /* FIXME: do we want defaults? */
16200 + // space->vx_real_cred = 0;
16201 + // space->vx_cred = 0;
16205 + vxdprintk(VXD_CBIT(xid, 0),
16206 + "alloc_vx_info(%d) = %p", xid, new);
16207 + vxh_alloc_vx_info(new);
16208 + atomic_inc(&vx_global_ctotal);
16217 +/* __dealloc_vx_info()
16219 + * final disposal of vx_info */
16221 +static void __dealloc_vx_info(struct vx_info *vxi)
16223 +#ifdef CONFIG_VSERVER_WARN
16224 + struct vx_info_save vxis;
16227 + vxdprintk(VXD_CBIT(xid, 0),
16228 + "dealloc_vx_info(%p)", vxi);
16229 + vxh_dealloc_vx_info(vxi);
16231 +#ifdef CONFIG_VSERVER_WARN
16232 + enter_vx_info(vxi, &vxis);
16233 + vx_info_exit_limit(&vxi->limit);
16234 + vx_info_exit_sched(&vxi->sched);
16235 + vx_info_exit_cvirt(&vxi->cvirt);
16236 + vx_info_exit_cacct(&vxi->cacct);
16238 + for_each_possible_cpu(cpu) {
16239 + vx_info_exit_sched_pc(
16240 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16241 + vx_info_exit_cvirt_pc(
16242 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16244 + leave_vx_info(&vxis);
16248 + vxi->vx_state |= VXS_RELEASED;
16251 + free_percpu(vxi->ptr_pc);
16254 + atomic_dec(&vx_global_ctotal);
16257 +static void __shutdown_vx_info(struct vx_info *vxi)
16259 + struct nsproxy *nsproxy;
16260 + struct fs_struct *fs;
16261 + const struct cred *cred;
16266 + vxi->vx_state |= VXS_SHUTDOWN;
16267 + vs_state_change(vxi, VSC_SHUTDOWN);
16269 + for (index = 0; index < VX_SPACES; index++) {
16270 + struct _vx_space *space = &vxi->space[index];
16272 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16274 + put_nsproxy(nsproxy);
16276 + fs = xchg(&space->vx_fs, NULL);
16277 + spin_lock(&fs->lock);
16278 + kill = !--fs->users;
16279 + spin_unlock(&fs->lock);
16281 + free_fs_struct(fs);
16283 + cred = xchg(&space->vx_real_cred, NULL);
16285 + alter_cred_subscribers(cred, -1);
16289 + cred = xchg(&space->vx_cred, NULL);
16291 + alter_cred_subscribers(cred, -1);
16298 +/* exported stuff */
16300 +void free_vx_info(struct vx_info *vxi)
16302 + unsigned long flags;
16305 + /* check for reference counts first */
16306 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16307 + BUG_ON(atomic_read(&vxi->vx_tasks));
16309 + /* context must not be hashed */
16310 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16312 + /* context shutdown is mandatory */
16313 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16315 + /* spaces check */
16316 + for (index = 0; index < VX_SPACES; index++) {
16317 + struct _vx_space *space = &vxi->space[index];
16319 + BUG_ON(space->vx_nsproxy);
16320 + BUG_ON(space->vx_fs);
16321 + // BUG_ON(space->vx_real_cred);
16322 + // BUG_ON(space->vx_cred);
16325 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16326 + hlist_del(&vxi->vx_hlist);
16327 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16329 + __dealloc_vx_info(vxi);
16333 +/* hash table for vx_info hash */
16335 +#define VX_HASH_SIZE 13
16337 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16338 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16340 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
16343 +static inline unsigned int __hashval(xid_t xid)
16345 + return (xid % VX_HASH_SIZE);
16350 +/* __hash_vx_info()
16352 + * add the vxi to the global hash table
16353 + * requires the hash_lock to be held */
16355 +static inline void __hash_vx_info(struct vx_info *vxi)
16357 + struct hlist_head *head;
16359 + vxd_assert_lock(&vx_info_hash_lock);
16360 + vxdprintk(VXD_CBIT(xid, 4),
16361 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16362 + vxh_hash_vx_info(vxi);
16364 + /* context must not be hashed */
16365 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16367 + vxi->vx_state |= VXS_HASHED;
16368 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16369 + hlist_add_head(&vxi->vx_hlist, head);
16370 + atomic_inc(&vx_global_cactive);
16373 +/* __unhash_vx_info()
16375 + * remove the vxi from the global hash table
16376 + * requires the hash_lock to be held */
16378 +static inline void __unhash_vx_info(struct vx_info *vxi)
16380 + unsigned long flags;
16382 + vxd_assert_lock(&vx_info_hash_lock);
16383 + vxdprintk(VXD_CBIT(xid, 4),
16384 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16385 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16386 + vxh_unhash_vx_info(vxi);
16388 + /* context must be hashed */
16389 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16390 + /* but without tasks */
16391 + BUG_ON(atomic_read(&vxi->vx_tasks));
16393 + vxi->vx_state &= ~VXS_HASHED;
16394 + hlist_del_init(&vxi->vx_hlist);
16395 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16396 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16397 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16398 + atomic_dec(&vx_global_cactive);
16402 +/* __lookup_vx_info()
16404 + * requires the hash_lock to be held
16405 + * doesn't increment the vx_refcnt */
16407 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16409 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16410 + struct hlist_node *pos;
16411 + struct vx_info *vxi;
16413 + vxd_assert_lock(&vx_info_hash_lock);
16414 + hlist_for_each(pos, head) {
16415 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16417 + if (vxi->vx_id == xid)
16422 + vxdprintk(VXD_CBIT(xid, 0),
16423 + "__lookup_vx_info(#%u): %p[#%u]",
16424 + xid, vxi, vxi ? vxi->vx_id : 0);
16425 + vxh_lookup_vx_info(vxi, xid);
16430 +/* __create_vx_info()
16432 + * create the requested context
16433 + * get(), claim() and hash it */
16435 +static struct vx_info *__create_vx_info(int id)
16437 + struct vx_info *new, *vxi = NULL;
16439 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16441 + if (!(new = __alloc_vx_info(id)))
16442 + return ERR_PTR(-ENOMEM);
16444 + /* required to make dynamic xids unique */
16445 + spin_lock(&vx_info_hash_lock);
16447 + /* static context requested */
16448 + if ((vxi = __lookup_vx_info(id))) {
16449 + vxdprintk(VXD_CBIT(xid, 0),
16450 + "create_vx_info(%d) = %p (already there)", id, vxi);
16451 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16452 + vxi = ERR_PTR(-EBUSY);
16454 + vxi = ERR_PTR(-EEXIST);
16457 + /* new context */
16458 + vxdprintk(VXD_CBIT(xid, 0),
16459 + "create_vx_info(%d) = %p (new)", id, new);
16460 + claim_vx_info(new, NULL);
16461 + __hash_vx_info(get_vx_info(new));
16462 + vxi = new, new = NULL;
16465 + spin_unlock(&vx_info_hash_lock);
16466 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16468 + __dealloc_vx_info(new);
16473 +/* exported stuff */
16476 +void unhash_vx_info(struct vx_info *vxi)
16478 + __shutdown_vx_info(vxi);
16479 + spin_lock(&vx_info_hash_lock);
16480 + __unhash_vx_info(vxi);
16481 + spin_unlock(&vx_info_hash_lock);
16482 + __wakeup_vx_info(vxi);
16486 +/* lookup_vx_info()
16488 + * search for a vx_info and get() it
16489 + * negative id means current */
16491 +struct vx_info *lookup_vx_info(int id)
16493 + struct vx_info *vxi = NULL;
16496 + vxi = get_vx_info(current_vx_info());
16497 + } else if (id > 1) {
16498 + spin_lock(&vx_info_hash_lock);
16499 + vxi = get_vx_info(__lookup_vx_info(id));
16500 + spin_unlock(&vx_info_hash_lock);
16505 +/* xid_is_hashed()
16507 + * verify that xid is still hashed */
16509 +int xid_is_hashed(xid_t xid)
16513 + spin_lock(&vx_info_hash_lock);
16514 + hashed = (__lookup_vx_info(xid) != NULL);
16515 + spin_unlock(&vx_info_hash_lock);
16519 +#ifdef CONFIG_PROC_FS
16523 + * get a subset of hashed xids for proc
16524 + * assumes size is at least one */
16526 +int get_xid_list(int index, unsigned int *xids, int size)
16528 + int hindex, nr_xids = 0;
16530 + /* only show current and children */
16531 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16534 + xids[nr_xids] = vx_current_xid();
16538 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16539 + struct hlist_head *head = &vx_info_hash[hindex];
16540 + struct hlist_node *pos;
16542 + spin_lock(&vx_info_hash_lock);
16543 + hlist_for_each(pos, head) {
16544 + struct vx_info *vxi;
16549 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16550 + xids[nr_xids] = vxi->vx_id;
16551 + if (++nr_xids >= size) {
16552 + spin_unlock(&vx_info_hash_lock);
16556 + /* keep the lock time short */
16557 + spin_unlock(&vx_info_hash_lock);
16564 +#ifdef CONFIG_VSERVER_DEBUG
16566 +void dump_vx_info_inactive(int level)
16568 + struct hlist_node *entry, *next;
16570 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16571 + struct vx_info *vxi =
16572 + list_entry(entry, struct vx_info, vx_hlist);
16574 + dump_vx_info(vxi, level);
16581 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16583 + struct user_struct *new_user, *old_user;
16588 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16591 + new_user = alloc_uid(vxi->vx_id, p->uid);
16595 + old_user = p->user;
16596 + if (new_user != old_user) {
16597 + atomic_inc(&new_user->processes);
16598 + atomic_dec(&old_user->processes);
16599 + p->user = new_user;
16601 + free_uid(old_user);
16607 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16609 + // p->cap_effective &= vxi->vx_cap_bset;
16610 + p->cap_effective =
16611 + cap_intersect(p->cap_effective, vxi->cap_bset);
16612 + // p->cap_inheritable &= vxi->vx_cap_bset;
16613 + p->cap_inheritable =
16614 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16615 + // p->cap_permitted &= vxi->vx_cap_bset;
16616 + p->cap_permitted =
16617 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16622 +#include <linux/file.h>
16623 +#include <linux/fdtable.h>
16625 +static int vx_openfd_task(struct task_struct *tsk)
16627 + struct files_struct *files = tsk->files;
16628 + struct fdtable *fdt;
16629 + const unsigned long *bptr;
16630 + int count, total;
16632 + /* no rcu_read_lock() because of spin_lock() */
16633 + spin_lock(&files->file_lock);
16634 + fdt = files_fdtable(files);
16635 + bptr = fdt->open_fds->fds_bits;
16636 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16637 + for (total = 0; count > 0; count--) {
16639 + total += hweight_long(*bptr);
16642 + spin_unlock(&files->file_lock);
16647 +/* for *space compatibility */
16649 +asmlinkage long sys_unshare(unsigned long);
16652 + * migrate task to new context
16653 + * gets vxi, puts old_vxi on change
16654 + * optionally unshares namespaces (hack)
16657 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16659 + struct vx_info *old_vxi;
16665 + vxdprintk(VXD_CBIT(xid, 5),
16666 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16667 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16669 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16670 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16673 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16676 + old_vxi = task_get_vx_info(p);
16677 + if (old_vxi == vxi)
16680 +// if (!(ret = vx_migrate_user(p, vxi))) {
16685 + openfd = vx_openfd_task(p);
16688 + atomic_dec(&old_vxi->cvirt.nr_threads);
16689 + atomic_dec(&old_vxi->cvirt.nr_running);
16690 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16691 + /* FIXME: what about the struct files here? */
16692 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16693 + /* account for the executable */
16694 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16696 + atomic_inc(&vxi->cvirt.nr_threads);
16697 + atomic_inc(&vxi->cvirt.nr_running);
16698 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16699 + /* FIXME: what about the struct files here? */
16700 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16701 + /* account for the executable */
16702 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16705 + release_vx_info(old_vxi, p);
16706 + clr_vx_info(&p->vx_info);
16708 + claim_vx_info(vxi, p);
16709 + set_vx_info(&p->vx_info, vxi);
16710 + p->xid = vxi->vx_id;
16712 + vxdprintk(VXD_CBIT(xid, 5),
16713 + "moved task %p into vxi:%p[#%d]",
16714 + p, vxi, vxi->vx_id);
16716 + // vx_mask_cap_bset(vxi, p);
16719 + /* hack for *spaces to provide compatibility */
16721 + struct nsproxy *old_nsp, *new_nsp;
16723 + ret = unshare_nsproxy_namespaces(
16724 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16729 + old_nsp = xchg(&p->nsproxy, new_nsp);
16730 + vx_set_space(vxi,
16731 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16732 + put_nsproxy(old_nsp);
16736 + put_vx_info(old_vxi);
16740 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16742 + struct task_struct *old_reaper;
16747 + vxdprintk(VXD_CBIT(xid, 6),
16748 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16749 + vxi, vxi->vx_id, p, p->xid, p->pid);
16751 + old_reaper = vxi->vx_reaper;
16752 + if (old_reaper == p)
16755 + /* set new child reaper */
16756 + get_task_struct(p);
16757 + vxi->vx_reaper = p;
16758 + put_task_struct(old_reaper);
16762 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16767 + vxdprintk(VXD_CBIT(xid, 6),
16768 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16769 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16771 + vxi->vx_flags &= ~VXF_STATE_INIT;
16772 + // vxi->vx_initpid = p->tgid;
16773 + vxi->vx_initpid = p->pid;
16777 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16779 + vxdprintk(VXD_CBIT(xid, 6),
16780 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16781 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16783 + vxi->exit_code = code;
16784 + vxi->vx_initpid = 0;
16788 +void vx_set_persistent(struct vx_info *vxi)
16790 + vxdprintk(VXD_CBIT(xid, 6),
16791 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16793 + get_vx_info(vxi);
16794 + claim_vx_info(vxi, NULL);
16797 +void vx_clear_persistent(struct vx_info *vxi)
16799 + vxdprintk(VXD_CBIT(xid, 6),
16800 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16802 + release_vx_info(vxi, NULL);
16803 + put_vx_info(vxi);
16806 +void vx_update_persistent(struct vx_info *vxi)
16808 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16809 + vx_set_persistent(vxi);
16811 + vx_clear_persistent(vxi);
16815 +/* task must be current or locked */
16817 +void exit_vx_info(struct task_struct *p, int code)
16819 + struct vx_info *vxi = p->vx_info;
16822 + atomic_dec(&vxi->cvirt.nr_threads);
16825 + vxi->exit_code = code;
16826 + release_vx_info(vxi, p);
16830 +void exit_vx_info_early(struct task_struct *p, int code)
16832 + struct vx_info *vxi = p->vx_info;
16835 + if (vxi->vx_initpid == p->pid)
16836 + vx_exit_init(vxi, p, code);
16837 + if (vxi->vx_reaper == p)
16838 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16843 +/* vserver syscall commands below here */
16845 +/* taks xid and vx_info functions */
16847 +#include <asm/uaccess.h>
16850 +int vc_task_xid(uint32_t id)
16855 + struct task_struct *tsk;
16857 + read_lock(&tasklist_lock);
16858 + tsk = find_task_by_real_pid(id);
16859 + xid = (tsk) ? tsk->xid : -ESRCH;
16860 + read_unlock(&tasklist_lock);
16862 + xid = vx_current_xid();
16867 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16869 + struct vcmd_vx_info_v0 vc_data;
16871 + vc_data.xid = vxi->vx_id;
16872 + vc_data.initpid = vxi->vx_initpid;
16874 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16880 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16882 + struct vcmd_ctx_stat_v0 vc_data;
16884 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16885 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16887 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16893 +/* context functions */
16895 +int vc_ctx_create(uint32_t xid, void __user *data)
16897 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16898 + struct vx_info *new_vxi;
16901 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16904 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16907 + new_vxi = __create_vx_info(xid);
16908 + if (IS_ERR(new_vxi))
16909 + return PTR_ERR(new_vxi);
16911 + /* initial flags */
16912 + new_vxi->vx_flags = vc_data.flagword;
16915 + if (vs_state_change(new_vxi, VSC_STARTUP))
16918 + ret = vx_migrate_task(current, new_vxi, (!data));
16922 + /* return context id on success */
16923 + ret = new_vxi->vx_id;
16925 + /* get a reference for persistent contexts */
16926 + if ((vc_data.flagword & VXF_PERSISTENT))
16927 + vx_set_persistent(new_vxi);
16929 + release_vx_info(new_vxi, NULL);
16930 + put_vx_info(new_vxi);
16935 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16937 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16940 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16943 + ret = vx_migrate_task(current, vxi, 0);
16946 + if (vc_data.flagword & VXM_SET_INIT)
16947 + ret = vx_set_init(vxi, current);
16950 + if (vc_data.flagword & VXM_SET_REAPER)
16951 + ret = vx_set_reaper(vxi, current);
16956 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16958 + struct vcmd_ctx_flags_v0 vc_data;
16960 + vc_data.flagword = vxi->vx_flags;
16962 + /* special STATE flag handling */
16963 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16965 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16970 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16972 + struct vcmd_ctx_flags_v0 vc_data;
16973 + uint64_t mask, trigger;
16975 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16978 + /* special STATE flag handling */
16979 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16980 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16982 + if (vxi == current_vx_info()) {
16983 + /* if (trigger & VXF_STATE_SETUP)
16984 + vx_mask_cap_bset(vxi, current); */
16985 + if (trigger & VXF_STATE_INIT) {
16988 + ret = vx_set_init(vxi, current);
16991 + ret = vx_set_reaper(vxi, current);
16997 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16998 + vc_data.flagword, mask);
16999 + if (trigger & VXF_PERSISTENT)
17000 + vx_update_persistent(vxi);
17006 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17008 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17010 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17014 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17016 + kernel_cap_t c = __cap_empty_set;
17018 + c.cap[0] = v & 0xFFFFFFFF;
17019 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17021 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17026 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17029 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17031 + *ccaps = vxi->vx_ccaps;
17036 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17038 + struct vcmd_ctx_caps_v1 vc_data;
17041 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17044 + vc_data.cmask = ~0ULL;
17046 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17051 +static int do_set_caps(struct vx_info *vxi,
17052 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17054 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17057 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17058 + bcaps, bmask, ccaps, cmask);
17060 + vxi->vx_bcaps = cap_t_from_caps(
17061 + vs_mask_flags(bcold, bcaps, bmask));
17062 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17067 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17069 + struct vcmd_ctx_caps_v1 vc_data;
17071 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17074 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17077 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17079 + struct vcmd_bcaps vc_data;
17082 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17085 + vc_data.bmask = ~0ULL;
17087 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17092 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17094 + struct vcmd_bcaps vc_data;
17096 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17099 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17103 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17105 + struct vcmd_umask vc_data;
17107 + vc_data.umask = vxi->vx_umask;
17108 + vc_data.mask = ~0ULL;
17110 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17115 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17117 + struct vcmd_umask vc_data;
17119 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17122 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17123 + vc_data.umask, vc_data.mask);
17128 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17130 + struct vcmd_badness_v0 vc_data;
17132 + vc_data.bias = vxi->vx_badness_bias;
17134 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17139 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17141 + struct vcmd_badness_v0 vc_data;
17143 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17146 + vxi->vx_badness_bias = vc_data.bias;
17150 +#include <linux/module.h>
17152 +EXPORT_SYMBOL_GPL(free_vx_info);
17154 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cvirt.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cvirt.c
17155 --- linux-2.6.37/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17156 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cvirt.c 2011-01-08 03:33:34.000000000 +0100
17159 + * linux/kernel/vserver/cvirt.c
17161 + * Virtual Server: Context Virtualization
17163 + * Copyright (C) 2004-2007 Herbert Pötzl
17165 + * V0.01 broken out from limit.c
17166 + * V0.02 added utsname stuff
17167 + * V0.03 changed vcmds to vxi arg
17171 +#include <linux/types.h>
17172 +#include <linux/utsname.h>
17173 +#include <linux/vs_cvirt.h>
17174 +#include <linux/vserver/switch.h>
17175 +#include <linux/vserver/cvirt_cmd.h>
17177 +#include <asm/uaccess.h>
17180 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17182 + struct vx_info *vxi = current_vx_info();
17184 + set_normalized_timespec(uptime,
17185 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17186 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17189 + set_normalized_timespec(idle,
17190 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17191 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17195 +uint64_t vx_idle_jiffies(void)
17197 + return init_task.utime + init_task.stime;
17202 +static inline uint32_t __update_loadavg(uint32_t load,
17203 + int wsize, int delta, int n)
17205 + unsigned long long calc, prev;
17207 + /* just set it to n */
17208 + if (unlikely(delta >= wsize))
17209 + return (n << FSHIFT);
17211 + calc = delta * n;
17213 + prev = (wsize - delta);
17216 + do_div(calc, wsize);
17221 +void vx_update_load(struct vx_info *vxi)
17223 + uint32_t now, last, delta;
17224 + unsigned int nr_running, nr_uninterruptible;
17225 + unsigned int total;
17226 + unsigned long flags;
17228 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17231 + last = vxi->cvirt.load_last;
17232 + delta = now - last;
17234 + if (delta < 5*HZ)
17237 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17238 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17239 + total = nr_running + nr_uninterruptible;
17241 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17242 + 60*HZ, delta, total);
17243 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17244 + 5*60*HZ, delta, total);
17245 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17246 + 15*60*HZ, delta, total);
17248 + vxi->cvirt.load_last = now;
17250 + atomic_inc(&vxi->cvirt.load_updates);
17251 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17256 + * Commands to do_syslog:
17258 + * 0 -- Close the log. Currently a NOP.
17259 + * 1 -- Open the log. Currently a NOP.
17260 + * 2 -- Read from the log.
17261 + * 3 -- Read all messages remaining in the ring buffer.
17262 + * 4 -- Read and clear all messages remaining in the ring buffer
17263 + * 5 -- Clear ring buffer.
17264 + * 6 -- Disable printk's to console
17265 + * 7 -- Enable printk's to console
17266 + * 8 -- Set level of messages printed to console
17267 + * 9 -- Return number of unread characters in the log buffer
17268 + * 10 -- Return size of the log buffer
17270 +int vx_do_syslog(int type, char __user *buf, int len)
17273 + int do_clear = 0;
17274 + struct vx_info *vxi = current_vx_info();
17275 + struct _vx_syslog *log;
17279 + log = &vxi->cvirt.syslog;
17282 + case 0: /* Close log */
17283 + case 1: /* Open log */
17285 + case 2: /* Read from log */
17286 + error = wait_event_interruptible(log->log_wait,
17287 + (log->log_start - log->log_end));
17290 + spin_lock_irq(&log->logbuf_lock);
17291 + spin_unlock_irq(&log->logbuf_lock);
17293 + case 4: /* Read/clear last kernel messages */
17295 + /* fall through */
17296 + case 3: /* Read last kernel messages */
17299 + case 5: /* Clear ring buffer */
17302 + case 6: /* Disable logging to console */
17303 + case 7: /* Enable logging to console */
17304 + case 8: /* Set level of messages printed to console */
17307 + case 9: /* Number of chars in the log buffer */
17309 + case 10: /* Size of the log buffer */
17319 +/* virtual host info names */
17321 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17323 + struct nsproxy *nsproxy;
17324 + struct uts_namespace *uts;
17326 + if (id == VHIN_CONTEXT)
17327 + return vxi->vx_name;
17329 + nsproxy = vxi->space[0].vx_nsproxy;
17333 + uts = nsproxy->uts_ns;
17338 + case VHIN_SYSNAME:
17339 + return uts->name.sysname;
17340 + case VHIN_NODENAME:
17341 + return uts->name.nodename;
17342 + case VHIN_RELEASE:
17343 + return uts->name.release;
17344 + case VHIN_VERSION:
17345 + return uts->name.version;
17346 + case VHIN_MACHINE:
17347 + return uts->name.machine;
17348 + case VHIN_DOMAINNAME:
17349 + return uts->name.domainname;
17356 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17358 + struct vcmd_vhi_name_v0 vc_data;
17361 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17364 + name = vx_vhi_name(vxi, vc_data.field);
17368 + memcpy(name, vc_data.name, 65);
17372 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17374 + struct vcmd_vhi_name_v0 vc_data;
17377 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17380 + name = vx_vhi_name(vxi, vc_data.field);
17384 + memcpy(vc_data.name, name, 65);
17385 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17391 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17393 + struct vcmd_virt_stat_v0 vc_data;
17394 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17395 + struct timespec uptime;
17397 + do_posix_clock_monotonic_gettime(&uptime);
17398 + set_normalized_timespec(&uptime,
17399 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17400 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17402 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17403 + vc_data.uptime = timespec_to_ns(&uptime);
17404 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17405 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17406 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17407 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17408 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17409 + vc_data.load[0] = cvirt->load[0];
17410 + vc_data.load[1] = cvirt->load[1];
17411 + vc_data.load[2] = cvirt->load[2];
17413 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17419 +#ifdef CONFIG_VSERVER_VTIME
17421 +/* virtualized time base */
17423 +void vx_adjust_timespec(struct timespec *ts)
17425 + struct vx_info *vxi;
17427 + if (!vx_flags(VXF_VIRT_TIME, 0))
17430 + vxi = current_vx_info();
17431 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17432 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17434 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17436 + ts->tv_nsec -= NSEC_PER_SEC;
17437 + } else if (ts->tv_nsec < 0) {
17439 + ts->tv_nsec += NSEC_PER_SEC;
17443 +int vx_settimeofday(struct timespec *ts)
17445 + struct timespec ats, delta;
17446 + struct vx_info *vxi;
17448 + if (!vx_flags(VXF_VIRT_TIME, 0))
17449 + return do_settimeofday(ts);
17451 + getnstimeofday(&ats);
17452 + delta = timespec_sub(*ts, ats);
17454 + vxi = current_vx_info();
17455 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17461 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cvirt_init.h linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cvirt_init.h
17462 --- linux-2.6.37/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17463 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cvirt_init.h 2010-11-23 02:09:41.000000000 +0100
17467 +extern uint64_t vx_idle_jiffies(void);
17469 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17471 + uint64_t idle_jiffies = vx_idle_jiffies();
17472 + uint64_t nsuptime;
17474 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17475 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17476 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17477 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17478 + cvirt->bias_ts.tv_sec = 0;
17479 + cvirt->bias_ts.tv_nsec = 0;
17481 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17482 + atomic_set(&cvirt->nr_threads, 0);
17483 + atomic_set(&cvirt->nr_running, 0);
17484 + atomic_set(&cvirt->nr_uninterruptible, 0);
17485 + atomic_set(&cvirt->nr_onhold, 0);
17487 + spin_lock_init(&cvirt->load_lock);
17488 + cvirt->load_last = jiffies;
17489 + atomic_set(&cvirt->load_updates, 0);
17490 + cvirt->load[0] = 0;
17491 + cvirt->load[1] = 0;
17492 + cvirt->load[2] = 0;
17493 + atomic_set(&cvirt->total_forks, 0);
17495 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17496 + init_waitqueue_head(&cvirt->syslog.log_wait);
17497 + cvirt->syslog.log_start = 0;
17498 + cvirt->syslog.log_end = 0;
17499 + cvirt->syslog.con_start = 0;
17500 + cvirt->syslog.logged_chars = 0;
17504 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17506 + // cvirt_pc->cpustat = { 0 };
17509 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17513 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17514 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17516 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17517 + "!!! cvirt: %p[nr_running] = %d on exit.",
17519 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17520 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17522 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17523 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17529 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17534 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cvirt_proc.h linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cvirt_proc.h
17535 --- linux-2.6.37/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17536 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/cvirt_proc.h 2010-11-23 02:09:41.000000000 +0100
17538 +#ifndef _VX_CVIRT_PROC_H
17539 +#define _VX_CVIRT_PROC_H
17541 +#include <linux/nsproxy.h>
17542 +#include <linux/mnt_namespace.h>
17543 +#include <linux/ipc_namespace.h>
17544 +#include <linux/utsname.h>
17545 +#include <linux/ipc.h>
17549 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17551 + struct mnt_namespace *ns;
17552 + struct uts_namespace *uts;
17553 + struct ipc_namespace *ipc;
17554 + struct path path;
17555 + char *pstr, *root;
17561 + length += sprintf(buffer + length,
17562 + "NSProxy:\t%p [%p,%p,%p]\n",
17563 + nsproxy, nsproxy->mnt_ns,
17564 + nsproxy->uts_ns, nsproxy->ipc_ns);
17566 + ns = nsproxy->mnt_ns;
17570 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17574 + path.mnt = ns->root;
17575 + path.dentry = ns->root->mnt_root;
17576 + root = d_path(&path, pstr, PATH_MAX - 2);
17577 + length += sprintf(buffer + length,
17578 + "Namespace:\t%p [#%u]\n"
17579 + "RootPath:\t%s\n",
17580 + ns, atomic_read(&ns->count),
17585 + uts = nsproxy->uts_ns;
17589 + length += sprintf(buffer + length,
17590 + "SysName:\t%.*s\n"
17591 + "NodeName:\t%.*s\n"
17592 + "Release:\t%.*s\n"
17593 + "Version:\t%.*s\n"
17594 + "Machine:\t%.*s\n"
17595 + "DomainName:\t%.*s\n",
17596 + __NEW_UTS_LEN, uts->name.sysname,
17597 + __NEW_UTS_LEN, uts->name.nodename,
17598 + __NEW_UTS_LEN, uts->name.release,
17599 + __NEW_UTS_LEN, uts->name.version,
17600 + __NEW_UTS_LEN, uts->name.machine,
17601 + __NEW_UTS_LEN, uts->name.domainname);
17604 + ipc = nsproxy->ipc_ns;
17608 + length += sprintf(buffer + length,
17609 + "SEMS:\t\t%d %d %d %d %d\n"
17610 + "MSG:\t\t%d %d %d\n"
17611 + "SHM:\t\t%lu %lu %d %d\n",
17612 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17613 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17615 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17616 + (unsigned long)ipc->shm_ctlmax,
17617 + (unsigned long)ipc->shm_ctlall,
17618 + ipc->shm_ctlmni, ipc->shm_tot);
17625 +#include <linux/sched.h>
17627 +#define LOAD_INT(x) ((x) >> FSHIFT)
17628 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17631 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17636 + length += sprintf(buffer + length,
17637 + "BiasUptime:\t%lu.%02lu\n",
17638 + (unsigned long)cvirt->bias_uptime.tv_sec,
17639 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17641 + a = cvirt->load[0] + (FIXED_1 / 200);
17642 + b = cvirt->load[1] + (FIXED_1 / 200);
17643 + c = cvirt->load[2] + (FIXED_1 / 200);
17644 + length += sprintf(buffer + length,
17645 + "nr_threads:\t%d\n"
17646 + "nr_running:\t%d\n"
17647 + "nr_unintr:\t%d\n"
17648 + "nr_onhold:\t%d\n"
17649 + "load_updates:\t%d\n"
17650 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17651 + "total_forks:\t%d\n",
17652 + atomic_read(&cvirt->nr_threads),
17653 + atomic_read(&cvirt->nr_running),
17654 + atomic_read(&cvirt->nr_uninterruptible),
17655 + atomic_read(&cvirt->nr_onhold),
17656 + atomic_read(&cvirt->load_updates),
17657 + LOAD_INT(a), LOAD_FRAC(a),
17658 + LOAD_INT(b), LOAD_FRAC(b),
17659 + LOAD_INT(c), LOAD_FRAC(c),
17660 + atomic_read(&cvirt->total_forks));
17665 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17666 + char *buffer, int cpu)
17672 +#endif /* _VX_CVIRT_PROC_H */
17673 diff -NurpP --minimal linux-2.6.37/kernel/vserver/debug.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/debug.c
17674 --- linux-2.6.37/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17675 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/debug.c 2010-11-23 02:09:41.000000000 +0100
17678 + * kernel/vserver/debug.c
17680 + * Copyright (C) 2005-2007 Herbert Pötzl
17682 + * V0.01 vx_info dump support
17686 +#include <linux/module.h>
17688 +#include <linux/vserver/context.h>
17691 +void dump_vx_info(struct vx_info *vxi, int level)
17693 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17694 + atomic_read(&vxi->vx_usecnt),
17695 + atomic_read(&vxi->vx_tasks),
17698 + __dump_vx_limit(&vxi->limit);
17699 + __dump_vx_sched(&vxi->sched);
17700 + __dump_vx_cvirt(&vxi->cvirt);
17701 + __dump_vx_cacct(&vxi->cacct);
17707 +EXPORT_SYMBOL_GPL(dump_vx_info);
17709 diff -NurpP --minimal linux-2.6.37/kernel/vserver/device.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/device.c
17710 --- linux-2.6.37/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17711 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/device.c 2010-11-23 02:09:41.000000000 +0100
17714 + * linux/kernel/vserver/device.c
17716 + * Linux-VServer: Device Support
17718 + * Copyright (C) 2006 Herbert Pötzl
17719 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17721 + * V0.01 device mapping basics
17722 + * V0.02 added defaults
17726 +#include <linux/slab.h>
17727 +#include <linux/rcupdate.h>
17728 +#include <linux/fs.h>
17729 +#include <linux/namei.h>
17730 +#include <linux/hash.h>
17732 +#include <asm/errno.h>
17733 +#include <asm/uaccess.h>
17734 +#include <linux/vserver/base.h>
17735 +#include <linux/vserver/debug.h>
17736 +#include <linux/vserver/context.h>
17737 +#include <linux/vserver/device.h>
17738 +#include <linux/vserver/device_cmd.h>
17741 +#define DMAP_HASH_BITS 4
17744 +struct vs_mapping {
17746 + struct hlist_node hlist;
17747 + struct list_head list;
17749 +#define dm_hlist u.hlist
17750 +#define dm_list u.list
17753 + struct vx_dmap_target target;
17757 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17759 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
17761 +static struct vx_dmap_target dmap_defaults[2] = {
17762 + { .flags = DATTR_OPEN },
17763 + { .flags = DATTR_OPEN },
17767 +struct kmem_cache *dmap_cachep __read_mostly;
17769 +int __init dmap_cache_init(void)
17771 + dmap_cachep = kmem_cache_create("dmap_cache",
17772 + sizeof(struct vs_mapping), 0,
17773 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17777 +__initcall(dmap_cache_init);
17780 +static inline unsigned int __hashval(dev_t dev, int bits)
17782 + return hash_long((unsigned long)dev, bits);
17786 +/* __hash_mapping()
17787 + * add the mapping to the hash table
17789 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17791 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17792 + struct hlist_head *head, *hash = dmap_main_hash;
17793 + int device = vdm->device;
17795 + spin_lock(hash_lock);
17796 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17797 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17799 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17800 + hlist_add_head(&vdm->dm_hlist, head);
17801 + spin_unlock(hash_lock);
17805 +static inline int __mode_to_default(umode_t mode)
17818 +/* __set_default()
17821 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17822 + struct vx_dmap_target *vdmt)
17824 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17825 + spin_lock(hash_lock);
17828 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17830 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17833 + spin_unlock(hash_lock);
17835 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17836 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17840 +/* __remove_default()
17841 + * remove a default
17843 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17845 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17846 + spin_lock(hash_lock);
17849 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17850 + else /* remove == reset */
17851 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17853 + spin_unlock(hash_lock);
17858 +/* __find_mapping()
17859 + * find a mapping in the hash table
17861 + * caller must hold hash_lock
17863 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17864 + struct vs_mapping **local, struct vs_mapping **global)
17866 + struct hlist_head *hash = dmap_main_hash;
17867 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17868 + struct hlist_node *pos;
17869 + struct vs_mapping *vdm;
17875 + hlist_for_each(pos, head) {
17876 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17878 + if ((vdm->device == device) &&
17879 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17880 + if (vdm->xid == xid) {
17883 + } else if (global && vdm->xid == 0)
17888 + if (global && *global)
17895 +/* __lookup_mapping()
17896 + * find a mapping and store the result in target and flags
17898 +static inline int __lookup_mapping(struct vx_info *vxi,
17899 + dev_t device, dev_t *target, int *flags, umode_t mode)
17901 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17902 + struct vs_mapping *vdm, *global;
17903 + struct vx_dmap_target *vdmt;
17905 + xid_t xid = vxi->vx_id;
17908 + spin_lock(hash_lock);
17909 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17911 + vdmt = &vdm->target;
17915 + index = __mode_to_default(mode);
17916 + if (vxi && vxi->dmap.targets[index].flags) {
17918 + vdmt = &vxi->dmap.targets[index];
17919 + } else if (global) {
17921 + vdmt = &global->target;
17925 + vdmt = &dmap_defaults[index];
17929 + if (target && (vdmt->flags & DATTR_REMAP))
17930 + *target = vdmt->target;
17932 + *target = device;
17934 + *flags = vdmt->flags;
17936 + spin_unlock(hash_lock);
17942 +/* __remove_mapping()
17943 + * remove a mapping from the hash table
17945 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17948 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17949 + struct vs_mapping *vdm = NULL;
17952 + spin_lock(hash_lock);
17954 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17956 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17957 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17960 + hlist_del(&vdm->dm_hlist);
17963 + spin_unlock(hash_lock);
17965 + kmem_cache_free(dmap_cachep, vdm);
17971 +int vs_map_device(struct vx_info *vxi,
17972 + dev_t device, dev_t *target, umode_t mode)
17974 + int ret, flags = DATTR_MASK;
17978 + *target = device;
17981 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17982 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17983 + device, target ? *target : 0, flags, mode, ret);
17985 + return (flags & DATTR_MASK);
17990 +static int do_set_mapping(struct vx_info *vxi,
17991 + dev_t device, dev_t target, int flags, umode_t mode)
17994 + struct vs_mapping *new;
17996 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18000 + INIT_HLIST_NODE(&new->dm_hlist);
18001 + new->device = device;
18002 + new->target.target = target;
18003 + new->target.flags = flags | mode;
18004 + new->xid = (vxi ? vxi->vx_id : 0);
18006 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18007 + __hash_mapping(vxi, new);
18009 + struct vx_dmap_target new = {
18010 + .target = target,
18011 + .flags = flags | mode,
18013 + __set_default(vxi, mode, &new);
18019 +static int do_unset_mapping(struct vx_info *vxi,
18020 + dev_t device, dev_t target, int flags, umode_t mode)
18022 + int ret = -EINVAL;
18025 + ret = __remove_mapping(vxi, device, mode);
18029 + ret = __remove_default(vxi, mode);
18039 +static inline int __user_device(const char __user *name, dev_t *dev,
18042 + struct nameidata nd;
18049 + ret = user_lpath(name, &nd.path);
18052 + if (nd.path.dentry->d_inode) {
18053 + *dev = nd.path.dentry->d_inode->i_rdev;
18054 + *mode = nd.path.dentry->d_inode->i_mode;
18056 + path_put(&nd.path);
18060 +static inline int __mapping_mode(dev_t device, dev_t target,
18061 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18064 + *mode = device_mode & S_IFMT;
18066 + *mode = target_mode & S_IFMT;
18070 + /* if both given, device and target mode have to match */
18071 + if (device && target &&
18072 + ((device_mode ^ target_mode) & S_IFMT))
18078 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18079 + const char __user *target_path, int flags, int set)
18081 + dev_t device = ~0, target = ~0;
18082 + umode_t device_mode = 0, target_mode = 0, mode;
18085 + ret = __user_device(device_path, &device, &device_mode);
18088 + ret = __user_device(target_path, &target, &target_mode);
18092 + ret = __mapping_mode(device, target,
18093 + device_mode, target_mode, &mode);
18098 + return do_set_mapping(vxi, device, target,
18101 + return do_unset_mapping(vxi, device, target,
18106 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18108 + struct vcmd_set_mapping_v0 vc_data;
18110 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18113 + return do_mapping(vxi, vc_data.device, vc_data.target,
18114 + vc_data.flags, 1);
18117 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18119 + struct vcmd_set_mapping_v0 vc_data;
18121 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18124 + return do_mapping(vxi, vc_data.device, vc_data.target,
18125 + vc_data.flags, 0);
18129 +#ifdef CONFIG_COMPAT
18131 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18133 + struct vcmd_set_mapping_v0_x32 vc_data;
18135 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18138 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18139 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18142 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18144 + struct vcmd_set_mapping_v0_x32 vc_data;
18146 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18149 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18150 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18153 +#endif /* CONFIG_COMPAT */
18156 diff -NurpP --minimal linux-2.6.37/kernel/vserver/dlimit.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/dlimit.c
18157 --- linux-2.6.37/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18158 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/dlimit.c 2011-01-05 23:26:15.000000000 +0100
18161 + * linux/kernel/vserver/dlimit.c
18163 + * Virtual Server: Context Disk Limits
18165 + * Copyright (C) 2004-2009 Herbert Pötzl
18167 + * V0.01 initial version
18168 + * V0.02 compat32 splitup
18169 + * V0.03 extended interface
18173 +#include <linux/statfs.h>
18174 +#include <linux/sched.h>
18175 +#include <linux/namei.h>
18176 +#include <linux/vs_tag.h>
18177 +#include <linux/vs_dlimit.h>
18178 +#include <linux/vserver/dlimit_cmd.h>
18179 +#include <linux/slab.h>
18180 +// #include <linux/gfp.h>
18182 +#include <asm/uaccess.h>
18184 +/* __alloc_dl_info()
18186 + * allocate an initialized dl_info struct
18187 + * doesn't make it visible (hash) */
18189 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18191 + struct dl_info *new = NULL;
18193 + vxdprintk(VXD_CBIT(dlim, 5),
18194 + "alloc_dl_info(%p,%d)*", sb, tag);
18196 + /* would this benefit from a slab cache? */
18197 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18201 + memset(new, 0, sizeof(struct dl_info));
18202 + new->dl_tag = tag;
18204 + // INIT_RCU_HEAD(&new->dl_rcu);
18205 + INIT_HLIST_NODE(&new->dl_hlist);
18206 + spin_lock_init(&new->dl_lock);
18207 + atomic_set(&new->dl_refcnt, 0);
18208 + atomic_set(&new->dl_usecnt, 0);
18210 + /* rest of init goes here */
18212 + vxdprintk(VXD_CBIT(dlim, 4),
18213 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18217 +/* __dealloc_dl_info()
18219 + * final disposal of dl_info */
18221 +static void __dealloc_dl_info(struct dl_info *dli)
18223 + vxdprintk(VXD_CBIT(dlim, 4),
18224 + "dealloc_dl_info(%p)", dli);
18226 + dli->dl_hlist.next = LIST_POISON1;
18227 + dli->dl_tag = -1;
18230 + BUG_ON(atomic_read(&dli->dl_usecnt));
18231 + BUG_ON(atomic_read(&dli->dl_refcnt));
18237 +/* hash table for dl_info hash */
18239 +#define DL_HASH_SIZE 13
18241 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18243 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
18246 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18248 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18253 +/* __hash_dl_info()
18255 + * add the dli to the global hash table
18256 + * requires the hash_lock to be held */
18258 +static inline void __hash_dl_info(struct dl_info *dli)
18260 + struct hlist_head *head;
18262 + vxdprintk(VXD_CBIT(dlim, 6),
18263 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18264 + get_dl_info(dli);
18265 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18266 + hlist_add_head_rcu(&dli->dl_hlist, head);
18269 +/* __unhash_dl_info()
18271 + * remove the dli from the global hash table
18272 + * requires the hash_lock to be held */
18274 +static inline void __unhash_dl_info(struct dl_info *dli)
18276 + vxdprintk(VXD_CBIT(dlim, 6),
18277 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18278 + hlist_del_rcu(&dli->dl_hlist);
18279 + put_dl_info(dli);
18283 +/* __lookup_dl_info()
18285 + * requires the rcu_read_lock()
18286 + * doesn't increment the dl_refcnt */
18288 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18290 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18291 + struct hlist_node *pos;
18292 + struct dl_info *dli;
18294 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18296 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18304 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18306 + struct dl_info *dli;
18309 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18310 + vxdprintk(VXD_CBIT(dlim, 7),
18311 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18312 + rcu_read_unlock();
18316 +void rcu_free_dl_info(struct rcu_head *head)
18318 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18319 + int usecnt, refcnt;
18321 + BUG_ON(!dli || !head);
18323 + usecnt = atomic_read(&dli->dl_usecnt);
18324 + BUG_ON(usecnt < 0);
18326 + refcnt = atomic_read(&dli->dl_refcnt);
18327 + BUG_ON(refcnt < 0);
18329 + vxdprintk(VXD_CBIT(dlim, 3),
18330 + "rcu_free_dl_info(%p)", dli);
18332 + __dealloc_dl_info(dli);
18334 + printk("!!! rcu didn't free\n");
18340 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18341 + uint32_t flags, int add)
18343 + struct path path;
18346 + ret = user_lpath(name, &path);
18348 + struct super_block *sb;
18349 + struct dl_info *dli;
18352 + if (!path.dentry->d_inode)
18353 + goto out_release;
18354 + if (!(sb = path.dentry->d_inode->i_sb))
18355 + goto out_release;
18358 + dli = __alloc_dl_info(sb, id);
18359 + spin_lock(&dl_info_hash_lock);
18362 + if (__lookup_dl_info(sb, id))
18364 + __hash_dl_info(dli);
18367 + spin_lock(&dl_info_hash_lock);
18368 + dli = __lookup_dl_info(sb, id);
18373 + __unhash_dl_info(dli);
18377 + spin_unlock(&dl_info_hash_lock);
18379 + __dealloc_dl_info(dli);
18386 +int vc_add_dlimit(uint32_t id, void __user *data)
18388 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18390 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18393 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18396 +int vc_rem_dlimit(uint32_t id, void __user *data)
18398 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18400 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18403 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18406 +#ifdef CONFIG_COMPAT
18408 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18410 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18412 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18415 + return do_addrem_dlimit(id,
18416 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18419 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18421 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18423 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18426 + return do_addrem_dlimit(id,
18427 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18430 +#endif /* CONFIG_COMPAT */
18434 +int do_set_dlimit(uint32_t id, const char __user *name,
18435 + uint32_t space_used, uint32_t space_total,
18436 + uint32_t inodes_used, uint32_t inodes_total,
18437 + uint32_t reserved, uint32_t flags)
18439 + struct path path;
18442 + ret = user_lpath(name, &path);
18444 + struct super_block *sb;
18445 + struct dl_info *dli;
18448 + if (!path.dentry->d_inode)
18449 + goto out_release;
18450 + if (!(sb = path.dentry->d_inode->i_sb))
18451 + goto out_release;
18453 + /* sanity checks */
18454 + if ((reserved != CDLIM_KEEP &&
18455 + reserved > 100) ||
18456 + (inodes_used != CDLIM_KEEP &&
18457 + inodes_used > inodes_total) ||
18458 + (space_used != CDLIM_KEEP &&
18459 + space_used > space_total))
18460 + goto out_release;
18463 + dli = locate_dl_info(sb, id);
18465 + goto out_release;
18467 + spin_lock(&dli->dl_lock);
18469 + if (inodes_used != CDLIM_KEEP)
18470 + dli->dl_inodes_used = inodes_used;
18471 + if (inodes_total != CDLIM_KEEP)
18472 + dli->dl_inodes_total = inodes_total;
18473 + if (space_used != CDLIM_KEEP)
18474 + dli->dl_space_used = dlimit_space_32to64(
18475 + space_used, flags, DLIMS_USED);
18477 + if (space_total == CDLIM_INFINITY)
18478 + dli->dl_space_total = DLIM_INFINITY;
18479 + else if (space_total != CDLIM_KEEP)
18480 + dli->dl_space_total = dlimit_space_32to64(
18481 + space_total, flags, DLIMS_TOTAL);
18483 + if (reserved != CDLIM_KEEP)
18484 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18486 + spin_unlock(&dli->dl_lock);
18488 + put_dl_info(dli);
18497 +int vc_set_dlimit(uint32_t id, void __user *data)
18499 + struct vcmd_ctx_dlimit_v0 vc_data;
18501 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18504 + return do_set_dlimit(id, vc_data.name,
18505 + vc_data.space_used, vc_data.space_total,
18506 + vc_data.inodes_used, vc_data.inodes_total,
18507 + vc_data.reserved, vc_data.flags);
18510 +#ifdef CONFIG_COMPAT
18512 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18514 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18516 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18519 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18520 + vc_data.space_used, vc_data.space_total,
18521 + vc_data.inodes_used, vc_data.inodes_total,
18522 + vc_data.reserved, vc_data.flags);
18525 +#endif /* CONFIG_COMPAT */
18529 +int do_get_dlimit(uint32_t id, const char __user *name,
18530 + uint32_t *space_used, uint32_t *space_total,
18531 + uint32_t *inodes_used, uint32_t *inodes_total,
18532 + uint32_t *reserved, uint32_t *flags)
18534 + struct path path;
18537 + ret = user_lpath(name, &path);
18539 + struct super_block *sb;
18540 + struct dl_info *dli;
18543 + if (!path.dentry->d_inode)
18544 + goto out_release;
18545 + if (!(sb = path.dentry->d_inode->i_sb))
18546 + goto out_release;
18549 + dli = locate_dl_info(sb, id);
18551 + goto out_release;
18553 + spin_lock(&dli->dl_lock);
18554 + *inodes_used = dli->dl_inodes_used;
18555 + *inodes_total = dli->dl_inodes_total;
18557 + *space_used = dlimit_space_64to32(
18558 + dli->dl_space_used, flags, DLIMS_USED);
18560 + if (dli->dl_space_total == DLIM_INFINITY)
18561 + *space_total = CDLIM_INFINITY;
18563 + *space_total = dlimit_space_64to32(
18564 + dli->dl_space_total, flags, DLIMS_TOTAL);
18566 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18567 + spin_unlock(&dli->dl_lock);
18569 + put_dl_info(dli);
18580 +int vc_get_dlimit(uint32_t id, void __user *data)
18582 + struct vcmd_ctx_dlimit_v0 vc_data;
18585 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18588 + ret = do_get_dlimit(id, vc_data.name,
18589 + &vc_data.space_used, &vc_data.space_total,
18590 + &vc_data.inodes_used, &vc_data.inodes_total,
18591 + &vc_data.reserved, &vc_data.flags);
18595 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18600 +#ifdef CONFIG_COMPAT
18602 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18604 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18607 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18610 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18611 + &vc_data.space_used, &vc_data.space_total,
18612 + &vc_data.inodes_used, &vc_data.inodes_total,
18613 + &vc_data.reserved, &vc_data.flags);
18617 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18622 +#endif /* CONFIG_COMPAT */
18625 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18627 + struct dl_info *dli;
18628 + __u64 blimit, bfree, bavail;
18631 + dli = locate_dl_info(sb, dx_current_tag());
18635 + spin_lock(&dli->dl_lock);
18636 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18639 + /* reduce max inodes available to limit */
18640 + if (buf->f_files > dli->dl_inodes_total)
18641 + buf->f_files = dli->dl_inodes_total;
18643 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18644 + /* reduce free inodes to min */
18645 + if (ifree < buf->f_ffree)
18646 + buf->f_ffree = ifree;
18649 + if (dli->dl_space_total == DLIM_INFINITY)
18652 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18654 + if (dli->dl_space_total < dli->dl_space_used)
18657 + bfree = (dli->dl_space_total - dli->dl_space_used)
18658 + >> sb->s_blocksize_bits;
18660 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18661 + if (bavail < dli->dl_space_used)
18664 + bavail = (bavail - dli->dl_space_used)
18665 + >> sb->s_blocksize_bits;
18667 + /* reduce max space available to limit */
18668 + if (buf->f_blocks > blimit)
18669 + buf->f_blocks = blimit;
18671 + /* reduce free space to min */
18672 + if (bfree < buf->f_bfree)
18673 + buf->f_bfree = bfree;
18675 + /* reduce avail space to min */
18676 + if (bavail < buf->f_bavail)
18677 + buf->f_bavail = bavail;
18680 + spin_unlock(&dli->dl_lock);
18681 + put_dl_info(dli);
18686 +#include <linux/module.h>
18688 +EXPORT_SYMBOL_GPL(locate_dl_info);
18689 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18691 diff -NurpP --minimal linux-2.6.37/kernel/vserver/helper.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/helper.c
18692 --- linux-2.6.37/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18693 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/helper.c 2010-11-23 02:09:41.000000000 +0100
18696 + * linux/kernel/vserver/helper.c
18698 + * Virtual Context Support
18700 + * Copyright (C) 2004-2007 Herbert Pötzl
18702 + * V0.01 basic helper
18706 +#include <linux/kmod.h>
18707 +#include <linux/reboot.h>
18708 +#include <linux/vs_context.h>
18709 +#include <linux/vs_network.h>
18710 +#include <linux/vserver/signal.h>
18713 +char vshelper_path[255] = "/sbin/vshelper";
18716 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18720 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18721 + printk( KERN_WARNING
18722 + "%s: (%s %s) returned %s with %d\n",
18723 + name, argv[1], argv[2],
18724 + sync ? "sync" : "async", ret);
18726 + vxdprintk(VXD_CBIT(switch, 4),
18727 + "%s: (%s %s) returned %s with %d",
18728 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18733 + * vshelper path is set via /proc/sys
18734 + * invoked by vserver sys_reboot(), with
18735 + * the following arguments
18737 + * argv [0] = vshelper_path;
18738 + * argv [1] = action: "restart", "halt", "poweroff", ...
18739 + * argv [2] = context identifier
18741 + * envp [*] = type-specific parameters
18744 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18746 + char id_buf[8], cmd_buf[16];
18747 + char uid_buf[16], pid_buf[16];
18750 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18751 + char *envp[] = {"HOME=/", "TERM=linux",
18752 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18753 + uid_buf, pid_buf, cmd_buf, 0};
18755 + if (vx_info_state(vxi, VXS_HELPER))
18757 + vxi->vx_state |= VXS_HELPER;
18759 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18761 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18762 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18763 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18766 + case LINUX_REBOOT_CMD_RESTART:
18767 + argv[1] = "restart";
18770 + case LINUX_REBOOT_CMD_HALT:
18771 + argv[1] = "halt";
18774 + case LINUX_REBOOT_CMD_POWER_OFF:
18775 + argv[1] = "poweroff";
18778 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18779 + argv[1] = "swsusp";
18782 + case LINUX_REBOOT_CMD_OOM:
18787 + vxi->vx_state &= ~VXS_HELPER;
18791 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18792 + vxi->vx_state &= ~VXS_HELPER;
18793 + __wakeup_vx_info(vxi);
18794 + return (ret) ? -EPERM : 0;
18798 +long vs_reboot(unsigned int cmd, void __user *arg)
18800 + struct vx_info *vxi = current_vx_info();
18803 + vxdprintk(VXD_CBIT(misc, 5),
18804 + "vs_reboot(%p[#%d],%u)",
18805 + vxi, vxi ? vxi->vx_id : 0, cmd);
18807 + ret = vs_reboot_helper(vxi, cmd, arg);
18811 + vxi->reboot_cmd = cmd;
18812 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18814 + case LINUX_REBOOT_CMD_RESTART:
18815 + case LINUX_REBOOT_CMD_HALT:
18816 + case LINUX_REBOOT_CMD_POWER_OFF:
18817 + vx_info_kill(vxi, 0, SIGKILL);
18818 + vx_info_kill(vxi, 1, SIGKILL);
18826 +long vs_oom_action(unsigned int cmd)
18828 + struct vx_info *vxi = current_vx_info();
18831 + vxdprintk(VXD_CBIT(misc, 5),
18832 + "vs_oom_action(%p[#%d],%u)",
18833 + vxi, vxi ? vxi->vx_id : 0, cmd);
18835 + ret = vs_reboot_helper(vxi, cmd, NULL);
18839 + vxi->reboot_cmd = cmd;
18840 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18841 + vx_info_kill(vxi, 0, SIGKILL);
18842 + vx_info_kill(vxi, 1, SIGKILL);
18848 + * argv [0] = vshelper_path;
18849 + * argv [1] = action: "startup", "shutdown"
18850 + * argv [2] = context identifier
18852 + * envp [*] = type-specific parameters
18855 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18857 + char id_buf[8], cmd_buf[16];
18858 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18859 + char *envp[] = {"HOME=/", "TERM=linux",
18860 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18862 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18865 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18866 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18869 + case VSC_STARTUP:
18870 + argv[1] = "startup";
18872 + case VSC_SHUTDOWN:
18873 + argv[1] = "shutdown";
18879 + return do_vshelper(vshelper_path, argv, envp, 1);
18884 + * argv [0] = vshelper_path;
18885 + * argv [1] = action: "netup", "netdown"
18886 + * argv [2] = context identifier
18888 + * envp [*] = type-specific parameters
18891 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18893 + char id_buf[8], cmd_buf[16];
18894 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18895 + char *envp[] = {"HOME=/", "TERM=linux",
18896 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18898 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18901 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
18902 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18906 + argv[1] = "netup";
18908 + case VSC_NETDOWN:
18909 + argv[1] = "netdown";
18915 + return do_vshelper(vshelper_path, argv, envp, 1);
18918 diff -NurpP --minimal linux-2.6.37/kernel/vserver/history.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/history.c
18919 --- linux-2.6.37/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
18920 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/history.c 2010-11-23 02:09:41.000000000 +0100
18923 + * kernel/vserver/history.c
18925 + * Virtual Context History Backtrace
18927 + * Copyright (C) 2004-2007 Herbert Pötzl
18929 + * V0.01 basic structure
18930 + * V0.02 hash/unhash and trace
18931 + * V0.03 preemption fixes
18935 +#include <linux/module.h>
18936 +#include <asm/uaccess.h>
18938 +#include <linux/vserver/context.h>
18939 +#include <linux/vserver/debug.h>
18940 +#include <linux/vserver/debug_cmd.h>
18941 +#include <linux/vserver/history.h>
18944 +#ifdef CONFIG_VSERVER_HISTORY
18945 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18947 +#define VXH_SIZE 64
18950 +struct _vx_history {
18951 + unsigned int counter;
18953 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18957 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18959 +unsigned volatile int vxh_active = 1;
18961 +static atomic_t sequence = ATOMIC_INIT(0);
18966 + * requires disabled preemption */
18968 +struct _vx_hist_entry *vxh_advance(void *loc)
18970 + unsigned int cpu = smp_processor_id();
18971 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18972 + struct _vx_hist_entry *entry;
18973 + unsigned int index;
18975 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18976 + entry = &hist->entry[index];
18978 + entry->seq = atomic_inc_return(&sequence);
18979 + entry->loc = loc;
18983 +EXPORT_SYMBOL_GPL(vxh_advance);
18986 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18988 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18991 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18993 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18994 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18995 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18996 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18998 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19000 + switch (e->type) {
19001 + case VXH_THROW_OOPS:
19002 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19005 + case VXH_GET_VX_INFO:
19006 + case VXH_PUT_VX_INFO:
19007 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19009 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19010 + VXH_VXI_ARGS(e));
19013 + case VXH_INIT_VX_INFO:
19014 + case VXH_SET_VX_INFO:
19015 + case VXH_CLR_VX_INFO:
19016 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19018 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19019 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19020 + VXH_VXI_ARGS(e), e->sc.data);
19023 + case VXH_CLAIM_VX_INFO:
19024 + case VXH_RELEASE_VX_INFO:
19025 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19027 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19028 + VXH_VXI_ARGS(e), e->sc.data);
19031 + case VXH_ALLOC_VX_INFO:
19032 + case VXH_DEALLOC_VX_INFO:
19033 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19035 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19036 + VXH_VXI_ARGS(e));
19039 + case VXH_HASH_VX_INFO:
19040 + case VXH_UNHASH_VX_INFO:
19041 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19043 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19044 + VXH_VXI_ARGS(e));
19047 + case VXH_LOC_VX_INFO:
19048 + case VXH_LOOKUP_VX_INFO:
19049 + case VXH_CREATE_VX_INFO:
19050 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19052 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19053 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19054 + e->ll.arg, VXH_VXI_ARGS(e));
19059 +static void __vxh_dump_history(void)
19061 + unsigned int i, cpu;
19063 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19064 + atomic_read(&sequence), NR_CPUS);
19066 + for (i = 0; i < VXH_SIZE; i++) {
19067 + for_each_online_cpu(cpu) {
19068 + struct _vx_history *hist =
19069 + &per_cpu(vx_history_buffer, cpu);
19070 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19071 + struct _vx_hist_entry *entry = &hist->entry[index];
19073 + vxh_dump_entry(entry, cpu);
19078 +void vxh_dump_history(void)
19082 + local_irq_enable();
19084 + local_irq_disable();
19086 + __vxh_dump_history();
19090 +/* vserver syscall commands below here */
19093 +int vc_dump_history(uint32_t id)
19096 + __vxh_dump_history();
19103 +int do_read_history(struct __user _vx_hist_entry *data,
19104 + int cpu, uint32_t *index, uint32_t *count)
19106 + int pos, ret = 0;
19107 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19108 + int end = hist->counter;
19109 + int start = end - VXH_SIZE + 2;
19110 + int idx = *index;
19112 + /* special case: get current pos */
19118 + /* have we lost some data? */
19122 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19123 + struct _vx_hist_entry *entry =
19124 + &hist->entry[idx % VXH_SIZE];
19126 + /* send entry to userspace */
19127 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19131 + /* save new index and count */
19134 + return ret ? ret : (*index < end);
19137 +int vc_read_history(uint32_t id, void __user *data)
19139 + struct vcmd_read_history_v0 vc_data;
19142 + if (id >= NR_CPUS)
19145 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19148 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19149 + id, &vc_data.index, &vc_data.count);
19151 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19156 +#ifdef CONFIG_COMPAT
19158 +int vc_read_history_x32(uint32_t id, void __user *data)
19160 + struct vcmd_read_history_v0_x32 vc_data;
19163 + if (id >= NR_CPUS)
19166 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19169 + ret = do_read_history((struct __user _vx_hist_entry *)
19170 + compat_ptr(vc_data.data_ptr),
19171 + id, &vc_data.index, &vc_data.count);
19173 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19178 +#endif /* CONFIG_COMPAT */
19180 diff -NurpP --minimal linux-2.6.37/kernel/vserver/inet.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/inet.c
19181 --- linux-2.6.37/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19182 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/inet.c 2010-11-23 02:09:41.000000000 +0100
19185 +#include <linux/in.h>
19186 +#include <linux/inetdevice.h>
19187 +#include <linux/vs_inet.h>
19188 +#include <linux/vs_inet6.h>
19189 +#include <linux/vserver/debug.h>
19190 +#include <net/route.h>
19191 +#include <net/addrconf.h>
19194 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19198 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19201 + struct nx_addr_v4 *ptr;
19203 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19204 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19211 + vxdprintk(VXD_CBIT(net, 2),
19212 + "nx_v4_addr_conflict(%p,%p): %d",
19213 + nxi1, nxi2, ret);
19219 +#ifdef CONFIG_IPV6
19221 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19225 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19228 + struct nx_addr_v6 *ptr;
19230 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19231 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19238 + vxdprintk(VXD_CBIT(net, 2),
19239 + "nx_v6_addr_conflict(%p,%p): %d",
19240 + nxi1, nxi2, ret);
19247 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19249 + struct in_device *in_dev;
19250 + struct in_ifaddr **ifap;
19251 + struct in_ifaddr *ifa;
19256 + in_dev = in_dev_get(dev);
19260 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19261 + ifap = &ifa->ifa_next) {
19262 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19267 + in_dev_put(in_dev);
19273 +#ifdef CONFIG_IPV6
19275 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19277 + struct inet6_dev *in_dev;
19278 + struct inet6_ifaddr *ifa;
19283 + in_dev = in6_dev_get(dev);
19287 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19288 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19289 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19294 + in6_dev_put(in_dev);
19301 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19307 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19309 +#ifdef CONFIG_IPV6
19311 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19316 + vxdprintk(VXD_CBIT(net, 3),
19317 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19318 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19322 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
19323 + struct rtable **rp, struct flowi *fl)
19328 + /* FIXME: handle lback only case */
19329 + if (!NX_IPV4(nxi))
19332 + vxdprintk(VXD_CBIT(net, 4),
19333 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19334 + nxi, nxi ? nxi->nx_id : 0,
19335 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
19337 + /* single IP is unconditional */
19338 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19339 + (fl->fl4_src == INADDR_ANY))
19340 + fl->fl4_src = nxi->v4.ip[0].s_addr;
19342 + if (fl->fl4_src == INADDR_ANY) {
19343 + struct nx_addr_v4 *ptr;
19344 + __be32 found = 0;
19347 + err = __ip_route_output_key(net, rp, fl);
19349 + found = (*rp)->rt_src;
19351 + vxdprintk(VXD_CBIT(net, 4),
19352 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19353 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
19354 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19358 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19359 + __be32 primary = ptr->ip[0].s_addr;
19360 + __be32 mask = ptr->mask.s_addr;
19361 + __be32 neta = primary & mask;
19363 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19364 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19365 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19366 + NIPQUAD(mask), NIPQUAD(neta));
19367 + if ((found & mask) != neta)
19370 + fl->fl4_src = primary;
19371 + err = __ip_route_output_key(net, rp, fl);
19372 + vxdprintk(VXD_CBIT(net, 4),
19373 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19374 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
19376 + found = (*rp)->rt_src;
19378 + if (found == primary)
19382 + /* still no source ip? */
19383 + found = ipv4_is_loopback(fl->fl4_dst)
19384 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19386 + /* assign src ip to flow */
19387 + fl->fl4_src = found;
19390 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
19394 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19395 + if (ipv4_is_loopback(fl->fl4_dst))
19396 + fl->fl4_dst = nxi->v4_lback.s_addr;
19397 + if (ipv4_is_loopback(fl->fl4_src))
19398 + fl->fl4_src = nxi->v4_lback.s_addr;
19399 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
19400 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19406 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19408 diff -NurpP --minimal linux-2.6.37/kernel/vserver/init.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/init.c
19409 --- linux-2.6.37/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19410 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/init.c 2010-11-23 02:09:41.000000000 +0100
19413 + * linux/kernel/init.c
19415 + * Virtual Server Init
19417 + * Copyright (C) 2004-2007 Herbert Pötzl
19419 + * V0.01 basic structure
19423 +#include <linux/init.h>
19425 +int vserver_register_sysctl(void);
19426 +void vserver_unregister_sysctl(void);
19429 +static int __init init_vserver(void)
19433 +#ifdef CONFIG_VSERVER_DEBUG
19434 + vserver_register_sysctl();
19440 +static void __exit exit_vserver(void)
19443 +#ifdef CONFIG_VSERVER_DEBUG
19444 + vserver_unregister_sysctl();
19449 +/* FIXME: GFP_ZONETYPES gone
19450 +long vx_slab[GFP_ZONETYPES]; */
19454 +module_init(init_vserver);
19455 +module_exit(exit_vserver);
19457 diff -NurpP --minimal linux-2.6.37/kernel/vserver/inode.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/inode.c
19458 --- linux-2.6.37/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19459 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/inode.c 2010-11-23 02:09:41.000000000 +0100
19462 + * linux/kernel/vserver/inode.c
19464 + * Virtual Server: File System Support
19466 + * Copyright (C) 2004-2007 Herbert Pötzl
19468 + * V0.01 separated from vcontext V0.05
19469 + * V0.02 moved to tag (instead of xid)
19473 +#include <linux/tty.h>
19474 +#include <linux/proc_fs.h>
19475 +#include <linux/devpts_fs.h>
19476 +#include <linux/fs.h>
19477 +#include <linux/file.h>
19478 +#include <linux/mount.h>
19479 +#include <linux/parser.h>
19480 +#include <linux/namei.h>
19481 +#include <linux/vserver/inode.h>
19482 +#include <linux/vserver/inode_cmd.h>
19483 +#include <linux/vs_base.h>
19484 +#include <linux/vs_tag.h>
19486 +#include <asm/uaccess.h>
19489 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19491 + struct proc_dir_entry *entry;
19493 + if (!in || !in->i_sb)
19496 + *flags = IATTR_TAG
19497 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19498 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19499 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19500 + | (IS_COW(in) ? IATTR_COW : 0);
19501 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19503 + if (S_ISDIR(in->i_mode))
19504 + *mask |= IATTR_BARRIER;
19506 + if (IS_TAGGED(in)) {
19507 + *tag = in->i_tag;
19508 + *mask |= IATTR_TAG;
19511 + switch (in->i_sb->s_magic) {
19512 + case PROC_SUPER_MAGIC:
19513 + entry = PROC_I(in)->pde;
19515 + /* check for specific inodes? */
19517 + *mask |= IATTR_FLAGS;
19519 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19521 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19524 + case DEVPTS_SUPER_MAGIC:
19525 + *tag = in->i_tag;
19526 + *mask |= IATTR_TAG;
19535 +int vc_get_iattr(void __user *data)
19537 + struct path path;
19538 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19541 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19544 + ret = user_lpath(vc_data.name, &path);
19546 + ret = __vc_get_iattr(path.dentry->d_inode,
19547 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19553 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19558 +#ifdef CONFIG_COMPAT
19560 +int vc_get_iattr_x32(void __user *data)
19562 + struct path path;
19563 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19566 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19569 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19571 + ret = __vc_get_iattr(path.dentry->d_inode,
19572 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19578 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19583 +#endif /* CONFIG_COMPAT */
19586 +int vc_fget_iattr(uint32_t fd, void __user *data)
19588 + struct file *filp;
19589 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19592 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19596 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19599 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19600 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19604 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19610 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19612 + struct inode *in = de->d_inode;
19613 + int error = 0, is_proc = 0, has_tag = 0;
19614 + struct iattr attr = { 0 };
19616 + if (!in || !in->i_sb)
19619 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19620 + if ((*mask & IATTR_FLAGS) && !is_proc)
19623 + has_tag = IS_TAGGED(in) ||
19624 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19625 + if ((*mask & IATTR_TAG) && !has_tag)
19628 + mutex_lock(&in->i_mutex);
19629 + if (*mask & IATTR_TAG) {
19630 + attr.ia_tag = *tag;
19631 + attr.ia_valid |= ATTR_TAG;
19634 + if (*mask & IATTR_FLAGS) {
19635 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19636 + unsigned int iflags = PROC_I(in)->vx_flags;
19638 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19639 + | (*flags & IATTR_FLAGS);
19640 + PROC_I(in)->vx_flags = iflags;
19642 + entry->vx_flags = iflags;
19645 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19646 + IATTR_BARRIER | IATTR_COW)) {
19647 + int iflags = in->i_flags;
19648 + int vflags = in->i_vflags;
19650 + if (*mask & IATTR_IMMUTABLE) {
19651 + if (*flags & IATTR_IMMUTABLE)
19652 + iflags |= S_IMMUTABLE;
19654 + iflags &= ~S_IMMUTABLE;
19656 + if (*mask & IATTR_IXUNLINK) {
19657 + if (*flags & IATTR_IXUNLINK)
19658 + iflags |= S_IXUNLINK;
19660 + iflags &= ~S_IXUNLINK;
19662 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19663 + if (*flags & IATTR_BARRIER)
19664 + vflags |= V_BARRIER;
19666 + vflags &= ~V_BARRIER;
19668 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19669 + if (*flags & IATTR_COW)
19672 + vflags &= ~V_COW;
19674 + if (in->i_op && in->i_op->sync_flags) {
19675 + error = in->i_op->sync_flags(in, iflags, vflags);
19681 + if (attr.ia_valid) {
19682 + if (in->i_op && in->i_op->setattr)
19683 + error = in->i_op->setattr(de, &attr);
19685 + error = inode_change_ok(in, &attr);
19687 + setattr_copy(in, &attr);
19688 + mark_inode_dirty(in);
19694 + mutex_unlock(&in->i_mutex);
19698 +int vc_set_iattr(void __user *data)
19700 + struct path path;
19701 + struct vcmd_ctx_iattr_v1 vc_data;
19704 + if (!capable(CAP_LINUX_IMMUTABLE))
19706 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19709 + ret = user_lpath(vc_data.name, &path);
19711 + ret = __vc_set_iattr(path.dentry,
19712 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19716 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19721 +#ifdef CONFIG_COMPAT
19723 +int vc_set_iattr_x32(void __user *data)
19725 + struct path path;
19726 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19729 + if (!capable(CAP_LINUX_IMMUTABLE))
19731 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19734 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19736 + ret = __vc_set_iattr(path.dentry,
19737 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19741 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19746 +#endif /* CONFIG_COMPAT */
19748 +int vc_fset_iattr(uint32_t fd, void __user *data)
19750 + struct file *filp;
19751 + struct vcmd_ctx_fiattr_v0 vc_data;
19754 + if (!capable(CAP_LINUX_IMMUTABLE))
19756 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19760 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19763 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19764 + &vc_data.flags, &vc_data.mask);
19768 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19774 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19776 +static match_table_t tokens = {
19777 + {Opt_notagcheck, "notagcheck"},
19778 +#ifdef CONFIG_PROPAGATE
19779 + {Opt_notag, "notag"},
19780 + {Opt_tag, "tag"},
19781 + {Opt_tagid, "tagid=%u"},
19787 +static void __dx_parse_remove(char *string, char *opt)
19789 + char *p = strstr(string, opt);
19793 + while (*q != '\0' && *q != ',')
19802 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19803 + unsigned long *flags)
19806 + substring_t args[MAX_OPT_ARGS];
19807 + int token, option = 0;
19808 + char *s, *p, *opts;
19812 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19817 + while ((p = strsep(&opts, ",")) != NULL) {
19818 + token = match_token(p, tokens, args);
19820 + vxdprintk(VXD_CBIT(tag, 7),
19821 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19822 + p, token, option);
19825 +#ifdef CONFIG_PROPAGATE
19830 + __dx_parse_remove(s, "tag");
19831 + *mnt_flags |= MNT_TAGID;
19832 + set |= MNT_TAGID;
19836 + __dx_parse_remove(s, "notag");
19837 + *mnt_flags |= MNT_NOTAG;
19838 + set |= MNT_NOTAG;
19841 + if (tag && !match_int(args, &option))
19844 + __dx_parse_remove(s, "tagid");
19845 + *mnt_flags |= MNT_TAGID;
19846 + set |= MNT_TAGID;
19849 + case Opt_notagcheck:
19851 + __dx_parse_remove(s, "notagcheck");
19852 + *flags |= MS_NOTAGCHECK;
19853 + set |= MS_NOTAGCHECK;
19858 + strcpy(string, s);
19863 +#ifdef CONFIG_PROPAGATE
19865 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19867 + tag_t new_tag = 0;
19868 + struct vfsmount *mnt;
19873 + mnt = nd->path.mnt;
19877 + propagate = (mnt->mnt_flags & MNT_TAGID);
19879 + new_tag = mnt->mnt_tag;
19881 + vxdprintk(VXD_CBIT(tag, 7),
19882 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19883 + inode, inode->i_ino, inode->i_tag,
19884 + new_tag, (propagate) ? 1 : 0);
19887 + inode->i_tag = new_tag;
19890 +#include <linux/module.h>
19892 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19894 +#endif /* CONFIG_PROPAGATE */
19896 diff -NurpP --minimal linux-2.6.37/kernel/vserver/Kconfig linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/Kconfig
19897 --- linux-2.6.37/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
19898 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/Kconfig 2010-11-23 02:09:41.000000000 +0100
19901 +# Linux VServer configuration
19904 +menu "Linux VServer"
19906 +config VSERVER_AUTO_LBACK
19907 + bool "Automatically Assign Loopback IP"
19910 + Automatically assign a guest specific loopback
19911 + IP and add it to the kernel network stack on
19914 +config VSERVER_AUTO_SINGLE
19915 + bool "Automatic Single IP Special Casing"
19916 + depends on EXPERIMENTAL
19919 + This allows network contexts with a single IP to
19920 + automatically remap 0.0.0.0 bindings to that IP,
19921 + avoiding further network checks and improving
19924 + (note: such guests do not allow to change the ip
19925 + on the fly and do not show loopback addresses)
19927 +config VSERVER_COWBL
19928 + bool "Enable COW Immutable Link Breaking"
19931 + This enables the COW (Copy-On-Write) link break code.
19932 + It allows you to treat unified files like normal files
19933 + when writing to them (which will implicitely break the
19934 + link and create a copy of the unified file)
19936 +config VSERVER_VTIME
19937 + bool "Enable Virtualized Guest Time"
19938 + depends on EXPERIMENTAL
19941 + This enables per guest time offsets to allow for
19942 + adjusting the system clock individually per guest.
19943 + this adds some overhead to the time functions and
19944 + therefore should not be enabled without good reason.
19946 +config VSERVER_DEVICE
19947 + bool "Enable Guest Device Mapping"
19948 + depends on EXPERIMENTAL
19951 + This enables generic device remapping.
19953 +config VSERVER_PROC_SECURE
19954 + bool "Enable Proc Security"
19955 + depends on PROC_FS
19958 + This configures ProcFS security to initially hide
19959 + non-process entries for all contexts except the main and
19960 + spectator context (i.e. for all guests), which is a secure
19963 + (note: on 1.2x the entries were visible by default)
19965 +config VSERVER_HARDCPU
19966 + bool "Enable Hard CPU Limits"
19969 + Activate the Hard CPU Limits
19971 + This will compile in code that allows the Token Bucket
19972 + Scheduler to put processes on hold when a context's
19973 + tokens are depleted (provided that its per-context
19974 + sched_hard flag is set).
19976 + Processes belonging to that context will not be able
19977 + to consume CPU resources again until a per-context
19978 + configured minimum of tokens has been reached.
19980 +config VSERVER_IDLETIME
19981 + bool "Avoid idle CPUs by skipping Time"
19982 + depends on VSERVER_HARDCPU
19985 + This option allows the scheduler to artificially
19986 + advance time (per cpu) when otherwise the idle
19987 + task would be scheduled, thus keeping the cpu
19988 + busy and sharing the available resources among
19989 + certain contexts.
19991 +config VSERVER_IDLELIMIT
19992 + bool "Limit the IDLE task"
19993 + depends on VSERVER_HARDCPU
19996 + Limit the idle slices, so the the next context
19997 + will be scheduled as soon as possible.
19999 + This might improve interactivity and latency, but
20000 + will also marginally increase scheduling overhead.
20003 + prompt "Persistent Inode Tagging"
20004 + default TAGGING_ID24
20006 + This adds persistent context information to filesystems
20007 + mounted with the tagxid option. Tagging is a requirement
20008 + for per-context disk limits and per-context quota.
20011 +config TAGGING_NONE
20014 + do not store per-context information in inodes.
20016 +config TAGGING_UID16
20017 + bool "UID16/GID32"
20019 + reduces UID to 16 bit, but leaves GID at 32 bit.
20021 +config TAGGING_GID16
20022 + bool "UID32/GID16"
20024 + reduces GID to 16 bit, but leaves UID at 32 bit.
20026 +config TAGGING_ID24
20027 + bool "UID24/GID24"
20029 + uses the upper 8bit from UID and GID for XID tagging
20030 + which leaves 24bit for UID/GID each, which should be
20031 + more than sufficient for normal use.
20033 +config TAGGING_INTERN
20034 + bool "UID32/GID32"
20036 + this uses otherwise reserved inode fields in the on
20037 + disk representation, which limits the use to a few
20038 + filesystems (currently ext2 and ext3)
20043 + bool "Tag NFSD User Auth and Files"
20046 + Enable this if you do want the in-kernel NFS
20047 + Server to use the tagging specified above.
20048 + (will require patched clients too)
20050 +config VSERVER_PRIVACY
20051 + bool "Honor Privacy Aspects of Guests"
20054 + When enabled, most context checks will disallow
20055 + access to structures assigned to a specific context,
20056 + like ptys or loop devices.
20058 +config VSERVER_CONTEXTS
20059 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
20061 + default "768" if 64BIT
20064 + This setting will optimize certain data structures
20065 + and memory allocations according to the expected
20068 + note: this is not a strict upper limit.
20070 +config VSERVER_WARN
20071 + bool "VServer Warnings"
20074 + This enables various runtime warnings, which will
20075 + notify about potential manipulation attempts or
20076 + resource shortage. It is generally considered to
20077 + be a good idea to have that enabled.
20079 +config VSERVER_WARN_DEVPTS
20080 + bool "VServer DevPTS Warnings"
20081 + depends on VSERVER_WARN
20084 + This enables DevPTS related warnings, issued when a
20085 + process inside a context tries to lookup or access
20086 + a dynamic pts from the host or a different context.
20088 +config VSERVER_DEBUG
20089 + bool "VServer Debugging Code"
20092 + Set this to yes if you want to be able to activate
20093 + debugging output at runtime. It adds a very small
20094 + overhead to all vserver related functions and
20095 + increases the kernel size by about 20k.
20097 +config VSERVER_HISTORY
20098 + bool "VServer History Tracing"
20099 + depends on VSERVER_DEBUG
20102 + Set this to yes if you want to record the history of
20103 + linux-vserver activities, so they can be replayed in
20104 + the event of a kernel panic or oops.
20106 +config VSERVER_HISTORY_SIZE
20107 + int "Per-CPU History Size (32-65536)"
20108 + depends on VSERVER_HISTORY
20112 + This allows you to specify the number of entries in
20113 + the per-CPU history buffer.
20115 +config VSERVER_LEGACY_MEM
20116 + bool "Legacy Memory Limits"
20119 + This provides fake memory limits to keep
20120 + older tools happy in the face of memory
20124 + prompt "Quotes used in debug and warn messages"
20125 + default QUOTES_ISO8859
20127 +config QUOTES_ISO8859
20128 + bool "Extended ASCII (ISO 8859) angle quotes"
20130 + This uses the extended ASCII characters \xbb
20131 + and \xab for quoting file and process names.
20133 +config QUOTES_UTF8
20134 + bool "UTF-8 angle quotes"
20136 + This uses the the UTF-8 sequences for angle
20137 + quotes to quote file and process names.
20139 +config QUOTES_ASCII
20140 + bool "ASCII single quotes"
20142 + This uses the ASCII single quote character
20143 + (\x27) to quote file and process names.
20153 + select NAMESPACES
20159 +config VSERVER_SECURITY
20161 + depends on SECURITY
20163 + select SECURITY_CAPABILITIES
20165 diff -NurpP --minimal linux-2.6.37/kernel/vserver/limit.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/limit.c
20166 --- linux-2.6.37/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
20167 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/limit.c 2010-11-23 02:09:41.000000000 +0100
20170 + * linux/kernel/vserver/limit.c
20172 + * Virtual Server: Context Limits
20174 + * Copyright (C) 2004-2010 Herbert Pötzl
20176 + * V0.01 broken out from vcontext V0.05
20177 + * V0.02 changed vcmds to vxi arg
20178 + * V0.03 added memory cgroup support
20182 +#include <linux/sched.h>
20183 +#include <linux/module.h>
20184 +#include <linux/memcontrol.h>
20185 +#include <linux/res_counter.h>
20186 +#include <linux/vs_limit.h>
20187 +#include <linux/vserver/limit.h>
20188 +#include <linux/vserver/limit_cmd.h>
20190 +#include <asm/uaccess.h>
20193 +const char *vlimit_name[NUM_LIMITS] = {
20194 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20195 + [RLIMIT_RSS] = "RSS",
20196 + [RLIMIT_AS] = "VM",
20197 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20198 + [RLIMIT_CPU] = "CPU",
20199 + [RLIMIT_NPROC] = "NPROC",
20200 + [RLIMIT_NOFILE] = "NOFILE",
20201 + [RLIMIT_LOCKS] = "LOCKS",
20202 + [RLIMIT_SIGPENDING] = "SIGP",
20203 + [RLIMIT_MSGQUEUE] = "MSGQ",
20205 + [VLIMIT_NSOCK] = "NSOCK",
20206 + [VLIMIT_OPENFD] = "OPENFD",
20207 + [VLIMIT_SHMEM] = "SHMEM",
20208 + [VLIMIT_DENTRY] = "DENTRY",
20211 +EXPORT_SYMBOL_GPL(vlimit_name);
20213 +#define MASK_ENTRY(x) (1 << (x))
20215 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20218 + , /* softlimit */
20219 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20220 + MASK_ENTRY( RLIMIT_RSS ) |
20221 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20224 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20225 + MASK_ENTRY( RLIMIT_RSS ) |
20226 + MASK_ENTRY( RLIMIT_AS ) |
20227 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20228 + MASK_ENTRY( RLIMIT_NPROC ) |
20229 + MASK_ENTRY( RLIMIT_NOFILE ) |
20230 + MASK_ENTRY( RLIMIT_LOCKS ) |
20231 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20233 + MASK_ENTRY( VLIMIT_NSOCK ) |
20234 + MASK_ENTRY( VLIMIT_OPENFD ) |
20235 + MASK_ENTRY( VLIMIT_SHMEM ) |
20236 + MASK_ENTRY( VLIMIT_DENTRY ) |
20239 + /* accounting only */
20240 +uint32_t account_mask =
20241 + MASK_ENTRY( VLIMIT_SEMARY ) |
20242 + MASK_ENTRY( VLIMIT_NSEMS ) |
20243 + MASK_ENTRY( VLIMIT_MAPPED ) |
20247 +static int is_valid_vlimit(int id)
20249 + uint32_t mask = vlimit_mask.minimum |
20250 + vlimit_mask.softlimit | vlimit_mask.maximum;
20251 + return mask & (1 << id);
20254 +static int is_accounted_vlimit(int id)
20256 + if (is_valid_vlimit(id))
20258 + return account_mask & (1 << id);
20262 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20264 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20265 + return VX_VLIM(limit);
20268 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20270 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20271 + return VX_VLIM(limit);
20274 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20275 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20277 + if (!is_valid_vlimit(id))
20281 + *minimum = CRLIM_UNSET;
20283 + *softlimit = vc_get_soft(vxi, id);
20285 + *maximum = vc_get_hard(vxi, id);
20289 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20291 + struct vcmd_ctx_rlimit_v0 vc_data;
20294 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20297 + ret = do_get_rlimit(vxi, vc_data.id,
20298 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20302 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20307 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20308 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20310 + if (!is_valid_vlimit(id))
20313 + if (maximum != CRLIM_KEEP)
20314 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20315 + if (softlimit != CRLIM_KEEP)
20316 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20318 + /* clamp soft limit */
20319 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20320 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20325 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20327 + struct vcmd_ctx_rlimit_v0 vc_data;
20329 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20332 + return do_set_rlimit(vxi, vc_data.id,
20333 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20336 +#ifdef CONFIG_IA32_EMULATION
20338 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20340 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20342 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20345 + return do_set_rlimit(vxi, vc_data.id,
20346 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20349 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20351 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20354 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20357 + ret = do_get_rlimit(vxi, vc_data.id,
20358 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20362 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20367 +#endif /* CONFIG_IA32_EMULATION */
20370 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20372 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20378 +static inline void vx_reset_hits(struct _vx_limit *limit)
20382 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20383 + atomic_set(&__rlim_lhit(limit, lim), 0);
20387 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20389 + vx_reset_hits(&vxi->limit);
20393 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20398 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20399 + value = __rlim_get(limit, lim);
20400 + __rlim_rmax(limit, lim) = value;
20401 + __rlim_rmin(limit, lim) = value;
20405 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20407 + vx_reset_minmax(&vxi->limit);
20412 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20414 + struct vcmd_rlimit_stat_v0 vc_data;
20415 + struct _vx_limit *limit = &vxi->limit;
20418 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20422 + if (!is_accounted_vlimit(id))
20425 + vx_limit_fixup(limit, id);
20426 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20427 + vc_data.value = __rlim_get(limit, id);
20428 + vc_data.minimum = __rlim_rmin(limit, id);
20429 + vc_data.maximum = __rlim_rmax(limit, id);
20431 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20437 +void vx_vsi_meminfo(struct sysinfo *val)
20439 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20440 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20441 + u64 res_limit, res_usage;
20446 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20447 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20449 + if (res_limit != RESOURCE_MAX)
20450 + val->totalram = (res_limit >> PAGE_SHIFT);
20451 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20452 + val->bufferram = 0;
20453 + val->totalhigh = 0;
20454 + val->freehigh = 0;
20455 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20459 +void vx_vsi_swapinfo(struct sysinfo *val)
20461 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20462 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20463 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20464 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20465 + s64 swap_limit, swap_usage;
20470 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20471 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20472 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20473 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20475 + if (res_limit == RESOURCE_MAX)
20478 + swap_limit = memsw_limit - res_limit;
20479 + if (memsw_limit != RESOURCE_MAX)
20480 + val->totalswap = swap_limit >> PAGE_SHIFT;
20482 + swap_usage = memsw_usage - res_usage;
20483 + val->freeswap = (swap_usage < swap_limit) ?
20484 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20485 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20486 + val->totalswap = 0;
20487 + val->freeswap = 0;
20488 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20489 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20493 +long vx_vsi_cached(struct sysinfo *val)
20495 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20496 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20498 + return mem_cgroup_stat_read_cache(mcg);
20505 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20507 + struct vx_info *vxi = mm->mm_vx_info;
20508 + unsigned long points;
20514 + points = vxi->vx_badness_bias;
20516 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20517 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20518 + points += (v > w) ? (v - w) : 0;
20523 diff -NurpP --minimal linux-2.6.37/kernel/vserver/limit_init.h linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/limit_init.h
20524 --- linux-2.6.37/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20525 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/limit_init.h 2010-11-23 02:09:41.000000000 +0100
20529 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20533 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20534 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20535 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20536 + __rlim_set(limit, lim, 0);
20537 + atomic_set(&__rlim_lhit(limit, lim), 0);
20538 + __rlim_rmin(limit, lim) = 0;
20539 + __rlim_rmax(limit, lim) = 0;
20543 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20548 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20549 + if ((1 << lim) & VLIM_NOCHECK)
20551 + value = __rlim_get(limit, lim);
20552 + vxwprintk_xid(value,
20553 + "!!! limit: %p[%s,%d] = %ld on exit.",
20554 + limit, vlimit_name[lim], lim, (long)value);
20558 diff -NurpP --minimal linux-2.6.37/kernel/vserver/limit_proc.h linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/limit_proc.h
20559 --- linux-2.6.37/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20560 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/limit_proc.h 2010-11-23 02:09:41.000000000 +0100
20562 +#ifndef _VX_LIMIT_PROC_H
20563 +#define _VX_LIMIT_PROC_H
20565 +#include <linux/vserver/limit_int.h>
20568 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20569 +#define VX_LIMIT_TOP \
20570 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20572 +#define VX_LIMIT_ARG(r) \
20573 + (unsigned long)__rlim_get(limit, r), \
20574 + (unsigned long)__rlim_rmin(limit, r), \
20575 + (unsigned long)__rlim_rmax(limit, r), \
20576 + VX_VLIM(__rlim_soft(limit, r)), \
20577 + VX_VLIM(__rlim_hard(limit, r)), \
20578 + atomic_read(&__rlim_lhit(limit, r))
20580 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20582 + vx_limit_fixup(limit, -1);
20583 + return sprintf(buffer, VX_LIMIT_TOP
20584 + "PROC" VX_LIMIT_FMT
20585 + "VM" VX_LIMIT_FMT
20586 + "VML" VX_LIMIT_FMT
20587 + "RSS" VX_LIMIT_FMT
20588 + "ANON" VX_LIMIT_FMT
20589 + "RMAP" VX_LIMIT_FMT
20590 + "FILES" VX_LIMIT_FMT
20591 + "OFD" VX_LIMIT_FMT
20592 + "LOCKS" VX_LIMIT_FMT
20593 + "SOCK" VX_LIMIT_FMT
20594 + "MSGQ" VX_LIMIT_FMT
20595 + "SHM" VX_LIMIT_FMT
20596 + "SEMA" VX_LIMIT_FMT
20597 + "SEMS" VX_LIMIT_FMT
20598 + "DENT" VX_LIMIT_FMT,
20599 + VX_LIMIT_ARG(RLIMIT_NPROC),
20600 + VX_LIMIT_ARG(RLIMIT_AS),
20601 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20602 + VX_LIMIT_ARG(RLIMIT_RSS),
20603 + VX_LIMIT_ARG(VLIMIT_ANON),
20604 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20605 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20606 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20607 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20608 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20609 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20610 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20611 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20612 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20613 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20616 +#endif /* _VX_LIMIT_PROC_H */
20619 diff -NurpP --minimal linux-2.6.37/kernel/vserver/Makefile linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/Makefile
20620 --- linux-2.6.37/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
20621 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/Makefile 2010-11-23 02:09:41.000000000 +0100
20624 +# Makefile for the Linux vserver routines.
20628 +obj-y += vserver.o
20630 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
20631 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
20634 +vserver-$(CONFIG_INET) += inet.o
20635 +vserver-$(CONFIG_PROC_FS) += proc.o
20636 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
20637 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
20638 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
20639 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
20641 diff -NurpP --minimal linux-2.6.37/kernel/vserver/network.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/network.c
20642 --- linux-2.6.37/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20643 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/network.c 2010-11-23 02:09:41.000000000 +0100
20646 + * linux/kernel/vserver/network.c
20648 + * Virtual Server: Network Support
20650 + * Copyright (C) 2003-2007 Herbert Pötzl
20652 + * V0.01 broken out from vcontext V0.05
20653 + * V0.02 cleaned up implementation
20654 + * V0.03 added equiv nx commands
20655 + * V0.04 switch to RCU based hash
20656 + * V0.05 and back to locking again
20657 + * V0.06 changed vcmds to nxi arg
20658 + * V0.07 have __create claim() the nxi
20662 +#include <linux/err.h>
20663 +#include <linux/slab.h>
20664 +#include <linux/rcupdate.h>
20666 +#include <linux/vs_network.h>
20667 +#include <linux/vs_pid.h>
20668 +#include <linux/vserver/network_cmd.h>
20671 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20672 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20674 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20675 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20678 +static int __init init_network(void)
20680 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20681 + sizeof(struct nx_addr_v4), 0,
20682 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20683 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20684 + sizeof(struct nx_addr_v6), 0,
20685 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20690 +/* __alloc_nx_addr_v4() */
20692 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20694 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20695 + nx_addr_v4_cachep, GFP_KERNEL);
20697 + if (!IS_ERR(nxa))
20698 + memset(nxa, 0, sizeof(*nxa));
20702 +/* __dealloc_nx_addr_v4() */
20704 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20706 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20709 +/* __dealloc_nx_addr_v4_all() */
20711 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20714 + struct nx_addr_v4 *next = nxa->next;
20716 + __dealloc_nx_addr_v4(nxa);
20722 +#ifdef CONFIG_IPV6
20724 +/* __alloc_nx_addr_v6() */
20726 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20728 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20729 + nx_addr_v6_cachep, GFP_KERNEL);
20731 + if (!IS_ERR(nxa))
20732 + memset(nxa, 0, sizeof(*nxa));
20736 +/* __dealloc_nx_addr_v6() */
20738 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20740 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20743 +/* __dealloc_nx_addr_v6_all() */
20745 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20748 + struct nx_addr_v6 *next = nxa->next;
20750 + __dealloc_nx_addr_v6(nxa);
20755 +#endif /* CONFIG_IPV6 */
20757 +/* __alloc_nx_info()
20759 + * allocate an initialized nx_info struct
20760 + * doesn't make it visible (hash) */
20762 +static struct nx_info *__alloc_nx_info(nid_t nid)
20764 + struct nx_info *new = NULL;
20766 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20768 + /* would this benefit from a slab cache? */
20769 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20773 + memset(new, 0, sizeof(struct nx_info));
20774 + new->nx_id = nid;
20775 + INIT_HLIST_NODE(&new->nx_hlist);
20776 + atomic_set(&new->nx_usecnt, 0);
20777 + atomic_set(&new->nx_tasks, 0);
20778 + new->nx_state = 0;
20780 + new->nx_flags = NXF_INIT_SET;
20782 + /* rest of init goes here */
20784 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20785 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20787 + vxdprintk(VXD_CBIT(nid, 0),
20788 + "alloc_nx_info(%d) = %p", nid, new);
20789 + atomic_inc(&nx_global_ctotal);
20793 +/* __dealloc_nx_info()
20795 + * final disposal of nx_info */
20797 +static void __dealloc_nx_info(struct nx_info *nxi)
20799 + vxdprintk(VXD_CBIT(nid, 0),
20800 + "dealloc_nx_info(%p)", nxi);
20802 + nxi->nx_hlist.next = LIST_POISON1;
20805 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20806 + BUG_ON(atomic_read(&nxi->nx_tasks));
20808 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20810 + nxi->nx_state |= NXS_RELEASED;
20812 + atomic_dec(&nx_global_ctotal);
20815 +static void __shutdown_nx_info(struct nx_info *nxi)
20817 + nxi->nx_state |= NXS_SHUTDOWN;
20818 + vs_net_change(nxi, VSC_NETDOWN);
20821 +/* exported stuff */
20823 +void free_nx_info(struct nx_info *nxi)
20825 + /* context shutdown is mandatory */
20826 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20828 + /* context must not be hashed */
20829 + BUG_ON(nxi->nx_state & NXS_HASHED);
20831 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20832 + BUG_ON(atomic_read(&nxi->nx_tasks));
20834 + __dealloc_nx_info(nxi);
20838 +void __nx_set_lback(struct nx_info *nxi)
20840 + int nid = nxi->nx_id;
20841 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20843 + nxi->v4_lback.s_addr = lback;
20846 +extern int __nx_inet_add_lback(__be32 addr);
20847 +extern int __nx_inet_del_lback(__be32 addr);
20850 +/* hash table for nx_info hash */
20852 +#define NX_HASH_SIZE 13
20854 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20856 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
20859 +static inline unsigned int __hashval(nid_t nid)
20861 + return (nid % NX_HASH_SIZE);
20866 +/* __hash_nx_info()
20868 + * add the nxi to the global hash table
20869 + * requires the hash_lock to be held */
20871 +static inline void __hash_nx_info(struct nx_info *nxi)
20873 + struct hlist_head *head;
20875 + vxd_assert_lock(&nx_info_hash_lock);
20876 + vxdprintk(VXD_CBIT(nid, 4),
20877 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20879 + /* context must not be hashed */
20880 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20882 + nxi->nx_state |= NXS_HASHED;
20883 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20884 + hlist_add_head(&nxi->nx_hlist, head);
20885 + atomic_inc(&nx_global_cactive);
20888 +/* __unhash_nx_info()
20890 + * remove the nxi from the global hash table
20891 + * requires the hash_lock to be held */
20893 +static inline void __unhash_nx_info(struct nx_info *nxi)
20895 + vxd_assert_lock(&nx_info_hash_lock);
20896 + vxdprintk(VXD_CBIT(nid, 4),
20897 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20898 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20900 + /* context must be hashed */
20901 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20902 + /* but without tasks */
20903 + BUG_ON(atomic_read(&nxi->nx_tasks));
20905 + nxi->nx_state &= ~NXS_HASHED;
20906 + hlist_del(&nxi->nx_hlist);
20907 + atomic_dec(&nx_global_cactive);
20911 +/* __lookup_nx_info()
20913 + * requires the hash_lock to be held
20914 + * doesn't increment the nx_refcnt */
20916 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20918 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20919 + struct hlist_node *pos;
20920 + struct nx_info *nxi;
20922 + vxd_assert_lock(&nx_info_hash_lock);
20923 + hlist_for_each(pos, head) {
20924 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20926 + if (nxi->nx_id == nid)
20931 + vxdprintk(VXD_CBIT(nid, 0),
20932 + "__lookup_nx_info(#%u): %p[#%u]",
20933 + nid, nxi, nxi ? nxi->nx_id : 0);
20938 +/* __create_nx_info()
20940 + * create the requested context
20941 + * get(), claim() and hash it */
20943 +static struct nx_info *__create_nx_info(int id)
20945 + struct nx_info *new, *nxi = NULL;
20947 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20949 + if (!(new = __alloc_nx_info(id)))
20950 + return ERR_PTR(-ENOMEM);
20952 + /* required to make dynamic xids unique */
20953 + spin_lock(&nx_info_hash_lock);
20955 + /* static context requested */
20956 + if ((nxi = __lookup_nx_info(id))) {
20957 + vxdprintk(VXD_CBIT(nid, 0),
20958 + "create_nx_info(%d) = %p (already there)", id, nxi);
20959 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20960 + nxi = ERR_PTR(-EBUSY);
20962 + nxi = ERR_PTR(-EEXIST);
20965 + /* new context */
20966 + vxdprintk(VXD_CBIT(nid, 0),
20967 + "create_nx_info(%d) = %p (new)", id, new);
20968 + claim_nx_info(new, NULL);
20969 + __nx_set_lback(new);
20970 + __hash_nx_info(get_nx_info(new));
20971 + nxi = new, new = NULL;
20974 + spin_unlock(&nx_info_hash_lock);
20976 + __dealloc_nx_info(new);
20982 +/* exported stuff */
20985 +void unhash_nx_info(struct nx_info *nxi)
20987 + __shutdown_nx_info(nxi);
20988 + spin_lock(&nx_info_hash_lock);
20989 + __unhash_nx_info(nxi);
20990 + spin_unlock(&nx_info_hash_lock);
20993 +/* lookup_nx_info()
20995 + * search for a nx_info and get() it
20996 + * negative id means current */
20998 +struct nx_info *lookup_nx_info(int id)
21000 + struct nx_info *nxi = NULL;
21003 + nxi = get_nx_info(current_nx_info());
21004 + } else if (id > 1) {
21005 + spin_lock(&nx_info_hash_lock);
21006 + nxi = get_nx_info(__lookup_nx_info(id));
21007 + spin_unlock(&nx_info_hash_lock);
21012 +/* nid_is_hashed()
21014 + * verify that nid is still hashed */
21016 +int nid_is_hashed(nid_t nid)
21020 + spin_lock(&nx_info_hash_lock);
21021 + hashed = (__lookup_nx_info(nid) != NULL);
21022 + spin_unlock(&nx_info_hash_lock);
21027 +#ifdef CONFIG_PROC_FS
21031 + * get a subset of hashed nids for proc
21032 + * assumes size is at least one */
21034 +int get_nid_list(int index, unsigned int *nids, int size)
21036 + int hindex, nr_nids = 0;
21038 + /* only show current and children */
21039 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
21042 + nids[nr_nids] = nx_current_nid();
21046 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
21047 + struct hlist_head *head = &nx_info_hash[hindex];
21048 + struct hlist_node *pos;
21050 + spin_lock(&nx_info_hash_lock);
21051 + hlist_for_each(pos, head) {
21052 + struct nx_info *nxi;
21057 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21058 + nids[nr_nids] = nxi->nx_id;
21059 + if (++nr_nids >= size) {
21060 + spin_unlock(&nx_info_hash_lock);
21064 + /* keep the lock time short */
21065 + spin_unlock(&nx_info_hash_lock);
21074 + * migrate task to new network
21075 + * gets nxi, puts old_nxi on change
21078 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
21080 + struct nx_info *old_nxi;
21086 + vxdprintk(VXD_CBIT(nid, 5),
21087 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
21088 + p, nxi, nxi->nx_id,
21089 + atomic_read(&nxi->nx_usecnt),
21090 + atomic_read(&nxi->nx_tasks));
21092 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
21093 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21096 + if (nx_info_state(nxi, NXS_SHUTDOWN))
21099 + /* maybe disallow this completely? */
21100 + old_nxi = task_get_nx_info(p);
21101 + if (old_nxi == nxi)
21106 + clr_nx_info(&p->nx_info);
21107 + claim_nx_info(nxi, p);
21108 + set_nx_info(&p->nx_info, nxi);
21109 + p->nid = nxi->nx_id;
21112 + vxdprintk(VXD_CBIT(nid, 5),
21113 + "moved task %p into nxi:%p[#%d]",
21114 + p, nxi, nxi->nx_id);
21117 + release_nx_info(old_nxi, p);
21120 + put_nx_info(old_nxi);
21125 +void nx_set_persistent(struct nx_info *nxi)
21127 + vxdprintk(VXD_CBIT(nid, 6),
21128 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
21130 + get_nx_info(nxi);
21131 + claim_nx_info(nxi, NULL);
21134 +void nx_clear_persistent(struct nx_info *nxi)
21136 + vxdprintk(VXD_CBIT(nid, 6),
21137 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
21139 + release_nx_info(nxi, NULL);
21140 + put_nx_info(nxi);
21143 +void nx_update_persistent(struct nx_info *nxi)
21145 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
21146 + nx_set_persistent(nxi);
21148 + nx_clear_persistent(nxi);
21151 +/* vserver syscall commands below here */
21153 +/* taks nid and nx_info functions */
21155 +#include <asm/uaccess.h>
21158 +int vc_task_nid(uint32_t id)
21163 + struct task_struct *tsk;
21165 + read_lock(&tasklist_lock);
21166 + tsk = find_task_by_real_pid(id);
21167 + nid = (tsk) ? tsk->nid : -ESRCH;
21168 + read_unlock(&tasklist_lock);
21170 + nid = nx_current_nid();
21175 +int vc_nx_info(struct nx_info *nxi, void __user *data)
21177 + struct vcmd_nx_info_v0 vc_data;
21179 + vc_data.nid = nxi->nx_id;
21181 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21187 +/* network functions */
21189 +int vc_net_create(uint32_t nid, void __user *data)
21191 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21192 + struct nx_info *new_nxi;
21195 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21198 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21201 + new_nxi = __create_nx_info(nid);
21202 + if (IS_ERR(new_nxi))
21203 + return PTR_ERR(new_nxi);
21205 + /* initial flags */
21206 + new_nxi->nx_flags = vc_data.flagword;
21209 + if (vs_net_change(new_nxi, VSC_NETUP))
21212 + ret = nx_migrate_task(current, new_nxi);
21216 + /* return context id on success */
21217 + ret = new_nxi->nx_id;
21219 + /* get a reference for persistent contexts */
21220 + if ((vc_data.flagword & NXF_PERSISTENT))
21221 + nx_set_persistent(new_nxi);
21223 + release_nx_info(new_nxi, NULL);
21224 + put_nx_info(new_nxi);
21229 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21231 + return nx_migrate_task(current, nxi);
21236 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21237 + uint16_t type, uint16_t flags)
21239 + struct nx_addr_v4 *nxa = &nxi->v4;
21241 + if (NX_IPV4(nxi)) {
21242 + /* locate last entry */
21243 + for (; nxa->next; nxa = nxa->next);
21244 + nxa->next = __alloc_nx_addr_v4();
21248 + return PTR_ERR(nxa);
21251 + if (nxi->v4.next)
21252 + /* remove single ip for ip list */
21253 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21255 + nxa->ip[0].s_addr = ip;
21256 + nxa->ip[1].s_addr = ip2;
21257 + nxa->mask.s_addr = mask;
21258 + nxa->type = type;
21259 + nxa->flags = flags;
21264 +int vc_net_add(struct nx_info *nxi, void __user *data)
21266 + struct vcmd_net_addr_v0 vc_data;
21267 + int index, ret = 0;
21269 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21272 + switch (vc_data.type) {
21273 + case NXA_TYPE_IPV4:
21274 + if ((vc_data.count < 1) || (vc_data.count > 4))
21278 + while (index < vc_data.count) {
21279 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21280 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21288 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21289 + nxi->v4_bcast = vc_data.ip[0];
21293 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21294 + nxi->v4_lback = vc_data.ip[0];
21305 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21307 + struct vcmd_net_addr_v0 vc_data;
21309 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21312 + switch (vc_data.type) {
21313 + case NXA_TYPE_ANY:
21314 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21315 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21325 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21327 + struct vcmd_net_addr_ipv4_v1 vc_data;
21329 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21332 + switch (vc_data.type) {
21333 + case NXA_TYPE_ADDR:
21334 + case NXA_TYPE_RANGE:
21335 + case NXA_TYPE_MASK:
21336 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21337 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21339 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21340 + nxi->v4_bcast = vc_data.ip;
21343 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21344 + nxi->v4_lback = vc_data.ip;
21353 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
21355 + struct vcmd_net_addr_ipv4_v1 vc_data;
21357 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21360 + switch (vc_data.type) {
21361 +/* case NXA_TYPE_ADDR:
21364 + case NXA_TYPE_ANY:
21365 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21366 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21376 +#ifdef CONFIG_IPV6
21378 +int do_add_v6_addr(struct nx_info *nxi,
21379 + struct in6_addr *ip, struct in6_addr *mask,
21380 + uint32_t prefix, uint16_t type, uint16_t flags)
21382 + struct nx_addr_v6 *nxa = &nxi->v6;
21384 + if (NX_IPV6(nxi)) {
21385 + /* locate last entry */
21386 + for (; nxa->next; nxa = nxa->next);
21387 + nxa->next = __alloc_nx_addr_v6();
21391 + return PTR_ERR(nxa);
21395 + nxa->mask = *mask;
21396 + nxa->prefix = prefix;
21397 + nxa->type = type;
21398 + nxa->flags = flags;
21403 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21405 + struct vcmd_net_addr_ipv6_v1 vc_data;
21407 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21410 + switch (vc_data.type) {
21411 + case NXA_TYPE_ADDR:
21412 + case NXA_TYPE_MASK:
21413 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21414 + vc_data.prefix, vc_data.type, vc_data.flags);
21421 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21423 + struct vcmd_net_addr_ipv6_v1 vc_data;
21425 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21428 + switch (vc_data.type) {
21429 + case NXA_TYPE_ANY:
21430 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21431 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21440 +#endif /* CONFIG_IPV6 */
21443 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21445 + struct vcmd_net_flags_v0 vc_data;
21447 + vc_data.flagword = nxi->nx_flags;
21449 + /* special STATE flag handling */
21450 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21452 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21457 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21459 + struct vcmd_net_flags_v0 vc_data;
21460 + uint64_t mask, trigger;
21462 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21465 + /* special STATE flag handling */
21466 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21467 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21469 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21470 + vc_data.flagword, mask);
21471 + if (trigger & NXF_PERSISTENT)
21472 + nx_update_persistent(nxi);
21477 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21479 + struct vcmd_net_caps_v0 vc_data;
21481 + vc_data.ncaps = nxi->nx_ncaps;
21482 + vc_data.cmask = ~0ULL;
21484 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21489 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21491 + struct vcmd_net_caps_v0 vc_data;
21493 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21496 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21497 + vc_data.ncaps, vc_data.cmask);
21502 +#include <linux/module.h>
21504 +module_init(init_network);
21506 +EXPORT_SYMBOL_GPL(free_nx_info);
21507 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21509 diff -NurpP --minimal linux-2.6.37/kernel/vserver/proc.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/proc.c
21510 --- linux-2.6.37/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21511 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/proc.c 2011-01-08 03:33:34.000000000 +0100
21514 + * linux/kernel/vserver/proc.c
21516 + * Virtual Context Support
21518 + * Copyright (C) 2003-2007 Herbert Pötzl
21520 + * V0.01 basic structure
21521 + * V0.02 adaptation vs1.3.0
21522 + * V0.03 proc permissions
21523 + * V0.04 locking/generic
21524 + * V0.05 next generation procfs
21525 + * V0.06 inode validation
21526 + * V0.07 generic rewrite vid
21527 + * V0.08 remove inode type
21531 +#include <linux/proc_fs.h>
21532 +#include <linux/fs_struct.h>
21533 +#include <linux/mount.h>
21534 +#include <asm/unistd.h>
21536 +#include <linux/vs_context.h>
21537 +#include <linux/vs_network.h>
21538 +#include <linux/vs_cvirt.h>
21540 +#include <linux/in.h>
21541 +#include <linux/inetdevice.h>
21542 +#include <linux/vs_inet.h>
21543 +#include <linux/vs_inet6.h>
21545 +#include <linux/vserver/global.h>
21547 +#include "cvirt_proc.h"
21548 +#include "cacct_proc.h"
21549 +#include "limit_proc.h"
21550 +#include "sched_proc.h"
21551 +#include "vci_config.h"
21554 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21558 + CAP_FOR_EACH_U32(__capi) {
21559 + buffer += sprintf(buffer, "%08x",
21560 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21566 +static struct proc_dir_entry *proc_virtual;
21568 +static struct proc_dir_entry *proc_virtnet;
21571 +/* first the actual feeds */
21574 +static int proc_vci(char *buffer)
21576 + return sprintf(buffer,
21577 + "VCIVersion:\t%04x:%04x\n"
21578 + "VCISyscall:\t%d\n"
21579 + "VCIKernel:\t%08x\n",
21580 + VCI_VERSION >> 16,
21581 + VCI_VERSION & 0xFFFF,
21583 + vci_kernel_config());
21586 +static int proc_virtual_info(char *buffer)
21588 + return proc_vci(buffer);
21591 +static int proc_virtual_status(char *buffer)
21593 + return sprintf(buffer,
21595 + "#CActive:\t%d\n"
21596 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21597 + "#InitTask:\t%d\t%d %d\n",
21598 + atomic_read(&vx_global_ctotal),
21599 + atomic_read(&vx_global_cactive),
21600 + atomic_read(&vs_global_nsproxy),
21601 + atomic_read(&vs_global_fs),
21602 + atomic_read(&vs_global_mnt_ns),
21603 + atomic_read(&vs_global_uts_ns),
21604 + atomic_read(&nr_ipc_ns),
21605 + atomic_read(&vs_global_user_ns),
21606 + atomic_read(&vs_global_pid_ns),
21607 + atomic_read(&init_task.usage),
21608 + atomic_read(&init_task.nsproxy->count),
21609 + init_task.fs->users);
21613 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21617 + length = sprintf(buffer,
21625 + vxi->vx_badness_bias);
21629 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21631 + char *orig = buffer;
21633 + buffer += sprintf(buffer,
21636 + "Flags:\t%016llx\n",
21637 + atomic_read(&vxi->vx_usecnt),
21638 + atomic_read(&vxi->vx_tasks),
21639 + (unsigned long long)vxi->vx_flags);
21641 + buffer += sprintf(buffer, "BCaps:\t");
21642 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21643 + buffer += sprintf(buffer, "\n");
21645 + buffer += sprintf(buffer,
21646 + "CCaps:\t%016llx\n"
21647 + "Spaces:\t%08lx %08lx\n",
21648 + (unsigned long long)vxi->vx_ccaps,
21649 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21650 + return buffer - orig;
21653 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21655 + return vx_info_proc_limit(&vxi->limit, buffer);
21658 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21662 + length = vx_info_proc_sched(&vxi->sched, buffer);
21663 + for_each_online_cpu(cpu) {
21664 + length += vx_info_proc_sched_pc(
21665 + &vx_per_cpu(vxi, sched_pc, cpu),
21666 + buffer + length, cpu);
21671 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21673 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21676 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21678 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21681 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21685 + vx_update_load(vxi);
21686 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21687 + for_each_online_cpu(cpu) {
21688 + length += vx_info_proc_cvirt_pc(
21689 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21690 + buffer + length, cpu);
21695 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21697 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21701 +static int proc_virtnet_info(char *buffer)
21703 + return proc_vci(buffer);
21706 +static int proc_virtnet_status(char *buffer)
21708 + return sprintf(buffer,
21710 + "#CActive:\t%d\n",
21711 + atomic_read(&nx_global_ctotal),
21712 + atomic_read(&nx_global_cactive));
21715 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21717 + struct nx_addr_v4 *v4a;
21718 +#ifdef CONFIG_IPV6
21719 + struct nx_addr_v6 *v6a;
21723 + length = sprintf(buffer,
21726 + "Bcast:\t" NIPQUAD_FMT "\n"
21727 + "Lback:\t" NIPQUAD_FMT "\n",
21730 + NIPQUAD(nxi->v4_bcast.s_addr),
21731 + NIPQUAD(nxi->v4_lback.s_addr));
21733 + if (!NX_IPV4(nxi))
21735 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21736 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21739 +#ifdef CONFIG_IPV6
21740 + if (!NX_IPV6(nxi))
21742 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21743 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21750 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21754 + length = sprintf(buffer,
21757 + "Flags:\t%016llx\n"
21758 + "NCaps:\t%016llx\n",
21759 + atomic_read(&nxi->nx_usecnt),
21760 + atomic_read(&nxi->nx_tasks),
21761 + (unsigned long long)nxi->nx_flags,
21762 + (unsigned long long)nxi->nx_ncaps);
21768 +/* here the inode helpers */
21774 + struct inode_operations *iop;
21775 + struct file_operations *fop;
21776 + union proc_op op;
21779 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21781 + struct inode *inode = new_inode(sb);
21786 + inode->i_mode = p->mode;
21788 + inode->i_op = p->iop;
21790 + inode->i_fop = p->fop;
21792 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
21793 + inode->i_flags |= S_IMMUTABLE;
21795 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21797 + inode->i_uid = 0;
21798 + inode->i_gid = 0;
21799 + inode->i_tag = 0;
21804 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21805 + struct dentry *dentry, int id, void *ptr)
21807 + struct vs_entry *p = ptr;
21808 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21809 + struct dentry *error = ERR_PTR(-EINVAL);
21814 + PROC_I(inode)->op = p->op;
21815 + PROC_I(inode)->fd = id;
21816 + d_add(dentry, inode);
21824 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21827 + * Fill a directory entry.
21829 + * If possible create the dcache entry and derive our inode number and
21830 + * file type from dcache entry.
21832 + * Since all of the proc inode numbers are dynamically generated, the inode
21833 + * numbers do not exist until the inode is cache. This means creating the
21834 + * the dcache entry in readdir is necessary to keep the inode numbers
21835 + * reported by readdir in sync with the inode numbers reported
21838 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21839 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21841 + struct dentry *child, *dir = filp->f_dentry;
21842 + struct inode *inode;
21843 + struct qstr qname;
21845 + unsigned type = DT_UNKNOWN;
21847 + qname.name = name;
21849 + qname.hash = full_name_hash(name, len);
21851 + child = d_lookup(dir, &qname);
21853 + struct dentry *new;
21854 + new = d_alloc(dir, &qname);
21856 + child = instantiate(dir->d_inode, new, id, ptr);
21863 + if (!child || IS_ERR(child) || !child->d_inode)
21864 + goto end_instantiate;
21865 + inode = child->d_inode;
21867 + ino = inode->i_ino;
21868 + type = inode->i_mode >> 12;
21873 + ino = find_inode_number(dir, &qname);
21876 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21881 +/* get and revalidate vx_info/xid */
21884 +struct vx_info *get_proc_vx_info(struct inode *inode)
21886 + return lookup_vx_info(PROC_I(inode)->fd);
21889 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21891 + struct inode *inode = dentry->d_inode;
21892 + xid_t xid = PROC_I(inode)->fd;
21894 + if (!xid || xid_is_hashed(xid))
21901 +/* get and revalidate nx_info/nid */
21903 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21905 + struct inode *inode = dentry->d_inode;
21906 + nid_t nid = PROC_I(inode)->fd;
21908 + if (!nid || nid_is_hashed(nid))
21916 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21918 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21919 + size_t count, loff_t *ppos)
21921 + struct inode *inode = file->f_dentry->d_inode;
21922 + unsigned long page;
21923 + ssize_t length = 0;
21925 + if (count > PROC_BLOCK_SIZE)
21926 + count = PROC_BLOCK_SIZE;
21928 + /* fade that out as soon as stable */
21929 + WARN_ON(PROC_I(inode)->fd);
21931 + if (!(page = __get_free_page(GFP_KERNEL)))
21934 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21935 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21938 + length = simple_read_from_buffer(buf, count, ppos,
21939 + (char *)page, length);
21945 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21946 + size_t count, loff_t *ppos)
21948 + struct inode *inode = file->f_dentry->d_inode;
21949 + struct vx_info *vxi = NULL;
21950 + xid_t xid = PROC_I(inode)->fd;
21951 + unsigned long page;
21952 + ssize_t length = 0;
21954 + if (count > PROC_BLOCK_SIZE)
21955 + count = PROC_BLOCK_SIZE;
21957 + /* fade that out as soon as stable */
21959 + vxi = lookup_vx_info(xid);
21963 + length = -ENOMEM;
21964 + if (!(page = __get_free_page(GFP_KERNEL)))
21967 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21968 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21971 + length = simple_read_from_buffer(buf, count, ppos,
21972 + (char *)page, length);
21976 + put_vx_info(vxi);
21981 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21982 + size_t count, loff_t *ppos)
21984 + struct inode *inode = file->f_dentry->d_inode;
21985 + struct nx_info *nxi = NULL;
21986 + nid_t nid = PROC_I(inode)->fd;
21987 + unsigned long page;
21988 + ssize_t length = 0;
21990 + if (count > PROC_BLOCK_SIZE)
21991 + count = PROC_BLOCK_SIZE;
21993 + /* fade that out as soon as stable */
21995 + nxi = lookup_nx_info(nid);
21999 + length = -ENOMEM;
22000 + if (!(page = __get_free_page(GFP_KERNEL)))
22003 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
22004 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
22007 + length = simple_read_from_buffer(buf, count, ppos,
22008 + (char *)page, length);
22012 + put_nx_info(nxi);
22019 +/* here comes the lower level */
22022 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
22023 + .len = sizeof(NAME) - 1, \
22024 + .name = (NAME), \
22032 +#define DIR(NAME, MODE, OTYPE) \
22033 + NOD(NAME, (S_IFDIR | (MODE)), \
22034 + &proc_ ## OTYPE ## _inode_operations, \
22035 + &proc_ ## OTYPE ## _file_operations, { } )
22037 +#define INF(NAME, MODE, OTYPE) \
22038 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22039 + &proc_vs_info_file_operations, \
22040 + { .proc_vs_read = &proc_##OTYPE } )
22042 +#define VINF(NAME, MODE, OTYPE) \
22043 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22044 + &proc_vx_info_file_operations, \
22045 + { .proc_vxi_read = &proc_##OTYPE } )
22047 +#define NINF(NAME, MODE, OTYPE) \
22048 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22049 + &proc_nx_info_file_operations, \
22050 + { .proc_nxi_read = &proc_##OTYPE } )
22053 +static struct file_operations proc_vs_info_file_operations = {
22054 + .read = proc_vs_info_read,
22057 +static struct file_operations proc_vx_info_file_operations = {
22058 + .read = proc_vx_info_read,
22061 +static struct dentry_operations proc_xid_dentry_operations = {
22062 + .d_revalidate = proc_xid_revalidate,
22065 +static struct vs_entry vx_base_stuff[] = {
22066 + VINF("info", S_IRUGO, vxi_info),
22067 + VINF("status", S_IRUGO, vxi_status),
22068 + VINF("limit", S_IRUGO, vxi_limit),
22069 + VINF("sched", S_IRUGO, vxi_sched),
22070 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
22071 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
22072 + VINF("cvirt", S_IRUGO, vxi_cvirt),
22073 + VINF("cacct", S_IRUGO, vxi_cacct),
22080 +static struct dentry *proc_xid_instantiate(struct inode *dir,
22081 + struct dentry *dentry, int id, void *ptr)
22083 + dentry->d_op = &proc_xid_dentry_operations;
22084 + return vs_proc_instantiate(dir, dentry, id, ptr);
22087 +static struct dentry *proc_xid_lookup(struct inode *dir,
22088 + struct dentry *dentry, struct nameidata *nd)
22090 + struct vs_entry *p = vx_base_stuff;
22091 + struct dentry *error = ERR_PTR(-ENOENT);
22093 + for (; p->name; p++) {
22094 + if (p->len != dentry->d_name.len)
22096 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22102 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22107 +static int proc_xid_readdir(struct file *filp,
22108 + void *dirent, filldir_t filldir)
22110 + struct dentry *dentry = filp->f_dentry;
22111 + struct inode *inode = dentry->d_inode;
22112 + struct vs_entry *p = vx_base_stuff;
22113 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
22117 + pos = filp->f_pos;
22120 + ino = inode->i_ino;
22121 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22124 + /* fall through */
22126 + ino = parent_ino(dentry);
22127 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22130 + /* fall through */
22133 + if (index >= size)
22135 + for (p += index; p->name; p++) {
22136 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22137 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22143 + filp->f_pos = pos;
22149 +static struct file_operations proc_nx_info_file_operations = {
22150 + .read = proc_nx_info_read,
22153 +static struct dentry_operations proc_nid_dentry_operations = {
22154 + .d_revalidate = proc_nid_revalidate,
22157 +static struct vs_entry nx_base_stuff[] = {
22158 + NINF("info", S_IRUGO, nxi_info),
22159 + NINF("status", S_IRUGO, nxi_status),
22164 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22165 + struct dentry *dentry, int id, void *ptr)
22167 + dentry->d_op = &proc_nid_dentry_operations;
22168 + return vs_proc_instantiate(dir, dentry, id, ptr);
22171 +static struct dentry *proc_nid_lookup(struct inode *dir,
22172 + struct dentry *dentry, struct nameidata *nd)
22174 + struct vs_entry *p = nx_base_stuff;
22175 + struct dentry *error = ERR_PTR(-ENOENT);
22177 + for (; p->name; p++) {
22178 + if (p->len != dentry->d_name.len)
22180 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22186 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22191 +static int proc_nid_readdir(struct file *filp,
22192 + void *dirent, filldir_t filldir)
22194 + struct dentry *dentry = filp->f_dentry;
22195 + struct inode *inode = dentry->d_inode;
22196 + struct vs_entry *p = nx_base_stuff;
22197 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22201 + pos = filp->f_pos;
22204 + ino = inode->i_ino;
22205 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22208 + /* fall through */
22210 + ino = parent_ino(dentry);
22211 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22214 + /* fall through */
22217 + if (index >= size)
22219 + for (p += index; p->name; p++) {
22220 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22221 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22227 + filp->f_pos = pos;
22232 +#define MAX_MULBY10 ((~0U - 9) / 10)
22234 +static inline int atovid(const char *str, int len)
22239 + while (len-- > 0) {
22244 + if (vid >= MAX_MULBY10)
22254 +/* now the upper level (virtual) */
22257 +static struct file_operations proc_xid_file_operations = {
22258 + .read = generic_read_dir,
22259 + .readdir = proc_xid_readdir,
22262 +static struct inode_operations proc_xid_inode_operations = {
22263 + .lookup = proc_xid_lookup,
22266 +static struct vs_entry vx_virtual_stuff[] = {
22267 + INF("info", S_IRUGO, virtual_info),
22268 + INF("status", S_IRUGO, virtual_status),
22269 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22273 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22274 + struct dentry *dentry, struct nameidata *nd)
22276 + struct vs_entry *p = vx_virtual_stuff;
22277 + struct dentry *error = ERR_PTR(-ENOENT);
22280 + for (; p->name; p++) {
22281 + if (p->len != dentry->d_name.len)
22283 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22287 + goto instantiate;
22289 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22290 + if ((id < 0) || !xid_is_hashed(id))
22294 + error = proc_xid_instantiate(dir, dentry, id, p);
22299 +static struct file_operations proc_nid_file_operations = {
22300 + .read = generic_read_dir,
22301 + .readdir = proc_nid_readdir,
22304 +static struct inode_operations proc_nid_inode_operations = {
22305 + .lookup = proc_nid_lookup,
22308 +static struct vs_entry nx_virtnet_stuff[] = {
22309 + INF("info", S_IRUGO, virtnet_info),
22310 + INF("status", S_IRUGO, virtnet_status),
22311 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22315 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22316 + struct dentry *dentry, struct nameidata *nd)
22318 + struct vs_entry *p = nx_virtnet_stuff;
22319 + struct dentry *error = ERR_PTR(-ENOENT);
22322 + for (; p->name; p++) {
22323 + if (p->len != dentry->d_name.len)
22325 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22329 + goto instantiate;
22331 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22332 + if ((id < 0) || !nid_is_hashed(id))
22336 + error = proc_nid_instantiate(dir, dentry, id, p);
22342 +#define PROC_MAXVIDS 32
22344 +int proc_virtual_readdir(struct file *filp,
22345 + void *dirent, filldir_t filldir)
22347 + struct dentry *dentry = filp->f_dentry;
22348 + struct inode *inode = dentry->d_inode;
22349 + struct vs_entry *p = vx_virtual_stuff;
22350 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22352 + unsigned int xid_array[PROC_MAXVIDS];
22353 + char buf[PROC_NUMBUF];
22354 + unsigned int nr_xids, i;
22357 + pos = filp->f_pos;
22360 + ino = inode->i_ino;
22361 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22364 + /* fall through */
22366 + ino = parent_ino(dentry);
22367 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22370 + /* fall through */
22373 + if (index >= size)
22375 + for (p += index; p->name; p++) {
22376 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22377 + vs_proc_instantiate, 0, p))
22382 + index = pos - size;
22383 + p = &vx_virtual_stuff[size - 1];
22384 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22385 + for (i = 0; i < nr_xids; i++) {
22386 + int n, xid = xid_array[i];
22387 + unsigned int j = PROC_NUMBUF;
22391 + buf[--j] = '0' + (n % 10);
22394 + if (proc_fill_cache(filp, dirent, filldir,
22395 + buf + j, PROC_NUMBUF - j,
22396 + vs_proc_instantiate, xid, p))
22402 + filp->f_pos = pos;
22406 +static int proc_virtual_getattr(struct vfsmount *mnt,
22407 + struct dentry *dentry, struct kstat *stat)
22409 + struct inode *inode = dentry->d_inode;
22411 + generic_fillattr(inode, stat);
22412 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22416 +static struct file_operations proc_virtual_dir_operations = {
22417 + .read = generic_read_dir,
22418 + .readdir = proc_virtual_readdir,
22421 +static struct inode_operations proc_virtual_dir_inode_operations = {
22422 + .getattr = proc_virtual_getattr,
22423 + .lookup = proc_virtual_lookup,
22430 +int proc_virtnet_readdir(struct file *filp,
22431 + void *dirent, filldir_t filldir)
22433 + struct dentry *dentry = filp->f_dentry;
22434 + struct inode *inode = dentry->d_inode;
22435 + struct vs_entry *p = nx_virtnet_stuff;
22436 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22438 + unsigned int nid_array[PROC_MAXVIDS];
22439 + char buf[PROC_NUMBUF];
22440 + unsigned int nr_nids, i;
22443 + pos = filp->f_pos;
22446 + ino = inode->i_ino;
22447 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22450 + /* fall through */
22452 + ino = parent_ino(dentry);
22453 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22456 + /* fall through */
22459 + if (index >= size)
22461 + for (p += index; p->name; p++) {
22462 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22463 + vs_proc_instantiate, 0, p))
22468 + index = pos - size;
22469 + p = &nx_virtnet_stuff[size - 1];
22470 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22471 + for (i = 0; i < nr_nids; i++) {
22472 + int n, nid = nid_array[i];
22473 + unsigned int j = PROC_NUMBUF;
22477 + buf[--j] = '0' + (n % 10);
22480 + if (proc_fill_cache(filp, dirent, filldir,
22481 + buf + j, PROC_NUMBUF - j,
22482 + vs_proc_instantiate, nid, p))
22488 + filp->f_pos = pos;
22492 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22493 + struct dentry *dentry, struct kstat *stat)
22495 + struct inode *inode = dentry->d_inode;
22497 + generic_fillattr(inode, stat);
22498 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22502 +static struct file_operations proc_virtnet_dir_operations = {
22503 + .read = generic_read_dir,
22504 + .readdir = proc_virtnet_readdir,
22507 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22508 + .getattr = proc_virtnet_getattr,
22509 + .lookup = proc_virtnet_lookup,
22514 +void proc_vx_init(void)
22516 + struct proc_dir_entry *ent;
22518 + ent = proc_mkdir("virtual", 0);
22520 + ent->proc_fops = &proc_virtual_dir_operations;
22521 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22523 + proc_virtual = ent;
22525 + ent = proc_mkdir("virtnet", 0);
22527 + ent->proc_fops = &proc_virtnet_dir_operations;
22528 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22530 + proc_virtnet = ent;
22536 +/* per pid info */
22539 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22541 + struct vx_info *vxi;
22542 + char *orig = buffer;
22544 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22546 + vxi = task_get_vx_info(p);
22550 + buffer += sprintf(buffer, "BCaps:\t");
22551 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22552 + buffer += sprintf(buffer, "\n");
22553 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22554 + (unsigned long long)vxi->vx_ccaps);
22555 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22556 + (unsigned long long)vxi->vx_flags);
22557 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22559 + put_vx_info(vxi);
22561 + return buffer - orig;
22565 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22567 + struct nx_info *nxi;
22568 + struct nx_addr_v4 *v4a;
22569 +#ifdef CONFIG_IPV6
22570 + struct nx_addr_v6 *v6a;
22572 + char *orig = buffer;
22575 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22577 + nxi = task_get_nx_info(p);
22581 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22582 + (unsigned long long)nxi->nx_ncaps);
22583 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22584 + (unsigned long long)nxi->nx_flags);
22586 + buffer += sprintf(buffer,
22587 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22588 + NIPQUAD(nxi->v4_bcast.s_addr));
22589 + buffer += sprintf (buffer,
22590 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22591 + NIPQUAD(nxi->v4_lback.s_addr));
22592 + if (!NX_IPV4(nxi))
22594 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22595 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22598 +#ifdef CONFIG_IPV6
22599 + if (!NX_IPV6(nxi))
22601 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22602 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22606 + put_nx_info(nxi);
22608 + return buffer - orig;
22611 diff -NurpP --minimal linux-2.6.37/kernel/vserver/sched.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/sched.c
22612 --- linux-2.6.37/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22613 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/sched.c 2010-11-23 02:09:41.000000000 +0100
22616 + * linux/kernel/vserver/sched.c
22618 + * Virtual Server: Scheduler Support
22620 + * Copyright (C) 2004-2010 Herbert Pötzl
22622 + * V0.01 adapted Sam Vilains version to 2.6.3
22623 + * V0.02 removed legacy interface
22624 + * V0.03 changed vcmds to vxi arg
22625 + * V0.04 removed older and legacy interfaces
22626 + * V0.05 removed scheduler code/commands
22630 +#include <linux/vs_context.h>
22631 +#include <linux/vs_sched.h>
22632 +#include <linux/vserver/sched_cmd.h>
22634 +#include <asm/uaccess.h>
22637 +void vx_update_sched_param(struct _vx_sched *sched,
22638 + struct _vx_sched_pc *sched_pc)
22640 + sched_pc->prio_bias = sched->prio_bias;
22643 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22647 + if (data->prio_bias > MAX_PRIO_BIAS)
22648 + data->prio_bias = MAX_PRIO_BIAS;
22649 + if (data->prio_bias < MIN_PRIO_BIAS)
22650 + data->prio_bias = MIN_PRIO_BIAS;
22652 + if (data->cpu_id != ~0) {
22653 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22654 + cpus_and(vxi->sched.update, cpu_online_map,
22655 + vxi->sched.update);
22657 + vxi->sched.update = cpu_online_map;
22659 + for_each_cpu_mask(cpu, vxi->sched.update)
22660 + vx_update_sched_param(&vxi->sched,
22661 + &vx_per_cpu(vxi, sched_pc, cpu));
22665 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22667 + struct vcmd_prio_bias vc_data;
22669 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22672 + return do_set_prio_bias(vxi, &vc_data);
22675 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22677 + struct vcmd_prio_bias vc_data;
22678 + struct _vx_sched_pc *pcd;
22681 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22684 + cpu = vc_data.cpu_id;
22686 + if (!cpu_possible(cpu))
22689 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22690 + vc_data.prio_bias = pcd->prio_bias;
22692 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22697 diff -NurpP --minimal linux-2.6.37/kernel/vserver/sched_init.h linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/sched_init.h
22698 --- linux-2.6.37/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22699 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/sched_init.h 2010-11-23 02:09:41.000000000 +0100
22702 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22704 + /* scheduling; hard code starting values as constants */
22705 + sched->prio_bias = 0;
22709 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22711 + sched_pc->prio_bias = 0;
22713 + sched_pc->user_ticks = 0;
22714 + sched_pc->sys_ticks = 0;
22715 + sched_pc->hold_ticks = 0;
22718 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22724 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22728 diff -NurpP --minimal linux-2.6.37/kernel/vserver/sched_proc.h linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/sched_proc.h
22729 --- linux-2.6.37/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22730 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/sched_proc.h 2010-11-23 02:09:41.000000000 +0100
22732 +#ifndef _VX_SCHED_PROC_H
22733 +#define _VX_SCHED_PROC_H
22737 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22741 + length += sprintf(buffer,
22742 + "PrioBias:\t%8d\n",
22743 + sched->prio_bias);
22748 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22749 + char *buffer, int cpu)
22753 + length += sprintf(buffer + length,
22754 + "cpu %d: %lld %lld %lld", cpu,
22755 + (unsigned long long)sched_pc->user_ticks,
22756 + (unsigned long long)sched_pc->sys_ticks,
22757 + (unsigned long long)sched_pc->hold_ticks);
22758 + length += sprintf(buffer + length,
22759 + " %d\n", sched_pc->prio_bias);
22763 +#endif /* _VX_SCHED_PROC_H */
22764 diff -NurpP --minimal linux-2.6.37/kernel/vserver/signal.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/signal.c
22765 --- linux-2.6.37/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22766 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/signal.c 2010-11-23 02:09:41.000000000 +0100
22769 + * linux/kernel/vserver/signal.c
22771 + * Virtual Server: Signal Support
22773 + * Copyright (C) 2003-2007 Herbert Pötzl
22775 + * V0.01 broken out from vcontext V0.05
22776 + * V0.02 changed vcmds to vxi arg
22777 + * V0.03 adjusted siginfo for kill
22781 +#include <asm/uaccess.h>
22783 +#include <linux/vs_context.h>
22784 +#include <linux/vs_pid.h>
22785 +#include <linux/vserver/signal_cmd.h>
22788 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22790 + int retval, count = 0;
22791 + struct task_struct *p;
22792 + struct siginfo *sip = SEND_SIG_PRIV;
22795 + vxdprintk(VXD_CBIT(misc, 4),
22796 + "vx_info_kill(%p[#%d],%d,%d)*",
22797 + vxi, vxi->vx_id, pid, sig);
22798 + read_lock(&tasklist_lock);
22802 + for_each_process(p) {
22805 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22806 + (pid && vxi->vx_initpid == p->pid))
22809 + err = group_send_sig_info(sig, sip, p);
22811 + if (err != -EPERM)
22817 + if (vxi->vx_initpid) {
22818 + pid = vxi->vx_initpid;
22819 + /* for now, only SIGINT to private init ... */
22820 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22821 + /* ... as long as there are tasks left */
22822 + (atomic_read(&vxi->vx_tasks) > 1))
22825 + /* fallthrough */
22827 + p = find_task_by_real_pid(pid);
22829 + if (vx_task_xid(p) == vxi->vx_id)
22830 + retval = group_send_sig_info(sig, sip, p);
22834 + read_unlock(&tasklist_lock);
22835 + vxdprintk(VXD_CBIT(misc, 4),
22836 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22837 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22841 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22843 + struct vcmd_ctx_kill_v0 vc_data;
22845 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22848 + /* special check to allow guest shutdown */
22849 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22850 + /* forbid killall pid=0 when init is present */
22851 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22852 + (vc_data.pid > 1)))
22855 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22859 +static int __wait_exit(struct vx_info *vxi)
22861 + DECLARE_WAITQUEUE(wait, current);
22864 + add_wait_queue(&vxi->vx_wait, &wait);
22865 + set_current_state(TASK_INTERRUPTIBLE);
22868 + if (vx_info_state(vxi,
22869 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22871 + if (signal_pending(current)) {
22872 + ret = -ERESTARTSYS;
22879 + set_current_state(TASK_RUNNING);
22880 + remove_wait_queue(&vxi->vx_wait, &wait);
22886 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22888 + struct vcmd_wait_exit_v0 vc_data;
22891 + ret = __wait_exit(vxi);
22892 + vc_data.reboot_cmd = vxi->reboot_cmd;
22893 + vc_data.exit_code = vxi->exit_code;
22895 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22900 diff -NurpP --minimal linux-2.6.37/kernel/vserver/space.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/space.c
22901 --- linux-2.6.37/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22902 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/space.c 2011-01-08 04:03:49.000000000 +0100
22905 + * linux/kernel/vserver/space.c
22907 + * Virtual Server: Context Space Support
22909 + * Copyright (C) 2003-2010 Herbert Pötzl
22911 + * V0.01 broken out from context.c 0.07
22912 + * V0.02 added task locking for namespace
22913 + * V0.03 broken out vx_enter_namespace
22914 + * V0.04 added *space support and commands
22915 + * V0.05 added credential support
22919 +#include <linux/utsname.h>
22920 +#include <linux/nsproxy.h>
22921 +#include <linux/err.h>
22922 +#include <linux/fs_struct.h>
22923 +#include <linux/cred.h>
22924 +#include <asm/uaccess.h>
22926 +#include <linux/vs_context.h>
22927 +#include <linux/vserver/space.h>
22928 +#include <linux/vserver/space_cmd.h>
22930 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22931 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22932 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22933 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22934 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22935 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22938 +/* namespace functions */
22940 +#include <linux/mnt_namespace.h>
22941 +#include <linux/user_namespace.h>
22942 +#include <linux/pid_namespace.h>
22943 +#include <linux/ipc_namespace.h>
22944 +#include <net/net_namespace.h>
22947 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22948 + .mask = CLONE_FS |
22956 +static const struct vcmd_space_mask_v1 space_mask = {
22957 + .mask = CLONE_FS |
22962 +#ifdef CONFIG_PID_NS
22965 +#ifdef CONFIG_NET_NS
22971 +static const struct vcmd_space_mask_v1 default_space_mask = {
22972 + .mask = CLONE_FS |
22977 +#ifdef CONFIG_PID_NS
22984 + * build a new nsproxy mix
22985 + * assumes that both proxies are 'const'
22986 + * does not touch nsproxy refcounts
22987 + * will hold a reference on the result.
22990 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22991 + struct nsproxy *new_nsproxy, unsigned long mask)
22993 + struct mnt_namespace *old_ns;
22994 + struct uts_namespace *old_uts;
22995 + struct ipc_namespace *old_ipc;
22996 +#ifdef CONFIG_PID_NS
22997 + struct pid_namespace *old_pid;
22999 +#ifdef CONFIG_NET_NS
23000 + struct net *old_net;
23002 + struct nsproxy *nsproxy;
23004 + nsproxy = copy_nsproxy(old_nsproxy);
23008 + if (mask & CLONE_NEWNS) {
23009 + old_ns = nsproxy->mnt_ns;
23010 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
23011 + if (nsproxy->mnt_ns)
23012 + get_mnt_ns(nsproxy->mnt_ns);
23016 + if (mask & CLONE_NEWUTS) {
23017 + old_uts = nsproxy->uts_ns;
23018 + nsproxy->uts_ns = new_nsproxy->uts_ns;
23019 + if (nsproxy->uts_ns)
23020 + get_uts_ns(nsproxy->uts_ns);
23024 + if (mask & CLONE_NEWIPC) {
23025 + old_ipc = nsproxy->ipc_ns;
23026 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
23027 + if (nsproxy->ipc_ns)
23028 + get_ipc_ns(nsproxy->ipc_ns);
23032 +#ifdef CONFIG_PID_NS
23033 + if (mask & CLONE_NEWPID) {
23034 + old_pid = nsproxy->pid_ns;
23035 + nsproxy->pid_ns = new_nsproxy->pid_ns;
23036 + if (nsproxy->pid_ns)
23037 + get_pid_ns(nsproxy->pid_ns);
23041 +#ifdef CONFIG_NET_NS
23042 + if (mask & CLONE_NEWNET) {
23043 + old_net = nsproxy->net_ns;
23044 + nsproxy->net_ns = new_nsproxy->net_ns;
23045 + if (nsproxy->net_ns)
23046 + get_net(nsproxy->net_ns);
23051 + put_mnt_ns(old_ns);
23053 + put_uts_ns(old_uts);
23055 + put_ipc_ns(old_ipc);
23056 +#ifdef CONFIG_PID_NS
23058 + put_pid_ns(old_pid);
23060 +#ifdef CONFIG_NET_NS
23062 + put_net(old_net);
23070 + * merge two nsproxy structs into a new one.
23071 + * will hold a reference on the result.
23075 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
23076 + struct nsproxy *proxy, unsigned long mask)
23078 + struct nsproxy null_proxy = { .mnt_ns = NULL };
23084 + /* vs_mix_nsproxy returns with reference */
23085 + return vs_mix_nsproxy(old ? old : &null_proxy,
23088 + get_nsproxy(proxy);
23093 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23095 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
23096 + struct fs_struct *fs_cur, *fs = NULL;
23097 + struct _vx_space *space;
23098 + int ret, kill = 0;
23100 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
23101 + vxi, vxi->vx_id, mask, index);
23103 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
23106 + if (index >= VX_SPACES)
23109 + space = &vxi->space[index];
23112 + mask = space->vx_nsmask;
23114 + if ((mask & space->vx_nsmask) != mask)
23117 + if (mask & CLONE_FS) {
23118 + fs = copy_fs_struct(space->vx_fs);
23122 + proxy = space->vx_nsproxy;
23124 + vxdprintk(VXD_CBIT(space, 9),
23125 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
23126 + vxi, vxi->vx_id, mask, index, proxy, fs);
23128 + task_lock(current);
23129 + fs_cur = current->fs;
23131 + if (mask & CLONE_FS) {
23132 + spin_lock(&fs_cur->lock);
23133 + current->fs = fs;
23134 + kill = !--fs_cur->users;
23135 + spin_unlock(&fs_cur->lock);
23138 + proxy_cur = current->nsproxy;
23139 + get_nsproxy(proxy_cur);
23140 + task_unlock(current);
23143 + free_fs_struct(fs_cur);
23145 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
23146 + if (IS_ERR(proxy_new)) {
23147 + ret = PTR_ERR(proxy_new);
23151 + proxy_new = xchg(¤t->nsproxy, proxy_new);
23153 + if (mask & CLONE_NEWUSER) {
23154 + vxdprintk(VXD_CBIT(space, 10),
23156 + "vx_enter_space(%p[#%u])", vxi, vxi->vx_id);
23158 + "vx_enter_space(%p[#%u],%p,%p) cred (%p,%p)",
23160 + space->vx_real_cred, space->vx_cred,
23161 + current->real_cred, current->cred);
23162 + exit_creds(current);
23163 + current->real_cred = get_cred(space->vx_real_cred);
23164 + alter_cred_subscribers(current->real_cred, 1);
23165 + current->cred = get_cred(space->vx_cred);
23166 + alter_cred_subscribers(current->cred, 1);
23173 + put_nsproxy(proxy_new);
23176 + put_nsproxy(proxy_cur);
23181 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23183 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
23184 + struct fs_struct *fs_vxi, *fs;
23185 + struct _vx_space *space;
23186 + int ret, kill = 0;
23188 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
23189 + vxi, vxi->vx_id, mask, index);
23191 + if ((mask & space_mask.mask) != mask)
23194 + if (index >= VX_SPACES)
23197 + space = &vxi->space[index];
23199 + proxy_vxi = space->vx_nsproxy;
23200 + fs_vxi = space->vx_fs;
23202 + if (mask & CLONE_FS) {
23203 + fs = copy_fs_struct(current->fs);
23208 + task_lock(current);
23210 + if (mask & CLONE_FS) {
23211 + spin_lock(&fs_vxi->lock);
23212 + space->vx_fs = fs;
23213 + kill = !--fs_vxi->users;
23214 + spin_unlock(&fs_vxi->lock);
23217 + proxy_cur = current->nsproxy;
23218 + get_nsproxy(proxy_cur);
23219 + task_unlock(current);
23222 + free_fs_struct(fs_vxi);
23224 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
23225 + if (IS_ERR(proxy_new)) {
23226 + ret = PTR_ERR(proxy_new);
23230 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
23231 + space->vx_nsmask |= mask;
23233 + if (mask & CLONE_NEWUSER) {
23234 + // const struct cred *cred;
23236 + vxdprintk(VXD_CBIT(space, 10),
23238 + "vx_set_space(%p[#%u])", vxi, vxi->vx_id);
23240 + "vx_set_space(%p[#%u],%p,%p) cred (%p,%p)",
23242 + space->vx_real_cred, space->vx_cred,
23243 + current->real_cred, current->cred);
23245 + if (current->real_cred) {
23246 + cred = get_cred(current->real_cred);
23247 + alter_cred_subscribers(cred, 1);
23250 + cred = xchg(&space->vx_real_cred, cred);
23252 + alter_cred_subscribers(cred, -1);
23256 + if (current->cred) {
23257 + cred = get_cred(current->cred);
23258 + alter_cred_subscribers(cred, 1);
23261 + cred = xchg(&space->vx_cred, cred);
23263 + alter_cred_subscribers(cred, -1);
23272 + put_nsproxy(proxy_new);
23275 + put_nsproxy(proxy_cur);
23280 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
23282 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23284 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23287 + return vx_enter_space(vxi, vc_data.mask, 0);
23290 +int vc_enter_space(struct vx_info *vxi, void __user *data)
23292 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23294 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23297 + if (vc_data.index >= VX_SPACES)
23300 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
23303 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
23305 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23307 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23310 + return vx_set_space(vxi, vc_data.mask, 0);
23313 +int vc_set_space(struct vx_info *vxi, void __user *data)
23315 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23317 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23320 + if (vc_data.index >= VX_SPACES)
23323 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
23326 +int vc_get_space_mask(void __user *data, int type)
23328 + const struct vcmd_space_mask_v1 *mask;
23331 + mask = &space_mask_v0;
23332 + else if (type == 1)
23333 + mask = &space_mask;
23335 + mask = &default_space_mask;
23337 + vxdprintk(VXD_CBIT(space, 10),
23338 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
23340 + if (copy_to_user(data, mask, sizeof(*mask)))
23345 diff -NurpP --minimal linux-2.6.37/kernel/vserver/switch.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/switch.c
23346 --- linux-2.6.37/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
23347 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/switch.c 2010-11-23 02:09:41.000000000 +0100
23350 + * linux/kernel/vserver/switch.c
23352 + * Virtual Server: Syscall Switch
23354 + * Copyright (C) 2003-2007 Herbert Pötzl
23356 + * V0.01 syscall switch
23357 + * V0.02 added signal to context
23358 + * V0.03 added rlimit functions
23359 + * V0.04 added iattr, task/xid functions
23360 + * V0.05 added debug/history stuff
23361 + * V0.06 added compat32 layer
23362 + * V0.07 vcmd args and perms
23363 + * V0.08 added status commands
23364 + * V0.09 added tag commands
23365 + * V0.10 added oom bias
23366 + * V0.11 added device commands
23370 +#include <linux/vs_context.h>
23371 +#include <linux/vs_network.h>
23372 +#include <linux/vserver/switch.h>
23374 +#include "vci_config.h"
23378 +int vc_get_version(uint32_t id)
23380 + return VCI_VERSION;
23384 +int vc_get_vci(uint32_t id)
23386 + return vci_kernel_config();
23389 +#include <linux/vserver/context_cmd.h>
23390 +#include <linux/vserver/cvirt_cmd.h>
23391 +#include <linux/vserver/cacct_cmd.h>
23392 +#include <linux/vserver/limit_cmd.h>
23393 +#include <linux/vserver/network_cmd.h>
23394 +#include <linux/vserver/sched_cmd.h>
23395 +#include <linux/vserver/debug_cmd.h>
23396 +#include <linux/vserver/inode_cmd.h>
23397 +#include <linux/vserver/dlimit_cmd.h>
23398 +#include <linux/vserver/signal_cmd.h>
23399 +#include <linux/vserver/space_cmd.h>
23400 +#include <linux/vserver/tag_cmd.h>
23401 +#include <linux/vserver/device_cmd.h>
23403 +#include <linux/vserver/inode.h>
23404 +#include <linux/vserver/dlimit.h>
23407 +#ifdef CONFIG_COMPAT
23408 +#define __COMPAT(name, id, data, compat) \
23409 + (compat) ? name ## _x32(id, data) : name(id, data)
23410 +#define __COMPAT_NO_ID(name, data, compat) \
23411 + (compat) ? name ## _x32(data) : name(data)
23413 +#define __COMPAT(name, id, data, compat) \
23415 +#define __COMPAT_NO_ID(name, data, compat) \
23421 +long do_vcmd(uint32_t cmd, uint32_t id,
23422 + struct vx_info *vxi, struct nx_info *nxi,
23423 + void __user *data, int compat)
23427 + case VCMD_get_version:
23428 + return vc_get_version(id);
23429 + case VCMD_get_vci:
23430 + return vc_get_vci(id);
23432 + case VCMD_task_xid:
23433 + return vc_task_xid(id);
23434 + case VCMD_vx_info:
23435 + return vc_vx_info(vxi, data);
23437 + case VCMD_task_nid:
23438 + return vc_task_nid(id);
23439 + case VCMD_nx_info:
23440 + return vc_nx_info(nxi, data);
23442 + case VCMD_task_tag:
23443 + return vc_task_tag(id);
23445 + case VCMD_set_space_v1:
23446 + return vc_set_space_v1(vxi, data);
23447 + /* this is version 2 */
23448 + case VCMD_set_space:
23449 + return vc_set_space(vxi, data);
23451 + case VCMD_get_space_mask_v0:
23452 + return vc_get_space_mask(data, 0);
23453 + /* this is version 1 */
23454 + case VCMD_get_space_mask:
23455 + return vc_get_space_mask(data, 1);
23457 + case VCMD_get_space_default:
23458 + return vc_get_space_mask(data, -1);
23460 +#ifdef CONFIG_IA32_EMULATION
23461 + case VCMD_get_rlimit:
23462 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23463 + case VCMD_set_rlimit:
23464 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23466 + case VCMD_get_rlimit:
23467 + return vc_get_rlimit(vxi, data);
23468 + case VCMD_set_rlimit:
23469 + return vc_set_rlimit(vxi, data);
23471 + case VCMD_get_rlimit_mask:
23472 + return vc_get_rlimit_mask(id, data);
23473 + case VCMD_reset_hits:
23474 + return vc_reset_hits(vxi, data);
23475 + case VCMD_reset_minmax:
23476 + return vc_reset_minmax(vxi, data);
23478 + case VCMD_get_vhi_name:
23479 + return vc_get_vhi_name(vxi, data);
23480 + case VCMD_set_vhi_name:
23481 + return vc_set_vhi_name(vxi, data);
23483 + case VCMD_ctx_stat:
23484 + return vc_ctx_stat(vxi, data);
23485 + case VCMD_virt_stat:
23486 + return vc_virt_stat(vxi, data);
23487 + case VCMD_sock_stat:
23488 + return vc_sock_stat(vxi, data);
23489 + case VCMD_rlimit_stat:
23490 + return vc_rlimit_stat(vxi, data);
23492 + case VCMD_set_cflags:
23493 + return vc_set_cflags(vxi, data);
23494 + case VCMD_get_cflags:
23495 + return vc_get_cflags(vxi, data);
23497 + /* this is version 1 */
23498 + case VCMD_set_ccaps:
23499 + return vc_set_ccaps(vxi, data);
23500 + /* this is version 1 */
23501 + case VCMD_get_ccaps:
23502 + return vc_get_ccaps(vxi, data);
23503 + case VCMD_set_bcaps:
23504 + return vc_set_bcaps(vxi, data);
23505 + case VCMD_get_bcaps:
23506 + return vc_get_bcaps(vxi, data);
23508 + case VCMD_set_badness:
23509 + return vc_set_badness(vxi, data);
23510 + case VCMD_get_badness:
23511 + return vc_get_badness(vxi, data);
23513 + case VCMD_set_nflags:
23514 + return vc_set_nflags(nxi, data);
23515 + case VCMD_get_nflags:
23516 + return vc_get_nflags(nxi, data);
23518 + case VCMD_set_ncaps:
23519 + return vc_set_ncaps(nxi, data);
23520 + case VCMD_get_ncaps:
23521 + return vc_get_ncaps(nxi, data);
23523 + case VCMD_set_prio_bias:
23524 + return vc_set_prio_bias(vxi, data);
23525 + case VCMD_get_prio_bias:
23526 + return vc_get_prio_bias(vxi, data);
23527 + case VCMD_add_dlimit:
23528 + return __COMPAT(vc_add_dlimit, id, data, compat);
23529 + case VCMD_rem_dlimit:
23530 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23531 + case VCMD_set_dlimit:
23532 + return __COMPAT(vc_set_dlimit, id, data, compat);
23533 + case VCMD_get_dlimit:
23534 + return __COMPAT(vc_get_dlimit, id, data, compat);
23536 + case VCMD_ctx_kill:
23537 + return vc_ctx_kill(vxi, data);
23539 + case VCMD_wait_exit:
23540 + return vc_wait_exit(vxi, data);
23542 + case VCMD_get_iattr:
23543 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23544 + case VCMD_set_iattr:
23545 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23547 + case VCMD_fget_iattr:
23548 + return vc_fget_iattr(id, data);
23549 + case VCMD_fset_iattr:
23550 + return vc_fset_iattr(id, data);
23552 + case VCMD_enter_space_v0:
23553 + return vc_enter_space_v1(vxi, NULL);
23554 + case VCMD_enter_space_v1:
23555 + return vc_enter_space_v1(vxi, data);
23556 + /* this is version 2 */
23557 + case VCMD_enter_space:
23558 + return vc_enter_space(vxi, data);
23560 + case VCMD_ctx_create_v0:
23561 + return vc_ctx_create(id, NULL);
23562 + case VCMD_ctx_create:
23563 + return vc_ctx_create(id, data);
23564 + case VCMD_ctx_migrate_v0:
23565 + return vc_ctx_migrate(vxi, NULL);
23566 + case VCMD_ctx_migrate:
23567 + return vc_ctx_migrate(vxi, data);
23569 + case VCMD_net_create_v0:
23570 + return vc_net_create(id, NULL);
23571 + case VCMD_net_create:
23572 + return vc_net_create(id, data);
23573 + case VCMD_net_migrate:
23574 + return vc_net_migrate(nxi, data);
23576 + case VCMD_tag_migrate:
23577 + return vc_tag_migrate(id);
23579 + case VCMD_net_add:
23580 + return vc_net_add(nxi, data);
23581 + case VCMD_net_remove:
23582 + return vc_net_remove(nxi, data);
23584 + case VCMD_net_add_ipv4:
23585 + return vc_net_add_ipv4(nxi, data);
23586 + case VCMD_net_remove_ipv4:
23587 + return vc_net_remove_ipv4(nxi, data);
23588 +#ifdef CONFIG_IPV6
23589 + case VCMD_net_add_ipv6:
23590 + return vc_net_add_ipv6(nxi, data);
23591 + case VCMD_net_remove_ipv6:
23592 + return vc_net_remove_ipv6(nxi, data);
23594 +/* case VCMD_add_match_ipv4:
23595 + return vc_add_match_ipv4(nxi, data);
23596 + case VCMD_get_match_ipv4:
23597 + return vc_get_match_ipv4(nxi, data);
23598 +#ifdef CONFIG_IPV6
23599 + case VCMD_add_match_ipv6:
23600 + return vc_add_match_ipv6(nxi, data);
23601 + case VCMD_get_match_ipv6:
23602 + return vc_get_match_ipv6(nxi, data);
23605 +#ifdef CONFIG_VSERVER_DEVICE
23606 + case VCMD_set_mapping:
23607 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23608 + case VCMD_unset_mapping:
23609 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23611 +#ifdef CONFIG_VSERVER_HISTORY
23612 + case VCMD_dump_history:
23613 + return vc_dump_history(id);
23614 + case VCMD_read_history:
23615 + return __COMPAT(vc_read_history, id, data, compat);
23618 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23619 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23625 +#define __VCMD(vcmd, _perm, _args, _flags) \
23626 + case VCMD_ ## vcmd: perm = _perm; \
23627 + args = _args; flags = _flags; break
23630 +#define VCA_NONE 0x00
23631 +#define VCA_VXI 0x01
23632 +#define VCA_NXI 0x02
23634 +#define VCF_NONE 0x00
23635 +#define VCF_INFO 0x01
23636 +#define VCF_ADMIN 0x02
23637 +#define VCF_ARES 0x06 /* includes admin */
23638 +#define VCF_SETUP 0x08
23640 +#define VCF_ZIDOK 0x10 /* zero id okay */
23644 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23647 + int permit = -1, state = 0;
23648 + int perm = -1, args = 0, flags = 0;
23649 + struct vx_info *vxi = NULL;
23650 + struct nx_info *nxi = NULL;
23653 + /* unpriviledged commands */
23654 + __VCMD(get_version, 0, VCA_NONE, 0);
23655 + __VCMD(get_vci, 0, VCA_NONE, 0);
23656 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23657 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23658 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23659 + __VCMD(get_space_default,0, VCA_NONE, 0);
23661 + /* info commands */
23662 + __VCMD(task_xid, 2, VCA_NONE, 0);
23663 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23664 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23665 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23666 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23667 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23668 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23669 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23670 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23671 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23673 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23674 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23675 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23676 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23678 + __VCMD(task_nid, 2, VCA_NONE, 0);
23679 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23680 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23681 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23683 + __VCMD(task_tag, 2, VCA_NONE, 0);
23685 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23686 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23687 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23688 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23690 + /* lower admin commands */
23691 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23692 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23693 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23694 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23695 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23696 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23697 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23698 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23700 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23701 + __VCMD(net_create, 5, VCA_NONE, 0);
23702 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23704 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23706 + /* higher admin commands */
23707 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23708 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23709 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23711 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23712 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23713 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23714 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23716 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23717 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23718 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23720 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23721 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23722 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23723 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23724 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23725 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23726 +#ifdef CONFIG_IPV6
23727 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23728 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23730 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23731 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23732 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23733 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23734 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23736 +#ifdef CONFIG_VSERVER_DEVICE
23737 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23738 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23740 + /* debug level admin commands */
23741 +#ifdef CONFIG_VSERVER_HISTORY
23742 + __VCMD(dump_history, 9, VCA_NONE, 0);
23743 + __VCMD(read_history, 9, VCA_NONE, 0);
23750 + vxdprintk(VXD_CBIT(switch, 0),
23751 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23752 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23753 + VC_VERSION(cmd), id, data, compat,
23754 + perm, args, flags);
23761 + if (!capable(CAP_CONTEXT))
23765 + /* moved here from the individual commands */
23767 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23771 + /* vcmd involves resource management */
23773 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23777 + /* various legacy exceptions */
23779 + /* will go away when spectator is a cap */
23780 + case VCMD_ctx_migrate_v0:
23781 + case VCMD_ctx_migrate:
23783 + current->xid = 1;
23789 + /* will go away when spectator is a cap */
23790 + case VCMD_net_migrate:
23792 + current->nid = 1;
23799 + /* vcmds are fine by default */
23802 + /* admin type vcmds require admin ... */
23803 + if (flags & VCF_ADMIN)
23804 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23806 + /* ... but setup type vcmds override that */
23807 + if (!permit && (flags & VCF_SETUP))
23808 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23816 + if (!id && (flags & VCF_ZIDOK))
23820 + if (args & VCA_VXI) {
23821 + vxi = lookup_vx_info(id);
23825 + if ((flags & VCF_ADMIN) &&
23826 + /* special case kill for shutdown */
23827 + (cmd != VCMD_ctx_kill) &&
23828 + /* can context be administrated? */
23829 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23835 + if (args & VCA_NXI) {
23836 + nxi = lookup_nx_info(id);
23840 + if ((flags & VCF_ADMIN) &&
23841 + /* can context be administrated? */
23842 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23849 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23852 + if ((args & VCA_NXI) && nxi)
23853 + put_nx_info(nxi);
23855 + if ((args & VCA_VXI) && vxi)
23856 + put_vx_info(vxi);
23858 + vxdprintk(VXD_CBIT(switch, 1),
23859 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23860 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23861 + VC_VERSION(cmd), ret, ret, state, permit);
23866 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23868 + return do_vserver(cmd, id, data, 0);
23871 +#ifdef CONFIG_COMPAT
23874 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23876 + return do_vserver(cmd, id, data, 1);
23879 +#endif /* CONFIG_COMPAT */
23880 diff -NurpP --minimal linux-2.6.37/kernel/vserver/sysctl.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/sysctl.c
23881 --- linux-2.6.37/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23882 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/sysctl.c 2010-11-23 02:09:41.000000000 +0100
23885 + * kernel/vserver/sysctl.c
23887 + * Virtual Context Support
23889 + * Copyright (C) 2004-2007 Herbert Pötzl
23891 + * V0.01 basic structure
23895 +#include <linux/module.h>
23896 +#include <linux/ctype.h>
23897 +#include <linux/sysctl.h>
23898 +#include <linux/parser.h>
23899 +#include <asm/uaccess.h>
23902 + CTL_DEBUG_ERROR = 0,
23903 + CTL_DEBUG_SWITCH = 1,
23918 +unsigned int vx_debug_switch = 0;
23919 +unsigned int vx_debug_xid = 0;
23920 +unsigned int vx_debug_nid = 0;
23921 +unsigned int vx_debug_tag = 0;
23922 +unsigned int vx_debug_net = 0;
23923 +unsigned int vx_debug_limit = 0;
23924 +unsigned int vx_debug_cres = 0;
23925 +unsigned int vx_debug_dlim = 0;
23926 +unsigned int vx_debug_quota = 0;
23927 +unsigned int vx_debug_cvirt = 0;
23928 +unsigned int vx_debug_space = 0;
23929 +unsigned int vx_debug_misc = 0;
23932 +static struct ctl_table_header *vserver_table_header;
23933 +static ctl_table vserver_root_table[];
23936 +void vserver_register_sysctl(void)
23938 + if (!vserver_table_header) {
23939 + vserver_table_header = register_sysctl_table(vserver_root_table);
23944 +void vserver_unregister_sysctl(void)
23946 + if (vserver_table_header) {
23947 + unregister_sysctl_table(vserver_table_header);
23948 + vserver_table_header = NULL;
23953 +static int proc_dodebug(ctl_table *table, int write,
23954 + void __user *buffer, size_t *lenp, loff_t *ppos)
23956 + char tmpbuf[20], *p, c;
23957 + unsigned int value;
23958 + size_t left, len;
23960 + if ((*ppos && !write) || !*lenp) {
23968 + if (!access_ok(VERIFY_READ, buffer, left))
23970 + p = (char *)buffer;
23971 + while (left && __get_user(c, p) >= 0 && isspace(c))
23976 + if (left > sizeof(tmpbuf) - 1)
23978 + if (copy_from_user(tmpbuf, p, left))
23980 + tmpbuf[left] = '\0';
23982 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23983 + value = 10 * value + (*p - '0');
23984 + if (*p && !isspace(*p))
23986 + while (left && isspace(*p))
23988 + *(unsigned int *)table->data = value;
23990 + if (!access_ok(VERIFY_WRITE, buffer, left))
23992 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23995 + if (__copy_to_user(buffer, tmpbuf, len))
23997 + if ((left -= len) > 0) {
23998 + if (put_user('\n', (char *)buffer + len))
24012 +#define CTL_ENTRY(ctl, name) \
24014 + .procname = #name, \
24015 + .data = &vx_ ## name, \
24016 + .maxlen = sizeof(int), \
24018 + .proc_handler = &proc_dodebug, \
24019 + .extra1 = &zero, \
24020 + .extra2 = &zero, \
24023 +static ctl_table vserver_debug_table[] = {
24024 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
24025 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
24026 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
24027 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
24028 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
24029 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
24030 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
24031 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
24032 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
24033 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
24034 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
24035 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
24039 +static ctl_table vserver_root_table[] = {
24041 + .procname = "vserver",
24043 + .child = vserver_debug_table
24049 +static match_table_t tokens = {
24050 + { CTL_DEBUG_SWITCH, "switch=%x" },
24051 + { CTL_DEBUG_XID, "xid=%x" },
24052 + { CTL_DEBUG_NID, "nid=%x" },
24053 + { CTL_DEBUG_TAG, "tag=%x" },
24054 + { CTL_DEBUG_NET, "net=%x" },
24055 + { CTL_DEBUG_LIMIT, "limit=%x" },
24056 + { CTL_DEBUG_CRES, "cres=%x" },
24057 + { CTL_DEBUG_DLIM, "dlim=%x" },
24058 + { CTL_DEBUG_QUOTA, "quota=%x" },
24059 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
24060 + { CTL_DEBUG_SPACE, "space=%x" },
24061 + { CTL_DEBUG_MISC, "misc=%x" },
24062 + { CTL_DEBUG_ERROR, NULL }
24065 +#define HANDLE_CASE(id, name, val) \
24066 + case CTL_DEBUG_ ## id: \
24067 + vx_debug_ ## name = val; \
24068 + printk("vs_debug_" #name "=0x%x\n", val); \
24072 +static int __init vs_debug_setup(char *str)
24077 + printk("vs_debug_setup(%s)\n", str);
24078 + while ((p = strsep(&str, ",")) != NULL) {
24079 + substring_t args[MAX_OPT_ARGS];
24080 + unsigned int value;
24085 + token = match_token(p, tokens, args);
24086 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
24089 + HANDLE_CASE(SWITCH, switch, value);
24090 + HANDLE_CASE(XID, xid, value);
24091 + HANDLE_CASE(NID, nid, value);
24092 + HANDLE_CASE(TAG, tag, value);
24093 + HANDLE_CASE(NET, net, value);
24094 + HANDLE_CASE(LIMIT, limit, value);
24095 + HANDLE_CASE(CRES, cres, value);
24096 + HANDLE_CASE(DLIM, dlim, value);
24097 + HANDLE_CASE(QUOTA, quota, value);
24098 + HANDLE_CASE(CVIRT, cvirt, value);
24099 + HANDLE_CASE(SPACE, space, value);
24100 + HANDLE_CASE(MISC, misc, value);
24109 +__setup("vsdebug=", vs_debug_setup);
24113 +EXPORT_SYMBOL_GPL(vx_debug_switch);
24114 +EXPORT_SYMBOL_GPL(vx_debug_xid);
24115 +EXPORT_SYMBOL_GPL(vx_debug_nid);
24116 +EXPORT_SYMBOL_GPL(vx_debug_net);
24117 +EXPORT_SYMBOL_GPL(vx_debug_limit);
24118 +EXPORT_SYMBOL_GPL(vx_debug_cres);
24119 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
24120 +EXPORT_SYMBOL_GPL(vx_debug_quota);
24121 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
24122 +EXPORT_SYMBOL_GPL(vx_debug_space);
24123 +EXPORT_SYMBOL_GPL(vx_debug_misc);
24125 diff -NurpP --minimal linux-2.6.37/kernel/vserver/tag.c linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/tag.c
24126 --- linux-2.6.37/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
24127 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/tag.c 2010-11-23 02:09:41.000000000 +0100
24130 + * linux/kernel/vserver/tag.c
24132 + * Virtual Server: Shallow Tag Space
24134 + * Copyright (C) 2007 Herbert Pötzl
24136 + * V0.01 basic implementation
24140 +#include <linux/sched.h>
24141 +#include <linux/vserver/debug.h>
24142 +#include <linux/vs_pid.h>
24143 +#include <linux/vs_tag.h>
24145 +#include <linux/vserver/tag_cmd.h>
24148 +int dx_migrate_task(struct task_struct *p, tag_t tag)
24153 + vxdprintk(VXD_CBIT(tag, 5),
24154 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
24160 + vxdprintk(VXD_CBIT(tag, 5),
24161 + "moved task %p into [#%d]", p, tag);
24165 +/* vserver syscall commands below here */
24167 +/* taks xid and vx_info functions */
24170 +int vc_task_tag(uint32_t id)
24175 + struct task_struct *tsk;
24176 + read_lock(&tasklist_lock);
24177 + tsk = find_task_by_real_pid(id);
24178 + tag = (tsk) ? tsk->tag : -ESRCH;
24179 + read_unlock(&tasklist_lock);
24181 + tag = dx_current_tag();
24186 +int vc_tag_migrate(uint32_t tag)
24188 + return dx_migrate_task(current, tag & 0xFFFF);
24192 diff -NurpP --minimal linux-2.6.37/kernel/vserver/vci_config.h linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/vci_config.h
24193 --- linux-2.6.37/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
24194 +++ linux-2.6.37-vs2.3.0.37-rc2/kernel/vserver/vci_config.h 2010-11-23 02:09:41.000000000 +0100
24197 +/* interface version */
24199 +#define VCI_VERSION 0x00020307
24203 + VCI_KCBIT_NO_DYNAMIC = 0,
24205 + VCI_KCBIT_PROC_SECURE = 4,
24206 + VCI_KCBIT_HARDCPU = 5,
24207 + VCI_KCBIT_IDLELIMIT = 6,
24208 + VCI_KCBIT_IDLETIME = 7,
24210 + VCI_KCBIT_COWBL = 8,
24211 + VCI_KCBIT_FULLCOWBL = 9,
24212 + VCI_KCBIT_SPACES = 10,
24213 + VCI_KCBIT_NETV2 = 11,
24214 + VCI_KCBIT_MEMCG = 12,
24216 + VCI_KCBIT_DEBUG = 16,
24217 + VCI_KCBIT_HISTORY = 20,
24218 + VCI_KCBIT_TAGGED = 24,
24219 + VCI_KCBIT_PPTAG = 28,
24221 + VCI_KCBIT_MORE = 31,
24225 +static inline uint32_t vci_kernel_config(void)
24228 + (1 << VCI_KCBIT_NO_DYNAMIC) |
24230 + /* configured features */
24231 +#ifdef CONFIG_VSERVER_PROC_SECURE
24232 + (1 << VCI_KCBIT_PROC_SECURE) |
24234 +#ifdef CONFIG_VSERVER_IDLELIMIT
24235 + (1 << VCI_KCBIT_IDLELIMIT) |
24237 +#ifdef CONFIG_VSERVER_IDLETIME
24238 + (1 << VCI_KCBIT_IDLETIME) |
24240 +#ifdef CONFIG_VSERVER_COWBL
24241 + (1 << VCI_KCBIT_COWBL) |
24242 + (1 << VCI_KCBIT_FULLCOWBL) |
24244 + (1 << VCI_KCBIT_SPACES) |
24245 + (1 << VCI_KCBIT_NETV2) |
24246 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
24247 + (1 << VCI_KCBIT_MEMCG) |
24250 + /* debug options */
24251 +#ifdef CONFIG_VSERVER_DEBUG
24252 + (1 << VCI_KCBIT_DEBUG) |
24254 +#ifdef CONFIG_VSERVER_HISTORY
24255 + (1 << VCI_KCBIT_HISTORY) |
24258 + /* inode context tagging */
24259 +#if defined(CONFIG_TAGGING_NONE)
24260 + (0 << VCI_KCBIT_TAGGED) |
24261 +#elif defined(CONFIG_TAGGING_UID16)
24262 + (1 << VCI_KCBIT_TAGGED) |
24263 +#elif defined(CONFIG_TAGGING_GID16)
24264 + (2 << VCI_KCBIT_TAGGED) |
24265 +#elif defined(CONFIG_TAGGING_ID24)
24266 + (3 << VCI_KCBIT_TAGGED) |
24267 +#elif defined(CONFIG_TAGGING_INTERN)
24268 + (4 << VCI_KCBIT_TAGGED) |
24269 +#elif defined(CONFIG_TAGGING_RUNTIME)
24270 + (5 << VCI_KCBIT_TAGGED) |
24272 + (7 << VCI_KCBIT_TAGGED) |
24274 + (1 << VCI_KCBIT_PPTAG) |
24278 diff -NurpP --minimal linux-2.6.37/mm/filemap_xip.c linux-2.6.37-vs2.3.0.37-rc2/mm/filemap_xip.c
24279 --- linux-2.6.37/mm/filemap_xip.c 2010-07-07 18:31:58.000000000 +0200
24280 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/filemap_xip.c 2010-11-23 02:09:41.000000000 +0100
24282 #include <linux/seqlock.h>
24283 #include <linux/mutex.h>
24284 #include <linux/gfp.h>
24285 +#include <linux/vs_memory.h>
24286 #include <asm/tlbflush.h>
24287 #include <asm/io.h>
24289 diff -NurpP --minimal linux-2.6.37/mm/fremap.c linux-2.6.37-vs2.3.0.37-rc2/mm/fremap.c
24290 --- linux-2.6.37/mm/fremap.c 2010-10-21 13:07:57.000000000 +0200
24291 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/fremap.c 2010-11-23 02:09:41.000000000 +0100
24293 #include <linux/module.h>
24294 #include <linux/syscalls.h>
24295 #include <linux/mmu_notifier.h>
24296 +#include <linux/vs_memory.h>
24298 #include <asm/mmu_context.h>
24299 #include <asm/cacheflush.h>
24300 diff -NurpP --minimal linux-2.6.37/mm/hugetlb.c linux-2.6.37-vs2.3.0.37-rc2/mm/hugetlb.c
24301 --- linux-2.6.37/mm/hugetlb.c 2011-01-05 21:50:39.000000000 +0100
24302 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/hugetlb.c 2011-01-05 22:30:43.000000000 +0100
24305 #include <linux/hugetlb.h>
24306 #include <linux/node.h>
24307 +#include <linux/vs_memory.h>
24308 #include "internal.h"
24310 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
24311 diff -NurpP --minimal linux-2.6.37/mm/memcontrol.c linux-2.6.37-vs2.3.0.37-rc2/mm/memcontrol.c
24312 --- linux-2.6.37/mm/memcontrol.c 2011-01-05 21:50:40.000000000 +0100
24313 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/memcontrol.c 2011-01-05 22:30:43.000000000 +0100
24314 @@ -681,6 +681,31 @@ struct mem_cgroup *mem_cgroup_from_task(
24315 struct mem_cgroup, css);
24318 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
24320 + return res_counter_read_u64(&mem->res, member);
24323 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
24325 + return res_counter_read_u64(&mem->memsw, member);
24328 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
24330 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
24333 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
24335 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
24338 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
24340 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
24343 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
24345 struct mem_cgroup *mem = NULL;
24346 diff -NurpP --minimal linux-2.6.37/mm/memory.c linux-2.6.37-vs2.3.0.37-rc2/mm/memory.c
24347 --- linux-2.6.37/mm/memory.c 2011-01-05 21:50:40.000000000 +0100
24348 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/memory.c 2010-11-23 02:09:41.000000000 +0100
24349 @@ -3153,6 +3153,7 @@ static inline int handle_pte_fault(struc
24353 + int ret = 0, type = VXPT_UNKNOWN;
24356 if (!pte_present(entry)) {
24357 @@ -3177,9 +3178,12 @@ static inline int handle_pte_fault(struc
24358 if (unlikely(!pte_same(*pte, entry)))
24360 if (flags & FAULT_FLAG_WRITE) {
24361 - if (!pte_write(entry))
24362 - return do_wp_page(mm, vma, address,
24363 + if (!pte_write(entry)) {
24364 + ret = do_wp_page(mm, vma, address,
24365 pte, pmd, ptl, entry);
24366 + type = VXPT_WRITE;
24369 entry = pte_mkdirty(entry);
24371 entry = pte_mkyoung(entry);
24372 @@ -3197,7 +3201,10 @@ static inline int handle_pte_fault(struc
24375 pte_unmap_unlock(pte, ptl);
24379 + vx_page_fault(mm, vma, type, ret);
24384 diff -NurpP --minimal linux-2.6.37/mm/mremap.c linux-2.6.37-vs2.3.0.37-rc2/mm/mremap.c
24385 --- linux-2.6.37/mm/mremap.c 2011-01-05 21:50:40.000000000 +0100
24386 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/mremap.c 2010-11-23 02:09:41.000000000 +0100
24388 #include <linux/security.h>
24389 #include <linux/syscalls.h>
24390 #include <linux/mmu_notifier.h>
24391 +#include <linux/vs_memory.h>
24393 #include <asm/uaccess.h>
24394 #include <asm/cacheflush.h>
24395 diff -NurpP --minimal linux-2.6.37/mm/oom_kill.c linux-2.6.37-vs2.3.0.37-rc2/mm/oom_kill.c
24396 --- linux-2.6.37/mm/oom_kill.c 2011-01-05 21:50:40.000000000 +0100
24397 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/oom_kill.c 2010-11-23 02:09:41.000000000 +0100
24399 #include <linux/memcontrol.h>
24400 #include <linux/mempolicy.h>
24401 #include <linux/security.h>
24402 +#include <linux/reboot.h>
24403 +#include <linux/vs_memory.h>
24404 +#include <linux/vs_context.h>
24406 int sysctl_panic_on_oom;
24407 int sysctl_oom_kill_allocating_task;
24408 @@ -124,11 +127,18 @@ struct task_struct *find_lock_task_mm(st
24409 static bool oom_unkillable_task(struct task_struct *p,
24410 const struct mem_cgroup *mem, const nodemask_t *nodemask)
24412 - if (is_global_init(p))
24413 + unsigned xid = vx_current_xid();
24415 + /* skip the init task, global and per guest */
24416 + if (task_is_init(p))
24418 if (p->flags & PF_KTHREAD)
24421 + /* skip other guest and host processes if oom in guest */
24422 + if (xid && vx_task_xid(p) != xid)
24425 /* When mem_cgroup_out_of_memory() and p is not member of the group */
24426 if (mem && !task_in_mem_cgroup(p, mem))
24428 @@ -210,6 +220,18 @@ unsigned int oom_badness(struct task_str
24429 points += p->signal->oom_score_adj;
24432 + * add points for context badness and
24433 + * reduce badness for processes belonging to
24434 + * a different context
24437 + points += vx_badness(p, p->mm);
24439 + if ((vx_current_xid() > 1) &&
24440 + vx_current_xid() != vx_task_xid(p))
24444 * Never return 0 for an eligible task that may be killed since it's
24445 * possible that no single user task uses more than 0.1% of memory and
24446 * no single admin tasks uses more than 3.0%.
24447 @@ -414,8 +436,8 @@ static int oom_kill_task(struct task_str
24448 /* mm cannot be safely dereferenced after task_unlock(p) */
24451 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24452 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
24453 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24454 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
24455 K(get_mm_counter(p->mm, MM_ANONPAGES)),
24456 K(get_mm_counter(p->mm, MM_FILEPAGES)));
24458 @@ -477,8 +499,8 @@ static int oom_kill_process(struct task_
24462 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
24463 - message, task_pid_nr(p), p->comm, points);
24464 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
24465 + message, task_pid_nr(p), p->xid, p->comm, points);
24469 @@ -567,6 +589,8 @@ int unregister_oom_notifier(struct notif
24471 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
24473 +long vs_oom_action(unsigned int);
24476 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
24477 * if a parallel OOM killing is already taking place that includes a zone in
24478 @@ -726,7 +750,12 @@ retry:
24480 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
24481 read_unlock(&tasklist_lock);
24482 - panic("Out of memory and no killable processes...\n");
24484 + /* avoid panic for guest OOM */
24485 + if (current->xid)
24486 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
24488 + panic("Out of memory and no killable processes...\n");
24491 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
24492 diff -NurpP --minimal linux-2.6.37/mm/page_alloc.c linux-2.6.37-vs2.3.0.37-rc2/mm/page_alloc.c
24493 --- linux-2.6.37/mm/page_alloc.c 2011-01-05 21:50:40.000000000 +0100
24494 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/page_alloc.c 2011-01-05 22:30:43.000000000 +0100
24496 #include <linux/compaction.h>
24497 #include <trace/events/kmem.h>
24498 #include <linux/ftrace_event.h>
24499 +#include <linux/vs_base.h>
24500 +#include <linux/vs_limit.h>
24502 #include <asm/tlbflush.h>
24503 #include <asm/div64.h>
24504 @@ -2335,6 +2337,9 @@ void si_meminfo(struct sysinfo *val)
24505 val->totalhigh = totalhigh_pages;
24506 val->freehigh = nr_free_highpages();
24507 val->mem_unit = PAGE_SIZE;
24509 + if (vx_flags(VXF_VIRT_MEM, 0))
24510 + vx_vsi_meminfo(val);
24513 EXPORT_SYMBOL(si_meminfo);
24514 @@ -2355,6 +2360,9 @@ void si_meminfo_node(struct sysinfo *val
24517 val->mem_unit = PAGE_SIZE;
24519 + if (vx_flags(VXF_VIRT_MEM, 0))
24520 + vx_vsi_meminfo(val);
24524 diff -NurpP --minimal linux-2.6.37/mm/rmap.c linux-2.6.37-vs2.3.0.37-rc2/mm/rmap.c
24525 --- linux-2.6.37/mm/rmap.c 2011-01-05 21:50:40.000000000 +0100
24526 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/rmap.c 2010-11-23 02:09:41.000000000 +0100
24528 #include <linux/mmu_notifier.h>
24529 #include <linux/migrate.h>
24530 #include <linux/hugetlb.h>
24531 +#include <linux/vs_memory.h>
24533 #include <asm/tlbflush.h>
24535 diff -NurpP --minimal linux-2.6.37/mm/shmem.c linux-2.6.37-vs2.3.0.37-rc2/mm/shmem.c
24536 --- linux-2.6.37/mm/shmem.c 2011-01-05 21:50:40.000000000 +0100
24537 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/shmem.c 2010-11-23 02:09:41.000000000 +0100
24538 @@ -1816,7 +1816,7 @@ static int shmem_statfs(struct dentry *d
24540 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24542 - buf->f_type = TMPFS_MAGIC;
24543 + buf->f_type = TMPFS_SUPER_MAGIC;
24544 buf->f_bsize = PAGE_CACHE_SIZE;
24545 buf->f_namelen = NAME_MAX;
24546 if (sbinfo->max_blocks) {
24547 @@ -2378,7 +2378,7 @@ int shmem_fill_super(struct super_block
24548 sb->s_maxbytes = SHMEM_MAX_BYTES;
24549 sb->s_blocksize = PAGE_CACHE_SIZE;
24550 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24551 - sb->s_magic = TMPFS_MAGIC;
24552 + sb->s_magic = TMPFS_SUPER_MAGIC;
24553 sb->s_op = &shmem_ops;
24554 sb->s_time_gran = 1;
24555 #ifdef CONFIG_TMPFS_POSIX_ACL
24556 diff -NurpP --minimal linux-2.6.37/mm/slab.c linux-2.6.37-vs2.3.0.37-rc2/mm/slab.c
24557 --- linux-2.6.37/mm/slab.c 2011-01-05 21:50:40.000000000 +0100
24558 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/slab.c 2010-11-23 02:09:41.000000000 +0100
24559 @@ -407,6 +407,8 @@ static void kmem_list3_init(struct kmem_
24560 #define STATS_INC_FREEMISS(x) do { } while (0)
24563 +#include "slab_vs.h"
24568 @@ -3346,6 +3348,7 @@ retry:
24570 obj = slab_get_obj(cachep, slabp, nodeid);
24571 check_slabp(cachep, slabp);
24572 + vx_slab_alloc(cachep, flags);
24573 l3->free_objects--;
24574 /* move slabp to correct slabp list: */
24575 list_del(&slabp->list);
24576 @@ -3423,6 +3426,7 @@ __cache_alloc_node(struct kmem_cache *ca
24577 /* ___cache_alloc_node can fall back to other nodes */
24578 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24580 + vx_slab_alloc(cachep, flags);
24581 local_irq_restore(save_flags);
24582 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24583 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24584 @@ -3609,6 +3613,7 @@ static inline void __cache_free(struct k
24586 kmemleak_free_recursive(objp, cachep->flags);
24587 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
24588 + vx_slab_free(cachep);
24590 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24592 diff -NurpP --minimal linux-2.6.37/mm/slab_vs.h linux-2.6.37-vs2.3.0.37-rc2/mm/slab_vs.h
24593 --- linux-2.6.37/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24594 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/slab_vs.h 2010-11-23 02:09:41.000000000 +0100
24597 +#include <linux/vserver/context.h>
24599 +#include <linux/vs_context.h>
24602 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24604 + int what = gfp_zone(cachep->gfpflags);
24605 + struct vx_info *vxi = current_vx_info();
24610 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24614 +void vx_slab_free(struct kmem_cache *cachep)
24616 + int what = gfp_zone(cachep->gfpflags);
24617 + struct vx_info *vxi = current_vx_info();
24622 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24625 diff -NurpP --minimal linux-2.6.37/mm/swapfile.c linux-2.6.37-vs2.3.0.37-rc2/mm/swapfile.c
24626 --- linux-2.6.37/mm/swapfile.c 2011-01-05 21:50:40.000000000 +0100
24627 +++ linux-2.6.37-vs2.3.0.37-rc2/mm/swapfile.c 2010-11-23 02:09:41.000000000 +0100
24629 #include <asm/tlbflush.h>
24630 #include <linux/swapops.h>
24631 #include <linux/page_cgroup.h>
24632 +#include <linux/vs_base.h>
24633 +#include <linux/vs_memory.h>
24635 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24637 @@ -1773,6 +1775,16 @@ static int swap_show(struct seq_file *sw
24639 if (si == SEQ_START_TOKEN) {
24640 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24641 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24642 + struct sysinfo si;
24644 + vx_vsi_swapinfo(&si);
24645 + if (si.totalswap < (1 << 10))
24647 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24648 + "hdv0", "partition", si.totalswap >> 10,
24649 + (si.totalswap - si.freeswap) >> 10, -1);
24654 @@ -2178,6 +2190,8 @@ void si_swapinfo(struct sysinfo *val)
24655 val->freeswap = nr_swap_pages + nr_to_be_unused;
24656 val->totalswap = total_swap_pages + nr_to_be_unused;
24657 spin_unlock(&swap_lock);
24658 + if (vx_flags(VXF_VIRT_MEM, 0))
24659 + vx_vsi_swapinfo(val);
24663 diff -NurpP --minimal linux-2.6.37/net/core/dev.c linux-2.6.37-vs2.3.0.37-rc2/net/core/dev.c
24664 --- linux-2.6.37/net/core/dev.c 2011-01-05 21:50:41.000000000 +0100
24665 +++ linux-2.6.37-vs2.3.0.37-rc2/net/core/dev.c 2010-11-23 02:09:41.000000000 +0100
24666 @@ -127,6 +127,7 @@
24667 #include <linux/in.h>
24668 #include <linux/jhash.h>
24669 #include <linux/random.h>
24670 +#include <linux/vs_inet.h>
24671 #include <trace/events/napi.h>
24672 #include <trace/events/net.h>
24673 #include <trace/events/skb.h>
24674 @@ -608,7 +609,8 @@ struct net_device *__dev_get_by_name(str
24675 struct hlist_head *head = dev_name_hash(net, name);
24677 hlist_for_each_entry(dev, p, head, name_hlist)
24678 - if (!strncmp(dev->name, name, IFNAMSIZ))
24679 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24680 + nx_dev_visible(current_nx_info(), dev))
24684 @@ -634,7 +636,8 @@ struct net_device *dev_get_by_name_rcu(s
24685 struct hlist_head *head = dev_name_hash(net, name);
24687 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24688 - if (!strncmp(dev->name, name, IFNAMSIZ))
24689 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24690 + nx_dev_visible(current_nx_info(), dev))
24694 @@ -685,7 +688,8 @@ struct net_device *__dev_get_by_index(st
24695 struct hlist_head *head = dev_index_hash(net, ifindex);
24697 hlist_for_each_entry(dev, p, head, index_hlist)
24698 - if (dev->ifindex == ifindex)
24699 + if ((dev->ifindex == ifindex) &&
24700 + nx_dev_visible(current_nx_info(), dev))
24704 @@ -710,7 +714,8 @@ struct net_device *dev_get_by_index_rcu(
24705 struct hlist_head *head = dev_index_hash(net, ifindex);
24707 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
24708 - if (dev->ifindex == ifindex)
24709 + if ((dev->ifindex == ifindex) &&
24710 + nx_dev_visible(current_nx_info(), dev))
24714 @@ -763,10 +768,12 @@ struct net_device *dev_getbyhwaddr(struc
24718 - for_each_netdev(net, dev)
24719 + for_each_netdev(net, dev) {
24720 if (dev->type == type &&
24721 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24722 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24723 + nx_dev_visible(current_nx_info(), dev))
24729 @@ -777,9 +784,11 @@ struct net_device *__dev_getfirstbyhwtyp
24730 struct net_device *dev;
24733 - for_each_netdev(net, dev)
24734 - if (dev->type == type)
24735 + for_each_netdev(net, dev) {
24736 + if ((dev->type == type) &&
24737 + nx_dev_visible(current_nx_info(), dev))
24743 @@ -897,6 +906,8 @@ static int __dev_alloc_name(struct net *
24745 if (i < 0 || i >= max_netdevices)
24747 + if (!nx_dev_visible(current_nx_info(), d))
24750 /* avoid cases where sscanf is not exact inverse of printf */
24751 snprintf(buf, IFNAMSIZ, name, i);
24752 @@ -3746,6 +3757,8 @@ static int dev_ifconf(struct net *net, c
24755 for_each_netdev(net, dev) {
24756 + if (!nx_dev_visible(current_nx_info(), dev))
24758 for (i = 0; i < NPROTO; i++) {
24759 if (gifconf_list[i]) {
24761 @@ -3817,6 +3830,10 @@ static void dev_seq_printf_stats(struct
24762 struct rtnl_link_stats64 temp;
24763 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24765 + /* device visible inside network context? */
24766 + if (!nx_dev_visible(current_nx_info(), dev))
24769 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24770 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24771 dev->name, stats->rx_bytes, stats->rx_packets,
24772 diff -NurpP --minimal linux-2.6.37/net/core/rtnetlink.c linux-2.6.37-vs2.3.0.37-rc2/net/core/rtnetlink.c
24773 --- linux-2.6.37/net/core/rtnetlink.c 2011-01-05 21:50:41.000000000 +0100
24774 +++ linux-2.6.37-vs2.3.0.37-rc2/net/core/rtnetlink.c 2010-11-23 02:09:41.000000000 +0100
24775 @@ -891,6 +891,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24776 hlist_for_each_entry(dev, node, head, index_hlist) {
24779 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24781 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24782 NETLINK_CB(cb->skb).pid,
24783 cb->nlh->nlmsg_seq, 0,
24784 @@ -1607,6 +1609,9 @@ void rtmsg_ifinfo(int type, struct net_d
24785 struct sk_buff *skb;
24786 int err = -ENOBUFS;
24788 + if (!nx_dev_visible(current_nx_info(), dev))
24791 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
24794 diff -NurpP --minimal linux-2.6.37/net/core/sock.c linux-2.6.37-vs2.3.0.37-rc2/net/core/sock.c
24795 --- linux-2.6.37/net/core/sock.c 2011-01-05 21:50:41.000000000 +0100
24796 +++ linux-2.6.37-vs2.3.0.37-rc2/net/core/sock.c 2011-01-05 22:30:43.000000000 +0100
24797 @@ -127,6 +127,10 @@
24798 #include <net/cls_cgroup.h>
24800 #include <linux/filter.h>
24801 +#include <linux/vs_socket.h>
24802 +#include <linux/vs_limit.h>
24803 +#include <linux/vs_context.h>
24804 +#include <linux/vs_network.h>
24807 #include <net/tcp.h>
24808 @@ -1069,6 +1073,8 @@ static struct sock *sk_prot_alloc(struct
24810 sk_tx_queue_clear(sk);
24812 + sock_vx_init(sk);
24813 + sock_nx_init(sk);
24817 @@ -1168,6 +1174,11 @@ static void __sk_free(struct sock *sk)
24818 put_cred(sk->sk_peer_cred);
24819 put_pid(sk->sk_peer_pid);
24820 put_net(sock_net(sk));
24822 + clr_vx_info(&sk->sk_vx_info);
24824 + clr_nx_info(&sk->sk_nx_info);
24826 sk_prot_free(sk->sk_prot_creator, sk);
24829 @@ -1215,6 +1226,8 @@ struct sock *sk_clone(const struct sock
24832 get_net(sock_net(newsk));
24833 + sock_vx_init(newsk);
24834 + sock_nx_init(newsk);
24835 sk_node_init(&newsk->sk_node);
24836 sock_lock_init(newsk);
24837 bh_lock_sock(newsk);
24838 @@ -1270,6 +1283,12 @@ struct sock *sk_clone(const struct sock
24840 atomic_set(&newsk->sk_refcnt, 2);
24842 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24843 + newsk->sk_xid = sk->sk_xid;
24844 + vx_sock_inc(newsk);
24845 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24846 + newsk->sk_nid = sk->sk_nid;
24849 * Increment the counter in the same struct proto as the master
24850 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24851 @@ -2016,6 +2035,12 @@ void sock_init_data(struct socket *sock,
24853 sk->sk_stamp = ktime_set(-1L, 0);
24855 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24856 + sk->sk_xid = vx_current_xid();
24858 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24859 + sk->sk_nid = nx_current_nid();
24862 * Before updating sk_refcnt, we must commit prior changes to memory
24863 * (Documentation/RCU/rculist_nulls.txt for details)
24864 diff -NurpP --minimal linux-2.6.37/net/ipv4/af_inet.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/af_inet.c
24865 --- linux-2.6.37/net/ipv4/af_inet.c 2011-01-05 21:50:41.000000000 +0100
24866 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/af_inet.c 2010-11-23 02:09:41.000000000 +0100
24867 @@ -116,6 +116,7 @@
24868 #ifdef CONFIG_IP_MROUTE
24869 #include <linux/mroute.h>
24871 +#include <linux/vs_limit.h>
24874 /* The inetsw table contains everything that inet_create needs to
24875 @@ -325,9 +326,13 @@ lookup_protocol:
24879 + if ((protocol == IPPROTO_ICMP) &&
24880 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24883 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24884 goto out_rcu_unlock;
24887 err = -EAFNOSUPPORT;
24888 if (!inet_netns_ok(net, protocol))
24889 goto out_rcu_unlock;
24890 @@ -451,6 +456,7 @@ int inet_bind(struct socket *sock, struc
24891 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24892 struct sock *sk = sock->sk;
24893 struct inet_sock *inet = inet_sk(sk);
24894 + struct nx_v4_sock_addr nsa;
24895 unsigned short snum;
24898 @@ -464,7 +470,11 @@ int inet_bind(struct socket *sock, struc
24899 if (addr_len < sizeof(struct sockaddr_in))
24902 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24903 + err = v4_map_sock_addr(inet, addr, &nsa);
24907 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24909 /* Not specified by any standard per-se, however it breaks too
24910 * many applications when removed. It is unfortunate since
24911 @@ -476,7 +486,7 @@ int inet_bind(struct socket *sock, struc
24912 err = -EADDRNOTAVAIL;
24913 if (!sysctl_ip_nonlocal_bind &&
24914 !(inet->freebind || inet->transparent) &&
24915 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24916 + nsa.saddr != htonl(INADDR_ANY) &&
24917 chk_addr_ret != RTN_LOCAL &&
24918 chk_addr_ret != RTN_MULTICAST &&
24919 chk_addr_ret != RTN_BROADCAST)
24920 @@ -501,7 +511,7 @@ int inet_bind(struct socket *sock, struc
24921 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24922 goto out_release_sock;
24924 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24925 + v4_set_sock_addr(inet, &nsa);
24926 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24927 inet->inet_saddr = 0; /* Use device */
24929 @@ -703,11 +713,13 @@ int inet_getname(struct socket *sock, st
24932 sin->sin_port = inet->inet_dport;
24933 - sin->sin_addr.s_addr = inet->inet_daddr;
24934 + sin->sin_addr.s_addr =
24935 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24937 __be32 addr = inet->inet_rcv_saddr;
24939 addr = inet->inet_saddr;
24940 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24941 sin->sin_port = inet->inet_sport;
24942 sin->sin_addr.s_addr = addr;
24944 diff -NurpP --minimal linux-2.6.37/net/ipv4/devinet.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/devinet.c
24945 --- linux-2.6.37/net/ipv4/devinet.c 2011-01-05 21:50:41.000000000 +0100
24946 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/devinet.c 2010-11-23 02:09:41.000000000 +0100
24947 @@ -420,6 +420,7 @@ struct in_device *inetdev_by_index(struc
24949 EXPORT_SYMBOL(inetdev_by_index);
24952 /* Called only from RTNL semaphored context. No locks. */
24954 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24955 @@ -660,6 +661,8 @@ int devinet_ioctl(struct net *net, unsig
24957 in_dev = __in_dev_get_rtnl(dev);
24959 + struct nx_info *nxi = current_nx_info();
24961 if (tryaddrmatch) {
24962 /* Matthias Andree */
24963 /* compare label and address (4.4BSD style) */
24964 @@ -668,6 +671,8 @@ int devinet_ioctl(struct net *net, unsig
24965 This is checked above. */
24966 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24967 ifap = &ifa->ifa_next) {
24968 + if (!nx_v4_ifa_visible(nxi, ifa))
24970 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24971 sin_orig.sin_addr.s_addr ==
24972 ifa->ifa_address) {
24973 @@ -680,9 +685,12 @@ int devinet_ioctl(struct net *net, unsig
24974 comparing just the label */
24976 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24977 - ifap = &ifa->ifa_next)
24978 + ifap = &ifa->ifa_next) {
24979 + if (!nx_v4_ifa_visible(nxi, ifa))
24981 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24987 @@ -834,6 +842,8 @@ static int inet_gifconf(struct net_devic
24990 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24991 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24994 done += sizeof(ifr);
24996 @@ -1183,6 +1193,7 @@ static int inet_dump_ifaddr(struct sk_bu
24997 struct net_device *dev;
24998 struct in_device *in_dev;
24999 struct in_ifaddr *ifa;
25000 + struct sock *sk = skb->sk;
25001 struct hlist_head *head;
25002 struct hlist_node *node;
25004 @@ -1205,6 +1216,8 @@ static int inet_dump_ifaddr(struct sk_bu
25006 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
25007 ifa = ifa->ifa_next, ip_idx++) {
25008 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
25010 if (ip_idx < s_ip_idx)
25012 if (inet_fill_ifaddr(skb, ifa,
25013 diff -NurpP --minimal linux-2.6.37/net/ipv4/fib_hash.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/fib_hash.c
25014 --- linux-2.6.37/net/ipv4/fib_hash.c 2011-01-05 21:50:41.000000000 +0100
25015 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/fib_hash.c 2010-11-23 02:09:41.000000000 +0100
25016 @@ -1080,7 +1080,7 @@ static int fib_seq_show(struct seq_file
25017 prefix = f->fn_key;
25018 mask = FZ_MASK(iter->zone);
25019 flags = fib_flag_trans(fa->fa_type, mask, fi);
25021 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
25023 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
25024 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
25025 diff -NurpP --minimal linux-2.6.37/net/ipv4/inet_connection_sock.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/inet_connection_sock.c
25026 --- linux-2.6.37/net/ipv4/inet_connection_sock.c 2010-10-21 13:07:58.000000000 +0200
25027 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/inet_connection_sock.c 2010-11-23 02:09:41.000000000 +0100
25028 @@ -52,10 +52,40 @@ void inet_get_local_port_range(int *low,
25030 EXPORT_SYMBOL(inet_get_local_port_range);
25032 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25034 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
25035 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
25037 + if (inet_v6_ipv6only(sk2))
25040 + if (sk1_rcv_saddr &&
25042 + sk1_rcv_saddr == sk2_rcv_saddr)
25045 + if (sk1_rcv_saddr &&
25046 + !sk2_rcv_saddr &&
25047 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
25050 + if (sk2_rcv_saddr &&
25051 + !sk1_rcv_saddr &&
25052 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
25055 + if (!sk1_rcv_saddr &&
25056 + !sk2_rcv_saddr &&
25057 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
25063 int inet_csk_bind_conflict(const struct sock *sk,
25064 const struct inet_bind_bucket *tb)
25066 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
25068 struct hlist_node *node;
25069 int reuse = sk->sk_reuse;
25070 @@ -75,9 +105,7 @@ int inet_csk_bind_conflict(const struct
25071 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
25072 if (!reuse || !sk2->sk_reuse ||
25073 sk2->sk_state == TCP_LISTEN) {
25074 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
25075 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
25076 - sk2_rcv_saddr == sk_rcv_saddr)
25077 + if (ipv4_rcv_saddr_equal(sk, sk2))
25081 diff -NurpP --minimal linux-2.6.37/net/ipv4/inet_diag.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/inet_diag.c
25082 --- linux-2.6.37/net/ipv4/inet_diag.c 2011-01-05 21:50:42.000000000 +0100
25083 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/inet_diag.c 2010-11-23 02:09:41.000000000 +0100
25085 #include <linux/stddef.h>
25087 #include <linux/inet_diag.h>
25088 +#include <linux/vs_network.h>
25089 +#include <linux/vs_inet.h>
25091 static const struct inet_diag_handler **inet_diag_table;
25093 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
25095 r->id.idiag_sport = inet->inet_sport;
25096 r->id.idiag_dport = inet->inet_dport;
25097 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
25098 - r->id.idiag_dst[0] = inet->inet_daddr;
25099 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
25100 + inet->inet_rcv_saddr);
25101 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
25102 + inet->inet_daddr);
25104 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25105 if (r->idiag_family == AF_INET6) {
25106 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
25107 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
25108 r->id.idiag_sport = tw->tw_sport;
25109 r->id.idiag_dport = tw->tw_dport;
25110 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
25111 - r->id.idiag_dst[0] = tw->tw_daddr;
25112 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
25113 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
25114 r->idiag_state = tw->tw_substate;
25115 r->idiag_timer = 3;
25116 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
25117 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
25120 if (req->idiag_family == AF_INET) {
25121 + /* TODO: lback */
25122 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
25123 req->id.idiag_dport, req->id.idiag_src[0],
25124 req->id.idiag_sport, req->id.idiag_if);
25125 @@ -507,6 +512,7 @@ static int inet_csk_diag_dump(struct soc
25129 + /* TODO: lback */
25130 entry.saddr = &inet->inet_rcv_saddr;
25131 entry.daddr = &inet->inet_daddr;
25133 @@ -545,6 +551,7 @@ static int inet_twsk_diag_dump(struct in
25137 + /* TODO: lback */
25138 entry.saddr = &tw->tw_rcv_saddr;
25139 entry.daddr = &tw->tw_daddr;
25141 @@ -591,8 +598,8 @@ static int inet_diag_fill_req(struct sk_
25143 r->id.idiag_sport = inet->inet_sport;
25144 r->id.idiag_dport = ireq->rmt_port;
25145 - r->id.idiag_src[0] = ireq->loc_addr;
25146 - r->id.idiag_dst[0] = ireq->rmt_addr;
25147 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
25148 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
25149 r->idiag_expires = jiffies_to_msecs(tmo);
25150 r->idiag_rqueue = 0;
25151 r->idiag_wqueue = 0;
25152 @@ -663,6 +670,7 @@ static int inet_diag_dump_reqs(struct sk
25156 + /* TODO: lback */
25158 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25159 (entry.family == AF_INET6) ?
25160 @@ -733,6 +741,8 @@ static int inet_diag_dump(struct sk_buff
25161 sk_nulls_for_each(sk, node, &ilb->head) {
25162 struct inet_sock *inet = inet_sk(sk);
25164 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25169 @@ -799,6 +809,8 @@ skip_listen_ht:
25170 sk_nulls_for_each(sk, node, &head->chain) {
25171 struct inet_sock *inet = inet_sk(sk);
25173 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25177 if (!(r->idiag_states & (1 << sk->sk_state)))
25178 @@ -823,6 +835,8 @@ next_normal:
25179 inet_twsk_for_each(tw, node,
25182 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25186 if (r->id.idiag_sport != tw->tw_sport &&
25187 diff -NurpP --minimal linux-2.6.37/net/ipv4/inet_hashtables.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/inet_hashtables.c
25188 --- linux-2.6.37/net/ipv4/inet_hashtables.c 2011-01-05 21:50:42.000000000 +0100
25189 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/inet_hashtables.c 2011-01-05 22:30:43.000000000 +0100
25192 #include <net/inet_connection_sock.h>
25193 #include <net/inet_hashtables.h>
25194 +#include <net/route.h>
25195 #include <net/ip.h>
25198 @@ -155,6 +156,11 @@ static inline int compute_score(struct s
25199 if (rcv_saddr != daddr)
25203 + /* block non nx_info ips */
25204 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25205 + daddr, NXA_MASK_BIND))
25208 if (sk->sk_bound_dev_if) {
25209 if (sk->sk_bound_dev_if != dif)
25210 @@ -172,7 +178,6 @@ static inline int compute_score(struct s
25211 * wildcarded during the search since they can never be otherwise.
25215 struct sock *__inet_lookup_listener(struct net *net,
25216 struct inet_hashinfo *hashinfo,
25217 const __be32 daddr, const unsigned short hnum,
25218 @@ -195,6 +200,7 @@ begin:
25224 * if the nulls value we got at the end of this lookup is
25225 * not the expected one, we must restart lookup.
25226 diff -NurpP --minimal linux-2.6.37/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/netfilter/nf_nat_helper.c
25227 --- linux-2.6.37/net/ipv4/netfilter/nf_nat_helper.c 2011-01-05 21:50:42.000000000 +0100
25228 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/netfilter/nf_nat_helper.c 2010-11-23 02:09:41.000000000 +0100
25230 #include <net/route.h>
25232 #include <linux/netfilter_ipv4.h>
25233 +#include <net/route.h>
25234 #include <net/netfilter/nf_conntrack.h>
25235 #include <net/netfilter/nf_conntrack_helper.h>
25236 #include <net/netfilter/nf_conntrack_ecache.h>
25237 diff -NurpP --minimal linux-2.6.37/net/ipv4/netfilter.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/netfilter.c
25238 --- linux-2.6.37/net/ipv4/netfilter.c 2010-10-21 13:07:58.000000000 +0200
25239 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/netfilter.c 2010-11-23 02:09:41.000000000 +0100
25241 #include <linux/ip.h>
25242 #include <linux/skbuff.h>
25243 #include <linux/gfp.h>
25244 -#include <net/route.h>
25245 +// #include <net/route.h>
25246 #include <net/xfrm.h>
25247 #include <net/ip.h>
25248 #include <net/netfilter/nf_queue.h>
25249 diff -NurpP --minimal linux-2.6.37/net/ipv4/raw.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/raw.c
25250 --- linux-2.6.37/net/ipv4/raw.c 2011-01-05 21:50:42.000000000 +0100
25251 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/raw.c 2010-11-23 02:09:41.000000000 +0100
25252 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
25254 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
25255 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
25256 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
25257 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
25258 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
25259 goto found; /* gotcha */
25261 @@ -383,6 +383,12 @@ static int raw_send_hdrinc(struct sock *
25262 icmp_out_count(net, ((struct icmphdr *)
25263 skb_transport_header(skb))->type);
25266 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
25267 + sk->sk_nx_info &&
25268 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
25271 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
25272 rt->dst.dev, dst_output);
25274 @@ -563,6 +569,13 @@ static int raw_sendmsg(struct kiocb *ioc
25277 security_sk_classify_flow(sk, &fl);
25278 + if (sk->sk_nx_info) {
25279 + err = ip_v4_find_src(sock_net(sk),
25280 + sk->sk_nx_info, &rt, &fl);
25285 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
25288 @@ -635,17 +648,19 @@ static int raw_bind(struct sock *sk, str
25290 struct inet_sock *inet = inet_sk(sk);
25291 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
25292 + struct nx_v4_sock_addr nsa = { 0 };
25296 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
25298 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25299 + v4_map_sock_addr(inet, addr, &nsa);
25300 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25301 ret = -EADDRNOTAVAIL;
25302 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
25303 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
25304 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
25306 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25307 + v4_set_sock_addr(inet, &nsa);
25308 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25309 inet->inet_saddr = 0; /* Use device */
25311 @@ -697,7 +712,8 @@ static int raw_recvmsg(struct kiocb *ioc
25312 /* Copy the address. */
25314 sin->sin_family = AF_INET;
25315 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25316 + sin->sin_addr.s_addr =
25317 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
25319 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
25321 @@ -875,7 +891,8 @@ static struct sock *raw_get_first(struct
25322 struct hlist_node *node;
25324 sk_for_each(sk, node, &state->h->ht[state->bucket])
25325 - if (sock_net(sk) == seq_file_net(seq))
25326 + if ((sock_net(sk) == seq_file_net(seq)) &&
25327 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25331 @@ -891,7 +908,8 @@ static struct sock *raw_get_next(struct
25335 - } while (sk && sock_net(sk) != seq_file_net(seq));
25336 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
25337 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25339 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
25340 sk = sk_head(&state->h->ht[state->bucket]);
25341 @@ -950,7 +968,10 @@ static void raw_sock_seq_show(struct seq
25343 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
25344 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
25345 - i, src, srcp, dest, destp, sp->sk_state,
25347 + nx_map_sock_lback(current_nx_info(), src), srcp,
25348 + nx_map_sock_lback(current_nx_info(), dest), destp,
25350 sk_wmem_alloc_get(sp),
25351 sk_rmem_alloc_get(sp),
25352 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
25353 diff -NurpP --minimal linux-2.6.37/net/ipv4/tcp.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/tcp.c
25354 --- linux-2.6.37/net/ipv4/tcp.c 2011-01-05 21:50:42.000000000 +0100
25355 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/tcp.c 2011-01-05 22:30:43.000000000 +0100
25356 @@ -266,6 +266,7 @@
25357 #include <linux/crypto.h>
25358 #include <linux/time.h>
25359 #include <linux/slab.h>
25360 +#include <linux/in.h>
25362 #include <net/icmp.h>
25363 #include <net/tcp.h>
25364 diff -NurpP --minimal linux-2.6.37/net/ipv4/tcp_ipv4.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/tcp_ipv4.c
25365 --- linux-2.6.37/net/ipv4/tcp_ipv4.c 2011-01-05 21:50:42.000000000 +0100
25366 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/tcp_ipv4.c 2011-01-05 22:33:32.000000000 +0100
25367 @@ -2018,6 +2018,12 @@ static void *listening_get_next(struct s
25368 req = req->dl_next;
25371 + vxdprintk(VXD_CBIT(net, 6),
25372 + "sk,req: %p [#%d] (from %d)", req->sk,
25373 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
25375 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
25377 if (req->rsk_ops->family == st->family) {
25380 @@ -2043,6 +2049,10 @@ get_req:
25383 sk_nulls_for_each_from(sk, node) {
25384 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
25385 + sk, sk->sk_nid, nx_current_nid());
25386 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25388 if (!net_eq(sock_net(sk), net))
25390 if (sk->sk_family == st->family) {
25391 @@ -2119,6 +2129,11 @@ static void *established_get_first(struc
25393 spin_lock_bh(lock);
25394 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
25395 + vxdprintk(VXD_CBIT(net, 6),
25396 + "sk,egf: %p [#%d] (from %d)",
25397 + sk, sk->sk_nid, nx_current_nid());
25398 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25400 if (sk->sk_family != st->family ||
25401 !net_eq(sock_net(sk), net)) {
25403 @@ -2129,6 +2144,11 @@ static void *established_get_first(struc
25404 st->state = TCP_SEQ_STATE_TIME_WAIT;
25405 inet_twsk_for_each(tw, node,
25406 &tcp_hashinfo.ehash[st->bucket].twchain) {
25407 + vxdprintk(VXD_CBIT(net, 6),
25408 + "tw: %p [#%d] (from %d)",
25409 + tw, tw->tw_nid, nx_current_nid());
25410 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25412 if (tw->tw_family != st->family ||
25413 !net_eq(twsk_net(tw), net)) {
25415 @@ -2158,7 +2178,9 @@ static void *established_get_next(struct
25419 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
25420 + while (tw && (tw->tw_family != st->family ||
25421 + !net_eq(twsk_net(tw), net) ||
25422 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
25426 @@ -2182,6 +2204,11 @@ get_tw:
25427 sk = sk_nulls_next(sk);
25429 sk_nulls_for_each_from(sk, node) {
25430 + vxdprintk(VXD_CBIT(net, 6),
25431 + "sk,egn: %p [#%d] (from %d)",
25432 + sk, sk->sk_nid, nx_current_nid());
25433 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25435 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
25438 @@ -2391,9 +2418,9 @@ static void get_openreq4(struct sock *sk
25439 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25440 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
25443 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
25444 ntohs(inet_sk(sk)->inet_sport),
25446 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
25447 ntohs(ireq->rmt_port),
25449 0, 0, /* could print option size, but that is af dependent. */
25450 @@ -2445,7 +2472,10 @@ static void get_tcp4_sock(struct sock *s
25452 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
25453 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
25454 - i, src, srcp, dest, destp, sk->sk_state,
25456 + nx_map_sock_lback(current_nx_info(), src), srcp,
25457 + nx_map_sock_lback(current_nx_info(), dest), destp,
25459 tp->write_seq - tp->snd_una,
25462 @@ -2480,7 +2510,10 @@ static void get_timewait4_sock(struct in
25464 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25465 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
25466 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
25468 + nx_map_sock_lback(current_nx_info(), src), srcp,
25469 + nx_map_sock_lback(current_nx_info(), dest), destp,
25470 + tw->tw_substate, 0, 0,
25471 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
25472 atomic_read(&tw->tw_refcnt), tw, len);
25474 diff -NurpP --minimal linux-2.6.37/net/ipv4/tcp_minisocks.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/tcp_minisocks.c
25475 --- linux-2.6.37/net/ipv4/tcp_minisocks.c 2011-01-05 21:50:42.000000000 +0100
25476 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/tcp_minisocks.c 2011-01-05 22:30:43.000000000 +0100
25478 #include <linux/slab.h>
25479 #include <linux/sysctl.h>
25480 #include <linux/workqueue.h>
25481 +#include <linux/vs_limit.h>
25482 +#include <linux/vs_socket.h>
25483 +#include <linux/vs_context.h>
25484 #include <net/tcp.h>
25485 #include <net/inet_common.h>
25486 #include <net/xfrm.h>
25487 @@ -290,6 +293,11 @@ void tcp_time_wait(struct sock *sk, int
25488 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25489 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25491 + tw->tw_xid = sk->sk_xid;
25492 + tw->tw_vx_info = NULL;
25493 + tw->tw_nid = sk->sk_nid;
25494 + tw->tw_nx_info = NULL;
25496 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25497 if (tw->tw_family == PF_INET6) {
25498 struct ipv6_pinfo *np = inet6_sk(sk);
25499 diff -NurpP --minimal linux-2.6.37/net/ipv4/udp.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/udp.c
25500 --- linux-2.6.37/net/ipv4/udp.c 2011-01-05 21:50:42.000000000 +0100
25501 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv4/udp.c 2011-01-05 22:30:43.000000000 +0100
25502 @@ -296,14 +296,7 @@ fail:
25504 EXPORT_SYMBOL(udp_lib_get_port);
25506 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25508 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25510 - return (!ipv6_only_sock(sk2) &&
25511 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25512 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25514 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25516 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25518 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
25519 if (inet->inet_rcv_saddr != daddr)
25523 + /* block non nx_info ips */
25524 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25525 + daddr, NXA_MASK_BIND))
25528 if (inet->inet_daddr) {
25529 if (inet->inet_daddr != saddr)
25530 @@ -441,6 +439,7 @@ exact_match:
25535 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25536 * harder than this. -DaveM
25538 @@ -486,6 +485,11 @@ begin:
25539 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25540 score = compute_score(sk, net, saddr, hnum, sport,
25541 daddr, dport, dif);
25542 + /* FIXME: disabled?
25543 + if (score == 9) {
25547 if (score > badness) {
25550 @@ -499,6 +503,7 @@ begin:
25551 if (get_nulls_value(node) != slot)
25556 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
25558 @@ -508,6 +513,7 @@ begin:
25566 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
25567 udp_sk(s)->udp_port_hash != hnum ||
25568 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25569 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25570 - (inet->inet_rcv_saddr &&
25571 - inet->inet_rcv_saddr != loc_addr) ||
25572 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25573 ipv6_only_sock(s) ||
25574 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25576 @@ -900,8 +905,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
25577 { .sport = inet->inet_sport,
25578 .dport = dport } } };
25579 struct net *net = sock_net(sk);
25580 + struct nx_info *nxi = sk->sk_nx_info;
25582 security_sk_classify_flow(sk, &fl);
25583 + err = ip_v4_find_src(net, nxi, &rt, &fl);
25587 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
25589 if (err == -ENETUNREACH)
25590 @@ -1183,7 +1193,8 @@ try_again:
25592 sin->sin_family = AF_INET;
25593 sin->sin_port = udp_hdr(skb)->source;
25594 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25595 + sin->sin_addr.s_addr = nx_map_sock_lback(
25596 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25597 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25599 if (inet->cmsg_flags)
25600 @@ -1924,6 +1935,8 @@ static struct sock *udp_get_first(struct
25601 sk_nulls_for_each(sk, node, &hslot->head) {
25602 if (!net_eq(sock_net(sk), net))
25604 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25606 if (sk->sk_family == state->family)
25609 @@ -1941,7 +1954,9 @@ static struct sock *udp_get_next(struct
25612 sk = sk_nulls_next(sk);
25613 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25614 + } while (sk && (!net_eq(sock_net(sk), net) ||
25615 + sk->sk_family != state->family ||
25616 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25619 if (state->bucket <= state->udp_table->mask)
25620 @@ -2048,7 +2063,10 @@ static void udp4_format_sock(struct sock
25622 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
25623 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
25624 - bucket, src, srcp, dest, destp, sp->sk_state,
25626 + nx_map_sock_lback(current_nx_info(), src), srcp,
25627 + nx_map_sock_lback(current_nx_info(), dest), destp,
25629 sk_wmem_alloc_get(sp),
25630 sk_rmem_alloc_get(sp),
25631 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
25632 diff -NurpP --minimal linux-2.6.37/net/ipv6/addrconf.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/addrconf.c
25633 --- linux-2.6.37/net/ipv6/addrconf.c 2011-01-05 21:50:42.000000000 +0100
25634 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/addrconf.c 2011-01-05 22:30:43.000000000 +0100
25637 #include <linux/proc_fs.h>
25638 #include <linux/seq_file.h>
25639 +#include <linux/vs_network.h>
25640 +#include <linux/vs_inet6.h>
25642 /* Set to 3 to get tracing... */
25643 #define ACONF_DEBUG 2
25644 @@ -1124,7 +1126,7 @@ out:
25646 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25647 const struct in6_addr *daddr, unsigned int prefs,
25648 - struct in6_addr *saddr)
25649 + struct in6_addr *saddr, struct nx_info *nxi)
25651 struct ipv6_saddr_score scores[2],
25652 *score = &scores[0], *hiscore = &scores[1];
25653 @@ -1196,6 +1198,8 @@ int ipv6_dev_get_saddr(struct net *net,
25657 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25661 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25662 @@ -3079,7 +3083,10 @@ static void if6_seq_stop(struct seq_file
25663 static int if6_seq_show(struct seq_file *seq, void *v)
25665 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25666 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25668 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25669 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25670 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25672 ifp->idev->dev->ifindex,
25674 @@ -3585,6 +3592,11 @@ static int in6_dump_addrs(struct inet6_d
25675 struct ifacaddr6 *ifaca;
25677 int ip_idx = *p_ip_idx;
25678 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25680 + /* disable ipv6 on non v6 guests */
25681 + if (nxi && !nx_info_has_v6(nxi))
25684 read_lock_bh(&idev->lock);
25686 @@ -3595,6 +3607,8 @@ static int in6_dump_addrs(struct inet6_d
25687 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25688 if (++ip_idx < s_ip_idx)
25690 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25692 err = inet6_fill_ifaddr(skb, ifa,
25693 NETLINK_CB(cb->skb).pid,
25694 cb->nlh->nlmsg_seq,
25695 @@ -3611,6 +3625,8 @@ static int in6_dump_addrs(struct inet6_d
25696 ifmca = ifmca->next, ip_idx++) {
25697 if (ip_idx < s_ip_idx)
25699 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25701 err = inet6_fill_ifmcaddr(skb, ifmca,
25702 NETLINK_CB(cb->skb).pid,
25703 cb->nlh->nlmsg_seq,
25704 @@ -3626,6 +3642,8 @@ static int in6_dump_addrs(struct inet6_d
25705 ifaca = ifaca->aca_next, ip_idx++) {
25706 if (ip_idx < s_ip_idx)
25708 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25710 err = inet6_fill_ifacaddr(skb, ifaca,
25711 NETLINK_CB(cb->skb).pid,
25712 cb->nlh->nlmsg_seq,
25713 @@ -3975,6 +3993,11 @@ static int inet6_dump_ifinfo(struct sk_b
25714 struct inet6_dev *idev;
25715 struct hlist_head *head;
25716 struct hlist_node *node;
25717 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25719 + /* FIXME: maybe disable ipv6 on non v6 guests?
25720 + if (skb->sk && skb->sk->sk_vx_info)
25721 + return skb->len; */
25724 s_idx = cb->args[1];
25725 @@ -3986,6 +4009,8 @@ static int inet6_dump_ifinfo(struct sk_b
25726 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25729 + if (!v6_dev_in_nx_info(dev, nxi))
25731 idev = __in6_dev_get(dev);
25734 diff -NurpP --minimal linux-2.6.37/net/ipv6/af_inet6.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/af_inet6.c
25735 --- linux-2.6.37/net/ipv6/af_inet6.c 2011-01-05 21:50:42.000000000 +0100
25736 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/af_inet6.c 2010-11-23 02:09:41.000000000 +0100
25738 #include <linux/netdevice.h>
25739 #include <linux/icmpv6.h>
25740 #include <linux/netfilter_ipv6.h>
25741 +#include <linux/vs_inet.h>
25742 +#include <linux/vs_inet6.h>
25744 #include <net/ip.h>
25745 #include <net/ipv6.h>
25746 @@ -160,9 +162,12 @@ lookup_protocol:
25750 + if ((protocol == IPPROTO_ICMPV6) &&
25751 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25753 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25754 goto out_rcu_unlock;
25757 sock->ops = answer->ops;
25758 answer_prot = answer->prot;
25759 answer_no_check = answer->no_check;
25760 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25761 struct inet_sock *inet = inet_sk(sk);
25762 struct ipv6_pinfo *np = inet6_sk(sk);
25763 struct net *net = sock_net(sk);
25764 + struct nx_v6_sock_addr nsa;
25766 unsigned short snum;
25768 @@ -272,6 +278,11 @@ int inet6_bind(struct socket *sock, stru
25770 if (addr_len < SIN6_LEN_RFC2133)
25773 + err = v6_map_sock_addr(inet, addr, &nsa);
25777 addr_type = ipv6_addr_type(&addr->sin6_addr);
25778 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25780 @@ -303,6 +314,7 @@ int inet6_bind(struct socket *sock, stru
25781 /* Reproduce AF_INET checks to make the bindings consitant */
25782 v4addr = addr->sin6_addr.s6_addr32[3];
25783 chk_addr_ret = inet_addr_type(net, v4addr);
25785 if (!sysctl_ip_nonlocal_bind &&
25786 !(inet->freebind || inet->transparent) &&
25787 v4addr != htonl(INADDR_ANY) &&
25788 @@ -312,6 +324,10 @@ int inet6_bind(struct socket *sock, stru
25789 err = -EADDRNOTAVAIL;
25792 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25793 + err = -EADDRNOTAVAIL;
25797 if (addr_type != IPV6_ADDR_ANY) {
25798 struct net_device *dev = NULL;
25799 @@ -338,6 +354,11 @@ int inet6_bind(struct socket *sock, stru
25803 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25804 + err = -EADDRNOTAVAIL;
25808 /* ipv4 addr of the socket is invalid. Only the
25809 * unspecified and mapped address have a v4 equivalent.
25811 @@ -354,6 +375,9 @@ int inet6_bind(struct socket *sock, stru
25815 + /* what's that for? */
25816 + v6_set_sock_addr(inet, &nsa);
25818 inet->inet_rcv_saddr = v4addr;
25819 inet->inet_saddr = v4addr;
25821 @@ -455,9 +479,11 @@ int inet6_getname(struct socket *sock, s
25823 sin->sin6_port = inet->inet_dport;
25824 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25825 + /* FIXME: remap lback? */
25827 sin->sin6_flowinfo = np->flow_label;
25829 + /* FIXME: remap lback? */
25830 if (ipv6_addr_any(&np->rcv_saddr))
25831 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25833 diff -NurpP --minimal linux-2.6.37/net/ipv6/fib6_rules.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/fib6_rules.c
25834 --- linux-2.6.37/net/ipv6/fib6_rules.c 2011-01-05 21:50:42.000000000 +0100
25835 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/fib6_rules.c 2010-11-23 02:09:41.000000000 +0100
25836 @@ -88,7 +88,7 @@ static int fib6_rule_action(struct fib_r
25837 ip6_dst_idev(&rt->dst)->dev,
25839 rt6_flags2srcprefs(flags),
25843 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25845 diff -NurpP --minimal linux-2.6.37/net/ipv6/inet6_hashtables.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/inet6_hashtables.c
25846 --- linux-2.6.37/net/ipv6/inet6_hashtables.c 2010-02-25 11:52:10.000000000 +0100
25847 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/inet6_hashtables.c 2010-11-23 02:09:41.000000000 +0100
25850 #include <linux/module.h>
25851 #include <linux/random.h>
25852 +#include <linux/vs_inet6.h>
25854 #include <net/inet_connection_sock.h>
25855 #include <net/inet_hashtables.h>
25856 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
25857 unsigned int slot = hash & hashinfo->ehash_mask;
25858 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25863 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25864 @@ -94,7 +94,7 @@ begin:
25872 if (get_nulls_value(node) != slot)
25873 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
25874 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25878 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25881 if (sk->sk_bound_dev_if) {
25882 if (sk->sk_bound_dev_if != dif)
25883 diff -NurpP --minimal linux-2.6.37/net/ipv6/ip6_output.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/ip6_output.c
25884 --- linux-2.6.37/net/ipv6/ip6_output.c 2011-01-05 21:50:42.000000000 +0100
25885 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/ip6_output.c 2011-01-05 22:30:43.000000000 +0100
25886 @@ -930,7 +930,7 @@ static int ip6_dst_lookup_tail(struct so
25887 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
25889 sk ? inet6_sk(sk)->srcprefs : 0,
25891 + &fl->fl6_src, sk->sk_nx_info);
25893 goto out_err_release;
25895 diff -NurpP --minimal linux-2.6.37/net/ipv6/Kconfig linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/Kconfig
25896 --- linux-2.6.37/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25897 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/Kconfig 2010-11-23 02:09:41.000000000 +0100
25900 # IPv6 as module will cause a CRASH if you try to unload it
25902 - tristate "The IPv6 protocol"
25904 + bool "The IPv6 protocol"
25907 This is complemental support for the IP version 6.
25908 You will still be able to do traditional IPv4 networking as well.
25909 diff -NurpP --minimal linux-2.6.37/net/ipv6/ndisc.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/ndisc.c
25910 --- linux-2.6.37/net/ipv6/ndisc.c 2011-01-05 21:50:42.000000000 +0100
25911 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/ndisc.c 2010-11-23 02:09:41.000000000 +0100
25912 @@ -595,7 +595,7 @@ static void ndisc_send_na(struct net_dev
25914 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25915 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25917 + &tmpaddr, NULL /* FIXME: ? */ ))
25919 src_addr = &tmpaddr;
25921 diff -NurpP --minimal linux-2.6.37/net/ipv6/raw.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/raw.c
25922 --- linux-2.6.37/net/ipv6/raw.c 2011-01-05 21:50:42.000000000 +0100
25923 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/raw.c 2010-11-23 02:09:41.000000000 +0100
25925 #include <linux/icmpv6.h>
25926 #include <linux/netfilter.h>
25927 #include <linux/netfilter_ipv6.h>
25928 +#include <linux/vs_inet6.h>
25929 #include <linux/skbuff.h>
25930 #include <asm/uaccess.h>
25931 #include <asm/ioctls.h>
25932 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
25936 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25937 + err = -EADDRNOTAVAIL;
25943 /* ipv4 addr of the socket is invalid. Only the
25944 * unspecified and mapped address have a v4 equivalent.
25946 diff -NurpP --minimal linux-2.6.37/net/ipv6/route.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/route.c
25947 --- linux-2.6.37/net/ipv6/route.c 2011-01-05 21:50:42.000000000 +0100
25948 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/route.c 2011-01-05 22:30:43.000000000 +0100
25949 @@ -2290,7 +2290,8 @@ static int rt6_fill_node(struct net *net
25950 struct inet6_dev *idev = ip6_dst_idev(&rt->dst);
25951 struct in6_addr saddr_buf;
25952 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25953 - dst, 0, &saddr_buf) == 0)
25954 + dst, 0, &saddr_buf,
25955 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25956 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25959 diff -NurpP --minimal linux-2.6.37/net/ipv6/tcp_ipv6.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/tcp_ipv6.c
25960 --- linux-2.6.37/net/ipv6/tcp_ipv6.c 2011-01-05 21:50:42.000000000 +0100
25961 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/tcp_ipv6.c 2010-11-23 02:09:41.000000000 +0100
25964 #include <linux/crypto.h>
25965 #include <linux/scatterlist.h>
25966 +#include <linux/vs_inet6.h>
25968 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25969 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25970 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
25971 * connect() to INADDR_ANY means loopback (BSD'ism).
25974 - if(ipv6_addr_any(&usin->sin6_addr))
25975 - usin->sin6_addr.s6_addr[15] = 0x1;
25976 + if(ipv6_addr_any(&usin->sin6_addr)) {
25977 + struct nx_info *nxi = sk->sk_nx_info;
25979 + if (nxi && nx_info_has_v6(nxi))
25980 + /* FIXME: remap lback? */
25981 + usin->sin6_addr = nxi->v6.ip;
25983 + usin->sin6_addr.s6_addr[15] = 0x1;
25986 addr_type = ipv6_addr_type(&usin->sin6_addr);
25988 diff -NurpP --minimal linux-2.6.37/net/ipv6/udp.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/udp.c
25989 --- linux-2.6.37/net/ipv6/udp.c 2011-01-05 21:50:42.000000000 +0100
25990 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/udp.c 2011-01-05 22:30:43.000000000 +0100
25991 @@ -48,13 +48,14 @@
25993 #include <linux/proc_fs.h>
25994 #include <linux/seq_file.h>
25995 +#include <linux/vs_inet6.h>
25996 #include "udp_impl.h"
25998 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
26000 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
26001 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
26002 - __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
26003 + __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
26004 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26005 int sk_ipv6only = ipv6_only_sock(sk);
26006 int sk2_ipv6only = inet_v6_ipv6only(sk2);
26007 @@ -62,24 +63,49 @@ int ipv6_rcv_saddr_equal(const struct so
26008 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
26010 /* if both are mapped, treat as IPv4 */
26011 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
26012 - return (!sk2_ipv6only &&
26013 - (!sk1_rcv_saddr || !sk2_rcv_saddr ||
26014 - sk1_rcv_saddr == sk2_rcv_saddr));
26015 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
26016 + if (!sk2_ipv6only &&
26017 + (!sk_rcv_saddr || !sk2_rcv_saddr ||
26018 + sk_rcv_saddr == sk2_rcv_saddr))
26024 if (addr_type2 == IPV6_ADDR_ANY &&
26025 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
26029 if (addr_type == IPV6_ADDR_ANY &&
26030 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26034 if (sk2_rcv_saddr6 &&
26035 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
26042 + if (!sk_rcv_saddr && !sk2_rcv_saddr)
26043 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
26044 + if (!sk2_rcv_saddr)
26045 + return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
26046 + if (!sk_rcv_saddr)
26047 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
26050 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
26051 + return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
26052 + else if (addr_type2 == IPV6_ADDR_ANY)
26053 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
26054 + else if (addr_type == IPV6_ADDR_ANY) {
26055 + if (addr_type2 == IPV6_ADDR_MAPPED)
26056 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
26058 + return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
26063 static unsigned int udp6_portaddr_hash(struct net *net,
26064 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
26065 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26069 + /* block non nx_info ips */
26070 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26073 if (!ipv6_addr_any(&np->daddr)) {
26074 if (!ipv6_addr_equal(&np->daddr, saddr))
26075 diff -NurpP --minimal linux-2.6.37/net/ipv6/xfrm6_policy.c linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/xfrm6_policy.c
26076 --- linux-2.6.37/net/ipv6/xfrm6_policy.c 2011-01-05 21:50:42.000000000 +0100
26077 +++ linux-2.6.37-vs2.3.0.37-rc2/net/ipv6/xfrm6_policy.c 2010-11-23 02:09:41.000000000 +0100
26078 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
26079 dev = ip6_dst_idev(dst)->dev;
26080 ipv6_dev_get_saddr(dev_net(dev), dev,
26081 (struct in6_addr *)&daddr->a6, 0,
26082 - (struct in6_addr *)&saddr->a6);
26083 + (struct in6_addr *)&saddr->a6, NULL);
26087 diff -NurpP --minimal linux-2.6.37/net/netfilter/ipvs/ip_vs_xmit.c linux-2.6.37-vs2.3.0.37-rc2/net/netfilter/ipvs/ip_vs_xmit.c
26088 --- linux-2.6.37/net/netfilter/ipvs/ip_vs_xmit.c 2011-01-05 21:50:43.000000000 +0100
26089 +++ linux-2.6.37-vs2.3.0.37-rc2/net/netfilter/ipvs/ip_vs_xmit.c 2011-01-06 00:35:16.000000000 +0100
26090 @@ -231,7 +231,7 @@ __ip_vs_route_output_v6(struct net *net,
26092 if (ipv6_addr_any(&fl.fl6_src) &&
26093 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
26094 - &fl.fl6_dst, 0, &fl.fl6_src) < 0)
26095 + &fl.fl6_dst, 0, &fl.fl6_src, NULL) < 0)
26097 if (do_xfrm && xfrm_lookup(net, &dst, &fl, NULL, 0) < 0)
26099 diff -NurpP --minimal linux-2.6.37/net/netlink/af_netlink.c linux-2.6.37-vs2.3.0.37-rc2/net/netlink/af_netlink.c
26100 --- linux-2.6.37/net/netlink/af_netlink.c 2011-01-05 21:50:43.000000000 +0100
26101 +++ linux-2.6.37-vs2.3.0.37-rc2/net/netlink/af_netlink.c 2010-11-23 02:09:41.000000000 +0100
26103 #include <linux/types.h>
26104 #include <linux/audit.h>
26105 #include <linux/mutex.h>
26106 +#include <linux/vs_context.h>
26107 +#include <linux/vs_network.h>
26108 +#include <linux/vs_limit.h>
26110 #include <net/net_namespace.h>
26111 #include <net/sock.h>
26112 @@ -1912,6 +1915,8 @@ static struct sock *netlink_seq_socket_i
26113 sk_for_each(s, node, &hash->table[j]) {
26114 if (sock_net(s) != seq_file_net(seq))
26116 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26120 iter->hash_idx = j;
26121 @@ -1946,7 +1951,8 @@ static void *netlink_seq_next(struct seq
26125 - } while (s && sock_net(s) != seq_file_net(seq));
26126 + } while (s && (sock_net(s) != seq_file_net(seq) ||
26127 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
26131 @@ -1958,7 +1964,8 @@ static void *netlink_seq_next(struct seq
26133 for (; j <= hash->mask; j++) {
26134 s = sk_head(&hash->table[j]);
26135 - while (s && sock_net(s) != seq_file_net(seq))
26136 + while (s && (sock_net(s) != seq_file_net(seq) ||
26137 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
26141 diff -NurpP --minimal linux-2.6.37/net/sctp/ipv6.c linux-2.6.37-vs2.3.0.37-rc2/net/sctp/ipv6.c
26142 --- linux-2.6.37/net/sctp/ipv6.c 2011-01-05 21:50:45.000000000 +0100
26143 +++ linux-2.6.37-vs2.3.0.37-rc2/net/sctp/ipv6.c 2010-11-23 02:09:41.000000000 +0100
26144 @@ -306,7 +306,8 @@ static void sctp_v6_get_saddr(struct sct
26145 dst ? ip6_dst_idev(dst)->dev : NULL,
26146 &daddr->v6.sin6_addr,
26147 inet6_sk(&sk->inet.sk)->srcprefs,
26148 - &saddr->v6.sin6_addr);
26149 + &saddr->v6.sin6_addr,
26150 + asoc->base.sk->sk_nx_info);
26151 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
26152 &saddr->v6.sin6_addr);
26154 diff -NurpP --minimal linux-2.6.37/net/socket.c linux-2.6.37-vs2.3.0.37-rc2/net/socket.c
26155 --- linux-2.6.37/net/socket.c 2011-01-05 21:50:45.000000000 +0100
26156 +++ linux-2.6.37-vs2.3.0.37-rc2/net/socket.c 2011-01-05 22:30:44.000000000 +0100
26159 #include <net/sock.h>
26160 #include <linux/netfilter.h>
26161 +#include <linux/vs_base.h>
26162 +#include <linux/vs_socket.h>
26163 +#include <linux/vs_inet.h>
26164 +#include <linux/vs_inet6.h>
26166 #include <linux/if_tun.h>
26167 #include <linux/ipv6_route.h>
26168 @@ -550,7 +554,7 @@ static inline int __sock_sendmsg(struct
26169 struct msghdr *msg, size_t size)
26171 struct sock_iocb *si = kiocb_to_siocb(iocb);
26175 sock_update_classid(sock->sk);
26177 @@ -563,7 +567,22 @@ static inline int __sock_sendmsg(struct
26181 - return sock->ops->sendmsg(iocb, sock, msg, size);
26182 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26185 + vx_sock_send(sock->sk, size);
26187 + vx_sock_fail(sock->sk, size);
26189 + vxdprintk(VXD_CBIT(net, 7),
26190 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26192 + (sock->sk)?sock->sk->sk_nx_info:0,
26193 + (sock->sk)?sock->sk->sk_vx_info:0,
26194 + (sock->sk)?sock->sk->sk_xid:0,
26195 + (sock->sk)?sock->sk->sk_nid:0,
26196 + (unsigned int)size, len);
26200 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
26201 @@ -681,6 +700,7 @@ static inline int __sock_recvmsg_nosec(s
26202 struct msghdr *msg, size_t size, int flags)
26204 struct sock_iocb *si = kiocb_to_siocb(iocb);
26207 sock_update_classid(sock->sk);
26209 @@ -690,7 +710,18 @@ static inline int __sock_recvmsg_nosec(s
26213 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26214 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26215 + if ((len >= 0) && sock->sk)
26216 + vx_sock_recv(sock->sk, len);
26217 + vxdprintk(VXD_CBIT(net, 7),
26218 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26220 + (sock->sk)?sock->sk->sk_nx_info:0,
26221 + (sock->sk)?sock->sk->sk_vx_info:0,
26222 + (sock->sk)?sock->sk->sk_xid:0,
26223 + (sock->sk)?sock->sk->sk_nid:0,
26224 + (unsigned int)size, len);
26228 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26229 @@ -1174,6 +1205,13 @@ int __sock_create(struct net *net, int f
26230 if (type < 0 || type >= SOCK_MAX)
26233 + if (!nx_check(0, VS_ADMIN)) {
26234 + if (family == PF_INET && !current_nx_info_has_v4())
26235 + return -EAFNOSUPPORT;
26236 + if (family == PF_INET6 && !current_nx_info_has_v6())
26237 + return -EAFNOSUPPORT;
26242 This uglymoron is moved from INET layer to here to avoid
26243 @@ -1309,6 +1347,7 @@ SYSCALL_DEFINE3(socket, int, family, int
26247 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26248 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
26251 @@ -1350,10 +1389,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
26252 err = sock_create(family, type, protocol, &sock1);
26255 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26257 err = sock_create(family, type, protocol, &sock2);
26259 goto out_release_1;
26260 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26262 err = sock1->ops->socketpair(sock1, sock2);
26264 diff -NurpP --minimal linux-2.6.37/net/sunrpc/auth.c linux-2.6.37-vs2.3.0.37-rc2/net/sunrpc/auth.c
26265 --- linux-2.6.37/net/sunrpc/auth.c 2011-01-05 21:50:45.000000000 +0100
26266 +++ linux-2.6.37-vs2.3.0.37-rc2/net/sunrpc/auth.c 2010-11-23 02:09:41.000000000 +0100
26268 #include <linux/hash.h>
26269 #include <linux/sunrpc/clnt.h>
26270 #include <linux/spinlock.h>
26271 +#include <linux/vs_tag.h>
26274 # define RPCDBG_FACILITY RPCDBG_AUTH
26275 @@ -425,6 +426,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26276 memset(&acred, 0, sizeof(acred));
26277 acred.uid = cred->fsuid;
26278 acred.gid = cred->fsgid;
26279 + acred.tag = dx_current_tag();
26280 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
26282 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
26283 @@ -465,6 +467,7 @@ rpcauth_bind_root_cred(struct rpc_task *
26284 struct auth_cred acred = {
26287 + .tag = dx_current_tag(),
26290 dprintk("RPC: %5u looking up %s cred\n",
26291 diff -NurpP --minimal linux-2.6.37/net/sunrpc/auth_unix.c linux-2.6.37-vs2.3.0.37-rc2/net/sunrpc/auth_unix.c
26292 --- linux-2.6.37/net/sunrpc/auth_unix.c 2010-10-21 13:08:01.000000000 +0200
26293 +++ linux-2.6.37-vs2.3.0.37-rc2/net/sunrpc/auth_unix.c 2010-11-23 02:09:41.000000000 +0100
26294 @@ -12,12 +12,14 @@
26295 #include <linux/module.h>
26296 #include <linux/sunrpc/clnt.h>
26297 #include <linux/sunrpc/auth.h>
26298 +#include <linux/vs_tag.h>
26300 #define NFS_NGROUPS 16
26303 struct rpc_cred uc_base;
26306 gid_t uc_gids[NFS_NGROUPS];
26308 #define uc_uid uc_base.cr_uid
26309 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
26310 groups = NFS_NGROUPS;
26312 cred->uc_gid = acred->gid;
26313 + cred->uc_tag = acred->tag;
26314 for (i = 0; i < groups; i++)
26315 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26316 if (i < NFS_NGROUPS)
26317 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
26321 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
26322 + if (cred->uc_uid != acred->uid ||
26323 + cred->uc_gid != acred->gid ||
26324 + cred->uc_tag != acred->tag)
26327 if (acred->group_info != NULL)
26328 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
26329 struct rpc_clnt *clnt = task->tk_client;
26330 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
26331 __be32 *base, *hold;
26335 *p++ = htonl(RPC_AUTH_UNIX);
26337 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
26338 * Copy the UTS nodename captured when the client was created.
26340 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26341 + tag = task->tk_client->cl_tag;
26343 - *p++ = htonl((u32) cred->uc_uid);
26344 - *p++ = htonl((u32) cred->uc_gid);
26345 + *p++ = htonl((u32) TAGINO_UID(tag,
26346 + cred->uc_uid, cred->uc_tag));
26347 + *p++ = htonl((u32) TAGINO_GID(tag,
26348 + cred->uc_gid, cred->uc_tag));
26350 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
26351 *p++ = htonl((u32) cred->uc_gids[i]);
26352 diff -NurpP --minimal linux-2.6.37/net/sunrpc/clnt.c linux-2.6.37-vs2.3.0.37-rc2/net/sunrpc/clnt.c
26353 --- linux-2.6.37/net/sunrpc/clnt.c 2011-01-05 21:50:45.000000000 +0100
26354 +++ linux-2.6.37-vs2.3.0.37-rc2/net/sunrpc/clnt.c 2011-01-05 22:30:44.000000000 +0100
26356 #include <linux/utsname.h>
26357 #include <linux/workqueue.h>
26358 #include <linux/in6.h>
26359 +#include <linux/vs_cvirt.h>
26361 #include <linux/sunrpc/clnt.h>
26362 #include <linux/sunrpc/rpc_pipe_fs.h>
26363 @@ -359,6 +360,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
26364 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
26365 clnt->cl_chatty = 1;
26367 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
26368 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
26369 + clnt->cl_tag = 1; */
26372 EXPORT_SYMBOL_GPL(rpc_create);
26373 diff -NurpP --minimal linux-2.6.37/net/unix/af_unix.c linux-2.6.37-vs2.3.0.37-rc2/net/unix/af_unix.c
26374 --- linux-2.6.37/net/unix/af_unix.c 2011-01-05 21:50:46.000000000 +0100
26375 +++ linux-2.6.37-vs2.3.0.37-rc2/net/unix/af_unix.c 2011-01-05 22:30:44.000000000 +0100
26376 @@ -114,6 +114,8 @@
26377 #include <linux/mount.h>
26378 #include <net/checksum.h>
26379 #include <linux/security.h>
26380 +#include <linux/vs_context.h>
26381 +#include <linux/vs_limit.h>
26383 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
26384 static DEFINE_SPINLOCK(unix_table_lock);
26385 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
26386 if (!net_eq(sock_net(s), net))
26389 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26391 if (u->addr->len == len &&
26392 !memcmp(u->addr->name, sunname, len))
26394 @@ -2179,6 +2183,8 @@ static struct sock *unix_seq_idx(struct
26395 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
26396 if (sock_net(s) != seq_file_net(seq))
26398 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26403 @@ -2203,7 +2209,8 @@ static void *unix_seq_next(struct seq_fi
26404 sk = first_unix_socket(&iter->i);
26406 sk = next_unix_socket(&iter->i, sk);
26407 - while (sk && (sock_net(sk) != seq_file_net(seq)))
26408 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
26409 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
26410 sk = next_unix_socket(&iter->i, sk);
26413 diff -NurpP --minimal linux-2.6.37/scripts/checksyscalls.sh linux-2.6.37-vs2.3.0.37-rc2/scripts/checksyscalls.sh
26414 --- linux-2.6.37/scripts/checksyscalls.sh 2010-10-21 13:08:01.000000000 +0200
26415 +++ linux-2.6.37-vs2.3.0.37-rc2/scripts/checksyscalls.sh 2010-11-23 02:09:41.000000000 +0100
26416 @@ -193,7 +193,6 @@ cat << EOF
26417 #define __IGNORE_afs_syscall
26418 #define __IGNORE_getpmsg
26419 #define __IGNORE_putpmsg
26420 -#define __IGNORE_vserver
26424 diff -NurpP --minimal linux-2.6.37/security/commoncap.c linux-2.6.37-vs2.3.0.37-rc2/security/commoncap.c
26425 --- linux-2.6.37/security/commoncap.c 2011-01-05 21:50:47.000000000 +0100
26426 +++ linux-2.6.37-vs2.3.0.37-rc2/security/commoncap.c 2010-11-23 02:21:20.000000000 +0100
26428 #include <linux/sched.h>
26429 #include <linux/prctl.h>
26430 #include <linux/securebits.h>
26431 +// #include <linux/vs_context.h>
26434 * If a non-root user executes a setuid-root binary in
26435 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
26437 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
26439 - NETLINK_CB(skb).eff_cap = current_cap();
26440 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
26444 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
26449 EXPORT_SYMBOL(cap_netlink_recv);
26452 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
26453 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
26456 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26457 + struct vx_info *vxi = tsk->vx_info;
26460 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
26461 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
26462 + cap_raised(tsk->cap_effective, cap),
26463 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
26466 + /* special case SETUP */
26467 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26468 + /* FIXME: maybe use cred instead? */
26469 + cap_raised(tsk->cred->cap_effective, cap))
26472 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26476 @@ -570,7 +587,7 @@ int cap_inode_setxattr(struct dentry *de
26478 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26479 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26480 - !capable(CAP_SYS_ADMIN))
26481 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26485 @@ -596,7 +613,7 @@ int cap_inode_removexattr(struct dentry
26487 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26488 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26489 - !capable(CAP_SYS_ADMIN))
26490 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26494 @@ -929,3 +946,4 @@ int cap_file_mmap(struct file *file, uns
26499 diff -NurpP --minimal linux-2.6.37/security/selinux/hooks.c linux-2.6.37-vs2.3.0.37-rc2/security/selinux/hooks.c
26500 --- linux-2.6.37/security/selinux/hooks.c 2011-01-05 21:50:47.000000000 +0100
26501 +++ linux-2.6.37-vs2.3.0.37-rc2/security/selinux/hooks.c 2010-11-23 02:09:41.000000000 +0100
26503 #include <linux/dccp.h>
26504 #include <linux/quota.h>
26505 #include <linux/un.h> /* for Unix socket types */
26506 -#include <net/af_unix.h> /* for Unix socket types */
26507 #include <linux/parser.h>
26508 #include <linux/nfs_mount.h>
26509 #include <net/ipv6.h>