1 diff -NurpP --minimal linux-2.6.37/arch/alpha/Kconfig linux-2.6.37-vs2.3.0.37-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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(&lo->lo_ctl_mutex);
1118 mutex_unlock(&lo->lo_ctl_mutex);
1119 diff -NurpP --minimal linux-2.6.37/drivers/block/Makefile linux-2.6.37-vs2.3.0.37-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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 task_context_switch_counts(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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/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-rc3/include/linux/cred.h 2011-01-31 21:05:40.000000000 +0100
8517 @@ -155,6 +155,7 @@ extern void exit_creds(struct task_struc
8518 extern int copy_creds(struct task_struct *, unsigned long);
8519 extern const struct cred *get_task_cred(struct task_struct *);
8520 extern struct cred *cred_alloc_blank(void);
8521 +extern struct cred *__prepare_creds(const struct cred *);
8522 extern struct cred *prepare_creds(void);
8523 extern struct cred *prepare_exec_creds(void);
8524 extern int commit_creds(struct cred *);
8525 @@ -208,6 +209,31 @@ static inline void validate_process_cred
8529 +static inline void set_cred_subscribers(struct cred *cred, int n)
8531 +#ifdef CONFIG_DEBUG_CREDENTIALS
8532 + atomic_set(&cred->subscribers, n);
8536 +static inline int read_cred_subscribers(const struct cred *cred)
8538 +#ifdef CONFIG_DEBUG_CREDENTIALS
8539 + return atomic_read(&cred->subscribers);
8545 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
8547 +#ifdef CONFIG_DEBUG_CREDENTIALS
8548 + struct cred *cred = (struct cred *) _cred;
8550 + atomic_add(n, &cred->subscribers);
8555 * get_new_cred - Get a reference on a new set of credentials
8556 * @cred: The new credentials to reference
8557 diff -NurpP --minimal linux-2.6.37/include/linux/devpts_fs.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/devpts_fs.h
8558 --- linux-2.6.37/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8559 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/devpts_fs.h 2010-11-23 02:09:41.000000000 +0100
8560 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8565 #endif /* _LINUX_DEVPTS_FS_H */
8566 diff -NurpP --minimal linux-2.6.37/include/linux/ext2_fs.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/ext2_fs.h
8567 --- linux-2.6.37/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
8568 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/ext2_fs.h 2010-11-23 02:09:41.000000000 +0100
8569 @@ -189,8 +189,12 @@ struct ext2_group_desc
8570 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8571 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8572 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8573 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8574 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8576 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8577 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8579 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8580 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8582 @@ -274,7 +278,8 @@ struct ext2_inode {
8584 __le16 l_i_uid_high; /* these 2 fields */
8585 __le16 l_i_gid_high; /* were reserved2[0] */
8586 - __u32 l_i_reserved2;
8587 + __le16 l_i_tag; /* Context Tag */
8588 + __u16 l_i_reserved2;
8591 __u8 h_i_frag; /* Fragment number */
8592 @@ -303,6 +308,7 @@ struct ext2_inode {
8593 #define i_gid_low i_gid
8594 #define i_uid_high osd2.linux2.l_i_uid_high
8595 #define i_gid_high osd2.linux2.l_i_gid_high
8596 +#define i_raw_tag osd2.linux2.l_i_tag
8597 #define i_reserved2 osd2.linux2.l_i_reserved2
8600 @@ -347,6 +353,7 @@ struct ext2_inode {
8601 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8602 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8603 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8604 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8607 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8608 diff -NurpP --minimal linux-2.6.37/include/linux/ext3_fs.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/ext3_fs.h
8609 --- linux-2.6.37/include/linux/ext3_fs.h 2010-10-21 13:07:53.000000000 +0200
8610 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/ext3_fs.h 2010-11-23 02:09:41.000000000 +0100
8611 @@ -173,10 +173,14 @@ struct ext3_group_desc
8612 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8613 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8614 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8615 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8616 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8618 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8619 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8620 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8621 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8623 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8624 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8626 /* Flags that should be inherited by new inodes from their parent. */
8627 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8628 @@ -312,7 +316,8 @@ struct ext3_inode {
8630 __le16 l_i_uid_high; /* these 2 fields */
8631 __le16 l_i_gid_high; /* were reserved2[0] */
8632 - __u32 l_i_reserved2;
8633 + __le16 l_i_tag; /* Context Tag */
8634 + __u16 l_i_reserved2;
8637 __u8 h_i_frag; /* Fragment number */
8638 @@ -343,6 +348,7 @@ struct ext3_inode {
8639 #define i_gid_low i_gid
8640 #define i_uid_high osd2.linux2.l_i_uid_high
8641 #define i_gid_high osd2.linux2.l_i_gid_high
8642 +#define i_raw_tag osd2.linux2.l_i_tag
8643 #define i_reserved2 osd2.linux2.l_i_reserved2
8645 #elif defined(__GNU__)
8646 @@ -405,6 +411,7 @@ struct ext3_inode {
8647 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8648 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8649 * error in ordered mode */
8650 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8652 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8653 #ifndef _LINUX_EXT2_FS_H
8654 @@ -908,6 +915,7 @@ extern void ext3_get_inode_flags(struct
8655 extern void ext3_set_aops(struct inode *inode);
8656 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8657 u64 start, u64 len);
8658 +extern int ext3_sync_flags(struct inode *, int, int);
8661 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8662 diff -NurpP --minimal linux-2.6.37/include/linux/fs.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/fs.h
8663 --- linux-2.6.37/include/linux/fs.h 2011-01-05 21:50:30.000000000 +0100
8664 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/fs.h 2011-01-05 22:30:40.000000000 +0100
8665 @@ -214,6 +214,9 @@ struct inodes_stat_t {
8666 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8667 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8668 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8669 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8670 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8671 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8672 #define MS_BORN (1<<29)
8673 #define MS_ACTIVE (1<<30)
8674 #define MS_NOUSER (1<<31)
8675 @@ -242,6 +245,14 @@ struct inodes_stat_t {
8676 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
8677 #define S_PRIVATE 512 /* Inode is fs-internal */
8678 #define S_IMA 1024 /* Inode has an associated IMA struct */
8679 +#define S_IXUNLINK 2048 /* Immutable Invert on unlink */
8681 +/* Linux-VServer related Inode flags */
8685 +#define V_BARRIER 4 /* Barrier for chroot() */
8686 +#define V_COW 8 /* Copy on Write */
8689 * Note that nosuid etc flags are inode-specific: setting some file-system
8690 @@ -264,12 +275,15 @@ struct inodes_stat_t {
8691 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8692 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8693 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8694 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8695 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8696 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8697 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8698 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8700 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8701 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8702 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8703 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8704 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8705 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8707 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8708 @@ -278,6 +292,16 @@ struct inodes_stat_t {
8709 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
8710 #define IS_IMA(inode) ((inode)->i_flags & S_IMA)
8712 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8714 +#ifdef CONFIG_VSERVER_COWBL
8715 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8716 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8718 +# define IS_COW(inode) (0)
8719 +# define IS_COW_LINK(inode) (0)
8722 /* the read-only stuff doesn't really belong here, but any other place is
8723 probably as bad and I don't want to create yet another include file. */
8725 @@ -362,11 +386,14 @@ struct inodes_stat_t {
8726 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8727 #define FS_EXTENT_FL 0x00080000 /* Extents */
8728 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8729 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8730 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8732 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8733 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8734 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8735 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8737 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8738 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8740 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8741 #define SYNC_FILE_RANGE_WRITE 2
8742 @@ -446,6 +473,7 @@ typedef void (dio_iodone_t)(struct kiocb
8743 #define ATTR_KILL_PRIV (1 << 14)
8744 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8745 #define ATTR_TIMES_SET (1 << 16)
8746 +#define ATTR_TAG (1 << 17)
8749 * This is the Inode Attributes structure, used for notify_change(). It
8750 @@ -461,6 +489,7 @@ struct iattr {
8756 struct timespec ia_atime;
8757 struct timespec ia_mtime;
8758 @@ -474,6 +503,9 @@ struct iattr {
8759 struct file *ia_file;
8762 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8763 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8766 * Includes for diskquotas.
8768 @@ -743,7 +775,9 @@ struct inode {
8769 unsigned int i_nlink;
8775 unsigned int i_blkbits;
8778 @@ -785,7 +819,8 @@ struct inode {
8779 unsigned long i_state;
8780 unsigned long dirtied_when; /* jiffies of first dirtying */
8782 - unsigned int i_flags;
8783 + unsigned short i_flags;
8784 + unsigned short i_vflags;
8787 /* protected by i_lock */
8788 @@ -882,12 +917,12 @@ static inline void i_size_write(struct i
8790 static inline unsigned iminor(const struct inode *inode)
8792 - return MINOR(inode->i_rdev);
8793 + return MINOR(inode->i_mdev);
8796 static inline unsigned imajor(const struct inode *inode)
8798 - return MAJOR(inode->i_rdev);
8799 + return MAJOR(inode->i_mdev);
8802 extern struct block_device *I_BDEV(struct inode *inode);
8803 @@ -949,6 +984,7 @@ struct file {
8805 struct fown_struct f_owner;
8806 const struct cred *f_cred;
8808 struct file_ra_state f_ra;
8811 @@ -1087,6 +1123,7 @@ struct file_lock {
8812 struct file *fl_file;
8817 struct fasync_struct * fl_fasync; /* for lease break notifications */
8818 unsigned long fl_break_time; /* for nonblocking lease breaks */
8819 @@ -1568,6 +1605,7 @@ struct inode_operations {
8820 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8821 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8822 int (*removexattr) (struct dentry *, const char *);
8823 + int (*sync_flags) (struct inode *, int, int);
8824 void (*truncate_range)(struct inode *, loff_t, loff_t);
8825 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
8827 @@ -1588,6 +1626,7 @@ extern ssize_t vfs_readv(struct file *,
8828 unsigned long, loff_t *);
8829 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8830 unsigned long, loff_t *);
8831 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8833 struct super_operations {
8834 struct inode *(*alloc_inode)(struct super_block *sb);
8835 @@ -2389,6 +2428,7 @@ extern int dcache_dir_open(struct inode
8836 extern int dcache_dir_close(struct inode *, struct file *);
8837 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8838 extern int dcache_readdir(struct file *, void *, filldir_t);
8839 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8840 extern int simple_setattr(struct dentry *, struct iattr *);
8841 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8842 extern int simple_statfs(struct dentry *, struct kstatfs *);
8843 diff -NurpP --minimal linux-2.6.37/include/linux/gfs2_ondisk.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/gfs2_ondisk.h
8844 --- linux-2.6.37/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8845 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/gfs2_ondisk.h 2010-11-23 02:09:41.000000000 +0100
8846 @@ -211,6 +211,9 @@ enum {
8850 + gfs2fl_IXUnlink = 16,
8851 + gfs2fl_Barrier = 17,
8853 gfs2fl_TruncInProg = 29,
8854 gfs2fl_InheritDirectio = 30,
8855 gfs2fl_InheritJdata = 31,
8856 @@ -227,6 +230,9 @@ enum {
8857 #define GFS2_DIF_NOATIME 0x00000080
8858 #define GFS2_DIF_SYNC 0x00000100
8859 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8860 +#define GFS2_DIF_IXUNLINK 0x00010000
8861 +#define GFS2_DIF_BARRIER 0x00020000
8862 +#define GFS2_DIF_COW 0x00040000
8863 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8864 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8865 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8866 diff -NurpP --minimal linux-2.6.37/include/linux/if_tun.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/if_tun.h
8867 --- linux-2.6.37/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8868 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/if_tun.h 2010-11-23 02:09:41.000000000 +0100
8870 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8871 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8872 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8873 +#define TUNSETNID _IOW('T', 217, int)
8875 /* TUNSETIFF ifr flags */
8876 #define IFF_TUN 0x0001
8877 diff -NurpP --minimal linux-2.6.37/include/linux/init_task.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/init_task.h
8878 --- linux-2.6.37/include/linux/init_task.h 2011-01-05 21:50:30.000000000 +0100
8879 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/init_task.h 2010-11-23 02:09:41.000000000 +0100
8880 @@ -178,6 +178,10 @@ extern struct cred init_cred;
8882 INIT_TRACE_RECURSION \
8883 INIT_TASK_RCU_PREEMPT(tsk) \
8885 + .vx_info = NULL, \
8887 + .nx_info = NULL, \
8891 diff -NurpP --minimal linux-2.6.37/include/linux/ipc.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/ipc.h
8892 --- linux-2.6.37/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8893 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/ipc.h 2010-11-23 02:09:41.000000000 +0100
8894 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8902 diff -NurpP --minimal linux-2.6.37/include/linux/Kbuild linux-2.6.37-vs2.3.0.37-rc3/include/linux/Kbuild
8903 --- linux-2.6.37/include/linux/Kbuild 2011-01-05 21:50:28.000000000 +0100
8904 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/Kbuild 2010-11-23 02:09:41.000000000 +0100
8905 @@ -15,6 +15,7 @@ header-y += netfilter_bridge/
8906 header-y += netfilter_ipv4/
8907 header-y += netfilter_ipv6/
8909 +header-y += vserver/
8912 objhdr-y += version.h
8913 diff -NurpP --minimal linux-2.6.37/include/linux/loop.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/loop.h
8914 --- linux-2.6.37/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
8915 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/loop.h 2010-11-23 02:09:41.000000000 +0100
8916 @@ -45,6 +45,7 @@ struct loop_device {
8917 struct loop_func_table *lo_encryption;
8919 uid_t lo_key_owner; /* Who set the key */
8921 int (*ioctl)(struct loop_device *, int cmd,
8924 diff -NurpP --minimal linux-2.6.37/include/linux/magic.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/magic.h
8925 --- linux-2.6.37/include/linux/magic.h 2011-01-05 21:50:30.000000000 +0100
8926 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/magic.h 2010-11-23 02:09:41.000000000 +0100
8929 #define ADFS_SUPER_MAGIC 0xadf5
8930 #define AFFS_SUPER_MAGIC 0xadff
8931 -#define AFS_SUPER_MAGIC 0x5346414F
8932 +#define AFS_SUPER_MAGIC 0x5346414F
8933 #define AUTOFS_SUPER_MAGIC 0x0187
8934 #define CODA_SUPER_MAGIC 0x73757245
8935 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8937 #define NFS_SUPER_MAGIC 0x6969
8938 #define OPENPROM_SUPER_MAGIC 0x9fa1
8939 #define PROC_SUPER_MAGIC 0x9fa0
8940 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8941 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8943 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8944 diff -NurpP --minimal linux-2.6.37/include/linux/major.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/major.h
8945 --- linux-2.6.37/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8946 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/major.h 2010-11-23 02:09:41.000000000 +0100
8948 #define HD_MAJOR IDE0_MAJOR
8949 #define PTY_SLAVE_MAJOR 3
8951 +#define VROOT_MAJOR 4
8952 #define TTYAUX_MAJOR 5
8955 diff -NurpP --minimal linux-2.6.37/include/linux/memcontrol.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/memcontrol.h
8956 --- linux-2.6.37/include/linux/memcontrol.h 2010-10-21 13:07:53.000000000 +0200
8957 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/memcontrol.h 2010-11-23 02:09:41.000000000 +0100
8958 @@ -77,6 +77,13 @@ int task_in_mem_cgroup(struct task_struc
8959 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
8960 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8962 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8963 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8965 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8966 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8967 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8970 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8972 diff -NurpP --minimal linux-2.6.37/include/linux/mm_types.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/mm_types.h
8973 --- linux-2.6.37/include/linux/mm_types.h 2011-01-05 21:50:31.000000000 +0100
8974 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/mm_types.h 2010-11-23 02:09:41.000000000 +0100
8975 @@ -269,6 +269,7 @@ struct mm_struct {
8977 /* Architecture-specific MM context */
8978 mm_context_t context;
8979 + struct vx_info *mm_vx_info;
8981 /* Swap token stuff */
8983 diff -NurpP --minimal linux-2.6.37/include/linux/mount.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/mount.h
8984 --- linux-2.6.37/include/linux/mount.h 2010-10-21 13:07:53.000000000 +0200
8985 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/mount.h 2010-11-23 02:09:41.000000000 +0100
8986 @@ -46,6 +46,9 @@ struct mnt_namespace;
8988 #define MNT_INTERNAL 0x4000
8990 +#define MNT_TAGID 0x10000
8991 +#define MNT_NOTAG 0x20000
8994 struct list_head mnt_hash;
8995 struct vfsmount *mnt_parent; /* fs we are mounted on */
8996 @@ -84,6 +87,7 @@ struct vfsmount {
9000 + tag_t mnt_tag; /* tagging used for vfsmount */
9003 static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
9004 diff -NurpP --minimal linux-2.6.37/include/linux/net.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/net.h
9005 --- linux-2.6.37/include/linux/net.h 2011-01-05 21:50:31.000000000 +0100
9006 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/net.h 2010-11-23 02:09:41.000000000 +0100
9007 @@ -71,6 +71,7 @@ struct net;
9008 #define SOCK_NOSPACE 2
9009 #define SOCK_PASSCRED 3
9010 #define SOCK_PASSSEC 4
9011 +#define SOCK_USER_SOCKET 5
9013 #ifndef ARCH_HAS_SOCKET_TYPES
9015 diff -NurpP --minimal linux-2.6.37/include/linux/nfs_mount.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/nfs_mount.h
9016 --- linux-2.6.37/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
9017 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/nfs_mount.h 2010-11-23 02:09:41.000000000 +0100
9018 @@ -63,7 +63,8 @@ struct nfs_mount_data {
9019 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
9020 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
9021 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
9022 -#define NFS_MOUNT_FLAGMASK 0xFFFF
9023 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
9024 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
9026 /* The following are for internal use only */
9027 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
9028 diff -NurpP --minimal linux-2.6.37/include/linux/nsproxy.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/nsproxy.h
9029 --- linux-2.6.37/include/linux/nsproxy.h 2009-06-11 17:13:17.000000000 +0200
9030 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/nsproxy.h 2010-11-23 02:09:41.000000000 +0100
9033 #include <linux/spinlock.h>
9034 #include <linux/sched.h>
9035 +#include <linux/vserver/debug.h>
9037 struct mnt_namespace;
9038 struct uts_namespace;
9039 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
9042 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
9043 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
9044 void exit_task_namespaces(struct task_struct *tsk);
9045 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
9046 void free_nsproxy(struct nsproxy *ns);
9047 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
9048 struct fs_struct *);
9050 -static inline void put_nsproxy(struct nsproxy *ns)
9051 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
9053 +static inline void __get_nsproxy(struct nsproxy *ns,
9054 + const char *_file, int _line)
9056 - if (atomic_dec_and_test(&ns->count)) {
9059 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
9060 + ns, atomic_read(&ns->count), _file, _line);
9061 + atomic_inc(&ns->count);
9064 -static inline void get_nsproxy(struct nsproxy *ns)
9065 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
9067 +static inline void __put_nsproxy(struct nsproxy *ns,
9068 + const char *_file, int _line)
9070 - atomic_inc(&ns->count);
9071 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
9072 + ns, atomic_read(&ns->count), _file, _line);
9073 + if (atomic_dec_and_test(&ns->count)) {
9078 #ifdef CONFIG_CGROUP_NS
9079 diff -NurpP --minimal linux-2.6.37/include/linux/pid.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/pid.h
9080 --- linux-2.6.37/include/linux/pid.h 2009-03-24 14:22:43.000000000 +0100
9081 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/pid.h 2010-11-23 02:09:41.000000000 +0100
9082 @@ -8,7 +8,8 @@ enum pid_type
9092 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
9095 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
9096 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
9097 pid_t pid_vnr(struct pid *pid);
9099 #define do_each_pid_task(pid, type, task) \
9100 diff -NurpP --minimal linux-2.6.37/include/linux/proc_fs.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/proc_fs.h
9101 --- linux-2.6.37/include/linux/proc_fs.h 2009-12-03 20:02:56.000000000 +0100
9102 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/proc_fs.h 2010-11-23 02:09:41.000000000 +0100
9103 @@ -56,6 +56,7 @@ struct proc_dir_entry {
9109 const struct inode_operations *proc_iops;
9111 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void
9112 extern void kclist_add(struct kcore_list *, void *, size_t, int type);
9119 int (*proc_get_link)(struct inode *, struct path *);
9120 int (*proc_read)(struct task_struct *task, char *page);
9121 int (*proc_show)(struct seq_file *m,
9122 struct pid_namespace *ns, struct pid *pid,
9123 struct task_struct *task);
9124 + int (*proc_vs_read)(char *page);
9125 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
9126 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
9129 struct ctl_table_header;
9130 @@ -263,6 +270,7 @@ struct ctl_table;
9137 struct proc_dir_entry *pde;
9138 diff -NurpP --minimal linux-2.6.37/include/linux/quotaops.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/quotaops.h
9139 --- linux-2.6.37/include/linux/quotaops.h 2010-10-21 13:07:54.000000000 +0200
9140 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/quotaops.h 2010-11-23 02:09:41.000000000 +0100
9142 #define _LINUX_QUOTAOPS_
9144 #include <linux/fs.h>
9145 +#include <linux/vs_dlimit.h>
9147 #define DQUOT_SPACE_WARN 0x1
9148 #define DQUOT_SPACE_RESERVE 0x2
9149 @@ -205,11 +206,12 @@ static inline void dquot_drop(struct ino
9151 static inline int dquot_alloc_inode(const struct inode *inode)
9154 + return dl_alloc_inode(inode);
9157 static inline void dquot_free_inode(const struct inode *inode)
9159 + dl_free_inode(inode);
9162 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
9163 @@ -220,6 +222,10 @@ static inline int dquot_transfer(struct
9164 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
9169 + if ((ret = dl_alloc_space(inode, number)))
9171 if (!(flags & DQUOT_SPACE_RESERVE))
9172 inode_add_bytes(inode, number);
9174 @@ -230,6 +236,7 @@ static inline void __dquot_free_space(st
9176 if (!(flags & DQUOT_SPACE_RESERVE))
9177 inode_sub_bytes(inode, number);
9178 + dl_free_space(inode, number);
9181 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
9182 diff -NurpP --minimal linux-2.6.37/include/linux/reboot.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/reboot.h
9183 --- linux-2.6.37/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
9184 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/reboot.h 2010-11-23 02:09:41.000000000 +0100
9186 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
9187 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
9188 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
9189 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
9193 diff -NurpP --minimal linux-2.6.37/include/linux/reiserfs_fs.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/reiserfs_fs.h
9194 --- linux-2.6.37/include/linux/reiserfs_fs.h 2011-01-05 21:50:32.000000000 +0100
9195 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/reiserfs_fs.h 2010-11-23 02:09:41.000000000 +0100
9196 @@ -976,6 +976,11 @@ struct stat_data_v1 {
9197 #define REISERFS_COMPR_FL FS_COMPR_FL
9198 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
9200 +/* unfortunately reiserfs sdattr is only 16 bit */
9201 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
9202 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
9203 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
9205 /* persistent flags that file inherits from the parent directory */
9206 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
9207 REISERFS_SYNC_FL | \
9208 @@ -985,6 +990,9 @@ struct stat_data_v1 {
9209 REISERFS_COMPR_FL | \
9210 REISERFS_NOTAIL_FL )
9212 +#define REISERFS_FL_USER_VISIBLE 0x80FF
9213 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
9215 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
9218 @@ -2070,6 +2078,7 @@ static inline void reiserfs_update_sd(st
9219 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
9220 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
9221 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
9222 +int reiserfs_sync_flags(struct inode *inode, int, int);
9224 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
9226 diff -NurpP --minimal linux-2.6.37/include/linux/reiserfs_fs_sb.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/reiserfs_fs_sb.h
9227 --- linux-2.6.37/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
9228 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/reiserfs_fs_sb.h 2010-11-23 02:09:41.000000000 +0100
9229 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
9230 REISERFS_EXPOSE_PRIVROOT,
9231 REISERFS_BARRIER_NONE,
9232 REISERFS_BARRIER_FLUSH,
9235 /* Actions on error */
9236 REISERFS_ERROR_PANIC,
9237 diff -NurpP --minimal linux-2.6.37/include/linux/sched.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/sched.h
9238 --- linux-2.6.37/include/linux/sched.h 2011-01-05 21:50:32.000000000 +0100
9239 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/sched.h 2011-01-05 22:30:40.000000000 +0100
9240 @@ -1357,6 +1357,14 @@ struct task_struct {
9244 +/* vserver context data */
9245 + struct vx_info *vx_info;
9246 + struct nx_info *nx_info;
9252 /* Thread group tracking */
9255 @@ -1591,6 +1599,11 @@ struct pid_namespace;
9256 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9257 struct pid_namespace *ns);
9259 +#include <linux/vserver/base.h>
9260 +#include <linux/vserver/context.h>
9261 +#include <linux/vserver/debug.h>
9262 +#include <linux/vserver/pid.h>
9264 static inline pid_t task_pid_nr(struct task_struct *tsk)
9267 @@ -1604,7 +1617,8 @@ static inline pid_t task_pid_nr_ns(struc
9269 static inline pid_t task_pid_vnr(struct task_struct *tsk)
9271 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9272 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
9273 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
9277 @@ -1617,7 +1631,7 @@ pid_t task_tgid_nr_ns(struct task_struct
9279 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
9281 - return pid_vnr(task_tgid(tsk));
9282 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
9286 diff -NurpP --minimal linux-2.6.37/include/linux/shmem_fs.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/shmem_fs.h
9287 --- linux-2.6.37/include/linux/shmem_fs.h 2010-10-21 13:07:55.000000000 +0200
9288 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/shmem_fs.h 2010-11-23 02:09:41.000000000 +0100
9291 #define SHMEM_NR_DIRECT 16
9293 +#define TMPFS_SUPER_MAGIC 0x01021994
9296 struct shmem_inode_info {
9298 unsigned long flags;
9299 diff -NurpP --minimal linux-2.6.37/include/linux/stat.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/stat.h
9300 --- linux-2.6.37/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
9301 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/stat.h 2010-11-23 02:09:41.000000000 +0100
9302 @@ -66,6 +66,7 @@ struct kstat {
9309 struct timespec atime;
9310 diff -NurpP --minimal linux-2.6.37/include/linux/sunrpc/auth.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/sunrpc/auth.h
9311 --- linux-2.6.37/include/linux/sunrpc/auth.h 2011-01-05 21:50:33.000000000 +0100
9312 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/sunrpc/auth.h 2010-11-23 02:09:41.000000000 +0100
9318 struct group_info *group_info;
9319 unsigned char machine_cred : 1;
9321 diff -NurpP --minimal linux-2.6.37/include/linux/sunrpc/clnt.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/sunrpc/clnt.h
9322 --- linux-2.6.37/include/linux/sunrpc/clnt.h 2011-01-05 21:50:33.000000000 +0100
9323 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/sunrpc/clnt.h 2010-11-23 02:09:41.000000000 +0100
9324 @@ -49,7 +49,8 @@ struct rpc_clnt {
9325 unsigned int cl_softrtry : 1,/* soft timeouts */
9326 cl_discrtry : 1,/* disconnect before retry */
9327 cl_autobind : 1,/* use getport() */
9328 - cl_chatty : 1;/* be verbose */
9329 + cl_chatty : 1,/* be verbose */
9330 + cl_tag : 1;/* context tagging */
9332 struct rpc_rtt * cl_rtt; /* RTO estimator data */
9333 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
9334 diff -NurpP --minimal linux-2.6.37/include/linux/syscalls.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/syscalls.h
9335 --- linux-2.6.37/include/linux/syscalls.h 2011-01-05 21:50:34.000000000 +0100
9336 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/syscalls.h 2010-11-23 02:09:41.000000000 +0100
9337 @@ -478,6 +478,8 @@ asmlinkage long sys_symlink(const char _
9338 asmlinkage long sys_unlink(const char __user *pathname);
9339 asmlinkage long sys_rename(const char __user *oldname,
9340 const char __user *newname);
9341 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9343 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9344 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9346 diff -NurpP --minimal linux-2.6.37/include/linux/sysctl.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/sysctl.h
9347 --- linux-2.6.37/include/linux/sysctl.h 2010-08-02 16:52:56.000000000 +0200
9348 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/sysctl.h 2010-11-23 02:09:41.000000000 +0100
9349 @@ -60,6 +60,7 @@ enum
9350 CTL_ABI=9, /* Binary emulation */
9351 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9352 CTL_ARLAN=254, /* arlan wireless driver */
9353 + CTL_VSERVER=4242, /* Linux-VServer debug */
9354 CTL_S390DBF=5677, /* s390 debug */
9355 CTL_SUNRPC=7249, /* sunrpc debug */
9356 CTL_PM=9899, /* frv power management */
9357 @@ -94,6 +95,7 @@ enum
9359 KERN_PANIC=15, /* int: panic timeout */
9360 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9361 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9363 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9364 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9365 diff -NurpP --minimal linux-2.6.37/include/linux/sysfs.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/sysfs.h
9366 --- linux-2.6.37/include/linux/sysfs.h 2011-01-05 21:50:34.000000000 +0100
9367 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/sysfs.h 2010-11-23 02:09:41.000000000 +0100
9369 #include <linux/kobject_ns.h>
9370 #include <asm/atomic.h>
9372 +#define SYSFS_SUPER_MAGIC 0x62656572
9377 diff -NurpP --minimal linux-2.6.37/include/linux/time.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/time.h
9378 --- linux-2.6.37/include/linux/time.h 2010-10-21 13:07:55.000000000 +0200
9379 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/time.h 2010-11-23 02:09:41.000000000 +0100
9380 @@ -252,6 +252,9 @@ static __always_inline void timespec_add
9381 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9385 +#include <linux/vs_time.h>
9387 #endif /* __KERNEL__ */
9389 #define NFDBITS __NFDBITS
9390 diff -NurpP --minimal linux-2.6.37/include/linux/types.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/types.h
9391 --- linux-2.6.37/include/linux/types.h 2011-01-05 21:50:34.000000000 +0100
9392 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/types.h 2010-11-23 02:09:41.000000000 +0100
9393 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
9394 typedef __kernel_gid32_t gid_t;
9395 typedef __kernel_uid16_t uid16_t;
9396 typedef __kernel_gid16_t gid16_t;
9397 +typedef unsigned int xid_t;
9398 +typedef unsigned int nid_t;
9399 +typedef unsigned int tag_t;
9401 typedef unsigned long uintptr_t;
9403 diff -NurpP --minimal linux-2.6.37/include/linux/vroot.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vroot.h
9404 --- linux-2.6.37/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9405 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vroot.h 2010-11-23 02:09:41.000000000 +0100
9409 + * include/linux/vroot.h
9411 + * written by Herbert Pötzl, 9/11/2002
9412 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9414 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9415 + * Redistribution of this file is permitted under the
9416 + * GNU General Public License.
9419 +#ifndef _LINUX_VROOT_H
9420 +#define _LINUX_VROOT_H
9425 +/* Possible states of device */
9431 +struct vroot_device {
9435 + struct semaphore vr_ctl_mutex;
9436 + struct block_device *vr_device;
9441 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9443 +extern int register_vroot_grb(vroot_grb_func *);
9444 +extern int unregister_vroot_grb(vroot_grb_func *);
9446 +#endif /* __KERNEL__ */
9448 +#define MAX_VROOT_DEFAULT 8
9451 + * IOCTL commands --- we will commandeer 0x56 ('V')
9454 +#define VROOT_SET_DEV 0x5600
9455 +#define VROOT_CLR_DEV 0x5601
9457 +#endif /* _LINUX_VROOT_H */
9458 diff -NurpP --minimal linux-2.6.37/include/linux/vs_base.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_base.h
9459 --- linux-2.6.37/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9460 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_base.h 2010-11-23 02:09:41.000000000 +0100
9465 +#include "vserver/base.h"
9466 +#include "vserver/check.h"
9467 +#include "vserver/debug.h"
9470 +#warning duplicate inclusion
9472 diff -NurpP --minimal linux-2.6.37/include/linux/vs_context.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_context.h
9473 --- linux-2.6.37/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9474 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_context.h 2010-11-23 02:09:41.000000000 +0100
9476 +#ifndef _VS_CONTEXT_H
9477 +#define _VS_CONTEXT_H
9479 +#include "vserver/base.h"
9480 +#include "vserver/check.h"
9481 +#include "vserver/context.h"
9482 +#include "vserver/history.h"
9483 +#include "vserver/debug.h"
9485 +#include <linux/sched.h>
9488 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9490 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9491 + const char *_file, int _line, void *_here)
9496 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9497 + vxi, vxi ? vxi->vx_id : 0,
9498 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9500 + __vxh_get_vx_info(vxi, _here);
9502 + atomic_inc(&vxi->vx_usecnt);
9507 +extern void free_vx_info(struct vx_info *);
9509 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9511 +static inline void __put_vx_info(struct vx_info *vxi,
9512 + const char *_file, int _line, void *_here)
9517 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9518 + vxi, vxi ? vxi->vx_id : 0,
9519 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9521 + __vxh_put_vx_info(vxi, _here);
9523 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9524 + free_vx_info(vxi);
9528 +#define init_vx_info(p, i) \
9529 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9531 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9532 + const char *_file, int _line, void *_here)
9535 + vxlprintk(VXD_CBIT(xid, 3),
9536 + "init_vx_info(%p[#%d.%d])",
9537 + vxi, vxi ? vxi->vx_id : 0,
9538 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9540 + __vxh_init_vx_info(vxi, vxp, _here);
9542 + atomic_inc(&vxi->vx_usecnt);
9548 +#define set_vx_info(p, i) \
9549 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9551 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9552 + const char *_file, int _line, void *_here)
9554 + struct vx_info *vxo;
9559 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9560 + vxi, vxi ? vxi->vx_id : 0,
9561 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9563 + __vxh_set_vx_info(vxi, vxp, _here);
9565 + atomic_inc(&vxi->vx_usecnt);
9566 + vxo = xchg(vxp, vxi);
9571 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9573 +static inline void __clr_vx_info(struct vx_info **vxp,
9574 + const char *_file, int _line, void *_here)
9576 + struct vx_info *vxo;
9578 + vxo = xchg(vxp, NULL);
9582 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9583 + vxo, vxo ? vxo->vx_id : 0,
9584 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9586 + __vxh_clr_vx_info(vxo, vxp, _here);
9588 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9589 + free_vx_info(vxo);
9593 +#define claim_vx_info(v, p) \
9594 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9596 +static inline void __claim_vx_info(struct vx_info *vxi,
9597 + struct task_struct *task,
9598 + const char *_file, int _line, void *_here)
9600 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9601 + vxi, vxi ? vxi->vx_id : 0,
9602 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9603 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9604 + task, _file, _line);
9605 + __vxh_claim_vx_info(vxi, task, _here);
9607 + atomic_inc(&vxi->vx_tasks);
9611 +extern void unhash_vx_info(struct vx_info *);
9613 +#define release_vx_info(v, p) \
9614 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9616 +static inline void __release_vx_info(struct vx_info *vxi,
9617 + struct task_struct *task,
9618 + const char *_file, int _line, void *_here)
9620 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9621 + vxi, vxi ? vxi->vx_id : 0,
9622 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9623 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9624 + task, _file, _line);
9625 + __vxh_release_vx_info(vxi, task, _here);
9629 + if (atomic_dec_and_test(&vxi->vx_tasks))
9630 + unhash_vx_info(vxi);
9634 +#define task_get_vx_info(p) \
9635 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9637 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9638 + const char *_file, int _line, void *_here)
9640 + struct vx_info *vxi;
9643 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9645 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9651 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9653 + if (waitqueue_active(&vxi->vx_wait))
9654 + wake_up_interruptible(&vxi->vx_wait);
9658 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9660 +static inline void __enter_vx_info(struct vx_info *vxi,
9661 + struct vx_info_save *vxis, const char *_file, int _line)
9663 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9664 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9665 + current->xid, current->vx_info, _file, _line);
9666 + vxis->vxi = xchg(¤t->vx_info, vxi);
9667 + vxis->xid = current->xid;
9668 + current->xid = vxi ? vxi->vx_id : 0;
9671 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9673 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9674 + const char *_file, int _line)
9676 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9677 + vxis, vxis->xid, vxis->vxi, current,
9678 + current->xid, current->vx_info, _file, _line);
9679 + (void)xchg(¤t->vx_info, vxis->vxi);
9680 + current->xid = vxis->xid;
9684 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9686 + vxis->vxi = xchg(¤t->vx_info, NULL);
9687 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9690 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9692 + (void)xchg(¤t->xid, vxis->xid);
9693 + (void)xchg(¤t->vx_info, vxis->vxi);
9696 +#define task_is_init(p) \
9697 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9699 +static inline int __task_is_init(struct task_struct *p,
9700 + const char *_file, int _line, void *_here)
9702 + int is_init = is_global_init(p);
9706 + is_init = p->vx_info->vx_initpid == p->pid;
9711 +extern void exit_vx_info(struct task_struct *, int);
9712 +extern void exit_vx_info_early(struct task_struct *, int);
9716 +#warning duplicate inclusion
9718 diff -NurpP --minimal linux-2.6.37/include/linux/vs_cowbl.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_cowbl.h
9719 --- linux-2.6.37/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9720 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_cowbl.h 2010-11-23 02:09:41.000000000 +0100
9722 +#ifndef _VS_COWBL_H
9723 +#define _VS_COWBL_H
9725 +#include <linux/fs.h>
9726 +#include <linux/dcache.h>
9727 +#include <linux/namei.h>
9728 +#include <linux/slab.h>
9730 +extern struct dentry *cow_break_link(const char *pathname);
9732 +static inline int cow_check_and_break(struct path *path)
9734 + struct inode *inode = path->dentry->d_inode;
9737 + /* do we need this check? */
9738 + if (IS_RDONLY(inode))
9741 + if (IS_COW(inode)) {
9742 + if (IS_COW_LINK(inode)) {
9743 + struct dentry *new_dentry, *old_dentry = path->dentry;
9746 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9750 + pp = d_path(path, buf, PATH_MAX);
9751 + new_dentry = cow_break_link(pp);
9753 + if (!IS_ERR(new_dentry)) {
9754 + path->dentry = new_dentry;
9757 + error = PTR_ERR(new_dentry);
9759 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9760 + inode->i_ctime = CURRENT_TIME;
9761 + mark_inode_dirty(inode);
9768 +#warning duplicate inclusion
9770 diff -NurpP --minimal linux-2.6.37/include/linux/vs_cvirt.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_cvirt.h
9771 --- linux-2.6.37/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9772 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_cvirt.h 2010-11-23 02:09:41.000000000 +0100
9774 +#ifndef _VS_CVIRT_H
9775 +#define _VS_CVIRT_H
9777 +#include "vserver/cvirt.h"
9778 +#include "vserver/context.h"
9779 +#include "vserver/base.h"
9780 +#include "vserver/check.h"
9781 +#include "vserver/debug.h"
9784 +static inline void vx_activate_task(struct task_struct *p)
9786 + struct vx_info *vxi;
9788 + if ((vxi = p->vx_info)) {
9789 + vx_update_load(vxi);
9790 + atomic_inc(&vxi->cvirt.nr_running);
9794 +static inline void vx_deactivate_task(struct task_struct *p)
9796 + struct vx_info *vxi;
9798 + if ((vxi = p->vx_info)) {
9799 + vx_update_load(vxi);
9800 + atomic_dec(&vxi->cvirt.nr_running);
9804 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9806 + struct vx_info *vxi;
9808 + if ((vxi = p->vx_info))
9809 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9812 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9814 + struct vx_info *vxi;
9816 + if ((vxi = p->vx_info))
9817 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9822 +#warning duplicate inclusion
9824 diff -NurpP --minimal linux-2.6.37/include/linux/vs_device.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_device.h
9825 --- linux-2.6.37/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9826 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_device.h 2010-11-23 02:09:41.000000000 +0100
9828 +#ifndef _VS_DEVICE_H
9829 +#define _VS_DEVICE_H
9831 +#include "vserver/base.h"
9832 +#include "vserver/device.h"
9833 +#include "vserver/debug.h"
9836 +#ifdef CONFIG_VSERVER_DEVICE
9838 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9840 +#define vs_device_perm(v, d, m, p) \
9841 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9846 +int vs_map_device(struct vx_info *vxi,
9847 + dev_t device, dev_t *target, umode_t mode)
9854 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9859 +#define vs_map_chrdev(d, t, p) \
9860 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9861 +#define vs_map_blkdev(d, t, p) \
9862 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9864 +#define vs_chrdev_perm(d, p) \
9865 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9866 +#define vs_blkdev_perm(d, p) \
9867 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9871 +#warning duplicate inclusion
9873 diff -NurpP --minimal linux-2.6.37/include/linux/vs_dlimit.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_dlimit.h
9874 --- linux-2.6.37/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9875 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_dlimit.h 2010-11-23 02:09:41.000000000 +0100
9877 +#ifndef _VS_DLIMIT_H
9878 +#define _VS_DLIMIT_H
9880 +#include <linux/fs.h>
9882 +#include "vserver/dlimit.h"
9883 +#include "vserver/base.h"
9884 +#include "vserver/debug.h"
9887 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9889 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9890 + const char *_file, int _line)
9894 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9895 + dli, dli ? dli->dl_tag : 0,
9896 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9898 + atomic_inc(&dli->dl_usecnt);
9903 +#define free_dl_info(i) \
9904 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9906 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9908 +static inline void __put_dl_info(struct dl_info *dli,
9909 + const char *_file, int _line)
9913 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9914 + dli, dli ? dli->dl_tag : 0,
9915 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9917 + if (atomic_dec_and_test(&dli->dl_usecnt))
9918 + free_dl_info(dli);
9922 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9924 +static inline int __dl_alloc_space(struct super_block *sb,
9925 + tag_t tag, dlsize_t nr, const char *file, int line)
9927 + struct dl_info *dli = NULL;
9932 + dli = locate_dl_info(sb, tag);
9936 + spin_lock(&dli->dl_lock);
9937 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9939 + dli->dl_space_used += nr;
9940 + spin_unlock(&dli->dl_lock);
9943 + vxlprintk(VXD_CBIT(dlim, 1),
9944 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9945 + sb, tag, __dlimit_char(dli), (long long)nr,
9947 + return ret ? -ENOSPC : 0;
9950 +static inline void __dl_free_space(struct super_block *sb,
9951 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9953 + struct dl_info *dli = NULL;
9957 + dli = locate_dl_info(sb, tag);
9961 + spin_lock(&dli->dl_lock);
9962 + if (dli->dl_space_used > nr)
9963 + dli->dl_space_used -= nr;
9965 + dli->dl_space_used = 0;
9966 + spin_unlock(&dli->dl_lock);
9969 + vxlprintk(VXD_CBIT(dlim, 1),
9970 + "FREE (%p,#%d)%c %lld bytes",
9971 + sb, tag, __dlimit_char(dli), (long long)nr,
9975 +static inline int __dl_alloc_inode(struct super_block *sb,
9976 + tag_t tag, const char *_file, int _line)
9978 + struct dl_info *dli;
9981 + dli = locate_dl_info(sb, tag);
9985 + spin_lock(&dli->dl_lock);
9986 + dli->dl_inodes_used++;
9987 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9988 + spin_unlock(&dli->dl_lock);
9991 + vxlprintk(VXD_CBIT(dlim, 0),
9992 + "ALLOC (%p,#%d)%c inode (%d)",
9993 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9994 + return ret ? -ENOSPC : 0;
9997 +static inline void __dl_free_inode(struct super_block *sb,
9998 + tag_t tag, const char *_file, int _line)
10000 + struct dl_info *dli;
10002 + dli = locate_dl_info(sb, tag);
10006 + spin_lock(&dli->dl_lock);
10007 + if (dli->dl_inodes_used > 1)
10008 + dli->dl_inodes_used--;
10010 + dli->dl_inodes_used = 0;
10011 + spin_unlock(&dli->dl_lock);
10012 + put_dl_info(dli);
10014 + vxlprintk(VXD_CBIT(dlim, 0),
10015 + "FREE (%p,#%d)%c inode",
10016 + sb, tag, __dlimit_char(dli), _file, _line);
10019 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
10020 + unsigned long long *free_blocks, unsigned long long *root_blocks,
10021 + const char *_file, int _line)
10023 + struct dl_info *dli;
10024 + uint64_t broot, bfree;
10026 + dli = locate_dl_info(sb, tag);
10030 + spin_lock(&dli->dl_lock);
10031 + broot = (dli->dl_space_total -
10032 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
10033 + >> sb->s_blocksize_bits;
10034 + bfree = (dli->dl_space_total - dli->dl_space_used)
10035 + >> sb->s_blocksize_bits;
10036 + spin_unlock(&dli->dl_lock);
10038 + vxlprintk(VXD_CBIT(dlim, 2),
10039 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
10040 + (long long)bfree, (long long)broot,
10041 + *free_blocks, *root_blocks, dli->dl_nrlmult,
10043 + if (free_blocks) {
10044 + if (*free_blocks > bfree)
10045 + *free_blocks = bfree;
10047 + if (root_blocks) {
10048 + if (*root_blocks > broot)
10049 + *root_blocks = broot;
10051 + put_dl_info(dli);
10054 +#define dl_prealloc_space(in, bytes) \
10055 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10056 + __FILE__, __LINE__ )
10058 +#define dl_alloc_space(in, bytes) \
10059 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10060 + __FILE__, __LINE__ )
10062 +#define dl_reserve_space(in, bytes) \
10063 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10064 + __FILE__, __LINE__ )
10066 +#define dl_claim_space(in, bytes) (0)
10068 +#define dl_release_space(in, bytes) \
10069 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10070 + __FILE__, __LINE__ )
10072 +#define dl_free_space(in, bytes) \
10073 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
10074 + __FILE__, __LINE__ )
10078 +#define dl_alloc_inode(in) \
10079 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10081 +#define dl_free_inode(in) \
10082 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
10085 +#define dl_adjust_block(sb, tag, fb, rb) \
10086 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
10090 +#warning duplicate inclusion
10092 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/base.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/base.h
10093 --- linux-2.6.37/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10094 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/base.h 2010-11-23 02:09:41.000000000 +0100
10096 +#ifndef _VX_BASE_H
10097 +#define _VX_BASE_H
10100 +/* context state changes */
10112 +#define vx_task_xid(t) ((t)->xid)
10114 +#define vx_current_xid() vx_task_xid(current)
10116 +#define current_vx_info() (current->vx_info)
10119 +#define nx_task_nid(t) ((t)->nid)
10121 +#define nx_current_nid() nx_task_nid(current)
10123 +#define current_nx_info() (current->nx_info)
10126 +/* generic flag merging */
10128 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10130 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10132 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10134 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10137 +/* context flags */
10139 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10141 +#define vx_current_flags() __vx_flags(current_vx_info())
10143 +#define vx_info_flags(v, m, f) \
10144 + vs_check_flags(__vx_flags(v), m, f)
10146 +#define task_vx_flags(t, m, f) \
10147 + ((t) && vx_info_flags((t)->vx_info, m, f))
10149 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10152 +/* context caps */
10154 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10156 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10158 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10160 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10164 +/* network flags */
10166 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10168 +#define nx_current_flags() __nx_flags(current_nx_info())
10170 +#define nx_info_flags(n, m, f) \
10171 + vs_check_flags(__nx_flags(n), m, f)
10173 +#define task_nx_flags(t, m, f) \
10174 + ((t) && nx_info_flags((t)->nx_info, m, f))
10176 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10179 +/* network caps */
10181 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10183 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10185 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10187 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10190 +/* context mask capabilities */
10192 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10194 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10196 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10199 +/* context bcap mask */
10201 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10203 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10206 +/* mask given bcaps */
10208 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10210 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10213 +/* masked cap_bset */
10215 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10217 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10220 +#define vx_info_mbcap(v, b) \
10221 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10222 + vx_info_bcaps(v, b) : (b))
10224 +#define task_vx_mbcap(t, b) \
10225 + vx_info_mbcap((t)->vx_info, (t)->b)
10227 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10230 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10232 +#define vx_capable(b, c) (capable(b) || \
10233 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10235 +#define nx_capable(b, c) (capable(b) || \
10236 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10238 +#define vx_task_initpid(t, n) \
10239 + ((t)->vx_info && \
10240 + ((t)->vx_info->vx_initpid == (n)))
10242 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10245 +/* context unshare mask */
10247 +#define __vx_umask(v) ((v)->vx_umask)
10249 +#define vx_current_umask() __vx_umask(current_vx_info())
10251 +#define vx_can_unshare(b, f) (capable(b) || \
10252 + (cap_raised(current_cap(), b) && \
10253 + !((f) & ~vx_current_umask())))
10256 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10258 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10261 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10263 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10266 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cacct_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cacct_cmd.h
10267 --- linux-2.6.37/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10268 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cacct_cmd.h 2010-11-23 02:09:41.000000000 +0100
10270 +#ifndef _VX_CACCT_CMD_H
10271 +#define _VX_CACCT_CMD_H
10274 +/* virtual host info name commands */
10276 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10278 +struct vcmd_sock_stat_v0 {
10280 + uint32_t count[3];
10281 + uint64_t total[3];
10287 +#include <linux/compiler.h>
10289 +extern int vc_sock_stat(struct vx_info *, void __user *);
10291 +#endif /* __KERNEL__ */
10292 +#endif /* _VX_CACCT_CMD_H */
10293 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cacct_def.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cacct_def.h
10294 --- linux-2.6.37/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10295 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cacct_def.h 2010-11-23 02:09:41.000000000 +0100
10297 +#ifndef _VX_CACCT_DEF_H
10298 +#define _VX_CACCT_DEF_H
10300 +#include <asm/atomic.h>
10301 +#include <linux/vserver/cacct.h>
10304 +struct _vx_sock_acc {
10305 + atomic_long_t count;
10306 + atomic_long_t total;
10309 +/* context sub struct */
10311 +struct _vx_cacct {
10312 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10313 + atomic_t slab[8];
10314 + atomic_t page[6][8];
10317 +#ifdef CONFIG_VSERVER_DEBUG
10319 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10323 + printk("\t_vx_cacct:");
10324 + for (i = 0; i < 6; i++) {
10325 + struct _vx_sock_acc *ptr = cacct->sock[i];
10327 + printk("\t [%d] =", i);
10328 + for (j = 0; j < 3; j++) {
10329 + printk(" [%d] = %8lu, %8lu", j,
10330 + atomic_long_read(&ptr[j].count),
10331 + atomic_long_read(&ptr[j].total));
10339 +#endif /* _VX_CACCT_DEF_H */
10340 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cacct.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cacct.h
10341 --- linux-2.6.37/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10342 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cacct.h 2010-11-23 02:09:41.000000000 +0100
10344 +#ifndef _VX_CACCT_H
10345 +#define _VX_CACCT_H
10348 +enum sock_acc_field {
10349 + VXA_SOCK_UNSPEC = 0,
10355 + VXA_SOCK_SIZE /* array size */
10358 +#endif /* _VX_CACCT_H */
10359 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cacct_int.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cacct_int.h
10360 --- linux-2.6.37/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10361 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cacct_int.h 2010-11-23 02:09:41.000000000 +0100
10363 +#ifndef _VX_CACCT_INT_H
10364 +#define _VX_CACCT_INT_H
10370 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10372 + return atomic_long_read(&cacct->sock[type][pos].count);
10377 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10379 + return atomic_long_read(&cacct->sock[type][pos].total);
10382 +#endif /* __KERNEL__ */
10383 +#endif /* _VX_CACCT_INT_H */
10384 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/check.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/check.h
10385 --- linux-2.6.37/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10386 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/check.h 2010-11-23 02:09:41.000000000 +0100
10388 +#ifndef _VS_CHECK_H
10389 +#define _VS_CHECK_H
10392 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10394 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10395 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10397 +#define MIN_D_CONTEXT 65536
10400 +/* check conditions */
10402 +#define VS_ADMIN 0x0001
10403 +#define VS_WATCH 0x0002
10404 +#define VS_HIDE 0x0004
10405 +#define VS_HOSTID 0x0008
10407 +#define VS_IDENT 0x0010
10408 +#define VS_EQUIV 0x0020
10409 +#define VS_PARENT 0x0040
10410 +#define VS_CHILD 0x0080
10412 +#define VS_ARG_MASK 0x00F0
10414 +#define VS_DYNAMIC 0x0100
10415 +#define VS_STATIC 0x0200
10417 +#define VS_ATR_MASK 0x0F00
10419 +#ifdef CONFIG_VSERVER_PRIVACY
10420 +#define VS_ADMIN_P (0)
10421 +#define VS_WATCH_P (0)
10423 +#define VS_ADMIN_P VS_ADMIN
10424 +#define VS_WATCH_P VS_WATCH
10427 +#define VS_HARDIRQ 0x1000
10428 +#define VS_SOFTIRQ 0x2000
10429 +#define VS_IRQ 0x4000
10431 +#define VS_IRQ_MASK 0xF000
10433 +#include <linux/hardirq.h>
10436 + * check current context for ADMIN/WATCH and
10437 + * optionally against supplied argument
10439 +static inline int __vs_check(int cid, int id, unsigned int mode)
10441 + if (mode & VS_ARG_MASK) {
10442 + if ((mode & VS_IDENT) && (id == cid))
10445 + if (mode & VS_ATR_MASK) {
10446 + if ((mode & VS_DYNAMIC) &&
10447 + (id >= MIN_D_CONTEXT) &&
10448 + (id <= MAX_S_CONTEXT))
10450 + if ((mode & VS_STATIC) &&
10451 + (id > 1) && (id < MIN_D_CONTEXT))
10454 + if (mode & VS_IRQ_MASK) {
10455 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10457 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10459 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10462 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10463 + ((mode & VS_WATCH) && (cid == 1)) ||
10464 + ((mode & VS_HOSTID) && (id == 0)));
10467 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10469 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10472 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10474 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10477 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/context_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/context_cmd.h
10478 --- linux-2.6.37/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
10479 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/context_cmd.h 2010-11-23 02:09:41.000000000 +0100
10481 +#ifndef _VX_CONTEXT_CMD_H
10482 +#define _VX_CONTEXT_CMD_H
10485 +/* vinfo commands */
10487 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
10490 +extern int vc_task_xid(uint32_t);
10492 +#endif /* __KERNEL__ */
10494 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
10496 +struct vcmd_vx_info_v0 {
10498 + uint32_t initpid;
10499 + /* more to come */
10503 +extern int vc_vx_info(struct vx_info *, void __user *);
10505 +#endif /* __KERNEL__ */
10507 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
10509 +struct vcmd_ctx_stat_v0 {
10512 + /* more to come */
10516 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10518 +#endif /* __KERNEL__ */
10520 +/* context commands */
10522 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
10523 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
10525 +struct vcmd_ctx_create {
10526 + uint64_t flagword;
10529 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
10530 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
10532 +struct vcmd_ctx_migrate {
10533 + uint64_t flagword;
10537 +extern int vc_ctx_create(uint32_t, void __user *);
10538 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10540 +#endif /* __KERNEL__ */
10543 +/* flag commands */
10545 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
10546 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
10548 +struct vcmd_ctx_flags_v0 {
10549 + uint64_t flagword;
10554 +extern int vc_get_cflags(struct vx_info *, void __user *);
10555 +extern int vc_set_cflags(struct vx_info *, void __user *);
10557 +#endif /* __KERNEL__ */
10560 +/* context caps commands */
10562 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
10563 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
10565 +struct vcmd_ctx_caps_v1 {
10571 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10572 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10574 +#endif /* __KERNEL__ */
10577 +/* bcaps commands */
10579 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
10580 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
10582 +struct vcmd_bcaps {
10588 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10589 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10591 +#endif /* __KERNEL__ */
10594 +/* umask commands */
10596 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
10597 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
10599 +struct vcmd_umask {
10605 +extern int vc_get_umask(struct vx_info *, void __user *);
10606 +extern int vc_set_umask(struct vx_info *, void __user *);
10608 +#endif /* __KERNEL__ */
10613 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
10614 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
10616 +struct vcmd_badness_v0 {
10621 +extern int vc_get_badness(struct vx_info *, void __user *);
10622 +extern int vc_set_badness(struct vx_info *, void __user *);
10624 +#endif /* __KERNEL__ */
10625 +#endif /* _VX_CONTEXT_CMD_H */
10626 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/context.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/context.h
10627 --- linux-2.6.37/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
10628 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/context.h 2011-01-31 21:05:40.000000000 +0100
10630 +#ifndef _VX_CONTEXT_H
10631 +#define _VX_CONTEXT_H
10633 +#include <linux/types.h>
10634 +#include <linux/capability.h>
10637 +/* context flags */
10639 +#define VXF_INFO_SCHED 0x00000002
10640 +#define VXF_INFO_NPROC 0x00000004
10641 +#define VXF_INFO_PRIVATE 0x00000008
10643 +#define VXF_INFO_INIT 0x00000010
10644 +#define VXF_INFO_HIDE 0x00000020
10645 +#define VXF_INFO_ULIMIT 0x00000040
10646 +#define VXF_INFO_NSPACE 0x00000080
10648 +#define VXF_SCHED_HARD 0x00000100
10649 +#define VXF_SCHED_PRIO 0x00000200
10650 +#define VXF_SCHED_PAUSE 0x00000400
10652 +#define VXF_VIRT_MEM 0x00010000
10653 +#define VXF_VIRT_UPTIME 0x00020000
10654 +#define VXF_VIRT_CPU 0x00040000
10655 +#define VXF_VIRT_LOAD 0x00080000
10656 +#define VXF_VIRT_TIME 0x00100000
10658 +#define VXF_HIDE_MOUNT 0x01000000
10659 +/* was VXF_HIDE_NETIF 0x02000000 */
10660 +#define VXF_HIDE_VINFO 0x04000000
10662 +#define VXF_STATE_SETUP (1ULL << 32)
10663 +#define VXF_STATE_INIT (1ULL << 33)
10664 +#define VXF_STATE_ADMIN (1ULL << 34)
10666 +#define VXF_SC_HELPER (1ULL << 36)
10667 +#define VXF_REBOOT_KILL (1ULL << 37)
10668 +#define VXF_PERSISTENT (1ULL << 38)
10670 +#define VXF_FORK_RSS (1ULL << 48)
10671 +#define VXF_PROLIFIC (1ULL << 49)
10673 +#define VXF_IGNEG_NICE (1ULL << 52)
10675 +#define VXF_ONE_TIME (0x0007ULL << 32)
10677 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
10680 +/* context migration */
10682 +#define VXM_SET_INIT 0x00000001
10683 +#define VXM_SET_REAPER 0x00000002
10685 +/* context caps */
10687 +#define VXC_CAP_MASK 0x00000000
10689 +#define VXC_SET_UTSNAME 0x00000001
10690 +#define VXC_SET_RLIMIT 0x00000002
10691 +#define VXC_FS_SECURITY 0x00000004
10692 +#define VXC_FS_TRUSTED 0x00000008
10693 +#define VXC_TIOCSTI 0x00000010
10695 +/* was VXC_RAW_ICMP 0x00000100 */
10696 +#define VXC_SYSLOG 0x00001000
10697 +#define VXC_OOM_ADJUST 0x00002000
10698 +#define VXC_AUDIT_CONTROL 0x00004000
10700 +#define VXC_SECURE_MOUNT 0x00010000
10701 +#define VXC_SECURE_REMOUNT 0x00020000
10702 +#define VXC_BINARY_MOUNT 0x00040000
10704 +#define VXC_QUOTA_CTL 0x00100000
10705 +#define VXC_ADMIN_MAPPER 0x00200000
10706 +#define VXC_ADMIN_CLOOP 0x00400000
10708 +#define VXC_KTHREAD 0x01000000
10709 +#define VXC_NAMESPACE 0x02000000
10714 +#include <linux/list.h>
10715 +#include <linux/spinlock.h>
10716 +#include <linux/rcupdate.h>
10718 +#include "limit_def.h"
10719 +#include "sched_def.h"
10720 +#include "cvirt_def.h"
10721 +#include "cacct_def.h"
10722 +#include "device_def.h"
10724 +#define VX_SPACES 2
10726 +struct _vx_info_pc {
10727 + struct _vx_sched_pc sched_pc;
10728 + struct _vx_cvirt_pc cvirt_pc;
10731 +struct _vx_space {
10732 + unsigned long vx_nsmask; /* assignment mask */
10733 + struct nsproxy *vx_nsproxy; /* private namespaces */
10734 + struct fs_struct *vx_fs; /* private namespace fs */
10735 +// const struct cred *vx_real_cred; /* real task credentials */
10736 + const struct cred *vx_cred; /* task credentials */
10740 + struct hlist_node vx_hlist; /* linked list of contexts */
10741 + xid_t vx_id; /* context id */
10742 + atomic_t vx_usecnt; /* usage count */
10743 + atomic_t vx_tasks; /* tasks count */
10744 + struct vx_info *vx_parent; /* parent context */
10745 + int vx_state; /* context state */
10747 + struct _vx_space space[VX_SPACES]; /* namespace store */
10749 + uint64_t vx_flags; /* context flags */
10750 + uint64_t vx_ccaps; /* context caps (vserver) */
10751 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10752 + unsigned long vx_umask; /* unshare mask (guest) */
10754 + struct task_struct *vx_reaper; /* guest reaper process */
10755 + pid_t vx_initpid; /* PID of guest init */
10756 + int64_t vx_badness_bias; /* OOM points bias */
10758 + struct _vx_limit limit; /* vserver limits */
10759 + struct _vx_sched sched; /* vserver scheduler */
10760 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10761 + struct _vx_cacct cacct; /* context accounting */
10763 + struct _vx_device dmap; /* default device map targets */
10765 +#ifndef CONFIG_SMP
10766 + struct _vx_info_pc info_pc; /* per cpu data */
10768 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10771 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10772 + int reboot_cmd; /* last sys_reboot() cmd */
10773 + int exit_code; /* last process exit code */
10775 + char vx_name[65]; /* vserver name */
10778 +#ifndef CONFIG_SMP
10779 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10780 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10782 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10783 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10786 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10789 +struct vx_info_save {
10790 + struct vx_info *vxi;
10795 +/* status flags */
10797 +#define VXS_HASHED 0x0001
10798 +#define VXS_PAUSED 0x0010
10799 +#define VXS_SHUTDOWN 0x0100
10800 +#define VXS_HELPER 0x1000
10801 +#define VXS_RELEASED 0x8000
10804 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10805 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10807 +extern struct vx_info *lookup_vx_info(int);
10808 +extern struct vx_info *lookup_or_create_vx_info(int);
10810 +extern int get_xid_list(int, unsigned int *, int);
10811 +extern int xid_is_hashed(xid_t);
10813 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10815 +extern long vs_state_change(struct vx_info *, unsigned int);
10818 +#endif /* __KERNEL__ */
10819 +#endif /* _VX_CONTEXT_H */
10820 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cvirt_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cvirt_cmd.h
10821 --- linux-2.6.37/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
10822 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cvirt_cmd.h 2010-11-23 02:09:41.000000000 +0100
10824 +#ifndef _VX_CVIRT_CMD_H
10825 +#define _VX_CVIRT_CMD_H
10828 +/* virtual host info name commands */
10830 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
10831 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
10833 +struct vcmd_vhi_name_v0 {
10839 +enum vhi_name_field {
10840 + VHIN_CONTEXT = 0,
10852 +#include <linux/compiler.h>
10854 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10855 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10857 +#endif /* __KERNEL__ */
10859 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
10861 +struct vcmd_virt_stat_v0 {
10864 + uint32_t nr_threads;
10865 + uint32_t nr_running;
10866 + uint32_t nr_uninterruptible;
10867 + uint32_t nr_onhold;
10868 + uint32_t nr_forks;
10869 + uint32_t load[3];
10873 +extern int vc_virt_stat(struct vx_info *, void __user *);
10875 +#endif /* __KERNEL__ */
10876 +#endif /* _VX_CVIRT_CMD_H */
10877 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cvirt_def.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cvirt_def.h
10878 --- linux-2.6.37/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
10879 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cvirt_def.h 2010-11-23 02:09:41.000000000 +0100
10881 +#ifndef _VX_CVIRT_DEF_H
10882 +#define _VX_CVIRT_DEF_H
10884 +#include <linux/jiffies.h>
10885 +#include <linux/spinlock.h>
10886 +#include <linux/wait.h>
10887 +#include <linux/time.h>
10888 +#include <asm/atomic.h>
10891 +struct _vx_usage_stat {
10895 + uint64_t softirq;
10901 +struct _vx_syslog {
10902 + wait_queue_head_t log_wait;
10903 + spinlock_t logbuf_lock; /* lock for the log buffer */
10905 + unsigned long log_start; /* next char to be read by syslog() */
10906 + unsigned long con_start; /* next char to be sent to consoles */
10907 + unsigned long log_end; /* most-recently-written-char + 1 */
10908 + unsigned long logged_chars; /* #chars since last read+clear operation */
10910 + char log_buf[1024];
10914 +/* context sub struct */
10916 +struct _vx_cvirt {
10917 + atomic_t nr_threads; /* number of current threads */
10918 + atomic_t nr_running; /* number of running threads */
10919 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10921 + atomic_t nr_onhold; /* processes on hold */
10922 + uint32_t onhold_last; /* jiffies when put on hold */
10924 + struct timespec bias_ts; /* time offset to the host */
10925 + struct timespec bias_idle;
10926 + struct timespec bias_uptime; /* context creation point */
10927 + uint64_t bias_clock; /* offset in clock_t */
10929 + spinlock_t load_lock; /* lock for the load averages */
10930 + atomic_t load_updates; /* nr of load updates done so far */
10931 + uint32_t load_last; /* last time load was calculated */
10932 + uint32_t load[3]; /* load averages 1,5,15 */
10934 + atomic_t total_forks; /* number of forks so far */
10936 + struct _vx_syslog syslog;
10939 +struct _vx_cvirt_pc {
10940 + struct _vx_usage_stat cpustat;
10944 +#ifdef CONFIG_VSERVER_DEBUG
10946 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
10948 + printk("\t_vx_cvirt:\n");
10949 + printk("\t threads: %4d, %4d, %4d, %4d\n",
10950 + atomic_read(&cvirt->nr_threads),
10951 + atomic_read(&cvirt->nr_running),
10952 + atomic_read(&cvirt->nr_uninterruptible),
10953 + atomic_read(&cvirt->nr_onhold));
10954 + /* add rest here */
10955 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
10960 +#endif /* _VX_CVIRT_DEF_H */
10961 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/cvirt.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cvirt.h
10962 --- linux-2.6.37/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
10963 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/cvirt.h 2010-11-23 02:09:41.000000000 +0100
10965 +#ifndef _VX_CVIRT_H
10966 +#define _VX_CVIRT_H
10973 +void vx_vsi_uptime(struct timespec *, struct timespec *);
10978 +void vx_update_load(struct vx_info *);
10981 +int vx_do_syslog(int, char __user *, int);
10983 +#endif /* __KERNEL__ */
10984 +#endif /* _VX_CVIRT_H */
10985 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/debug_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/debug_cmd.h
10986 --- linux-2.6.37/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
10987 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/debug_cmd.h 2010-11-23 02:09:41.000000000 +0100
10989 +#ifndef _VX_DEBUG_CMD_H
10990 +#define _VX_DEBUG_CMD_H
10993 +/* debug commands */
10995 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
10997 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
10998 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11000 +struct vcmd_read_history_v0 {
11003 + char __user *data;
11006 +struct vcmd_read_monitor_v0 {
11009 + char __user *data;
11015 +#ifdef CONFIG_COMPAT
11017 +#include <asm/compat.h>
11019 +struct vcmd_read_history_v0_x32 {
11022 + compat_uptr_t data_ptr;
11025 +struct vcmd_read_monitor_v0_x32 {
11028 + compat_uptr_t data_ptr;
11031 +#endif /* CONFIG_COMPAT */
11033 +extern int vc_dump_history(uint32_t);
11035 +extern int vc_read_history(uint32_t, void __user *);
11036 +extern int vc_read_monitor(uint32_t, void __user *);
11038 +#ifdef CONFIG_COMPAT
11040 +extern int vc_read_history_x32(uint32_t, void __user *);
11041 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11043 +#endif /* CONFIG_COMPAT */
11045 +#endif /* __KERNEL__ */
11046 +#endif /* _VX_DEBUG_CMD_H */
11047 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/debug.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/debug.h
11048 --- linux-2.6.37/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11049 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/debug.h 2010-11-23 02:09:41.000000000 +0100
11051 +#ifndef _VX_DEBUG_H
11052 +#define _VX_DEBUG_H
11055 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11056 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11057 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11059 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11060 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11061 +#define VXF_DEV "%p[%lu,%d:%d]"
11063 +#if defined(CONFIG_QUOTES_UTF8)
11064 +#define VS_Q_LQM "\xc2\xbb"
11065 +#define VS_Q_RQM "\xc2\xab"
11066 +#elif defined(CONFIG_QUOTES_ASCII)
11067 +#define VS_Q_LQM "\x27"
11068 +#define VS_Q_RQM "\x27"
11070 +#define VS_Q_LQM "\xbb"
11071 +#define VS_Q_RQM "\xab"
11074 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11077 +#define vxd_path(p) \
11078 + ({ static char _buffer[PATH_MAX]; \
11079 + d_path(p, _buffer, sizeof(_buffer)); })
11081 +#define vxd_cond_path(n) \
11082 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11085 +#ifdef CONFIG_VSERVER_DEBUG
11087 +extern unsigned int vx_debug_switch;
11088 +extern unsigned int vx_debug_xid;
11089 +extern unsigned int vx_debug_nid;
11090 +extern unsigned int vx_debug_tag;
11091 +extern unsigned int vx_debug_net;
11092 +extern unsigned int vx_debug_limit;
11093 +extern unsigned int vx_debug_cres;
11094 +extern unsigned int vx_debug_dlim;
11095 +extern unsigned int vx_debug_quota;
11096 +extern unsigned int vx_debug_cvirt;
11097 +extern unsigned int vx_debug_space;
11098 +extern unsigned int vx_debug_misc;
11101 +#define VX_LOGLEVEL "vxD: "
11102 +#define VX_PROC_FMT "%p: "
11103 +#define VX_PROCESS current
11105 +#define vxdprintk(c, f, x...) \
11108 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11109 + VX_PROCESS , ##x); \
11112 +#define vxlprintk(c, f, x...) \
11115 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11118 +#define vxfprintk(c, f, x...) \
11121 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11127 +void dump_vx_info(struct vx_info *, int);
11128 +void dump_vx_info_inactive(int);
11130 +#else /* CONFIG_VSERVER_DEBUG */
11132 +#define vx_debug_switch 0
11133 +#define vx_debug_xid 0
11134 +#define vx_debug_nid 0
11135 +#define vx_debug_tag 0
11136 +#define vx_debug_net 0
11137 +#define vx_debug_limit 0
11138 +#define vx_debug_cres 0
11139 +#define vx_debug_dlim 0
11140 +#define vx_debug_cvirt 0
11142 +#define vxdprintk(x...) do { } while (0)
11143 +#define vxlprintk(x...) do { } while (0)
11144 +#define vxfprintk(x...) do { } while (0)
11146 +#endif /* CONFIG_VSERVER_DEBUG */
11149 +#ifdef CONFIG_VSERVER_WARN
11151 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11152 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
11153 +#define VX_WARN_XID "[xid #%u] "
11154 +#define VX_WARN_NID "[nid #%u] "
11155 +#define VX_WARN_TAG "[tag #%u] "
11157 +#define vxwprintk(c, f, x...) \
11160 + printk(VX_WARNLEVEL f "\n", ##x); \
11163 +#else /* CONFIG_VSERVER_WARN */
11165 +#define vxwprintk(x...) do { } while (0)
11167 +#endif /* CONFIG_VSERVER_WARN */
11169 +#define vxwprintk_task(c, f, x...) \
11170 + vxwprintk(c, VX_WARN_TASK f, \
11171 + current->comm, current->pid, \
11172 + current->xid, current->nid, current->tag, ##x)
11173 +#define vxwprintk_xid(c, f, x...) \
11174 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11175 +#define vxwprintk_nid(c, f, x...) \
11176 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11177 +#define vxwprintk_tag(c, f, x...) \
11178 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11180 +#ifdef CONFIG_VSERVER_DEBUG
11181 +#define vxd_assert_lock(l) assert_spin_locked(l)
11182 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11183 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11185 +#define vxd_assert_lock(l) do { } while (0)
11186 +#define vxd_assert(c, f, x...) do { } while (0)
11190 +#endif /* _VX_DEBUG_H */
11191 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/device_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/device_cmd.h
11192 --- linux-2.6.37/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11193 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/device_cmd.h 2010-11-23 02:09:41.000000000 +0100
11195 +#ifndef _VX_DEVICE_CMD_H
11196 +#define _VX_DEVICE_CMD_H
11199 +/* device vserver commands */
11201 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11202 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11204 +struct vcmd_set_mapping_v0 {
11205 + const char __user *device;
11206 + const char __user *target;
11213 +#ifdef CONFIG_COMPAT
11215 +#include <asm/compat.h>
11217 +struct vcmd_set_mapping_v0_x32 {
11218 + compat_uptr_t device_ptr;
11219 + compat_uptr_t target_ptr;
11223 +#endif /* CONFIG_COMPAT */
11225 +#include <linux/compiler.h>
11227 +extern int vc_set_mapping(struct vx_info *, void __user *);
11228 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11230 +#ifdef CONFIG_COMPAT
11232 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11233 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11235 +#endif /* CONFIG_COMPAT */
11237 +#endif /* __KERNEL__ */
11238 +#endif /* _VX_DEVICE_CMD_H */
11239 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/device_def.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/device_def.h
11240 --- linux-2.6.37/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11241 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/device_def.h 2010-11-23 02:09:41.000000000 +0100
11243 +#ifndef _VX_DEVICE_DEF_H
11244 +#define _VX_DEVICE_DEF_H
11246 +#include <linux/types.h>
11248 +struct vx_dmap_target {
11253 +struct _vx_device {
11254 +#ifdef CONFIG_VSERVER_DEVICE
11255 + struct vx_dmap_target targets[2];
11259 +#endif /* _VX_DEVICE_DEF_H */
11260 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/device.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/device.h
11261 --- linux-2.6.37/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11262 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/device.h 2010-11-23 02:09:41.000000000 +0100
11264 +#ifndef _VX_DEVICE_H
11265 +#define _VX_DEVICE_H
11268 +#define DATTR_CREATE 0x00000001
11269 +#define DATTR_OPEN 0x00000002
11271 +#define DATTR_REMAP 0x00000010
11273 +#define DATTR_MASK 0x00000013
11276 +#else /* _VX_DEVICE_H */
11277 +#warning duplicate inclusion
11278 +#endif /* _VX_DEVICE_H */
11279 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/dlimit_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/dlimit_cmd.h
11280 --- linux-2.6.37/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11281 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/dlimit_cmd.h 2010-11-23 02:09:41.000000000 +0100
11283 +#ifndef _VX_DLIMIT_CMD_H
11284 +#define _VX_DLIMIT_CMD_H
11287 +/* dlimit vserver commands */
11289 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11290 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11292 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11293 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11295 +struct vcmd_ctx_dlimit_base_v0 {
11296 + const char __user *name;
11300 +struct vcmd_ctx_dlimit_v0 {
11301 + const char __user *name;
11302 + uint32_t space_used; /* used space in kbytes */
11303 + uint32_t space_total; /* maximum space in kbytes */
11304 + uint32_t inodes_used; /* used inodes */
11305 + uint32_t inodes_total; /* maximum inodes */
11306 + uint32_t reserved; /* reserved for root in % */
11310 +#define CDLIM_UNSET ((uint32_t)0UL)
11311 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11312 +#define CDLIM_KEEP ((uint32_t)~1UL)
11314 +#define DLIME_UNIT 0
11315 +#define DLIME_KILO 1
11316 +#define DLIME_MEGA 2
11317 +#define DLIME_GIGA 3
11319 +#define DLIMF_SHIFT 0x10
11321 +#define DLIMS_USED 0
11322 +#define DLIMS_TOTAL 2
11325 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
11327 + int exp = (flags & DLIMF_SHIFT) ?
11328 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
11329 + return ((uint64_t)val) << (10 * exp);
11333 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
11337 + if (*flags & DLIMF_SHIFT) {
11338 + while (val > (1LL << 32) && (exp < 3)) {
11342 + *flags &= ~(DLIME_GIGA << shift);
11343 + *flags |= exp << shift;
11351 +#ifdef CONFIG_COMPAT
11353 +#include <asm/compat.h>
11355 +struct vcmd_ctx_dlimit_base_v0_x32 {
11356 + compat_uptr_t name_ptr;
11360 +struct vcmd_ctx_dlimit_v0_x32 {
11361 + compat_uptr_t name_ptr;
11362 + uint32_t space_used; /* used space in kbytes */
11363 + uint32_t space_total; /* maximum space in kbytes */
11364 + uint32_t inodes_used; /* used inodes */
11365 + uint32_t inodes_total; /* maximum inodes */
11366 + uint32_t reserved; /* reserved for root in % */
11370 +#endif /* CONFIG_COMPAT */
11372 +#include <linux/compiler.h>
11374 +extern int vc_add_dlimit(uint32_t, void __user *);
11375 +extern int vc_rem_dlimit(uint32_t, void __user *);
11377 +extern int vc_set_dlimit(uint32_t, void __user *);
11378 +extern int vc_get_dlimit(uint32_t, void __user *);
11380 +#ifdef CONFIG_COMPAT
11382 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11383 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11385 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11386 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11388 +#endif /* CONFIG_COMPAT */
11390 +#endif /* __KERNEL__ */
11391 +#endif /* _VX_DLIMIT_CMD_H */
11392 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/dlimit.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/dlimit.h
11393 --- linux-2.6.37/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11394 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/dlimit.h 2010-11-23 02:09:41.000000000 +0100
11396 +#ifndef _VX_DLIMIT_H
11397 +#define _VX_DLIMIT_H
11399 +#include "switch.h"
11404 +/* keep in sync with CDLIM_INFINITY */
11406 +#define DLIM_INFINITY (~0ULL)
11408 +#include <linux/spinlock.h>
11409 +#include <linux/rcupdate.h>
11411 +struct super_block;
11414 + struct hlist_node dl_hlist; /* linked list of contexts */
11415 + struct rcu_head dl_rcu; /* the rcu head */
11416 + tag_t dl_tag; /* context tag */
11417 + atomic_t dl_usecnt; /* usage count */
11418 + atomic_t dl_refcnt; /* reference count */
11420 + struct super_block *dl_sb; /* associated superblock */
11422 + spinlock_t dl_lock; /* protect the values */
11424 + unsigned long long dl_space_used; /* used space in bytes */
11425 + unsigned long long dl_space_total; /* maximum space in bytes */
11426 + unsigned long dl_inodes_used; /* used inodes */
11427 + unsigned long dl_inodes_total; /* maximum inodes */
11429 + unsigned int dl_nrlmult; /* non root limit mult */
11434 +extern void rcu_free_dl_info(struct rcu_head *);
11435 +extern void unhash_dl_info(struct dl_info *);
11437 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11442 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11444 +typedef uint64_t dlsize_t;
11446 +#endif /* __KERNEL__ */
11447 +#else /* _VX_DLIMIT_H */
11448 +#warning duplicate inclusion
11449 +#endif /* _VX_DLIMIT_H */
11450 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/global.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/global.h
11451 --- linux-2.6.37/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
11452 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/global.h 2010-11-23 02:09:41.000000000 +0100
11454 +#ifndef _VX_GLOBAL_H
11455 +#define _VX_GLOBAL_H
11458 +extern atomic_t vx_global_ctotal;
11459 +extern atomic_t vx_global_cactive;
11461 +extern atomic_t nx_global_ctotal;
11462 +extern atomic_t nx_global_cactive;
11464 +extern atomic_t vs_global_nsproxy;
11465 +extern atomic_t vs_global_fs;
11466 +extern atomic_t vs_global_mnt_ns;
11467 +extern atomic_t vs_global_uts_ns;
11468 +extern atomic_t vs_global_user_ns;
11469 +extern atomic_t vs_global_pid_ns;
11472 +#endif /* _VX_GLOBAL_H */
11473 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/history.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/history.h
11474 --- linux-2.6.37/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
11475 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/history.h 2010-11-23 02:09:41.000000000 +0100
11477 +#ifndef _VX_HISTORY_H
11478 +#define _VX_HISTORY_H
11483 + VXH_THROW_OOPS = 1,
11487 + VXH_INIT_VX_INFO,
11490 + VXH_CLAIM_VX_INFO,
11491 + VXH_RELEASE_VX_INFO,
11492 + VXH_ALLOC_VX_INFO,
11493 + VXH_DEALLOC_VX_INFO,
11494 + VXH_HASH_VX_INFO,
11495 + VXH_UNHASH_VX_INFO,
11497 + VXH_LOOKUP_VX_INFO,
11498 + VXH_CREATE_VX_INFO,
11501 +struct _vxhe_vxi {
11502 + struct vx_info *ptr;
11508 +struct _vxhe_set_clr {
11512 +struct _vxhe_loc_lookup {
11516 +struct _vx_hist_entry {
11518 + unsigned short seq;
11519 + unsigned short type;
11520 + struct _vxhe_vxi vxi;
11522 + struct _vxhe_set_clr sc;
11523 + struct _vxhe_loc_lookup ll;
11527 +#ifdef CONFIG_VSERVER_HISTORY
11529 +extern unsigned volatile int vxh_active;
11531 +struct _vx_hist_entry *vxh_advance(void *loc);
11535 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11537 + entry->vxi.ptr = vxi;
11539 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11540 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11541 + entry->vxi.xid = vxi->vx_id;
11546 +#define __HERE__ current_text_addr()
11548 +#define __VXH_BODY(__type, __data, __here) \
11549 + struct _vx_hist_entry *entry; \
11551 + preempt_disable(); \
11552 + entry = vxh_advance(__here); \
11554 + entry->type = __type; \
11555 + preempt_enable();
11558 + /* pass vxi only */
11560 +#define __VXH_SMPL \
11561 + __vxh_copy_vxi(entry, vxi)
11564 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11566 + __VXH_BODY(__type, __VXH_SMPL, __here)
11569 + /* pass vxi and data (void *) */
11571 +#define __VXH_DATA \
11572 + __vxh_copy_vxi(entry, vxi); \
11573 + entry->sc.data = data
11576 +void __vxh_data(struct vx_info *vxi, void *data,
11577 + int __type, void *__here)
11579 + __VXH_BODY(__type, __VXH_DATA, __here)
11582 + /* pass vxi and arg (long) */
11584 +#define __VXH_LONG \
11585 + __vxh_copy_vxi(entry, vxi); \
11586 + entry->ll.arg = arg
11589 +void __vxh_long(struct vx_info *vxi, long arg,
11590 + int __type, void *__here)
11592 + __VXH_BODY(__type, __VXH_LONG, __here)
11597 +void __vxh_throw_oops(void *__here)
11599 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11600 + /* prevent further acquisition */
11605 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11607 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11608 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11610 +#define __vxh_init_vx_info(v, d, h) \
11611 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11612 +#define __vxh_set_vx_info(v, d, h) \
11613 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11614 +#define __vxh_clr_vx_info(v, d, h) \
11615 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11617 +#define __vxh_claim_vx_info(v, d, h) \
11618 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11619 +#define __vxh_release_vx_info(v, d, h) \
11620 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11622 +#define vxh_alloc_vx_info(v) \
11623 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11624 +#define vxh_dealloc_vx_info(v) \
11625 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11627 +#define vxh_hash_vx_info(v) \
11628 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11629 +#define vxh_unhash_vx_info(v) \
11630 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11632 +#define vxh_loc_vx_info(v, l) \
11633 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11634 +#define vxh_lookup_vx_info(v, l) \
11635 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11636 +#define vxh_create_vx_info(v, l) \
11637 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11639 +extern void vxh_dump_history(void);
11642 +#else /* CONFIG_VSERVER_HISTORY */
11644 +#define __HERE__ 0
11646 +#define vxh_throw_oops() do { } while (0)
11648 +#define __vxh_get_vx_info(v, h) do { } while (0)
11649 +#define __vxh_put_vx_info(v, h) do { } while (0)
11651 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11652 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11653 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11655 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11656 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11658 +#define vxh_alloc_vx_info(v) do { } while (0)
11659 +#define vxh_dealloc_vx_info(v) do { } while (0)
11661 +#define vxh_hash_vx_info(v) do { } while (0)
11662 +#define vxh_unhash_vx_info(v) do { } while (0)
11664 +#define vxh_loc_vx_info(v, l) do { } while (0)
11665 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11666 +#define vxh_create_vx_info(v, l) do { } while (0)
11668 +#define vxh_dump_history() do { } while (0)
11671 +#endif /* CONFIG_VSERVER_HISTORY */
11673 +#endif /* _VX_HISTORY_H */
11674 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/inode_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/inode_cmd.h
11675 --- linux-2.6.37/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
11676 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/inode_cmd.h 2010-11-23 02:09:41.000000000 +0100
11678 +#ifndef _VX_INODE_CMD_H
11679 +#define _VX_INODE_CMD_H
11682 +/* inode vserver commands */
11684 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
11685 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
11687 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
11688 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
11690 +struct vcmd_ctx_iattr_v1 {
11691 + const char __user *name;
11697 +struct vcmd_ctx_fiattr_v0 {
11707 +#ifdef CONFIG_COMPAT
11709 +#include <asm/compat.h>
11711 +struct vcmd_ctx_iattr_v1_x32 {
11712 + compat_uptr_t name_ptr;
11718 +#endif /* CONFIG_COMPAT */
11720 +#include <linux/compiler.h>
11722 +extern int vc_get_iattr(void __user *);
11723 +extern int vc_set_iattr(void __user *);
11725 +extern int vc_fget_iattr(uint32_t, void __user *);
11726 +extern int vc_fset_iattr(uint32_t, void __user *);
11728 +#ifdef CONFIG_COMPAT
11730 +extern int vc_get_iattr_x32(void __user *);
11731 +extern int vc_set_iattr_x32(void __user *);
11733 +#endif /* CONFIG_COMPAT */
11735 +#endif /* __KERNEL__ */
11736 +#endif /* _VX_INODE_CMD_H */
11737 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/inode.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/inode.h
11738 --- linux-2.6.37/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
11739 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/inode.h 2010-11-23 02:09:41.000000000 +0100
11741 +#ifndef _VX_INODE_H
11742 +#define _VX_INODE_H
11745 +#define IATTR_TAG 0x01000000
11747 +#define IATTR_ADMIN 0x00000001
11748 +#define IATTR_WATCH 0x00000002
11749 +#define IATTR_HIDE 0x00000004
11750 +#define IATTR_FLAGS 0x00000007
11752 +#define IATTR_BARRIER 0x00010000
11753 +#define IATTR_IXUNLINK 0x00020000
11754 +#define IATTR_IMMUTABLE 0x00040000
11755 +#define IATTR_COW 0x00080000
11760 +#ifdef CONFIG_VSERVER_PROC_SECURE
11761 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11762 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11764 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11765 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11768 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11770 +#endif /* __KERNEL__ */
11772 +/* inode ioctls */
11774 +#define FIOC_GETXFLG _IOR('x', 5, long)
11775 +#define FIOC_SETXFLG _IOW('x', 6, long)
11777 +#else /* _VX_INODE_H */
11778 +#warning duplicate inclusion
11779 +#endif /* _VX_INODE_H */
11780 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/Kbuild linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/Kbuild
11781 --- linux-2.6.37/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11782 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/Kbuild 2010-11-23 02:09:41.000000000 +0100
11785 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
11786 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11787 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11788 + debug_cmd.h device_cmd.h
11790 +unifdef-y += switch.h network.h monitor.h inode.h device.h
11792 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/limit_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/limit_cmd.h
11793 --- linux-2.6.37/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11794 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/limit_cmd.h 2010-11-23 02:09:41.000000000 +0100
11796 +#ifndef _VX_LIMIT_CMD_H
11797 +#define _VX_LIMIT_CMD_H
11800 +/* rlimit vserver commands */
11802 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
11803 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
11804 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
11805 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
11806 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
11808 +struct vcmd_ctx_rlimit_v0 {
11810 + uint64_t minimum;
11811 + uint64_t softlimit;
11812 + uint64_t maximum;
11815 +struct vcmd_ctx_rlimit_mask_v0 {
11816 + uint32_t minimum;
11817 + uint32_t softlimit;
11818 + uint32_t maximum;
11821 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
11823 +struct vcmd_rlimit_stat_v0 {
11827 + uint64_t minimum;
11828 + uint64_t maximum;
11831 +#define CRLIM_UNSET (0ULL)
11832 +#define CRLIM_INFINITY (~0ULL)
11833 +#define CRLIM_KEEP (~1ULL)
11837 +#ifdef CONFIG_IA32_EMULATION
11839 +struct vcmd_ctx_rlimit_v0_x32 {
11841 + uint64_t minimum;
11842 + uint64_t softlimit;
11843 + uint64_t maximum;
11844 +} __attribute__ ((packed));
11846 +#endif /* CONFIG_IA32_EMULATION */
11848 +#include <linux/compiler.h>
11850 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11851 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11852 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11853 +extern int vc_reset_hits(struct vx_info *, void __user *);
11854 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11856 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11858 +#ifdef CONFIG_IA32_EMULATION
11860 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11861 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11863 +#endif /* CONFIG_IA32_EMULATION */
11865 +#endif /* __KERNEL__ */
11866 +#endif /* _VX_LIMIT_CMD_H */
11867 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/limit_def.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/limit_def.h
11868 --- linux-2.6.37/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
11869 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/limit_def.h 2010-11-23 02:09:41.000000000 +0100
11871 +#ifndef _VX_LIMIT_DEF_H
11872 +#define _VX_LIMIT_DEF_H
11874 +#include <asm/atomic.h>
11875 +#include <asm/resource.h>
11877 +#include "limit.h"
11880 +struct _vx_res_limit {
11881 + rlim_t soft; /* Context soft limit */
11882 + rlim_t hard; /* Context hard limit */
11884 + rlim_atomic_t rcur; /* Current value */
11885 + rlim_t rmin; /* Context minimum */
11886 + rlim_t rmax; /* Context maximum */
11888 + atomic_t lhit; /* Limit hits */
11891 +/* context sub struct */
11893 +struct _vx_limit {
11894 + struct _vx_res_limit res[NUM_LIMITS];
11897 +#ifdef CONFIG_VSERVER_DEBUG
11899 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11903 + printk("\t_vx_limit:");
11904 + for (i = 0; i < NUM_LIMITS; i++) {
11905 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11906 + i, (unsigned long)__rlim_get(limit, i),
11907 + (unsigned long)__rlim_rmin(limit, i),
11908 + (unsigned long)__rlim_rmax(limit, i),
11909 + (long)__rlim_soft(limit, i),
11910 + (long)__rlim_hard(limit, i),
11911 + atomic_read(&__rlim_lhit(limit, i)));
11917 +#endif /* _VX_LIMIT_DEF_H */
11918 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/limit.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/limit.h
11919 --- linux-2.6.37/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
11920 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/limit.h 2010-11-23 02:09:41.000000000 +0100
11922 +#ifndef _VX_LIMIT_H
11923 +#define _VX_LIMIT_H
11925 +#define VLIMIT_NSOCK 16
11926 +#define VLIMIT_OPENFD 17
11927 +#define VLIMIT_ANON 18
11928 +#define VLIMIT_SHMEM 19
11929 +#define VLIMIT_SEMARY 20
11930 +#define VLIMIT_NSEMS 21
11931 +#define VLIMIT_DENTRY 22
11932 +#define VLIMIT_MAPPED 23
11937 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11939 +/* keep in sync with CRLIM_INFINITY */
11941 +#define VLIM_INFINITY (~0ULL)
11943 +#include <asm/atomic.h>
11944 +#include <asm/resource.h>
11946 +#ifndef RLIM_INFINITY
11947 +#warning RLIM_INFINITY is undefined
11950 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11952 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
11953 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
11955 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
11956 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
11957 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
11959 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
11960 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
11962 +typedef atomic_long_t rlim_atomic_t;
11963 +typedef unsigned long rlim_t;
11965 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
11966 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
11967 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
11968 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
11969 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
11970 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
11973 +#if (RLIM_INFINITY == VLIM_INFINITY)
11974 +#define VX_VLIM(r) ((long long)(long)(r))
11975 +#define VX_RLIM(v) ((rlim_t)(v))
11977 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
11978 + ? VLIM_INFINITY : (long long)(r))
11979 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
11980 + ? RLIM_INFINITY : (rlim_t)(v))
11985 +void vx_vsi_meminfo(struct sysinfo *);
11986 +void vx_vsi_swapinfo(struct sysinfo *);
11987 +long vx_vsi_cached(struct sysinfo *);
11989 +#define NUM_LIMITS 24
11991 +#endif /* __KERNEL__ */
11992 +#endif /* _VX_LIMIT_H */
11993 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/limit_int.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/limit_int.h
11994 --- linux-2.6.37/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
11995 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/limit_int.h 2010-11-23 02:09:41.000000000 +0100
11997 +#ifndef _VX_LIMIT_INT_H
11998 +#define _VX_LIMIT_INT_H
12000 +#include "context.h"
12004 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12005 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12007 +extern const char *vlimit_name[NUM_LIMITS];
12009 +static inline void __vx_acc_cres(struct vx_info *vxi,
12010 + int res, int dir, void *_data, char *_file, int _line)
12012 + if (VXD_RCRES_COND(res))
12013 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12014 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12015 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12016 + (dir > 0) ? "++" : "--", _data, _file, _line);
12021 + __rlim_inc(&vxi->limit, res);
12023 + __rlim_dec(&vxi->limit, res);
12026 +static inline void __vx_add_cres(struct vx_info *vxi,
12027 + int res, int amount, void *_data, char *_file, int _line)
12029 + if (VXD_RCRES_COND(res))
12030 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12031 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12032 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12033 + amount, _data, _file, _line);
12038 + __rlim_add(&vxi->limit, res, amount);
12042 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12044 + int cond = (value > __rlim_rmax(limit, res));
12047 + __rlim_rmax(limit, res) = value;
12052 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12054 + int cond = (value < __rlim_rmin(limit, res));
12057 + __rlim_rmin(limit, res) = value;
12062 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12064 + if (!__vx_cres_adjust_max(limit, res, value))
12065 + __vx_cres_adjust_min(limit, res, value);
12070 + +1 ... no limit hit
12071 + -1 ... over soft limit
12072 + 0 ... over hard limit */
12074 +static inline int __vx_cres_avail(struct vx_info *vxi,
12075 + int res, int num, char *_file, int _line)
12077 + struct _vx_limit *limit;
12080 + if (VXD_RLIMIT_COND(res))
12081 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12082 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12083 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12084 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12085 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12086 + num, _file, _line);
12090 + limit = &vxi->limit;
12091 + value = __rlim_get(limit, res);
12093 + if (!__vx_cres_adjust_max(limit, res, value))
12094 + __vx_cres_adjust_min(limit, res, value);
12099 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12101 + if (value + num <= __rlim_soft(limit, res))
12104 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12106 + if (value + num <= __rlim_hard(limit, res))
12109 + __rlim_hit(limit, res);
12114 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12117 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12119 + rlim_t value, sum = 0;
12122 + while ((res = *array++)) {
12123 + value = __rlim_get(limit, res);
12124 + __vx_cres_fixup(limit, res, value);
12131 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12133 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12134 + int res = *array;
12136 + if (value == __rlim_get(limit, res))
12139 + __rlim_set(limit, res, value);
12140 + /* now adjust min/max */
12141 + if (!__vx_cres_adjust_max(limit, res, value))
12142 + __vx_cres_adjust_min(limit, res, value);
12147 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12148 + const int *array, int num, char *_file, int _line)
12150 + struct _vx_limit *limit;
12151 + rlim_t value = 0;
12159 + limit = &vxi->limit;
12161 + value = __vx_cres_array_sum(limit, array + 1);
12163 + __rlim_set(limit, res, value);
12164 + __vx_cres_fixup(limit, res, value);
12166 + return __vx_cres_avail(vxi, res, num, _file, _line);
12170 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12175 + /* complex resources first */
12176 + if ((id < 0) || (id == RLIMIT_RSS))
12177 + __vx_cres_array_fixup(limit, VLA_RSS);
12179 + for (res = 0; res < NUM_LIMITS; res++) {
12180 + if ((id > 0) && (res != id))
12183 + value = __rlim_get(limit, res);
12184 + __vx_cres_fixup(limit, res, value);
12186 + /* not supposed to happen, maybe warn? */
12187 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12188 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12193 +#endif /* __KERNEL__ */
12194 +#endif /* _VX_LIMIT_INT_H */
12195 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/monitor.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/monitor.h
12196 --- linux-2.6.37/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12197 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/monitor.h 2010-11-23 02:09:41.000000000 +0100
12199 +#ifndef _VX_MONITOR_H
12200 +#define _VX_MONITOR_H
12202 +#include <linux/types.h>
12209 + VXM_UPDATE = 0x20,
12213 + VXM_RQINFO_1 = 0x24,
12216 + VXM_ACTIVATE = 0x40,
12223 + VXM_MIGRATE = 0x48,
12226 + /* all other bits are flags */
12227 + VXM_SCHED = 0x80,
12230 +struct _vxm_update_1 {
12231 + uint32_t tokens_max;
12232 + uint32_t fill_rate;
12233 + uint32_t interval;
12236 +struct _vxm_update_2 {
12237 + uint32_t tokens_min;
12238 + uint32_t fill_rate;
12239 + uint32_t interval;
12242 +struct _vxm_rqinfo_1 {
12243 + uint16_t running;
12247 + uint32_t idle_tokens;
12250 +struct _vxm_rqinfo_2 {
12251 + uint32_t norm_time;
12252 + uint32_t idle_time;
12253 + uint32_t idle_skip;
12256 +struct _vxm_sched {
12258 + uint32_t norm_time;
12259 + uint32_t idle_time;
12262 +struct _vxm_task {
12267 +struct _vxm_event {
12276 + struct _vxm_task tsk;
12280 +struct _vx_mon_entry {
12284 + struct _vxm_event ev;
12285 + struct _vxm_sched sd;
12286 + struct _vxm_update_1 u1;
12287 + struct _vxm_update_2 u2;
12288 + struct _vxm_rqinfo_1 q1;
12289 + struct _vxm_rqinfo_2 q2;
12294 +#endif /* _VX_MONITOR_H */
12295 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/network_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/network_cmd.h
12296 --- linux-2.6.37/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
12297 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/network_cmd.h 2010-11-23 02:09:41.000000000 +0100
12299 +#ifndef _VX_NETWORK_CMD_H
12300 +#define _VX_NETWORK_CMD_H
12303 +/* vinfo commands */
12305 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
12308 +extern int vc_task_nid(uint32_t);
12310 +#endif /* __KERNEL__ */
12312 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
12314 +struct vcmd_nx_info_v0 {
12316 + /* more to come */
12320 +extern int vc_nx_info(struct nx_info *, void __user *);
12322 +#endif /* __KERNEL__ */
12324 +#include <linux/in.h>
12325 +#include <linux/in6.h>
12327 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
12328 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
12330 +struct vcmd_net_create {
12331 + uint64_t flagword;
12334 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
12336 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
12337 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
12339 +struct vcmd_net_addr_v0 {
12342 + struct in_addr ip[4];
12343 + struct in_addr mask[4];
12346 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
12347 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
12349 +struct vcmd_net_addr_ipv4_v1 {
12352 + struct in_addr ip;
12353 + struct in_addr mask;
12356 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
12357 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
12359 +struct vcmd_net_addr_ipv6_v1 {
12363 + struct in6_addr ip;
12364 + struct in6_addr mask;
12367 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
12368 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
12370 +struct vcmd_match_ipv4_v0 {
12375 + struct in_addr ip;
12376 + struct in_addr ip2;
12377 + struct in_addr mask;
12380 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
12381 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
12383 +struct vcmd_match_ipv6_v0 {
12388 + struct in6_addr ip;
12389 + struct in6_addr ip2;
12390 + struct in6_addr mask;
12395 +extern int vc_net_create(uint32_t, void __user *);
12396 +extern int vc_net_migrate(struct nx_info *, void __user *);
12398 +extern int vc_net_add(struct nx_info *, void __user *);
12399 +extern int vc_net_remove(struct nx_info *, void __user *);
12401 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
12402 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
12404 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
12405 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
12407 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
12408 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
12410 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
12411 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
12413 +#endif /* __KERNEL__ */
12416 +/* flag commands */
12418 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
12419 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
12421 +struct vcmd_net_flags_v0 {
12422 + uint64_t flagword;
12427 +extern int vc_get_nflags(struct nx_info *, void __user *);
12428 +extern int vc_set_nflags(struct nx_info *, void __user *);
12430 +#endif /* __KERNEL__ */
12433 +/* network caps commands */
12435 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
12436 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
12438 +struct vcmd_net_caps_v0 {
12444 +extern int vc_get_ncaps(struct nx_info *, void __user *);
12445 +extern int vc_set_ncaps(struct nx_info *, void __user *);
12447 +#endif /* __KERNEL__ */
12448 +#endif /* _VX_CONTEXT_CMD_H */
12449 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/network.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/network.h
12450 --- linux-2.6.37/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12451 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/network.h 2010-11-23 02:09:41.000000000 +0100
12453 +#ifndef _VX_NETWORK_H
12454 +#define _VX_NETWORK_H
12456 +#include <linux/types.h>
12459 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12462 +/* network flags */
12464 +#define NXF_INFO_PRIVATE 0x00000008
12466 +#define NXF_SINGLE_IP 0x00000100
12467 +#define NXF_LBACK_REMAP 0x00000200
12468 +#define NXF_LBACK_ALLOW 0x00000400
12470 +#define NXF_HIDE_NETIF 0x02000000
12471 +#define NXF_HIDE_LBACK 0x04000000
12473 +#define NXF_STATE_SETUP (1ULL << 32)
12474 +#define NXF_STATE_ADMIN (1ULL << 34)
12476 +#define NXF_SC_HELPER (1ULL << 36)
12477 +#define NXF_PERSISTENT (1ULL << 38)
12479 +#define NXF_ONE_TIME (0x0005ULL << 32)
12482 +#define NXF_INIT_SET (__nxf_init_set())
12484 +static inline uint64_t __nxf_init_set(void) {
12485 + return NXF_STATE_ADMIN
12486 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12487 + | NXF_LBACK_REMAP
12490 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12493 + | NXF_HIDE_NETIF;
12497 +/* network caps */
12499 +#define NXC_TUN_CREATE 0x00000001
12501 +#define NXC_RAW_ICMP 0x00000100
12504 +/* address types */
12506 +#define NXA_TYPE_IPV4 0x0001
12507 +#define NXA_TYPE_IPV6 0x0002
12509 +#define NXA_TYPE_NONE 0x0000
12510 +#define NXA_TYPE_ANY 0x00FF
12512 +#define NXA_TYPE_ADDR 0x0010
12513 +#define NXA_TYPE_MASK 0x0020
12514 +#define NXA_TYPE_RANGE 0x0040
12516 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12518 +#define NXA_MOD_BCAST 0x0100
12519 +#define NXA_MOD_LBACK 0x0200
12521 +#define NXA_LOOPBACK 0x1000
12523 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12524 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12528 +#include <linux/list.h>
12529 +#include <linux/spinlock.h>
12530 +#include <linux/rcupdate.h>
12531 +#include <linux/in.h>
12532 +#include <linux/in6.h>
12533 +#include <asm/atomic.h>
12535 +struct nx_addr_v4 {
12536 + struct nx_addr_v4 *next;
12537 + struct in_addr ip[2];
12538 + struct in_addr mask;
12543 +struct nx_addr_v6 {
12544 + struct nx_addr_v6 *next;
12545 + struct in6_addr ip;
12546 + struct in6_addr mask;
12553 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12554 + nid_t nx_id; /* vnet id */
12555 + atomic_t nx_usecnt; /* usage count */
12556 + atomic_t nx_tasks; /* tasks count */
12557 + int nx_state; /* context state */
12559 + uint64_t nx_flags; /* network flag word */
12560 + uint64_t nx_ncaps; /* network capabilities */
12562 + struct in_addr v4_lback; /* Loopback address */
12563 + struct in_addr v4_bcast; /* Broadcast address */
12564 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12565 +#ifdef CONFIG_IPV6
12566 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12568 + char nx_name[65]; /* network context name */
12572 +/* status flags */
12574 +#define NXS_HASHED 0x0001
12575 +#define NXS_SHUTDOWN 0x0100
12576 +#define NXS_RELEASED 0x8000
12578 +extern struct nx_info *lookup_nx_info(int);
12580 +extern int get_nid_list(int, unsigned int *, int);
12581 +extern int nid_is_hashed(nid_t);
12583 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12585 +extern long vs_net_change(struct nx_info *, unsigned int);
12590 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
12591 +#ifdef CONFIG_IPV6
12592 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
12594 +#define NX_IPV6(n) (0)
12597 +#endif /* __KERNEL__ */
12598 +#endif /* _VX_NETWORK_H */
12599 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/percpu.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/percpu.h
12600 --- linux-2.6.37/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
12601 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/percpu.h 2010-11-23 02:09:41.000000000 +0100
12603 +#ifndef _VX_PERCPU_H
12604 +#define _VX_PERCPU_H
12606 +#include "cvirt_def.h"
12607 +#include "sched_def.h"
12609 +struct _vx_percpu {
12610 + struct _vx_cvirt_pc cvirt;
12611 + struct _vx_sched_pc sched;
12614 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
12616 +#endif /* _VX_PERCPU_H */
12617 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/pid.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/pid.h
12618 --- linux-2.6.37/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
12619 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/pid.h 2010-11-23 02:09:41.000000000 +0100
12621 +#ifndef _VSERVER_PID_H
12622 +#define _VSERVER_PID_H
12624 +/* pid faking stuff */
12626 +#define vx_info_map_pid(v, p) \
12627 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12628 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12629 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
12630 +#define vx_map_tgid(p) vx_map_pid(p)
12632 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12633 + const char *func, const char *file, int line)
12635 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12636 + vxfprintk(VXD_CBIT(cvirt, 2),
12637 + "vx_map_tgid: %p/%llx: %d -> %d",
12638 + vxi, (long long)vxi->vx_flags, pid,
12639 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12640 + func, file, line);
12643 + if (pid == vxi->vx_initpid)
12649 +#define vx_info_rmap_pid(v, p) \
12650 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12651 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
12652 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12654 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12655 + const char *func, const char *file, int line)
12657 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12658 + vxfprintk(VXD_CBIT(cvirt, 2),
12659 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12660 + vxi, (long long)vxi->vx_flags, pid,
12661 + (pid == 1) ? vxi->vx_initpid : pid,
12662 + func, file, line);
12663 + if ((pid == 1) && vxi->vx_initpid)
12664 + return vxi->vx_initpid;
12665 + if (pid == vxi->vx_initpid)
12672 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/sched_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/sched_cmd.h
12673 --- linux-2.6.37/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
12674 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/sched_cmd.h 2010-11-23 02:09:41.000000000 +0100
12676 +#ifndef _VX_SCHED_CMD_H
12677 +#define _VX_SCHED_CMD_H
12680 +struct vcmd_prio_bias {
12682 + int32_t prio_bias;
12685 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
12686 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
12690 +#include <linux/compiler.h>
12692 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
12693 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
12695 +#endif /* __KERNEL__ */
12696 +#endif /* _VX_SCHED_CMD_H */
12697 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/sched_def.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/sched_def.h
12698 --- linux-2.6.37/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
12699 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/sched_def.h 2010-11-23 02:09:41.000000000 +0100
12701 +#ifndef _VX_SCHED_DEF_H
12702 +#define _VX_SCHED_DEF_H
12704 +#include <linux/spinlock.h>
12705 +#include <linux/jiffies.h>
12706 +#include <linux/cpumask.h>
12707 +#include <asm/atomic.h>
12708 +#include <asm/param.h>
12711 +/* context sub struct */
12713 +struct _vx_sched {
12714 + int prio_bias; /* bias offset for priority */
12716 + cpumask_t update; /* CPUs which should update */
12719 +struct _vx_sched_pc {
12720 + int prio_bias; /* bias offset for priority */
12722 + uint64_t user_ticks; /* token tick events */
12723 + uint64_t sys_ticks; /* token tick events */
12724 + uint64_t hold_ticks; /* token ticks paused */
12728 +#ifdef CONFIG_VSERVER_DEBUG
12730 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12732 + printk("\t_vx_sched:\n");
12733 + printk("\t priority = %4d\n", sched->prio_bias);
12738 +#endif /* _VX_SCHED_DEF_H */
12739 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/sched.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/sched.h
12740 --- linux-2.6.37/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
12741 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/sched.h 2010-11-23 02:09:41.000000000 +0100
12743 +#ifndef _VX_SCHED_H
12744 +#define _VX_SCHED_H
12751 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12756 +void vx_update_load(struct vx_info *);
12759 +void vx_update_sched_param(struct _vx_sched *sched,
12760 + struct _vx_sched_pc *sched_pc);
12762 +#endif /* __KERNEL__ */
12763 +#else /* _VX_SCHED_H */
12764 +#warning duplicate inclusion
12765 +#endif /* _VX_SCHED_H */
12766 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/signal_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/signal_cmd.h
12767 --- linux-2.6.37/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
12768 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/signal_cmd.h 2010-11-23 02:09:41.000000000 +0100
12770 +#ifndef _VX_SIGNAL_CMD_H
12771 +#define _VX_SIGNAL_CMD_H
12774 +/* signalling vserver commands */
12776 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
12777 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
12779 +struct vcmd_ctx_kill_v0 {
12784 +struct vcmd_wait_exit_v0 {
12785 + int32_t reboot_cmd;
12786 + int32_t exit_code;
12791 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12792 +extern int vc_wait_exit(struct vx_info *, void __user *);
12794 +#endif /* __KERNEL__ */
12796 +/* process alteration commands */
12798 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
12799 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
12801 +struct vcmd_pflags_v0 {
12802 + uint32_t flagword;
12808 +extern int vc_get_pflags(uint32_t pid, void __user *);
12809 +extern int vc_set_pflags(uint32_t pid, void __user *);
12811 +#endif /* __KERNEL__ */
12812 +#endif /* _VX_SIGNAL_CMD_H */
12813 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/signal.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/signal.h
12814 --- linux-2.6.37/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
12815 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/signal.h 2010-11-23 02:09:41.000000000 +0100
12817 +#ifndef _VX_SIGNAL_H
12818 +#define _VX_SIGNAL_H
12825 +int vx_info_kill(struct vx_info *, int, int);
12827 +#endif /* __KERNEL__ */
12828 +#else /* _VX_SIGNAL_H */
12829 +#warning duplicate inclusion
12830 +#endif /* _VX_SIGNAL_H */
12831 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/space_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/space_cmd.h
12832 --- linux-2.6.37/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
12833 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/space_cmd.h 2010-11-23 02:09:41.000000000 +0100
12835 +#ifndef _VX_SPACE_CMD_H
12836 +#define _VX_SPACE_CMD_H
12839 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
12840 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
12841 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
12843 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
12844 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
12845 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
12847 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
12849 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
12850 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
12853 +struct vcmd_space_mask_v1 {
12857 +struct vcmd_space_mask_v2 {
12865 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
12866 +extern int vc_set_space_v1(struct vx_info *, void __user *);
12867 +extern int vc_enter_space(struct vx_info *, void __user *);
12868 +extern int vc_set_space(struct vx_info *, void __user *);
12869 +extern int vc_get_space_mask(void __user *, int);
12871 +#endif /* __KERNEL__ */
12872 +#endif /* _VX_SPACE_CMD_H */
12873 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/space.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/space.h
12874 --- linux-2.6.37/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
12875 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/space.h 2010-11-23 02:09:41.000000000 +0100
12877 +#ifndef _VX_SPACE_H
12878 +#define _VX_SPACE_H
12880 +#include <linux/types.h>
12884 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
12886 +#else /* _VX_SPACE_H */
12887 +#warning duplicate inclusion
12888 +#endif /* _VX_SPACE_H */
12889 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/switch.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/switch.h
12890 --- linux-2.6.37/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
12891 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/switch.h 2010-11-23 02:09:41.000000000 +0100
12893 +#ifndef _VX_SWITCH_H
12894 +#define _VX_SWITCH_H
12896 +#include <linux/types.h>
12899 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
12900 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
12901 +#define VC_VERSION(c) ((c) & 0xFFF)
12903 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
12904 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
12908 + Syscall Matrix V2.8
12910 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
12911 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
12912 + |INFO |SETUP | |MOVE | | | | | |
12913 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12914 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
12915 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
12916 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12917 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
12918 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
12919 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12920 + MEMORY | | | | |MEMCTRL| | |SWAP | |
12921 + | 16| 17| 18| 19| 20| 21| | 22| 23|
12922 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12923 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
12924 + | 24| 25| 26| 27| 28| 29| | 30| 31|
12925 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12926 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
12927 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
12928 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12929 + OTHER |VSTAT | | | | | | |VINFO | |
12930 + | 40| 41| 42| 43| 44| 45| | 46| 47|
12931 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
12932 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
12933 + | 48| 49| 50| 51| 52| 53| | 54| 55|
12934 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12935 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
12936 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
12937 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
12941 +#define VC_CAT_VERSION 0
12943 +#define VC_CAT_VSETUP 1
12944 +#define VC_CAT_VHOST 2
12946 +#define VC_CAT_DEVICE 6
12948 +#define VC_CAT_VPROC 9
12949 +#define VC_CAT_PROCALT 10
12950 +#define VC_CAT_PROCMIG 11
12951 +#define VC_CAT_PROCTRL 12
12953 +#define VC_CAT_SCHED 14
12954 +#define VC_CAT_MEMCTRL 20
12956 +#define VC_CAT_VNET 25
12957 +#define VC_CAT_NETALT 26
12958 +#define VC_CAT_NETMIG 27
12959 +#define VC_CAT_NETCTRL 28
12961 +#define VC_CAT_TAGMIG 35
12962 +#define VC_CAT_DLIMIT 36
12963 +#define VC_CAT_INODE 38
12965 +#define VC_CAT_VSTAT 40
12966 +#define VC_CAT_VINFO 46
12967 +#define VC_CAT_EVENT 48
12969 +#define VC_CAT_FLAGS 52
12970 +#define VC_CAT_VSPACE 54
12971 +#define VC_CAT_DEBUG 56
12972 +#define VC_CAT_RLIMIT 60
12974 +#define VC_CAT_SYSTEST 61
12975 +#define VC_CAT_COMPAT 63
12977 +/* query version */
12979 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
12980 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
12985 +#include <linux/errno.h>
12987 +#endif /* __KERNEL__ */
12989 +#endif /* _VX_SWITCH_H */
12991 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/tag_cmd.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/tag_cmd.h
12992 --- linux-2.6.37/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
12993 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/tag_cmd.h 2010-11-23 02:09:41.000000000 +0100
12995 +#ifndef _VX_TAG_CMD_H
12996 +#define _VX_TAG_CMD_H
12999 +/* vinfo commands */
13001 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13004 +extern int vc_task_tag(uint32_t);
13006 +#endif /* __KERNEL__ */
13008 +/* context commands */
13010 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13013 +extern int vc_tag_migrate(uint32_t);
13015 +#endif /* __KERNEL__ */
13016 +#endif /* _VX_TAG_CMD_H */
13017 diff -NurpP --minimal linux-2.6.37/include/linux/vserver/tag.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/tag.h
13018 --- linux-2.6.37/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13019 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vserver/tag.h 2010-11-23 02:09:41.000000000 +0100
13024 +#include <linux/types.h>
13027 +#define DX_TAG(in) (IS_TAGGED(in))
13030 +#ifdef CONFIG_TAG_NFSD
13031 +#define DX_TAG_NFSD 1
13033 +#define DX_TAG_NFSD 0
13037 +#ifdef CONFIG_TAGGING_NONE
13039 +#define MAX_UID 0xFFFFFFFF
13040 +#define MAX_GID 0xFFFFFFFF
13042 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13044 +#define TAGINO_UID(cond, uid, tag) (uid)
13045 +#define TAGINO_GID(cond, gid, tag) (gid)
13050 +#ifdef CONFIG_TAGGING_GID16
13052 +#define MAX_UID 0xFFFFFFFF
13053 +#define MAX_GID 0x0000FFFF
13055 +#define INOTAG_TAG(cond, uid, gid, tag) \
13056 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13058 +#define TAGINO_UID(cond, uid, tag) (uid)
13059 +#define TAGINO_GID(cond, gid, tag) \
13060 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13065 +#ifdef CONFIG_TAGGING_ID24
13067 +#define MAX_UID 0x00FFFFFF
13068 +#define MAX_GID 0x00FFFFFF
13070 +#define INOTAG_TAG(cond, uid, gid, tag) \
13071 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13073 +#define TAGINO_UID(cond, uid, tag) \
13074 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13075 +#define TAGINO_GID(cond, gid, tag) \
13076 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13081 +#ifdef CONFIG_TAGGING_UID16
13083 +#define MAX_UID 0x0000FFFF
13084 +#define MAX_GID 0xFFFFFFFF
13086 +#define INOTAG_TAG(cond, uid, gid, tag) \
13087 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13089 +#define TAGINO_UID(cond, uid, tag) \
13090 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13091 +#define TAGINO_GID(cond, gid, tag) (gid)
13096 +#ifdef CONFIG_TAGGING_INTERN
13098 +#define MAX_UID 0xFFFFFFFF
13099 +#define MAX_GID 0xFFFFFFFF
13101 +#define INOTAG_TAG(cond, uid, gid, tag) \
13102 + ((cond) ? (tag) : 0)
13104 +#define TAGINO_UID(cond, uid, tag) (uid)
13105 +#define TAGINO_GID(cond, gid, tag) (gid)
13110 +#ifndef CONFIG_TAGGING_NONE
13111 +#define dx_current_fstag(sb) \
13112 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13114 +#define dx_current_fstag(sb) (0)
13117 +#ifndef CONFIG_TAGGING_INTERN
13118 +#define TAGINO_TAG(cond, tag) (0)
13120 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13123 +#define INOTAG_UID(cond, uid, gid) \
13124 + ((cond) ? ((uid) & MAX_UID) : (uid))
13125 +#define INOTAG_GID(cond, uid, gid) \
13126 + ((cond) ? ((gid) & MAX_GID) : (gid))
13129 +static inline uid_t dx_map_uid(uid_t uid)
13131 + if ((uid > MAX_UID) && (uid != -1))
13133 + return (uid & MAX_UID);
13136 +static inline gid_t dx_map_gid(gid_t gid)
13138 + if ((gid > MAX_GID) && (gid != -1))
13140 + return (gid & MAX_GID);
13148 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13150 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13151 + unsigned long *flags);
13153 +#ifdef CONFIG_PROPAGATE
13155 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13157 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13160 +#define dx_propagate_tag(n, i) do { } while (0)
13163 +#endif /* _DX_TAG_H */
13164 diff -NurpP --minimal linux-2.6.37/include/linux/vs_inet6.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_inet6.h
13165 --- linux-2.6.37/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
13166 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_inet6.h 2010-11-23 02:09:41.000000000 +0100
13168 +#ifndef _VS_INET6_H
13169 +#define _VS_INET6_H
13171 +#include "vserver/base.h"
13172 +#include "vserver/network.h"
13173 +#include "vserver/debug.h"
13175 +#include <net/ipv6.h>
13177 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
13178 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
13181 +#ifdef CONFIG_IPV6
13184 +int v6_addr_match(struct nx_addr_v6 *nxa,
13185 + const struct in6_addr *addr, uint16_t mask)
13189 + switch (nxa->type & mask) {
13190 + case NXA_TYPE_MASK:
13191 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
13193 + case NXA_TYPE_ADDR:
13194 + ret = ipv6_addr_equal(&nxa->ip, addr);
13196 + case NXA_TYPE_ANY:
13200 + vxdprintk(VXD_CBIT(net, 0),
13201 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
13202 + nxa, NXAV6(nxa), addr, mask, ret);
13207 +int v6_addr_in_nx_info(struct nx_info *nxi,
13208 + const struct in6_addr *addr, uint16_t mask)
13210 + struct nx_addr_v6 *nxa;
13215 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
13216 + if (v6_addr_match(nxa, addr, mask))
13220 + vxdprintk(VXD_CBIT(net, 0),
13221 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
13222 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
13227 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
13229 + /* FIXME: needs full range checks */
13230 + return v6_addr_match(nxa, &addr->ip, mask);
13234 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
13236 + struct nx_addr_v6 *ptr;
13238 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
13239 + if (v6_nx_addr_match(ptr, nxa, mask))
13246 + * Check if a given address matches for a socket
13248 + * nxi: the socket's nx_info if any
13249 + * addr: to be verified address
13252 +int v6_sock_addr_match (
13253 + struct nx_info *nxi,
13254 + struct inet_sock *inet,
13255 + struct in6_addr *addr)
13257 + struct sock *sk = &inet->sk;
13258 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13260 + if (!ipv6_addr_any(addr) &&
13261 + ipv6_addr_equal(saddr, addr))
13263 + if (ipv6_addr_any(saddr))
13264 + return v6_addr_in_nx_info(nxi, addr, -1);
13269 + * check if address is covered by socket
13271 + * sk: the socket to check against
13272 + * addr: the address in question (must be != 0)
13276 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13278 + struct nx_info *nxi = sk->sk_nx_info;
13279 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13281 + vxdprintk(VXD_CBIT(net, 5),
13282 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
13283 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
13284 + (sk->sk_socket?sk->sk_socket->flags:0));
13286 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13287 + return v6_addr_match(nxa, saddr, -1);
13288 + } else if (nxi) { /* match against nx_info */
13289 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13290 + } else { /* unrestricted any socket */
13296 +/* inet related checks and helpers */
13300 +struct net_device;
13304 +#include <linux/netdevice.h>
13305 +#include <linux/inetdevice.h>
13306 +#include <net/inet_timewait_sock.h>
13309 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13310 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13311 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13316 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13322 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13326 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13328 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
13329 + nxi, nxi ? nxi->nx_id : 0, ifa,
13330 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
13332 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13334 + if (v6_ifa_in_nx_info(ifa, nxi))
13340 +struct nx_v6_sock_addr {
13341 + struct in6_addr saddr; /* Address used for validation */
13342 + struct in6_addr baddr; /* Address used for socket bind */
13346 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13347 + struct nx_v6_sock_addr *nsa)
13349 + // struct sock *sk = &inet->sk;
13350 + // struct nx_info *nxi = sk->sk_nx_info;
13351 + struct in6_addr saddr = addr->sin6_addr;
13352 + struct in6_addr baddr = saddr;
13354 + nsa->saddr = saddr;
13355 + nsa->baddr = baddr;
13360 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13362 + // struct sock *sk = &inet->sk;
13363 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13365 + // *saddr = nsa->baddr;
13366 + // inet->inet_saddr = nsa->baddr;
13370 +int nx_info_has_v6(struct nx_info *nxi)
13374 + if (NX_IPV6(nxi))
13379 +#else /* CONFIG_IPV6 */
13382 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13389 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13395 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13401 +int nx_info_has_v6(struct nx_info *nxi)
13406 +#endif /* CONFIG_IPV6 */
13408 +#define current_nx_info_has_v6() \
13409 + nx_info_has_v6(current_nx_info())
13412 +#warning duplicate inclusion
13414 diff -NurpP --minimal linux-2.6.37/include/linux/vs_inet.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_inet.h
13415 --- linux-2.6.37/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
13416 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_inet.h 2010-11-23 02:09:41.000000000 +0100
13418 +#ifndef _VS_INET_H
13419 +#define _VS_INET_H
13421 +#include "vserver/base.h"
13422 +#include "vserver/network.h"
13423 +#include "vserver/debug.h"
13425 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
13427 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
13428 + NIPQUAD((a)->mask), (a)->type
13429 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
13431 +#define NIPQUAD(addr) \
13432 + ((unsigned char *)&addr)[0], \
13433 + ((unsigned char *)&addr)[1], \
13434 + ((unsigned char *)&addr)[2], \
13435 + ((unsigned char *)&addr)[3]
13437 +#define NIPQUAD_FMT "%u.%u.%u.%u"
13441 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
13443 + __be32 ip = nxa->ip[0].s_addr;
13444 + __be32 mask = nxa->mask.s_addr;
13445 + __be32 bcast = ip | ~mask;
13448 + switch (nxa->type & tmask) {
13449 + case NXA_TYPE_MASK:
13450 + ret = (ip == (addr & mask));
13452 + case NXA_TYPE_ADDR:
13456 + /* fall through to broadcast */
13457 + case NXA_MOD_BCAST:
13458 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
13460 + case NXA_TYPE_RANGE:
13461 + ret = ((nxa->ip[0].s_addr <= addr) &&
13462 + (nxa->ip[1].s_addr > addr));
13464 + case NXA_TYPE_ANY:
13469 + vxdprintk(VXD_CBIT(net, 0),
13470 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
13471 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
13476 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
13478 + struct nx_addr_v4 *nxa;
13485 + /* allow 127.0.0.1 when remapping lback */
13486 + if ((tmask & NXA_LOOPBACK) &&
13487 + (addr == IPI_LOOPBACK) &&
13488 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13491 + /* check for lback address */
13492 + if ((tmask & NXA_MOD_LBACK) &&
13493 + (nxi->v4_lback.s_addr == addr))
13496 + /* check for broadcast address */
13497 + if ((tmask & NXA_MOD_BCAST) &&
13498 + (nxi->v4_bcast.s_addr == addr))
13501 + /* check for v4 addresses */
13502 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
13503 + if (v4_addr_match(nxa, addr, tmask))
13507 + vxdprintk(VXD_CBIT(net, 0),
13508 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
13509 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
13514 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
13516 + /* FIXME: needs full range checks */
13517 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
13521 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
13523 + struct nx_addr_v4 *ptr;
13525 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
13526 + if (v4_nx_addr_match(ptr, nxa, mask))
13531 +#include <net/inet_sock.h>
13534 + * Check if a given address matches for a socket
13536 + * nxi: the socket's nx_info if any
13537 + * addr: to be verified address
13540 +int v4_sock_addr_match (
13541 + struct nx_info *nxi,
13542 + struct inet_sock *inet,
13545 + __be32 saddr = inet->inet_rcv_saddr;
13546 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
13548 + if (addr && (saddr == addr || bcast == addr))
13551 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
13556 +/* inet related checks and helpers */
13560 +struct net_device;
13563 +#ifdef CONFIG_INET
13565 +#include <linux/netdevice.h>
13566 +#include <linux/inetdevice.h>
13567 +#include <net/inet_sock.h>
13568 +#include <net/inet_timewait_sock.h>
13571 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13572 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
13573 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
13577 + * check if address is covered by socket
13579 + * sk: the socket to check against
13580 + * addr: the address in question (must be != 0)
13584 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
13586 + struct nx_info *nxi = sk->sk_nx_info;
13587 + __be32 saddr = inet_rcv_saddr(sk);
13589 + vxdprintk(VXD_CBIT(net, 5),
13590 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
13591 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
13592 + (sk->sk_socket?sk->sk_socket->flags:0));
13594 + if (saddr) { /* direct address match */
13595 + return v4_addr_match(nxa, saddr, -1);
13596 + } else if (nxi) { /* match against nx_info */
13597 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
13598 + } else { /* unrestricted any socket */
13606 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
13608 + vxdprintk(VXD_CBIT(net, 1),
13609 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
13610 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
13611 + nxi ? dev_in_nx_info(dev, nxi) : 0);
13613 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13615 + if (dev_in_nx_info(dev, nxi))
13622 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13628 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
13632 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
13634 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
13635 + nxi, nxi ? nxi->nx_id : 0, ifa,
13636 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
13638 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13640 + if (v4_ifa_in_nx_info(ifa, nxi))
13646 +struct nx_v4_sock_addr {
13647 + __be32 saddr; /* Address used for validation */
13648 + __be32 baddr; /* Address used for socket bind */
13652 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
13653 + struct nx_v4_sock_addr *nsa)
13655 + struct sock *sk = &inet->sk;
13656 + struct nx_info *nxi = sk->sk_nx_info;
13657 + __be32 saddr = addr->sin_addr.s_addr;
13658 + __be32 baddr = saddr;
13660 + vxdprintk(VXD_CBIT(net, 3),
13661 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
13662 + sk, sk->sk_nx_info, sk->sk_socket,
13663 + (sk->sk_socket ? sk->sk_socket->flags : 0),
13667 + if (saddr == INADDR_ANY) {
13668 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
13669 + baddr = nxi->v4.ip[0].s_addr;
13670 + } else if (saddr == IPI_LOOPBACK) {
13671 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13672 + baddr = nxi->v4_lback.s_addr;
13673 + } else { /* normal address bind */
13674 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
13675 + return -EADDRNOTAVAIL;
13679 + vxdprintk(VXD_CBIT(net, 3),
13680 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
13681 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
13683 + nsa->saddr = saddr;
13684 + nsa->baddr = baddr;
13689 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
13691 + inet->inet_saddr = nsa->baddr;
13692 + inet->inet_rcv_saddr = nsa->baddr;
13697 + * helper to simplify inet_lookup_listener
13699 + * nxi: the socket's nx_info if any
13700 + * addr: to be verified address
13701 + * saddr: socket address
13703 +static inline int v4_inet_addr_match (
13704 + struct nx_info *nxi,
13708 + if (addr && (saddr == addr))
13711 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
13715 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
13717 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
13718 + (addr == nxi->v4_lback.s_addr))
13719 + return IPI_LOOPBACK;
13724 +int nx_info_has_v4(struct nx_info *nxi)
13728 + if (NX_IPV4(nxi))
13730 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
13735 +#else /* CONFIG_INET */
13738 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
13744 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13750 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13756 +int nx_info_has_v4(struct nx_info *nxi)
13761 +#endif /* CONFIG_INET */
13763 +#define current_nx_info_has_v4() \
13764 + nx_info_has_v4(current_nx_info())
13767 +// #warning duplicate inclusion
13769 diff -NurpP --minimal linux-2.6.37/include/linux/vs_limit.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_limit.h
13770 --- linux-2.6.37/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
13771 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_limit.h 2010-11-23 02:09:41.000000000 +0100
13773 +#ifndef _VS_LIMIT_H
13774 +#define _VS_LIMIT_H
13776 +#include "vserver/limit.h"
13777 +#include "vserver/base.h"
13778 +#include "vserver/context.h"
13779 +#include "vserver/debug.h"
13780 +#include "vserver/context.h"
13781 +#include "vserver/limit_int.h"
13784 +#define vx_acc_cres(v, d, p, r) \
13785 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13787 +#define vx_acc_cres_cond(x, d, p, r) \
13788 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13789 + r, d, p, __FILE__, __LINE__)
13792 +#define vx_add_cres(v, a, p, r) \
13793 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13794 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13796 +#define vx_add_cres_cond(x, a, p, r) \
13797 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
13798 + r, a, p, __FILE__, __LINE__)
13799 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13802 +/* process and file limits */
13804 +#define vx_nproc_inc(p) \
13805 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13807 +#define vx_nproc_dec(p) \
13808 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13810 +#define vx_files_inc(f) \
13811 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13813 +#define vx_files_dec(f) \
13814 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13816 +#define vx_locks_inc(l) \
13817 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13819 +#define vx_locks_dec(l) \
13820 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13822 +#define vx_openfd_inc(f) \
13823 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
13825 +#define vx_openfd_dec(f) \
13826 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
13829 +#define vx_cres_avail(v, n, r) \
13830 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13833 +#define vx_nproc_avail(n) \
13834 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
13836 +#define vx_files_avail(n) \
13837 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
13839 +#define vx_locks_avail(n) \
13840 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
13842 +#define vx_openfd_avail(n) \
13843 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
13846 +/* dentry limits */
13848 +#define vx_dentry_inc(d) do { \
13849 + if (atomic_read(&d->d_count) == 1) \
13850 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
13853 +#define vx_dentry_dec(d) do { \
13854 + if (atomic_read(&d->d_count) == 0) \
13855 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
13858 +#define vx_dentry_avail(n) \
13859 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
13862 +/* socket limits */
13864 +#define vx_sock_inc(s) \
13865 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
13867 +#define vx_sock_dec(s) \
13868 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
13870 +#define vx_sock_avail(n) \
13871 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
13874 +/* ipc resource limits */
13876 +#define vx_ipcmsg_add(v, u, a) \
13877 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
13879 +#define vx_ipcmsg_sub(v, u, a) \
13880 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
13882 +#define vx_ipcmsg_avail(v, a) \
13883 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
13886 +#define vx_ipcshm_add(v, k, a) \
13887 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13889 +#define vx_ipcshm_sub(v, k, a) \
13890 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13892 +#define vx_ipcshm_avail(v, a) \
13893 + vx_cres_avail(v, a, VLIMIT_SHMEM)
13896 +#define vx_semary_inc(a) \
13897 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
13899 +#define vx_semary_dec(a) \
13900 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
13903 +#define vx_nsems_add(a,n) \
13904 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
13906 +#define vx_nsems_sub(a,n) \
13907 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
13911 +#warning duplicate inclusion
13913 diff -NurpP --minimal linux-2.6.37/include/linux/vs_memory.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_memory.h
13914 --- linux-2.6.37/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
13915 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_memory.h 2010-11-23 02:09:41.000000000 +0100
13917 +#ifndef _VS_MEMORY_H
13918 +#define _VS_MEMORY_H
13920 +#include "vserver/limit.h"
13921 +#include "vserver/base.h"
13922 +#include "vserver/context.h"
13923 +#include "vserver/debug.h"
13924 +#include "vserver/context.h"
13925 +#include "vserver/limit_int.h"
13928 + VXPT_UNKNOWN = 0,
13937 +#define vx_page_fault(mm, vma, type, ret)
13941 +void __vx_page_fault(struct mm_struct *mm,
13942 + struct vm_area_struct *vma, int type, int ret)
13944 + struct vx_info *vxi = mm->mm_vx_info;
13947 + static char *page_type[6] =
13948 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
13949 + static char *page_what[4] =
13950 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
13956 + what = (ret & 0x3);
13958 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
13959 + type, what, ret, page_type[type], page_what[what]);
13961 + if (ret & VM_FAULT_WRITE)
13963 + atomic_inc(&vxi->cacct.page[type][what]);
13966 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
13970 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
13973 +#warning duplicate inclusion
13975 diff -NurpP --minimal linux-2.6.37/include/linux/vs_network.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_network.h
13976 --- linux-2.6.37/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
13977 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_network.h 2010-11-23 02:09:41.000000000 +0100
13979 +#ifndef _NX_VS_NETWORK_H
13980 +#define _NX_VS_NETWORK_H
13982 +#include "vserver/context.h"
13983 +#include "vserver/network.h"
13984 +#include "vserver/base.h"
13985 +#include "vserver/check.h"
13986 +#include "vserver/debug.h"
13988 +#include <linux/sched.h>
13991 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
13993 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
13994 + const char *_file, int _line)
13999 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
14000 + nxi, nxi ? nxi->nx_id : 0,
14001 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14004 + atomic_inc(&nxi->nx_usecnt);
14009 +extern void free_nx_info(struct nx_info *);
14011 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
14013 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
14018 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
14019 + nxi, nxi ? nxi->nx_id : 0,
14020 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14023 + if (atomic_dec_and_test(&nxi->nx_usecnt))
14024 + free_nx_info(nxi);
14028 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
14030 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14031 + const char *_file, int _line)
14034 + vxlprintk(VXD_CBIT(nid, 3),
14035 + "init_nx_info(%p[#%d.%d])",
14036 + nxi, nxi ? nxi->nx_id : 0,
14037 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14040 + atomic_inc(&nxi->nx_usecnt);
14046 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
14048 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
14049 + const char *_file, int _line)
14051 + struct nx_info *nxo;
14056 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
14057 + nxi, nxi ? nxi->nx_id : 0,
14058 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14061 + atomic_inc(&nxi->nx_usecnt);
14062 + nxo = xchg(nxp, nxi);
14066 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
14068 +static inline void __clr_nx_info(struct nx_info **nxp,
14069 + const char *_file, int _line)
14071 + struct nx_info *nxo;
14073 + nxo = xchg(nxp, NULL);
14077 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
14078 + nxo, nxo ? nxo->nx_id : 0,
14079 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
14082 + if (atomic_dec_and_test(&nxo->nx_usecnt))
14083 + free_nx_info(nxo);
14087 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
14089 +static inline void __claim_nx_info(struct nx_info *nxi,
14090 + struct task_struct *task, const char *_file, int _line)
14092 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
14093 + nxi, nxi ? nxi->nx_id : 0,
14094 + nxi?atomic_read(&nxi->nx_usecnt):0,
14095 + nxi?atomic_read(&nxi->nx_tasks):0,
14096 + task, _file, _line);
14098 + atomic_inc(&nxi->nx_tasks);
14102 +extern void unhash_nx_info(struct nx_info *);
14104 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
14106 +static inline void __release_nx_info(struct nx_info *nxi,
14107 + struct task_struct *task, const char *_file, int _line)
14109 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
14110 + nxi, nxi ? nxi->nx_id : 0,
14111 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
14112 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
14113 + task, _file, _line);
14117 + if (atomic_dec_and_test(&nxi->nx_tasks))
14118 + unhash_nx_info(nxi);
14122 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
14124 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
14125 + const char *_file, int _line)
14127 + struct nx_info *nxi;
14130 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
14131 + p, _file, _line);
14132 + nxi = __get_nx_info(p->nx_info, _file, _line);
14138 +static inline void exit_nx_info(struct task_struct *p)
14141 + release_nx_info(p->nx_info, p);
14146 +#warning duplicate inclusion
14148 diff -NurpP --minimal linux-2.6.37/include/linux/vs_pid.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_pid.h
14149 --- linux-2.6.37/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
14150 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_pid.h 2010-11-23 02:09:41.000000000 +0100
14155 +#include "vserver/base.h"
14156 +#include "vserver/check.h"
14157 +#include "vserver/context.h"
14158 +#include "vserver/debug.h"
14159 +#include "vserver/pid.h"
14160 +#include <linux/pid_namespace.h>
14163 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
14166 +int vx_proc_task_visible(struct task_struct *task)
14168 + if ((task->pid == 1) &&
14169 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
14170 + /* show a blend through init */
14172 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
14179 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
14184 +struct task_struct *vx_find_proc_task_by_pid(int pid)
14186 + struct task_struct *task = find_task_by_real_pid(pid);
14188 + if (task && !vx_proc_task_visible(task)) {
14189 + vxdprintk(VXD_CBIT(misc, 6),
14190 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
14191 + task, task->xid, task->pid,
14192 + current, current->xid, current->pid);
14201 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
14203 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
14205 + if (task && !vx_proc_task_visible(task)) {
14206 + vxdprintk(VXD_CBIT(misc, 6),
14207 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
14208 + task, task->xid, task->pid,
14209 + current, current->xid, current->pid);
14210 + put_task_struct(task);
14219 +struct task_struct *vx_child_reaper(struct task_struct *p)
14221 + struct vx_info *vxi = p->vx_info;
14222 + struct task_struct *reaper = child_reaper(p);
14227 + BUG_ON(!p->vx_info->vx_reaper);
14229 + /* child reaper for the guest reaper */
14230 + if (vxi->vx_reaper == p)
14233 + reaper = vxi->vx_reaper;
14235 + vxdprintk(VXD_CBIT(xid, 7),
14236 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
14237 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
14245 +#warning duplicate inclusion
14247 diff -NurpP --minimal linux-2.6.37/include/linux/vs_sched.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_sched.h
14248 --- linux-2.6.37/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
14249 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_sched.h 2010-11-23 02:09:41.000000000 +0100
14251 +#ifndef _VS_SCHED_H
14252 +#define _VS_SCHED_H
14254 +#include "vserver/base.h"
14255 +#include "vserver/context.h"
14256 +#include "vserver/sched.h"
14259 +#define MAX_PRIO_BIAS 20
14260 +#define MIN_PRIO_BIAS -20
14263 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
14265 + struct vx_info *vxi = p->vx_info;
14268 + prio += vx_cpu(vxi, sched_pc).prio_bias;
14272 +static inline void vx_account_user(struct vx_info *vxi,
14273 + cputime_t cputime, int nice)
14277 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
14280 +static inline void vx_account_system(struct vx_info *vxi,
14281 + cputime_t cputime, int idle)
14285 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
14289 +#warning duplicate inclusion
14291 diff -NurpP --minimal linux-2.6.37/include/linux/vs_socket.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_socket.h
14292 --- linux-2.6.37/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
14293 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_socket.h 2010-11-23 02:09:41.000000000 +0100
14295 +#ifndef _VS_SOCKET_H
14296 +#define _VS_SOCKET_H
14298 +#include "vserver/debug.h"
14299 +#include "vserver/base.h"
14300 +#include "vserver/cacct.h"
14301 +#include "vserver/context.h"
14302 +#include "vserver/tag.h"
14305 +/* socket accounting */
14307 +#include <linux/socket.h>
14309 +static inline int vx_sock_type(int family)
14311 + switch (family) {
14313 + return VXA_SOCK_UNSPEC;
14315 + return VXA_SOCK_UNIX;
14317 + return VXA_SOCK_INET;
14319 + return VXA_SOCK_INET6;
14321 + return VXA_SOCK_PACKET;
14323 + return VXA_SOCK_OTHER;
14327 +#define vx_acc_sock(v, f, p, s) \
14328 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
14330 +static inline void __vx_acc_sock(struct vx_info *vxi,
14331 + int family, int pos, int size, char *file, int line)
14334 + int type = vx_sock_type(family);
14336 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
14337 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
14341 +#define vx_sock_recv(sk, s) \
14342 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
14343 +#define vx_sock_send(sk, s) \
14344 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
14345 +#define vx_sock_fail(sk, s) \
14346 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
14349 +#define sock_vx_init(s) do { \
14350 + (s)->sk_xid = 0; \
14351 + (s)->sk_vx_info = NULL; \
14354 +#define sock_nx_init(s) do { \
14355 + (s)->sk_nid = 0; \
14356 + (s)->sk_nx_info = NULL; \
14360 +#warning duplicate inclusion
14362 diff -NurpP --minimal linux-2.6.37/include/linux/vs_tag.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_tag.h
14363 --- linux-2.6.37/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
14364 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_tag.h 2010-11-23 02:09:41.000000000 +0100
14369 +#include <linux/vserver/tag.h>
14371 +/* check conditions */
14373 +#define DX_ADMIN 0x0001
14374 +#define DX_WATCH 0x0002
14375 +#define DX_HOSTID 0x0008
14377 +#define DX_IDENT 0x0010
14379 +#define DX_ARG_MASK 0x0010
14382 +#define dx_task_tag(t) ((t)->tag)
14384 +#define dx_current_tag() dx_task_tag(current)
14386 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14388 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14392 + * check current context for ADMIN/WATCH and
14393 + * optionally against supplied argument
14395 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14397 + if (mode & DX_ARG_MASK) {
14398 + if ((mode & DX_IDENT) && (id == cid))
14401 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14402 + ((mode & DX_WATCH) && (cid == 1)) ||
14403 + ((mode & DX_HOSTID) && (id == 0)));
14407 +int dx_permission(const struct inode *inode, int mask);
14411 +#warning duplicate inclusion
14413 diff -NurpP --minimal linux-2.6.37/include/linux/vs_time.h linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_time.h
14414 --- linux-2.6.37/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
14415 +++ linux-2.6.37-vs2.3.0.37-rc3/include/linux/vs_time.h 2010-11-23 02:09:41.000000000 +0100
14417 +#ifndef _VS_TIME_H
14418 +#define _VS_TIME_H
14421 +/* time faking stuff */
14423 +#ifdef CONFIG_VSERVER_VTIME
14425 +extern void vx_adjust_timespec(struct timespec *ts);
14426 +extern int vx_settimeofday(struct timespec *ts);
14429 +#define vx_adjust_timespec(t) do { } while (0)
14430 +#define vx_settimeofday(t) do_settimeofday(t)
14434 +#warning duplicate inclusion
14436 diff -NurpP --minimal linux-2.6.37/include/net/addrconf.h linux-2.6.37-vs2.3.0.37-rc3/include/net/addrconf.h
14437 --- linux-2.6.37/include/net/addrconf.h 2011-01-05 21:50:35.000000000 +0100
14438 +++ linux-2.6.37-vs2.3.0.37-rc3/include/net/addrconf.h 2010-11-23 02:09:41.000000000 +0100
14439 @@ -84,7 +84,8 @@ extern int ipv6_dev_get_saddr(struct n
14440 struct net_device *dev,
14441 const struct in6_addr *daddr,
14442 unsigned int srcprefs,
14443 - struct in6_addr *saddr);
14444 + struct in6_addr *saddr,
14445 + struct nx_info *nxi);
14446 extern int ipv6_get_lladdr(struct net_device *dev,
14447 struct in6_addr *addr,
14448 unsigned char banned_flags);
14449 diff -NurpP --minimal linux-2.6.37/include/net/af_unix.h linux-2.6.37-vs2.3.0.37-rc3/include/net/af_unix.h
14450 --- linux-2.6.37/include/net/af_unix.h 2011-01-05 21:50:35.000000000 +0100
14451 +++ linux-2.6.37-vs2.3.0.37-rc3/include/net/af_unix.h 2011-01-05 22:30:40.000000000 +0100
14453 #include <linux/socket.h>
14454 #include <linux/un.h>
14455 #include <linux/mutex.h>
14456 +#include <linux/vs_base.h>
14457 #include <net/sock.h>
14459 extern void unix_inflight(struct file *fp);
14460 diff -NurpP --minimal linux-2.6.37/include/net/inet_timewait_sock.h linux-2.6.37-vs2.3.0.37-rc3/include/net/inet_timewait_sock.h
14461 --- linux-2.6.37/include/net/inet_timewait_sock.h 2010-08-02 16:52:56.000000000 +0200
14462 +++ linux-2.6.37-vs2.3.0.37-rc3/include/net/inet_timewait_sock.h 2010-11-23 02:09:41.000000000 +0100
14463 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
14464 #define tw_hash __tw_common.skc_hash
14465 #define tw_prot __tw_common.skc_prot
14466 #define tw_net __tw_common.skc_net
14467 +#define tw_xid __tw_common.skc_xid
14468 +#define tw_vx_info __tw_common.skc_vx_info
14469 +#define tw_nid __tw_common.skc_nid
14470 +#define tw_nx_info __tw_common.skc_nx_info
14472 volatile unsigned char tw_substate;
14473 /* 3 bits hole, try to pack */
14474 diff -NurpP --minimal linux-2.6.37/include/net/route.h linux-2.6.37-vs2.3.0.37-rc3/include/net/route.h
14475 --- linux-2.6.37/include/net/route.h 2010-10-21 13:07:56.000000000 +0200
14476 +++ linux-2.6.37-vs2.3.0.37-rc3/include/net/route.h 2010-11-23 02:09:41.000000000 +0100
14477 @@ -145,6 +145,9 @@ static inline void ip_rt_put(struct rtab
14478 dst_release(&rt->dst);
14481 +#include <linux/vs_base.h>
14482 +#include <linux/vs_inet.h>
14484 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14486 extern const __u8 ip_tos2prio[16];
14487 @@ -154,6 +157,9 @@ static inline char rt_tos2priority(u8 to
14488 return ip_tos2prio[IPTOS_TOS(tos)>>1];
14491 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
14492 + struct rtable **, struct flowi *);
14494 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
14495 __be32 src, u32 tos, int oif, u8 protocol,
14496 __be16 sport, __be16 dport, struct sock *sk,
14497 @@ -171,11 +177,24 @@ static inline int ip_route_connect(struc
14500 struct net *net = sock_net(sk);
14501 + struct nx_info *nx_info = current_nx_info();
14503 if (inet_sk(sk)->transparent)
14504 fl.flags |= FLOWI_FLAG_ANYSRC;
14506 - if (!dst || !src) {
14508 + nx_info = sk->sk_nx_info;
14510 + vxdprintk(VXD_CBIT(net, 4),
14511 + "ip_route_connect(%p) %p,%p;%lx",
14512 + sk, nx_info, sk->sk_socket,
14513 + (sk->sk_socket?sk->sk_socket->flags:0));
14515 + err = ip_v4_find_src(net, nx_info, rp, &fl);
14519 + if (!fl.fl4_dst || !fl.fl4_src) {
14520 err = __ip_route_output_key(net, rp, &fl);
14523 diff -NurpP --minimal linux-2.6.37/include/net/sock.h linux-2.6.37-vs2.3.0.37-rc3/include/net/sock.h
14524 --- linux-2.6.37/include/net/sock.h 2011-01-05 21:50:36.000000000 +0100
14525 +++ linux-2.6.37-vs2.3.0.37-rc3/include/net/sock.h 2011-01-05 22:30:42.000000000 +0100
14526 @@ -150,6 +150,10 @@ struct sock_common {
14527 #ifdef CONFIG_NET_NS
14528 struct net *skc_net;
14531 + struct vx_info *skc_vx_info;
14533 + struct nx_info *skc_nx_info;
14537 @@ -241,6 +245,10 @@ struct sock {
14538 #define sk_bind_node __sk_common.skc_bind_node
14539 #define sk_prot __sk_common.skc_prot
14540 #define sk_net __sk_common.skc_net
14541 +#define sk_xid __sk_common.skc_xid
14542 +#define sk_vx_info __sk_common.skc_vx_info
14543 +#define sk_nid __sk_common.skc_nid
14544 +#define sk_nx_info __sk_common.skc_nx_info
14545 kmemcheck_bitfield_begin(flags);
14546 unsigned int sk_shutdown : 2,
14548 diff -NurpP --minimal linux-2.6.37/init/Kconfig linux-2.6.37-vs2.3.0.37-rc3/init/Kconfig
14549 --- linux-2.6.37/init/Kconfig 2011-01-05 21:50:37.000000000 +0100
14550 +++ linux-2.6.37-vs2.3.0.37-rc3/init/Kconfig 2011-01-05 22:30:42.000000000 +0100
14551 @@ -503,6 +503,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14553 boolean "Control Group support"
14557 This option adds support for grouping sets of processes together, for
14558 use with process control subsystems such as Cpusets, CFS, memory
14559 @@ -528,6 +529,7 @@ config CGROUP_DEBUG
14562 bool "Namespace cgroup subsystem"
14565 Provides a simple namespace cgroup subsystem to
14566 provide hierarchical naming of sets of namespaces,
14567 diff -NurpP --minimal linux-2.6.37/init/main.c linux-2.6.37-vs2.3.0.37-rc3/init/main.c
14568 --- linux-2.6.37/init/main.c 2011-01-05 21:50:37.000000000 +0100
14569 +++ linux-2.6.37-vs2.3.0.37-rc3/init/main.c 2010-11-23 02:09:41.000000000 +0100
14571 #include <linux/sfi.h>
14572 #include <linux/shmem_fs.h>
14573 #include <linux/slab.h>
14574 +#include <linux/vserver/percpu.h>
14576 #include <asm/io.h>
14577 #include <asm/bugs.h>
14578 diff -NurpP --minimal linux-2.6.37/ipc/mqueue.c linux-2.6.37-vs2.3.0.37-rc3/ipc/mqueue.c
14579 --- linux-2.6.37/ipc/mqueue.c 2011-01-05 21:50:37.000000000 +0100
14580 +++ linux-2.6.37-vs2.3.0.37-rc3/ipc/mqueue.c 2010-11-23 02:09:41.000000000 +0100
14582 #include <linux/pid.h>
14583 #include <linux/ipc_namespace.h>
14584 #include <linux/slab.h>
14585 +#include <linux/vs_context.h>
14586 +#include <linux/vs_limit.h>
14588 #include <net/sock.h>
14590 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14591 struct sigevent notify;
14592 struct pid* notify_owner;
14593 struct user_struct *user; /* user who created, for accounting */
14594 + struct vx_info *vxi;
14595 struct sock *notify_sock;
14596 struct sk_buff *notify_cookie;
14598 @@ -126,6 +129,7 @@ static struct inode *mqueue_get_inode(st
14599 if (S_ISREG(mode)) {
14600 struct mqueue_inode_info *info;
14601 struct task_struct *p = current;
14602 + struct vx_info *vxi = p->vx_info;
14603 unsigned long mq_bytes, mq_msg_tblsz;
14605 inode->i_fop = &mqueue_file_operations;
14606 @@ -139,6 +143,7 @@ static struct inode *mqueue_get_inode(st
14607 info->notify_owner = NULL;
14609 info->user = NULL; /* set when all is ok */
14610 + info->vxi = NULL;
14611 memset(&info->attr, 0, sizeof(info->attr));
14612 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14613 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14614 @@ -157,16 +162,19 @@ static struct inode *mqueue_get_inode(st
14615 spin_lock(&mq_lock);
14616 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14617 u->mq_bytes + mq_bytes >
14618 - task_rlimit(p, RLIMIT_MSGQUEUE)) {
14619 + task_rlimit(p, RLIMIT_MSGQUEUE) ||
14620 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14621 spin_unlock(&mq_lock);
14622 /* mqueue_evict_inode() releases info->messages */
14625 u->mq_bytes += mq_bytes;
14626 + vx_ipcmsg_add(vxi, u, mq_bytes);
14627 spin_unlock(&mq_lock);
14630 info->user = get_uid(u);
14631 + info->vxi = get_vx_info(vxi);
14632 } else if (S_ISDIR(mode)) {
14634 /* Some things misbehave if size == 0 on a directory */
14635 @@ -268,8 +276,11 @@ static void mqueue_evict_inode(struct in
14636 + info->attr.mq_msgsize);
14639 + struct vx_info *vxi = info->vxi;
14641 spin_lock(&mq_lock);
14642 user->mq_bytes -= mq_bytes;
14643 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14645 * get_ns_from_inode() ensures that the
14646 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14647 @@ -279,6 +290,7 @@ static void mqueue_evict_inode(struct in
14649 ipc_ns->mq_queues_count--;
14650 spin_unlock(&mq_lock);
14651 + put_vx_info(vxi);
14655 diff -NurpP --minimal linux-2.6.37/ipc/msg.c linux-2.6.37-vs2.3.0.37-rc3/ipc/msg.c
14656 --- linux-2.6.37/ipc/msg.c 2010-08-02 16:52:57.000000000 +0200
14657 +++ linux-2.6.37-vs2.3.0.37-rc3/ipc/msg.c 2010-11-23 02:09:41.000000000 +0100
14659 #include <linux/rwsem.h>
14660 #include <linux/nsproxy.h>
14661 #include <linux/ipc_namespace.h>
14662 +#include <linux/vs_base.h>
14664 #include <asm/current.h>
14665 #include <asm/uaccess.h>
14666 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14668 msq->q_perm.mode = msgflg & S_IRWXUGO;
14669 msq->q_perm.key = key;
14670 + msq->q_perm.xid = vx_current_xid();
14672 msq->q_perm.security = NULL;
14673 retval = security_msg_queue_alloc(msq);
14674 diff -NurpP --minimal linux-2.6.37/ipc/namespace.c linux-2.6.37-vs2.3.0.37-rc3/ipc/namespace.c
14675 --- linux-2.6.37/ipc/namespace.c 2009-09-10 15:26:27.000000000 +0200
14676 +++ linux-2.6.37-vs2.3.0.37-rc3/ipc/namespace.c 2010-11-23 02:09:41.000000000 +0100
14678 #include <linux/slab.h>
14679 #include <linux/fs.h>
14680 #include <linux/mount.h>
14681 +#include <linux/vs_base.h>
14682 +#include <linux/vserver/global.h>
14686 diff -NurpP --minimal linux-2.6.37/ipc/sem.c linux-2.6.37-vs2.3.0.37-rc3/ipc/sem.c
14687 --- linux-2.6.37/ipc/sem.c 2010-10-21 13:07:56.000000000 +0200
14688 +++ linux-2.6.37-vs2.3.0.37-rc3/ipc/sem.c 2010-11-23 02:09:41.000000000 +0100
14690 #include <linux/rwsem.h>
14691 #include <linux/nsproxy.h>
14692 #include <linux/ipc_namespace.h>
14693 +#include <linux/vs_base.h>
14694 +#include <linux/vs_limit.h>
14696 #include <asm/uaccess.h>
14698 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
14700 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14701 sma->sem_perm.key = key;
14702 + sma->sem_perm.xid = vx_current_xid();
14704 sma->sem_perm.security = NULL;
14705 retval = security_sem_alloc(sma);
14706 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
14709 ns->used_sems += nsems;
14710 + /* FIXME: obsoleted? */
14711 + vx_semary_inc(sma);
14712 + vx_nsems_add(sma, nsems);
14714 sma->sem_base = (struct sem *) &sma[1];
14716 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
14718 wake_up_sem_queue_do(&tasks);
14719 ns->used_sems -= sma->sem_nsems;
14720 + /* FIXME: obsoleted? */
14721 + vx_nsems_sub(sma, sma->sem_nsems);
14722 + vx_semary_dec(sma);
14723 security_sem_free(sma);
14724 ipc_rcu_putref(sma);
14726 diff -NurpP --minimal linux-2.6.37/ipc/shm.c linux-2.6.37-vs2.3.0.37-rc3/ipc/shm.c
14727 --- linux-2.6.37/ipc/shm.c 2011-01-05 21:50:37.000000000 +0100
14728 +++ linux-2.6.37-vs2.3.0.37-rc3/ipc/shm.c 2010-11-23 02:09:41.000000000 +0100
14730 #include <linux/nsproxy.h>
14731 #include <linux/mount.h>
14732 #include <linux/ipc_namespace.h>
14733 +#include <linux/vs_context.h>
14734 +#include <linux/vs_limit.h>
14736 #include <asm/uaccess.h>
14738 @@ -173,7 +175,12 @@ static void shm_open(struct vm_area_stru
14740 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14742 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14743 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14744 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14746 + vx_ipcshm_sub(vxi, shp, numpages);
14747 + ns->shm_tot -= numpages;
14751 if (!is_file_hugepages(shp->shm_file))
14752 @@ -183,6 +190,7 @@ static void shm_destroy(struct ipc_names
14754 fput (shp->shm_file);
14755 security_shm_free(shp);
14756 + put_vx_info(vxi);
14757 ipc_rcu_putref(shp);
14760 @@ -355,11 +363,15 @@ static int newseg(struct ipc_namespace *
14761 if (ns->shm_tot + numpages > ns->shm_ctlall)
14764 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14767 shp = ipc_rcu_alloc(sizeof(*shp));
14771 shp->shm_perm.key = key;
14772 + shp->shm_perm.xid = vx_current_xid();
14773 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14774 shp->mlock_user = NULL;
14776 @@ -413,6 +425,7 @@ static int newseg(struct ipc_namespace *
14777 ns->shm_tot += numpages;
14778 error = shp->shm_perm.id;
14780 + vx_ipcshm_add(current_vx_info(), key, numpages);
14784 diff -NurpP --minimal linux-2.6.37/kernel/capability.c linux-2.6.37-vs2.3.0.37-rc3/kernel/capability.c
14785 --- linux-2.6.37/kernel/capability.c 2010-08-02 16:52:57.000000000 +0200
14786 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/capability.c 2010-11-23 02:09:41.000000000 +0100
14788 #include <linux/security.h>
14789 #include <linux/syscalls.h>
14790 #include <linux/pid_namespace.h>
14791 +#include <linux/vs_context.h>
14792 #include <asm/uaccess.h>
14795 @@ -119,6 +120,7 @@ static int cap_validate_magic(cap_user_h
14801 * The only thing that can change the capabilities of the current
14802 * process is the current process. As such, we can't be in this code
14803 @@ -289,6 +291,8 @@ error:
14807 +#include <linux/vserver/base.h>
14810 * capable - Determine if the current task has a superior capability in effect
14811 * @cap: The capability to be tested for
14812 @@ -301,6 +305,9 @@ error:
14814 int capable(int cap)
14816 + /* here for now so we don't require task locking */
14817 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
14819 if (unlikely(!cap_valid(cap))) {
14820 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
14822 diff -NurpP --minimal linux-2.6.37/kernel/compat.c linux-2.6.37-vs2.3.0.37-rc3/kernel/compat.c
14823 --- linux-2.6.37/kernel/compat.c 2010-10-21 13:07:56.000000000 +0200
14824 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/compat.c 2010-11-23 02:09:41.000000000 +0100
14825 @@ -914,7 +914,7 @@ asmlinkage long compat_sys_stime(compat_
14829 - do_settimeofday(&tv);
14830 + vx_settimeofday(&tv);
14834 diff -NurpP --minimal linux-2.6.37/kernel/cred.c linux-2.6.37-vs2.3.0.37-rc3/kernel/cred.c
14835 --- linux-2.6.37/kernel/cred.c 2011-01-05 21:50:37.000000000 +0100
14836 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/cred.c 2011-01-31 21:05:40.000000000 +0100
14837 @@ -60,31 +60,6 @@ struct cred init_cred = {
14841 -static inline void set_cred_subscribers(struct cred *cred, int n)
14843 -#ifdef CONFIG_DEBUG_CREDENTIALS
14844 - atomic_set(&cred->subscribers, n);
14848 -static inline int read_cred_subscribers(const struct cred *cred)
14850 -#ifdef CONFIG_DEBUG_CREDENTIALS
14851 - return atomic_read(&cred->subscribers);
14857 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14859 -#ifdef CONFIG_DEBUG_CREDENTIALS
14860 - struct cred *cred = (struct cred *) _cred;
14862 - atomic_add(n, &cred->subscribers);
14867 * Dispose of the shared task group credentials
14869 @@ -280,21 +255,16 @@ error:
14871 * Call commit_creds() or abort_creds() to clean up.
14873 -struct cred *prepare_creds(void)
14874 +struct cred *__prepare_creds(const struct cred *old)
14876 - struct task_struct *task = current;
14877 - const struct cred *old;
14880 - validate_process_creds();
14882 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14886 kdebug("prepare_creds() alloc %p", new);
14888 - old = task->cred;
14889 memcpy(new, old, sizeof(struct cred));
14891 atomic_set(&new->usage, 1);
14892 @@ -321,6 +291,13 @@ error:
14897 +struct cred *prepare_creds(void)
14899 + validate_process_creds();
14901 + return __prepare_creds(current->cred);
14903 EXPORT_SYMBOL(prepare_creds);
14906 diff -NurpP --minimal linux-2.6.37/kernel/exit.c linux-2.6.37-vs2.3.0.37-rc3/kernel/exit.c
14907 --- linux-2.6.37/kernel/exit.c 2011-01-05 21:50:37.000000000 +0100
14908 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/exit.c 2011-01-05 22:30:42.000000000 +0100
14910 #include <linux/fs_struct.h>
14911 #include <linux/init_task.h>
14912 #include <linux/perf_event.h>
14913 +#include <linux/vs_limit.h>
14914 +#include <linux/vs_context.h>
14915 +#include <linux/vs_network.h>
14916 +#include <linux/vs_pid.h>
14917 #include <trace/events/sched.h>
14918 #include <linux/hw_breakpoint.h>
14919 #include <linux/oom.h>
14920 @@ -494,9 +498,11 @@ static void close_files(struct files_str
14921 filp_close(file, files);
14924 + vx_openfd_dec(i);
14932 @@ -1043,11 +1049,16 @@ NORET_TYPE void do_exit(long code)
14934 validate_creds_for_do_exit(tsk);
14936 + /* needs to stay after exit_notify() */
14937 + exit_vx_info(tsk, code);
14938 + exit_nx_info(tsk);
14942 /* causes final put_task_struct in finish_task_switch(). */
14943 tsk->state = TASK_DEAD;
14945 + printk("bad task: %p [%lx]\n", current, current->state);
14947 /* Avoid "noreturn function does return". */
14949 diff -NurpP --minimal linux-2.6.37/kernel/fork.c linux-2.6.37-vs2.3.0.37-rc3/kernel/fork.c
14950 --- linux-2.6.37/kernel/fork.c 2011-01-05 21:50:37.000000000 +0100
14951 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/fork.c 2011-01-05 22:30:42.000000000 +0100
14953 #include <linux/posix-timers.h>
14954 #include <linux/user-return-notifier.h>
14955 #include <linux/oom.h>
14956 +#include <linux/vs_context.h>
14957 +#include <linux/vs_network.h>
14958 +#include <linux/vs_limit.h>
14959 +#include <linux/vs_memory.h>
14961 #include <asm/pgtable.h>
14962 #include <asm/pgalloc.h>
14963 @@ -161,6 +165,8 @@ void free_task(struct task_struct *tsk)
14964 account_kernel_stack(tsk->stack, -1);
14965 free_thread_info(tsk->stack);
14966 rt_mutex_debug_task_free(tsk);
14967 + clr_vx_info(&tsk->vx_info);
14968 + clr_nx_info(&tsk->nx_info);
14969 ftrace_graph_exit_task(tsk);
14970 free_task_struct(tsk);
14972 @@ -495,6 +501,7 @@ static struct mm_struct * mm_init(struct
14973 if (likely(!mm_alloc_pgd(mm))) {
14975 mmu_notifier_mm_init(mm);
14976 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14980 @@ -528,6 +535,7 @@ void __mmdrop(struct mm_struct *mm)
14982 destroy_context(mm);
14983 mmu_notifier_mm_destroy(mm);
14984 + clr_vx_info(&mm->mm_vx_info);
14987 EXPORT_SYMBOL_GPL(__mmdrop);
14988 @@ -663,6 +671,7 @@ struct mm_struct *dup_mm(struct task_str
14991 memcpy(mm, oldmm, sizeof(*mm));
14992 + mm->mm_vx_info = NULL;
14994 /* Initializing for Swap token stuff */
14995 mm->token_priority = 0;
14996 @@ -701,6 +710,7 @@ fail_nocontext:
14997 * If init_new_context() failed, we cannot use mmput() to free the mm
14998 * because it calls destroy_context()
15000 + clr_vx_info(&mm->mm_vx_info);
15004 @@ -980,6 +990,8 @@ static struct task_struct *copy_process(
15006 struct task_struct *p;
15007 int cgroup_callbacks_done = 0;
15008 + struct vx_info *vxi;
15009 + struct nx_info *nxi;
15011 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15012 return ERR_PTR(-EINVAL);
15013 @@ -1026,7 +1038,12 @@ static struct task_struct *copy_process(
15014 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15015 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15017 + init_vx_info(&p->vx_info, current_vx_info());
15018 + init_nx_info(&p->nx_info, current_nx_info());
15021 + if (!vx_nproc_avail(1))
15022 + goto bad_fork_free;
15023 if (atomic_read(&p->real_cred->user->processes) >=
15024 task_rlimit(p, RLIMIT_NPROC)) {
15025 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15026 @@ -1291,6 +1308,18 @@ static struct task_struct *copy_process(
15029 spin_unlock(¤t->sighand->siglock);
15031 + /* p is copy of current */
15032 + vxi = p->vx_info;
15034 + claim_vx_info(vxi, p);
15035 + atomic_inc(&vxi->cvirt.nr_threads);
15036 + atomic_inc(&vxi->cvirt.total_forks);
15039 + nxi = p->nx_info;
15041 + claim_nx_info(nxi, p);
15042 write_unlock_irq(&tasklist_lock);
15043 proc_fork_connector(p);
15044 cgroup_post_fork(p);
15045 diff -NurpP --minimal linux-2.6.37/kernel/kthread.c linux-2.6.37-vs2.3.0.37-rc3/kernel/kthread.c
15046 --- linux-2.6.37/kernel/kthread.c 2011-01-05 21:50:38.000000000 +0100
15047 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/kthread.c 2011-01-05 22:30:42.000000000 +0100
15049 #include <linux/mutex.h>
15050 #include <linux/slab.h>
15051 #include <linux/freezer.h>
15052 +#include <linux/vs_pid.h>
15053 #include <trace/events/sched.h>
15055 static DEFINE_SPINLOCK(kthread_create_lock);
15056 diff -NurpP --minimal linux-2.6.37/kernel/Makefile linux-2.6.37-vs2.3.0.37-rc3/kernel/Makefile
15057 --- linux-2.6.37/kernel/Makefile 2011-01-05 21:50:37.000000000 +0100
15058 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/Makefile 2010-11-23 02:09:41.000000000 +0100
15059 @@ -25,6 +25,7 @@ CFLAGS_REMOVE_perf_event.o = -pg
15060 CFLAGS_REMOVE_irq_work.o = -pg
15064 obj-$(CONFIG_FREEZER) += freezer.o
15065 obj-$(CONFIG_PROFILING) += profile.o
15066 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15067 diff -NurpP --minimal linux-2.6.37/kernel/nsproxy.c linux-2.6.37-vs2.3.0.37-rc3/kernel/nsproxy.c
15068 --- linux-2.6.37/kernel/nsproxy.c 2010-07-07 18:31:57.000000000 +0200
15069 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/nsproxy.c 2010-11-23 02:09:41.000000000 +0100
15071 #include <linux/mnt_namespace.h>
15072 #include <linux/utsname.h>
15073 #include <linux/pid_namespace.h>
15074 +#include <linux/vserver/global.h>
15075 +#include <linux/vserver/debug.h>
15076 #include <net/net_namespace.h>
15077 #include <linux/ipc_namespace.h>
15079 @@ -43,8 +45,11 @@ static inline struct nsproxy *create_nsp
15080 struct nsproxy *nsproxy;
15082 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
15085 atomic_set(&nsproxy->count, 1);
15086 + atomic_inc(&vs_global_nsproxy);
15088 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
15092 @@ -53,41 +58,52 @@ static inline struct nsproxy *create_nsp
15093 * Return the newly created nsproxy. Do not attach this to the task,
15094 * leave it to the caller to do proper locking and attach it to task.
15096 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15097 - struct task_struct *tsk, struct fs_struct *new_fs)
15098 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15099 + struct nsproxy *orig, struct fs_struct *new_fs)
15101 struct nsproxy *new_nsp;
15104 + vxdprintk(VXD_CBIT(space, 4),
15105 + "unshare_namespaces(0x%08lx,%p,%p)",
15106 + flags, orig, new_fs);
15108 new_nsp = create_nsproxy();
15110 return ERR_PTR(-ENOMEM);
15112 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15113 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15114 if (IS_ERR(new_nsp->mnt_ns)) {
15115 err = PTR_ERR(new_nsp->mnt_ns);
15119 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15120 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15121 if (IS_ERR(new_nsp->uts_ns)) {
15122 err = PTR_ERR(new_nsp->uts_ns);
15126 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15127 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15128 if (IS_ERR(new_nsp->ipc_ns)) {
15129 err = PTR_ERR(new_nsp->ipc_ns);
15133 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15134 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15135 if (IS_ERR(new_nsp->pid_ns)) {
15136 err = PTR_ERR(new_nsp->pid_ns);
15140 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15142 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15143 + if (IS_ERR(new_nsp->user_ns)) {
15144 + err = PTR_ERR(new_nsp->user_ns);
15148 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15149 if (IS_ERR(new_nsp->net_ns)) {
15150 err = PTR_ERR(new_nsp->net_ns);
15152 @@ -112,6 +128,38 @@ out_ns:
15153 return ERR_PTR(err);
15156 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15157 + struct fs_struct *new_fs)
15159 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15163 + * copies the nsproxy, setting refcount to 1, and grabbing a
15164 + * reference to all contained namespaces.
15166 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15168 + struct nsproxy *ns = create_nsproxy();
15171 + memcpy(ns, orig, sizeof(struct nsproxy));
15172 + atomic_set(&ns->count, 1);
15175 + get_mnt_ns(ns->mnt_ns);
15177 + get_uts_ns(ns->uts_ns);
15179 + get_ipc_ns(ns->ipc_ns);
15181 + get_pid_ns(ns->pid_ns);
15183 + get_net(ns->net_ns);
15189 * called from clone. This now handles copy for nsproxy and all
15190 * namespaces therein.
15191 @@ -119,9 +167,12 @@ out_ns:
15192 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15194 struct nsproxy *old_ns = tsk->nsproxy;
15195 - struct nsproxy *new_ns;
15196 + struct nsproxy *new_ns = NULL;
15199 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15200 + flags, tsk, old_ns);
15205 @@ -131,7 +182,7 @@ int copy_namespaces(unsigned long flags,
15206 CLONE_NEWPID | CLONE_NEWNET)))
15209 - if (!capable(CAP_SYS_ADMIN)) {
15210 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
15214 @@ -158,6 +209,9 @@ int copy_namespaces(unsigned long flags,
15217 put_nsproxy(old_ns);
15218 + vxdprintk(VXD_CBIT(space, 3),
15219 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
15220 + flags, tsk, old_ns, err, new_ns);
15224 @@ -171,7 +225,9 @@ void free_nsproxy(struct nsproxy *ns)
15225 put_ipc_ns(ns->ipc_ns);
15227 put_pid_ns(ns->pid_ns);
15228 - put_net(ns->net_ns);
15230 + put_net(ns->net_ns);
15231 + atomic_dec(&vs_global_nsproxy);
15232 kmem_cache_free(nsproxy_cachep, ns);
15235 @@ -184,11 +240,15 @@ int unshare_nsproxy_namespaces(unsigned
15239 + vxdprintk(VXD_CBIT(space, 4),
15240 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
15241 + unshare_flags, current->nsproxy);
15243 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
15247 - if (!capable(CAP_SYS_ADMIN))
15248 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
15251 *new_nsp = create_new_namespaces(unshare_flags, current,
15252 diff -NurpP --minimal linux-2.6.37/kernel/pid.c linux-2.6.37-vs2.3.0.37-rc3/kernel/pid.c
15253 --- linux-2.6.37/kernel/pid.c 2011-01-05 21:50:38.000000000 +0100
15254 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/pid.c 2010-11-23 02:37:26.000000000 +0100
15256 #include <linux/pid_namespace.h>
15257 #include <linux/init_task.h>
15258 #include <linux/syscalls.h>
15259 +#include <linux/vs_pid.h>
15261 #define pid_hashfn(nr, ns) \
15262 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
15263 @@ -339,7 +340,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
15265 struct pid *find_vpid(int nr)
15267 - return find_pid_ns(nr, current->nsproxy->pid_ns);
15268 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
15270 EXPORT_SYMBOL_GPL(find_vpid);
15272 @@ -399,6 +400,9 @@ void transfer_pid(struct task_struct *ol
15273 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
15275 struct task_struct *result = NULL;
15277 + if (type == PIDTYPE_REALPID)
15278 + type = PIDTYPE_PID;
15280 struct hlist_node *first;
15281 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
15282 @@ -417,7 +421,7 @@ EXPORT_SYMBOL(pid_task);
15283 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15285 rcu_lockdep_assert(rcu_read_lock_held());
15286 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15287 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15290 struct task_struct *find_task_by_vpid(pid_t vnr)
15291 @@ -459,7 +463,7 @@ struct pid *find_get_pid(pid_t nr)
15293 EXPORT_SYMBOL_GPL(find_get_pid);
15295 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15296 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15300 @@ -472,6 +476,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15304 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15306 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15309 pid_t pid_vnr(struct pid *pid)
15311 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15312 diff -NurpP --minimal linux-2.6.37/kernel/pid_namespace.c linux-2.6.37-vs2.3.0.37-rc3/kernel/pid_namespace.c
15313 --- linux-2.6.37/kernel/pid_namespace.c 2010-07-07 18:31:57.000000000 +0200
15314 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/pid_namespace.c 2010-11-23 02:09:41.000000000 +0100
15316 #include <linux/err.h>
15317 #include <linux/acct.h>
15318 #include <linux/slab.h>
15319 +#include <linux/vserver/global.h>
15321 #define BITS_PER_PAGE (PAGE_SIZE*8)
15323 @@ -87,6 +88,7 @@ static struct pid_namespace *create_pid_
15326 kref_init(&ns->kref);
15327 + atomic_inc(&vs_global_pid_ns);
15329 ns->parent = get_pid_ns(parent_pid_ns);
15331 @@ -112,6 +114,7 @@ static void destroy_pid_namespace(struct
15333 for (i = 0; i < PIDMAP_ENTRIES; i++)
15334 kfree(ns->pidmap[i].page);
15335 + atomic_dec(&vs_global_pid_ns);
15336 kmem_cache_free(pid_ns_cachep, ns);
15339 diff -NurpP --minimal linux-2.6.37/kernel/posix-timers.c linux-2.6.37-vs2.3.0.37-rc3/kernel/posix-timers.c
15340 --- linux-2.6.37/kernel/posix-timers.c 2010-10-21 13:07:57.000000000 +0200
15341 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/posix-timers.c 2010-11-23 02:09:41.000000000 +0100
15343 #include <linux/wait.h>
15344 #include <linux/workqueue.h>
15345 #include <linux/module.h>
15346 +#include <linux/vs_context.h>
15349 * Management arrays for POSIX timers. Timers are kept in slab memory
15350 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
15352 struct task_struct *task;
15353 int shared, ret = -1;
15356 * FIXME: if ->sigq is queued we can race with
15357 * dequeue_signal()->do_schedule_next_timer().
15358 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
15360 task = pid_task(timr->it_pid, PIDTYPE_PID);
15362 + struct vx_info_save vxis;
15363 + struct vx_info *vxi;
15365 + vxi = get_vx_info(task->vx_info);
15366 + enter_vx_info(vxi, &vxis);
15367 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15368 ret = send_sigqueue(timr->sigq, task, shared);
15369 + leave_vx_info(&vxis);
15370 + put_vx_info(vxi);
15374 /* If we failed to send the signal the timer stops. */
15377 diff -NurpP --minimal linux-2.6.37/kernel/printk.c linux-2.6.37-vs2.3.0.37-rc3/kernel/printk.c
15378 --- linux-2.6.37/kernel/printk.c 2011-01-05 21:50:38.000000000 +0100
15379 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/printk.c 2011-01-05 22:30:42.000000000 +0100
15381 #include <linux/syslog.h>
15382 #include <linux/cpu.h>
15383 #include <linux/notifier.h>
15384 +#include <linux/vs_cvirt.h>
15386 #include <asm/uaccess.h>
15388 @@ -272,18 +273,19 @@ int do_syslog(int type, char __user *buf
15389 unsigned i, j, limit, count;
15396 * If this is from /proc/kmsg we only do the capabilities checks
15399 if (type == SYSLOG_ACTION_OPEN || !from_file) {
15400 - if (dmesg_restrict && !capable(CAP_SYS_ADMIN))
15401 + if (dmesg_restrict &&
15402 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
15404 if ((type != SYSLOG_ACTION_READ_ALL &&
15405 type != SYSLOG_ACTION_SIZE_BUFFER) &&
15406 - !capable(CAP_SYS_ADMIN))
15407 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
15411 @@ -291,12 +293,9 @@ int do_syslog(int type, char __user *buf
15416 - case SYSLOG_ACTION_CLOSE: /* Close log */
15418 - case SYSLOG_ACTION_OPEN: /* Open log */
15420 - case SYSLOG_ACTION_READ: /* Read from log */
15421 + if ((type == SYSLOG_ACTION_READ) ||
15422 + (type == SYSLOG_ACTION_READ_ALL) ||
15423 + (type == SYSLOG_ACTION_READ_CLEAR)) {
15425 if (!buf || len < 0)
15427 @@ -307,6 +306,16 @@ int do_syslog(int type, char __user *buf
15432 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15433 + return vx_do_syslog(type, buf, len);
15436 + case SYSLOG_ACTION_CLOSE: /* Close log */
15438 + case SYSLOG_ACTION_OPEN: /* Open log */
15440 + case SYSLOG_ACTION_READ: /* Read from log */
15441 error = wait_event_interruptible(log_wait,
15442 (log_start - log_end));
15444 @@ -333,16 +342,6 @@ int do_syslog(int type, char __user *buf
15446 /* Read last kernel messages */
15447 case SYSLOG_ACTION_READ_ALL:
15449 - if (!buf || len < 0)
15454 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15459 if (count > log_buf_len)
15460 count = log_buf_len;
15461 diff -NurpP --minimal linux-2.6.37/kernel/ptrace.c linux-2.6.37-vs2.3.0.37-rc3/kernel/ptrace.c
15462 --- linux-2.6.37/kernel/ptrace.c 2011-01-05 21:50:38.000000000 +0100
15463 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/ptrace.c 2010-11-23 02:09:41.000000000 +0100
15465 #include <linux/syscalls.h>
15466 #include <linux/uaccess.h>
15467 #include <linux/regset.h>
15468 +#include <linux/vs_context.h>
15472 @@ -150,6 +151,11 @@ int __ptrace_may_access(struct task_stru
15473 dumpable = get_dumpable(task->mm);
15474 if (!dumpable && !capable(CAP_SYS_PTRACE))
15476 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
15478 + if (!vx_check(task->xid, VS_IDENT) &&
15479 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15482 return security_ptrace_access_check(task, mode);
15484 @@ -713,6 +719,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
15489 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
15490 + goto out_put_task_struct;
15492 if (request == PTRACE_ATTACH) {
15493 ret = ptrace_attach(child);
15495 diff -NurpP --minimal linux-2.6.37/kernel/sched.c linux-2.6.37-vs2.3.0.37-rc3/kernel/sched.c
15496 --- linux-2.6.37/kernel/sched.c 2011-01-05 21:50:38.000000000 +0100
15497 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/sched.c 2011-01-05 22:30:42.000000000 +0100
15499 #include <linux/ctype.h>
15500 #include <linux/ftrace.h>
15501 #include <linux/slab.h>
15502 +#include <linux/vs_sched.h>
15503 +#include <linux/vs_cvirt.h>
15505 #include <asm/tlb.h>
15506 #include <asm/irq_regs.h>
15507 @@ -3361,9 +3363,17 @@ static void calc_global_nohz(unsigned lo
15509 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15511 - loads[0] = (avenrun[0] + offset) << shift;
15512 - loads[1] = (avenrun[1] + offset) << shift;
15513 - loads[2] = (avenrun[2] + offset) << shift;
15514 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15515 + struct vx_info *vxi = current_vx_info();
15517 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15518 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15519 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15521 + loads[0] = (avenrun[0] + offset) << shift;
15522 + loads[1] = (avenrun[1] + offset) << shift;
15523 + loads[2] = (avenrun[2] + offset) << shift;
15528 @@ -3651,16 +3661,19 @@ void account_user_time(struct task_struc
15529 cputime_t cputime_scaled)
15531 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15532 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15534 + int nice = (TASK_NICE(p) > 0);
15536 /* Add user time to process. */
15537 p->utime = cputime_add(p->utime, cputime);
15538 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15539 + vx_account_user(vxi, cputime, nice);
15540 account_group_user_time(p, cputime);
15542 /* Add user time to cpustat. */
15543 tmp = cputime_to_cputime64(cputime);
15544 - if (TASK_NICE(p) > 0)
15546 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15548 cpustat->user = cputime64_add(cpustat->user, tmp);
15549 @@ -3711,6 +3724,7 @@ void account_system_time(struct task_str
15550 cputime_t cputime, cputime_t cputime_scaled)
15552 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15553 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15556 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
15557 @@ -3721,6 +3735,7 @@ void account_system_time(struct task_str
15558 /* Add system time to process. */
15559 p->stime = cputime_add(p->stime, cputime);
15560 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15561 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15562 account_group_system_time(p, cputime);
15564 /* Add system time to cpustat. */
15565 @@ -4804,7 +4819,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15568 if (increment < 0 && !can_nice(current, nice))
15570 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15572 retval = security_task_setnice(current, nice);
15574 diff -NurpP --minimal linux-2.6.37/kernel/sched_fair.c linux-2.6.37-vs2.3.0.37-rc3/kernel/sched_fair.c
15575 --- linux-2.6.37/kernel/sched_fair.c 2011-01-05 21:50:38.000000000 +0100
15576 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/sched_fair.c 2011-01-05 22:30:42.000000000 +0100
15577 @@ -782,6 +782,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15578 check_spread(cfs_rq, se);
15579 if (se != cfs_rq->curr)
15580 __enqueue_entity(cfs_rq, se);
15582 + if (entity_is_task(se))
15583 + vx_activate_task(task_of(se));
15586 static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
15587 @@ -825,6 +828,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15589 if (se != cfs_rq->curr)
15590 __dequeue_entity(cfs_rq, se);
15591 + if (entity_is_task(se))
15592 + vx_deactivate_task(task_of(se));
15593 account_entity_dequeue(cfs_rq, se);
15594 update_min_vruntime(cfs_rq);
15596 diff -NurpP --minimal linux-2.6.37/kernel/signal.c linux-2.6.37-vs2.3.0.37-rc3/kernel/signal.c
15597 --- linux-2.6.37/kernel/signal.c 2011-01-05 21:50:38.000000000 +0100
15598 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/signal.c 2010-11-23 02:09:41.000000000 +0100
15600 #include <linux/freezer.h>
15601 #include <linux/pid_namespace.h>
15602 #include <linux/nsproxy.h>
15603 +#include <linux/vs_context.h>
15604 +#include <linux/vs_pid.h>
15605 #define CREATE_TRACE_POINTS
15606 #include <trace/events/signal.h>
15608 @@ -646,9 +648,18 @@ static int check_kill_permission(int sig
15612 + vxdprintk(VXD_CBIT(misc, 7),
15613 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15614 + sig, info, t, vx_task_xid(t), t->pid);
15616 if (!valid_signal(sig))
15619 +/* FIXME: needed? if so, why?
15620 + if ((info != SEND_SIG_NOINFO) &&
15621 + (is_si_special(info) || !si_fromuser(info)))
15624 if (!si_fromuser(info))
15627 @@ -678,6 +689,20 @@ static int check_kill_permission(int sig
15632 + if (t->pid == 1 && current->xid)
15636 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15637 + loops, maybe ENOENT or EACCES? */
15638 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15639 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15640 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15641 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15645 return security_task_kill(t, info, sig, 0);
15648 @@ -1171,7 +1196,7 @@ int kill_pid_info(int sig, struct siginf
15651 p = pid_task(pid, PIDTYPE_PID);
15653 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15654 error = group_send_sig_info(sig, info, p);
15655 if (unlikely(error == -ESRCH))
15657 @@ -1211,7 +1236,7 @@ int kill_pid_info_as_uid(int sig, struct
15660 p = pid_task(pid, PIDTYPE_PID);
15662 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15666 @@ -1266,8 +1291,10 @@ static int kill_something_info(int sig,
15667 struct task_struct * p;
15669 for_each_process(p) {
15670 - if (task_pid_vnr(p) > 1 &&
15671 - !same_thread_group(p, current)) {
15672 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15673 + task_pid_vnr(p) > 1 &&
15674 + !same_thread_group(p, current) &&
15675 + !vx_current_initpid(p->pid)) {
15676 int err = group_send_sig_info(sig, info, p);
15679 @@ -1936,6 +1963,11 @@ relock:
15680 !sig_kernel_only(signr))
15683 + /* virtual init is protected against user signals */
15684 + if ((info->si_code == SI_USER) &&
15685 + vx_current_initpid(current->pid))
15688 if (sig_kernel_stop(signr)) {
15690 * The default action is to stop all threads in
15691 diff -NurpP --minimal linux-2.6.37/kernel/softirq.c linux-2.6.37-vs2.3.0.37-rc3/kernel/softirq.c
15692 --- linux-2.6.37/kernel/softirq.c 2011-01-05 21:50:38.000000000 +0100
15693 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/softirq.c 2010-11-23 02:09:41.000000000 +0100
15695 #include <linux/ftrace.h>
15696 #include <linux/smp.h>
15697 #include <linux/tick.h>
15698 +#include <linux/vs_context.h>
15700 #define CREATE_TRACE_POINTS
15701 #include <trace/events/irq.h>
15702 diff -NurpP --minimal linux-2.6.37/kernel/sys.c linux-2.6.37-vs2.3.0.37-rc3/kernel/sys.c
15703 --- linux-2.6.37/kernel/sys.c 2010-10-21 13:07:57.000000000 +0200
15704 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/sys.c 2010-11-23 02:09:41.000000000 +0100
15706 #include <linux/syscalls.h>
15707 #include <linux/kprobes.h>
15708 #include <linux/user_namespace.h>
15709 +#include <linux/vs_pid.h>
15711 #include <asm/uaccess.h>
15712 #include <asm/io.h>
15713 @@ -131,7 +132,10 @@ static int set_one_prio(struct task_stru
15716 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15718 + if (vx_flags(VXF_IGNEG_NICE, 0))
15724 no_nice = security_task_setnice(p, niceval);
15725 @@ -181,6 +185,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15727 pgrp = task_pgrp(current);
15728 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15729 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15731 error = set_one_prio(p, niceval, error);
15732 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15734 @@ -244,6 +250,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15736 pgrp = task_pgrp(current);
15737 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15738 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15740 niceval = 20 - task_nice(p);
15741 if (niceval > retval)
15743 @@ -357,6 +365,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15745 static DEFINE_MUTEX(reboot_mutex);
15747 +long vs_reboot(unsigned int, void __user *);
15750 * Reboot system call: for obvious reasons only root may call it,
15751 * and even root needs to set up some magic numbers in the registers
15752 @@ -389,6 +399,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15753 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15754 cmd = LINUX_REBOOT_CMD_HALT;
15756 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15757 + return vs_reboot(cmd, arg);
15759 mutex_lock(&reboot_mutex);
15761 case LINUX_REBOOT_CMD_RESTART:
15762 @@ -1169,7 +1182,7 @@ SYSCALL_DEFINE2(sethostname, char __user
15764 char tmp[__NEW_UTS_LEN];
15766 - if (!capable(CAP_SYS_ADMIN))
15767 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15769 if (len < 0 || len > __NEW_UTS_LEN)
15771 @@ -1218,7 +1231,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
15773 char tmp[__NEW_UTS_LEN];
15775 - if (!capable(CAP_SYS_ADMIN))
15776 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15778 if (len < 0 || len > __NEW_UTS_LEN)
15780 @@ -1334,7 +1347,7 @@ int do_prlimit(struct task_struct *tsk,
15781 task_lock(tsk->group_leader);
15783 if (new_rlim->rlim_max > rlim->rlim_max &&
15784 - !capable(CAP_SYS_RESOURCE))
15785 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15788 retval = security_task_setrlimit(tsk->group_leader,
15789 @@ -1383,7 +1396,7 @@ static int check_prlimit_permission(stru
15790 cred->gid != tcred->egid ||
15791 cred->gid != tcred->sgid ||
15792 cred->gid != tcred->gid) &&
15793 - !capable(CAP_SYS_RESOURCE)) {
15794 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT)) {
15798 diff -NurpP --minimal linux-2.6.37/kernel/sysctl_binary.c linux-2.6.37-vs2.3.0.37-rc3/kernel/sysctl_binary.c
15799 --- linux-2.6.37/kernel/sysctl_binary.c 2010-08-02 16:52:57.000000000 +0200
15800 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/sysctl_binary.c 2010-11-23 02:09:41.000000000 +0100
15801 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15803 { CTL_INT, KERN_PANIC, "panic" },
15804 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15805 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15807 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15808 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15809 diff -NurpP --minimal linux-2.6.37/kernel/sysctl.c linux-2.6.37-vs2.3.0.37-rc3/kernel/sysctl.c
15810 --- linux-2.6.37/kernel/sysctl.c 2011-01-05 21:50:39.000000000 +0100
15811 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/sysctl.c 2010-11-23 02:09:41.000000000 +0100
15813 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15814 #include <linux/lockdep.h>
15816 +extern char vshelper_path[];
15817 #ifdef CONFIG_CHR_DEV_SG
15818 #include <scsi/sg.h>
15820 @@ -571,6 +572,13 @@ static struct ctl_table kern_table[] = {
15821 .proc_handler = proc_dostring,
15825 + .procname = "vshelper",
15826 + .data = &vshelper_path,
15829 + .proc_handler = &proc_dostring,
15831 #ifdef CONFIG_CHR_DEV_SG
15833 .procname = "sg-big-buff",
15834 diff -NurpP --minimal linux-2.6.37/kernel/time/timekeeping.c linux-2.6.37-vs2.3.0.37-rc3/kernel/time/timekeeping.c
15835 --- linux-2.6.37/kernel/time/timekeeping.c 2010-10-21 13:07:57.000000000 +0200
15836 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/time/timekeeping.c 2010-11-23 02:09:41.000000000 +0100
15837 @@ -229,6 +229,7 @@ void getnstimeofday(struct timespec *ts)
15838 } while (read_seqretry(&xtime_lock, seq));
15840 timespec_add_ns(ts, nsecs);
15841 + vx_adjust_timespec(ts);
15844 EXPORT_SYMBOL(getnstimeofday);
15845 diff -NurpP --minimal linux-2.6.37/kernel/time.c linux-2.6.37-vs2.3.0.37-rc3/kernel/time.c
15846 --- linux-2.6.37/kernel/time.c 2010-10-21 13:07:57.000000000 +0200
15847 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/time.c 2010-11-23 02:09:41.000000000 +0100
15848 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15852 - do_settimeofday(&tv);
15853 + vx_settimeofday(&tv);
15857 @@ -177,7 +177,7 @@ int do_sys_settimeofday(struct timespec
15858 /* SMP safe, again the code in arch/foo/time.c should
15859 * globally block out interrupts when it runs.
15861 - return do_settimeofday(tv);
15862 + return vx_settimeofday(tv);
15866 diff -NurpP --minimal linux-2.6.37/kernel/timer.c linux-2.6.37-vs2.3.0.37-rc3/kernel/timer.c
15867 --- linux-2.6.37/kernel/timer.c 2011-01-05 21:50:39.000000000 +0100
15868 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/timer.c 2011-01-05 22:30:42.000000000 +0100
15870 #include <linux/irq_work.h>
15871 #include <linux/sched.h>
15872 #include <linux/slab.h>
15873 +#include <linux/vs_base.h>
15874 +#include <linux/vs_cvirt.h>
15875 +#include <linux/vs_pid.h>
15876 +#include <linux/vserver/sched.h>
15878 #include <asm/uaccess.h>
15879 #include <asm/unistd.h>
15880 @@ -1341,12 +1345,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15887 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15888 - * should be moved into arch/i386 instead?
15892 * sys_getpid - return the thread group id of the current process
15893 @@ -1375,10 +1373,23 @@ SYSCALL_DEFINE0(getppid)
15895 pid = task_tgid_vnr(current->real_parent);
15897 + return vx_map_pid(pid);
15904 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15907 +asmlinkage long do_getxpid(long *ppid)
15909 + *ppid = sys_getppid();
15910 + return sys_getpid();
15913 +#else /* _alpha_ */
15915 SYSCALL_DEFINE0(getuid)
15917 /* Only we change this so SMP safe */
15918 diff -NurpP --minimal linux-2.6.37/kernel/user_namespace.c linux-2.6.37-vs2.3.0.37-rc3/kernel/user_namespace.c
15919 --- linux-2.6.37/kernel/user_namespace.c 2010-10-21 13:07:57.000000000 +0200
15920 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/user_namespace.c 2010-11-23 02:09:41.000000000 +0100
15922 #include <linux/user_namespace.h>
15923 #include <linux/highuid.h>
15924 #include <linux/cred.h>
15925 +#include <linux/vserver/global.h>
15928 * Create a new user namespace, deriving the creator from the user in the
15929 @@ -31,6 +32,7 @@ int create_user_ns(struct cred *new)
15932 kref_init(&ns->kref);
15933 + atomic_inc(&vs_global_user_ns);
15935 for (n = 0; n < UIDHASH_SZ; ++n)
15936 INIT_HLIST_HEAD(ns->uidhash_table + n);
15937 @@ -79,6 +81,8 @@ void free_user_ns(struct kref *kref)
15938 struct user_namespace *ns =
15939 container_of(kref, struct user_namespace, kref);
15941 + /* FIXME: maybe move into destroyer? */
15942 + atomic_dec(&vs_global_user_ns);
15943 INIT_WORK(&ns->destroyer, free_user_ns_work);
15944 schedule_work(&ns->destroyer);
15946 diff -NurpP --minimal linux-2.6.37/kernel/utsname.c linux-2.6.37-vs2.3.0.37-rc3/kernel/utsname.c
15947 --- linux-2.6.37/kernel/utsname.c 2009-09-10 15:26:28.000000000 +0200
15948 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/utsname.c 2010-11-23 02:09:41.000000000 +0100
15949 @@ -14,14 +14,17 @@
15950 #include <linux/utsname.h>
15951 #include <linux/err.h>
15952 #include <linux/slab.h>
15953 +#include <linux/vserver/global.h>
15955 static struct uts_namespace *create_uts_ns(void)
15957 struct uts_namespace *uts_ns;
15959 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15962 kref_init(&uts_ns->kref);
15963 + atomic_inc(&vs_global_uts_ns);
15968 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
15969 struct uts_namespace *ns;
15971 ns = container_of(kref, struct uts_namespace, kref);
15972 + atomic_dec(&vs_global_uts_ns);
15975 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cacct.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cacct.c
15976 --- linux-2.6.37/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
15977 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cacct.c 2010-11-23 02:09:41.000000000 +0100
15980 + * linux/kernel/vserver/cacct.c
15982 + * Virtual Server: Context Accounting
15984 + * Copyright (C) 2006-2007 Herbert Pötzl
15986 + * V0.01 added accounting stats
15990 +#include <linux/types.h>
15991 +#include <linux/vs_context.h>
15992 +#include <linux/vserver/cacct_cmd.h>
15993 +#include <linux/vserver/cacct_int.h>
15995 +#include <asm/errno.h>
15996 +#include <asm/uaccess.h>
15999 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16001 + struct vcmd_sock_stat_v0 vc_data;
16004 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16007 + field = vc_data.field;
16008 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16011 + for (j = 0; j < 3; j++) {
16012 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16013 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16016 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16021 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cacct_init.h linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cacct_init.h
16022 --- linux-2.6.37/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16023 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cacct_init.h 2010-11-23 02:09:41.000000000 +0100
16027 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16032 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16033 + for (j = 0; j < 3; j++) {
16034 + atomic_long_set(&cacct->sock[i][j].count, 0);
16035 + atomic_long_set(&cacct->sock[i][j].total, 0);
16038 + for (i = 0; i < 8; i++)
16039 + atomic_set(&cacct->slab[i], 0);
16040 + for (i = 0; i < 5; i++)
16041 + for (j = 0; j < 4; j++)
16042 + atomic_set(&cacct->page[i][j], 0);
16045 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16050 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cacct_proc.h linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cacct_proc.h
16051 --- linux-2.6.37/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16052 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cacct_proc.h 2010-11-23 02:09:41.000000000 +0100
16054 +#ifndef _VX_CACCT_PROC_H
16055 +#define _VX_CACCT_PROC_H
16057 +#include <linux/vserver/cacct_int.h>
16060 +#define VX_SOCKA_TOP \
16061 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16063 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16065 + int i, j, length = 0;
16066 + static char *type[VXA_SOCK_SIZE] = {
16067 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16070 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16071 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16072 + length += sprintf(buffer + length, "%s:", type[i]);
16073 + for (j = 0; j < 3; j++) {
16074 + length += sprintf(buffer + length,
16075 + "\t%10lu/%-10lu",
16076 + vx_sock_count(cacct, i, j),
16077 + vx_sock_total(cacct, i, j));
16079 + buffer[length++] = '\n';
16082 + length += sprintf(buffer + length, "\n");
16083 + length += sprintf(buffer + length,
16084 + "slab:\t %8u %8u %8u %8u\n",
16085 + atomic_read(&cacct->slab[1]),
16086 + atomic_read(&cacct->slab[4]),
16087 + atomic_read(&cacct->slab[0]),
16088 + atomic_read(&cacct->slab[2]));
16090 + length += sprintf(buffer + length, "\n");
16091 + for (i = 0; i < 5; i++) {
16092 + length += sprintf(buffer + length,
16093 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16094 + atomic_read(&cacct->page[i][0]),
16095 + atomic_read(&cacct->page[i][1]),
16096 + atomic_read(&cacct->page[i][2]),
16097 + atomic_read(&cacct->page[i][3]),
16098 + atomic_read(&cacct->page[i][4]),
16099 + atomic_read(&cacct->page[i][5]),
16100 + atomic_read(&cacct->page[i][6]),
16101 + atomic_read(&cacct->page[i][7]));
16106 +#endif /* _VX_CACCT_PROC_H */
16107 diff -NurpP --minimal linux-2.6.37/kernel/vserver/context.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/context.c
16108 --- linux-2.6.37/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16109 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/context.c 2011-01-31 21:05:40.000000000 +0100
16112 + * linux/kernel/vserver/context.c
16114 + * Virtual Server: Context Support
16116 + * Copyright (C) 2003-2010 Herbert Pötzl
16118 + * V0.01 context helper
16119 + * V0.02 vx_ctx_kill syscall command
16120 + * V0.03 replaced context_info calls
16121 + * V0.04 redesign of struct (de)alloc
16122 + * V0.05 rlimit basic implementation
16123 + * V0.06 task_xid and info commands
16124 + * V0.07 context flags and caps
16125 + * V0.08 switch to RCU based hash
16126 + * V0.09 revert to non RCU for now
16127 + * V0.10 and back to working RCU hash
16128 + * V0.11 and back to locking again
16129 + * V0.12 referenced context store
16130 + * V0.13 separate per cpu data
16131 + * V0.14 changed vcmds to vxi arg
16132 + * V0.15 added context stat
16133 + * V0.16 have __create claim() the vxi
16134 + * V0.17 removed older and legacy stuff
16135 + * V0.18 added user credentials
16139 +#include <linux/slab.h>
16140 +#include <linux/types.h>
16141 +#include <linux/security.h>
16142 +#include <linux/pid_namespace.h>
16144 +#include <linux/vserver/context.h>
16145 +#include <linux/vserver/network.h>
16146 +#include <linux/vserver/debug.h>
16147 +#include <linux/vserver/limit.h>
16148 +#include <linux/vserver/limit_int.h>
16149 +#include <linux/vserver/space.h>
16150 +#include <linux/init_task.h>
16151 +#include <linux/fs_struct.h>
16152 +#include <linux/cred.h>
16154 +#include <linux/vs_context.h>
16155 +#include <linux/vs_limit.h>
16156 +#include <linux/vs_pid.h>
16157 +#include <linux/vserver/context_cmd.h>
16159 +#include "cvirt_init.h"
16160 +#include "cacct_init.h"
16161 +#include "limit_init.h"
16162 +#include "sched_init.h"
16165 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16166 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16169 +/* now inactive context structures */
16171 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16173 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
16176 +/* __alloc_vx_info()
16178 + * allocate an initialized vx_info struct
16179 + * doesn't make it visible (hash) */
16181 +static struct vx_info *__alloc_vx_info(xid_t xid)
16183 + struct vx_info *new = NULL;
16186 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16188 + /* would this benefit from a slab cache? */
16189 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16193 + memset(new, 0, sizeof(struct vx_info));
16195 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16196 + if (!new->ptr_pc)
16199 + new->vx_id = xid;
16200 + INIT_HLIST_NODE(&new->vx_hlist);
16201 + atomic_set(&new->vx_usecnt, 0);
16202 + atomic_set(&new->vx_tasks, 0);
16203 + new->vx_parent = NULL;
16204 + new->vx_state = 0;
16205 + init_waitqueue_head(&new->vx_wait);
16207 + /* prepare reaper */
16208 + get_task_struct(init_pid_ns.child_reaper);
16209 + new->vx_reaper = init_pid_ns.child_reaper;
16210 + new->vx_badness_bias = 0;
16212 + /* rest of init goes here */
16213 + vx_info_init_limit(&new->limit);
16214 + vx_info_init_sched(&new->sched);
16215 + vx_info_init_cvirt(&new->cvirt);
16216 + vx_info_init_cacct(&new->cacct);
16218 + /* per cpu data structures */
16219 + for_each_possible_cpu(cpu) {
16220 + vx_info_init_sched_pc(
16221 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16222 + vx_info_init_cvirt_pc(
16223 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16226 + new->vx_flags = VXF_INIT_SET;
16227 + cap_set_init_eff(new->vx_bcaps);
16228 + new->vx_ccaps = 0;
16229 + new->vx_umask = 0;
16231 + new->reboot_cmd = 0;
16232 + new->exit_code = 0;
16234 + // preconfig spaces
16235 + for (index = 0; index < VX_SPACES; index++) {
16236 + struct _vx_space *space = &new->space[index];
16239 + spin_lock(&init_fs.lock);
16241 + spin_unlock(&init_fs.lock);
16242 + space->vx_fs = &init_fs;
16244 + /* FIXME: do we want defaults? */
16245 + // space->vx_real_cred = 0;
16246 + // space->vx_cred = 0;
16250 + vxdprintk(VXD_CBIT(xid, 0),
16251 + "alloc_vx_info(%d) = %p", xid, new);
16252 + vxh_alloc_vx_info(new);
16253 + atomic_inc(&vx_global_ctotal);
16262 +/* __dealloc_vx_info()
16264 + * final disposal of vx_info */
16266 +static void __dealloc_vx_info(struct vx_info *vxi)
16268 +#ifdef CONFIG_VSERVER_WARN
16269 + struct vx_info_save vxis;
16272 + vxdprintk(VXD_CBIT(xid, 0),
16273 + "dealloc_vx_info(%p)", vxi);
16274 + vxh_dealloc_vx_info(vxi);
16276 +#ifdef CONFIG_VSERVER_WARN
16277 + enter_vx_info(vxi, &vxis);
16278 + vx_info_exit_limit(&vxi->limit);
16279 + vx_info_exit_sched(&vxi->sched);
16280 + vx_info_exit_cvirt(&vxi->cvirt);
16281 + vx_info_exit_cacct(&vxi->cacct);
16283 + for_each_possible_cpu(cpu) {
16284 + vx_info_exit_sched_pc(
16285 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16286 + vx_info_exit_cvirt_pc(
16287 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16289 + leave_vx_info(&vxis);
16293 + vxi->vx_state |= VXS_RELEASED;
16296 + free_percpu(vxi->ptr_pc);
16299 + atomic_dec(&vx_global_ctotal);
16302 +static void __shutdown_vx_info(struct vx_info *vxi)
16304 + struct nsproxy *nsproxy;
16305 + struct fs_struct *fs;
16306 + struct cred *cred;
16311 + vxi->vx_state |= VXS_SHUTDOWN;
16312 + vs_state_change(vxi, VSC_SHUTDOWN);
16314 + for (index = 0; index < VX_SPACES; index++) {
16315 + struct _vx_space *space = &vxi->space[index];
16317 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16319 + put_nsproxy(nsproxy);
16321 + fs = xchg(&space->vx_fs, NULL);
16322 + spin_lock(&fs->lock);
16323 + kill = !--fs->users;
16324 + spin_unlock(&fs->lock);
16326 + free_fs_struct(fs);
16328 + cred = xchg(&space->vx_real_cred, NULL);
16330 + alter_cred_subscribers(cred, -1);
16335 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16337 + abort_creds(cred);
16341 +/* exported stuff */
16343 +void free_vx_info(struct vx_info *vxi)
16345 + unsigned long flags;
16348 + /* check for reference counts first */
16349 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16350 + BUG_ON(atomic_read(&vxi->vx_tasks));
16352 + /* context must not be hashed */
16353 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16355 + /* context shutdown is mandatory */
16356 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16358 + /* spaces check */
16359 + for (index = 0; index < VX_SPACES; index++) {
16360 + struct _vx_space *space = &vxi->space[index];
16362 + BUG_ON(space->vx_nsproxy);
16363 + BUG_ON(space->vx_fs);
16364 + // BUG_ON(space->vx_real_cred);
16365 + // BUG_ON(space->vx_cred);
16368 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16369 + hlist_del(&vxi->vx_hlist);
16370 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16372 + __dealloc_vx_info(vxi);
16376 +/* hash table for vx_info hash */
16378 +#define VX_HASH_SIZE 13
16380 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16381 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16383 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
16386 +static inline unsigned int __hashval(xid_t xid)
16388 + return (xid % VX_HASH_SIZE);
16393 +/* __hash_vx_info()
16395 + * add the vxi to the global hash table
16396 + * requires the hash_lock to be held */
16398 +static inline void __hash_vx_info(struct vx_info *vxi)
16400 + struct hlist_head *head;
16402 + vxd_assert_lock(&vx_info_hash_lock);
16403 + vxdprintk(VXD_CBIT(xid, 4),
16404 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16405 + vxh_hash_vx_info(vxi);
16407 + /* context must not be hashed */
16408 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16410 + vxi->vx_state |= VXS_HASHED;
16411 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16412 + hlist_add_head(&vxi->vx_hlist, head);
16413 + atomic_inc(&vx_global_cactive);
16416 +/* __unhash_vx_info()
16418 + * remove the vxi from the global hash table
16419 + * requires the hash_lock to be held */
16421 +static inline void __unhash_vx_info(struct vx_info *vxi)
16423 + unsigned long flags;
16425 + vxd_assert_lock(&vx_info_hash_lock);
16426 + vxdprintk(VXD_CBIT(xid, 4),
16427 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16428 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16429 + vxh_unhash_vx_info(vxi);
16431 + /* context must be hashed */
16432 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16433 + /* but without tasks */
16434 + BUG_ON(atomic_read(&vxi->vx_tasks));
16436 + vxi->vx_state &= ~VXS_HASHED;
16437 + hlist_del_init(&vxi->vx_hlist);
16438 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16439 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16440 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16441 + atomic_dec(&vx_global_cactive);
16445 +/* __lookup_vx_info()
16447 + * requires the hash_lock to be held
16448 + * doesn't increment the vx_refcnt */
16450 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16452 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16453 + struct hlist_node *pos;
16454 + struct vx_info *vxi;
16456 + vxd_assert_lock(&vx_info_hash_lock);
16457 + hlist_for_each(pos, head) {
16458 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16460 + if (vxi->vx_id == xid)
16465 + vxdprintk(VXD_CBIT(xid, 0),
16466 + "__lookup_vx_info(#%u): %p[#%u]",
16467 + xid, vxi, vxi ? vxi->vx_id : 0);
16468 + vxh_lookup_vx_info(vxi, xid);
16473 +/* __create_vx_info()
16475 + * create the requested context
16476 + * get(), claim() and hash it */
16478 +static struct vx_info *__create_vx_info(int id)
16480 + struct vx_info *new, *vxi = NULL;
16482 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16484 + if (!(new = __alloc_vx_info(id)))
16485 + return ERR_PTR(-ENOMEM);
16487 + /* required to make dynamic xids unique */
16488 + spin_lock(&vx_info_hash_lock);
16490 + /* static context requested */
16491 + if ((vxi = __lookup_vx_info(id))) {
16492 + vxdprintk(VXD_CBIT(xid, 0),
16493 + "create_vx_info(%d) = %p (already there)", id, vxi);
16494 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16495 + vxi = ERR_PTR(-EBUSY);
16497 + vxi = ERR_PTR(-EEXIST);
16500 + /* new context */
16501 + vxdprintk(VXD_CBIT(xid, 0),
16502 + "create_vx_info(%d) = %p (new)", id, new);
16503 + claim_vx_info(new, NULL);
16504 + __hash_vx_info(get_vx_info(new));
16505 + vxi = new, new = NULL;
16508 + spin_unlock(&vx_info_hash_lock);
16509 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16511 + __dealloc_vx_info(new);
16516 +/* exported stuff */
16519 +void unhash_vx_info(struct vx_info *vxi)
16521 + __shutdown_vx_info(vxi);
16522 + spin_lock(&vx_info_hash_lock);
16523 + __unhash_vx_info(vxi);
16524 + spin_unlock(&vx_info_hash_lock);
16525 + __wakeup_vx_info(vxi);
16529 +/* lookup_vx_info()
16531 + * search for a vx_info and get() it
16532 + * negative id means current */
16534 +struct vx_info *lookup_vx_info(int id)
16536 + struct vx_info *vxi = NULL;
16539 + vxi = get_vx_info(current_vx_info());
16540 + } else if (id > 1) {
16541 + spin_lock(&vx_info_hash_lock);
16542 + vxi = get_vx_info(__lookup_vx_info(id));
16543 + spin_unlock(&vx_info_hash_lock);
16548 +/* xid_is_hashed()
16550 + * verify that xid is still hashed */
16552 +int xid_is_hashed(xid_t xid)
16556 + spin_lock(&vx_info_hash_lock);
16557 + hashed = (__lookup_vx_info(xid) != NULL);
16558 + spin_unlock(&vx_info_hash_lock);
16562 +#ifdef CONFIG_PROC_FS
16566 + * get a subset of hashed xids for proc
16567 + * assumes size is at least one */
16569 +int get_xid_list(int index, unsigned int *xids, int size)
16571 + int hindex, nr_xids = 0;
16573 + /* only show current and children */
16574 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16577 + xids[nr_xids] = vx_current_xid();
16581 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16582 + struct hlist_head *head = &vx_info_hash[hindex];
16583 + struct hlist_node *pos;
16585 + spin_lock(&vx_info_hash_lock);
16586 + hlist_for_each(pos, head) {
16587 + struct vx_info *vxi;
16592 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16593 + xids[nr_xids] = vxi->vx_id;
16594 + if (++nr_xids >= size) {
16595 + spin_unlock(&vx_info_hash_lock);
16599 + /* keep the lock time short */
16600 + spin_unlock(&vx_info_hash_lock);
16607 +#ifdef CONFIG_VSERVER_DEBUG
16609 +void dump_vx_info_inactive(int level)
16611 + struct hlist_node *entry, *next;
16613 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16614 + struct vx_info *vxi =
16615 + list_entry(entry, struct vx_info, vx_hlist);
16617 + dump_vx_info(vxi, level);
16624 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16626 + struct user_struct *new_user, *old_user;
16631 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16634 + new_user = alloc_uid(vxi->vx_id, p->uid);
16638 + old_user = p->user;
16639 + if (new_user != old_user) {
16640 + atomic_inc(&new_user->processes);
16641 + atomic_dec(&old_user->processes);
16642 + p->user = new_user;
16644 + free_uid(old_user);
16650 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16652 + // p->cap_effective &= vxi->vx_cap_bset;
16653 + p->cap_effective =
16654 + cap_intersect(p->cap_effective, vxi->cap_bset);
16655 + // p->cap_inheritable &= vxi->vx_cap_bset;
16656 + p->cap_inheritable =
16657 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16658 + // p->cap_permitted &= vxi->vx_cap_bset;
16659 + p->cap_permitted =
16660 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16665 +#include <linux/file.h>
16666 +#include <linux/fdtable.h>
16668 +static int vx_openfd_task(struct task_struct *tsk)
16670 + struct files_struct *files = tsk->files;
16671 + struct fdtable *fdt;
16672 + const unsigned long *bptr;
16673 + int count, total;
16675 + /* no rcu_read_lock() because of spin_lock() */
16676 + spin_lock(&files->file_lock);
16677 + fdt = files_fdtable(files);
16678 + bptr = fdt->open_fds->fds_bits;
16679 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16680 + for (total = 0; count > 0; count--) {
16682 + total += hweight_long(*bptr);
16685 + spin_unlock(&files->file_lock);
16690 +/* for *space compatibility */
16692 +asmlinkage long sys_unshare(unsigned long);
16695 + * migrate task to new context
16696 + * gets vxi, puts old_vxi on change
16697 + * optionally unshares namespaces (hack)
16700 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16702 + struct vx_info *old_vxi;
16708 + vxdprintk(VXD_CBIT(xid, 5),
16709 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16710 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16712 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16713 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16716 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16719 + old_vxi = task_get_vx_info(p);
16720 + if (old_vxi == vxi)
16723 +// if (!(ret = vx_migrate_user(p, vxi))) {
16728 + openfd = vx_openfd_task(p);
16731 + atomic_dec(&old_vxi->cvirt.nr_threads);
16732 + atomic_dec(&old_vxi->cvirt.nr_running);
16733 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16734 + /* FIXME: what about the struct files here? */
16735 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16736 + /* account for the executable */
16737 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16739 + atomic_inc(&vxi->cvirt.nr_threads);
16740 + atomic_inc(&vxi->cvirt.nr_running);
16741 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16742 + /* FIXME: what about the struct files here? */
16743 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16744 + /* account for the executable */
16745 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16748 + release_vx_info(old_vxi, p);
16749 + clr_vx_info(&p->vx_info);
16751 + claim_vx_info(vxi, p);
16752 + set_vx_info(&p->vx_info, vxi);
16753 + p->xid = vxi->vx_id;
16755 + vxdprintk(VXD_CBIT(xid, 5),
16756 + "moved task %p into vxi:%p[#%d]",
16757 + p, vxi, vxi->vx_id);
16759 + // vx_mask_cap_bset(vxi, p);
16762 + /* hack for *spaces to provide compatibility */
16764 + struct nsproxy *old_nsp, *new_nsp;
16766 + ret = unshare_nsproxy_namespaces(
16767 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16772 + old_nsp = xchg(&p->nsproxy, new_nsp);
16773 + vx_set_space(vxi,
16774 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16775 + put_nsproxy(old_nsp);
16779 + put_vx_info(old_vxi);
16783 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16785 + struct task_struct *old_reaper;
16790 + vxdprintk(VXD_CBIT(xid, 6),
16791 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16792 + vxi, vxi->vx_id, p, p->xid, p->pid);
16794 + old_reaper = vxi->vx_reaper;
16795 + if (old_reaper == p)
16798 + /* set new child reaper */
16799 + get_task_struct(p);
16800 + vxi->vx_reaper = p;
16801 + put_task_struct(old_reaper);
16805 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16810 + vxdprintk(VXD_CBIT(xid, 6),
16811 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16812 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16814 + vxi->vx_flags &= ~VXF_STATE_INIT;
16815 + // vxi->vx_initpid = p->tgid;
16816 + vxi->vx_initpid = p->pid;
16820 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16822 + vxdprintk(VXD_CBIT(xid, 6),
16823 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16824 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16826 + vxi->exit_code = code;
16827 + vxi->vx_initpid = 0;
16831 +void vx_set_persistent(struct vx_info *vxi)
16833 + vxdprintk(VXD_CBIT(xid, 6),
16834 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16836 + get_vx_info(vxi);
16837 + claim_vx_info(vxi, NULL);
16840 +void vx_clear_persistent(struct vx_info *vxi)
16842 + vxdprintk(VXD_CBIT(xid, 6),
16843 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16845 + release_vx_info(vxi, NULL);
16846 + put_vx_info(vxi);
16849 +void vx_update_persistent(struct vx_info *vxi)
16851 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16852 + vx_set_persistent(vxi);
16854 + vx_clear_persistent(vxi);
16858 +/* task must be current or locked */
16860 +void exit_vx_info(struct task_struct *p, int code)
16862 + struct vx_info *vxi = p->vx_info;
16865 + atomic_dec(&vxi->cvirt.nr_threads);
16868 + vxi->exit_code = code;
16869 + release_vx_info(vxi, p);
16873 +void exit_vx_info_early(struct task_struct *p, int code)
16875 + struct vx_info *vxi = p->vx_info;
16878 + if (vxi->vx_initpid == p->pid)
16879 + vx_exit_init(vxi, p, code);
16880 + if (vxi->vx_reaper == p)
16881 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16886 +/* vserver syscall commands below here */
16888 +/* taks xid and vx_info functions */
16890 +#include <asm/uaccess.h>
16893 +int vc_task_xid(uint32_t id)
16898 + struct task_struct *tsk;
16900 + read_lock(&tasklist_lock);
16901 + tsk = find_task_by_real_pid(id);
16902 + xid = (tsk) ? tsk->xid : -ESRCH;
16903 + read_unlock(&tasklist_lock);
16905 + xid = vx_current_xid();
16910 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16912 + struct vcmd_vx_info_v0 vc_data;
16914 + vc_data.xid = vxi->vx_id;
16915 + vc_data.initpid = vxi->vx_initpid;
16917 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16923 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16925 + struct vcmd_ctx_stat_v0 vc_data;
16927 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16928 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16930 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16936 +/* context functions */
16938 +int vc_ctx_create(uint32_t xid, void __user *data)
16940 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16941 + struct vx_info *new_vxi;
16944 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16947 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16950 + new_vxi = __create_vx_info(xid);
16951 + if (IS_ERR(new_vxi))
16952 + return PTR_ERR(new_vxi);
16954 + /* initial flags */
16955 + new_vxi->vx_flags = vc_data.flagword;
16958 + if (vs_state_change(new_vxi, VSC_STARTUP))
16961 + ret = vx_migrate_task(current, new_vxi, (!data));
16965 + /* return context id on success */
16966 + ret = new_vxi->vx_id;
16968 + /* get a reference for persistent contexts */
16969 + if ((vc_data.flagword & VXF_PERSISTENT))
16970 + vx_set_persistent(new_vxi);
16972 + release_vx_info(new_vxi, NULL);
16973 + put_vx_info(new_vxi);
16978 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16980 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16983 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16986 + ret = vx_migrate_task(current, vxi, 0);
16989 + if (vc_data.flagword & VXM_SET_INIT)
16990 + ret = vx_set_init(vxi, current);
16993 + if (vc_data.flagword & VXM_SET_REAPER)
16994 + ret = vx_set_reaper(vxi, current);
16999 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17001 + struct vcmd_ctx_flags_v0 vc_data;
17003 + vc_data.flagword = vxi->vx_flags;
17005 + /* special STATE flag handling */
17006 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17008 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17013 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17015 + struct vcmd_ctx_flags_v0 vc_data;
17016 + uint64_t mask, trigger;
17018 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17021 + /* special STATE flag handling */
17022 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17023 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17025 + if (vxi == current_vx_info()) {
17026 + /* if (trigger & VXF_STATE_SETUP)
17027 + vx_mask_cap_bset(vxi, current); */
17028 + if (trigger & VXF_STATE_INIT) {
17031 + ret = vx_set_init(vxi, current);
17034 + ret = vx_set_reaper(vxi, current);
17040 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17041 + vc_data.flagword, mask);
17042 + if (trigger & VXF_PERSISTENT)
17043 + vx_update_persistent(vxi);
17049 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17051 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17053 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17057 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17059 + kernel_cap_t c = __cap_empty_set;
17061 + c.cap[0] = v & 0xFFFFFFFF;
17062 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17064 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17069 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17072 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17074 + *ccaps = vxi->vx_ccaps;
17079 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17081 + struct vcmd_ctx_caps_v1 vc_data;
17084 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17087 + vc_data.cmask = ~0ULL;
17089 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17094 +static int do_set_caps(struct vx_info *vxi,
17095 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17097 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17100 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17101 + bcaps, bmask, ccaps, cmask);
17103 + vxi->vx_bcaps = cap_t_from_caps(
17104 + vs_mask_flags(bcold, bcaps, bmask));
17105 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17110 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17112 + struct vcmd_ctx_caps_v1 vc_data;
17114 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17117 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17120 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17122 + struct vcmd_bcaps vc_data;
17125 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17128 + vc_data.bmask = ~0ULL;
17130 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17135 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17137 + struct vcmd_bcaps vc_data;
17139 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17142 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17146 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17148 + struct vcmd_umask vc_data;
17150 + vc_data.umask = vxi->vx_umask;
17151 + vc_data.mask = ~0ULL;
17153 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17158 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17160 + struct vcmd_umask vc_data;
17162 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17165 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17166 + vc_data.umask, vc_data.mask);
17171 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17173 + struct vcmd_badness_v0 vc_data;
17175 + vc_data.bias = vxi->vx_badness_bias;
17177 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17182 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17184 + struct vcmd_badness_v0 vc_data;
17186 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17189 + vxi->vx_badness_bias = vc_data.bias;
17193 +#include <linux/module.h>
17195 +EXPORT_SYMBOL_GPL(free_vx_info);
17197 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cvirt.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cvirt.c
17198 --- linux-2.6.37/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17199 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cvirt.c 2011-01-08 03:33:34.000000000 +0100
17202 + * linux/kernel/vserver/cvirt.c
17204 + * Virtual Server: Context Virtualization
17206 + * Copyright (C) 2004-2007 Herbert Pötzl
17208 + * V0.01 broken out from limit.c
17209 + * V0.02 added utsname stuff
17210 + * V0.03 changed vcmds to vxi arg
17214 +#include <linux/types.h>
17215 +#include <linux/utsname.h>
17216 +#include <linux/vs_cvirt.h>
17217 +#include <linux/vserver/switch.h>
17218 +#include <linux/vserver/cvirt_cmd.h>
17220 +#include <asm/uaccess.h>
17223 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17225 + struct vx_info *vxi = current_vx_info();
17227 + set_normalized_timespec(uptime,
17228 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17229 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17232 + set_normalized_timespec(idle,
17233 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17234 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17238 +uint64_t vx_idle_jiffies(void)
17240 + return init_task.utime + init_task.stime;
17245 +static inline uint32_t __update_loadavg(uint32_t load,
17246 + int wsize, int delta, int n)
17248 + unsigned long long calc, prev;
17250 + /* just set it to n */
17251 + if (unlikely(delta >= wsize))
17252 + return (n << FSHIFT);
17254 + calc = delta * n;
17256 + prev = (wsize - delta);
17259 + do_div(calc, wsize);
17264 +void vx_update_load(struct vx_info *vxi)
17266 + uint32_t now, last, delta;
17267 + unsigned int nr_running, nr_uninterruptible;
17268 + unsigned int total;
17269 + unsigned long flags;
17271 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17274 + last = vxi->cvirt.load_last;
17275 + delta = now - last;
17277 + if (delta < 5*HZ)
17280 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17281 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17282 + total = nr_running + nr_uninterruptible;
17284 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17285 + 60*HZ, delta, total);
17286 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17287 + 5*60*HZ, delta, total);
17288 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17289 + 15*60*HZ, delta, total);
17291 + vxi->cvirt.load_last = now;
17293 + atomic_inc(&vxi->cvirt.load_updates);
17294 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17299 + * Commands to do_syslog:
17301 + * 0 -- Close the log. Currently a NOP.
17302 + * 1 -- Open the log. Currently a NOP.
17303 + * 2 -- Read from the log.
17304 + * 3 -- Read all messages remaining in the ring buffer.
17305 + * 4 -- Read and clear all messages remaining in the ring buffer
17306 + * 5 -- Clear ring buffer.
17307 + * 6 -- Disable printk's to console
17308 + * 7 -- Enable printk's to console
17309 + * 8 -- Set level of messages printed to console
17310 + * 9 -- Return number of unread characters in the log buffer
17311 + * 10 -- Return size of the log buffer
17313 +int vx_do_syslog(int type, char __user *buf, int len)
17316 + int do_clear = 0;
17317 + struct vx_info *vxi = current_vx_info();
17318 + struct _vx_syslog *log;
17322 + log = &vxi->cvirt.syslog;
17325 + case 0: /* Close log */
17326 + case 1: /* Open log */
17328 + case 2: /* Read from log */
17329 + error = wait_event_interruptible(log->log_wait,
17330 + (log->log_start - log->log_end));
17333 + spin_lock_irq(&log->logbuf_lock);
17334 + spin_unlock_irq(&log->logbuf_lock);
17336 + case 4: /* Read/clear last kernel messages */
17338 + /* fall through */
17339 + case 3: /* Read last kernel messages */
17342 + case 5: /* Clear ring buffer */
17345 + case 6: /* Disable logging to console */
17346 + case 7: /* Enable logging to console */
17347 + case 8: /* Set level of messages printed to console */
17350 + case 9: /* Number of chars in the log buffer */
17352 + case 10: /* Size of the log buffer */
17362 +/* virtual host info names */
17364 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17366 + struct nsproxy *nsproxy;
17367 + struct uts_namespace *uts;
17369 + if (id == VHIN_CONTEXT)
17370 + return vxi->vx_name;
17372 + nsproxy = vxi->space[0].vx_nsproxy;
17376 + uts = nsproxy->uts_ns;
17381 + case VHIN_SYSNAME:
17382 + return uts->name.sysname;
17383 + case VHIN_NODENAME:
17384 + return uts->name.nodename;
17385 + case VHIN_RELEASE:
17386 + return uts->name.release;
17387 + case VHIN_VERSION:
17388 + return uts->name.version;
17389 + case VHIN_MACHINE:
17390 + return uts->name.machine;
17391 + case VHIN_DOMAINNAME:
17392 + return uts->name.domainname;
17399 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17401 + struct vcmd_vhi_name_v0 vc_data;
17404 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17407 + name = vx_vhi_name(vxi, vc_data.field);
17411 + memcpy(name, vc_data.name, 65);
17415 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17417 + struct vcmd_vhi_name_v0 vc_data;
17420 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17423 + name = vx_vhi_name(vxi, vc_data.field);
17427 + memcpy(vc_data.name, name, 65);
17428 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17434 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17436 + struct vcmd_virt_stat_v0 vc_data;
17437 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17438 + struct timespec uptime;
17440 + do_posix_clock_monotonic_gettime(&uptime);
17441 + set_normalized_timespec(&uptime,
17442 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17443 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17445 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17446 + vc_data.uptime = timespec_to_ns(&uptime);
17447 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17448 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17449 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17450 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17451 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17452 + vc_data.load[0] = cvirt->load[0];
17453 + vc_data.load[1] = cvirt->load[1];
17454 + vc_data.load[2] = cvirt->load[2];
17456 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17462 +#ifdef CONFIG_VSERVER_VTIME
17464 +/* virtualized time base */
17466 +void vx_adjust_timespec(struct timespec *ts)
17468 + struct vx_info *vxi;
17470 + if (!vx_flags(VXF_VIRT_TIME, 0))
17473 + vxi = current_vx_info();
17474 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17475 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17477 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17479 + ts->tv_nsec -= NSEC_PER_SEC;
17480 + } else if (ts->tv_nsec < 0) {
17482 + ts->tv_nsec += NSEC_PER_SEC;
17486 +int vx_settimeofday(struct timespec *ts)
17488 + struct timespec ats, delta;
17489 + struct vx_info *vxi;
17491 + if (!vx_flags(VXF_VIRT_TIME, 0))
17492 + return do_settimeofday(ts);
17494 + getnstimeofday(&ats);
17495 + delta = timespec_sub(*ts, ats);
17497 + vxi = current_vx_info();
17498 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17504 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cvirt_init.h linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cvirt_init.h
17505 --- linux-2.6.37/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17506 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cvirt_init.h 2010-11-23 02:09:41.000000000 +0100
17510 +extern uint64_t vx_idle_jiffies(void);
17512 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17514 + uint64_t idle_jiffies = vx_idle_jiffies();
17515 + uint64_t nsuptime;
17517 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17518 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17519 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17520 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17521 + cvirt->bias_ts.tv_sec = 0;
17522 + cvirt->bias_ts.tv_nsec = 0;
17524 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17525 + atomic_set(&cvirt->nr_threads, 0);
17526 + atomic_set(&cvirt->nr_running, 0);
17527 + atomic_set(&cvirt->nr_uninterruptible, 0);
17528 + atomic_set(&cvirt->nr_onhold, 0);
17530 + spin_lock_init(&cvirt->load_lock);
17531 + cvirt->load_last = jiffies;
17532 + atomic_set(&cvirt->load_updates, 0);
17533 + cvirt->load[0] = 0;
17534 + cvirt->load[1] = 0;
17535 + cvirt->load[2] = 0;
17536 + atomic_set(&cvirt->total_forks, 0);
17538 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17539 + init_waitqueue_head(&cvirt->syslog.log_wait);
17540 + cvirt->syslog.log_start = 0;
17541 + cvirt->syslog.log_end = 0;
17542 + cvirt->syslog.con_start = 0;
17543 + cvirt->syslog.logged_chars = 0;
17547 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17549 + // cvirt_pc->cpustat = { 0 };
17552 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17556 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17557 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17559 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17560 + "!!! cvirt: %p[nr_running] = %d on exit.",
17562 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17563 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17565 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17566 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17572 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17577 diff -NurpP --minimal linux-2.6.37/kernel/vserver/cvirt_proc.h linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cvirt_proc.h
17578 --- linux-2.6.37/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17579 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/cvirt_proc.h 2010-11-23 02:09:41.000000000 +0100
17581 +#ifndef _VX_CVIRT_PROC_H
17582 +#define _VX_CVIRT_PROC_H
17584 +#include <linux/nsproxy.h>
17585 +#include <linux/mnt_namespace.h>
17586 +#include <linux/ipc_namespace.h>
17587 +#include <linux/utsname.h>
17588 +#include <linux/ipc.h>
17592 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17594 + struct mnt_namespace *ns;
17595 + struct uts_namespace *uts;
17596 + struct ipc_namespace *ipc;
17597 + struct path path;
17598 + char *pstr, *root;
17604 + length += sprintf(buffer + length,
17605 + "NSProxy:\t%p [%p,%p,%p]\n",
17606 + nsproxy, nsproxy->mnt_ns,
17607 + nsproxy->uts_ns, nsproxy->ipc_ns);
17609 + ns = nsproxy->mnt_ns;
17613 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17617 + path.mnt = ns->root;
17618 + path.dentry = ns->root->mnt_root;
17619 + root = d_path(&path, pstr, PATH_MAX - 2);
17620 + length += sprintf(buffer + length,
17621 + "Namespace:\t%p [#%u]\n"
17622 + "RootPath:\t%s\n",
17623 + ns, atomic_read(&ns->count),
17628 + uts = nsproxy->uts_ns;
17632 + length += sprintf(buffer + length,
17633 + "SysName:\t%.*s\n"
17634 + "NodeName:\t%.*s\n"
17635 + "Release:\t%.*s\n"
17636 + "Version:\t%.*s\n"
17637 + "Machine:\t%.*s\n"
17638 + "DomainName:\t%.*s\n",
17639 + __NEW_UTS_LEN, uts->name.sysname,
17640 + __NEW_UTS_LEN, uts->name.nodename,
17641 + __NEW_UTS_LEN, uts->name.release,
17642 + __NEW_UTS_LEN, uts->name.version,
17643 + __NEW_UTS_LEN, uts->name.machine,
17644 + __NEW_UTS_LEN, uts->name.domainname);
17647 + ipc = nsproxy->ipc_ns;
17651 + length += sprintf(buffer + length,
17652 + "SEMS:\t\t%d %d %d %d %d\n"
17653 + "MSG:\t\t%d %d %d\n"
17654 + "SHM:\t\t%lu %lu %d %d\n",
17655 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17656 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17658 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17659 + (unsigned long)ipc->shm_ctlmax,
17660 + (unsigned long)ipc->shm_ctlall,
17661 + ipc->shm_ctlmni, ipc->shm_tot);
17668 +#include <linux/sched.h>
17670 +#define LOAD_INT(x) ((x) >> FSHIFT)
17671 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17674 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17679 + length += sprintf(buffer + length,
17680 + "BiasUptime:\t%lu.%02lu\n",
17681 + (unsigned long)cvirt->bias_uptime.tv_sec,
17682 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17684 + a = cvirt->load[0] + (FIXED_1 / 200);
17685 + b = cvirt->load[1] + (FIXED_1 / 200);
17686 + c = cvirt->load[2] + (FIXED_1 / 200);
17687 + length += sprintf(buffer + length,
17688 + "nr_threads:\t%d\n"
17689 + "nr_running:\t%d\n"
17690 + "nr_unintr:\t%d\n"
17691 + "nr_onhold:\t%d\n"
17692 + "load_updates:\t%d\n"
17693 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17694 + "total_forks:\t%d\n",
17695 + atomic_read(&cvirt->nr_threads),
17696 + atomic_read(&cvirt->nr_running),
17697 + atomic_read(&cvirt->nr_uninterruptible),
17698 + atomic_read(&cvirt->nr_onhold),
17699 + atomic_read(&cvirt->load_updates),
17700 + LOAD_INT(a), LOAD_FRAC(a),
17701 + LOAD_INT(b), LOAD_FRAC(b),
17702 + LOAD_INT(c), LOAD_FRAC(c),
17703 + atomic_read(&cvirt->total_forks));
17708 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17709 + char *buffer, int cpu)
17715 +#endif /* _VX_CVIRT_PROC_H */
17716 diff -NurpP --minimal linux-2.6.37/kernel/vserver/debug.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/debug.c
17717 --- linux-2.6.37/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17718 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/debug.c 2010-11-23 02:09:41.000000000 +0100
17721 + * kernel/vserver/debug.c
17723 + * Copyright (C) 2005-2007 Herbert Pötzl
17725 + * V0.01 vx_info dump support
17729 +#include <linux/module.h>
17731 +#include <linux/vserver/context.h>
17734 +void dump_vx_info(struct vx_info *vxi, int level)
17736 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17737 + atomic_read(&vxi->vx_usecnt),
17738 + atomic_read(&vxi->vx_tasks),
17741 + __dump_vx_limit(&vxi->limit);
17742 + __dump_vx_sched(&vxi->sched);
17743 + __dump_vx_cvirt(&vxi->cvirt);
17744 + __dump_vx_cacct(&vxi->cacct);
17750 +EXPORT_SYMBOL_GPL(dump_vx_info);
17752 diff -NurpP --minimal linux-2.6.37/kernel/vserver/device.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/device.c
17753 --- linux-2.6.37/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17754 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/device.c 2010-11-23 02:09:41.000000000 +0100
17757 + * linux/kernel/vserver/device.c
17759 + * Linux-VServer: Device Support
17761 + * Copyright (C) 2006 Herbert Pötzl
17762 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17764 + * V0.01 device mapping basics
17765 + * V0.02 added defaults
17769 +#include <linux/slab.h>
17770 +#include <linux/rcupdate.h>
17771 +#include <linux/fs.h>
17772 +#include <linux/namei.h>
17773 +#include <linux/hash.h>
17775 +#include <asm/errno.h>
17776 +#include <asm/uaccess.h>
17777 +#include <linux/vserver/base.h>
17778 +#include <linux/vserver/debug.h>
17779 +#include <linux/vserver/context.h>
17780 +#include <linux/vserver/device.h>
17781 +#include <linux/vserver/device_cmd.h>
17784 +#define DMAP_HASH_BITS 4
17787 +struct vs_mapping {
17789 + struct hlist_node hlist;
17790 + struct list_head list;
17792 +#define dm_hlist u.hlist
17793 +#define dm_list u.list
17796 + struct vx_dmap_target target;
17800 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17802 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
17804 +static struct vx_dmap_target dmap_defaults[2] = {
17805 + { .flags = DATTR_OPEN },
17806 + { .flags = DATTR_OPEN },
17810 +struct kmem_cache *dmap_cachep __read_mostly;
17812 +int __init dmap_cache_init(void)
17814 + dmap_cachep = kmem_cache_create("dmap_cache",
17815 + sizeof(struct vs_mapping), 0,
17816 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17820 +__initcall(dmap_cache_init);
17823 +static inline unsigned int __hashval(dev_t dev, int bits)
17825 + return hash_long((unsigned long)dev, bits);
17829 +/* __hash_mapping()
17830 + * add the mapping to the hash table
17832 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17834 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17835 + struct hlist_head *head, *hash = dmap_main_hash;
17836 + int device = vdm->device;
17838 + spin_lock(hash_lock);
17839 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17840 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17842 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17843 + hlist_add_head(&vdm->dm_hlist, head);
17844 + spin_unlock(hash_lock);
17848 +static inline int __mode_to_default(umode_t mode)
17861 +/* __set_default()
17864 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17865 + struct vx_dmap_target *vdmt)
17867 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17868 + spin_lock(hash_lock);
17871 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17873 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17876 + spin_unlock(hash_lock);
17878 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17879 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17883 +/* __remove_default()
17884 + * remove a default
17886 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17888 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17889 + spin_lock(hash_lock);
17892 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17893 + else /* remove == reset */
17894 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17896 + spin_unlock(hash_lock);
17901 +/* __find_mapping()
17902 + * find a mapping in the hash table
17904 + * caller must hold hash_lock
17906 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17907 + struct vs_mapping **local, struct vs_mapping **global)
17909 + struct hlist_head *hash = dmap_main_hash;
17910 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17911 + struct hlist_node *pos;
17912 + struct vs_mapping *vdm;
17918 + hlist_for_each(pos, head) {
17919 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17921 + if ((vdm->device == device) &&
17922 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17923 + if (vdm->xid == xid) {
17926 + } else if (global && vdm->xid == 0)
17931 + if (global && *global)
17938 +/* __lookup_mapping()
17939 + * find a mapping and store the result in target and flags
17941 +static inline int __lookup_mapping(struct vx_info *vxi,
17942 + dev_t device, dev_t *target, int *flags, umode_t mode)
17944 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17945 + struct vs_mapping *vdm, *global;
17946 + struct vx_dmap_target *vdmt;
17948 + xid_t xid = vxi->vx_id;
17951 + spin_lock(hash_lock);
17952 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17954 + vdmt = &vdm->target;
17958 + index = __mode_to_default(mode);
17959 + if (vxi && vxi->dmap.targets[index].flags) {
17961 + vdmt = &vxi->dmap.targets[index];
17962 + } else if (global) {
17964 + vdmt = &global->target;
17968 + vdmt = &dmap_defaults[index];
17972 + if (target && (vdmt->flags & DATTR_REMAP))
17973 + *target = vdmt->target;
17975 + *target = device;
17977 + *flags = vdmt->flags;
17979 + spin_unlock(hash_lock);
17985 +/* __remove_mapping()
17986 + * remove a mapping from the hash table
17988 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17991 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17992 + struct vs_mapping *vdm = NULL;
17995 + spin_lock(hash_lock);
17997 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17999 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18000 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18003 + hlist_del(&vdm->dm_hlist);
18006 + spin_unlock(hash_lock);
18008 + kmem_cache_free(dmap_cachep, vdm);
18014 +int vs_map_device(struct vx_info *vxi,
18015 + dev_t device, dev_t *target, umode_t mode)
18017 + int ret, flags = DATTR_MASK;
18021 + *target = device;
18024 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18025 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18026 + device, target ? *target : 0, flags, mode, ret);
18028 + return (flags & DATTR_MASK);
18033 +static int do_set_mapping(struct vx_info *vxi,
18034 + dev_t device, dev_t target, int flags, umode_t mode)
18037 + struct vs_mapping *new;
18039 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18043 + INIT_HLIST_NODE(&new->dm_hlist);
18044 + new->device = device;
18045 + new->target.target = target;
18046 + new->target.flags = flags | mode;
18047 + new->xid = (vxi ? vxi->vx_id : 0);
18049 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18050 + __hash_mapping(vxi, new);
18052 + struct vx_dmap_target new = {
18053 + .target = target,
18054 + .flags = flags | mode,
18056 + __set_default(vxi, mode, &new);
18062 +static int do_unset_mapping(struct vx_info *vxi,
18063 + dev_t device, dev_t target, int flags, umode_t mode)
18065 + int ret = -EINVAL;
18068 + ret = __remove_mapping(vxi, device, mode);
18072 + ret = __remove_default(vxi, mode);
18082 +static inline int __user_device(const char __user *name, dev_t *dev,
18085 + struct nameidata nd;
18092 + ret = user_lpath(name, &nd.path);
18095 + if (nd.path.dentry->d_inode) {
18096 + *dev = nd.path.dentry->d_inode->i_rdev;
18097 + *mode = nd.path.dentry->d_inode->i_mode;
18099 + path_put(&nd.path);
18103 +static inline int __mapping_mode(dev_t device, dev_t target,
18104 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18107 + *mode = device_mode & S_IFMT;
18109 + *mode = target_mode & S_IFMT;
18113 + /* if both given, device and target mode have to match */
18114 + if (device && target &&
18115 + ((device_mode ^ target_mode) & S_IFMT))
18121 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18122 + const char __user *target_path, int flags, int set)
18124 + dev_t device = ~0, target = ~0;
18125 + umode_t device_mode = 0, target_mode = 0, mode;
18128 + ret = __user_device(device_path, &device, &device_mode);
18131 + ret = __user_device(target_path, &target, &target_mode);
18135 + ret = __mapping_mode(device, target,
18136 + device_mode, target_mode, &mode);
18141 + return do_set_mapping(vxi, device, target,
18144 + return do_unset_mapping(vxi, device, target,
18149 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18151 + struct vcmd_set_mapping_v0 vc_data;
18153 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18156 + return do_mapping(vxi, vc_data.device, vc_data.target,
18157 + vc_data.flags, 1);
18160 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18162 + struct vcmd_set_mapping_v0 vc_data;
18164 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18167 + return do_mapping(vxi, vc_data.device, vc_data.target,
18168 + vc_data.flags, 0);
18172 +#ifdef CONFIG_COMPAT
18174 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18176 + struct vcmd_set_mapping_v0_x32 vc_data;
18178 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18181 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18182 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18185 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18187 + struct vcmd_set_mapping_v0_x32 vc_data;
18189 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18192 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18193 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18196 +#endif /* CONFIG_COMPAT */
18199 diff -NurpP --minimal linux-2.6.37/kernel/vserver/dlimit.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/dlimit.c
18200 --- linux-2.6.37/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18201 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/dlimit.c 2011-01-05 23:26:15.000000000 +0100
18204 + * linux/kernel/vserver/dlimit.c
18206 + * Virtual Server: Context Disk Limits
18208 + * Copyright (C) 2004-2009 Herbert Pötzl
18210 + * V0.01 initial version
18211 + * V0.02 compat32 splitup
18212 + * V0.03 extended interface
18216 +#include <linux/statfs.h>
18217 +#include <linux/sched.h>
18218 +#include <linux/namei.h>
18219 +#include <linux/vs_tag.h>
18220 +#include <linux/vs_dlimit.h>
18221 +#include <linux/vserver/dlimit_cmd.h>
18222 +#include <linux/slab.h>
18223 +// #include <linux/gfp.h>
18225 +#include <asm/uaccess.h>
18227 +/* __alloc_dl_info()
18229 + * allocate an initialized dl_info struct
18230 + * doesn't make it visible (hash) */
18232 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18234 + struct dl_info *new = NULL;
18236 + vxdprintk(VXD_CBIT(dlim, 5),
18237 + "alloc_dl_info(%p,%d)*", sb, tag);
18239 + /* would this benefit from a slab cache? */
18240 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18244 + memset(new, 0, sizeof(struct dl_info));
18245 + new->dl_tag = tag;
18247 + // INIT_RCU_HEAD(&new->dl_rcu);
18248 + INIT_HLIST_NODE(&new->dl_hlist);
18249 + spin_lock_init(&new->dl_lock);
18250 + atomic_set(&new->dl_refcnt, 0);
18251 + atomic_set(&new->dl_usecnt, 0);
18253 + /* rest of init goes here */
18255 + vxdprintk(VXD_CBIT(dlim, 4),
18256 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18260 +/* __dealloc_dl_info()
18262 + * final disposal of dl_info */
18264 +static void __dealloc_dl_info(struct dl_info *dli)
18266 + vxdprintk(VXD_CBIT(dlim, 4),
18267 + "dealloc_dl_info(%p)", dli);
18269 + dli->dl_hlist.next = LIST_POISON1;
18270 + dli->dl_tag = -1;
18273 + BUG_ON(atomic_read(&dli->dl_usecnt));
18274 + BUG_ON(atomic_read(&dli->dl_refcnt));
18280 +/* hash table for dl_info hash */
18282 +#define DL_HASH_SIZE 13
18284 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18286 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
18289 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18291 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18296 +/* __hash_dl_info()
18298 + * add the dli to the global hash table
18299 + * requires the hash_lock to be held */
18301 +static inline void __hash_dl_info(struct dl_info *dli)
18303 + struct hlist_head *head;
18305 + vxdprintk(VXD_CBIT(dlim, 6),
18306 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18307 + get_dl_info(dli);
18308 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18309 + hlist_add_head_rcu(&dli->dl_hlist, head);
18312 +/* __unhash_dl_info()
18314 + * remove the dli from the global hash table
18315 + * requires the hash_lock to be held */
18317 +static inline void __unhash_dl_info(struct dl_info *dli)
18319 + vxdprintk(VXD_CBIT(dlim, 6),
18320 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18321 + hlist_del_rcu(&dli->dl_hlist);
18322 + put_dl_info(dli);
18326 +/* __lookup_dl_info()
18328 + * requires the rcu_read_lock()
18329 + * doesn't increment the dl_refcnt */
18331 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18333 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18334 + struct hlist_node *pos;
18335 + struct dl_info *dli;
18337 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18339 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18347 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18349 + struct dl_info *dli;
18352 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18353 + vxdprintk(VXD_CBIT(dlim, 7),
18354 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18355 + rcu_read_unlock();
18359 +void rcu_free_dl_info(struct rcu_head *head)
18361 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18362 + int usecnt, refcnt;
18364 + BUG_ON(!dli || !head);
18366 + usecnt = atomic_read(&dli->dl_usecnt);
18367 + BUG_ON(usecnt < 0);
18369 + refcnt = atomic_read(&dli->dl_refcnt);
18370 + BUG_ON(refcnt < 0);
18372 + vxdprintk(VXD_CBIT(dlim, 3),
18373 + "rcu_free_dl_info(%p)", dli);
18375 + __dealloc_dl_info(dli);
18377 + printk("!!! rcu didn't free\n");
18383 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18384 + uint32_t flags, int add)
18386 + struct path path;
18389 + ret = user_lpath(name, &path);
18391 + struct super_block *sb;
18392 + struct dl_info *dli;
18395 + if (!path.dentry->d_inode)
18396 + goto out_release;
18397 + if (!(sb = path.dentry->d_inode->i_sb))
18398 + goto out_release;
18401 + dli = __alloc_dl_info(sb, id);
18402 + spin_lock(&dl_info_hash_lock);
18405 + if (__lookup_dl_info(sb, id))
18407 + __hash_dl_info(dli);
18410 + spin_lock(&dl_info_hash_lock);
18411 + dli = __lookup_dl_info(sb, id);
18416 + __unhash_dl_info(dli);
18420 + spin_unlock(&dl_info_hash_lock);
18422 + __dealloc_dl_info(dli);
18429 +int vc_add_dlimit(uint32_t id, void __user *data)
18431 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18433 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18436 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18439 +int vc_rem_dlimit(uint32_t id, void __user *data)
18441 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18443 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18446 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18449 +#ifdef CONFIG_COMPAT
18451 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18453 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18455 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18458 + return do_addrem_dlimit(id,
18459 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18462 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18464 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18466 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18469 + return do_addrem_dlimit(id,
18470 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18473 +#endif /* CONFIG_COMPAT */
18477 +int do_set_dlimit(uint32_t id, const char __user *name,
18478 + uint32_t space_used, uint32_t space_total,
18479 + uint32_t inodes_used, uint32_t inodes_total,
18480 + uint32_t reserved, uint32_t flags)
18482 + struct path path;
18485 + ret = user_lpath(name, &path);
18487 + struct super_block *sb;
18488 + struct dl_info *dli;
18491 + if (!path.dentry->d_inode)
18492 + goto out_release;
18493 + if (!(sb = path.dentry->d_inode->i_sb))
18494 + goto out_release;
18496 + /* sanity checks */
18497 + if ((reserved != CDLIM_KEEP &&
18498 + reserved > 100) ||
18499 + (inodes_used != CDLIM_KEEP &&
18500 + inodes_used > inodes_total) ||
18501 + (space_used != CDLIM_KEEP &&
18502 + space_used > space_total))
18503 + goto out_release;
18506 + dli = locate_dl_info(sb, id);
18508 + goto out_release;
18510 + spin_lock(&dli->dl_lock);
18512 + if (inodes_used != CDLIM_KEEP)
18513 + dli->dl_inodes_used = inodes_used;
18514 + if (inodes_total != CDLIM_KEEP)
18515 + dli->dl_inodes_total = inodes_total;
18516 + if (space_used != CDLIM_KEEP)
18517 + dli->dl_space_used = dlimit_space_32to64(
18518 + space_used, flags, DLIMS_USED);
18520 + if (space_total == CDLIM_INFINITY)
18521 + dli->dl_space_total = DLIM_INFINITY;
18522 + else if (space_total != CDLIM_KEEP)
18523 + dli->dl_space_total = dlimit_space_32to64(
18524 + space_total, flags, DLIMS_TOTAL);
18526 + if (reserved != CDLIM_KEEP)
18527 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18529 + spin_unlock(&dli->dl_lock);
18531 + put_dl_info(dli);
18540 +int vc_set_dlimit(uint32_t id, void __user *data)
18542 + struct vcmd_ctx_dlimit_v0 vc_data;
18544 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18547 + return do_set_dlimit(id, vc_data.name,
18548 + vc_data.space_used, vc_data.space_total,
18549 + vc_data.inodes_used, vc_data.inodes_total,
18550 + vc_data.reserved, vc_data.flags);
18553 +#ifdef CONFIG_COMPAT
18555 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18557 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18559 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18562 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18563 + vc_data.space_used, vc_data.space_total,
18564 + vc_data.inodes_used, vc_data.inodes_total,
18565 + vc_data.reserved, vc_data.flags);
18568 +#endif /* CONFIG_COMPAT */
18572 +int do_get_dlimit(uint32_t id, const char __user *name,
18573 + uint32_t *space_used, uint32_t *space_total,
18574 + uint32_t *inodes_used, uint32_t *inodes_total,
18575 + uint32_t *reserved, uint32_t *flags)
18577 + struct path path;
18580 + ret = user_lpath(name, &path);
18582 + struct super_block *sb;
18583 + struct dl_info *dli;
18586 + if (!path.dentry->d_inode)
18587 + goto out_release;
18588 + if (!(sb = path.dentry->d_inode->i_sb))
18589 + goto out_release;
18592 + dli = locate_dl_info(sb, id);
18594 + goto out_release;
18596 + spin_lock(&dli->dl_lock);
18597 + *inodes_used = dli->dl_inodes_used;
18598 + *inodes_total = dli->dl_inodes_total;
18600 + *space_used = dlimit_space_64to32(
18601 + dli->dl_space_used, flags, DLIMS_USED);
18603 + if (dli->dl_space_total == DLIM_INFINITY)
18604 + *space_total = CDLIM_INFINITY;
18606 + *space_total = dlimit_space_64to32(
18607 + dli->dl_space_total, flags, DLIMS_TOTAL);
18609 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18610 + spin_unlock(&dli->dl_lock);
18612 + put_dl_info(dli);
18623 +int vc_get_dlimit(uint32_t id, void __user *data)
18625 + struct vcmd_ctx_dlimit_v0 vc_data;
18628 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18631 + ret = do_get_dlimit(id, vc_data.name,
18632 + &vc_data.space_used, &vc_data.space_total,
18633 + &vc_data.inodes_used, &vc_data.inodes_total,
18634 + &vc_data.reserved, &vc_data.flags);
18638 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18643 +#ifdef CONFIG_COMPAT
18645 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18647 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18650 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18653 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18654 + &vc_data.space_used, &vc_data.space_total,
18655 + &vc_data.inodes_used, &vc_data.inodes_total,
18656 + &vc_data.reserved, &vc_data.flags);
18660 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18665 +#endif /* CONFIG_COMPAT */
18668 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18670 + struct dl_info *dli;
18671 + __u64 blimit, bfree, bavail;
18674 + dli = locate_dl_info(sb, dx_current_tag());
18678 + spin_lock(&dli->dl_lock);
18679 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18682 + /* reduce max inodes available to limit */
18683 + if (buf->f_files > dli->dl_inodes_total)
18684 + buf->f_files = dli->dl_inodes_total;
18686 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18687 + /* reduce free inodes to min */
18688 + if (ifree < buf->f_ffree)
18689 + buf->f_ffree = ifree;
18692 + if (dli->dl_space_total == DLIM_INFINITY)
18695 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18697 + if (dli->dl_space_total < dli->dl_space_used)
18700 + bfree = (dli->dl_space_total - dli->dl_space_used)
18701 + >> sb->s_blocksize_bits;
18703 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18704 + if (bavail < dli->dl_space_used)
18707 + bavail = (bavail - dli->dl_space_used)
18708 + >> sb->s_blocksize_bits;
18710 + /* reduce max space available to limit */
18711 + if (buf->f_blocks > blimit)
18712 + buf->f_blocks = blimit;
18714 + /* reduce free space to min */
18715 + if (bfree < buf->f_bfree)
18716 + buf->f_bfree = bfree;
18718 + /* reduce avail space to min */
18719 + if (bavail < buf->f_bavail)
18720 + buf->f_bavail = bavail;
18723 + spin_unlock(&dli->dl_lock);
18724 + put_dl_info(dli);
18729 +#include <linux/module.h>
18731 +EXPORT_SYMBOL_GPL(locate_dl_info);
18732 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18734 diff -NurpP --minimal linux-2.6.37/kernel/vserver/helper.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/helper.c
18735 --- linux-2.6.37/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18736 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/helper.c 2010-11-23 02:09:41.000000000 +0100
18739 + * linux/kernel/vserver/helper.c
18741 + * Virtual Context Support
18743 + * Copyright (C) 2004-2007 Herbert Pötzl
18745 + * V0.01 basic helper
18749 +#include <linux/kmod.h>
18750 +#include <linux/reboot.h>
18751 +#include <linux/vs_context.h>
18752 +#include <linux/vs_network.h>
18753 +#include <linux/vserver/signal.h>
18756 +char vshelper_path[255] = "/sbin/vshelper";
18759 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18763 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18764 + printk( KERN_WARNING
18765 + "%s: (%s %s) returned %s with %d\n",
18766 + name, argv[1], argv[2],
18767 + sync ? "sync" : "async", ret);
18769 + vxdprintk(VXD_CBIT(switch, 4),
18770 + "%s: (%s %s) returned %s with %d",
18771 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18776 + * vshelper path is set via /proc/sys
18777 + * invoked by vserver sys_reboot(), with
18778 + * the following arguments
18780 + * argv [0] = vshelper_path;
18781 + * argv [1] = action: "restart", "halt", "poweroff", ...
18782 + * argv [2] = context identifier
18784 + * envp [*] = type-specific parameters
18787 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18789 + char id_buf[8], cmd_buf[16];
18790 + char uid_buf[16], pid_buf[16];
18793 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18794 + char *envp[] = {"HOME=/", "TERM=linux",
18795 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18796 + uid_buf, pid_buf, cmd_buf, 0};
18798 + if (vx_info_state(vxi, VXS_HELPER))
18800 + vxi->vx_state |= VXS_HELPER;
18802 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18804 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18805 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18806 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18809 + case LINUX_REBOOT_CMD_RESTART:
18810 + argv[1] = "restart";
18813 + case LINUX_REBOOT_CMD_HALT:
18814 + argv[1] = "halt";
18817 + case LINUX_REBOOT_CMD_POWER_OFF:
18818 + argv[1] = "poweroff";
18821 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18822 + argv[1] = "swsusp";
18825 + case LINUX_REBOOT_CMD_OOM:
18830 + vxi->vx_state &= ~VXS_HELPER;
18834 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18835 + vxi->vx_state &= ~VXS_HELPER;
18836 + __wakeup_vx_info(vxi);
18837 + return (ret) ? -EPERM : 0;
18841 +long vs_reboot(unsigned int cmd, void __user *arg)
18843 + struct vx_info *vxi = current_vx_info();
18846 + vxdprintk(VXD_CBIT(misc, 5),
18847 + "vs_reboot(%p[#%d],%u)",
18848 + vxi, vxi ? vxi->vx_id : 0, cmd);
18850 + ret = vs_reboot_helper(vxi, cmd, arg);
18854 + vxi->reboot_cmd = cmd;
18855 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18857 + case LINUX_REBOOT_CMD_RESTART:
18858 + case LINUX_REBOOT_CMD_HALT:
18859 + case LINUX_REBOOT_CMD_POWER_OFF:
18860 + vx_info_kill(vxi, 0, SIGKILL);
18861 + vx_info_kill(vxi, 1, SIGKILL);
18869 +long vs_oom_action(unsigned int cmd)
18871 + struct vx_info *vxi = current_vx_info();
18874 + vxdprintk(VXD_CBIT(misc, 5),
18875 + "vs_oom_action(%p[#%d],%u)",
18876 + vxi, vxi ? vxi->vx_id : 0, cmd);
18878 + ret = vs_reboot_helper(vxi, cmd, NULL);
18882 + vxi->reboot_cmd = cmd;
18883 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18884 + vx_info_kill(vxi, 0, SIGKILL);
18885 + vx_info_kill(vxi, 1, SIGKILL);
18891 + * argv [0] = vshelper_path;
18892 + * argv [1] = action: "startup", "shutdown"
18893 + * argv [2] = context identifier
18895 + * envp [*] = type-specific parameters
18898 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18900 + char id_buf[8], cmd_buf[16];
18901 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18902 + char *envp[] = {"HOME=/", "TERM=linux",
18903 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18905 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18908 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18909 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18912 + case VSC_STARTUP:
18913 + argv[1] = "startup";
18915 + case VSC_SHUTDOWN:
18916 + argv[1] = "shutdown";
18922 + return do_vshelper(vshelper_path, argv, envp, 1);
18927 + * argv [0] = vshelper_path;
18928 + * argv [1] = action: "netup", "netdown"
18929 + * argv [2] = context identifier
18931 + * envp [*] = type-specific parameters
18934 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18936 + char id_buf[8], cmd_buf[16];
18937 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18938 + char *envp[] = {"HOME=/", "TERM=linux",
18939 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18941 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18944 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
18945 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18949 + argv[1] = "netup";
18951 + case VSC_NETDOWN:
18952 + argv[1] = "netdown";
18958 + return do_vshelper(vshelper_path, argv, envp, 1);
18961 diff -NurpP --minimal linux-2.6.37/kernel/vserver/history.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/history.c
18962 --- linux-2.6.37/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
18963 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/history.c 2010-11-23 02:09:41.000000000 +0100
18966 + * kernel/vserver/history.c
18968 + * Virtual Context History Backtrace
18970 + * Copyright (C) 2004-2007 Herbert Pötzl
18972 + * V0.01 basic structure
18973 + * V0.02 hash/unhash and trace
18974 + * V0.03 preemption fixes
18978 +#include <linux/module.h>
18979 +#include <asm/uaccess.h>
18981 +#include <linux/vserver/context.h>
18982 +#include <linux/vserver/debug.h>
18983 +#include <linux/vserver/debug_cmd.h>
18984 +#include <linux/vserver/history.h>
18987 +#ifdef CONFIG_VSERVER_HISTORY
18988 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18990 +#define VXH_SIZE 64
18993 +struct _vx_history {
18994 + unsigned int counter;
18996 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19000 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19002 +unsigned volatile int vxh_active = 1;
19004 +static atomic_t sequence = ATOMIC_INIT(0);
19009 + * requires disabled preemption */
19011 +struct _vx_hist_entry *vxh_advance(void *loc)
19013 + unsigned int cpu = smp_processor_id();
19014 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19015 + struct _vx_hist_entry *entry;
19016 + unsigned int index;
19018 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19019 + entry = &hist->entry[index];
19021 + entry->seq = atomic_inc_return(&sequence);
19022 + entry->loc = loc;
19026 +EXPORT_SYMBOL_GPL(vxh_advance);
19029 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19031 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19034 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19036 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19037 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19038 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19039 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19041 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19043 + switch (e->type) {
19044 + case VXH_THROW_OOPS:
19045 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19048 + case VXH_GET_VX_INFO:
19049 + case VXH_PUT_VX_INFO:
19050 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19052 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19053 + VXH_VXI_ARGS(e));
19056 + case VXH_INIT_VX_INFO:
19057 + case VXH_SET_VX_INFO:
19058 + case VXH_CLR_VX_INFO:
19059 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19061 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19062 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19063 + VXH_VXI_ARGS(e), e->sc.data);
19066 + case VXH_CLAIM_VX_INFO:
19067 + case VXH_RELEASE_VX_INFO:
19068 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19070 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19071 + VXH_VXI_ARGS(e), e->sc.data);
19074 + case VXH_ALLOC_VX_INFO:
19075 + case VXH_DEALLOC_VX_INFO:
19076 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19078 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19079 + VXH_VXI_ARGS(e));
19082 + case VXH_HASH_VX_INFO:
19083 + case VXH_UNHASH_VX_INFO:
19084 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19086 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19087 + VXH_VXI_ARGS(e));
19090 + case VXH_LOC_VX_INFO:
19091 + case VXH_LOOKUP_VX_INFO:
19092 + case VXH_CREATE_VX_INFO:
19093 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19095 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19096 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19097 + e->ll.arg, VXH_VXI_ARGS(e));
19102 +static void __vxh_dump_history(void)
19104 + unsigned int i, cpu;
19106 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19107 + atomic_read(&sequence), NR_CPUS);
19109 + for (i = 0; i < VXH_SIZE; i++) {
19110 + for_each_online_cpu(cpu) {
19111 + struct _vx_history *hist =
19112 + &per_cpu(vx_history_buffer, cpu);
19113 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19114 + struct _vx_hist_entry *entry = &hist->entry[index];
19116 + vxh_dump_entry(entry, cpu);
19121 +void vxh_dump_history(void)
19125 + local_irq_enable();
19127 + local_irq_disable();
19129 + __vxh_dump_history();
19133 +/* vserver syscall commands below here */
19136 +int vc_dump_history(uint32_t id)
19139 + __vxh_dump_history();
19146 +int do_read_history(struct __user _vx_hist_entry *data,
19147 + int cpu, uint32_t *index, uint32_t *count)
19149 + int pos, ret = 0;
19150 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19151 + int end = hist->counter;
19152 + int start = end - VXH_SIZE + 2;
19153 + int idx = *index;
19155 + /* special case: get current pos */
19161 + /* have we lost some data? */
19165 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19166 + struct _vx_hist_entry *entry =
19167 + &hist->entry[idx % VXH_SIZE];
19169 + /* send entry to userspace */
19170 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19174 + /* save new index and count */
19177 + return ret ? ret : (*index < end);
19180 +int vc_read_history(uint32_t id, void __user *data)
19182 + struct vcmd_read_history_v0 vc_data;
19185 + if (id >= NR_CPUS)
19188 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19191 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19192 + id, &vc_data.index, &vc_data.count);
19194 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19199 +#ifdef CONFIG_COMPAT
19201 +int vc_read_history_x32(uint32_t id, void __user *data)
19203 + struct vcmd_read_history_v0_x32 vc_data;
19206 + if (id >= NR_CPUS)
19209 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19212 + ret = do_read_history((struct __user _vx_hist_entry *)
19213 + compat_ptr(vc_data.data_ptr),
19214 + id, &vc_data.index, &vc_data.count);
19216 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19221 +#endif /* CONFIG_COMPAT */
19223 diff -NurpP --minimal linux-2.6.37/kernel/vserver/inet.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/inet.c
19224 --- linux-2.6.37/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19225 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/inet.c 2010-11-23 02:09:41.000000000 +0100
19228 +#include <linux/in.h>
19229 +#include <linux/inetdevice.h>
19230 +#include <linux/vs_inet.h>
19231 +#include <linux/vs_inet6.h>
19232 +#include <linux/vserver/debug.h>
19233 +#include <net/route.h>
19234 +#include <net/addrconf.h>
19237 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19241 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19244 + struct nx_addr_v4 *ptr;
19246 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19247 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19254 + vxdprintk(VXD_CBIT(net, 2),
19255 + "nx_v4_addr_conflict(%p,%p): %d",
19256 + nxi1, nxi2, ret);
19262 +#ifdef CONFIG_IPV6
19264 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19268 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19271 + struct nx_addr_v6 *ptr;
19273 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19274 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19281 + vxdprintk(VXD_CBIT(net, 2),
19282 + "nx_v6_addr_conflict(%p,%p): %d",
19283 + nxi1, nxi2, ret);
19290 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19292 + struct in_device *in_dev;
19293 + struct in_ifaddr **ifap;
19294 + struct in_ifaddr *ifa;
19299 + in_dev = in_dev_get(dev);
19303 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19304 + ifap = &ifa->ifa_next) {
19305 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19310 + in_dev_put(in_dev);
19316 +#ifdef CONFIG_IPV6
19318 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19320 + struct inet6_dev *in_dev;
19321 + struct inet6_ifaddr *ifa;
19326 + in_dev = in6_dev_get(dev);
19330 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19331 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19332 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19337 + in6_dev_put(in_dev);
19344 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19350 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19352 +#ifdef CONFIG_IPV6
19354 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19359 + vxdprintk(VXD_CBIT(net, 3),
19360 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19361 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19365 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
19366 + struct rtable **rp, struct flowi *fl)
19371 + /* FIXME: handle lback only case */
19372 + if (!NX_IPV4(nxi))
19375 + vxdprintk(VXD_CBIT(net, 4),
19376 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19377 + nxi, nxi ? nxi->nx_id : 0,
19378 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
19380 + /* single IP is unconditional */
19381 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19382 + (fl->fl4_src == INADDR_ANY))
19383 + fl->fl4_src = nxi->v4.ip[0].s_addr;
19385 + if (fl->fl4_src == INADDR_ANY) {
19386 + struct nx_addr_v4 *ptr;
19387 + __be32 found = 0;
19390 + err = __ip_route_output_key(net, rp, fl);
19392 + found = (*rp)->rt_src;
19394 + vxdprintk(VXD_CBIT(net, 4),
19395 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19396 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
19397 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19401 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19402 + __be32 primary = ptr->ip[0].s_addr;
19403 + __be32 mask = ptr->mask.s_addr;
19404 + __be32 neta = primary & mask;
19406 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19407 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19408 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19409 + NIPQUAD(mask), NIPQUAD(neta));
19410 + if ((found & mask) != neta)
19413 + fl->fl4_src = primary;
19414 + err = __ip_route_output_key(net, rp, fl);
19415 + vxdprintk(VXD_CBIT(net, 4),
19416 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19417 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
19419 + found = (*rp)->rt_src;
19421 + if (found == primary)
19425 + /* still no source ip? */
19426 + found = ipv4_is_loopback(fl->fl4_dst)
19427 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19429 + /* assign src ip to flow */
19430 + fl->fl4_src = found;
19433 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
19437 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19438 + if (ipv4_is_loopback(fl->fl4_dst))
19439 + fl->fl4_dst = nxi->v4_lback.s_addr;
19440 + if (ipv4_is_loopback(fl->fl4_src))
19441 + fl->fl4_src = nxi->v4_lback.s_addr;
19442 + } else if (ipv4_is_loopback(fl->fl4_dst) &&
19443 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19449 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19451 diff -NurpP --minimal linux-2.6.37/kernel/vserver/init.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/init.c
19452 --- linux-2.6.37/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19453 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/init.c 2010-11-23 02:09:41.000000000 +0100
19456 + * linux/kernel/init.c
19458 + * Virtual Server Init
19460 + * Copyright (C) 2004-2007 Herbert Pötzl
19462 + * V0.01 basic structure
19466 +#include <linux/init.h>
19468 +int vserver_register_sysctl(void);
19469 +void vserver_unregister_sysctl(void);
19472 +static int __init init_vserver(void)
19476 +#ifdef CONFIG_VSERVER_DEBUG
19477 + vserver_register_sysctl();
19483 +static void __exit exit_vserver(void)
19486 +#ifdef CONFIG_VSERVER_DEBUG
19487 + vserver_unregister_sysctl();
19492 +/* FIXME: GFP_ZONETYPES gone
19493 +long vx_slab[GFP_ZONETYPES]; */
19497 +module_init(init_vserver);
19498 +module_exit(exit_vserver);
19500 diff -NurpP --minimal linux-2.6.37/kernel/vserver/inode.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/inode.c
19501 --- linux-2.6.37/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19502 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/inode.c 2010-11-23 02:09:41.000000000 +0100
19505 + * linux/kernel/vserver/inode.c
19507 + * Virtual Server: File System Support
19509 + * Copyright (C) 2004-2007 Herbert Pötzl
19511 + * V0.01 separated from vcontext V0.05
19512 + * V0.02 moved to tag (instead of xid)
19516 +#include <linux/tty.h>
19517 +#include <linux/proc_fs.h>
19518 +#include <linux/devpts_fs.h>
19519 +#include <linux/fs.h>
19520 +#include <linux/file.h>
19521 +#include <linux/mount.h>
19522 +#include <linux/parser.h>
19523 +#include <linux/namei.h>
19524 +#include <linux/vserver/inode.h>
19525 +#include <linux/vserver/inode_cmd.h>
19526 +#include <linux/vs_base.h>
19527 +#include <linux/vs_tag.h>
19529 +#include <asm/uaccess.h>
19532 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19534 + struct proc_dir_entry *entry;
19536 + if (!in || !in->i_sb)
19539 + *flags = IATTR_TAG
19540 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19541 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19542 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19543 + | (IS_COW(in) ? IATTR_COW : 0);
19544 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19546 + if (S_ISDIR(in->i_mode))
19547 + *mask |= IATTR_BARRIER;
19549 + if (IS_TAGGED(in)) {
19550 + *tag = in->i_tag;
19551 + *mask |= IATTR_TAG;
19554 + switch (in->i_sb->s_magic) {
19555 + case PROC_SUPER_MAGIC:
19556 + entry = PROC_I(in)->pde;
19558 + /* check for specific inodes? */
19560 + *mask |= IATTR_FLAGS;
19562 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19564 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19567 + case DEVPTS_SUPER_MAGIC:
19568 + *tag = in->i_tag;
19569 + *mask |= IATTR_TAG;
19578 +int vc_get_iattr(void __user *data)
19580 + struct path path;
19581 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19584 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19587 + ret = user_lpath(vc_data.name, &path);
19589 + ret = __vc_get_iattr(path.dentry->d_inode,
19590 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19596 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19601 +#ifdef CONFIG_COMPAT
19603 +int vc_get_iattr_x32(void __user *data)
19605 + struct path path;
19606 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19609 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19612 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19614 + ret = __vc_get_iattr(path.dentry->d_inode,
19615 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19621 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19626 +#endif /* CONFIG_COMPAT */
19629 +int vc_fget_iattr(uint32_t fd, void __user *data)
19631 + struct file *filp;
19632 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19635 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19639 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19642 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19643 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19647 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19653 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19655 + struct inode *in = de->d_inode;
19656 + int error = 0, is_proc = 0, has_tag = 0;
19657 + struct iattr attr = { 0 };
19659 + if (!in || !in->i_sb)
19662 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19663 + if ((*mask & IATTR_FLAGS) && !is_proc)
19666 + has_tag = IS_TAGGED(in) ||
19667 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19668 + if ((*mask & IATTR_TAG) && !has_tag)
19671 + mutex_lock(&in->i_mutex);
19672 + if (*mask & IATTR_TAG) {
19673 + attr.ia_tag = *tag;
19674 + attr.ia_valid |= ATTR_TAG;
19677 + if (*mask & IATTR_FLAGS) {
19678 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19679 + unsigned int iflags = PROC_I(in)->vx_flags;
19681 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19682 + | (*flags & IATTR_FLAGS);
19683 + PROC_I(in)->vx_flags = iflags;
19685 + entry->vx_flags = iflags;
19688 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19689 + IATTR_BARRIER | IATTR_COW)) {
19690 + int iflags = in->i_flags;
19691 + int vflags = in->i_vflags;
19693 + if (*mask & IATTR_IMMUTABLE) {
19694 + if (*flags & IATTR_IMMUTABLE)
19695 + iflags |= S_IMMUTABLE;
19697 + iflags &= ~S_IMMUTABLE;
19699 + if (*mask & IATTR_IXUNLINK) {
19700 + if (*flags & IATTR_IXUNLINK)
19701 + iflags |= S_IXUNLINK;
19703 + iflags &= ~S_IXUNLINK;
19705 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19706 + if (*flags & IATTR_BARRIER)
19707 + vflags |= V_BARRIER;
19709 + vflags &= ~V_BARRIER;
19711 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19712 + if (*flags & IATTR_COW)
19715 + vflags &= ~V_COW;
19717 + if (in->i_op && in->i_op->sync_flags) {
19718 + error = in->i_op->sync_flags(in, iflags, vflags);
19724 + if (attr.ia_valid) {
19725 + if (in->i_op && in->i_op->setattr)
19726 + error = in->i_op->setattr(de, &attr);
19728 + error = inode_change_ok(in, &attr);
19730 + setattr_copy(in, &attr);
19731 + mark_inode_dirty(in);
19737 + mutex_unlock(&in->i_mutex);
19741 +int vc_set_iattr(void __user *data)
19743 + struct path path;
19744 + struct vcmd_ctx_iattr_v1 vc_data;
19747 + if (!capable(CAP_LINUX_IMMUTABLE))
19749 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19752 + ret = user_lpath(vc_data.name, &path);
19754 + ret = __vc_set_iattr(path.dentry,
19755 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19759 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19764 +#ifdef CONFIG_COMPAT
19766 +int vc_set_iattr_x32(void __user *data)
19768 + struct path path;
19769 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19772 + if (!capable(CAP_LINUX_IMMUTABLE))
19774 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19777 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19779 + ret = __vc_set_iattr(path.dentry,
19780 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19784 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19789 +#endif /* CONFIG_COMPAT */
19791 +int vc_fset_iattr(uint32_t fd, void __user *data)
19793 + struct file *filp;
19794 + struct vcmd_ctx_fiattr_v0 vc_data;
19797 + if (!capable(CAP_LINUX_IMMUTABLE))
19799 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19803 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19806 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19807 + &vc_data.flags, &vc_data.mask);
19811 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19817 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19819 +static match_table_t tokens = {
19820 + {Opt_notagcheck, "notagcheck"},
19821 +#ifdef CONFIG_PROPAGATE
19822 + {Opt_notag, "notag"},
19823 + {Opt_tag, "tag"},
19824 + {Opt_tagid, "tagid=%u"},
19830 +static void __dx_parse_remove(char *string, char *opt)
19832 + char *p = strstr(string, opt);
19836 + while (*q != '\0' && *q != ',')
19845 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19846 + unsigned long *flags)
19849 + substring_t args[MAX_OPT_ARGS];
19850 + int token, option = 0;
19851 + char *s, *p, *opts;
19855 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19860 + while ((p = strsep(&opts, ",")) != NULL) {
19861 + token = match_token(p, tokens, args);
19863 + vxdprintk(VXD_CBIT(tag, 7),
19864 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19865 + p, token, option);
19868 +#ifdef CONFIG_PROPAGATE
19873 + __dx_parse_remove(s, "tag");
19874 + *mnt_flags |= MNT_TAGID;
19875 + set |= MNT_TAGID;
19879 + __dx_parse_remove(s, "notag");
19880 + *mnt_flags |= MNT_NOTAG;
19881 + set |= MNT_NOTAG;
19884 + if (tag && !match_int(args, &option))
19887 + __dx_parse_remove(s, "tagid");
19888 + *mnt_flags |= MNT_TAGID;
19889 + set |= MNT_TAGID;
19892 + case Opt_notagcheck:
19894 + __dx_parse_remove(s, "notagcheck");
19895 + *flags |= MS_NOTAGCHECK;
19896 + set |= MS_NOTAGCHECK;
19901 + strcpy(string, s);
19906 +#ifdef CONFIG_PROPAGATE
19908 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19910 + tag_t new_tag = 0;
19911 + struct vfsmount *mnt;
19916 + mnt = nd->path.mnt;
19920 + propagate = (mnt->mnt_flags & MNT_TAGID);
19922 + new_tag = mnt->mnt_tag;
19924 + vxdprintk(VXD_CBIT(tag, 7),
19925 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19926 + inode, inode->i_ino, inode->i_tag,
19927 + new_tag, (propagate) ? 1 : 0);
19930 + inode->i_tag = new_tag;
19933 +#include <linux/module.h>
19935 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19937 +#endif /* CONFIG_PROPAGATE */
19939 diff -NurpP --minimal linux-2.6.37/kernel/vserver/Kconfig linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/Kconfig
19940 --- linux-2.6.37/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
19941 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/Kconfig 2010-11-23 02:09:41.000000000 +0100
19944 +# Linux VServer configuration
19947 +menu "Linux VServer"
19949 +config VSERVER_AUTO_LBACK
19950 + bool "Automatically Assign Loopback IP"
19953 + Automatically assign a guest specific loopback
19954 + IP and add it to the kernel network stack on
19957 +config VSERVER_AUTO_SINGLE
19958 + bool "Automatic Single IP Special Casing"
19959 + depends on EXPERIMENTAL
19962 + This allows network contexts with a single IP to
19963 + automatically remap 0.0.0.0 bindings to that IP,
19964 + avoiding further network checks and improving
19967 + (note: such guests do not allow to change the ip
19968 + on the fly and do not show loopback addresses)
19970 +config VSERVER_COWBL
19971 + bool "Enable COW Immutable Link Breaking"
19974 + This enables the COW (Copy-On-Write) link break code.
19975 + It allows you to treat unified files like normal files
19976 + when writing to them (which will implicitely break the
19977 + link and create a copy of the unified file)
19979 +config VSERVER_VTIME
19980 + bool "Enable Virtualized Guest Time"
19981 + depends on EXPERIMENTAL
19984 + This enables per guest time offsets to allow for
19985 + adjusting the system clock individually per guest.
19986 + this adds some overhead to the time functions and
19987 + therefore should not be enabled without good reason.
19989 +config VSERVER_DEVICE
19990 + bool "Enable Guest Device Mapping"
19991 + depends on EXPERIMENTAL
19994 + This enables generic device remapping.
19996 +config VSERVER_PROC_SECURE
19997 + bool "Enable Proc Security"
19998 + depends on PROC_FS
20001 + This configures ProcFS security to initially hide
20002 + non-process entries for all contexts except the main and
20003 + spectator context (i.e. for all guests), which is a secure
20006 + (note: on 1.2x the entries were visible by default)
20008 +config VSERVER_HARDCPU
20009 + bool "Enable Hard CPU Limits"
20012 + Activate the Hard CPU Limits
20014 + This will compile in code that allows the Token Bucket
20015 + Scheduler to put processes on hold when a context's
20016 + tokens are depleted (provided that its per-context
20017 + sched_hard flag is set).
20019 + Processes belonging to that context will not be able
20020 + to consume CPU resources again until a per-context
20021 + configured minimum of tokens has been reached.
20023 +config VSERVER_IDLETIME
20024 + bool "Avoid idle CPUs by skipping Time"
20025 + depends on VSERVER_HARDCPU
20028 + This option allows the scheduler to artificially
20029 + advance time (per cpu) when otherwise the idle
20030 + task would be scheduled, thus keeping the cpu
20031 + busy and sharing the available resources among
20032 + certain contexts.
20034 +config VSERVER_IDLELIMIT
20035 + bool "Limit the IDLE task"
20036 + depends on VSERVER_HARDCPU
20039 + Limit the idle slices, so the the next context
20040 + will be scheduled as soon as possible.
20042 + This might improve interactivity and latency, but
20043 + will also marginally increase scheduling overhead.
20046 + prompt "Persistent Inode Tagging"
20047 + default TAGGING_ID24
20049 + This adds persistent context information to filesystems
20050 + mounted with the tagxid option. Tagging is a requirement
20051 + for per-context disk limits and per-context quota.
20054 +config TAGGING_NONE
20057 + do not store per-context information in inodes.
20059 +config TAGGING_UID16
20060 + bool "UID16/GID32"
20062 + reduces UID to 16 bit, but leaves GID at 32 bit.
20064 +config TAGGING_GID16
20065 + bool "UID32/GID16"
20067 + reduces GID to 16 bit, but leaves UID at 32 bit.
20069 +config TAGGING_ID24
20070 + bool "UID24/GID24"
20072 + uses the upper 8bit from UID and GID for XID tagging
20073 + which leaves 24bit for UID/GID each, which should be
20074 + more than sufficient for normal use.
20076 +config TAGGING_INTERN
20077 + bool "UID32/GID32"
20079 + this uses otherwise reserved inode fields in the on
20080 + disk representation, which limits the use to a few
20081 + filesystems (currently ext2 and ext3)
20086 + bool "Tag NFSD User Auth and Files"
20089 + Enable this if you do want the in-kernel NFS
20090 + Server to use the tagging specified above.
20091 + (will require patched clients too)
20093 +config VSERVER_PRIVACY
20094 + bool "Honor Privacy Aspects of Guests"
20097 + When enabled, most context checks will disallow
20098 + access to structures assigned to a specific context,
20099 + like ptys or loop devices.
20101 +config VSERVER_CONTEXTS
20102 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
20104 + default "768" if 64BIT
20107 + This setting will optimize certain data structures
20108 + and memory allocations according to the expected
20111 + note: this is not a strict upper limit.
20113 +config VSERVER_WARN
20114 + bool "VServer Warnings"
20117 + This enables various runtime warnings, which will
20118 + notify about potential manipulation attempts or
20119 + resource shortage. It is generally considered to
20120 + be a good idea to have that enabled.
20122 +config VSERVER_WARN_DEVPTS
20123 + bool "VServer DevPTS Warnings"
20124 + depends on VSERVER_WARN
20127 + This enables DevPTS related warnings, issued when a
20128 + process inside a context tries to lookup or access
20129 + a dynamic pts from the host or a different context.
20131 +config VSERVER_DEBUG
20132 + bool "VServer Debugging Code"
20135 + Set this to yes if you want to be able to activate
20136 + debugging output at runtime. It adds a very small
20137 + overhead to all vserver related functions and
20138 + increases the kernel size by about 20k.
20140 +config VSERVER_HISTORY
20141 + bool "VServer History Tracing"
20142 + depends on VSERVER_DEBUG
20145 + Set this to yes if you want to record the history of
20146 + linux-vserver activities, so they can be replayed in
20147 + the event of a kernel panic or oops.
20149 +config VSERVER_HISTORY_SIZE
20150 + int "Per-CPU History Size (32-65536)"
20151 + depends on VSERVER_HISTORY
20155 + This allows you to specify the number of entries in
20156 + the per-CPU history buffer.
20158 +config VSERVER_LEGACY_MEM
20159 + bool "Legacy Memory Limits"
20162 + This provides fake memory limits to keep
20163 + older tools happy in the face of memory
20167 + prompt "Quotes used in debug and warn messages"
20168 + default QUOTES_ISO8859
20170 +config QUOTES_ISO8859
20171 + bool "Extended ASCII (ISO 8859) angle quotes"
20173 + This uses the extended ASCII characters \xbb
20174 + and \xab for quoting file and process names.
20176 +config QUOTES_UTF8
20177 + bool "UTF-8 angle quotes"
20179 + This uses the the UTF-8 sequences for angle
20180 + quotes to quote file and process names.
20182 +config QUOTES_ASCII
20183 + bool "ASCII single quotes"
20185 + This uses the ASCII single quote character
20186 + (\x27) to quote file and process names.
20196 + select NAMESPACES
20202 +config VSERVER_SECURITY
20204 + depends on SECURITY
20206 + select SECURITY_CAPABILITIES
20208 diff -NurpP --minimal linux-2.6.37/kernel/vserver/limit.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/limit.c
20209 --- linux-2.6.37/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
20210 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/limit.c 2010-11-23 02:09:41.000000000 +0100
20213 + * linux/kernel/vserver/limit.c
20215 + * Virtual Server: Context Limits
20217 + * Copyright (C) 2004-2010 Herbert Pötzl
20219 + * V0.01 broken out from vcontext V0.05
20220 + * V0.02 changed vcmds to vxi arg
20221 + * V0.03 added memory cgroup support
20225 +#include <linux/sched.h>
20226 +#include <linux/module.h>
20227 +#include <linux/memcontrol.h>
20228 +#include <linux/res_counter.h>
20229 +#include <linux/vs_limit.h>
20230 +#include <linux/vserver/limit.h>
20231 +#include <linux/vserver/limit_cmd.h>
20233 +#include <asm/uaccess.h>
20236 +const char *vlimit_name[NUM_LIMITS] = {
20237 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20238 + [RLIMIT_RSS] = "RSS",
20239 + [RLIMIT_AS] = "VM",
20240 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20241 + [RLIMIT_CPU] = "CPU",
20242 + [RLIMIT_NPROC] = "NPROC",
20243 + [RLIMIT_NOFILE] = "NOFILE",
20244 + [RLIMIT_LOCKS] = "LOCKS",
20245 + [RLIMIT_SIGPENDING] = "SIGP",
20246 + [RLIMIT_MSGQUEUE] = "MSGQ",
20248 + [VLIMIT_NSOCK] = "NSOCK",
20249 + [VLIMIT_OPENFD] = "OPENFD",
20250 + [VLIMIT_SHMEM] = "SHMEM",
20251 + [VLIMIT_DENTRY] = "DENTRY",
20254 +EXPORT_SYMBOL_GPL(vlimit_name);
20256 +#define MASK_ENTRY(x) (1 << (x))
20258 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20261 + , /* softlimit */
20262 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20263 + MASK_ENTRY( RLIMIT_RSS ) |
20264 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20267 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20268 + MASK_ENTRY( RLIMIT_RSS ) |
20269 + MASK_ENTRY( RLIMIT_AS ) |
20270 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20271 + MASK_ENTRY( RLIMIT_NPROC ) |
20272 + MASK_ENTRY( RLIMIT_NOFILE ) |
20273 + MASK_ENTRY( RLIMIT_LOCKS ) |
20274 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20276 + MASK_ENTRY( VLIMIT_NSOCK ) |
20277 + MASK_ENTRY( VLIMIT_OPENFD ) |
20278 + MASK_ENTRY( VLIMIT_SHMEM ) |
20279 + MASK_ENTRY( VLIMIT_DENTRY ) |
20282 + /* accounting only */
20283 +uint32_t account_mask =
20284 + MASK_ENTRY( VLIMIT_SEMARY ) |
20285 + MASK_ENTRY( VLIMIT_NSEMS ) |
20286 + MASK_ENTRY( VLIMIT_MAPPED ) |
20290 +static int is_valid_vlimit(int id)
20292 + uint32_t mask = vlimit_mask.minimum |
20293 + vlimit_mask.softlimit | vlimit_mask.maximum;
20294 + return mask & (1 << id);
20297 +static int is_accounted_vlimit(int id)
20299 + if (is_valid_vlimit(id))
20301 + return account_mask & (1 << id);
20305 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20307 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20308 + return VX_VLIM(limit);
20311 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20313 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20314 + return VX_VLIM(limit);
20317 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20318 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20320 + if (!is_valid_vlimit(id))
20324 + *minimum = CRLIM_UNSET;
20326 + *softlimit = vc_get_soft(vxi, id);
20328 + *maximum = vc_get_hard(vxi, id);
20332 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20334 + struct vcmd_ctx_rlimit_v0 vc_data;
20337 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20340 + ret = do_get_rlimit(vxi, vc_data.id,
20341 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20345 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20350 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20351 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20353 + if (!is_valid_vlimit(id))
20356 + if (maximum != CRLIM_KEEP)
20357 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20358 + if (softlimit != CRLIM_KEEP)
20359 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20361 + /* clamp soft limit */
20362 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20363 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20368 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20370 + struct vcmd_ctx_rlimit_v0 vc_data;
20372 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20375 + return do_set_rlimit(vxi, vc_data.id,
20376 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20379 +#ifdef CONFIG_IA32_EMULATION
20381 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20383 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20385 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20388 + return do_set_rlimit(vxi, vc_data.id,
20389 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20392 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20394 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20397 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20400 + ret = do_get_rlimit(vxi, vc_data.id,
20401 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20405 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20410 +#endif /* CONFIG_IA32_EMULATION */
20413 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20415 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20421 +static inline void vx_reset_hits(struct _vx_limit *limit)
20425 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20426 + atomic_set(&__rlim_lhit(limit, lim), 0);
20430 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20432 + vx_reset_hits(&vxi->limit);
20436 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20441 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20442 + value = __rlim_get(limit, lim);
20443 + __rlim_rmax(limit, lim) = value;
20444 + __rlim_rmin(limit, lim) = value;
20448 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20450 + vx_reset_minmax(&vxi->limit);
20455 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20457 + struct vcmd_rlimit_stat_v0 vc_data;
20458 + struct _vx_limit *limit = &vxi->limit;
20461 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20465 + if (!is_accounted_vlimit(id))
20468 + vx_limit_fixup(limit, id);
20469 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20470 + vc_data.value = __rlim_get(limit, id);
20471 + vc_data.minimum = __rlim_rmin(limit, id);
20472 + vc_data.maximum = __rlim_rmax(limit, id);
20474 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20480 +void vx_vsi_meminfo(struct sysinfo *val)
20482 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20483 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20484 + u64 res_limit, res_usage;
20489 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20490 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20492 + if (res_limit != RESOURCE_MAX)
20493 + val->totalram = (res_limit >> PAGE_SHIFT);
20494 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20495 + val->bufferram = 0;
20496 + val->totalhigh = 0;
20497 + val->freehigh = 0;
20498 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20502 +void vx_vsi_swapinfo(struct sysinfo *val)
20504 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20505 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20506 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20507 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20508 + s64 swap_limit, swap_usage;
20513 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20514 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20515 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20516 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20518 + if (res_limit == RESOURCE_MAX)
20521 + swap_limit = memsw_limit - res_limit;
20522 + if (memsw_limit != RESOURCE_MAX)
20523 + val->totalswap = swap_limit >> PAGE_SHIFT;
20525 + swap_usage = memsw_usage - res_usage;
20526 + val->freeswap = (swap_usage < swap_limit) ?
20527 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20528 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20529 + val->totalswap = 0;
20530 + val->freeswap = 0;
20531 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20532 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20536 +long vx_vsi_cached(struct sysinfo *val)
20538 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20539 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20541 + return mem_cgroup_stat_read_cache(mcg);
20548 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20550 + struct vx_info *vxi = mm->mm_vx_info;
20551 + unsigned long points;
20557 + points = vxi->vx_badness_bias;
20559 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20560 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20561 + points += (v > w) ? (v - w) : 0;
20566 diff -NurpP --minimal linux-2.6.37/kernel/vserver/limit_init.h linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/limit_init.h
20567 --- linux-2.6.37/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20568 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/limit_init.h 2010-11-23 02:09:41.000000000 +0100
20572 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20576 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20577 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20578 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20579 + __rlim_set(limit, lim, 0);
20580 + atomic_set(&__rlim_lhit(limit, lim), 0);
20581 + __rlim_rmin(limit, lim) = 0;
20582 + __rlim_rmax(limit, lim) = 0;
20586 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20591 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20592 + if ((1 << lim) & VLIM_NOCHECK)
20594 + value = __rlim_get(limit, lim);
20595 + vxwprintk_xid(value,
20596 + "!!! limit: %p[%s,%d] = %ld on exit.",
20597 + limit, vlimit_name[lim], lim, (long)value);
20601 diff -NurpP --minimal linux-2.6.37/kernel/vserver/limit_proc.h linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/limit_proc.h
20602 --- linux-2.6.37/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20603 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/limit_proc.h 2010-11-23 02:09:41.000000000 +0100
20605 +#ifndef _VX_LIMIT_PROC_H
20606 +#define _VX_LIMIT_PROC_H
20608 +#include <linux/vserver/limit_int.h>
20611 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20612 +#define VX_LIMIT_TOP \
20613 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20615 +#define VX_LIMIT_ARG(r) \
20616 + (unsigned long)__rlim_get(limit, r), \
20617 + (unsigned long)__rlim_rmin(limit, r), \
20618 + (unsigned long)__rlim_rmax(limit, r), \
20619 + VX_VLIM(__rlim_soft(limit, r)), \
20620 + VX_VLIM(__rlim_hard(limit, r)), \
20621 + atomic_read(&__rlim_lhit(limit, r))
20623 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20625 + vx_limit_fixup(limit, -1);
20626 + return sprintf(buffer, VX_LIMIT_TOP
20627 + "PROC" VX_LIMIT_FMT
20628 + "VM" VX_LIMIT_FMT
20629 + "VML" VX_LIMIT_FMT
20630 + "RSS" VX_LIMIT_FMT
20631 + "ANON" VX_LIMIT_FMT
20632 + "RMAP" VX_LIMIT_FMT
20633 + "FILES" VX_LIMIT_FMT
20634 + "OFD" VX_LIMIT_FMT
20635 + "LOCKS" VX_LIMIT_FMT
20636 + "SOCK" VX_LIMIT_FMT
20637 + "MSGQ" VX_LIMIT_FMT
20638 + "SHM" VX_LIMIT_FMT
20639 + "SEMA" VX_LIMIT_FMT
20640 + "SEMS" VX_LIMIT_FMT
20641 + "DENT" VX_LIMIT_FMT,
20642 + VX_LIMIT_ARG(RLIMIT_NPROC),
20643 + VX_LIMIT_ARG(RLIMIT_AS),
20644 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20645 + VX_LIMIT_ARG(RLIMIT_RSS),
20646 + VX_LIMIT_ARG(VLIMIT_ANON),
20647 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20648 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20649 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20650 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20651 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20652 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20653 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20654 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20655 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20656 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20659 +#endif /* _VX_LIMIT_PROC_H */
20662 diff -NurpP --minimal linux-2.6.37/kernel/vserver/Makefile linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/Makefile
20663 --- linux-2.6.37/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
20664 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/Makefile 2010-11-23 02:09:41.000000000 +0100
20667 +# Makefile for the Linux vserver routines.
20671 +obj-y += vserver.o
20673 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
20674 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
20677 +vserver-$(CONFIG_INET) += inet.o
20678 +vserver-$(CONFIG_PROC_FS) += proc.o
20679 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
20680 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
20681 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
20682 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
20684 diff -NurpP --minimal linux-2.6.37/kernel/vserver/network.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/network.c
20685 --- linux-2.6.37/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20686 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/network.c 2010-11-23 02:09:41.000000000 +0100
20689 + * linux/kernel/vserver/network.c
20691 + * Virtual Server: Network Support
20693 + * Copyright (C) 2003-2007 Herbert Pötzl
20695 + * V0.01 broken out from vcontext V0.05
20696 + * V0.02 cleaned up implementation
20697 + * V0.03 added equiv nx commands
20698 + * V0.04 switch to RCU based hash
20699 + * V0.05 and back to locking again
20700 + * V0.06 changed vcmds to nxi arg
20701 + * V0.07 have __create claim() the nxi
20705 +#include <linux/err.h>
20706 +#include <linux/slab.h>
20707 +#include <linux/rcupdate.h>
20709 +#include <linux/vs_network.h>
20710 +#include <linux/vs_pid.h>
20711 +#include <linux/vserver/network_cmd.h>
20714 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20715 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20717 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20718 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20721 +static int __init init_network(void)
20723 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20724 + sizeof(struct nx_addr_v4), 0,
20725 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20726 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20727 + sizeof(struct nx_addr_v6), 0,
20728 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20733 +/* __alloc_nx_addr_v4() */
20735 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20737 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20738 + nx_addr_v4_cachep, GFP_KERNEL);
20740 + if (!IS_ERR(nxa))
20741 + memset(nxa, 0, sizeof(*nxa));
20745 +/* __dealloc_nx_addr_v4() */
20747 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20749 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20752 +/* __dealloc_nx_addr_v4_all() */
20754 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20757 + struct nx_addr_v4 *next = nxa->next;
20759 + __dealloc_nx_addr_v4(nxa);
20765 +#ifdef CONFIG_IPV6
20767 +/* __alloc_nx_addr_v6() */
20769 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20771 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20772 + nx_addr_v6_cachep, GFP_KERNEL);
20774 + if (!IS_ERR(nxa))
20775 + memset(nxa, 0, sizeof(*nxa));
20779 +/* __dealloc_nx_addr_v6() */
20781 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20783 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20786 +/* __dealloc_nx_addr_v6_all() */
20788 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20791 + struct nx_addr_v6 *next = nxa->next;
20793 + __dealloc_nx_addr_v6(nxa);
20798 +#endif /* CONFIG_IPV6 */
20800 +/* __alloc_nx_info()
20802 + * allocate an initialized nx_info struct
20803 + * doesn't make it visible (hash) */
20805 +static struct nx_info *__alloc_nx_info(nid_t nid)
20807 + struct nx_info *new = NULL;
20809 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20811 + /* would this benefit from a slab cache? */
20812 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20816 + memset(new, 0, sizeof(struct nx_info));
20817 + new->nx_id = nid;
20818 + INIT_HLIST_NODE(&new->nx_hlist);
20819 + atomic_set(&new->nx_usecnt, 0);
20820 + atomic_set(&new->nx_tasks, 0);
20821 + new->nx_state = 0;
20823 + new->nx_flags = NXF_INIT_SET;
20825 + /* rest of init goes here */
20827 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20828 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20830 + vxdprintk(VXD_CBIT(nid, 0),
20831 + "alloc_nx_info(%d) = %p", nid, new);
20832 + atomic_inc(&nx_global_ctotal);
20836 +/* __dealloc_nx_info()
20838 + * final disposal of nx_info */
20840 +static void __dealloc_nx_info(struct nx_info *nxi)
20842 + vxdprintk(VXD_CBIT(nid, 0),
20843 + "dealloc_nx_info(%p)", nxi);
20845 + nxi->nx_hlist.next = LIST_POISON1;
20848 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20849 + BUG_ON(atomic_read(&nxi->nx_tasks));
20851 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20853 + nxi->nx_state |= NXS_RELEASED;
20855 + atomic_dec(&nx_global_ctotal);
20858 +static void __shutdown_nx_info(struct nx_info *nxi)
20860 + nxi->nx_state |= NXS_SHUTDOWN;
20861 + vs_net_change(nxi, VSC_NETDOWN);
20864 +/* exported stuff */
20866 +void free_nx_info(struct nx_info *nxi)
20868 + /* context shutdown is mandatory */
20869 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20871 + /* context must not be hashed */
20872 + BUG_ON(nxi->nx_state & NXS_HASHED);
20874 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20875 + BUG_ON(atomic_read(&nxi->nx_tasks));
20877 + __dealloc_nx_info(nxi);
20881 +void __nx_set_lback(struct nx_info *nxi)
20883 + int nid = nxi->nx_id;
20884 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20886 + nxi->v4_lback.s_addr = lback;
20889 +extern int __nx_inet_add_lback(__be32 addr);
20890 +extern int __nx_inet_del_lback(__be32 addr);
20893 +/* hash table for nx_info hash */
20895 +#define NX_HASH_SIZE 13
20897 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20899 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
20902 +static inline unsigned int __hashval(nid_t nid)
20904 + return (nid % NX_HASH_SIZE);
20909 +/* __hash_nx_info()
20911 + * add the nxi to the global hash table
20912 + * requires the hash_lock to be held */
20914 +static inline void __hash_nx_info(struct nx_info *nxi)
20916 + struct hlist_head *head;
20918 + vxd_assert_lock(&nx_info_hash_lock);
20919 + vxdprintk(VXD_CBIT(nid, 4),
20920 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20922 + /* context must not be hashed */
20923 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20925 + nxi->nx_state |= NXS_HASHED;
20926 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20927 + hlist_add_head(&nxi->nx_hlist, head);
20928 + atomic_inc(&nx_global_cactive);
20931 +/* __unhash_nx_info()
20933 + * remove the nxi from the global hash table
20934 + * requires the hash_lock to be held */
20936 +static inline void __unhash_nx_info(struct nx_info *nxi)
20938 + vxd_assert_lock(&nx_info_hash_lock);
20939 + vxdprintk(VXD_CBIT(nid, 4),
20940 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20941 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20943 + /* context must be hashed */
20944 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20945 + /* but without tasks */
20946 + BUG_ON(atomic_read(&nxi->nx_tasks));
20948 + nxi->nx_state &= ~NXS_HASHED;
20949 + hlist_del(&nxi->nx_hlist);
20950 + atomic_dec(&nx_global_cactive);
20954 +/* __lookup_nx_info()
20956 + * requires the hash_lock to be held
20957 + * doesn't increment the nx_refcnt */
20959 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20961 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20962 + struct hlist_node *pos;
20963 + struct nx_info *nxi;
20965 + vxd_assert_lock(&nx_info_hash_lock);
20966 + hlist_for_each(pos, head) {
20967 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20969 + if (nxi->nx_id == nid)
20974 + vxdprintk(VXD_CBIT(nid, 0),
20975 + "__lookup_nx_info(#%u): %p[#%u]",
20976 + nid, nxi, nxi ? nxi->nx_id : 0);
20981 +/* __create_nx_info()
20983 + * create the requested context
20984 + * get(), claim() and hash it */
20986 +static struct nx_info *__create_nx_info(int id)
20988 + struct nx_info *new, *nxi = NULL;
20990 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20992 + if (!(new = __alloc_nx_info(id)))
20993 + return ERR_PTR(-ENOMEM);
20995 + /* required to make dynamic xids unique */
20996 + spin_lock(&nx_info_hash_lock);
20998 + /* static context requested */
20999 + if ((nxi = __lookup_nx_info(id))) {
21000 + vxdprintk(VXD_CBIT(nid, 0),
21001 + "create_nx_info(%d) = %p (already there)", id, nxi);
21002 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21003 + nxi = ERR_PTR(-EBUSY);
21005 + nxi = ERR_PTR(-EEXIST);
21008 + /* new context */
21009 + vxdprintk(VXD_CBIT(nid, 0),
21010 + "create_nx_info(%d) = %p (new)", id, new);
21011 + claim_nx_info(new, NULL);
21012 + __nx_set_lback(new);
21013 + __hash_nx_info(get_nx_info(new));
21014 + nxi = new, new = NULL;
21017 + spin_unlock(&nx_info_hash_lock);
21019 + __dealloc_nx_info(new);
21025 +/* exported stuff */
21028 +void unhash_nx_info(struct nx_info *nxi)
21030 + __shutdown_nx_info(nxi);
21031 + spin_lock(&nx_info_hash_lock);
21032 + __unhash_nx_info(nxi);
21033 + spin_unlock(&nx_info_hash_lock);
21036 +/* lookup_nx_info()
21038 + * search for a nx_info and get() it
21039 + * negative id means current */
21041 +struct nx_info *lookup_nx_info(int id)
21043 + struct nx_info *nxi = NULL;
21046 + nxi = get_nx_info(current_nx_info());
21047 + } else if (id > 1) {
21048 + spin_lock(&nx_info_hash_lock);
21049 + nxi = get_nx_info(__lookup_nx_info(id));
21050 + spin_unlock(&nx_info_hash_lock);
21055 +/* nid_is_hashed()
21057 + * verify that nid is still hashed */
21059 +int nid_is_hashed(nid_t nid)
21063 + spin_lock(&nx_info_hash_lock);
21064 + hashed = (__lookup_nx_info(nid) != NULL);
21065 + spin_unlock(&nx_info_hash_lock);
21070 +#ifdef CONFIG_PROC_FS
21074 + * get a subset of hashed nids for proc
21075 + * assumes size is at least one */
21077 +int get_nid_list(int index, unsigned int *nids, int size)
21079 + int hindex, nr_nids = 0;
21081 + /* only show current and children */
21082 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
21085 + nids[nr_nids] = nx_current_nid();
21089 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
21090 + struct hlist_head *head = &nx_info_hash[hindex];
21091 + struct hlist_node *pos;
21093 + spin_lock(&nx_info_hash_lock);
21094 + hlist_for_each(pos, head) {
21095 + struct nx_info *nxi;
21100 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21101 + nids[nr_nids] = nxi->nx_id;
21102 + if (++nr_nids >= size) {
21103 + spin_unlock(&nx_info_hash_lock);
21107 + /* keep the lock time short */
21108 + spin_unlock(&nx_info_hash_lock);
21117 + * migrate task to new network
21118 + * gets nxi, puts old_nxi on change
21121 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
21123 + struct nx_info *old_nxi;
21129 + vxdprintk(VXD_CBIT(nid, 5),
21130 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
21131 + p, nxi, nxi->nx_id,
21132 + atomic_read(&nxi->nx_usecnt),
21133 + atomic_read(&nxi->nx_tasks));
21135 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
21136 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
21139 + if (nx_info_state(nxi, NXS_SHUTDOWN))
21142 + /* maybe disallow this completely? */
21143 + old_nxi = task_get_nx_info(p);
21144 + if (old_nxi == nxi)
21149 + clr_nx_info(&p->nx_info);
21150 + claim_nx_info(nxi, p);
21151 + set_nx_info(&p->nx_info, nxi);
21152 + p->nid = nxi->nx_id;
21155 + vxdprintk(VXD_CBIT(nid, 5),
21156 + "moved task %p into nxi:%p[#%d]",
21157 + p, nxi, nxi->nx_id);
21160 + release_nx_info(old_nxi, p);
21163 + put_nx_info(old_nxi);
21168 +void nx_set_persistent(struct nx_info *nxi)
21170 + vxdprintk(VXD_CBIT(nid, 6),
21171 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
21173 + get_nx_info(nxi);
21174 + claim_nx_info(nxi, NULL);
21177 +void nx_clear_persistent(struct nx_info *nxi)
21179 + vxdprintk(VXD_CBIT(nid, 6),
21180 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
21182 + release_nx_info(nxi, NULL);
21183 + put_nx_info(nxi);
21186 +void nx_update_persistent(struct nx_info *nxi)
21188 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
21189 + nx_set_persistent(nxi);
21191 + nx_clear_persistent(nxi);
21194 +/* vserver syscall commands below here */
21196 +/* taks nid and nx_info functions */
21198 +#include <asm/uaccess.h>
21201 +int vc_task_nid(uint32_t id)
21206 + struct task_struct *tsk;
21208 + read_lock(&tasklist_lock);
21209 + tsk = find_task_by_real_pid(id);
21210 + nid = (tsk) ? tsk->nid : -ESRCH;
21211 + read_unlock(&tasklist_lock);
21213 + nid = nx_current_nid();
21218 +int vc_nx_info(struct nx_info *nxi, void __user *data)
21220 + struct vcmd_nx_info_v0 vc_data;
21222 + vc_data.nid = nxi->nx_id;
21224 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21230 +/* network functions */
21232 +int vc_net_create(uint32_t nid, void __user *data)
21234 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21235 + struct nx_info *new_nxi;
21238 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21241 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21244 + new_nxi = __create_nx_info(nid);
21245 + if (IS_ERR(new_nxi))
21246 + return PTR_ERR(new_nxi);
21248 + /* initial flags */
21249 + new_nxi->nx_flags = vc_data.flagword;
21252 + if (vs_net_change(new_nxi, VSC_NETUP))
21255 + ret = nx_migrate_task(current, new_nxi);
21259 + /* return context id on success */
21260 + ret = new_nxi->nx_id;
21262 + /* get a reference for persistent contexts */
21263 + if ((vc_data.flagword & NXF_PERSISTENT))
21264 + nx_set_persistent(new_nxi);
21266 + release_nx_info(new_nxi, NULL);
21267 + put_nx_info(new_nxi);
21272 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21274 + return nx_migrate_task(current, nxi);
21279 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21280 + uint16_t type, uint16_t flags)
21282 + struct nx_addr_v4 *nxa = &nxi->v4;
21284 + if (NX_IPV4(nxi)) {
21285 + /* locate last entry */
21286 + for (; nxa->next; nxa = nxa->next);
21287 + nxa->next = __alloc_nx_addr_v4();
21291 + return PTR_ERR(nxa);
21294 + if (nxi->v4.next)
21295 + /* remove single ip for ip list */
21296 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21298 + nxa->ip[0].s_addr = ip;
21299 + nxa->ip[1].s_addr = ip2;
21300 + nxa->mask.s_addr = mask;
21301 + nxa->type = type;
21302 + nxa->flags = flags;
21307 +int vc_net_add(struct nx_info *nxi, void __user *data)
21309 + struct vcmd_net_addr_v0 vc_data;
21310 + int index, ret = 0;
21312 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21315 + switch (vc_data.type) {
21316 + case NXA_TYPE_IPV4:
21317 + if ((vc_data.count < 1) || (vc_data.count > 4))
21321 + while (index < vc_data.count) {
21322 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21323 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21331 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21332 + nxi->v4_bcast = vc_data.ip[0];
21336 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21337 + nxi->v4_lback = vc_data.ip[0];
21348 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21350 + struct vcmd_net_addr_v0 vc_data;
21352 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21355 + switch (vc_data.type) {
21356 + case NXA_TYPE_ANY:
21357 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21358 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21368 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21370 + struct vcmd_net_addr_ipv4_v1 vc_data;
21372 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21375 + switch (vc_data.type) {
21376 + case NXA_TYPE_ADDR:
21377 + case NXA_TYPE_RANGE:
21378 + case NXA_TYPE_MASK:
21379 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21380 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21382 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21383 + nxi->v4_bcast = vc_data.ip;
21386 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21387 + nxi->v4_lback = vc_data.ip;
21396 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
21398 + struct vcmd_net_addr_ipv4_v1 vc_data;
21400 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21403 + switch (vc_data.type) {
21404 +/* case NXA_TYPE_ADDR:
21407 + case NXA_TYPE_ANY:
21408 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21409 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21419 +#ifdef CONFIG_IPV6
21421 +int do_add_v6_addr(struct nx_info *nxi,
21422 + struct in6_addr *ip, struct in6_addr *mask,
21423 + uint32_t prefix, uint16_t type, uint16_t flags)
21425 + struct nx_addr_v6 *nxa = &nxi->v6;
21427 + if (NX_IPV6(nxi)) {
21428 + /* locate last entry */
21429 + for (; nxa->next; nxa = nxa->next);
21430 + nxa->next = __alloc_nx_addr_v6();
21434 + return PTR_ERR(nxa);
21438 + nxa->mask = *mask;
21439 + nxa->prefix = prefix;
21440 + nxa->type = type;
21441 + nxa->flags = flags;
21446 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21448 + struct vcmd_net_addr_ipv6_v1 vc_data;
21450 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21453 + switch (vc_data.type) {
21454 + case NXA_TYPE_ADDR:
21455 + case NXA_TYPE_MASK:
21456 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21457 + vc_data.prefix, vc_data.type, vc_data.flags);
21464 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21466 + struct vcmd_net_addr_ipv6_v1 vc_data;
21468 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21471 + switch (vc_data.type) {
21472 + case NXA_TYPE_ANY:
21473 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21474 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21483 +#endif /* CONFIG_IPV6 */
21486 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21488 + struct vcmd_net_flags_v0 vc_data;
21490 + vc_data.flagword = nxi->nx_flags;
21492 + /* special STATE flag handling */
21493 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21495 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21500 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21502 + struct vcmd_net_flags_v0 vc_data;
21503 + uint64_t mask, trigger;
21505 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21508 + /* special STATE flag handling */
21509 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21510 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21512 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21513 + vc_data.flagword, mask);
21514 + if (trigger & NXF_PERSISTENT)
21515 + nx_update_persistent(nxi);
21520 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21522 + struct vcmd_net_caps_v0 vc_data;
21524 + vc_data.ncaps = nxi->nx_ncaps;
21525 + vc_data.cmask = ~0ULL;
21527 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21532 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21534 + struct vcmd_net_caps_v0 vc_data;
21536 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21539 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21540 + vc_data.ncaps, vc_data.cmask);
21545 +#include <linux/module.h>
21547 +module_init(init_network);
21549 +EXPORT_SYMBOL_GPL(free_nx_info);
21550 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21552 diff -NurpP --minimal linux-2.6.37/kernel/vserver/proc.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/proc.c
21553 --- linux-2.6.37/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21554 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/proc.c 2011-01-08 03:33:34.000000000 +0100
21557 + * linux/kernel/vserver/proc.c
21559 + * Virtual Context Support
21561 + * Copyright (C) 2003-2007 Herbert Pötzl
21563 + * V0.01 basic structure
21564 + * V0.02 adaptation vs1.3.0
21565 + * V0.03 proc permissions
21566 + * V0.04 locking/generic
21567 + * V0.05 next generation procfs
21568 + * V0.06 inode validation
21569 + * V0.07 generic rewrite vid
21570 + * V0.08 remove inode type
21574 +#include <linux/proc_fs.h>
21575 +#include <linux/fs_struct.h>
21576 +#include <linux/mount.h>
21577 +#include <asm/unistd.h>
21579 +#include <linux/vs_context.h>
21580 +#include <linux/vs_network.h>
21581 +#include <linux/vs_cvirt.h>
21583 +#include <linux/in.h>
21584 +#include <linux/inetdevice.h>
21585 +#include <linux/vs_inet.h>
21586 +#include <linux/vs_inet6.h>
21588 +#include <linux/vserver/global.h>
21590 +#include "cvirt_proc.h"
21591 +#include "cacct_proc.h"
21592 +#include "limit_proc.h"
21593 +#include "sched_proc.h"
21594 +#include "vci_config.h"
21597 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21601 + CAP_FOR_EACH_U32(__capi) {
21602 + buffer += sprintf(buffer, "%08x",
21603 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21609 +static struct proc_dir_entry *proc_virtual;
21611 +static struct proc_dir_entry *proc_virtnet;
21614 +/* first the actual feeds */
21617 +static int proc_vci(char *buffer)
21619 + return sprintf(buffer,
21620 + "VCIVersion:\t%04x:%04x\n"
21621 + "VCISyscall:\t%d\n"
21622 + "VCIKernel:\t%08x\n",
21623 + VCI_VERSION >> 16,
21624 + VCI_VERSION & 0xFFFF,
21626 + vci_kernel_config());
21629 +static int proc_virtual_info(char *buffer)
21631 + return proc_vci(buffer);
21634 +static int proc_virtual_status(char *buffer)
21636 + return sprintf(buffer,
21638 + "#CActive:\t%d\n"
21639 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21640 + "#InitTask:\t%d\t%d %d\n",
21641 + atomic_read(&vx_global_ctotal),
21642 + atomic_read(&vx_global_cactive),
21643 + atomic_read(&vs_global_nsproxy),
21644 + atomic_read(&vs_global_fs),
21645 + atomic_read(&vs_global_mnt_ns),
21646 + atomic_read(&vs_global_uts_ns),
21647 + atomic_read(&nr_ipc_ns),
21648 + atomic_read(&vs_global_user_ns),
21649 + atomic_read(&vs_global_pid_ns),
21650 + atomic_read(&init_task.usage),
21651 + atomic_read(&init_task.nsproxy->count),
21652 + init_task.fs->users);
21656 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21660 + length = sprintf(buffer,
21668 + vxi->vx_badness_bias);
21672 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21674 + char *orig = buffer;
21676 + buffer += sprintf(buffer,
21679 + "Flags:\t%016llx\n",
21680 + atomic_read(&vxi->vx_usecnt),
21681 + atomic_read(&vxi->vx_tasks),
21682 + (unsigned long long)vxi->vx_flags);
21684 + buffer += sprintf(buffer, "BCaps:\t");
21685 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21686 + buffer += sprintf(buffer, "\n");
21688 + buffer += sprintf(buffer,
21689 + "CCaps:\t%016llx\n"
21690 + "Spaces:\t%08lx %08lx\n",
21691 + (unsigned long long)vxi->vx_ccaps,
21692 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21693 + return buffer - orig;
21696 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21698 + return vx_info_proc_limit(&vxi->limit, buffer);
21701 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21705 + length = vx_info_proc_sched(&vxi->sched, buffer);
21706 + for_each_online_cpu(cpu) {
21707 + length += vx_info_proc_sched_pc(
21708 + &vx_per_cpu(vxi, sched_pc, cpu),
21709 + buffer + length, cpu);
21714 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21716 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21719 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21721 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21724 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21728 + vx_update_load(vxi);
21729 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21730 + for_each_online_cpu(cpu) {
21731 + length += vx_info_proc_cvirt_pc(
21732 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21733 + buffer + length, cpu);
21738 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21740 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21744 +static int proc_virtnet_info(char *buffer)
21746 + return proc_vci(buffer);
21749 +static int proc_virtnet_status(char *buffer)
21751 + return sprintf(buffer,
21753 + "#CActive:\t%d\n",
21754 + atomic_read(&nx_global_ctotal),
21755 + atomic_read(&nx_global_cactive));
21758 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21760 + struct nx_addr_v4 *v4a;
21761 +#ifdef CONFIG_IPV6
21762 + struct nx_addr_v6 *v6a;
21766 + length = sprintf(buffer,
21769 + "Bcast:\t" NIPQUAD_FMT "\n"
21770 + "Lback:\t" NIPQUAD_FMT "\n",
21773 + NIPQUAD(nxi->v4_bcast.s_addr),
21774 + NIPQUAD(nxi->v4_lback.s_addr));
21776 + if (!NX_IPV4(nxi))
21778 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21779 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21782 +#ifdef CONFIG_IPV6
21783 + if (!NX_IPV6(nxi))
21785 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21786 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21793 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21797 + length = sprintf(buffer,
21800 + "Flags:\t%016llx\n"
21801 + "NCaps:\t%016llx\n",
21802 + atomic_read(&nxi->nx_usecnt),
21803 + atomic_read(&nxi->nx_tasks),
21804 + (unsigned long long)nxi->nx_flags,
21805 + (unsigned long long)nxi->nx_ncaps);
21811 +/* here the inode helpers */
21817 + struct inode_operations *iop;
21818 + struct file_operations *fop;
21819 + union proc_op op;
21822 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21824 + struct inode *inode = new_inode(sb);
21829 + inode->i_mode = p->mode;
21831 + inode->i_op = p->iop;
21833 + inode->i_fop = p->fop;
21835 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
21836 + inode->i_flags |= S_IMMUTABLE;
21838 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21840 + inode->i_uid = 0;
21841 + inode->i_gid = 0;
21842 + inode->i_tag = 0;
21847 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21848 + struct dentry *dentry, int id, void *ptr)
21850 + struct vs_entry *p = ptr;
21851 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21852 + struct dentry *error = ERR_PTR(-EINVAL);
21857 + PROC_I(inode)->op = p->op;
21858 + PROC_I(inode)->fd = id;
21859 + d_add(dentry, inode);
21867 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21870 + * Fill a directory entry.
21872 + * If possible create the dcache entry and derive our inode number and
21873 + * file type from dcache entry.
21875 + * Since all of the proc inode numbers are dynamically generated, the inode
21876 + * numbers do not exist until the inode is cache. This means creating the
21877 + * the dcache entry in readdir is necessary to keep the inode numbers
21878 + * reported by readdir in sync with the inode numbers reported
21881 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21882 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21884 + struct dentry *child, *dir = filp->f_dentry;
21885 + struct inode *inode;
21886 + struct qstr qname;
21888 + unsigned type = DT_UNKNOWN;
21890 + qname.name = name;
21892 + qname.hash = full_name_hash(name, len);
21894 + child = d_lookup(dir, &qname);
21896 + struct dentry *new;
21897 + new = d_alloc(dir, &qname);
21899 + child = instantiate(dir->d_inode, new, id, ptr);
21906 + if (!child || IS_ERR(child) || !child->d_inode)
21907 + goto end_instantiate;
21908 + inode = child->d_inode;
21910 + ino = inode->i_ino;
21911 + type = inode->i_mode >> 12;
21916 + ino = find_inode_number(dir, &qname);
21919 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21924 +/* get and revalidate vx_info/xid */
21927 +struct vx_info *get_proc_vx_info(struct inode *inode)
21929 + return lookup_vx_info(PROC_I(inode)->fd);
21932 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21934 + struct inode *inode = dentry->d_inode;
21935 + xid_t xid = PROC_I(inode)->fd;
21937 + if (!xid || xid_is_hashed(xid))
21944 +/* get and revalidate nx_info/nid */
21946 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21948 + struct inode *inode = dentry->d_inode;
21949 + nid_t nid = PROC_I(inode)->fd;
21951 + if (!nid || nid_is_hashed(nid))
21959 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21961 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21962 + size_t count, loff_t *ppos)
21964 + struct inode *inode = file->f_dentry->d_inode;
21965 + unsigned long page;
21966 + ssize_t length = 0;
21968 + if (count > PROC_BLOCK_SIZE)
21969 + count = PROC_BLOCK_SIZE;
21971 + /* fade that out as soon as stable */
21972 + WARN_ON(PROC_I(inode)->fd);
21974 + if (!(page = __get_free_page(GFP_KERNEL)))
21977 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21978 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21981 + length = simple_read_from_buffer(buf, count, ppos,
21982 + (char *)page, length);
21988 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21989 + size_t count, loff_t *ppos)
21991 + struct inode *inode = file->f_dentry->d_inode;
21992 + struct vx_info *vxi = NULL;
21993 + xid_t xid = PROC_I(inode)->fd;
21994 + unsigned long page;
21995 + ssize_t length = 0;
21997 + if (count > PROC_BLOCK_SIZE)
21998 + count = PROC_BLOCK_SIZE;
22000 + /* fade that out as soon as stable */
22002 + vxi = lookup_vx_info(xid);
22006 + length = -ENOMEM;
22007 + if (!(page = __get_free_page(GFP_KERNEL)))
22010 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
22011 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
22014 + length = simple_read_from_buffer(buf, count, ppos,
22015 + (char *)page, length);
22019 + put_vx_info(vxi);
22024 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
22025 + size_t count, loff_t *ppos)
22027 + struct inode *inode = file->f_dentry->d_inode;
22028 + struct nx_info *nxi = NULL;
22029 + nid_t nid = PROC_I(inode)->fd;
22030 + unsigned long page;
22031 + ssize_t length = 0;
22033 + if (count > PROC_BLOCK_SIZE)
22034 + count = PROC_BLOCK_SIZE;
22036 + /* fade that out as soon as stable */
22038 + nxi = lookup_nx_info(nid);
22042 + length = -ENOMEM;
22043 + if (!(page = __get_free_page(GFP_KERNEL)))
22046 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
22047 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
22050 + length = simple_read_from_buffer(buf, count, ppos,
22051 + (char *)page, length);
22055 + put_nx_info(nxi);
22062 +/* here comes the lower level */
22065 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
22066 + .len = sizeof(NAME) - 1, \
22067 + .name = (NAME), \
22075 +#define DIR(NAME, MODE, OTYPE) \
22076 + NOD(NAME, (S_IFDIR | (MODE)), \
22077 + &proc_ ## OTYPE ## _inode_operations, \
22078 + &proc_ ## OTYPE ## _file_operations, { } )
22080 +#define INF(NAME, MODE, OTYPE) \
22081 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22082 + &proc_vs_info_file_operations, \
22083 + { .proc_vs_read = &proc_##OTYPE } )
22085 +#define VINF(NAME, MODE, OTYPE) \
22086 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22087 + &proc_vx_info_file_operations, \
22088 + { .proc_vxi_read = &proc_##OTYPE } )
22090 +#define NINF(NAME, MODE, OTYPE) \
22091 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22092 + &proc_nx_info_file_operations, \
22093 + { .proc_nxi_read = &proc_##OTYPE } )
22096 +static struct file_operations proc_vs_info_file_operations = {
22097 + .read = proc_vs_info_read,
22100 +static struct file_operations proc_vx_info_file_operations = {
22101 + .read = proc_vx_info_read,
22104 +static struct dentry_operations proc_xid_dentry_operations = {
22105 + .d_revalidate = proc_xid_revalidate,
22108 +static struct vs_entry vx_base_stuff[] = {
22109 + VINF("info", S_IRUGO, vxi_info),
22110 + VINF("status", S_IRUGO, vxi_status),
22111 + VINF("limit", S_IRUGO, vxi_limit),
22112 + VINF("sched", S_IRUGO, vxi_sched),
22113 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
22114 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
22115 + VINF("cvirt", S_IRUGO, vxi_cvirt),
22116 + VINF("cacct", S_IRUGO, vxi_cacct),
22123 +static struct dentry *proc_xid_instantiate(struct inode *dir,
22124 + struct dentry *dentry, int id, void *ptr)
22126 + dentry->d_op = &proc_xid_dentry_operations;
22127 + return vs_proc_instantiate(dir, dentry, id, ptr);
22130 +static struct dentry *proc_xid_lookup(struct inode *dir,
22131 + struct dentry *dentry, struct nameidata *nd)
22133 + struct vs_entry *p = vx_base_stuff;
22134 + struct dentry *error = ERR_PTR(-ENOENT);
22136 + for (; p->name; p++) {
22137 + if (p->len != dentry->d_name.len)
22139 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22145 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22150 +static int proc_xid_readdir(struct file *filp,
22151 + void *dirent, filldir_t filldir)
22153 + struct dentry *dentry = filp->f_dentry;
22154 + struct inode *inode = dentry->d_inode;
22155 + struct vs_entry *p = vx_base_stuff;
22156 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
22160 + pos = filp->f_pos;
22163 + ino = inode->i_ino;
22164 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22167 + /* fall through */
22169 + ino = parent_ino(dentry);
22170 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22173 + /* fall through */
22176 + if (index >= size)
22178 + for (p += index; p->name; p++) {
22179 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22180 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22186 + filp->f_pos = pos;
22192 +static struct file_operations proc_nx_info_file_operations = {
22193 + .read = proc_nx_info_read,
22196 +static struct dentry_operations proc_nid_dentry_operations = {
22197 + .d_revalidate = proc_nid_revalidate,
22200 +static struct vs_entry nx_base_stuff[] = {
22201 + NINF("info", S_IRUGO, nxi_info),
22202 + NINF("status", S_IRUGO, nxi_status),
22207 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22208 + struct dentry *dentry, int id, void *ptr)
22210 + dentry->d_op = &proc_nid_dentry_operations;
22211 + return vs_proc_instantiate(dir, dentry, id, ptr);
22214 +static struct dentry *proc_nid_lookup(struct inode *dir,
22215 + struct dentry *dentry, struct nameidata *nd)
22217 + struct vs_entry *p = nx_base_stuff;
22218 + struct dentry *error = ERR_PTR(-ENOENT);
22220 + for (; p->name; p++) {
22221 + if (p->len != dentry->d_name.len)
22223 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22229 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22234 +static int proc_nid_readdir(struct file *filp,
22235 + void *dirent, filldir_t filldir)
22237 + struct dentry *dentry = filp->f_dentry;
22238 + struct inode *inode = dentry->d_inode;
22239 + struct vs_entry *p = nx_base_stuff;
22240 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22244 + pos = filp->f_pos;
22247 + ino = inode->i_ino;
22248 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22251 + /* fall through */
22253 + ino = parent_ino(dentry);
22254 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22257 + /* fall through */
22260 + if (index >= size)
22262 + for (p += index; p->name; p++) {
22263 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22264 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22270 + filp->f_pos = pos;
22275 +#define MAX_MULBY10 ((~0U - 9) / 10)
22277 +static inline int atovid(const char *str, int len)
22282 + while (len-- > 0) {
22287 + if (vid >= MAX_MULBY10)
22297 +/* now the upper level (virtual) */
22300 +static struct file_operations proc_xid_file_operations = {
22301 + .read = generic_read_dir,
22302 + .readdir = proc_xid_readdir,
22305 +static struct inode_operations proc_xid_inode_operations = {
22306 + .lookup = proc_xid_lookup,
22309 +static struct vs_entry vx_virtual_stuff[] = {
22310 + INF("info", S_IRUGO, virtual_info),
22311 + INF("status", S_IRUGO, virtual_status),
22312 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22316 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22317 + struct dentry *dentry, struct nameidata *nd)
22319 + struct vs_entry *p = vx_virtual_stuff;
22320 + struct dentry *error = ERR_PTR(-ENOENT);
22323 + for (; p->name; p++) {
22324 + if (p->len != dentry->d_name.len)
22326 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22330 + goto instantiate;
22332 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22333 + if ((id < 0) || !xid_is_hashed(id))
22337 + error = proc_xid_instantiate(dir, dentry, id, p);
22342 +static struct file_operations proc_nid_file_operations = {
22343 + .read = generic_read_dir,
22344 + .readdir = proc_nid_readdir,
22347 +static struct inode_operations proc_nid_inode_operations = {
22348 + .lookup = proc_nid_lookup,
22351 +static struct vs_entry nx_virtnet_stuff[] = {
22352 + INF("info", S_IRUGO, virtnet_info),
22353 + INF("status", S_IRUGO, virtnet_status),
22354 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22358 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22359 + struct dentry *dentry, struct nameidata *nd)
22361 + struct vs_entry *p = nx_virtnet_stuff;
22362 + struct dentry *error = ERR_PTR(-ENOENT);
22365 + for (; p->name; p++) {
22366 + if (p->len != dentry->d_name.len)
22368 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22372 + goto instantiate;
22374 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22375 + if ((id < 0) || !nid_is_hashed(id))
22379 + error = proc_nid_instantiate(dir, dentry, id, p);
22385 +#define PROC_MAXVIDS 32
22387 +int proc_virtual_readdir(struct file *filp,
22388 + void *dirent, filldir_t filldir)
22390 + struct dentry *dentry = filp->f_dentry;
22391 + struct inode *inode = dentry->d_inode;
22392 + struct vs_entry *p = vx_virtual_stuff;
22393 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22395 + unsigned int xid_array[PROC_MAXVIDS];
22396 + char buf[PROC_NUMBUF];
22397 + unsigned int nr_xids, i;
22400 + pos = filp->f_pos;
22403 + ino = inode->i_ino;
22404 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22407 + /* fall through */
22409 + ino = parent_ino(dentry);
22410 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22413 + /* fall through */
22416 + if (index >= size)
22418 + for (p += index; p->name; p++) {
22419 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22420 + vs_proc_instantiate, 0, p))
22425 + index = pos - size;
22426 + p = &vx_virtual_stuff[size - 1];
22427 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22428 + for (i = 0; i < nr_xids; i++) {
22429 + int n, xid = xid_array[i];
22430 + unsigned int j = PROC_NUMBUF;
22434 + buf[--j] = '0' + (n % 10);
22437 + if (proc_fill_cache(filp, dirent, filldir,
22438 + buf + j, PROC_NUMBUF - j,
22439 + vs_proc_instantiate, xid, p))
22445 + filp->f_pos = pos;
22449 +static int proc_virtual_getattr(struct vfsmount *mnt,
22450 + struct dentry *dentry, struct kstat *stat)
22452 + struct inode *inode = dentry->d_inode;
22454 + generic_fillattr(inode, stat);
22455 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22459 +static struct file_operations proc_virtual_dir_operations = {
22460 + .read = generic_read_dir,
22461 + .readdir = proc_virtual_readdir,
22464 +static struct inode_operations proc_virtual_dir_inode_operations = {
22465 + .getattr = proc_virtual_getattr,
22466 + .lookup = proc_virtual_lookup,
22473 +int proc_virtnet_readdir(struct file *filp,
22474 + void *dirent, filldir_t filldir)
22476 + struct dentry *dentry = filp->f_dentry;
22477 + struct inode *inode = dentry->d_inode;
22478 + struct vs_entry *p = nx_virtnet_stuff;
22479 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22481 + unsigned int nid_array[PROC_MAXVIDS];
22482 + char buf[PROC_NUMBUF];
22483 + unsigned int nr_nids, i;
22486 + pos = filp->f_pos;
22489 + ino = inode->i_ino;
22490 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22493 + /* fall through */
22495 + ino = parent_ino(dentry);
22496 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22499 + /* fall through */
22502 + if (index >= size)
22504 + for (p += index; p->name; p++) {
22505 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22506 + vs_proc_instantiate, 0, p))
22511 + index = pos - size;
22512 + p = &nx_virtnet_stuff[size - 1];
22513 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22514 + for (i = 0; i < nr_nids; i++) {
22515 + int n, nid = nid_array[i];
22516 + unsigned int j = PROC_NUMBUF;
22520 + buf[--j] = '0' + (n % 10);
22523 + if (proc_fill_cache(filp, dirent, filldir,
22524 + buf + j, PROC_NUMBUF - j,
22525 + vs_proc_instantiate, nid, p))
22531 + filp->f_pos = pos;
22535 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22536 + struct dentry *dentry, struct kstat *stat)
22538 + struct inode *inode = dentry->d_inode;
22540 + generic_fillattr(inode, stat);
22541 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22545 +static struct file_operations proc_virtnet_dir_operations = {
22546 + .read = generic_read_dir,
22547 + .readdir = proc_virtnet_readdir,
22550 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22551 + .getattr = proc_virtnet_getattr,
22552 + .lookup = proc_virtnet_lookup,
22557 +void proc_vx_init(void)
22559 + struct proc_dir_entry *ent;
22561 + ent = proc_mkdir("virtual", 0);
22563 + ent->proc_fops = &proc_virtual_dir_operations;
22564 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22566 + proc_virtual = ent;
22568 + ent = proc_mkdir("virtnet", 0);
22570 + ent->proc_fops = &proc_virtnet_dir_operations;
22571 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22573 + proc_virtnet = ent;
22579 +/* per pid info */
22582 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22584 + struct vx_info *vxi;
22585 + char *orig = buffer;
22587 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22589 + vxi = task_get_vx_info(p);
22593 + buffer += sprintf(buffer, "BCaps:\t");
22594 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22595 + buffer += sprintf(buffer, "\n");
22596 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22597 + (unsigned long long)vxi->vx_ccaps);
22598 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22599 + (unsigned long long)vxi->vx_flags);
22600 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22602 + put_vx_info(vxi);
22604 + return buffer - orig;
22608 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22610 + struct nx_info *nxi;
22611 + struct nx_addr_v4 *v4a;
22612 +#ifdef CONFIG_IPV6
22613 + struct nx_addr_v6 *v6a;
22615 + char *orig = buffer;
22618 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22620 + nxi = task_get_nx_info(p);
22624 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22625 + (unsigned long long)nxi->nx_ncaps);
22626 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22627 + (unsigned long long)nxi->nx_flags);
22629 + buffer += sprintf(buffer,
22630 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22631 + NIPQUAD(nxi->v4_bcast.s_addr));
22632 + buffer += sprintf (buffer,
22633 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22634 + NIPQUAD(nxi->v4_lback.s_addr));
22635 + if (!NX_IPV4(nxi))
22637 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22638 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22641 +#ifdef CONFIG_IPV6
22642 + if (!NX_IPV6(nxi))
22644 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22645 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22649 + put_nx_info(nxi);
22651 + return buffer - orig;
22654 diff -NurpP --minimal linux-2.6.37/kernel/vserver/sched.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/sched.c
22655 --- linux-2.6.37/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22656 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/sched.c 2010-11-23 02:09:41.000000000 +0100
22659 + * linux/kernel/vserver/sched.c
22661 + * Virtual Server: Scheduler Support
22663 + * Copyright (C) 2004-2010 Herbert Pötzl
22665 + * V0.01 adapted Sam Vilains version to 2.6.3
22666 + * V0.02 removed legacy interface
22667 + * V0.03 changed vcmds to vxi arg
22668 + * V0.04 removed older and legacy interfaces
22669 + * V0.05 removed scheduler code/commands
22673 +#include <linux/vs_context.h>
22674 +#include <linux/vs_sched.h>
22675 +#include <linux/vserver/sched_cmd.h>
22677 +#include <asm/uaccess.h>
22680 +void vx_update_sched_param(struct _vx_sched *sched,
22681 + struct _vx_sched_pc *sched_pc)
22683 + sched_pc->prio_bias = sched->prio_bias;
22686 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22690 + if (data->prio_bias > MAX_PRIO_BIAS)
22691 + data->prio_bias = MAX_PRIO_BIAS;
22692 + if (data->prio_bias < MIN_PRIO_BIAS)
22693 + data->prio_bias = MIN_PRIO_BIAS;
22695 + if (data->cpu_id != ~0) {
22696 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22697 + cpus_and(vxi->sched.update, cpu_online_map,
22698 + vxi->sched.update);
22700 + vxi->sched.update = cpu_online_map;
22702 + for_each_cpu_mask(cpu, vxi->sched.update)
22703 + vx_update_sched_param(&vxi->sched,
22704 + &vx_per_cpu(vxi, sched_pc, cpu));
22708 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22710 + struct vcmd_prio_bias vc_data;
22712 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22715 + return do_set_prio_bias(vxi, &vc_data);
22718 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22720 + struct vcmd_prio_bias vc_data;
22721 + struct _vx_sched_pc *pcd;
22724 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22727 + cpu = vc_data.cpu_id;
22729 + if (!cpu_possible(cpu))
22732 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22733 + vc_data.prio_bias = pcd->prio_bias;
22735 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22740 diff -NurpP --minimal linux-2.6.37/kernel/vserver/sched_init.h linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/sched_init.h
22741 --- linux-2.6.37/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22742 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/sched_init.h 2010-11-23 02:09:41.000000000 +0100
22745 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22747 + /* scheduling; hard code starting values as constants */
22748 + sched->prio_bias = 0;
22752 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22754 + sched_pc->prio_bias = 0;
22756 + sched_pc->user_ticks = 0;
22757 + sched_pc->sys_ticks = 0;
22758 + sched_pc->hold_ticks = 0;
22761 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22767 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22771 diff -NurpP --minimal linux-2.6.37/kernel/vserver/sched_proc.h linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/sched_proc.h
22772 --- linux-2.6.37/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22773 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/sched_proc.h 2010-11-23 02:09:41.000000000 +0100
22775 +#ifndef _VX_SCHED_PROC_H
22776 +#define _VX_SCHED_PROC_H
22780 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22784 + length += sprintf(buffer,
22785 + "PrioBias:\t%8d\n",
22786 + sched->prio_bias);
22791 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22792 + char *buffer, int cpu)
22796 + length += sprintf(buffer + length,
22797 + "cpu %d: %lld %lld %lld", cpu,
22798 + (unsigned long long)sched_pc->user_ticks,
22799 + (unsigned long long)sched_pc->sys_ticks,
22800 + (unsigned long long)sched_pc->hold_ticks);
22801 + length += sprintf(buffer + length,
22802 + " %d\n", sched_pc->prio_bias);
22806 +#endif /* _VX_SCHED_PROC_H */
22807 diff -NurpP --minimal linux-2.6.37/kernel/vserver/signal.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/signal.c
22808 --- linux-2.6.37/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22809 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/signal.c 2010-11-23 02:09:41.000000000 +0100
22812 + * linux/kernel/vserver/signal.c
22814 + * Virtual Server: Signal Support
22816 + * Copyright (C) 2003-2007 Herbert Pötzl
22818 + * V0.01 broken out from vcontext V0.05
22819 + * V0.02 changed vcmds to vxi arg
22820 + * V0.03 adjusted siginfo for kill
22824 +#include <asm/uaccess.h>
22826 +#include <linux/vs_context.h>
22827 +#include <linux/vs_pid.h>
22828 +#include <linux/vserver/signal_cmd.h>
22831 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22833 + int retval, count = 0;
22834 + struct task_struct *p;
22835 + struct siginfo *sip = SEND_SIG_PRIV;
22838 + vxdprintk(VXD_CBIT(misc, 4),
22839 + "vx_info_kill(%p[#%d],%d,%d)*",
22840 + vxi, vxi->vx_id, pid, sig);
22841 + read_lock(&tasklist_lock);
22845 + for_each_process(p) {
22848 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22849 + (pid && vxi->vx_initpid == p->pid))
22852 + err = group_send_sig_info(sig, sip, p);
22854 + if (err != -EPERM)
22860 + if (vxi->vx_initpid) {
22861 + pid = vxi->vx_initpid;
22862 + /* for now, only SIGINT to private init ... */
22863 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22864 + /* ... as long as there are tasks left */
22865 + (atomic_read(&vxi->vx_tasks) > 1))
22868 + /* fallthrough */
22870 + p = find_task_by_real_pid(pid);
22872 + if (vx_task_xid(p) == vxi->vx_id)
22873 + retval = group_send_sig_info(sig, sip, p);
22877 + read_unlock(&tasklist_lock);
22878 + vxdprintk(VXD_CBIT(misc, 4),
22879 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22880 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22884 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22886 + struct vcmd_ctx_kill_v0 vc_data;
22888 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22891 + /* special check to allow guest shutdown */
22892 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22893 + /* forbid killall pid=0 when init is present */
22894 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22895 + (vc_data.pid > 1)))
22898 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22902 +static int __wait_exit(struct vx_info *vxi)
22904 + DECLARE_WAITQUEUE(wait, current);
22907 + add_wait_queue(&vxi->vx_wait, &wait);
22908 + set_current_state(TASK_INTERRUPTIBLE);
22911 + if (vx_info_state(vxi,
22912 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22914 + if (signal_pending(current)) {
22915 + ret = -ERESTARTSYS;
22922 + set_current_state(TASK_RUNNING);
22923 + remove_wait_queue(&vxi->vx_wait, &wait);
22929 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22931 + struct vcmd_wait_exit_v0 vc_data;
22934 + ret = __wait_exit(vxi);
22935 + vc_data.reboot_cmd = vxi->reboot_cmd;
22936 + vc_data.exit_code = vxi->exit_code;
22938 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22943 diff -NurpP --minimal linux-2.6.37/kernel/vserver/space.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/space.c
22944 --- linux-2.6.37/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22945 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/space.c 2011-01-31 21:05:40.000000000 +0100
22948 + * linux/kernel/vserver/space.c
22950 + * Virtual Server: Context Space Support
22952 + * Copyright (C) 2003-2010 Herbert Pötzl
22954 + * V0.01 broken out from context.c 0.07
22955 + * V0.02 added task locking for namespace
22956 + * V0.03 broken out vx_enter_namespace
22957 + * V0.04 added *space support and commands
22958 + * V0.05 added credential support
22962 +#include <linux/utsname.h>
22963 +#include <linux/nsproxy.h>
22964 +#include <linux/err.h>
22965 +#include <linux/fs_struct.h>
22966 +#include <linux/cred.h>
22967 +#include <asm/uaccess.h>
22969 +#include <linux/vs_context.h>
22970 +#include <linux/vserver/space.h>
22971 +#include <linux/vserver/space_cmd.h>
22973 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22974 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22975 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22976 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22977 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22978 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22981 +/* namespace functions */
22983 +#include <linux/mnt_namespace.h>
22984 +#include <linux/user_namespace.h>
22985 +#include <linux/pid_namespace.h>
22986 +#include <linux/ipc_namespace.h>
22987 +#include <net/net_namespace.h>
22990 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22991 + .mask = CLONE_FS |
22999 +static const struct vcmd_space_mask_v1 space_mask = {
23000 + .mask = CLONE_FS |
23005 +#ifdef CONFIG_PID_NS
23008 +#ifdef CONFIG_NET_NS
23014 +static const struct vcmd_space_mask_v1 default_space_mask = {
23015 + .mask = CLONE_FS |
23020 +#ifdef CONFIG_PID_NS
23027 + * build a new nsproxy mix
23028 + * assumes that both proxies are 'const'
23029 + * does not touch nsproxy refcounts
23030 + * will hold a reference on the result.
23033 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
23034 + struct nsproxy *new_nsproxy, unsigned long mask)
23036 + struct mnt_namespace *old_ns;
23037 + struct uts_namespace *old_uts;
23038 + struct ipc_namespace *old_ipc;
23039 +#ifdef CONFIG_PID_NS
23040 + struct pid_namespace *old_pid;
23042 +#ifdef CONFIG_NET_NS
23043 + struct net *old_net;
23045 + struct nsproxy *nsproxy;
23047 + nsproxy = copy_nsproxy(old_nsproxy);
23051 + if (mask & CLONE_NEWNS) {
23052 + old_ns = nsproxy->mnt_ns;
23053 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
23054 + if (nsproxy->mnt_ns)
23055 + get_mnt_ns(nsproxy->mnt_ns);
23059 + if (mask & CLONE_NEWUTS) {
23060 + old_uts = nsproxy->uts_ns;
23061 + nsproxy->uts_ns = new_nsproxy->uts_ns;
23062 + if (nsproxy->uts_ns)
23063 + get_uts_ns(nsproxy->uts_ns);
23067 + if (mask & CLONE_NEWIPC) {
23068 + old_ipc = nsproxy->ipc_ns;
23069 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
23070 + if (nsproxy->ipc_ns)
23071 + get_ipc_ns(nsproxy->ipc_ns);
23075 +#ifdef CONFIG_PID_NS
23076 + if (mask & CLONE_NEWPID) {
23077 + old_pid = nsproxy->pid_ns;
23078 + nsproxy->pid_ns = new_nsproxy->pid_ns;
23079 + if (nsproxy->pid_ns)
23080 + get_pid_ns(nsproxy->pid_ns);
23084 +#ifdef CONFIG_NET_NS
23085 + if (mask & CLONE_NEWNET) {
23086 + old_net = nsproxy->net_ns;
23087 + nsproxy->net_ns = new_nsproxy->net_ns;
23088 + if (nsproxy->net_ns)
23089 + get_net(nsproxy->net_ns);
23094 + put_mnt_ns(old_ns);
23096 + put_uts_ns(old_uts);
23098 + put_ipc_ns(old_ipc);
23099 +#ifdef CONFIG_PID_NS
23101 + put_pid_ns(old_pid);
23103 +#ifdef CONFIG_NET_NS
23105 + put_net(old_net);
23113 + * merge two nsproxy structs into a new one.
23114 + * will hold a reference on the result.
23118 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
23119 + struct nsproxy *proxy, unsigned long mask)
23121 + struct nsproxy null_proxy = { .mnt_ns = NULL };
23127 + /* vs_mix_nsproxy returns with reference */
23128 + return vs_mix_nsproxy(old ? old : &null_proxy,
23131 + get_nsproxy(proxy);
23136 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23138 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
23139 + struct fs_struct *fs_cur, *fs = NULL;
23140 + struct _vx_space *space;
23141 + int ret, kill = 0;
23143 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
23144 + vxi, vxi->vx_id, mask, index);
23146 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
23149 + if (index >= VX_SPACES)
23152 + space = &vxi->space[index];
23155 + mask = space->vx_nsmask;
23157 + if ((mask & space->vx_nsmask) != mask)
23160 + if (mask & CLONE_FS) {
23161 + fs = copy_fs_struct(space->vx_fs);
23165 + proxy = space->vx_nsproxy;
23167 + vxdprintk(VXD_CBIT(space, 9),
23168 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
23169 + vxi, vxi->vx_id, mask, index, proxy, fs);
23171 + task_lock(current);
23172 + fs_cur = current->fs;
23174 + if (mask & CLONE_FS) {
23175 + spin_lock(&fs_cur->lock);
23176 + current->fs = fs;
23177 + kill = !--fs_cur->users;
23178 + spin_unlock(&fs_cur->lock);
23181 + proxy_cur = current->nsproxy;
23182 + get_nsproxy(proxy_cur);
23183 + task_unlock(current);
23186 + free_fs_struct(fs_cur);
23188 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
23189 + if (IS_ERR(proxy_new)) {
23190 + ret = PTR_ERR(proxy_new);
23194 + proxy_new = xchg(¤t->nsproxy, proxy_new);
23196 + if (mask & CLONE_NEWUSER) {
23197 + struct cred *cred;
23199 + vxdprintk(VXD_CBIT(space, 10),
23201 + "vx_enter_space(%p[#%u])", vxi, vxi->vx_id);
23203 + "vx_enter_space(%p[#%u],%p,%p) cred (%p,%p)",
23205 + space->vx_real_cred, space->vx_cred,
23206 + current->real_cred, current->cred);
23207 + exit_creds(current);
23208 + current->real_cred = get_cred(space->vx_real_cred);
23209 + alter_cred_subscribers(current->real_cred, 1);
23211 + cred = __prepare_creds(space->vx_cred);
23213 + commit_creds(cred);
23219 + put_nsproxy(proxy_new);
23222 + put_nsproxy(proxy_cur);
23227 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23229 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
23230 + struct fs_struct *fs_vxi, *fs;
23231 + struct _vx_space *space;
23232 + int ret, kill = 0;
23234 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
23235 + vxi, vxi->vx_id, mask, index);
23237 + if ((mask & space_mask.mask) != mask)
23240 + if (index >= VX_SPACES)
23243 + space = &vxi->space[index];
23245 + proxy_vxi = space->vx_nsproxy;
23246 + fs_vxi = space->vx_fs;
23248 + if (mask & CLONE_FS) {
23249 + fs = copy_fs_struct(current->fs);
23254 + task_lock(current);
23256 + if (mask & CLONE_FS) {
23257 + spin_lock(&fs_vxi->lock);
23258 + space->vx_fs = fs;
23259 + kill = !--fs_vxi->users;
23260 + spin_unlock(&fs_vxi->lock);
23263 + proxy_cur = current->nsproxy;
23264 + get_nsproxy(proxy_cur);
23265 + task_unlock(current);
23268 + free_fs_struct(fs_vxi);
23270 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
23271 + if (IS_ERR(proxy_new)) {
23272 + ret = PTR_ERR(proxy_new);
23276 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
23277 + space->vx_nsmask |= mask;
23279 + if (mask & CLONE_NEWUSER) {
23280 + struct cred *cred;
23282 + vxdprintk(VXD_CBIT(space, 10),
23284 + "vx_set_space(%p[#%u])", vxi, vxi->vx_id);
23286 + "vx_set_space(%p[#%u],%p,%p) cred (%p,%p)",
23288 + space->vx_real_cred, space->vx_cred,
23289 + current->real_cred, current->cred);
23291 + if (current->real_cred) {
23292 + cred = get_cred(current->real_cred);
23293 + alter_cred_subscribers(cred, 1);
23296 + cred = xchg(&space->vx_real_cred, cred);
23298 + alter_cred_subscribers(cred, -1);
23303 + cred = prepare_creds();
23304 + cred = (struct cred *)xchg(&space->vx_cred, cred);
23306 + abort_creds(cred);
23312 + put_nsproxy(proxy_new);
23315 + put_nsproxy(proxy_cur);
23320 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
23322 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23324 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23327 + return vx_enter_space(vxi, vc_data.mask, 0);
23330 +int vc_enter_space(struct vx_info *vxi, void __user *data)
23332 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23334 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23337 + if (vc_data.index >= VX_SPACES)
23340 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
23343 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
23345 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23347 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23350 + return vx_set_space(vxi, vc_data.mask, 0);
23353 +int vc_set_space(struct vx_info *vxi, void __user *data)
23355 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23357 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23360 + if (vc_data.index >= VX_SPACES)
23363 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
23366 +int vc_get_space_mask(void __user *data, int type)
23368 + const struct vcmd_space_mask_v1 *mask;
23371 + mask = &space_mask_v0;
23372 + else if (type == 1)
23373 + mask = &space_mask;
23375 + mask = &default_space_mask;
23377 + vxdprintk(VXD_CBIT(space, 10),
23378 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
23380 + if (copy_to_user(data, mask, sizeof(*mask)))
23385 diff -NurpP --minimal linux-2.6.37/kernel/vserver/switch.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/switch.c
23386 --- linux-2.6.37/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
23387 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/switch.c 2010-11-23 02:09:41.000000000 +0100
23390 + * linux/kernel/vserver/switch.c
23392 + * Virtual Server: Syscall Switch
23394 + * Copyright (C) 2003-2007 Herbert Pötzl
23396 + * V0.01 syscall switch
23397 + * V0.02 added signal to context
23398 + * V0.03 added rlimit functions
23399 + * V0.04 added iattr, task/xid functions
23400 + * V0.05 added debug/history stuff
23401 + * V0.06 added compat32 layer
23402 + * V0.07 vcmd args and perms
23403 + * V0.08 added status commands
23404 + * V0.09 added tag commands
23405 + * V0.10 added oom bias
23406 + * V0.11 added device commands
23410 +#include <linux/vs_context.h>
23411 +#include <linux/vs_network.h>
23412 +#include <linux/vserver/switch.h>
23414 +#include "vci_config.h"
23418 +int vc_get_version(uint32_t id)
23420 + return VCI_VERSION;
23424 +int vc_get_vci(uint32_t id)
23426 + return vci_kernel_config();
23429 +#include <linux/vserver/context_cmd.h>
23430 +#include <linux/vserver/cvirt_cmd.h>
23431 +#include <linux/vserver/cacct_cmd.h>
23432 +#include <linux/vserver/limit_cmd.h>
23433 +#include <linux/vserver/network_cmd.h>
23434 +#include <linux/vserver/sched_cmd.h>
23435 +#include <linux/vserver/debug_cmd.h>
23436 +#include <linux/vserver/inode_cmd.h>
23437 +#include <linux/vserver/dlimit_cmd.h>
23438 +#include <linux/vserver/signal_cmd.h>
23439 +#include <linux/vserver/space_cmd.h>
23440 +#include <linux/vserver/tag_cmd.h>
23441 +#include <linux/vserver/device_cmd.h>
23443 +#include <linux/vserver/inode.h>
23444 +#include <linux/vserver/dlimit.h>
23447 +#ifdef CONFIG_COMPAT
23448 +#define __COMPAT(name, id, data, compat) \
23449 + (compat) ? name ## _x32(id, data) : name(id, data)
23450 +#define __COMPAT_NO_ID(name, data, compat) \
23451 + (compat) ? name ## _x32(data) : name(data)
23453 +#define __COMPAT(name, id, data, compat) \
23455 +#define __COMPAT_NO_ID(name, data, compat) \
23461 +long do_vcmd(uint32_t cmd, uint32_t id,
23462 + struct vx_info *vxi, struct nx_info *nxi,
23463 + void __user *data, int compat)
23467 + case VCMD_get_version:
23468 + return vc_get_version(id);
23469 + case VCMD_get_vci:
23470 + return vc_get_vci(id);
23472 + case VCMD_task_xid:
23473 + return vc_task_xid(id);
23474 + case VCMD_vx_info:
23475 + return vc_vx_info(vxi, data);
23477 + case VCMD_task_nid:
23478 + return vc_task_nid(id);
23479 + case VCMD_nx_info:
23480 + return vc_nx_info(nxi, data);
23482 + case VCMD_task_tag:
23483 + return vc_task_tag(id);
23485 + case VCMD_set_space_v1:
23486 + return vc_set_space_v1(vxi, data);
23487 + /* this is version 2 */
23488 + case VCMD_set_space:
23489 + return vc_set_space(vxi, data);
23491 + case VCMD_get_space_mask_v0:
23492 + return vc_get_space_mask(data, 0);
23493 + /* this is version 1 */
23494 + case VCMD_get_space_mask:
23495 + return vc_get_space_mask(data, 1);
23497 + case VCMD_get_space_default:
23498 + return vc_get_space_mask(data, -1);
23500 +#ifdef CONFIG_IA32_EMULATION
23501 + case VCMD_get_rlimit:
23502 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23503 + case VCMD_set_rlimit:
23504 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23506 + case VCMD_get_rlimit:
23507 + return vc_get_rlimit(vxi, data);
23508 + case VCMD_set_rlimit:
23509 + return vc_set_rlimit(vxi, data);
23511 + case VCMD_get_rlimit_mask:
23512 + return vc_get_rlimit_mask(id, data);
23513 + case VCMD_reset_hits:
23514 + return vc_reset_hits(vxi, data);
23515 + case VCMD_reset_minmax:
23516 + return vc_reset_minmax(vxi, data);
23518 + case VCMD_get_vhi_name:
23519 + return vc_get_vhi_name(vxi, data);
23520 + case VCMD_set_vhi_name:
23521 + return vc_set_vhi_name(vxi, data);
23523 + case VCMD_ctx_stat:
23524 + return vc_ctx_stat(vxi, data);
23525 + case VCMD_virt_stat:
23526 + return vc_virt_stat(vxi, data);
23527 + case VCMD_sock_stat:
23528 + return vc_sock_stat(vxi, data);
23529 + case VCMD_rlimit_stat:
23530 + return vc_rlimit_stat(vxi, data);
23532 + case VCMD_set_cflags:
23533 + return vc_set_cflags(vxi, data);
23534 + case VCMD_get_cflags:
23535 + return vc_get_cflags(vxi, data);
23537 + /* this is version 1 */
23538 + case VCMD_set_ccaps:
23539 + return vc_set_ccaps(vxi, data);
23540 + /* this is version 1 */
23541 + case VCMD_get_ccaps:
23542 + return vc_get_ccaps(vxi, data);
23543 + case VCMD_set_bcaps:
23544 + return vc_set_bcaps(vxi, data);
23545 + case VCMD_get_bcaps:
23546 + return vc_get_bcaps(vxi, data);
23548 + case VCMD_set_badness:
23549 + return vc_set_badness(vxi, data);
23550 + case VCMD_get_badness:
23551 + return vc_get_badness(vxi, data);
23553 + case VCMD_set_nflags:
23554 + return vc_set_nflags(nxi, data);
23555 + case VCMD_get_nflags:
23556 + return vc_get_nflags(nxi, data);
23558 + case VCMD_set_ncaps:
23559 + return vc_set_ncaps(nxi, data);
23560 + case VCMD_get_ncaps:
23561 + return vc_get_ncaps(nxi, data);
23563 + case VCMD_set_prio_bias:
23564 + return vc_set_prio_bias(vxi, data);
23565 + case VCMD_get_prio_bias:
23566 + return vc_get_prio_bias(vxi, data);
23567 + case VCMD_add_dlimit:
23568 + return __COMPAT(vc_add_dlimit, id, data, compat);
23569 + case VCMD_rem_dlimit:
23570 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23571 + case VCMD_set_dlimit:
23572 + return __COMPAT(vc_set_dlimit, id, data, compat);
23573 + case VCMD_get_dlimit:
23574 + return __COMPAT(vc_get_dlimit, id, data, compat);
23576 + case VCMD_ctx_kill:
23577 + return vc_ctx_kill(vxi, data);
23579 + case VCMD_wait_exit:
23580 + return vc_wait_exit(vxi, data);
23582 + case VCMD_get_iattr:
23583 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23584 + case VCMD_set_iattr:
23585 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23587 + case VCMD_fget_iattr:
23588 + return vc_fget_iattr(id, data);
23589 + case VCMD_fset_iattr:
23590 + return vc_fset_iattr(id, data);
23592 + case VCMD_enter_space_v0:
23593 + return vc_enter_space_v1(vxi, NULL);
23594 + case VCMD_enter_space_v1:
23595 + return vc_enter_space_v1(vxi, data);
23596 + /* this is version 2 */
23597 + case VCMD_enter_space:
23598 + return vc_enter_space(vxi, data);
23600 + case VCMD_ctx_create_v0:
23601 + return vc_ctx_create(id, NULL);
23602 + case VCMD_ctx_create:
23603 + return vc_ctx_create(id, data);
23604 + case VCMD_ctx_migrate_v0:
23605 + return vc_ctx_migrate(vxi, NULL);
23606 + case VCMD_ctx_migrate:
23607 + return vc_ctx_migrate(vxi, data);
23609 + case VCMD_net_create_v0:
23610 + return vc_net_create(id, NULL);
23611 + case VCMD_net_create:
23612 + return vc_net_create(id, data);
23613 + case VCMD_net_migrate:
23614 + return vc_net_migrate(nxi, data);
23616 + case VCMD_tag_migrate:
23617 + return vc_tag_migrate(id);
23619 + case VCMD_net_add:
23620 + return vc_net_add(nxi, data);
23621 + case VCMD_net_remove:
23622 + return vc_net_remove(nxi, data);
23624 + case VCMD_net_add_ipv4:
23625 + return vc_net_add_ipv4(nxi, data);
23626 + case VCMD_net_remove_ipv4:
23627 + return vc_net_remove_ipv4(nxi, data);
23628 +#ifdef CONFIG_IPV6
23629 + case VCMD_net_add_ipv6:
23630 + return vc_net_add_ipv6(nxi, data);
23631 + case VCMD_net_remove_ipv6:
23632 + return vc_net_remove_ipv6(nxi, data);
23634 +/* case VCMD_add_match_ipv4:
23635 + return vc_add_match_ipv4(nxi, data);
23636 + case VCMD_get_match_ipv4:
23637 + return vc_get_match_ipv4(nxi, data);
23638 +#ifdef CONFIG_IPV6
23639 + case VCMD_add_match_ipv6:
23640 + return vc_add_match_ipv6(nxi, data);
23641 + case VCMD_get_match_ipv6:
23642 + return vc_get_match_ipv6(nxi, data);
23645 +#ifdef CONFIG_VSERVER_DEVICE
23646 + case VCMD_set_mapping:
23647 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23648 + case VCMD_unset_mapping:
23649 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23651 +#ifdef CONFIG_VSERVER_HISTORY
23652 + case VCMD_dump_history:
23653 + return vc_dump_history(id);
23654 + case VCMD_read_history:
23655 + return __COMPAT(vc_read_history, id, data, compat);
23658 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23659 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23665 +#define __VCMD(vcmd, _perm, _args, _flags) \
23666 + case VCMD_ ## vcmd: perm = _perm; \
23667 + args = _args; flags = _flags; break
23670 +#define VCA_NONE 0x00
23671 +#define VCA_VXI 0x01
23672 +#define VCA_NXI 0x02
23674 +#define VCF_NONE 0x00
23675 +#define VCF_INFO 0x01
23676 +#define VCF_ADMIN 0x02
23677 +#define VCF_ARES 0x06 /* includes admin */
23678 +#define VCF_SETUP 0x08
23680 +#define VCF_ZIDOK 0x10 /* zero id okay */
23684 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23687 + int permit = -1, state = 0;
23688 + int perm = -1, args = 0, flags = 0;
23689 + struct vx_info *vxi = NULL;
23690 + struct nx_info *nxi = NULL;
23693 + /* unpriviledged commands */
23694 + __VCMD(get_version, 0, VCA_NONE, 0);
23695 + __VCMD(get_vci, 0, VCA_NONE, 0);
23696 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23697 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23698 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23699 + __VCMD(get_space_default,0, VCA_NONE, 0);
23701 + /* info commands */
23702 + __VCMD(task_xid, 2, VCA_NONE, 0);
23703 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23704 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23705 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23706 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23707 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23708 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23709 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23710 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23711 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23713 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23714 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23715 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23716 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23718 + __VCMD(task_nid, 2, VCA_NONE, 0);
23719 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23720 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23721 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23723 + __VCMD(task_tag, 2, VCA_NONE, 0);
23725 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23726 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23727 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23728 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23730 + /* lower admin commands */
23731 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23732 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23733 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23734 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23735 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23736 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23737 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23738 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23740 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23741 + __VCMD(net_create, 5, VCA_NONE, 0);
23742 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23744 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23746 + /* higher admin commands */
23747 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23748 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23749 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23751 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23752 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23753 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23754 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23756 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23757 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23758 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23760 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23761 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23762 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23763 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23764 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23765 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23766 +#ifdef CONFIG_IPV6
23767 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23768 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23770 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23771 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23772 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23773 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23774 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23776 +#ifdef CONFIG_VSERVER_DEVICE
23777 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23778 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23780 + /* debug level admin commands */
23781 +#ifdef CONFIG_VSERVER_HISTORY
23782 + __VCMD(dump_history, 9, VCA_NONE, 0);
23783 + __VCMD(read_history, 9, VCA_NONE, 0);
23790 + vxdprintk(VXD_CBIT(switch, 0),
23791 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23792 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23793 + VC_VERSION(cmd), id, data, compat,
23794 + perm, args, flags);
23801 + if (!capable(CAP_CONTEXT))
23805 + /* moved here from the individual commands */
23807 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23811 + /* vcmd involves resource management */
23813 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23817 + /* various legacy exceptions */
23819 + /* will go away when spectator is a cap */
23820 + case VCMD_ctx_migrate_v0:
23821 + case VCMD_ctx_migrate:
23823 + current->xid = 1;
23829 + /* will go away when spectator is a cap */
23830 + case VCMD_net_migrate:
23832 + current->nid = 1;
23839 + /* vcmds are fine by default */
23842 + /* admin type vcmds require admin ... */
23843 + if (flags & VCF_ADMIN)
23844 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23846 + /* ... but setup type vcmds override that */
23847 + if (!permit && (flags & VCF_SETUP))
23848 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23856 + if (!id && (flags & VCF_ZIDOK))
23860 + if (args & VCA_VXI) {
23861 + vxi = lookup_vx_info(id);
23865 + if ((flags & VCF_ADMIN) &&
23866 + /* special case kill for shutdown */
23867 + (cmd != VCMD_ctx_kill) &&
23868 + /* can context be administrated? */
23869 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23875 + if (args & VCA_NXI) {
23876 + nxi = lookup_nx_info(id);
23880 + if ((flags & VCF_ADMIN) &&
23881 + /* can context be administrated? */
23882 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23889 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23892 + if ((args & VCA_NXI) && nxi)
23893 + put_nx_info(nxi);
23895 + if ((args & VCA_VXI) && vxi)
23896 + put_vx_info(vxi);
23898 + vxdprintk(VXD_CBIT(switch, 1),
23899 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23900 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23901 + VC_VERSION(cmd), ret, ret, state, permit);
23906 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23908 + return do_vserver(cmd, id, data, 0);
23911 +#ifdef CONFIG_COMPAT
23914 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23916 + return do_vserver(cmd, id, data, 1);
23919 +#endif /* CONFIG_COMPAT */
23920 diff -NurpP --minimal linux-2.6.37/kernel/vserver/sysctl.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/sysctl.c
23921 --- linux-2.6.37/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23922 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/sysctl.c 2010-11-23 02:09:41.000000000 +0100
23925 + * kernel/vserver/sysctl.c
23927 + * Virtual Context Support
23929 + * Copyright (C) 2004-2007 Herbert Pötzl
23931 + * V0.01 basic structure
23935 +#include <linux/module.h>
23936 +#include <linux/ctype.h>
23937 +#include <linux/sysctl.h>
23938 +#include <linux/parser.h>
23939 +#include <asm/uaccess.h>
23942 + CTL_DEBUG_ERROR = 0,
23943 + CTL_DEBUG_SWITCH = 1,
23958 +unsigned int vx_debug_switch = 0;
23959 +unsigned int vx_debug_xid = 0;
23960 +unsigned int vx_debug_nid = 0;
23961 +unsigned int vx_debug_tag = 0;
23962 +unsigned int vx_debug_net = 0;
23963 +unsigned int vx_debug_limit = 0;
23964 +unsigned int vx_debug_cres = 0;
23965 +unsigned int vx_debug_dlim = 0;
23966 +unsigned int vx_debug_quota = 0;
23967 +unsigned int vx_debug_cvirt = 0;
23968 +unsigned int vx_debug_space = 0;
23969 +unsigned int vx_debug_misc = 0;
23972 +static struct ctl_table_header *vserver_table_header;
23973 +static ctl_table vserver_root_table[];
23976 +void vserver_register_sysctl(void)
23978 + if (!vserver_table_header) {
23979 + vserver_table_header = register_sysctl_table(vserver_root_table);
23984 +void vserver_unregister_sysctl(void)
23986 + if (vserver_table_header) {
23987 + unregister_sysctl_table(vserver_table_header);
23988 + vserver_table_header = NULL;
23993 +static int proc_dodebug(ctl_table *table, int write,
23994 + void __user *buffer, size_t *lenp, loff_t *ppos)
23996 + char tmpbuf[20], *p, c;
23997 + unsigned int value;
23998 + size_t left, len;
24000 + if ((*ppos && !write) || !*lenp) {
24008 + if (!access_ok(VERIFY_READ, buffer, left))
24010 + p = (char *)buffer;
24011 + while (left && __get_user(c, p) >= 0 && isspace(c))
24016 + if (left > sizeof(tmpbuf) - 1)
24018 + if (copy_from_user(tmpbuf, p, left))
24020 + tmpbuf[left] = '\0';
24022 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
24023 + value = 10 * value + (*p - '0');
24024 + if (*p && !isspace(*p))
24026 + while (left && isspace(*p))
24028 + *(unsigned int *)table->data = value;
24030 + if (!access_ok(VERIFY_WRITE, buffer, left))
24032 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
24035 + if (__copy_to_user(buffer, tmpbuf, len))
24037 + if ((left -= len) > 0) {
24038 + if (put_user('\n', (char *)buffer + len))
24052 +#define CTL_ENTRY(ctl, name) \
24054 + .procname = #name, \
24055 + .data = &vx_ ## name, \
24056 + .maxlen = sizeof(int), \
24058 + .proc_handler = &proc_dodebug, \
24059 + .extra1 = &zero, \
24060 + .extra2 = &zero, \
24063 +static ctl_table vserver_debug_table[] = {
24064 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
24065 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
24066 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
24067 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
24068 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
24069 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
24070 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
24071 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
24072 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
24073 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
24074 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
24075 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
24079 +static ctl_table vserver_root_table[] = {
24081 + .procname = "vserver",
24083 + .child = vserver_debug_table
24089 +static match_table_t tokens = {
24090 + { CTL_DEBUG_SWITCH, "switch=%x" },
24091 + { CTL_DEBUG_XID, "xid=%x" },
24092 + { CTL_DEBUG_NID, "nid=%x" },
24093 + { CTL_DEBUG_TAG, "tag=%x" },
24094 + { CTL_DEBUG_NET, "net=%x" },
24095 + { CTL_DEBUG_LIMIT, "limit=%x" },
24096 + { CTL_DEBUG_CRES, "cres=%x" },
24097 + { CTL_DEBUG_DLIM, "dlim=%x" },
24098 + { CTL_DEBUG_QUOTA, "quota=%x" },
24099 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
24100 + { CTL_DEBUG_SPACE, "space=%x" },
24101 + { CTL_DEBUG_MISC, "misc=%x" },
24102 + { CTL_DEBUG_ERROR, NULL }
24105 +#define HANDLE_CASE(id, name, val) \
24106 + case CTL_DEBUG_ ## id: \
24107 + vx_debug_ ## name = val; \
24108 + printk("vs_debug_" #name "=0x%x\n", val); \
24112 +static int __init vs_debug_setup(char *str)
24117 + printk("vs_debug_setup(%s)\n", str);
24118 + while ((p = strsep(&str, ",")) != NULL) {
24119 + substring_t args[MAX_OPT_ARGS];
24120 + unsigned int value;
24125 + token = match_token(p, tokens, args);
24126 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
24129 + HANDLE_CASE(SWITCH, switch, value);
24130 + HANDLE_CASE(XID, xid, value);
24131 + HANDLE_CASE(NID, nid, value);
24132 + HANDLE_CASE(TAG, tag, value);
24133 + HANDLE_CASE(NET, net, value);
24134 + HANDLE_CASE(LIMIT, limit, value);
24135 + HANDLE_CASE(CRES, cres, value);
24136 + HANDLE_CASE(DLIM, dlim, value);
24137 + HANDLE_CASE(QUOTA, quota, value);
24138 + HANDLE_CASE(CVIRT, cvirt, value);
24139 + HANDLE_CASE(SPACE, space, value);
24140 + HANDLE_CASE(MISC, misc, value);
24149 +__setup("vsdebug=", vs_debug_setup);
24153 +EXPORT_SYMBOL_GPL(vx_debug_switch);
24154 +EXPORT_SYMBOL_GPL(vx_debug_xid);
24155 +EXPORT_SYMBOL_GPL(vx_debug_nid);
24156 +EXPORT_SYMBOL_GPL(vx_debug_net);
24157 +EXPORT_SYMBOL_GPL(vx_debug_limit);
24158 +EXPORT_SYMBOL_GPL(vx_debug_cres);
24159 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
24160 +EXPORT_SYMBOL_GPL(vx_debug_quota);
24161 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
24162 +EXPORT_SYMBOL_GPL(vx_debug_space);
24163 +EXPORT_SYMBOL_GPL(vx_debug_misc);
24165 diff -NurpP --minimal linux-2.6.37/kernel/vserver/tag.c linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/tag.c
24166 --- linux-2.6.37/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
24167 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/tag.c 2010-11-23 02:09:41.000000000 +0100
24170 + * linux/kernel/vserver/tag.c
24172 + * Virtual Server: Shallow Tag Space
24174 + * Copyright (C) 2007 Herbert Pötzl
24176 + * V0.01 basic implementation
24180 +#include <linux/sched.h>
24181 +#include <linux/vserver/debug.h>
24182 +#include <linux/vs_pid.h>
24183 +#include <linux/vs_tag.h>
24185 +#include <linux/vserver/tag_cmd.h>
24188 +int dx_migrate_task(struct task_struct *p, tag_t tag)
24193 + vxdprintk(VXD_CBIT(tag, 5),
24194 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
24200 + vxdprintk(VXD_CBIT(tag, 5),
24201 + "moved task %p into [#%d]", p, tag);
24205 +/* vserver syscall commands below here */
24207 +/* taks xid and vx_info functions */
24210 +int vc_task_tag(uint32_t id)
24215 + struct task_struct *tsk;
24216 + read_lock(&tasklist_lock);
24217 + tsk = find_task_by_real_pid(id);
24218 + tag = (tsk) ? tsk->tag : -ESRCH;
24219 + read_unlock(&tasklist_lock);
24221 + tag = dx_current_tag();
24226 +int vc_tag_migrate(uint32_t tag)
24228 + return dx_migrate_task(current, tag & 0xFFFF);
24232 diff -NurpP --minimal linux-2.6.37/kernel/vserver/vci_config.h linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/vci_config.h
24233 --- linux-2.6.37/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
24234 +++ linux-2.6.37-vs2.3.0.37-rc3/kernel/vserver/vci_config.h 2010-11-23 02:09:41.000000000 +0100
24237 +/* interface version */
24239 +#define VCI_VERSION 0x00020307
24243 + VCI_KCBIT_NO_DYNAMIC = 0,
24245 + VCI_KCBIT_PROC_SECURE = 4,
24246 + VCI_KCBIT_HARDCPU = 5,
24247 + VCI_KCBIT_IDLELIMIT = 6,
24248 + VCI_KCBIT_IDLETIME = 7,
24250 + VCI_KCBIT_COWBL = 8,
24251 + VCI_KCBIT_FULLCOWBL = 9,
24252 + VCI_KCBIT_SPACES = 10,
24253 + VCI_KCBIT_NETV2 = 11,
24254 + VCI_KCBIT_MEMCG = 12,
24256 + VCI_KCBIT_DEBUG = 16,
24257 + VCI_KCBIT_HISTORY = 20,
24258 + VCI_KCBIT_TAGGED = 24,
24259 + VCI_KCBIT_PPTAG = 28,
24261 + VCI_KCBIT_MORE = 31,
24265 +static inline uint32_t vci_kernel_config(void)
24268 + (1 << VCI_KCBIT_NO_DYNAMIC) |
24270 + /* configured features */
24271 +#ifdef CONFIG_VSERVER_PROC_SECURE
24272 + (1 << VCI_KCBIT_PROC_SECURE) |
24274 +#ifdef CONFIG_VSERVER_IDLELIMIT
24275 + (1 << VCI_KCBIT_IDLELIMIT) |
24277 +#ifdef CONFIG_VSERVER_IDLETIME
24278 + (1 << VCI_KCBIT_IDLETIME) |
24280 +#ifdef CONFIG_VSERVER_COWBL
24281 + (1 << VCI_KCBIT_COWBL) |
24282 + (1 << VCI_KCBIT_FULLCOWBL) |
24284 + (1 << VCI_KCBIT_SPACES) |
24285 + (1 << VCI_KCBIT_NETV2) |
24286 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
24287 + (1 << VCI_KCBIT_MEMCG) |
24290 + /* debug options */
24291 +#ifdef CONFIG_VSERVER_DEBUG
24292 + (1 << VCI_KCBIT_DEBUG) |
24294 +#ifdef CONFIG_VSERVER_HISTORY
24295 + (1 << VCI_KCBIT_HISTORY) |
24298 + /* inode context tagging */
24299 +#if defined(CONFIG_TAGGING_NONE)
24300 + (0 << VCI_KCBIT_TAGGED) |
24301 +#elif defined(CONFIG_TAGGING_UID16)
24302 + (1 << VCI_KCBIT_TAGGED) |
24303 +#elif defined(CONFIG_TAGGING_GID16)
24304 + (2 << VCI_KCBIT_TAGGED) |
24305 +#elif defined(CONFIG_TAGGING_ID24)
24306 + (3 << VCI_KCBIT_TAGGED) |
24307 +#elif defined(CONFIG_TAGGING_INTERN)
24308 + (4 << VCI_KCBIT_TAGGED) |
24309 +#elif defined(CONFIG_TAGGING_RUNTIME)
24310 + (5 << VCI_KCBIT_TAGGED) |
24312 + (7 << VCI_KCBIT_TAGGED) |
24314 + (1 << VCI_KCBIT_PPTAG) |
24318 diff -NurpP --minimal linux-2.6.37/mm/filemap_xip.c linux-2.6.37-vs2.3.0.37-rc3/mm/filemap_xip.c
24319 --- linux-2.6.37/mm/filemap_xip.c 2010-07-07 18:31:58.000000000 +0200
24320 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/filemap_xip.c 2010-11-23 02:09:41.000000000 +0100
24322 #include <linux/seqlock.h>
24323 #include <linux/mutex.h>
24324 #include <linux/gfp.h>
24325 +#include <linux/vs_memory.h>
24326 #include <asm/tlbflush.h>
24327 #include <asm/io.h>
24329 diff -NurpP --minimal linux-2.6.37/mm/fremap.c linux-2.6.37-vs2.3.0.37-rc3/mm/fremap.c
24330 --- linux-2.6.37/mm/fremap.c 2010-10-21 13:07:57.000000000 +0200
24331 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/fremap.c 2010-11-23 02:09:41.000000000 +0100
24333 #include <linux/module.h>
24334 #include <linux/syscalls.h>
24335 #include <linux/mmu_notifier.h>
24336 +#include <linux/vs_memory.h>
24338 #include <asm/mmu_context.h>
24339 #include <asm/cacheflush.h>
24340 diff -NurpP --minimal linux-2.6.37/mm/hugetlb.c linux-2.6.37-vs2.3.0.37-rc3/mm/hugetlb.c
24341 --- linux-2.6.37/mm/hugetlb.c 2011-01-05 21:50:39.000000000 +0100
24342 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/hugetlb.c 2011-01-05 22:30:43.000000000 +0100
24345 #include <linux/hugetlb.h>
24346 #include <linux/node.h>
24347 +#include <linux/vs_memory.h>
24348 #include "internal.h"
24350 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
24351 diff -NurpP --minimal linux-2.6.37/mm/memcontrol.c linux-2.6.37-vs2.3.0.37-rc3/mm/memcontrol.c
24352 --- linux-2.6.37/mm/memcontrol.c 2011-01-05 21:50:40.000000000 +0100
24353 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/memcontrol.c 2011-01-05 22:30:43.000000000 +0100
24354 @@ -681,6 +681,31 @@ struct mem_cgroup *mem_cgroup_from_task(
24355 struct mem_cgroup, css);
24358 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
24360 + return res_counter_read_u64(&mem->res, member);
24363 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
24365 + return res_counter_read_u64(&mem->memsw, member);
24368 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
24370 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
24373 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
24375 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
24378 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
24380 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
24383 static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
24385 struct mem_cgroup *mem = NULL;
24386 diff -NurpP --minimal linux-2.6.37/mm/memory.c linux-2.6.37-vs2.3.0.37-rc3/mm/memory.c
24387 --- linux-2.6.37/mm/memory.c 2011-01-05 21:50:40.000000000 +0100
24388 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/memory.c 2010-11-23 02:09:41.000000000 +0100
24389 @@ -3153,6 +3153,7 @@ static inline int handle_pte_fault(struc
24393 + int ret = 0, type = VXPT_UNKNOWN;
24396 if (!pte_present(entry)) {
24397 @@ -3177,9 +3178,12 @@ static inline int handle_pte_fault(struc
24398 if (unlikely(!pte_same(*pte, entry)))
24400 if (flags & FAULT_FLAG_WRITE) {
24401 - if (!pte_write(entry))
24402 - return do_wp_page(mm, vma, address,
24403 + if (!pte_write(entry)) {
24404 + ret = do_wp_page(mm, vma, address,
24405 pte, pmd, ptl, entry);
24406 + type = VXPT_WRITE;
24409 entry = pte_mkdirty(entry);
24411 entry = pte_mkyoung(entry);
24412 @@ -3197,7 +3201,10 @@ static inline int handle_pte_fault(struc
24415 pte_unmap_unlock(pte, ptl);
24419 + vx_page_fault(mm, vma, type, ret);
24424 diff -NurpP --minimal linux-2.6.37/mm/mremap.c linux-2.6.37-vs2.3.0.37-rc3/mm/mremap.c
24425 --- linux-2.6.37/mm/mremap.c 2011-01-05 21:50:40.000000000 +0100
24426 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/mremap.c 2010-11-23 02:09:41.000000000 +0100
24428 #include <linux/security.h>
24429 #include <linux/syscalls.h>
24430 #include <linux/mmu_notifier.h>
24431 +#include <linux/vs_memory.h>
24433 #include <asm/uaccess.h>
24434 #include <asm/cacheflush.h>
24435 diff -NurpP --minimal linux-2.6.37/mm/oom_kill.c linux-2.6.37-vs2.3.0.37-rc3/mm/oom_kill.c
24436 --- linux-2.6.37/mm/oom_kill.c 2011-01-05 21:50:40.000000000 +0100
24437 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/oom_kill.c 2010-11-23 02:09:41.000000000 +0100
24439 #include <linux/memcontrol.h>
24440 #include <linux/mempolicy.h>
24441 #include <linux/security.h>
24442 +#include <linux/reboot.h>
24443 +#include <linux/vs_memory.h>
24444 +#include <linux/vs_context.h>
24446 int sysctl_panic_on_oom;
24447 int sysctl_oom_kill_allocating_task;
24448 @@ -124,11 +127,18 @@ struct task_struct *find_lock_task_mm(st
24449 static bool oom_unkillable_task(struct task_struct *p,
24450 const struct mem_cgroup *mem, const nodemask_t *nodemask)
24452 - if (is_global_init(p))
24453 + unsigned xid = vx_current_xid();
24455 + /* skip the init task, global and per guest */
24456 + if (task_is_init(p))
24458 if (p->flags & PF_KTHREAD)
24461 + /* skip other guest and host processes if oom in guest */
24462 + if (xid && vx_task_xid(p) != xid)
24465 /* When mem_cgroup_out_of_memory() and p is not member of the group */
24466 if (mem && !task_in_mem_cgroup(p, mem))
24468 @@ -210,6 +220,18 @@ unsigned int oom_badness(struct task_str
24469 points += p->signal->oom_score_adj;
24472 + * add points for context badness and
24473 + * reduce badness for processes belonging to
24474 + * a different context
24477 + points += vx_badness(p, p->mm);
24479 + if ((vx_current_xid() > 1) &&
24480 + vx_current_xid() != vx_task_xid(p))
24484 * Never return 0 for an eligible task that may be killed since it's
24485 * possible that no single user task uses more than 0.1% of memory and
24486 * no single admin tasks uses more than 3.0%.
24487 @@ -414,8 +436,8 @@ static int oom_kill_task(struct task_str
24488 /* mm cannot be safely dereferenced after task_unlock(p) */
24491 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24492 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
24493 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24494 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
24495 K(get_mm_counter(p->mm, MM_ANONPAGES)),
24496 K(get_mm_counter(p->mm, MM_FILEPAGES)));
24498 @@ -477,8 +499,8 @@ static int oom_kill_process(struct task_
24502 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
24503 - message, task_pid_nr(p), p->comm, points);
24504 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
24505 + message, task_pid_nr(p), p->xid, p->comm, points);
24509 @@ -567,6 +589,8 @@ int unregister_oom_notifier(struct notif
24511 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
24513 +long vs_oom_action(unsigned int);
24516 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
24517 * if a parallel OOM killing is already taking place that includes a zone in
24518 @@ -726,7 +750,12 @@ retry:
24520 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
24521 read_unlock(&tasklist_lock);
24522 - panic("Out of memory and no killable processes...\n");
24524 + /* avoid panic for guest OOM */
24525 + if (current->xid)
24526 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
24528 + panic("Out of memory and no killable processes...\n");
24531 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
24532 diff -NurpP --minimal linux-2.6.37/mm/page_alloc.c linux-2.6.37-vs2.3.0.37-rc3/mm/page_alloc.c
24533 --- linux-2.6.37/mm/page_alloc.c 2011-01-05 21:50:40.000000000 +0100
24534 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/page_alloc.c 2011-01-05 22:30:43.000000000 +0100
24536 #include <linux/compaction.h>
24537 #include <trace/events/kmem.h>
24538 #include <linux/ftrace_event.h>
24539 +#include <linux/vs_base.h>
24540 +#include <linux/vs_limit.h>
24542 #include <asm/tlbflush.h>
24543 #include <asm/div64.h>
24544 @@ -2335,6 +2337,9 @@ void si_meminfo(struct sysinfo *val)
24545 val->totalhigh = totalhigh_pages;
24546 val->freehigh = nr_free_highpages();
24547 val->mem_unit = PAGE_SIZE;
24549 + if (vx_flags(VXF_VIRT_MEM, 0))
24550 + vx_vsi_meminfo(val);
24553 EXPORT_SYMBOL(si_meminfo);
24554 @@ -2355,6 +2360,9 @@ void si_meminfo_node(struct sysinfo *val
24557 val->mem_unit = PAGE_SIZE;
24559 + if (vx_flags(VXF_VIRT_MEM, 0))
24560 + vx_vsi_meminfo(val);
24564 diff -NurpP --minimal linux-2.6.37/mm/rmap.c linux-2.6.37-vs2.3.0.37-rc3/mm/rmap.c
24565 --- linux-2.6.37/mm/rmap.c 2011-01-05 21:50:40.000000000 +0100
24566 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/rmap.c 2010-11-23 02:09:41.000000000 +0100
24568 #include <linux/mmu_notifier.h>
24569 #include <linux/migrate.h>
24570 #include <linux/hugetlb.h>
24571 +#include <linux/vs_memory.h>
24573 #include <asm/tlbflush.h>
24575 diff -NurpP --minimal linux-2.6.37/mm/shmem.c linux-2.6.37-vs2.3.0.37-rc3/mm/shmem.c
24576 --- linux-2.6.37/mm/shmem.c 2011-01-05 21:50:40.000000000 +0100
24577 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/shmem.c 2010-11-23 02:09:41.000000000 +0100
24578 @@ -1816,7 +1816,7 @@ static int shmem_statfs(struct dentry *d
24580 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24582 - buf->f_type = TMPFS_MAGIC;
24583 + buf->f_type = TMPFS_SUPER_MAGIC;
24584 buf->f_bsize = PAGE_CACHE_SIZE;
24585 buf->f_namelen = NAME_MAX;
24586 if (sbinfo->max_blocks) {
24587 @@ -2378,7 +2378,7 @@ int shmem_fill_super(struct super_block
24588 sb->s_maxbytes = SHMEM_MAX_BYTES;
24589 sb->s_blocksize = PAGE_CACHE_SIZE;
24590 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24591 - sb->s_magic = TMPFS_MAGIC;
24592 + sb->s_magic = TMPFS_SUPER_MAGIC;
24593 sb->s_op = &shmem_ops;
24594 sb->s_time_gran = 1;
24595 #ifdef CONFIG_TMPFS_POSIX_ACL
24596 diff -NurpP --minimal linux-2.6.37/mm/slab.c linux-2.6.37-vs2.3.0.37-rc3/mm/slab.c
24597 --- linux-2.6.37/mm/slab.c 2011-01-05 21:50:40.000000000 +0100
24598 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/slab.c 2010-11-23 02:09:41.000000000 +0100
24599 @@ -407,6 +407,8 @@ static void kmem_list3_init(struct kmem_
24600 #define STATS_INC_FREEMISS(x) do { } while (0)
24603 +#include "slab_vs.h"
24608 @@ -3346,6 +3348,7 @@ retry:
24610 obj = slab_get_obj(cachep, slabp, nodeid);
24611 check_slabp(cachep, slabp);
24612 + vx_slab_alloc(cachep, flags);
24613 l3->free_objects--;
24614 /* move slabp to correct slabp list: */
24615 list_del(&slabp->list);
24616 @@ -3423,6 +3426,7 @@ __cache_alloc_node(struct kmem_cache *ca
24617 /* ___cache_alloc_node can fall back to other nodes */
24618 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24620 + vx_slab_alloc(cachep, flags);
24621 local_irq_restore(save_flags);
24622 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24623 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24624 @@ -3609,6 +3613,7 @@ static inline void __cache_free(struct k
24626 kmemleak_free_recursive(objp, cachep->flags);
24627 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
24628 + vx_slab_free(cachep);
24630 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24632 diff -NurpP --minimal linux-2.6.37/mm/slab_vs.h linux-2.6.37-vs2.3.0.37-rc3/mm/slab_vs.h
24633 --- linux-2.6.37/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24634 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/slab_vs.h 2010-11-23 02:09:41.000000000 +0100
24637 +#include <linux/vserver/context.h>
24639 +#include <linux/vs_context.h>
24642 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24644 + int what = gfp_zone(cachep->gfpflags);
24645 + struct vx_info *vxi = current_vx_info();
24650 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24654 +void vx_slab_free(struct kmem_cache *cachep)
24656 + int what = gfp_zone(cachep->gfpflags);
24657 + struct vx_info *vxi = current_vx_info();
24662 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24665 diff -NurpP --minimal linux-2.6.37/mm/swapfile.c linux-2.6.37-vs2.3.0.37-rc3/mm/swapfile.c
24666 --- linux-2.6.37/mm/swapfile.c 2011-01-05 21:50:40.000000000 +0100
24667 +++ linux-2.6.37-vs2.3.0.37-rc3/mm/swapfile.c 2010-11-23 02:09:41.000000000 +0100
24669 #include <asm/tlbflush.h>
24670 #include <linux/swapops.h>
24671 #include <linux/page_cgroup.h>
24672 +#include <linux/vs_base.h>
24673 +#include <linux/vs_memory.h>
24675 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24677 @@ -1773,6 +1775,16 @@ static int swap_show(struct seq_file *sw
24679 if (si == SEQ_START_TOKEN) {
24680 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24681 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24682 + struct sysinfo si;
24684 + vx_vsi_swapinfo(&si);
24685 + if (si.totalswap < (1 << 10))
24687 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24688 + "hdv0", "partition", si.totalswap >> 10,
24689 + (si.totalswap - si.freeswap) >> 10, -1);
24694 @@ -2178,6 +2190,8 @@ void si_swapinfo(struct sysinfo *val)
24695 val->freeswap = nr_swap_pages + nr_to_be_unused;
24696 val->totalswap = total_swap_pages + nr_to_be_unused;
24697 spin_unlock(&swap_lock);
24698 + if (vx_flags(VXF_VIRT_MEM, 0))
24699 + vx_vsi_swapinfo(val);
24703 diff -NurpP --minimal linux-2.6.37/net/core/dev.c linux-2.6.37-vs2.3.0.37-rc3/net/core/dev.c
24704 --- linux-2.6.37/net/core/dev.c 2011-01-05 21:50:41.000000000 +0100
24705 +++ linux-2.6.37-vs2.3.0.37-rc3/net/core/dev.c 2010-11-23 02:09:41.000000000 +0100
24706 @@ -127,6 +127,7 @@
24707 #include <linux/in.h>
24708 #include <linux/jhash.h>
24709 #include <linux/random.h>
24710 +#include <linux/vs_inet.h>
24711 #include <trace/events/napi.h>
24712 #include <trace/events/net.h>
24713 #include <trace/events/skb.h>
24714 @@ -608,7 +609,8 @@ struct net_device *__dev_get_by_name(str
24715 struct hlist_head *head = dev_name_hash(net, name);
24717 hlist_for_each_entry(dev, p, head, name_hlist)
24718 - if (!strncmp(dev->name, name, IFNAMSIZ))
24719 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24720 + nx_dev_visible(current_nx_info(), dev))
24724 @@ -634,7 +636,8 @@ struct net_device *dev_get_by_name_rcu(s
24725 struct hlist_head *head = dev_name_hash(net, name);
24727 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24728 - if (!strncmp(dev->name, name, IFNAMSIZ))
24729 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24730 + nx_dev_visible(current_nx_info(), dev))
24734 @@ -685,7 +688,8 @@ struct net_device *__dev_get_by_index(st
24735 struct hlist_head *head = dev_index_hash(net, ifindex);
24737 hlist_for_each_entry(dev, p, head, index_hlist)
24738 - if (dev->ifindex == ifindex)
24739 + if ((dev->ifindex == ifindex) &&
24740 + nx_dev_visible(current_nx_info(), dev))
24744 @@ -710,7 +714,8 @@ struct net_device *dev_get_by_index_rcu(
24745 struct hlist_head *head = dev_index_hash(net, ifindex);
24747 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
24748 - if (dev->ifindex == ifindex)
24749 + if ((dev->ifindex == ifindex) &&
24750 + nx_dev_visible(current_nx_info(), dev))
24754 @@ -763,10 +768,12 @@ struct net_device *dev_getbyhwaddr(struc
24758 - for_each_netdev(net, dev)
24759 + for_each_netdev(net, dev) {
24760 if (dev->type == type &&
24761 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24762 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24763 + nx_dev_visible(current_nx_info(), dev))
24769 @@ -777,9 +784,11 @@ struct net_device *__dev_getfirstbyhwtyp
24770 struct net_device *dev;
24773 - for_each_netdev(net, dev)
24774 - if (dev->type == type)
24775 + for_each_netdev(net, dev) {
24776 + if ((dev->type == type) &&
24777 + nx_dev_visible(current_nx_info(), dev))
24783 @@ -897,6 +906,8 @@ static int __dev_alloc_name(struct net *
24785 if (i < 0 || i >= max_netdevices)
24787 + if (!nx_dev_visible(current_nx_info(), d))
24790 /* avoid cases where sscanf is not exact inverse of printf */
24791 snprintf(buf, IFNAMSIZ, name, i);
24792 @@ -3746,6 +3757,8 @@ static int dev_ifconf(struct net *net, c
24795 for_each_netdev(net, dev) {
24796 + if (!nx_dev_visible(current_nx_info(), dev))
24798 for (i = 0; i < NPROTO; i++) {
24799 if (gifconf_list[i]) {
24801 @@ -3817,6 +3830,10 @@ static void dev_seq_printf_stats(struct
24802 struct rtnl_link_stats64 temp;
24803 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24805 + /* device visible inside network context? */
24806 + if (!nx_dev_visible(current_nx_info(), dev))
24809 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24810 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24811 dev->name, stats->rx_bytes, stats->rx_packets,
24812 diff -NurpP --minimal linux-2.6.37/net/core/rtnetlink.c linux-2.6.37-vs2.3.0.37-rc3/net/core/rtnetlink.c
24813 --- linux-2.6.37/net/core/rtnetlink.c 2011-01-05 21:50:41.000000000 +0100
24814 +++ linux-2.6.37-vs2.3.0.37-rc3/net/core/rtnetlink.c 2010-11-23 02:09:41.000000000 +0100
24815 @@ -891,6 +891,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24816 hlist_for_each_entry(dev, node, head, index_hlist) {
24819 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24821 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24822 NETLINK_CB(cb->skb).pid,
24823 cb->nlh->nlmsg_seq, 0,
24824 @@ -1607,6 +1609,9 @@ void rtmsg_ifinfo(int type, struct net_d
24825 struct sk_buff *skb;
24826 int err = -ENOBUFS;
24828 + if (!nx_dev_visible(current_nx_info(), dev))
24831 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
24834 diff -NurpP --minimal linux-2.6.37/net/core/sock.c linux-2.6.37-vs2.3.0.37-rc3/net/core/sock.c
24835 --- linux-2.6.37/net/core/sock.c 2011-01-05 21:50:41.000000000 +0100
24836 +++ linux-2.6.37-vs2.3.0.37-rc3/net/core/sock.c 2011-01-05 22:30:43.000000000 +0100
24837 @@ -127,6 +127,10 @@
24838 #include <net/cls_cgroup.h>
24840 #include <linux/filter.h>
24841 +#include <linux/vs_socket.h>
24842 +#include <linux/vs_limit.h>
24843 +#include <linux/vs_context.h>
24844 +#include <linux/vs_network.h>
24847 #include <net/tcp.h>
24848 @@ -1069,6 +1073,8 @@ static struct sock *sk_prot_alloc(struct
24850 sk_tx_queue_clear(sk);
24852 + sock_vx_init(sk);
24853 + sock_nx_init(sk);
24857 @@ -1168,6 +1174,11 @@ static void __sk_free(struct sock *sk)
24858 put_cred(sk->sk_peer_cred);
24859 put_pid(sk->sk_peer_pid);
24860 put_net(sock_net(sk));
24862 + clr_vx_info(&sk->sk_vx_info);
24864 + clr_nx_info(&sk->sk_nx_info);
24866 sk_prot_free(sk->sk_prot_creator, sk);
24869 @@ -1215,6 +1226,8 @@ struct sock *sk_clone(const struct sock
24872 get_net(sock_net(newsk));
24873 + sock_vx_init(newsk);
24874 + sock_nx_init(newsk);
24875 sk_node_init(&newsk->sk_node);
24876 sock_lock_init(newsk);
24877 bh_lock_sock(newsk);
24878 @@ -1270,6 +1283,12 @@ struct sock *sk_clone(const struct sock
24880 atomic_set(&newsk->sk_refcnt, 2);
24882 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24883 + newsk->sk_xid = sk->sk_xid;
24884 + vx_sock_inc(newsk);
24885 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24886 + newsk->sk_nid = sk->sk_nid;
24889 * Increment the counter in the same struct proto as the master
24890 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24891 @@ -2016,6 +2035,12 @@ void sock_init_data(struct socket *sock,
24893 sk->sk_stamp = ktime_set(-1L, 0);
24895 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24896 + sk->sk_xid = vx_current_xid();
24898 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24899 + sk->sk_nid = nx_current_nid();
24902 * Before updating sk_refcnt, we must commit prior changes to memory
24903 * (Documentation/RCU/rculist_nulls.txt for details)
24904 diff -NurpP --minimal linux-2.6.37/net/ipv4/af_inet.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/af_inet.c
24905 --- linux-2.6.37/net/ipv4/af_inet.c 2011-01-05 21:50:41.000000000 +0100
24906 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/af_inet.c 2010-11-23 02:09:41.000000000 +0100
24907 @@ -116,6 +116,7 @@
24908 #ifdef CONFIG_IP_MROUTE
24909 #include <linux/mroute.h>
24911 +#include <linux/vs_limit.h>
24914 /* The inetsw table contains everything that inet_create needs to
24915 @@ -325,9 +326,13 @@ lookup_protocol:
24919 + if ((protocol == IPPROTO_ICMP) &&
24920 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24923 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24924 goto out_rcu_unlock;
24927 err = -EAFNOSUPPORT;
24928 if (!inet_netns_ok(net, protocol))
24929 goto out_rcu_unlock;
24930 @@ -451,6 +456,7 @@ int inet_bind(struct socket *sock, struc
24931 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24932 struct sock *sk = sock->sk;
24933 struct inet_sock *inet = inet_sk(sk);
24934 + struct nx_v4_sock_addr nsa;
24935 unsigned short snum;
24938 @@ -464,7 +470,11 @@ int inet_bind(struct socket *sock, struc
24939 if (addr_len < sizeof(struct sockaddr_in))
24942 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24943 + err = v4_map_sock_addr(inet, addr, &nsa);
24947 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24949 /* Not specified by any standard per-se, however it breaks too
24950 * many applications when removed. It is unfortunate since
24951 @@ -476,7 +486,7 @@ int inet_bind(struct socket *sock, struc
24952 err = -EADDRNOTAVAIL;
24953 if (!sysctl_ip_nonlocal_bind &&
24954 !(inet->freebind || inet->transparent) &&
24955 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24956 + nsa.saddr != htonl(INADDR_ANY) &&
24957 chk_addr_ret != RTN_LOCAL &&
24958 chk_addr_ret != RTN_MULTICAST &&
24959 chk_addr_ret != RTN_BROADCAST)
24960 @@ -501,7 +511,7 @@ int inet_bind(struct socket *sock, struc
24961 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24962 goto out_release_sock;
24964 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24965 + v4_set_sock_addr(inet, &nsa);
24966 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24967 inet->inet_saddr = 0; /* Use device */
24969 @@ -703,11 +713,13 @@ int inet_getname(struct socket *sock, st
24972 sin->sin_port = inet->inet_dport;
24973 - sin->sin_addr.s_addr = inet->inet_daddr;
24974 + sin->sin_addr.s_addr =
24975 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24977 __be32 addr = inet->inet_rcv_saddr;
24979 addr = inet->inet_saddr;
24980 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24981 sin->sin_port = inet->inet_sport;
24982 sin->sin_addr.s_addr = addr;
24984 diff -NurpP --minimal linux-2.6.37/net/ipv4/devinet.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/devinet.c
24985 --- linux-2.6.37/net/ipv4/devinet.c 2011-01-05 21:50:41.000000000 +0100
24986 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/devinet.c 2010-11-23 02:09:41.000000000 +0100
24987 @@ -420,6 +420,7 @@ struct in_device *inetdev_by_index(struc
24989 EXPORT_SYMBOL(inetdev_by_index);
24992 /* Called only from RTNL semaphored context. No locks. */
24994 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24995 @@ -660,6 +661,8 @@ int devinet_ioctl(struct net *net, unsig
24997 in_dev = __in_dev_get_rtnl(dev);
24999 + struct nx_info *nxi = current_nx_info();
25001 if (tryaddrmatch) {
25002 /* Matthias Andree */
25003 /* compare label and address (4.4BSD style) */
25004 @@ -668,6 +671,8 @@ int devinet_ioctl(struct net *net, unsig
25005 This is checked above. */
25006 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
25007 ifap = &ifa->ifa_next) {
25008 + if (!nx_v4_ifa_visible(nxi, ifa))
25010 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
25011 sin_orig.sin_addr.s_addr ==
25012 ifa->ifa_address) {
25013 @@ -680,9 +685,12 @@ int devinet_ioctl(struct net *net, unsig
25014 comparing just the label */
25016 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
25017 - ifap = &ifa->ifa_next)
25018 + ifap = &ifa->ifa_next) {
25019 + if (!nx_v4_ifa_visible(nxi, ifa))
25021 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
25027 @@ -834,6 +842,8 @@ static int inet_gifconf(struct net_devic
25030 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
25031 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
25034 done += sizeof(ifr);
25036 @@ -1183,6 +1193,7 @@ static int inet_dump_ifaddr(struct sk_bu
25037 struct net_device *dev;
25038 struct in_device *in_dev;
25039 struct in_ifaddr *ifa;
25040 + struct sock *sk = skb->sk;
25041 struct hlist_head *head;
25042 struct hlist_node *node;
25044 @@ -1205,6 +1216,8 @@ static int inet_dump_ifaddr(struct sk_bu
25046 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
25047 ifa = ifa->ifa_next, ip_idx++) {
25048 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
25050 if (ip_idx < s_ip_idx)
25052 if (inet_fill_ifaddr(skb, ifa,
25053 diff -NurpP --minimal linux-2.6.37/net/ipv4/fib_hash.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/fib_hash.c
25054 --- linux-2.6.37/net/ipv4/fib_hash.c 2011-01-05 21:50:41.000000000 +0100
25055 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/fib_hash.c 2010-11-23 02:09:41.000000000 +0100
25056 @@ -1080,7 +1080,7 @@ static int fib_seq_show(struct seq_file
25057 prefix = f->fn_key;
25058 mask = FZ_MASK(iter->zone);
25059 flags = fib_flag_trans(fa->fa_type, mask, fi);
25061 + if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
25063 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
25064 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
25065 diff -NurpP --minimal linux-2.6.37/net/ipv4/inet_connection_sock.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/inet_connection_sock.c
25066 --- linux-2.6.37/net/ipv4/inet_connection_sock.c 2010-10-21 13:07:58.000000000 +0200
25067 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/inet_connection_sock.c 2010-11-23 02:09:41.000000000 +0100
25068 @@ -52,10 +52,40 @@ void inet_get_local_port_range(int *low,
25070 EXPORT_SYMBOL(inet_get_local_port_range);
25072 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25074 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
25075 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
25077 + if (inet_v6_ipv6only(sk2))
25080 + if (sk1_rcv_saddr &&
25082 + sk1_rcv_saddr == sk2_rcv_saddr)
25085 + if (sk1_rcv_saddr &&
25086 + !sk2_rcv_saddr &&
25087 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
25090 + if (sk2_rcv_saddr &&
25091 + !sk1_rcv_saddr &&
25092 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
25095 + if (!sk1_rcv_saddr &&
25096 + !sk2_rcv_saddr &&
25097 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
25103 int inet_csk_bind_conflict(const struct sock *sk,
25104 const struct inet_bind_bucket *tb)
25106 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
25108 struct hlist_node *node;
25109 int reuse = sk->sk_reuse;
25110 @@ -75,9 +105,7 @@ int inet_csk_bind_conflict(const struct
25111 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
25112 if (!reuse || !sk2->sk_reuse ||
25113 sk2->sk_state == TCP_LISTEN) {
25114 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
25115 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
25116 - sk2_rcv_saddr == sk_rcv_saddr)
25117 + if (ipv4_rcv_saddr_equal(sk, sk2))
25121 diff -NurpP --minimal linux-2.6.37/net/ipv4/inet_diag.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/inet_diag.c
25122 --- linux-2.6.37/net/ipv4/inet_diag.c 2011-01-05 21:50:42.000000000 +0100
25123 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/inet_diag.c 2010-11-23 02:09:41.000000000 +0100
25125 #include <linux/stddef.h>
25127 #include <linux/inet_diag.h>
25128 +#include <linux/vs_network.h>
25129 +#include <linux/vs_inet.h>
25131 static const struct inet_diag_handler **inet_diag_table;
25133 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
25135 r->id.idiag_sport = inet->inet_sport;
25136 r->id.idiag_dport = inet->inet_dport;
25137 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
25138 - r->id.idiag_dst[0] = inet->inet_daddr;
25139 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
25140 + inet->inet_rcv_saddr);
25141 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
25142 + inet->inet_daddr);
25144 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25145 if (r->idiag_family == AF_INET6) {
25146 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
25147 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
25148 r->id.idiag_sport = tw->tw_sport;
25149 r->id.idiag_dport = tw->tw_dport;
25150 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
25151 - r->id.idiag_dst[0] = tw->tw_daddr;
25152 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
25153 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
25154 r->idiag_state = tw->tw_substate;
25155 r->idiag_timer = 3;
25156 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
25157 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
25160 if (req->idiag_family == AF_INET) {
25161 + /* TODO: lback */
25162 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
25163 req->id.idiag_dport, req->id.idiag_src[0],
25164 req->id.idiag_sport, req->id.idiag_if);
25165 @@ -507,6 +512,7 @@ static int inet_csk_diag_dump(struct soc
25169 + /* TODO: lback */
25170 entry.saddr = &inet->inet_rcv_saddr;
25171 entry.daddr = &inet->inet_daddr;
25173 @@ -545,6 +551,7 @@ static int inet_twsk_diag_dump(struct in
25177 + /* TODO: lback */
25178 entry.saddr = &tw->tw_rcv_saddr;
25179 entry.daddr = &tw->tw_daddr;
25181 @@ -591,8 +598,8 @@ static int inet_diag_fill_req(struct sk_
25183 r->id.idiag_sport = inet->inet_sport;
25184 r->id.idiag_dport = ireq->rmt_port;
25185 - r->id.idiag_src[0] = ireq->loc_addr;
25186 - r->id.idiag_dst[0] = ireq->rmt_addr;
25187 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
25188 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
25189 r->idiag_expires = jiffies_to_msecs(tmo);
25190 r->idiag_rqueue = 0;
25191 r->idiag_wqueue = 0;
25192 @@ -663,6 +670,7 @@ static int inet_diag_dump_reqs(struct sk
25196 + /* TODO: lback */
25198 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25199 (entry.family == AF_INET6) ?
25200 @@ -733,6 +741,8 @@ static int inet_diag_dump(struct sk_buff
25201 sk_nulls_for_each(sk, node, &ilb->head) {
25202 struct inet_sock *inet = inet_sk(sk);
25204 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25209 @@ -799,6 +809,8 @@ skip_listen_ht:
25210 sk_nulls_for_each(sk, node, &head->chain) {
25211 struct inet_sock *inet = inet_sk(sk);
25213 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25217 if (!(r->idiag_states & (1 << sk->sk_state)))
25218 @@ -823,6 +835,8 @@ next_normal:
25219 inet_twsk_for_each(tw, node,
25222 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25226 if (r->id.idiag_sport != tw->tw_sport &&
25227 diff -NurpP --minimal linux-2.6.37/net/ipv4/inet_hashtables.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/inet_hashtables.c
25228 --- linux-2.6.37/net/ipv4/inet_hashtables.c 2011-01-05 21:50:42.000000000 +0100
25229 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/inet_hashtables.c 2011-01-05 22:30:43.000000000 +0100
25232 #include <net/inet_connection_sock.h>
25233 #include <net/inet_hashtables.h>
25234 +#include <net/route.h>
25235 #include <net/ip.h>
25238 @@ -155,6 +156,11 @@ static inline int compute_score(struct s
25239 if (rcv_saddr != daddr)
25243 + /* block non nx_info ips */
25244 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25245 + daddr, NXA_MASK_BIND))
25248 if (sk->sk_bound_dev_if) {
25249 if (sk->sk_bound_dev_if != dif)
25250 @@ -172,7 +178,6 @@ static inline int compute_score(struct s
25251 * wildcarded during the search since they can never be otherwise.
25255 struct sock *__inet_lookup_listener(struct net *net,
25256 struct inet_hashinfo *hashinfo,
25257 const __be32 daddr, const unsigned short hnum,
25258 @@ -195,6 +200,7 @@ begin:
25264 * if the nulls value we got at the end of this lookup is
25265 * not the expected one, we must restart lookup.
25266 diff -NurpP --minimal linux-2.6.37/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/netfilter/nf_nat_helper.c
25267 --- linux-2.6.37/net/ipv4/netfilter/nf_nat_helper.c 2011-01-05 21:50:42.000000000 +0100
25268 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/netfilter/nf_nat_helper.c 2010-11-23 02:09:41.000000000 +0100
25270 #include <net/route.h>
25272 #include <linux/netfilter_ipv4.h>
25273 +#include <net/route.h>
25274 #include <net/netfilter/nf_conntrack.h>
25275 #include <net/netfilter/nf_conntrack_helper.h>
25276 #include <net/netfilter/nf_conntrack_ecache.h>
25277 diff -NurpP --minimal linux-2.6.37/net/ipv4/netfilter.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/netfilter.c
25278 --- linux-2.6.37/net/ipv4/netfilter.c 2010-10-21 13:07:58.000000000 +0200
25279 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/netfilter.c 2010-11-23 02:09:41.000000000 +0100
25281 #include <linux/ip.h>
25282 #include <linux/skbuff.h>
25283 #include <linux/gfp.h>
25284 -#include <net/route.h>
25285 +// #include <net/route.h>
25286 #include <net/xfrm.h>
25287 #include <net/ip.h>
25288 #include <net/netfilter/nf_queue.h>
25289 diff -NurpP --minimal linux-2.6.37/net/ipv4/raw.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/raw.c
25290 --- linux-2.6.37/net/ipv4/raw.c 2011-01-05 21:50:42.000000000 +0100
25291 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/raw.c 2010-11-23 02:09:41.000000000 +0100
25292 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
25294 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
25295 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
25296 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
25297 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
25298 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
25299 goto found; /* gotcha */
25301 @@ -383,6 +383,12 @@ static int raw_send_hdrinc(struct sock *
25302 icmp_out_count(net, ((struct icmphdr *)
25303 skb_transport_header(skb))->type);
25306 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
25307 + sk->sk_nx_info &&
25308 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
25311 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
25312 rt->dst.dev, dst_output);
25314 @@ -563,6 +569,13 @@ static int raw_sendmsg(struct kiocb *ioc
25317 security_sk_classify_flow(sk, &fl);
25318 + if (sk->sk_nx_info) {
25319 + err = ip_v4_find_src(sock_net(sk),
25320 + sk->sk_nx_info, &rt, &fl);
25325 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
25328 @@ -635,17 +648,19 @@ static int raw_bind(struct sock *sk, str
25330 struct inet_sock *inet = inet_sk(sk);
25331 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
25332 + struct nx_v4_sock_addr nsa = { 0 };
25336 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
25338 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25339 + v4_map_sock_addr(inet, addr, &nsa);
25340 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25341 ret = -EADDRNOTAVAIL;
25342 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
25343 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
25344 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
25346 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25347 + v4_set_sock_addr(inet, &nsa);
25348 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25349 inet->inet_saddr = 0; /* Use device */
25351 @@ -697,7 +712,8 @@ static int raw_recvmsg(struct kiocb *ioc
25352 /* Copy the address. */
25354 sin->sin_family = AF_INET;
25355 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25356 + sin->sin_addr.s_addr =
25357 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
25359 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
25361 @@ -875,7 +891,8 @@ static struct sock *raw_get_first(struct
25362 struct hlist_node *node;
25364 sk_for_each(sk, node, &state->h->ht[state->bucket])
25365 - if (sock_net(sk) == seq_file_net(seq))
25366 + if ((sock_net(sk) == seq_file_net(seq)) &&
25367 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25371 @@ -891,7 +908,8 @@ static struct sock *raw_get_next(struct
25375 - } while (sk && sock_net(sk) != seq_file_net(seq));
25376 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
25377 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25379 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
25380 sk = sk_head(&state->h->ht[state->bucket]);
25381 @@ -950,7 +968,10 @@ static void raw_sock_seq_show(struct seq
25383 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
25384 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
25385 - i, src, srcp, dest, destp, sp->sk_state,
25387 + nx_map_sock_lback(current_nx_info(), src), srcp,
25388 + nx_map_sock_lback(current_nx_info(), dest), destp,
25390 sk_wmem_alloc_get(sp),
25391 sk_rmem_alloc_get(sp),
25392 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
25393 diff -NurpP --minimal linux-2.6.37/net/ipv4/tcp.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/tcp.c
25394 --- linux-2.6.37/net/ipv4/tcp.c 2011-01-05 21:50:42.000000000 +0100
25395 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/tcp.c 2011-01-05 22:30:43.000000000 +0100
25396 @@ -266,6 +266,7 @@
25397 #include <linux/crypto.h>
25398 #include <linux/time.h>
25399 #include <linux/slab.h>
25400 +#include <linux/in.h>
25402 #include <net/icmp.h>
25403 #include <net/tcp.h>
25404 diff -NurpP --minimal linux-2.6.37/net/ipv4/tcp_ipv4.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/tcp_ipv4.c
25405 --- linux-2.6.37/net/ipv4/tcp_ipv4.c 2011-01-05 21:50:42.000000000 +0100
25406 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/tcp_ipv4.c 2011-01-05 22:33:32.000000000 +0100
25407 @@ -2018,6 +2018,12 @@ static void *listening_get_next(struct s
25408 req = req->dl_next;
25411 + vxdprintk(VXD_CBIT(net, 6),
25412 + "sk,req: %p [#%d] (from %d)", req->sk,
25413 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
25415 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
25417 if (req->rsk_ops->family == st->family) {
25420 @@ -2043,6 +2049,10 @@ get_req:
25423 sk_nulls_for_each_from(sk, node) {
25424 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
25425 + sk, sk->sk_nid, nx_current_nid());
25426 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25428 if (!net_eq(sock_net(sk), net))
25430 if (sk->sk_family == st->family) {
25431 @@ -2119,6 +2129,11 @@ static void *established_get_first(struc
25433 spin_lock_bh(lock);
25434 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
25435 + vxdprintk(VXD_CBIT(net, 6),
25436 + "sk,egf: %p [#%d] (from %d)",
25437 + sk, sk->sk_nid, nx_current_nid());
25438 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25440 if (sk->sk_family != st->family ||
25441 !net_eq(sock_net(sk), net)) {
25443 @@ -2129,6 +2144,11 @@ static void *established_get_first(struc
25444 st->state = TCP_SEQ_STATE_TIME_WAIT;
25445 inet_twsk_for_each(tw, node,
25446 &tcp_hashinfo.ehash[st->bucket].twchain) {
25447 + vxdprintk(VXD_CBIT(net, 6),
25448 + "tw: %p [#%d] (from %d)",
25449 + tw, tw->tw_nid, nx_current_nid());
25450 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25452 if (tw->tw_family != st->family ||
25453 !net_eq(twsk_net(tw), net)) {
25455 @@ -2158,7 +2178,9 @@ static void *established_get_next(struct
25459 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
25460 + while (tw && (tw->tw_family != st->family ||
25461 + !net_eq(twsk_net(tw), net) ||
25462 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
25466 @@ -2182,6 +2204,11 @@ get_tw:
25467 sk = sk_nulls_next(sk);
25469 sk_nulls_for_each_from(sk, node) {
25470 + vxdprintk(VXD_CBIT(net, 6),
25471 + "sk,egn: %p [#%d] (from %d)",
25472 + sk, sk->sk_nid, nx_current_nid());
25473 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25475 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
25478 @@ -2391,9 +2418,9 @@ static void get_openreq4(struct sock *sk
25479 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25480 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
25483 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
25484 ntohs(inet_sk(sk)->inet_sport),
25486 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
25487 ntohs(ireq->rmt_port),
25489 0, 0, /* could print option size, but that is af dependent. */
25490 @@ -2445,7 +2472,10 @@ static void get_tcp4_sock(struct sock *s
25492 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
25493 "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
25494 - i, src, srcp, dest, destp, sk->sk_state,
25496 + nx_map_sock_lback(current_nx_info(), src), srcp,
25497 + nx_map_sock_lback(current_nx_info(), dest), destp,
25499 tp->write_seq - tp->snd_una,
25502 @@ -2480,7 +2510,10 @@ static void get_timewait4_sock(struct in
25504 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25505 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
25506 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
25508 + nx_map_sock_lback(current_nx_info(), src), srcp,
25509 + nx_map_sock_lback(current_nx_info(), dest), destp,
25510 + tw->tw_substate, 0, 0,
25511 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
25512 atomic_read(&tw->tw_refcnt), tw, len);
25514 diff -NurpP --minimal linux-2.6.37/net/ipv4/tcp_minisocks.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/tcp_minisocks.c
25515 --- linux-2.6.37/net/ipv4/tcp_minisocks.c 2011-01-05 21:50:42.000000000 +0100
25516 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/tcp_minisocks.c 2011-01-05 22:30:43.000000000 +0100
25518 #include <linux/slab.h>
25519 #include <linux/sysctl.h>
25520 #include <linux/workqueue.h>
25521 +#include <linux/vs_limit.h>
25522 +#include <linux/vs_socket.h>
25523 +#include <linux/vs_context.h>
25524 #include <net/tcp.h>
25525 #include <net/inet_common.h>
25526 #include <net/xfrm.h>
25527 @@ -290,6 +293,11 @@ void tcp_time_wait(struct sock *sk, int
25528 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25529 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25531 + tw->tw_xid = sk->sk_xid;
25532 + tw->tw_vx_info = NULL;
25533 + tw->tw_nid = sk->sk_nid;
25534 + tw->tw_nx_info = NULL;
25536 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25537 if (tw->tw_family == PF_INET6) {
25538 struct ipv6_pinfo *np = inet6_sk(sk);
25539 diff -NurpP --minimal linux-2.6.37/net/ipv4/udp.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/udp.c
25540 --- linux-2.6.37/net/ipv4/udp.c 2011-01-05 21:50:42.000000000 +0100
25541 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv4/udp.c 2011-01-05 22:30:43.000000000 +0100
25542 @@ -296,14 +296,7 @@ fail:
25544 EXPORT_SYMBOL(udp_lib_get_port);
25546 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25548 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25550 - return (!ipv6_only_sock(sk2) &&
25551 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25552 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25554 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25556 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25558 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
25559 if (inet->inet_rcv_saddr != daddr)
25563 + /* block non nx_info ips */
25564 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25565 + daddr, NXA_MASK_BIND))
25568 if (inet->inet_daddr) {
25569 if (inet->inet_daddr != saddr)
25570 @@ -441,6 +439,7 @@ exact_match:
25575 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25576 * harder than this. -DaveM
25578 @@ -486,6 +485,11 @@ begin:
25579 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25580 score = compute_score(sk, net, saddr, hnum, sport,
25581 daddr, dport, dif);
25582 + /* FIXME: disabled?
25583 + if (score == 9) {
25587 if (score > badness) {
25590 @@ -499,6 +503,7 @@ begin:
25591 if (get_nulls_value(node) != slot)
25596 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
25598 @@ -508,6 +513,7 @@ begin:
25606 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
25607 udp_sk(s)->udp_port_hash != hnum ||
25608 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25609 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25610 - (inet->inet_rcv_saddr &&
25611 - inet->inet_rcv_saddr != loc_addr) ||
25612 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25613 ipv6_only_sock(s) ||
25614 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25616 @@ -900,8 +905,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
25617 { .sport = inet->inet_sport,
25618 .dport = dport } } };
25619 struct net *net = sock_net(sk);
25620 + struct nx_info *nxi = sk->sk_nx_info;
25622 security_sk_classify_flow(sk, &fl);
25623 + err = ip_v4_find_src(net, nxi, &rt, &fl);
25627 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
25629 if (err == -ENETUNREACH)
25630 @@ -1183,7 +1193,8 @@ try_again:
25632 sin->sin_family = AF_INET;
25633 sin->sin_port = udp_hdr(skb)->source;
25634 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25635 + sin->sin_addr.s_addr = nx_map_sock_lback(
25636 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25637 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25639 if (inet->cmsg_flags)
25640 @@ -1924,6 +1935,8 @@ static struct sock *udp_get_first(struct
25641 sk_nulls_for_each(sk, node, &hslot->head) {
25642 if (!net_eq(sock_net(sk), net))
25644 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25646 if (sk->sk_family == state->family)
25649 @@ -1941,7 +1954,9 @@ static struct sock *udp_get_next(struct
25652 sk = sk_nulls_next(sk);
25653 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25654 + } while (sk && (!net_eq(sock_net(sk), net) ||
25655 + sk->sk_family != state->family ||
25656 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25659 if (state->bucket <= state->udp_table->mask)
25660 @@ -2048,7 +2063,10 @@ static void udp4_format_sock(struct sock
25662 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
25663 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
25664 - bucket, src, srcp, dest, destp, sp->sk_state,
25666 + nx_map_sock_lback(current_nx_info(), src), srcp,
25667 + nx_map_sock_lback(current_nx_info(), dest), destp,
25669 sk_wmem_alloc_get(sp),
25670 sk_rmem_alloc_get(sp),
25671 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
25672 diff -NurpP --minimal linux-2.6.37/net/ipv6/addrconf.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/addrconf.c
25673 --- linux-2.6.37/net/ipv6/addrconf.c 2011-01-05 21:50:42.000000000 +0100
25674 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/addrconf.c 2011-01-05 22:30:43.000000000 +0100
25677 #include <linux/proc_fs.h>
25678 #include <linux/seq_file.h>
25679 +#include <linux/vs_network.h>
25680 +#include <linux/vs_inet6.h>
25682 /* Set to 3 to get tracing... */
25683 #define ACONF_DEBUG 2
25684 @@ -1124,7 +1126,7 @@ out:
25686 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25687 const struct in6_addr *daddr, unsigned int prefs,
25688 - struct in6_addr *saddr)
25689 + struct in6_addr *saddr, struct nx_info *nxi)
25691 struct ipv6_saddr_score scores[2],
25692 *score = &scores[0], *hiscore = &scores[1];
25693 @@ -1196,6 +1198,8 @@ int ipv6_dev_get_saddr(struct net *net,
25697 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25701 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25702 @@ -3079,7 +3083,10 @@ static void if6_seq_stop(struct seq_file
25703 static int if6_seq_show(struct seq_file *seq, void *v)
25705 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25706 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25708 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25709 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25710 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25712 ifp->idev->dev->ifindex,
25714 @@ -3585,6 +3592,11 @@ static int in6_dump_addrs(struct inet6_d
25715 struct ifacaddr6 *ifaca;
25717 int ip_idx = *p_ip_idx;
25718 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25720 + /* disable ipv6 on non v6 guests */
25721 + if (nxi && !nx_info_has_v6(nxi))
25724 read_lock_bh(&idev->lock);
25726 @@ -3595,6 +3607,8 @@ static int in6_dump_addrs(struct inet6_d
25727 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25728 if (++ip_idx < s_ip_idx)
25730 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25732 err = inet6_fill_ifaddr(skb, ifa,
25733 NETLINK_CB(cb->skb).pid,
25734 cb->nlh->nlmsg_seq,
25735 @@ -3611,6 +3625,8 @@ static int in6_dump_addrs(struct inet6_d
25736 ifmca = ifmca->next, ip_idx++) {
25737 if (ip_idx < s_ip_idx)
25739 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25741 err = inet6_fill_ifmcaddr(skb, ifmca,
25742 NETLINK_CB(cb->skb).pid,
25743 cb->nlh->nlmsg_seq,
25744 @@ -3626,6 +3642,8 @@ static int in6_dump_addrs(struct inet6_d
25745 ifaca = ifaca->aca_next, ip_idx++) {
25746 if (ip_idx < s_ip_idx)
25748 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25750 err = inet6_fill_ifacaddr(skb, ifaca,
25751 NETLINK_CB(cb->skb).pid,
25752 cb->nlh->nlmsg_seq,
25753 @@ -3975,6 +3993,11 @@ static int inet6_dump_ifinfo(struct sk_b
25754 struct inet6_dev *idev;
25755 struct hlist_head *head;
25756 struct hlist_node *node;
25757 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25759 + /* FIXME: maybe disable ipv6 on non v6 guests?
25760 + if (skb->sk && skb->sk->sk_vx_info)
25761 + return skb->len; */
25764 s_idx = cb->args[1];
25765 @@ -3986,6 +4009,8 @@ static int inet6_dump_ifinfo(struct sk_b
25766 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25769 + if (!v6_dev_in_nx_info(dev, nxi))
25771 idev = __in6_dev_get(dev);
25774 diff -NurpP --minimal linux-2.6.37/net/ipv6/af_inet6.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/af_inet6.c
25775 --- linux-2.6.37/net/ipv6/af_inet6.c 2011-01-05 21:50:42.000000000 +0100
25776 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/af_inet6.c 2010-11-23 02:09:41.000000000 +0100
25778 #include <linux/netdevice.h>
25779 #include <linux/icmpv6.h>
25780 #include <linux/netfilter_ipv6.h>
25781 +#include <linux/vs_inet.h>
25782 +#include <linux/vs_inet6.h>
25784 #include <net/ip.h>
25785 #include <net/ipv6.h>
25786 @@ -160,9 +162,12 @@ lookup_protocol:
25790 + if ((protocol == IPPROTO_ICMPV6) &&
25791 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25793 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25794 goto out_rcu_unlock;
25797 sock->ops = answer->ops;
25798 answer_prot = answer->prot;
25799 answer_no_check = answer->no_check;
25800 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25801 struct inet_sock *inet = inet_sk(sk);
25802 struct ipv6_pinfo *np = inet6_sk(sk);
25803 struct net *net = sock_net(sk);
25804 + struct nx_v6_sock_addr nsa;
25806 unsigned short snum;
25808 @@ -272,6 +278,11 @@ int inet6_bind(struct socket *sock, stru
25810 if (addr_len < SIN6_LEN_RFC2133)
25813 + err = v6_map_sock_addr(inet, addr, &nsa);
25817 addr_type = ipv6_addr_type(&addr->sin6_addr);
25818 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25820 @@ -303,6 +314,7 @@ int inet6_bind(struct socket *sock, stru
25821 /* Reproduce AF_INET checks to make the bindings consitant */
25822 v4addr = addr->sin6_addr.s6_addr32[3];
25823 chk_addr_ret = inet_addr_type(net, v4addr);
25825 if (!sysctl_ip_nonlocal_bind &&
25826 !(inet->freebind || inet->transparent) &&
25827 v4addr != htonl(INADDR_ANY) &&
25828 @@ -312,6 +324,10 @@ int inet6_bind(struct socket *sock, stru
25829 err = -EADDRNOTAVAIL;
25832 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25833 + err = -EADDRNOTAVAIL;
25837 if (addr_type != IPV6_ADDR_ANY) {
25838 struct net_device *dev = NULL;
25839 @@ -338,6 +354,11 @@ int inet6_bind(struct socket *sock, stru
25843 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25844 + err = -EADDRNOTAVAIL;
25848 /* ipv4 addr of the socket is invalid. Only the
25849 * unspecified and mapped address have a v4 equivalent.
25851 @@ -354,6 +375,9 @@ int inet6_bind(struct socket *sock, stru
25855 + /* what's that for? */
25856 + v6_set_sock_addr(inet, &nsa);
25858 inet->inet_rcv_saddr = v4addr;
25859 inet->inet_saddr = v4addr;
25861 @@ -455,9 +479,11 @@ int inet6_getname(struct socket *sock, s
25863 sin->sin6_port = inet->inet_dport;
25864 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25865 + /* FIXME: remap lback? */
25867 sin->sin6_flowinfo = np->flow_label;
25869 + /* FIXME: remap lback? */
25870 if (ipv6_addr_any(&np->rcv_saddr))
25871 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25873 diff -NurpP --minimal linux-2.6.37/net/ipv6/fib6_rules.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/fib6_rules.c
25874 --- linux-2.6.37/net/ipv6/fib6_rules.c 2011-01-05 21:50:42.000000000 +0100
25875 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/fib6_rules.c 2010-11-23 02:09:41.000000000 +0100
25876 @@ -88,7 +88,7 @@ static int fib6_rule_action(struct fib_r
25877 ip6_dst_idev(&rt->dst)->dev,
25879 rt6_flags2srcprefs(flags),
25883 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25885 diff -NurpP --minimal linux-2.6.37/net/ipv6/inet6_hashtables.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/inet6_hashtables.c
25886 --- linux-2.6.37/net/ipv6/inet6_hashtables.c 2010-02-25 11:52:10.000000000 +0100
25887 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/inet6_hashtables.c 2010-11-23 02:09:41.000000000 +0100
25890 #include <linux/module.h>
25891 #include <linux/random.h>
25892 +#include <linux/vs_inet6.h>
25894 #include <net/inet_connection_sock.h>
25895 #include <net/inet_hashtables.h>
25896 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
25897 unsigned int slot = hash & hashinfo->ehash_mask;
25898 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25903 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25904 @@ -94,7 +94,7 @@ begin:
25912 if (get_nulls_value(node) != slot)
25913 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
25914 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25918 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25921 if (sk->sk_bound_dev_if) {
25922 if (sk->sk_bound_dev_if != dif)
25923 diff -NurpP --minimal linux-2.6.37/net/ipv6/ip6_output.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/ip6_output.c
25924 --- linux-2.6.37/net/ipv6/ip6_output.c 2011-01-05 21:50:42.000000000 +0100
25925 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/ip6_output.c 2011-01-05 22:30:43.000000000 +0100
25926 @@ -930,7 +930,7 @@ static int ip6_dst_lookup_tail(struct so
25927 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
25929 sk ? inet6_sk(sk)->srcprefs : 0,
25931 + &fl->fl6_src, sk->sk_nx_info);
25933 goto out_err_release;
25935 diff -NurpP --minimal linux-2.6.37/net/ipv6/Kconfig linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/Kconfig
25936 --- linux-2.6.37/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25937 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/Kconfig 2010-11-23 02:09:41.000000000 +0100
25940 # IPv6 as module will cause a CRASH if you try to unload it
25942 - tristate "The IPv6 protocol"
25944 + bool "The IPv6 protocol"
25947 This is complemental support for the IP version 6.
25948 You will still be able to do traditional IPv4 networking as well.
25949 diff -NurpP --minimal linux-2.6.37/net/ipv6/ndisc.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/ndisc.c
25950 --- linux-2.6.37/net/ipv6/ndisc.c 2011-01-05 21:50:42.000000000 +0100
25951 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/ndisc.c 2010-11-23 02:09:41.000000000 +0100
25952 @@ -595,7 +595,7 @@ static void ndisc_send_na(struct net_dev
25954 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25955 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25957 + &tmpaddr, NULL /* FIXME: ? */ ))
25959 src_addr = &tmpaddr;
25961 diff -NurpP --minimal linux-2.6.37/net/ipv6/raw.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/raw.c
25962 --- linux-2.6.37/net/ipv6/raw.c 2011-01-05 21:50:42.000000000 +0100
25963 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/raw.c 2010-11-23 02:09:41.000000000 +0100
25965 #include <linux/icmpv6.h>
25966 #include <linux/netfilter.h>
25967 #include <linux/netfilter_ipv6.h>
25968 +#include <linux/vs_inet6.h>
25969 #include <linux/skbuff.h>
25970 #include <asm/uaccess.h>
25971 #include <asm/ioctls.h>
25972 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
25976 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25977 + err = -EADDRNOTAVAIL;
25983 /* ipv4 addr of the socket is invalid. Only the
25984 * unspecified and mapped address have a v4 equivalent.
25986 diff -NurpP --minimal linux-2.6.37/net/ipv6/route.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/route.c
25987 --- linux-2.6.37/net/ipv6/route.c 2011-01-05 21:50:42.000000000 +0100
25988 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/route.c 2011-01-05 22:30:43.000000000 +0100
25989 @@ -2290,7 +2290,8 @@ static int rt6_fill_node(struct net *net
25990 struct inet6_dev *idev = ip6_dst_idev(&rt->dst);
25991 struct in6_addr saddr_buf;
25992 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25993 - dst, 0, &saddr_buf) == 0)
25994 + dst, 0, &saddr_buf,
25995 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25996 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25999 diff -NurpP --minimal linux-2.6.37/net/ipv6/tcp_ipv6.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/tcp_ipv6.c
26000 --- linux-2.6.37/net/ipv6/tcp_ipv6.c 2011-01-05 21:50:42.000000000 +0100
26001 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/tcp_ipv6.c 2010-11-23 02:09:41.000000000 +0100
26004 #include <linux/crypto.h>
26005 #include <linux/scatterlist.h>
26006 +#include <linux/vs_inet6.h>
26008 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
26009 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
26010 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
26011 * connect() to INADDR_ANY means loopback (BSD'ism).
26014 - if(ipv6_addr_any(&usin->sin6_addr))
26015 - usin->sin6_addr.s6_addr[15] = 0x1;
26016 + if(ipv6_addr_any(&usin->sin6_addr)) {
26017 + struct nx_info *nxi = sk->sk_nx_info;
26019 + if (nxi && nx_info_has_v6(nxi))
26020 + /* FIXME: remap lback? */
26021 + usin->sin6_addr = nxi->v6.ip;
26023 + usin->sin6_addr.s6_addr[15] = 0x1;
26026 addr_type = ipv6_addr_type(&usin->sin6_addr);
26028 diff -NurpP --minimal linux-2.6.37/net/ipv6/udp.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/udp.c
26029 --- linux-2.6.37/net/ipv6/udp.c 2011-01-05 21:50:42.000000000 +0100
26030 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/udp.c 2011-01-05 22:30:43.000000000 +0100
26031 @@ -48,13 +48,14 @@
26033 #include <linux/proc_fs.h>
26034 #include <linux/seq_file.h>
26035 +#include <linux/vs_inet6.h>
26036 #include "udp_impl.h"
26038 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
26040 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
26041 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
26042 - __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
26043 + __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
26044 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26045 int sk_ipv6only = ipv6_only_sock(sk);
26046 int sk2_ipv6only = inet_v6_ipv6only(sk2);
26047 @@ -62,24 +63,49 @@ int ipv6_rcv_saddr_equal(const struct so
26048 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
26050 /* if both are mapped, treat as IPv4 */
26051 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
26052 - return (!sk2_ipv6only &&
26053 - (!sk1_rcv_saddr || !sk2_rcv_saddr ||
26054 - sk1_rcv_saddr == sk2_rcv_saddr));
26055 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
26056 + if (!sk2_ipv6only &&
26057 + (!sk_rcv_saddr || !sk2_rcv_saddr ||
26058 + sk_rcv_saddr == sk2_rcv_saddr))
26064 if (addr_type2 == IPV6_ADDR_ANY &&
26065 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
26069 if (addr_type == IPV6_ADDR_ANY &&
26070 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26074 if (sk2_rcv_saddr6 &&
26075 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
26082 + if (!sk_rcv_saddr && !sk2_rcv_saddr)
26083 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
26084 + if (!sk2_rcv_saddr)
26085 + return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
26086 + if (!sk_rcv_saddr)
26087 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
26090 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
26091 + return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
26092 + else if (addr_type2 == IPV6_ADDR_ANY)
26093 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
26094 + else if (addr_type == IPV6_ADDR_ANY) {
26095 + if (addr_type2 == IPV6_ADDR_MAPPED)
26096 + return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
26098 + return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
26103 static unsigned int udp6_portaddr_hash(struct net *net,
26104 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
26105 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26109 + /* block non nx_info ips */
26110 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26113 if (!ipv6_addr_any(&np->daddr)) {
26114 if (!ipv6_addr_equal(&np->daddr, saddr))
26115 diff -NurpP --minimal linux-2.6.37/net/ipv6/xfrm6_policy.c linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/xfrm6_policy.c
26116 --- linux-2.6.37/net/ipv6/xfrm6_policy.c 2011-01-05 21:50:42.000000000 +0100
26117 +++ linux-2.6.37-vs2.3.0.37-rc3/net/ipv6/xfrm6_policy.c 2010-11-23 02:09:41.000000000 +0100
26118 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
26119 dev = ip6_dst_idev(dst)->dev;
26120 ipv6_dev_get_saddr(dev_net(dev), dev,
26121 (struct in6_addr *)&daddr->a6, 0,
26122 - (struct in6_addr *)&saddr->a6);
26123 + (struct in6_addr *)&saddr->a6, NULL);
26127 diff -NurpP --minimal linux-2.6.37/net/netfilter/ipvs/ip_vs_xmit.c linux-2.6.37-vs2.3.0.37-rc3/net/netfilter/ipvs/ip_vs_xmit.c
26128 --- linux-2.6.37/net/netfilter/ipvs/ip_vs_xmit.c 2011-01-05 21:50:43.000000000 +0100
26129 +++ linux-2.6.37-vs2.3.0.37-rc3/net/netfilter/ipvs/ip_vs_xmit.c 2011-01-06 00:35:16.000000000 +0100
26130 @@ -231,7 +231,7 @@ __ip_vs_route_output_v6(struct net *net,
26132 if (ipv6_addr_any(&fl.fl6_src) &&
26133 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
26134 - &fl.fl6_dst, 0, &fl.fl6_src) < 0)
26135 + &fl.fl6_dst, 0, &fl.fl6_src, NULL) < 0)
26137 if (do_xfrm && xfrm_lookup(net, &dst, &fl, NULL, 0) < 0)
26139 diff -NurpP --minimal linux-2.6.37/net/netlink/af_netlink.c linux-2.6.37-vs2.3.0.37-rc3/net/netlink/af_netlink.c
26140 --- linux-2.6.37/net/netlink/af_netlink.c 2011-01-05 21:50:43.000000000 +0100
26141 +++ linux-2.6.37-vs2.3.0.37-rc3/net/netlink/af_netlink.c 2010-11-23 02:09:41.000000000 +0100
26143 #include <linux/types.h>
26144 #include <linux/audit.h>
26145 #include <linux/mutex.h>
26146 +#include <linux/vs_context.h>
26147 +#include <linux/vs_network.h>
26148 +#include <linux/vs_limit.h>
26150 #include <net/net_namespace.h>
26151 #include <net/sock.h>
26152 @@ -1912,6 +1915,8 @@ static struct sock *netlink_seq_socket_i
26153 sk_for_each(s, node, &hash->table[j]) {
26154 if (sock_net(s) != seq_file_net(seq))
26156 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26160 iter->hash_idx = j;
26161 @@ -1946,7 +1951,8 @@ static void *netlink_seq_next(struct seq
26165 - } while (s && sock_net(s) != seq_file_net(seq));
26166 + } while (s && (sock_net(s) != seq_file_net(seq) ||
26167 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
26171 @@ -1958,7 +1964,8 @@ static void *netlink_seq_next(struct seq
26173 for (; j <= hash->mask; j++) {
26174 s = sk_head(&hash->table[j]);
26175 - while (s && sock_net(s) != seq_file_net(seq))
26176 + while (s && (sock_net(s) != seq_file_net(seq) ||
26177 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
26181 diff -NurpP --minimal linux-2.6.37/net/sctp/ipv6.c linux-2.6.37-vs2.3.0.37-rc3/net/sctp/ipv6.c
26182 --- linux-2.6.37/net/sctp/ipv6.c 2011-01-05 21:50:45.000000000 +0100
26183 +++ linux-2.6.37-vs2.3.0.37-rc3/net/sctp/ipv6.c 2010-11-23 02:09:41.000000000 +0100
26184 @@ -306,7 +306,8 @@ static void sctp_v6_get_saddr(struct sct
26185 dst ? ip6_dst_idev(dst)->dev : NULL,
26186 &daddr->v6.sin6_addr,
26187 inet6_sk(&sk->inet.sk)->srcprefs,
26188 - &saddr->v6.sin6_addr);
26189 + &saddr->v6.sin6_addr,
26190 + asoc->base.sk->sk_nx_info);
26191 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
26192 &saddr->v6.sin6_addr);
26194 diff -NurpP --minimal linux-2.6.37/net/socket.c linux-2.6.37-vs2.3.0.37-rc3/net/socket.c
26195 --- linux-2.6.37/net/socket.c 2011-01-05 21:50:45.000000000 +0100
26196 +++ linux-2.6.37-vs2.3.0.37-rc3/net/socket.c 2011-01-05 22:30:44.000000000 +0100
26199 #include <net/sock.h>
26200 #include <linux/netfilter.h>
26201 +#include <linux/vs_base.h>
26202 +#include <linux/vs_socket.h>
26203 +#include <linux/vs_inet.h>
26204 +#include <linux/vs_inet6.h>
26206 #include <linux/if_tun.h>
26207 #include <linux/ipv6_route.h>
26208 @@ -550,7 +554,7 @@ static inline int __sock_sendmsg(struct
26209 struct msghdr *msg, size_t size)
26211 struct sock_iocb *si = kiocb_to_siocb(iocb);
26215 sock_update_classid(sock->sk);
26217 @@ -563,7 +567,22 @@ static inline int __sock_sendmsg(struct
26221 - return sock->ops->sendmsg(iocb, sock, msg, size);
26222 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26225 + vx_sock_send(sock->sk, size);
26227 + vx_sock_fail(sock->sk, size);
26229 + vxdprintk(VXD_CBIT(net, 7),
26230 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26232 + (sock->sk)?sock->sk->sk_nx_info:0,
26233 + (sock->sk)?sock->sk->sk_vx_info:0,
26234 + (sock->sk)?sock->sk->sk_xid:0,
26235 + (sock->sk)?sock->sk->sk_nid:0,
26236 + (unsigned int)size, len);
26240 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
26241 @@ -681,6 +700,7 @@ static inline int __sock_recvmsg_nosec(s
26242 struct msghdr *msg, size_t size, int flags)
26244 struct sock_iocb *si = kiocb_to_siocb(iocb);
26247 sock_update_classid(sock->sk);
26249 @@ -690,7 +710,18 @@ static inline int __sock_recvmsg_nosec(s
26253 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26254 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26255 + if ((len >= 0) && sock->sk)
26256 + vx_sock_recv(sock->sk, len);
26257 + vxdprintk(VXD_CBIT(net, 7),
26258 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26260 + (sock->sk)?sock->sk->sk_nx_info:0,
26261 + (sock->sk)?sock->sk->sk_vx_info:0,
26262 + (sock->sk)?sock->sk->sk_xid:0,
26263 + (sock->sk)?sock->sk->sk_nid:0,
26264 + (unsigned int)size, len);
26268 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26269 @@ -1174,6 +1205,13 @@ int __sock_create(struct net *net, int f
26270 if (type < 0 || type >= SOCK_MAX)
26273 + if (!nx_check(0, VS_ADMIN)) {
26274 + if (family == PF_INET && !current_nx_info_has_v4())
26275 + return -EAFNOSUPPORT;
26276 + if (family == PF_INET6 && !current_nx_info_has_v6())
26277 + return -EAFNOSUPPORT;
26282 This uglymoron is moved from INET layer to here to avoid
26283 @@ -1309,6 +1347,7 @@ SYSCALL_DEFINE3(socket, int, family, int
26287 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26288 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
26291 @@ -1350,10 +1389,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
26292 err = sock_create(family, type, protocol, &sock1);
26295 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26297 err = sock_create(family, type, protocol, &sock2);
26299 goto out_release_1;
26300 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26302 err = sock1->ops->socketpair(sock1, sock2);
26304 diff -NurpP --minimal linux-2.6.37/net/sunrpc/auth.c linux-2.6.37-vs2.3.0.37-rc3/net/sunrpc/auth.c
26305 --- linux-2.6.37/net/sunrpc/auth.c 2011-01-05 21:50:45.000000000 +0100
26306 +++ linux-2.6.37-vs2.3.0.37-rc3/net/sunrpc/auth.c 2010-11-23 02:09:41.000000000 +0100
26308 #include <linux/hash.h>
26309 #include <linux/sunrpc/clnt.h>
26310 #include <linux/spinlock.h>
26311 +#include <linux/vs_tag.h>
26314 # define RPCDBG_FACILITY RPCDBG_AUTH
26315 @@ -425,6 +426,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26316 memset(&acred, 0, sizeof(acred));
26317 acred.uid = cred->fsuid;
26318 acred.gid = cred->fsgid;
26319 + acred.tag = dx_current_tag();
26320 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
26322 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
26323 @@ -465,6 +467,7 @@ rpcauth_bind_root_cred(struct rpc_task *
26324 struct auth_cred acred = {
26327 + .tag = dx_current_tag(),
26330 dprintk("RPC: %5u looking up %s cred\n",
26331 diff -NurpP --minimal linux-2.6.37/net/sunrpc/auth_unix.c linux-2.6.37-vs2.3.0.37-rc3/net/sunrpc/auth_unix.c
26332 --- linux-2.6.37/net/sunrpc/auth_unix.c 2010-10-21 13:08:01.000000000 +0200
26333 +++ linux-2.6.37-vs2.3.0.37-rc3/net/sunrpc/auth_unix.c 2010-11-23 02:09:41.000000000 +0100
26334 @@ -12,12 +12,14 @@
26335 #include <linux/module.h>
26336 #include <linux/sunrpc/clnt.h>
26337 #include <linux/sunrpc/auth.h>
26338 +#include <linux/vs_tag.h>
26340 #define NFS_NGROUPS 16
26343 struct rpc_cred uc_base;
26346 gid_t uc_gids[NFS_NGROUPS];
26348 #define uc_uid uc_base.cr_uid
26349 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
26350 groups = NFS_NGROUPS;
26352 cred->uc_gid = acred->gid;
26353 + cred->uc_tag = acred->tag;
26354 for (i = 0; i < groups; i++)
26355 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26356 if (i < NFS_NGROUPS)
26357 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
26361 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
26362 + if (cred->uc_uid != acred->uid ||
26363 + cred->uc_gid != acred->gid ||
26364 + cred->uc_tag != acred->tag)
26367 if (acred->group_info != NULL)
26368 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
26369 struct rpc_clnt *clnt = task->tk_client;
26370 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
26371 __be32 *base, *hold;
26375 *p++ = htonl(RPC_AUTH_UNIX);
26377 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
26378 * Copy the UTS nodename captured when the client was created.
26380 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26381 + tag = task->tk_client->cl_tag;
26383 - *p++ = htonl((u32) cred->uc_uid);
26384 - *p++ = htonl((u32) cred->uc_gid);
26385 + *p++ = htonl((u32) TAGINO_UID(tag,
26386 + cred->uc_uid, cred->uc_tag));
26387 + *p++ = htonl((u32) TAGINO_GID(tag,
26388 + cred->uc_gid, cred->uc_tag));
26390 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
26391 *p++ = htonl((u32) cred->uc_gids[i]);
26392 diff -NurpP --minimal linux-2.6.37/net/sunrpc/clnt.c linux-2.6.37-vs2.3.0.37-rc3/net/sunrpc/clnt.c
26393 --- linux-2.6.37/net/sunrpc/clnt.c 2011-01-05 21:50:45.000000000 +0100
26394 +++ linux-2.6.37-vs2.3.0.37-rc3/net/sunrpc/clnt.c 2011-01-05 22:30:44.000000000 +0100
26396 #include <linux/utsname.h>
26397 #include <linux/workqueue.h>
26398 #include <linux/in6.h>
26399 +#include <linux/vs_cvirt.h>
26401 #include <linux/sunrpc/clnt.h>
26402 #include <linux/sunrpc/rpc_pipe_fs.h>
26403 @@ -359,6 +360,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
26404 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
26405 clnt->cl_chatty = 1;
26407 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
26408 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
26409 + clnt->cl_tag = 1; */
26412 EXPORT_SYMBOL_GPL(rpc_create);
26413 diff -NurpP --minimal linux-2.6.37/net/unix/af_unix.c linux-2.6.37-vs2.3.0.37-rc3/net/unix/af_unix.c
26414 --- linux-2.6.37/net/unix/af_unix.c 2011-01-05 21:50:46.000000000 +0100
26415 +++ linux-2.6.37-vs2.3.0.37-rc3/net/unix/af_unix.c 2011-01-05 22:30:44.000000000 +0100
26416 @@ -114,6 +114,8 @@
26417 #include <linux/mount.h>
26418 #include <net/checksum.h>
26419 #include <linux/security.h>
26420 +#include <linux/vs_context.h>
26421 +#include <linux/vs_limit.h>
26423 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
26424 static DEFINE_SPINLOCK(unix_table_lock);
26425 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
26426 if (!net_eq(sock_net(s), net))
26429 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26431 if (u->addr->len == len &&
26432 !memcmp(u->addr->name, sunname, len))
26434 @@ -2179,6 +2183,8 @@ static struct sock *unix_seq_idx(struct
26435 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
26436 if (sock_net(s) != seq_file_net(seq))
26438 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26443 @@ -2203,7 +2209,8 @@ static void *unix_seq_next(struct seq_fi
26444 sk = first_unix_socket(&iter->i);
26446 sk = next_unix_socket(&iter->i, sk);
26447 - while (sk && (sock_net(sk) != seq_file_net(seq)))
26448 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
26449 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
26450 sk = next_unix_socket(&iter->i, sk);
26453 diff -NurpP --minimal linux-2.6.37/scripts/checksyscalls.sh linux-2.6.37-vs2.3.0.37-rc3/scripts/checksyscalls.sh
26454 --- linux-2.6.37/scripts/checksyscalls.sh 2010-10-21 13:08:01.000000000 +0200
26455 +++ linux-2.6.37-vs2.3.0.37-rc3/scripts/checksyscalls.sh 2010-11-23 02:09:41.000000000 +0100
26456 @@ -193,7 +193,6 @@ cat << EOF
26457 #define __IGNORE_afs_syscall
26458 #define __IGNORE_getpmsg
26459 #define __IGNORE_putpmsg
26460 -#define __IGNORE_vserver
26464 diff -NurpP --minimal linux-2.6.37/security/commoncap.c linux-2.6.37-vs2.3.0.37-rc3/security/commoncap.c
26465 --- linux-2.6.37/security/commoncap.c 2011-01-05 21:50:47.000000000 +0100
26466 +++ linux-2.6.37-vs2.3.0.37-rc3/security/commoncap.c 2010-11-23 02:21:20.000000000 +0100
26468 #include <linux/sched.h>
26469 #include <linux/prctl.h>
26470 #include <linux/securebits.h>
26471 +// #include <linux/vs_context.h>
26474 * If a non-root user executes a setuid-root binary in
26475 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
26477 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
26479 - NETLINK_CB(skb).eff_cap = current_cap();
26480 + NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
26484 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
26489 EXPORT_SYMBOL(cap_netlink_recv);
26492 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
26493 int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
26496 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26497 + struct vx_info *vxi = tsk->vx_info;
26500 + printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
26501 + vx_info_flags(vxi, VXF_STATE_SETUP, 0),
26502 + cap_raised(tsk->cap_effective, cap),
26503 + tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
26506 + /* special case SETUP */
26507 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26508 + /* FIXME: maybe use cred instead? */
26509 + cap_raised(tsk->cred->cap_effective, cap))
26512 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26516 @@ -570,7 +587,7 @@ int cap_inode_setxattr(struct dentry *de
26518 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26519 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26520 - !capable(CAP_SYS_ADMIN))
26521 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26525 @@ -596,7 +613,7 @@ int cap_inode_removexattr(struct dentry
26527 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26528 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26529 - !capable(CAP_SYS_ADMIN))
26530 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26534 @@ -929,3 +946,4 @@ int cap_file_mmap(struct file *file, uns
26539 diff -NurpP --minimal linux-2.6.37/security/selinux/hooks.c linux-2.6.37-vs2.3.0.37-rc3/security/selinux/hooks.c
26540 --- linux-2.6.37/security/selinux/hooks.c 2011-01-05 21:50:47.000000000 +0100
26541 +++ linux-2.6.37-vs2.3.0.37-rc3/security/selinux/hooks.c 2010-11-23 02:09:41.000000000 +0100
26543 #include <linux/dccp.h>
26544 #include <linux/quota.h>
26545 #include <linux/un.h> /* for Unix socket types */
26546 -#include <net/af_unix.h> /* for Unix socket types */
26547 #include <linux/parser.h>
26548 #include <linux/nfs_mount.h>
26549 #include <net/ipv6.h>