1 diff -Nurp linux-2.6.22.18/arch/alpha/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/alpha/Kconfig
2 --- linux-2.6.22.18/arch/alpha/Kconfig 2007-07-21 23:59:44.000000000 +0200
3 +++ linux-2.6.22.18-vs2.3.0.32/arch/alpha/Kconfig 2008-02-11 12:35:31.000000000 +0100
4 @@ -662,6 +662,8 @@ config DUMMY_CONSOLE
8 +source "kernel/vserver/Kconfig"
10 source "security/Kconfig"
12 source "crypto/Kconfig"
13 diff -Nurp linux-2.6.22.18/arch/alpha/kernel/asm-offsets.c linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/asm-offsets.c
14 --- linux-2.6.22.18/arch/alpha/kernel/asm-offsets.c 2006-06-18 03:49:35.000000000 +0200
15 +++ linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/asm-offsets.c 2008-02-11 12:35:31.000000000 +0100
16 @@ -36,6 +36,7 @@ void foo(void)
17 DEFINE(PT_PTRACED, PT_PTRACED);
18 DEFINE(CLONE_VM, CLONE_VM);
19 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
20 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
21 DEFINE(SIGCHLD, SIGCHLD);
24 diff -Nurp linux-2.6.22.18/arch/alpha/kernel/entry.S linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/entry.S
25 --- linux-2.6.22.18/arch/alpha/kernel/entry.S 2007-07-21 23:59:44.000000000 +0200
26 +++ linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/entry.S 2008-02-11 12:35:31.000000000 +0100
27 @@ -643,7 +643,7 @@ kernel_thread:
28 stq $2, 152($sp) /* HAE */
30 /* Shuffle FLAGS to the front; add CLONE_VM. */
31 - ldi $1, CLONE_VM|CLONE_UNTRACED
32 + ldi $1, CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
36 @@ -872,24 +872,15 @@ sys_getxgid:
45 - /* See linux/kernel/timer.c sys_getppid for discussion
47 - ldq $3, TASK_GROUP_LEADER($2)
48 - ldq $4, TASK_REAL_PARENT($3)
49 - ldl $0, TASK_TGID($2)
50 -1: ldl $1, TASK_TGID($4)
54 - ldq $3, TASK_GROUP_LEADER($2)
55 - ldq $4, TASK_REAL_PARENT($3)
68 diff -Nurp linux-2.6.22.18/arch/alpha/kernel/osf_sys.c linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/osf_sys.c
69 --- linux-2.6.22.18/arch/alpha/kernel/osf_sys.c 2007-07-21 23:59:44.000000000 +0200
70 +++ linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/osf_sys.c 2008-02-11 12:35:31.000000000 +0100
71 @@ -883,7 +883,7 @@ osf_gettimeofday(struct timeval32 __user
75 - do_gettimeofday(&ktv);
76 + vx_gettimeofday(&ktv);
77 if (put_tv32(tv, &ktv))
80 diff -Nurp linux-2.6.22.18/arch/alpha/kernel/ptrace.c linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/ptrace.c
81 --- linux-2.6.22.18/arch/alpha/kernel/ptrace.c 2006-06-18 03:49:35.000000000 +0200
82 +++ linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/ptrace.c 2008-02-11 12:35:31.000000000 +0100
84 #include <linux/slab.h>
85 #include <linux/security.h>
86 #include <linux/signal.h>
87 +#include <linux/vs_base.h>
89 #include <asm/uaccess.h>
90 #include <asm/pgtable.h>
91 @@ -283,6 +284,11 @@ do_sys_ptrace(long request, long pid, lo
95 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
100 if (request == PTRACE_ATTACH) {
101 ret = ptrace_attach(child);
103 diff -Nurp linux-2.6.22.18/arch/alpha/kernel/semaphore.c linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/semaphore.c
104 --- linux-2.6.22.18/arch/alpha/kernel/semaphore.c 2006-06-18 03:49:35.000000000 +0200
105 +++ linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/semaphore.c 2008-02-11 12:35:31.000000000 +0100
106 @@ -68,8 +68,8 @@ __down_failed(struct semaphore *sem)
107 DECLARE_WAITQUEUE(wait, tsk);
109 #ifdef CONFIG_DEBUG_SEMAPHORE
110 - printk("%s(%d): down failed(%p)\n",
111 - tsk->comm, tsk->pid, sem);
112 + printk("%s(%d:#%u): down failed(%p)\n",
113 + tsk->comm, tsk->pid, tsk->xid, sem);
116 tsk->state = TASK_UNINTERRUPTIBLE;
117 @@ -97,8 +97,8 @@ __down_failed(struct semaphore *sem)
120 #ifdef CONFIG_DEBUG_SEMAPHORE
121 - printk("%s(%d): down acquired(%p)\n",
122 - tsk->comm, tsk->pid, sem);
123 + printk("%s(%d:#%u): down acquired(%p)\n",
124 + tsk->comm, tsk->pid, tsk->xid, sem);
128 @@ -110,8 +110,8 @@ __down_failed_interruptible(struct semap
131 #ifdef CONFIG_DEBUG_SEMAPHORE
132 - printk("%s(%d): down failed(%p)\n",
133 - tsk->comm, tsk->pid, sem);
134 + printk("%s(%d:#%u): down failed(%p)\n",
135 + tsk->comm, tsk->pid, tsk->xid, sem);
138 tsk->state = TASK_INTERRUPTIBLE;
139 diff -Nurp linux-2.6.22.18/arch/alpha/kernel/systbls.S linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/systbls.S
140 --- linux-2.6.22.18/arch/alpha/kernel/systbls.S 2007-07-21 23:59:44.000000000 +0200
141 +++ linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/systbls.S 2008-02-11 12:35:31.000000000 +0100
142 @@ -446,7 +446,7 @@ sys_call_table:
143 .quad sys_stat64 /* 425 */
146 - .quad sys_ni_syscall /* sys_vserver */
147 + .quad sys_vserver /* sys_vserver */
148 .quad sys_ni_syscall /* sys_mbind */
149 .quad sys_ni_syscall /* sys_get_mempolicy */
150 .quad sys_ni_syscall /* sys_set_mempolicy */
151 diff -Nurp linux-2.6.22.18/arch/alpha/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/traps.c
152 --- linux-2.6.22.18/arch/alpha/kernel/traps.c 2007-05-04 15:55:03.000000000 +0200
153 +++ linux-2.6.22.18-vs2.3.0.32/arch/alpha/kernel/traps.c 2008-02-11 12:35:31.000000000 +0100
154 @@ -182,7 +182,8 @@ die_if_kernel(char * str, struct pt_regs
156 printk("CPU %d ", hard_smp_processor_id());
158 - printk("%s(%d): %s %ld\n", current->comm, current->pid, str, err);
159 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
160 + current->pid, current->xid, str, err);
161 dik_show_regs(regs, r9_15);
162 dik_show_trace((unsigned long *)(regs+1));
163 dik_show_code((unsigned int *)regs->pc);
164 diff -Nurp linux-2.6.22.18/arch/alpha/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/alpha/mm/fault.c
165 --- linux-2.6.22.18/arch/alpha/mm/fault.c 2007-07-21 23:59:44.000000000 +0200
166 +++ linux-2.6.22.18-vs2.3.0.32/arch/alpha/mm/fault.c 2008-02-11 12:35:31.000000000 +0100
167 @@ -197,8 +197,8 @@ do_page_fault(unsigned long address, uns
168 down_read(&mm->mmap_sem);
171 - printk(KERN_ALERT "VM: killing process %s(%d)\n",
172 - current->comm, current->pid);
173 + printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
174 + current->comm, current->pid, current->xid);
175 if (!user_mode(regs))
178 diff -Nurp linux-2.6.22.18/arch/arm/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/arm/Kconfig
179 --- linux-2.6.22.18/arch/arm/Kconfig 2007-07-21 23:59:44.000000000 +0200
180 +++ linux-2.6.22.18-vs2.3.0.32/arch/arm/Kconfig 2008-02-11 12:35:31.000000000 +0100
181 @@ -1042,6 +1042,8 @@ source "arch/arm/oprofile/Kconfig"
183 source "arch/arm/Kconfig.debug"
185 +source "kernel/vserver/Kconfig"
187 source "security/Kconfig"
189 source "crypto/Kconfig"
190 diff -Nurp linux-2.6.22.18/arch/arm/kernel/calls.S linux-2.6.22.18-vs2.3.0.32/arch/arm/kernel/calls.S
191 --- linux-2.6.22.18/arch/arm/kernel/calls.S 2007-07-21 23:59:44.000000000 +0200
192 +++ linux-2.6.22.18-vs2.3.0.32/arch/arm/kernel/calls.S 2008-02-11 12:35:31.000000000 +0100
194 /* 310 */ CALL(sys_request_key)
196 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
197 -/* vserver */ CALL(sys_ni_syscall)
200 /* 315 */ CALL(sys_ioprio_get)
201 CALL(sys_inotify_init)
202 diff -Nurp linux-2.6.22.18/arch/arm/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/arm/kernel/process.c
203 --- linux-2.6.22.18/arch/arm/kernel/process.c 2007-07-21 23:59:44.000000000 +0200
204 +++ linux-2.6.22.18-vs2.3.0.32/arch/arm/kernel/process.c 2008-02-11 12:35:31.000000000 +0100
205 @@ -261,7 +261,8 @@ void __show_regs(struct pt_regs *regs)
206 void show_regs(struct pt_regs * regs)
209 - printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
210 + printk("Pid: %d[#%u], comm: %20s\n",
211 + current->pid, current->xid, current->comm);
215 @@ -423,7 +424,8 @@ pid_t kernel_thread(int (*fn)(void *), v
216 regs.ARM_pc = (unsigned long)kernel_thread_helper;
217 regs.ARM_cpsr = SVC_MODE;
219 - return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
220 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
221 + 0, ®s, 0, NULL, NULL);
223 EXPORT_SYMBOL(kernel_thread);
225 diff -Nurp linux-2.6.22.18/arch/arm/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/arm/kernel/traps.c
226 --- linux-2.6.22.18/arch/arm/kernel/traps.c 2007-07-21 23:59:44.000000000 +0200
227 +++ linux-2.6.22.18-vs2.3.0.32/arch/arm/kernel/traps.c 2008-02-11 12:35:31.000000000 +0100
228 @@ -222,8 +222,8 @@ static void __die(const char *str, int e
229 str, err, ++die_counter);
232 - printk("Process %s (pid: %d, stack limit = 0x%p)\n",
233 - tsk->comm, tsk->pid, thread + 1);
234 + printk("Process %s (pid: %d:#%u, stack limit = 0x%p)\n",
235 + tsk->comm, tsk->pid, tsk->xid, thread + 1);
237 if (!user_mode(regs) || in_interrupt()) {
238 dump_mem("Stack: ", regs->ARM_sp,
239 diff -Nurp linux-2.6.22.18/arch/arm/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/arm/mm/fault.c
240 --- linux-2.6.22.18/arch/arm/mm/fault.c 2007-07-21 23:59:44.000000000 +0200
241 +++ linux-2.6.22.18-vs2.3.0.32/arch/arm/mm/fault.c 2008-02-11 12:35:31.000000000 +0100
242 @@ -266,7 +266,8 @@ do_page_fault(unsigned long addr, unsign
243 * happened to us that made us unable to handle
244 * the page fault gracefully.
246 - printk("VM: killing process %s\n", tsk->comm);
247 + printk("VM: killing process %s(%d:#%u)\n",
248 + tsk->comm, tsk->pid, tsk->xid);
252 diff -Nurp linux-2.6.22.18/arch/arm26/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/arm26/Kconfig
253 --- linux-2.6.22.18/arch/arm26/Kconfig 2007-07-21 23:59:44.000000000 +0200
254 +++ linux-2.6.22.18-vs2.3.0.32/arch/arm26/Kconfig 2008-02-11 12:35:31.000000000 +0100
255 @@ -243,6 +243,8 @@ source "drivers/usb/Kconfig"
257 source "arch/arm26/Kconfig.debug"
259 +source "kernel/vserver/Kconfig"
261 source "security/Kconfig"
263 source "crypto/Kconfig"
264 diff -Nurp linux-2.6.22.18/arch/arm26/kernel/calls.S linux-2.6.22.18-vs2.3.0.32/arch/arm26/kernel/calls.S
265 --- linux-2.6.22.18/arch/arm26/kernel/calls.S 2006-06-18 03:49:35.000000000 +0200
266 +++ linux-2.6.22.18-vs2.3.0.32/arch/arm26/kernel/calls.S 2008-02-11 12:35:31.000000000 +0100
267 @@ -257,6 +257,11 @@ __syscall_start:
268 .long sys_lremovexattr
269 .long sys_fremovexattr
272 + .rept 313 - (. - __syscall_start) / 4
273 + .long sys_ni_syscall
275 + .long sys_vserver /* 313 */
278 .rept NR_syscalls - (__syscall_end - __syscall_start) / 4
279 diff -Nurp linux-2.6.22.18/arch/arm26/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/arm26/kernel/process.c
280 --- linux-2.6.22.18/arch/arm26/kernel/process.c 2007-05-04 15:55:07.000000000 +0200
281 +++ linux-2.6.22.18-vs2.3.0.32/arch/arm26/kernel/process.c 2008-02-11 12:35:31.000000000 +0100
282 @@ -365,7 +365,8 @@ pid_t kernel_thread(int (*fn)(void *), v
283 regs.ARM_r3 = (unsigned long)do_exit;
284 regs.ARM_pc = (unsigned long)kernel_thread_helper | MODE_SVC26;
286 - return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
287 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
288 + 0, ®s, 0, NULL, NULL);
290 EXPORT_SYMBOL(kernel_thread);
292 diff -Nurp linux-2.6.22.18/arch/arm26/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/arm26/kernel/traps.c
293 --- linux-2.6.22.18/arch/arm26/kernel/traps.c 2007-05-04 15:55:07.000000000 +0200
294 +++ linux-2.6.22.18-vs2.3.0.32/arch/arm26/kernel/traps.c 2008-02-11 12:35:31.000000000 +0100
295 @@ -185,8 +185,9 @@ NORET_TYPE void die(const char *str, str
296 printk("Internal error: %s: %x\n", str, err);
297 printk("CPU: %d\n", smp_processor_id());
299 - printk("Process %s (pid: %d, stack limit = 0x%p)\n",
300 - current->comm, current->pid, end_of_stack(tsk));
301 + printk("Process %s (pid: %d[#%u], stack limit = 0x%p)\n",
302 + current->comm, current->pid,
303 + current->xid, end_of_stack(tsk));
305 if (!user_mode(regs) || in_interrupt()) {
306 __dump_stack(tsk, (unsigned long)(regs + 1));
307 diff -Nurp linux-2.6.22.18/arch/cris/arch-v10/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/cris/arch-v10/kernel/process.c
308 --- linux-2.6.22.18/arch/cris/arch-v10/kernel/process.c 2007-05-04 15:55:07.000000000 +0200
309 +++ linux-2.6.22.18-vs2.3.0.32/arch/cris/arch-v10/kernel/process.c 2008-02-11 12:35:31.000000000 +0100
310 @@ -103,7 +103,8 @@ int kernel_thread(int (*fn)(void *), voi
311 regs.dccr = 1 << I_DCCR_BITNR;
313 /* Ok, create the new process.. */
314 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
315 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
316 + 0, ®s, 0, NULL, NULL);
319 /* setup the child's kernel stack with a pt_regs and switch_stack on it.
320 diff -Nurp linux-2.6.22.18/arch/cris/arch-v32/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/cris/arch-v32/kernel/process.c
321 --- linux-2.6.22.18/arch/cris/arch-v32/kernel/process.c 2007-05-04 15:55:07.000000000 +0200
322 +++ linux-2.6.22.18-vs2.3.0.32/arch/cris/arch-v32/kernel/process.c 2008-02-11 12:35:31.000000000 +0100
323 @@ -120,7 +120,8 @@ kernel_thread(int (*fn)(void *), void *
324 regs.ccs = 1 << (I_CCS_BITNR + CCS_SHIFT);
326 /* Create the new process. */
327 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
328 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
329 + 0, ®s, 0, NULL, NULL);
333 diff -Nurp linux-2.6.22.18/arch/cris/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/cris/Kconfig
334 --- linux-2.6.22.18/arch/cris/Kconfig 2007-07-21 23:58:14.000000000 +0200
335 +++ linux-2.6.22.18-vs2.3.0.32/arch/cris/Kconfig 2008-02-11 12:35:31.000000000 +0100
336 @@ -200,6 +200,8 @@ source "drivers/usb/Kconfig"
338 source "arch/cris/Kconfig.debug"
340 +source "kernel/vserver/Kconfig"
342 source "security/Kconfig"
344 source "crypto/Kconfig"
345 diff -Nurp linux-2.6.22.18/arch/frv/kernel/kernel_thread.S linux-2.6.22.18-vs2.3.0.32/arch/frv/kernel/kernel_thread.S
346 --- linux-2.6.22.18/arch/frv/kernel/kernel_thread.S 2006-06-18 03:49:35.000000000 +0200
347 +++ linux-2.6.22.18-vs2.3.0.32/arch/frv/kernel/kernel_thread.S 2008-02-11 12:35:31.000000000 +0100
349 #include <asm/unistd.h>
351 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
352 +#define CLONE_KTHREAD 0x10000000 /* kernel thread */
353 +#define CLONE_KT (CLONE_VM | CLONE_KTHREAD) /* kernel thread flags */
354 #define KERN_ERR "<3>"
357 @@ -37,7 +39,7 @@ kernel_thread:
359 # start by forking the current process, but with shared VM
360 setlos.p #__NR_clone,gr7 ; syscall number
361 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
362 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
363 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
365 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
366 diff -Nurp linux-2.6.22.18/arch/h8300/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/h8300/Kconfig
367 --- linux-2.6.22.18/arch/h8300/Kconfig 2007-07-21 23:59:44.000000000 +0200
368 +++ linux-2.6.22.18-vs2.3.0.32/arch/h8300/Kconfig 2008-02-11 12:35:32.000000000 +0100
369 @@ -222,6 +222,8 @@ source "fs/Kconfig"
371 source "arch/h8300/Kconfig.debug"
373 +source "kernel/vserver/Kconfig"
375 source "security/Kconfig"
377 source "crypto/Kconfig"
378 diff -Nurp linux-2.6.22.18/arch/h8300/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/h8300/kernel/process.c
379 --- linux-2.6.22.18/arch/h8300/kernel/process.c 2007-05-04 15:55:07.000000000 +0200
380 +++ linux-2.6.22.18-vs2.3.0.32/arch/h8300/kernel/process.c 2008-02-11 12:35:32.000000000 +0100
381 @@ -134,7 +134,7 @@ int kernel_thread(int (*fn)(void *), voi
385 - clone_arg = flags | CLONE_VM;
386 + clone_arg = flags | CLONE_VM | CLONE_KTHREAD;
387 __asm__("mov.l sp,er3\n\t"
390 diff -Nurp linux-2.6.22.18/arch/i386/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/i386/Kconfig
391 --- linux-2.6.22.18/arch/i386/Kconfig 2007-07-21 23:59:44.000000000 +0200
392 +++ linux-2.6.22.18-vs2.3.0.32/arch/i386/Kconfig 2008-02-11 12:35:32.000000000 +0100
393 @@ -1230,6 +1230,8 @@ endmenu
395 source "arch/i386/Kconfig.debug"
397 +source "kernel/vserver/Kconfig"
399 source "security/Kconfig"
401 source "crypto/Kconfig"
402 diff -Nurp linux-2.6.22.18/arch/i386/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/i386/kernel/process.c
403 --- linux-2.6.22.18/arch/i386/kernel/process.c 2007-07-21 23:59:45.000000000 +0200
404 +++ linux-2.6.22.18-vs2.3.0.32/arch/i386/kernel/process.c 2008-02-11 12:35:32.000000000 +0100
405 @@ -302,8 +302,10 @@ void show_regs(struct pt_regs * regs)
406 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
409 - printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
410 - printk("EIP: %04x:[<%08lx>] CPU: %d\n",0xffff & regs->xcs,regs->eip, smp_processor_id());
411 + printk("Pid: %d[#%u], comm: %20s\n",
412 + current->pid, current->xid, current->comm);
413 + printk("EIP: %04x:[<%08lx>] CPU: %d\n",
414 + 0xffff & regs->xcs,regs->eip, smp_processor_id());
415 print_symbol("EIP is at %s\n", regs->eip);
417 if (user_mode_vm(regs))
418 @@ -355,7 +357,8 @@ int kernel_thread(int (*fn)(void *), voi
419 regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2;
421 /* Ok, create the new process.. */
422 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
423 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
424 + 0, ®s, 0, NULL, NULL);
426 EXPORT_SYMBOL(kernel_thread);
428 diff -Nurp linux-2.6.22.18/arch/i386/kernel/syscall_table.S linux-2.6.22.18-vs2.3.0.32/arch/i386/kernel/syscall_table.S
429 --- linux-2.6.22.18/arch/i386/kernel/syscall_table.S 2007-07-21 23:59:45.000000000 +0200
430 +++ linux-2.6.22.18-vs2.3.0.32/arch/i386/kernel/syscall_table.S 2008-02-11 12:35:32.000000000 +0100
431 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
432 .long sys_tgkill /* 270 */
434 .long sys_fadvise64_64
435 - .long sys_ni_syscall /* sys_vserver */
438 .long sys_get_mempolicy
439 .long sys_set_mempolicy
440 diff -Nurp linux-2.6.22.18/arch/i386/kernel/sysenter.c linux-2.6.22.18-vs2.3.0.32/arch/i386/kernel/sysenter.c
441 --- linux-2.6.22.18/arch/i386/kernel/sysenter.c 2007-08-26 03:38:36.000000000 +0200
442 +++ linux-2.6.22.18-vs2.3.0.32/arch/i386/kernel/sysenter.c 2008-02-11 12:35:32.000000000 +0100
444 #include <linux/elf.h>
445 #include <linux/mm.h>
446 #include <linux/module.h>
447 +#include <linux/vs_memory.h>
449 #include <asm/cpufeature.h>
451 diff -Nurp linux-2.6.22.18/arch/i386/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/i386/kernel/traps.c
452 --- linux-2.6.22.18/arch/i386/kernel/traps.c 2007-07-21 23:59:45.000000000 +0200
453 +++ linux-2.6.22.18-vs2.3.0.32/arch/i386/kernel/traps.c 2008-02-11 12:35:32.000000000 +0100
455 #include <asm/stacktrace.h>
457 #include <linux/module.h>
458 +#include <linux/vs_context.h>
459 +#include <linux/vserver/history.h>
461 #include "mach_traps.h"
463 @@ -303,8 +305,8 @@ void show_registers(struct pt_regs *regs
464 regs->esi, regs->edi, regs->ebp, esp);
465 printk(KERN_EMERG "ds: %04x es: %04x fs: %04x gs: %04x ss: %04x\n",
466 regs->xds & 0xffff, regs->xes & 0xffff, regs->xfs & 0xffff, gs, ss);
467 - printk(KERN_EMERG "Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)",
468 - TASK_COMM_LEN, current->comm, current->pid,
469 + printk(KERN_EMERG "Process %.*s (pid: %d[#%u], ti=%p task=%p task.ti=%p)",
470 + TASK_COMM_LEN, current->comm, current->pid, current->xid,
471 current_thread_info(), current, task_thread_info(current));
473 * When in-kernel, we also print out the stack and code at the
474 @@ -375,6 +377,8 @@ void die(const char * str, struct pt_reg
480 if (die.lock_owner != raw_smp_processor_id()) {
482 spin_lock_irqsave(&die.lock, flags);
483 @@ -412,9 +416,9 @@ void die(const char * str, struct pt_reg
486 if (notify_die(DIE_OOPS, str, regs, err,
487 - current->thread.trap_no, SIGSEGV) !=
489 + current->thread.trap_no, SIGSEGV) != NOTIFY_STOP) {
490 show_registers(regs);
491 + vxh_dump_history();
492 /* Executive summary in case the oops scrolled away */
493 esp = (unsigned long) (®s->esp);
495 diff -Nurp linux-2.6.22.18/arch/i386/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/i386/mm/fault.c
496 --- linux-2.6.22.18/arch/i386/mm/fault.c 2007-09-05 07:07:59.000000000 +0200
497 +++ linux-2.6.22.18-vs2.3.0.32/arch/i386/mm/fault.c 2008-02-11 12:35:32.000000000 +0100
498 @@ -587,7 +587,8 @@ out_of_memory:
499 down_read(&mm->mmap_sem);
502 - printk("VM: killing process %s\n", tsk->comm);
503 + printk("VM: killing process %s(%d:#%u)\n",
504 + tsk->comm, tsk->pid, tsk->xid);
508 diff -Nurp linux-2.6.22.18/arch/ia64/ia32/binfmt_elf32.c linux-2.6.22.18-vs2.3.0.32/arch/ia64/ia32/binfmt_elf32.c
509 --- linux-2.6.22.18/arch/ia64/ia32/binfmt_elf32.c 2007-07-21 23:58:15.000000000 +0200
510 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/ia32/binfmt_elf32.c 2008-02-11 12:35:32.000000000 +0100
511 @@ -233,7 +233,8 @@ ia32_setup_arg_pages (struct linux_binpr
512 kmem_cache_free(vm_area_cachep, mpnt);
515 - current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt);
516 + vx_vmpages_sub(current->mm, current->mm->total_vm - vma_pages(mpnt));
517 + current->mm->stack_vm = current->mm->total_vm;
520 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
521 diff -Nurp linux-2.6.22.18/arch/ia64/ia32/ia32_entry.S linux-2.6.22.18-vs2.3.0.32/arch/ia64/ia32/ia32_entry.S
522 --- linux-2.6.22.18/arch/ia64/ia32/ia32_entry.S 2007-07-21 23:59:45.000000000 +0200
523 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/ia32/ia32_entry.S 2008-02-11 12:35:32.000000000 +0100
524 @@ -446,7 +446,7 @@ ia32_syscall_table:
525 data8 sys_tgkill /* 270 */
526 data8 compat_sys_utimes
527 data8 sys32_fadvise64_64
528 - data8 sys_ni_syscall
529 + data8 sys32_vserver
531 data8 sys_ni_syscall /* 275 */
533 diff -Nurp linux-2.6.22.18/arch/ia64/ia32/sys_ia32.c linux-2.6.22.18-vs2.3.0.32/arch/ia64/ia32/sys_ia32.c
534 --- linux-2.6.22.18/arch/ia64/ia32/sys_ia32.c 2007-07-21 23:58:15.000000000 +0200
535 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/ia32/sys_ia32.c 2008-02-11 12:35:32.000000000 +0100
536 @@ -1182,7 +1182,7 @@ sys32_gettimeofday (struct compat_timeva
540 - do_gettimeofday(&ktv);
541 + vx_gettimeofday(&ktv);
542 if (put_tv32(tv, &ktv))
545 diff -Nurp linux-2.6.22.18/arch/ia64/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/ia64/Kconfig
546 --- linux-2.6.22.18/arch/ia64/Kconfig 2007-07-21 23:59:45.000000000 +0200
547 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/Kconfig 2008-02-11 12:35:32.000000000 +0100
548 @@ -592,6 +592,8 @@ endmenu
550 source "arch/ia64/Kconfig.debug"
552 +source "kernel/vserver/Kconfig"
554 source "security/Kconfig"
556 source "crypto/Kconfig"
557 diff -Nurp linux-2.6.22.18/arch/ia64/kernel/asm-offsets.c linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/asm-offsets.c
558 --- linux-2.6.22.18/arch/ia64/kernel/asm-offsets.c 2007-07-21 23:58:15.000000000 +0200
559 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/asm-offsets.c 2008-02-11 12:35:32.000000000 +0100
560 @@ -192,6 +192,7 @@ void foo(void)
561 /* for assembly files which can't include sched.h: */
562 DEFINE(IA64_CLONE_VFORK, CLONE_VFORK);
563 DEFINE(IA64_CLONE_VM, CLONE_VM);
564 + DEFINE(IA64_CLONE_KTHREAD, CLONE_KTHREAD);
567 DEFINE(IA64_CPUINFO_NSEC_PER_CYC_OFFSET,
568 diff -Nurp linux-2.6.22.18/arch/ia64/kernel/entry.S linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/entry.S
569 --- linux-2.6.22.18/arch/ia64/kernel/entry.S 2007-07-21 23:59:45.000000000 +0200
570 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/entry.S 2008-02-11 12:35:32.000000000 +0100
571 @@ -1547,7 +1547,7 @@ sys_call_table:
573 data8 sys_mq_getsetattr
575 - data8 sys_ni_syscall // reserved for vserver
577 data8 sys_waitid // 1270
579 data8 sys_request_key
580 diff -Nurp linux-2.6.22.18/arch/ia64/kernel/perfmon.c linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/perfmon.c
581 --- linux-2.6.22.18/arch/ia64/kernel/perfmon.c 2007-07-21 23:59:45.000000000 +0200
582 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/perfmon.c 2008-02-11 12:35:32.000000000 +0100
584 #include <linux/capability.h>
585 #include <linux/rcupdate.h>
586 #include <linux/completion.h>
587 +#include <linux/vs_memory.h>
589 #include <asm/errno.h>
590 #include <asm/intrinsics.h>
591 @@ -2395,7 +2396,7 @@ pfm_smpl_buffer_alloc(struct task_struct
593 insert_vm_struct(mm, vma);
595 - mm->total_vm += size >> PAGE_SHIFT;
596 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
597 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
599 up_write(&task->mm->mmap_sem);
600 diff -Nurp linux-2.6.22.18/arch/ia64/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/process.c
601 --- linux-2.6.22.18/arch/ia64/kernel/process.c 2007-07-21 23:59:45.000000000 +0200
602 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/process.c 2008-02-11 12:35:32.000000000 +0100
603 @@ -105,7 +105,8 @@ show_regs (struct pt_regs *regs)
604 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
607 - printk("\nPid: %d, CPU %d, comm: %20s\n", current->pid, smp_processor_id(), current->comm);
608 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n",
609 + current->pid, current->xid, smp_processor_id(), current->comm);
610 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s\n",
611 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted());
612 print_symbol("ip is at %s\n", ip);
613 @@ -696,7 +697,8 @@ kernel_thread (int (*fn)(void *), void *
614 regs.sw.ar_fpsr = regs.pt.ar_fpsr = ia64_getreg(_IA64_REG_AR_FPSR);
615 regs.sw.ar_bspstore = (unsigned long) current + IA64_RBS_OFFSET;
616 regs.sw.pr = (1 << PRED_KERNEL_STACK);
617 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s.pt, 0, NULL, NULL);
618 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
619 + 0, ®s.pt, 0, NULL, NULL);
621 EXPORT_SYMBOL(kernel_thread);
623 diff -Nurp linux-2.6.22.18/arch/ia64/kernel/ptrace.c linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/ptrace.c
624 --- linux-2.6.22.18/arch/ia64/kernel/ptrace.c 2007-07-21 23:58:15.000000000 +0200
625 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/ptrace.c 2008-02-11 12:35:32.000000000 +0100
627 #include <linux/security.h>
628 #include <linux/audit.h>
629 #include <linux/signal.h>
630 +#include <linux/vs_base.h>
632 #include <asm/pgtable.h>
633 #include <asm/processor.h>
634 @@ -1443,6 +1444,9 @@ sys_ptrace (long request, pid_t pid, uns
635 read_unlock(&tasklist_lock);
638 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
642 if (pid == 1) /* no messing around with init! */
644 diff -Nurp linux-2.6.22.18/arch/ia64/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/traps.c
645 --- linux-2.6.22.18/arch/ia64/kernel/traps.c 2007-07-21 23:59:45.000000000 +0200
646 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/kernel/traps.c 2008-02-11 12:35:32.000000000 +0100
647 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
650 if (++die.lock_owner_depth < 3) {
651 - printk("%s[%d]: %s %ld [%d]\n",
652 - current->comm, current->pid, str, err, ++die_counter);
653 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
654 + current->comm, current->pid, current->xid,
655 + str, err, ++die_counter);
656 (void) notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV);
659 @@ -313,8 +314,9 @@ handle_fpu_swa (int fp_fault, struct pt_
660 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
661 last.time = current_jiffies + 5 * HZ;
663 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
664 - current->comm, current->pid, regs->cr_iip + ia64_psr(regs)->ri, isr);
665 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
666 + current->comm, current->pid, current->xid,
667 + regs->cr_iip + ia64_psr(regs)->ri, isr);
671 diff -Nurp linux-2.6.22.18/arch/ia64/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/ia64/mm/fault.c
672 --- linux-2.6.22.18/arch/ia64/mm/fault.c 2007-07-21 23:59:45.000000000 +0200
673 +++ linux-2.6.22.18-vs2.3.0.32/arch/ia64/mm/fault.c 2008-02-11 12:35:32.000000000 +0100
675 #include <linux/interrupt.h>
676 #include <linux/kprobes.h>
677 #include <linux/kdebug.h>
678 +#include <linux/vs_memory.h>
680 #include <asm/pgtable.h>
681 #include <asm/processor.h>
682 diff -Nurp linux-2.6.22.18/arch/m32r/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/m32r/kernel/process.c
683 --- linux-2.6.22.18/arch/m32r/kernel/process.c 2007-07-21 23:58:15.000000000 +0200
684 +++ linux-2.6.22.18-vs2.3.0.32/arch/m32r/kernel/process.c 2008-02-11 12:35:32.000000000 +0100
685 @@ -211,8 +211,8 @@ int kernel_thread(int (*fn)(void *), voi
686 regs.psw = M32R_PSW_BIE;
688 /* Ok, create the new process. */
689 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL,
691 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
692 + 0, ®s, 0, NULL, NULL);
696 diff -Nurp linux-2.6.22.18/arch/m32r/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/m32r/kernel/traps.c
697 --- linux-2.6.22.18/arch/m32r/kernel/traps.c 2007-05-04 15:57:13.000000000 +0200
698 +++ linux-2.6.22.18-vs2.3.0.32/arch/m32r/kernel/traps.c 2008-02-11 12:35:32.000000000 +0100
699 @@ -195,8 +195,9 @@ static void show_registers(struct pt_reg
701 printk("SPI: %08lx\n", sp);
703 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
704 - current->comm, current->pid, 0xffff & i, 4096+(unsigned long)current);
705 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
706 + current->comm, current->pid, current->xid,
707 + 0xffff & i, 4096+(unsigned long)current);
710 * When in-kernel, we also print out the stack and code at the
711 diff -Nurp linux-2.6.22.18/arch/m68k/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/m68k/Kconfig
712 --- linux-2.6.22.18/arch/m68k/Kconfig 2007-07-21 23:59:45.000000000 +0200
713 +++ linux-2.6.22.18-vs2.3.0.32/arch/m68k/Kconfig 2008-02-11 12:35:32.000000000 +0100
714 @@ -678,6 +678,8 @@ source "fs/Kconfig"
716 source "arch/m68k/Kconfig.debug"
718 +source "kernel/vserver/Kconfig"
720 source "security/Kconfig"
722 source "crypto/Kconfig"
723 diff -Nurp linux-2.6.22.18/arch/m68k/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/m68k/kernel/process.c
724 --- linux-2.6.22.18/arch/m68k/kernel/process.c 2007-05-04 15:57:14.000000000 +0200
725 +++ linux-2.6.22.18-vs2.3.0.32/arch/m68k/kernel/process.c 2008-02-11 12:35:32.000000000 +0100
726 @@ -159,7 +159,8 @@ int kernel_thread(int (*fn)(void *), voi
729 register long retval __asm__ ("d0");
730 - register long clone_arg __asm__ ("d1") = flags | CLONE_VM | CLONE_UNTRACED;
731 + register long clone_arg __asm__ ("d1") =
732 + flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
736 diff -Nurp linux-2.6.22.18/arch/m68k/kernel/ptrace.c linux-2.6.22.18-vs2.3.0.32/arch/m68k/kernel/ptrace.c
737 --- linux-2.6.22.18/arch/m68k/kernel/ptrace.c 2007-07-21 23:59:45.000000000 +0200
738 +++ linux-2.6.22.18-vs2.3.0.32/arch/m68k/kernel/ptrace.c 2008-02-11 12:35:32.000000000 +0100
740 #include <linux/ptrace.h>
741 #include <linux/user.h>
742 #include <linux/signal.h>
743 +#include <linux/vs_base.h>
745 #include <asm/uaccess.h>
746 #include <asm/page.h>
747 @@ -278,6 +279,8 @@ long arch_ptrace(struct task_struct *chi
748 ret = ptrace_request(child, request, addr, data);
751 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
756 diff -Nurp linux-2.6.22.18/arch/m68k/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/m68k/kernel/traps.c
757 --- linux-2.6.22.18/arch/m68k/kernel/traps.c 2007-07-21 23:58:15.000000000 +0200
758 +++ linux-2.6.22.18-vs2.3.0.32/arch/m68k/kernel/traps.c 2008-02-11 12:35:32.000000000 +0100
759 @@ -899,8 +899,8 @@ void show_registers(struct pt_regs *regs
760 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
761 regs->d4, regs->d5, regs->a0, regs->a1);
763 - printk("Process %s (pid: %d, task=%p)\n",
764 - current->comm, current->pid, current);
765 + printk("Process %s (pid: %d[#%u], task=%p)\n",
766 + current->comm, current->pid, current->xid, current);
767 addr = (unsigned long)&fp->un;
768 printk("Frame format=%X ", regs->format);
769 switch (regs->format) {
770 diff -Nurp linux-2.6.22.18/arch/m68knommu/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/m68knommu/Kconfig
771 --- linux-2.6.22.18/arch/m68knommu/Kconfig 2007-07-21 23:59:45.000000000 +0200
772 +++ linux-2.6.22.18-vs2.3.0.32/arch/m68knommu/Kconfig 2008-02-11 12:35:32.000000000 +0100
773 @@ -670,6 +670,8 @@ source "fs/Kconfig"
775 source "arch/m68knommu/Kconfig.debug"
777 +source "kernel/vserver/Kconfig"
779 source "security/Kconfig"
781 source "crypto/Kconfig"
782 diff -Nurp linux-2.6.22.18/arch/m68knommu/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/m68knommu/kernel/process.c
783 --- linux-2.6.22.18/arch/m68knommu/kernel/process.c 2007-05-04 15:58:04.000000000 +0200
784 +++ linux-2.6.22.18-vs2.3.0.32/arch/m68knommu/kernel/process.c 2008-02-11 12:35:32.000000000 +0100
785 @@ -122,7 +122,7 @@ void show_regs(struct pt_regs * regs)
786 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
789 - long clone_arg = flags | CLONE_VM;
790 + long clone_arg = flags | CLONE_VM | CLONE_KTHREAD;
794 diff -Nurp linux-2.6.22.18/arch/m68knommu/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/m68knommu/kernel/traps.c
795 --- linux-2.6.22.18/arch/m68knommu/kernel/traps.c 2007-07-21 23:58:15.000000000 +0200
796 +++ linux-2.6.22.18-vs2.3.0.32/arch/m68knommu/kernel/traps.c 2008-02-11 12:35:32.000000000 +0100
797 @@ -80,8 +80,9 @@ void die_if_kernel(char *str, struct pt_
798 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
799 fp->d4, fp->d5, fp->a0, fp->a1);
801 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
802 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
803 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
804 + current->comm, current->pid, current->xid,
805 + PAGE_SIZE+(unsigned long)current);
806 show_stack(NULL, (unsigned long *)fp);
809 diff -Nurp linux-2.6.22.18/arch/mips/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/mips/Kconfig
810 --- linux-2.6.22.18/arch/mips/Kconfig 2007-07-21 23:59:45.000000000 +0200
811 +++ linux-2.6.22.18-vs2.3.0.32/arch/mips/Kconfig 2008-02-11 12:35:32.000000000 +0100
812 @@ -1959,6 +1959,8 @@ source "arch/mips/oprofile/Kconfig"
814 source "arch/mips/Kconfig.debug"
816 +source "kernel/vserver/Kconfig"
818 source "security/Kconfig"
820 source "crypto/Kconfig"
821 diff -Nurp linux-2.6.22.18/arch/mips/kernel/linux32.c linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/linux32.c
822 --- linux-2.6.22.18/arch/mips/kernel/linux32.c 2007-07-21 23:59:45.000000000 +0200
823 +++ linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/linux32.c 2008-02-11 12:35:32.000000000 +0100
824 @@ -229,7 +229,7 @@ sys32_gettimeofday(struct compat_timeval
828 - do_gettimeofday(&ktv);
829 + vx_gettimeofday(&ktv);
830 if (put_tv32(tv, &ktv))
833 diff -Nurp linux-2.6.22.18/arch/mips/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/process.c
834 --- linux-2.6.22.18/arch/mips/kernel/process.c 2007-07-21 23:58:16.000000000 +0200
835 +++ linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/process.c 2008-02-11 12:35:32.000000000 +0100
836 @@ -236,7 +236,8 @@ long kernel_thread(int (*fn)(void *), vo
839 /* Ok, create the new process.. */
840 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
841 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
842 + 0, ®s, 0, NULL, NULL);
846 diff -Nurp linux-2.6.22.18/arch/mips/kernel/ptrace.c linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/ptrace.c
847 --- linux-2.6.22.18/arch/mips/kernel/ptrace.c 2007-07-21 23:59:45.000000000 +0200
848 +++ linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/ptrace.c 2008-02-11 12:35:32.000000000 +0100
850 #include <linux/user.h>
851 #include <linux/security.h>
852 #include <linux/signal.h>
853 +#include <linux/vs_base.h>
855 #include <asm/byteorder.h>
857 @@ -171,6 +172,9 @@ long arch_ptrace(struct task_struct *chi
861 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
865 /* when I and D space are separate, these will need to be fixed. */
866 case PTRACE_PEEKTEXT: /* read word at location addr. */
867 diff -Nurp linux-2.6.22.18/arch/mips/kernel/scall32-o32.S linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/scall32-o32.S
868 --- linux-2.6.22.18/arch/mips/kernel/scall32-o32.S 2007-07-21 23:59:45.000000000 +0200
869 +++ linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/scall32-o32.S 2008-02-11 12:35:32.000000000 +0100
870 @@ -619,7 +619,7 @@ einval: li v0, -EINVAL
871 sys sys_mq_timedreceive 5
872 sys sys_mq_notify 2 /* 4275 */
873 sys sys_mq_getsetattr 3
874 - sys sys_ni_syscall 0 /* sys_vserver */
877 sys sys_ni_syscall 0 /* available, was setaltroot */
878 sys sys_add_key 5 /* 4280 */
879 diff -Nurp linux-2.6.22.18/arch/mips/kernel/scall64-64.S linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/scall64-64.S
880 --- linux-2.6.22.18/arch/mips/kernel/scall64-64.S 2007-07-21 23:59:45.000000000 +0200
881 +++ linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/scall64-64.S 2008-02-11 12:35:32.000000000 +0100
882 @@ -434,7 +434,7 @@ sys_call_table:
883 PTR sys_mq_timedreceive
885 PTR sys_mq_getsetattr /* 5235 */
886 - PTR sys_ni_syscall /* sys_vserver */
889 PTR sys_ni_syscall /* available, was setaltroot */
891 diff -Nurp linux-2.6.22.18/arch/mips/kernel/scall64-n32.S linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/scall64-n32.S
892 --- linux-2.6.22.18/arch/mips/kernel/scall64-n32.S 2007-07-21 23:59:45.000000000 +0200
893 +++ linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/scall64-n32.S 2008-02-11 12:35:32.000000000 +0100
894 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
895 PTR compat_sys_mq_timedreceive
896 PTR compat_sys_mq_notify
897 PTR compat_sys_mq_getsetattr
898 - PTR sys_ni_syscall /* 6240, sys_vserver */
899 + PTR sys32_vserver /* 6240 */
900 PTR compat_sys_waitid
901 PTR sys_ni_syscall /* available, was setaltroot */
903 diff -Nurp linux-2.6.22.18/arch/mips/kernel/scall64-o32.S linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/scall64-o32.S
904 --- linux-2.6.22.18/arch/mips/kernel/scall64-o32.S 2007-07-21 23:59:45.000000000 +0200
905 +++ linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/scall64-o32.S 2008-02-11 12:35:32.000000000 +0100
906 @@ -482,7 +482,7 @@ sys_call_table:
907 PTR compat_sys_mq_timedreceive
908 PTR compat_sys_mq_notify /* 4275 */
909 PTR compat_sys_mq_getsetattr
910 - PTR sys_ni_syscall /* sys_vserver */
913 PTR sys_ni_syscall /* available, was setaltroot */
914 PTR sys_add_key /* 4280 */
915 diff -Nurp linux-2.6.22.18/arch/mips/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/traps.c
916 --- linux-2.6.22.18/arch/mips/kernel/traps.c 2007-07-21 23:59:48.000000000 +0200
917 +++ linux-2.6.22.18-vs2.3.0.32/arch/mips/kernel/traps.c 2008-02-11 12:35:32.000000000 +0100
918 @@ -302,8 +302,9 @@ void show_registers(struct pt_regs *regs
922 - printk("Process %s (pid: %d, threadinfo=%p, task=%p)\n",
923 - current->comm, current->pid, current_thread_info(), current);
924 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p)\n",
925 + current->comm, current->pid, current->xid,
926 + current_thread_info(), current);
927 show_stacktrace(current, regs);
928 show_code((unsigned int *) regs->cp0_epc);
930 diff -Nurp linux-2.6.22.18/arch/mips/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/mips/mm/fault.c
931 --- linux-2.6.22.18/arch/mips/mm/fault.c 2007-07-21 23:59:48.000000000 +0200
932 +++ linux-2.6.22.18-vs2.3.0.32/arch/mips/mm/fault.c 2008-02-11 12:35:32.000000000 +0100
933 @@ -179,7 +179,8 @@ out_of_memory:
934 down_read(&mm->mmap_sem);
937 - printk("VM: killing process %s\n", tsk->comm);
938 + printk("VM: killing process %s(%d:#%u)\n",
939 + tsk->comm, tsk->pid, tsk->xid);
943 diff -Nurp linux-2.6.22.18/arch/parisc/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/parisc/Kconfig
944 --- linux-2.6.22.18/arch/parisc/Kconfig 2007-07-21 23:58:18.000000000 +0200
945 +++ linux-2.6.22.18-vs2.3.0.32/arch/parisc/Kconfig 2008-02-11 12:35:32.000000000 +0100
946 @@ -271,6 +271,8 @@ source "arch/parisc/oprofile/Kconfig"
948 source "arch/parisc/Kconfig.debug"
950 +source "kernel/vserver/Kconfig"
952 source "security/Kconfig"
954 source "crypto/Kconfig"
955 diff -Nurp linux-2.6.22.18/arch/parisc/kernel/entry.S linux-2.6.22.18-vs2.3.0.32/arch/parisc/kernel/entry.S
956 --- linux-2.6.22.18/arch/parisc/kernel/entry.S 2007-07-21 23:59:48.000000000 +0200
957 +++ linux-2.6.22.18-vs2.3.0.32/arch/parisc/kernel/entry.S 2008-02-11 12:35:32.000000000 +0100
958 @@ -761,6 +761,7 @@ END(fault_vector_11)
960 #define CLONE_VM 0x100 /* Must agree with <linux/sched.h> */
961 #define CLONE_UNTRACED 0x00800000
962 +#define CLONE_KTHREAD 0x10000000
965 ENTRY(__kernel_thread)
966 diff -Nurp linux-2.6.22.18/arch/parisc/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/parisc/kernel/process.c
967 --- linux-2.6.22.18/arch/parisc/kernel/process.c 2007-07-21 23:59:48.000000000 +0200
968 +++ linux-2.6.22.18-vs2.3.0.32/arch/parisc/kernel/process.c 2008-02-11 12:35:32.000000000 +0100
969 @@ -173,7 +173,7 @@ pid_t kernel_thread(int (*fn)(void *), v
970 * kernel_thread can become a #define.
973 - return __kernel_thread(fn, arg, flags);
974 + return __kernel_thread(fn, arg, flags | CLONE_KTHREAD);
976 EXPORT_SYMBOL(kernel_thread);
978 diff -Nurp linux-2.6.22.18/arch/parisc/kernel/syscall_table.S linux-2.6.22.18-vs2.3.0.32/arch/parisc/kernel/syscall_table.S
979 --- linux-2.6.22.18/arch/parisc/kernel/syscall_table.S 2007-07-21 23:59:48.000000000 +0200
980 +++ linux-2.6.22.18-vs2.3.0.32/arch/parisc/kernel/syscall_table.S 2008-02-11 12:35:32.000000000 +0100
982 ENTRY_COMP(mbind) /* 260 */
983 ENTRY_COMP(get_mempolicy)
984 ENTRY_COMP(set_mempolicy)
985 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
986 + ENTRY_DIFF(vserver)
988 ENTRY_SAME(request_key) /* 265 */
990 diff -Nurp linux-2.6.22.18/arch/parisc/kernel/sys_parisc32.c linux-2.6.22.18-vs2.3.0.32/arch/parisc/kernel/sys_parisc32.c
991 --- linux-2.6.22.18/arch/parisc/kernel/sys_parisc32.c 2007-07-21 23:59:48.000000000 +0200
992 +++ linux-2.6.22.18-vs2.3.0.32/arch/parisc/kernel/sys_parisc32.c 2008-02-11 12:35:32.000000000 +0100
993 @@ -204,11 +204,11 @@ static inline long get_ts32(struct times
995 sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
997 - extern void do_gettimeofday(struct timeval *tv);
998 + extern void vx_gettimeofday(struct timeval *tv);
1002 - do_gettimeofday(&ktv);
1003 + vx_gettimeofday(&ktv);
1004 if (put_compat_timeval(tv, &ktv))
1007 diff -Nurp linux-2.6.22.18/arch/parisc/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/parisc/kernel/traps.c
1008 --- linux-2.6.22.18/arch/parisc/kernel/traps.c 2007-07-21 23:59:48.000000000 +0200
1009 +++ linux-2.6.22.18-vs2.3.0.32/arch/parisc/kernel/traps.c 2008-02-11 12:35:32.000000000 +0100
1010 @@ -218,8 +218,9 @@ void die_if_kernel(char *str, struct pt_
1014 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
1015 - current->comm, current->pid, str, err, regs->iaoq[0]);
1016 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
1017 + current->comm, current->pid, current->xid,
1018 + str, err, regs->iaoq[0]);
1019 #ifdef PRINT_USER_FAULTS
1020 /* XXX for debugging only */
1022 @@ -251,8 +252,8 @@ KERN_CRIT " || |
1023 pdc_console_restart();
1026 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
1027 - current->comm, current->pid, str, err);
1028 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
1029 + current->comm, current->pid, current->xid, str, err);
1031 /* Wot's wrong wif bein' racy? */
1032 if (current->thread.flags & PARISC_KERNEL_DEATH) {
1033 diff -Nurp linux-2.6.22.18/arch/parisc/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/parisc/mm/fault.c
1034 --- linux-2.6.22.18/arch/parisc/mm/fault.c 2007-07-21 23:58:18.000000000 +0200
1035 +++ linux-2.6.22.18-vs2.3.0.32/arch/parisc/mm/fault.c 2008-02-11 12:35:32.000000000 +0100
1036 @@ -209,8 +209,9 @@ bad_area:
1038 #ifdef PRINT_USER_FAULTS
1039 printk(KERN_DEBUG "\n");
1040 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
1041 - tsk->pid, tsk->comm, code, address);
1042 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
1043 + "command='%s' type=%lu address=0x%08lx\n",
1044 + tsk->pid, tsk->xid, tsk->comm, code, address);
1046 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
1047 vma->vm_start, vma->vm_end);
1048 @@ -260,7 +261,8 @@ no_context:
1051 up_read(&mm->mmap_sem);
1052 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
1053 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
1054 + current->comm, current->pid, current->xid);
1055 if (user_mode(regs))
1058 diff -Nurp linux-2.6.22.18/arch/powerpc/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/powerpc/Kconfig
1059 --- linux-2.6.22.18/arch/powerpc/Kconfig 2007-07-21 23:59:48.000000000 +0200
1060 +++ linux-2.6.22.18-vs2.3.0.32/arch/powerpc/Kconfig 2008-02-11 12:35:32.000000000 +0100
1061 @@ -906,6 +906,8 @@ endmenu
1063 source "arch/powerpc/Kconfig.debug"
1065 +source "kernel/vserver/Kconfig"
1067 source "security/Kconfig"
1070 diff -Nurp linux-2.6.22.18/arch/powerpc/kernel/asm-offsets.c linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/asm-offsets.c
1071 --- linux-2.6.22.18/arch/powerpc/kernel/asm-offsets.c 2007-07-21 23:59:48.000000000 +0200
1072 +++ linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/asm-offsets.c 2008-02-11 12:35:32.000000000 +0100
1073 @@ -250,6 +250,7 @@ int main(void)
1075 DEFINE(CLONE_VM, CLONE_VM);
1076 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
1077 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
1079 #ifndef CONFIG_PPC64
1080 DEFINE(MM_PGD, offsetof(struct mm_struct, pgd));
1081 diff -Nurp linux-2.6.22.18/arch/powerpc/kernel/irq.c linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/irq.c
1082 --- linux-2.6.22.18/arch/powerpc/kernel/irq.c 2007-07-21 23:59:48.000000000 +0200
1083 +++ linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/irq.c 2008-02-11 12:35:32.000000000 +0100
1085 #include <linux/mutex.h>
1086 #include <linux/bootmem.h>
1087 #include <linux/pci.h>
1088 +#include <linux/vs_context.h>
1090 #include <asm/uaccess.h>
1091 #include <asm/system.h>
1092 diff -Nurp linux-2.6.22.18/arch/powerpc/kernel/misc_32.S linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/misc_32.S
1093 --- linux-2.6.22.18/arch/powerpc/kernel/misc_32.S 2007-07-21 23:59:48.000000000 +0200
1094 +++ linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/misc_32.S 2008-02-11 12:35:32.000000000 +0100
1095 @@ -745,7 +745,7 @@ _GLOBAL(kernel_thread)
1096 mr r30,r3 /* function */
1097 mr r31,r4 /* argument */
1098 ori r3,r5,CLONE_VM /* flags */
1099 - oris r3,r3,CLONE_UNTRACED>>16
1100 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1101 li r4,0 /* new sp (unused) */
1104 diff -Nurp linux-2.6.22.18/arch/powerpc/kernel/misc_64.S linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/misc_64.S
1105 --- linux-2.6.22.18/arch/powerpc/kernel/misc_64.S 2007-07-21 23:58:18.000000000 +0200
1106 +++ linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/misc_64.S 2008-02-11 12:35:32.000000000 +0100
1107 @@ -434,7 +434,7 @@ _GLOBAL(kernel_thread)
1110 ori r3,r5,CLONE_VM /* flags */
1111 - oris r3,r3,(CLONE_UNTRACED>>16)
1112 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1113 li r4,0 /* new sp (unused) */
1116 diff -Nurp linux-2.6.22.18/arch/powerpc/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/process.c
1117 --- linux-2.6.22.18/arch/powerpc/kernel/process.c 2007-09-29 14:11:48.000000000 +0200
1118 +++ linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/process.c 2008-02-11 12:35:32.000000000 +0100
1119 @@ -422,8 +422,9 @@ void show_regs(struct pt_regs * regs)
1121 if (trap == 0x300 || trap == 0x600)
1122 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
1123 - printk("TASK = %p[%d] '%s' THREAD: %p",
1124 - current, current->pid, current->comm, task_thread_info(current));
1125 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
1126 + current, current->pid, current->xid,
1127 + current->comm, task_thread_info(current));
1130 printk(" CPU: %d", smp_processor_id());
1131 diff -Nurp linux-2.6.22.18/arch/powerpc/kernel/sys_ppc32.c linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/sys_ppc32.c
1132 --- linux-2.6.22.18/arch/powerpc/kernel/sys_ppc32.c 2007-07-21 23:59:48.000000000 +0200
1133 +++ linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/sys_ppc32.c 2008-02-11 12:35:32.000000000 +0100
1134 @@ -205,7 +205,7 @@ asmlinkage long compat_sys_gettimeofday(
1138 - do_gettimeofday(&ktv);
1139 + vx_gettimeofday(&ktv);
1140 if (put_tv32(tv, &ktv))
1143 diff -Nurp linux-2.6.22.18/arch/powerpc/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/traps.c
1144 --- linux-2.6.22.18/arch/powerpc/kernel/traps.c 2007-07-21 23:59:48.000000000 +0200
1145 +++ linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/traps.c 2008-02-11 12:35:32.000000000 +0100
1146 @@ -878,8 +878,9 @@ void nonrecoverable_exception(struct pt_
1148 void trace_syscall(struct pt_regs *regs)
1150 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1151 - current, current->pid, regs->nip, regs->link, regs->gpr[0],
1152 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1153 + current, current->pid, current->xid,
1154 + regs->nip, regs->link, regs->gpr[0],
1155 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
1158 diff -Nurp linux-2.6.22.18/arch/powerpc/kernel/vdso.c linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/vdso.c
1159 --- linux-2.6.22.18/arch/powerpc/kernel/vdso.c 2007-07-21 23:59:48.000000000 +0200
1160 +++ linux-2.6.22.18-vs2.3.0.32/arch/powerpc/kernel/vdso.c 2008-02-11 12:35:32.000000000 +0100
1162 #include <linux/elf.h>
1163 #include <linux/security.h>
1164 #include <linux/bootmem.h>
1165 +#include <linux/vs_memory.h>
1167 #include <asm/pgtable.h>
1168 #include <asm/system.h>
1169 diff -Nurp linux-2.6.22.18/arch/powerpc/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/powerpc/mm/fault.c
1170 --- linux-2.6.22.18/arch/powerpc/mm/fault.c 2007-07-21 23:59:48.000000000 +0200
1171 +++ linux-2.6.22.18-vs2.3.0.32/arch/powerpc/mm/fault.c 2008-02-11 12:35:32.000000000 +0100
1172 @@ -378,7 +378,8 @@ out_of_memory:
1173 down_read(&mm->mmap_sem);
1176 - printk("VM: killing process %s\n", current->comm);
1177 + printk("VM: killing process %s(%d:#%u)\n",
1178 + current->comm, current->pid, current->xid);
1179 if (user_mode(regs))
1182 diff -Nurp linux-2.6.22.18/arch/ppc/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/ppc/Kconfig
1183 --- linux-2.6.22.18/arch/ppc/Kconfig 2007-07-21 23:58:19.000000000 +0200
1184 +++ linux-2.6.22.18-vs2.3.0.32/arch/ppc/Kconfig 2008-02-11 12:35:32.000000000 +0100
1185 @@ -1455,6 +1455,8 @@ source "arch/powerpc/oprofile/Kconfig"
1187 source "arch/ppc/Kconfig.debug"
1189 +source "kernel/vserver/Kconfig"
1191 source "security/Kconfig"
1193 source "crypto/Kconfig"
1194 diff -Nurp linux-2.6.22.18/arch/ppc/kernel/asm-offsets.c linux-2.6.22.18-vs2.3.0.32/arch/ppc/kernel/asm-offsets.c
1195 --- linux-2.6.22.18/arch/ppc/kernel/asm-offsets.c 2007-07-21 23:59:49.000000000 +0200
1196 +++ linux-2.6.22.18-vs2.3.0.32/arch/ppc/kernel/asm-offsets.c 2008-02-11 12:35:32.000000000 +0100
1197 @@ -120,6 +120,7 @@ main(void)
1198 DEFINE(TRAP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, trap));
1199 DEFINE(CLONE_VM, CLONE_VM);
1200 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
1201 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
1202 DEFINE(MM_PGD, offsetof(struct mm_struct, pgd));
1204 /* About the CPU features table */
1205 diff -Nurp linux-2.6.22.18/arch/ppc/kernel/misc.S linux-2.6.22.18-vs2.3.0.32/arch/ppc/kernel/misc.S
1206 --- linux-2.6.22.18/arch/ppc/kernel/misc.S 2007-05-04 15:57:15.000000000 +0200
1207 +++ linux-2.6.22.18-vs2.3.0.32/arch/ppc/kernel/misc.S 2008-02-11 12:35:32.000000000 +0100
1208 @@ -848,7 +848,7 @@ _GLOBAL(kernel_thread)
1209 mr r30,r3 /* function */
1210 mr r31,r4 /* argument */
1211 ori r3,r5,CLONE_VM /* flags */
1212 - oris r3,r3,CLONE_UNTRACED>>16
1213 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1214 li r4,0 /* new sp (unused) */
1217 diff -Nurp linux-2.6.22.18/arch/ppc/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/ppc/kernel/traps.c
1218 --- linux-2.6.22.18/arch/ppc/kernel/traps.c 2007-07-21 23:59:49.000000000 +0200
1219 +++ linux-2.6.22.18-vs2.3.0.32/arch/ppc/kernel/traps.c 2008-02-11 12:35:32.000000000 +0100
1220 @@ -696,8 +696,9 @@ void nonrecoverable_exception(struct pt_
1222 void trace_syscall(struct pt_regs *regs)
1224 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1225 - current, current->pid, regs->nip, regs->link, regs->gpr[0],
1226 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1227 + current, current->pid, current->xid,
1228 + regs->nip, regs->link, regs->gpr[0],
1229 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
1232 diff -Nurp linux-2.6.22.18/arch/ppc/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/ppc/mm/fault.c
1233 --- linux-2.6.22.18/arch/ppc/mm/fault.c 2007-05-04 15:57:15.000000000 +0200
1234 +++ linux-2.6.22.18-vs2.3.0.32/arch/ppc/mm/fault.c 2008-02-11 12:35:32.000000000 +0100
1235 @@ -296,7 +296,8 @@ out_of_memory:
1236 down_read(&mm->mmap_sem);
1239 - printk("VM: killing process %s\n", current->comm);
1240 + printk("VM: killing process %s(%d:#%u)\n",
1241 + current->comm, current->pid, current->xid);
1242 if (user_mode(regs))
1245 diff -Nurp linux-2.6.22.18/arch/s390/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/s390/Kconfig
1246 --- linux-2.6.22.18/arch/s390/Kconfig 2007-07-21 23:59:49.000000000 +0200
1247 +++ linux-2.6.22.18-vs2.3.0.32/arch/s390/Kconfig 2008-02-11 12:35:32.000000000 +0100
1248 @@ -551,6 +551,8 @@ endmenu
1250 source "arch/s390/Kconfig.debug"
1252 +source "kernel/vserver/Kconfig"
1254 source "security/Kconfig"
1256 source "crypto/Kconfig"
1257 diff -Nurp linux-2.6.22.18/arch/s390/kernel/compat_linux.c linux-2.6.22.18-vs2.3.0.32/arch/s390/kernel/compat_linux.c
1258 --- linux-2.6.22.18/arch/s390/kernel/compat_linux.c 2007-07-21 23:59:49.000000000 +0200
1259 +++ linux-2.6.22.18-vs2.3.0.32/arch/s390/kernel/compat_linux.c 2008-02-11 12:35:32.000000000 +0100
1260 @@ -567,7 +567,7 @@ asmlinkage long sys32_gettimeofday(struc
1264 - do_gettimeofday(&ktv);
1265 + vx_gettimeofday(&ktv);
1266 if (put_tv32(tv, &ktv))
1269 diff -Nurp linux-2.6.22.18/arch/s390/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/s390/kernel/process.c
1270 --- linux-2.6.22.18/arch/s390/kernel/process.c 2007-07-21 23:59:49.000000000 +0200
1271 +++ linux-2.6.22.18-vs2.3.0.32/arch/s390/kernel/process.c 2008-02-11 12:35:32.000000000 +0100
1272 @@ -164,9 +164,9 @@ void show_regs(struct pt_regs *regs)
1273 struct task_struct *tsk = current;
1275 printk("CPU: %d %s\n", task_thread_info(tsk)->cpu, print_tainted());
1276 - printk("Process %s (pid: %d, task: %p, ksp: %p)\n",
1277 - current->comm, current->pid, (void *) tsk,
1278 - (void *) tsk->thread.ksp);
1279 + printk("Process %s (pid: %d[#%u], task: %p, ksp: %p)\n",
1280 + current->comm, current->pid, current->xid,
1281 + (void *) tsk, (void *) tsk->thread.ksp);
1283 show_registers(regs);
1284 /* Show stack backtrace if pt_regs is from kernel mode */
1285 @@ -197,7 +197,7 @@ int kernel_thread(int (*fn)(void *), voi
1286 regs.orig_gpr2 = -1;
1288 /* Ok, create the new process.. */
1289 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED,
1290 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
1291 0, ®s, 0, NULL, NULL);
1294 diff -Nurp linux-2.6.22.18/arch/s390/kernel/ptrace.c linux-2.6.22.18-vs2.3.0.32/arch/s390/kernel/ptrace.c
1295 --- linux-2.6.22.18/arch/s390/kernel/ptrace.c 2007-07-21 23:58:19.000000000 +0200
1296 +++ linux-2.6.22.18-vs2.3.0.32/arch/s390/kernel/ptrace.c 2008-02-11 12:35:32.000000000 +0100
1298 #include <linux/security.h>
1299 #include <linux/audit.h>
1300 #include <linux/signal.h>
1301 +#include <linux/vs_base.h>
1303 #include <asm/segment.h>
1304 #include <asm/page.h>
1305 @@ -725,7 +726,13 @@ sys_ptrace(long request, long pid, long
1309 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1314 ret = do_ptrace(child, request, addr, data);
1316 put_task_struct(child);
1319 diff -Nurp linux-2.6.22.18/arch/s390/kernel/syscalls.S linux-2.6.22.18-vs2.3.0.32/arch/s390/kernel/syscalls.S
1320 --- linux-2.6.22.18/arch/s390/kernel/syscalls.S 2007-07-21 23:59:49.000000000 +0200
1321 +++ linux-2.6.22.18-vs2.3.0.32/arch/s390/kernel/syscalls.S 2008-02-11 12:35:32.000000000 +0100
1322 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
1323 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
1324 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
1325 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
1326 -NI_SYSCALL /* reserved for vserver */
1327 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
1328 SYSCALL(s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
1329 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
1330 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
1331 diff -Nurp linux-2.6.22.18/arch/s390/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/s390/mm/fault.c
1332 --- linux-2.6.22.18/arch/s390/mm/fault.c 2007-07-21 23:59:49.000000000 +0200
1333 +++ linux-2.6.22.18-vs2.3.0.32/arch/s390/mm/fault.c 2008-02-11 12:35:32.000000000 +0100
1334 @@ -216,7 +216,8 @@ static int do_out_of_memory(struct pt_re
1335 down_read(&mm->mmap_sem);
1338 - printk("VM: killing process %s\n", tsk->comm);
1339 + printk("VM: killing process %s(%d:#%u)\n",
1340 + tsk->comm, tsk->pid, tsk->xid);
1341 if (regs->psw.mask & PSW_MASK_PSTATE)
1343 do_no_context(regs, error_code, address);
1344 diff -Nurp linux-2.6.22.18/arch/sh/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/sh/Kconfig
1345 --- linux-2.6.22.18/arch/sh/Kconfig 2007-07-21 23:59:49.000000000 +0200
1346 +++ linux-2.6.22.18-vs2.3.0.32/arch/sh/Kconfig 2008-02-11 12:35:32.000000000 +0100
1347 @@ -723,6 +723,8 @@ source "arch/sh/oprofile/Kconfig"
1349 source "arch/sh/Kconfig.debug"
1351 +source "kernel/vserver/Kconfig"
1353 source "security/Kconfig"
1355 source "crypto/Kconfig"
1356 diff -Nurp linux-2.6.22.18/arch/sh/kernel/irq.c linux-2.6.22.18-vs2.3.0.32/arch/sh/kernel/irq.c
1357 --- linux-2.6.22.18/arch/sh/kernel/irq.c 2007-07-21 23:59:49.000000000 +0200
1358 +++ linux-2.6.22.18-vs2.3.0.32/arch/sh/kernel/irq.c 2008-02-11 12:35:33.000000000 +0100
1360 #include <linux/kernel_stat.h>
1361 #include <linux/seq_file.h>
1362 #include <linux/irq.h>
1363 +#include <linux/vs_context.h>
1364 #include <asm/processor.h>
1365 #include <asm/machvec.h>
1366 #include <asm/uaccess.h>
1367 diff -Nurp linux-2.6.22.18/arch/sh/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/sh/kernel/process.c
1368 --- linux-2.6.22.18/arch/sh/kernel/process.c 2007-07-21 23:59:49.000000000 +0200
1369 +++ linux-2.6.22.18-vs2.3.0.32/arch/sh/kernel/process.c 2008-02-11 12:35:33.000000000 +0100
1370 @@ -118,7 +118,8 @@ void machine_power_off(void)
1371 void show_regs(struct pt_regs * regs)
1374 - printk("Pid : %d, Comm: %20s\n", current->pid, current->comm);
1375 + printk("Pid : %d:#%u, Comm: %20s\n",
1376 + current->pid, current->xid, current->comm);
1377 print_symbol("PC is at %s\n", instruction_pointer(regs));
1378 printk("PC : %08lx SP : %08lx SR : %08lx ",
1379 regs->pc, regs->regs[15], regs->sr);
1380 @@ -179,7 +180,7 @@ int kernel_thread(int (*fn)(void *), voi
1381 regs.sr = (1 << 30);
1383 /* Ok, create the new process.. */
1384 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
1385 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD, 0,
1386 ®s, 0, NULL, NULL);
1389 diff -Nurp linux-2.6.22.18/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.22.18-vs2.3.0.32/arch/sh/kernel/vsyscall/vsyscall.c
1390 --- linux-2.6.22.18/arch/sh/kernel/vsyscall/vsyscall.c 2007-07-21 23:59:49.000000000 +0200
1391 +++ linux-2.6.22.18-vs2.3.0.32/arch/sh/kernel/vsyscall/vsyscall.c 2008-02-11 12:35:33.000000000 +0100
1393 #include <linux/module.h>
1394 #include <linux/elf.h>
1395 #include <linux/sched.h>
1396 +#include <linux/vs_memory.h>
1399 * Should the kernel map a VDSO page into processes and pass its
1400 diff -Nurp linux-2.6.22.18/arch/sh/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/sh/mm/fault.c
1401 --- linux-2.6.22.18/arch/sh/mm/fault.c 2007-07-21 23:59:49.000000000 +0200
1402 +++ linux-2.6.22.18-vs2.3.0.32/arch/sh/mm/fault.c 2008-02-11 12:35:33.000000000 +0100
1403 @@ -201,7 +201,8 @@ out_of_memory:
1404 down_read(&mm->mmap_sem);
1407 - printk("VM: killing process %s\n", tsk->comm);
1408 + printk("VM: killing process %s(%d:#%u)\n",
1409 + tsk->comm, tsk->pid, tsk->xid);
1410 if (user_mode(regs))
1413 diff -Nurp linux-2.6.22.18/arch/sh64/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/sh64/kernel/process.c
1414 --- linux-2.6.22.18/arch/sh64/kernel/process.c 2007-07-21 23:59:49.000000000 +0200
1415 +++ linux-2.6.22.18-vs2.3.0.32/arch/sh64/kernel/process.c 2008-02-11 12:35:33.000000000 +0100
1416 @@ -400,8 +400,8 @@ int kernel_thread(int (*fn)(void *), voi
1417 regs.pc = (unsigned long)kernel_thread_helper;
1418 regs.sr = (1 << 30);
1420 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
1421 - ®s, 0, NULL, NULL);
1422 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
1423 + 0, ®s, 0, NULL, NULL);
1427 diff -Nurp linux-2.6.22.18/arch/sh64/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/sh64/mm/fault.c
1428 --- linux-2.6.22.18/arch/sh64/mm/fault.c 2007-07-21 23:59:49.000000000 +0200
1429 +++ linux-2.6.22.18-vs2.3.0.32/arch/sh64/mm/fault.c 2008-02-11 12:35:33.000000000 +0100
1430 @@ -81,7 +81,7 @@ static inline void print_vma(struct vm_a
1432 static inline void print_task(struct task_struct *tsk)
1434 - printk("Task pid %d\n", tsk->pid);
1435 + printk("Task pid %d:#%u\n", tsk->pid, tsk->xid);
1438 static pte_t *lookup_pte(struct mm_struct *mm, unsigned long address)
1439 @@ -330,7 +330,8 @@ out_of_memory:
1440 down_read(&mm->mmap_sem);
1443 - printk("VM: killing process %s\n", tsk->comm);
1444 + printk("VM: killing process %s(%d:#%u)\n",
1445 + tsk->comm, tsk->pid, tsk->xid);
1446 if (user_mode(regs))
1449 diff -Nurp linux-2.6.22.18/arch/sparc/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/sparc/Kconfig
1450 --- linux-2.6.22.18/arch/sparc/Kconfig 2007-07-21 23:59:49.000000000 +0200
1451 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc/Kconfig 2008-02-11 12:35:33.000000000 +0100
1452 @@ -317,6 +317,8 @@ endmenu
1454 source "arch/sparc/Kconfig.debug"
1456 +source "kernel/vserver/Kconfig"
1458 source "security/Kconfig"
1460 source "crypto/Kconfig"
1461 diff -Nurp linux-2.6.22.18/arch/sparc/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/sparc/kernel/process.c
1462 --- linux-2.6.22.18/arch/sparc/kernel/process.c 2007-07-21 23:59:49.000000000 +0200
1463 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc/kernel/process.c 2008-02-11 12:35:33.000000000 +0100
1464 @@ -705,7 +705,8 @@ pid_t kernel_thread(int (*fn)(void *), v
1465 /* Notreached by child. */
1466 "1: mov %%o0, %0\n\t" :
1468 - "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
1469 + "i" (__NR_clone), "r" (flags |
1470 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD),
1471 "i" (__NR_exit), "r" (fn), "r" (arg) :
1472 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
1474 diff -Nurp linux-2.6.22.18/arch/sparc/kernel/ptrace.c linux-2.6.22.18-vs2.3.0.32/arch/sparc/kernel/ptrace.c
1475 --- linux-2.6.22.18/arch/sparc/kernel/ptrace.c 2007-05-04 15:58:05.000000000 +0200
1476 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc/kernel/ptrace.c 2008-02-11 12:35:33.000000000 +0100
1478 #include <linux/smp_lock.h>
1479 #include <linux/security.h>
1480 #include <linux/signal.h>
1481 +#include <linux/vs_base.h>
1483 #include <asm/pgtable.h>
1484 #include <asm/system.h>
1485 @@ -302,6 +303,10 @@ asmlinkage void do_ptrace(struct pt_regs
1486 pt_error_return(regs, -ret);
1489 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1490 + pt_error_return(regs, ESRCH);
1494 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1495 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1496 diff -Nurp linux-2.6.22.18/arch/sparc/kernel/systbls.S linux-2.6.22.18-vs2.3.0.32/arch/sparc/kernel/systbls.S
1497 --- linux-2.6.22.18/arch/sparc/kernel/systbls.S 2007-07-21 23:59:49.000000000 +0200
1498 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc/kernel/systbls.S 2008-02-11 12:35:33.000000000 +0100
1499 @@ -71,7 +71,7 @@ sys_call_table:
1500 /*250*/ .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1501 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1502 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1503 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
1504 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1505 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1506 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1507 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
1508 diff -Nurp linux-2.6.22.18/arch/sparc/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/sparc/kernel/traps.c
1509 --- linux-2.6.22.18/arch/sparc/kernel/traps.c 2007-07-21 23:59:49.000000000 +0200
1510 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc/kernel/traps.c 2008-02-11 12:35:33.000000000 +0100
1511 @@ -99,7 +99,8 @@ void die_if_kernel(char *str, struct pt_
1515 - printk("%s(%d): %s [#%d]\n", current->comm, current->pid, str, ++die_counter);
1516 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
1517 + current->pid, current->xid, str, ++die_counter);
1520 __SAVE; __SAVE; __SAVE; __SAVE;
1521 diff -Nurp linux-2.6.22.18/arch/sparc/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/sparc/mm/fault.c
1522 --- linux-2.6.22.18/arch/sparc/mm/fault.c 2007-07-21 23:59:49.000000000 +0200
1523 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc/mm/fault.c 2008-02-11 12:35:33.000000000 +0100
1524 @@ -367,7 +367,8 @@ no_context:
1527 up_read(&mm->mmap_sem);
1528 - printk("VM: killing process %s\n", tsk->comm);
1529 + printk("VM: killing process %s(%d:#%u)\n",
1530 + tsk->comm, tsk->pid, tsk->xid);
1534 diff -Nurp linux-2.6.22.18/arch/sparc64/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/sparc64/Kconfig
1535 --- linux-2.6.22.18/arch/sparc64/Kconfig 2007-07-21 23:59:49.000000000 +0200
1536 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc64/Kconfig 2008-02-11 12:35:33.000000000 +0100
1537 @@ -451,6 +451,8 @@ endmenu
1539 source "arch/sparc64/Kconfig.debug"
1541 +source "kernel/vserver/Kconfig"
1543 source "security/Kconfig"
1545 source "crypto/Kconfig"
1546 diff -Nurp linux-2.6.22.18/arch/sparc64/kernel/binfmt_aout32.c linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/binfmt_aout32.c
1547 --- linux-2.6.22.18/arch/sparc64/kernel/binfmt_aout32.c 2007-05-04 15:58:05.000000000 +0200
1548 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/binfmt_aout32.c 2008-02-11 12:35:33.000000000 +0100
1550 #include <linux/binfmts.h>
1551 #include <linux/personality.h>
1552 #include <linux/init.h>
1553 +#include <linux/vs_memory.h>
1555 #include <asm/system.h>
1556 #include <asm/uaccess.h>
1557 diff -Nurp linux-2.6.22.18/arch/sparc64/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/process.c
1558 --- linux-2.6.22.18/arch/sparc64/kernel/process.c 2007-07-21 23:59:49.000000000 +0200
1559 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/process.c 2008-02-11 12:35:33.000000000 +0100
1560 @@ -707,7 +707,8 @@ pid_t kernel_thread(int (*fn)(void *), v
1561 /* Notreached by child. */
1564 - "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
1565 + "i" (__NR_clone), "r" (flags |
1566 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD),
1567 "i" (__NR_exit), "r" (fn), "r" (arg) :
1568 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
1570 diff -Nurp linux-2.6.22.18/arch/sparc64/kernel/ptrace.c linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/ptrace.c
1571 --- linux-2.6.22.18/arch/sparc64/kernel/ptrace.c 2007-05-04 15:58:05.000000000 +0200
1572 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/ptrace.c 2008-02-11 12:35:33.000000000 +0100
1574 #include <linux/seccomp.h>
1575 #include <linux/audit.h>
1576 #include <linux/signal.h>
1577 +#include <linux/vs_base.h>
1579 #include <asm/asi.h>
1580 #include <asm/pgtable.h>
1581 @@ -215,6 +216,10 @@ asmlinkage void do_ptrace(struct pt_regs
1582 pt_error_return(regs, -ret);
1585 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1586 + pt_error_return(regs, ESRCH);
1590 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1591 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1592 diff -Nurp linux-2.6.22.18/arch/sparc64/kernel/sys_sparc32.c linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/sys_sparc32.c
1593 --- linux-2.6.22.18/arch/sparc64/kernel/sys_sparc32.c 2007-07-21 23:59:49.000000000 +0200
1594 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/sys_sparc32.c 2008-02-11 12:35:33.000000000 +0100
1595 @@ -729,7 +729,7 @@ asmlinkage long sys32_gettimeofday(struc
1599 - do_gettimeofday(&ktv);
1600 + vx_gettimeofday(&ktv);
1601 if (put_tv32(tv, &ktv))
1604 diff -Nurp linux-2.6.22.18/arch/sparc64/kernel/systbls.S linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/systbls.S
1605 --- linux-2.6.22.18/arch/sparc64/kernel/systbls.S 2007-07-21 23:59:49.000000000 +0200
1606 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/systbls.S 2008-02-11 12:35:33.000000000 +0100
1607 @@ -72,7 +72,7 @@ sys_call_table32:
1608 /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
1609 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
1610 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
1611 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
1612 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
1613 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
1614 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
1615 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
1616 @@ -144,7 +144,7 @@ sys_call_table:
1617 /*250*/ .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1618 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1619 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1620 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
1621 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1622 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1623 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1624 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
1625 diff -Nurp linux-2.6.22.18/arch/sparc64/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/traps.c
1626 --- linux-2.6.22.18/arch/sparc64/kernel/traps.c 2007-09-05 07:07:59.000000000 +0200
1627 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc64/kernel/traps.c 2008-02-11 12:35:33.000000000 +0100
1628 @@ -2225,7 +2225,8 @@ void die_if_kernel(char *str, struct pt_
1632 - printk("%s(%d): %s [#%d]\n", current->comm, current->pid, str, ++die_counter);
1633 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
1634 + current->pid, current->xid, str, ++die_counter);
1635 notify_die(DIE_OOPS, str, regs, 0, 255, SIGSEGV);
1636 __asm__ __volatile__("flushw");
1638 diff -Nurp linux-2.6.22.18/arch/sparc64/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/sparc64/mm/fault.c
1639 --- linux-2.6.22.18/arch/sparc64/mm/fault.c 2007-09-05 07:07:59.000000000 +0200
1640 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc64/mm/fault.c 2008-02-11 12:35:33.000000000 +0100
1641 @@ -463,7 +463,8 @@ handle_kernel_fault:
1643 insn = get_fault_insn(regs, insn);
1644 up_read(&mm->mmap_sem);
1645 - printk("VM: killing process %s\n", current->comm);
1646 + printk("VM: killing process %s(%d:#%u)\n",
1647 + current->comm, current->pid, current->xid);
1648 if (!(regs->tstate & TSTATE_PRIV))
1650 goto handle_kernel_fault;
1651 diff -Nurp linux-2.6.22.18/arch/sparc64/solaris/fs.c linux-2.6.22.18-vs2.3.0.32/arch/sparc64/solaris/fs.c
1652 --- linux-2.6.22.18/arch/sparc64/solaris/fs.c 2007-05-04 15:58:05.000000000 +0200
1653 +++ linux-2.6.22.18-vs2.3.0.32/arch/sparc64/solaris/fs.c 2008-02-11 12:35:33.000000000 +0100
1654 @@ -368,7 +368,7 @@ static int report_statvfs(struct vfsmoun
1658 - if (IS_RDONLY(inode)) i = 1;
1659 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
1660 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
1661 if (!sysv_valid_dev(inode->i_sb->s_dev))
1663 @@ -404,7 +404,7 @@ static int report_statvfs64(struct vfsmo
1667 - if (IS_RDONLY(inode)) i = 1;
1668 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
1669 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
1670 if (!sysv_valid_dev(inode->i_sb->s_dev))
1672 diff -Nurp linux-2.6.22.18/arch/um/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/um/Kconfig
1673 --- linux-2.6.22.18/arch/um/Kconfig 2007-07-21 23:59:49.000000000 +0200
1674 +++ linux-2.6.22.18-vs2.3.0.32/arch/um/Kconfig 2008-02-11 12:35:33.000000000 +0100
1675 @@ -316,6 +316,8 @@ source "drivers/connector/Kconfig"
1679 +source "kernel/vserver/Kconfig"
1681 source "security/Kconfig"
1683 source "crypto/Kconfig"
1684 diff -Nurp linux-2.6.22.18/arch/um/kernel/trap.c linux-2.6.22.18-vs2.3.0.32/arch/um/kernel/trap.c
1685 --- linux-2.6.22.18/arch/um/kernel/trap.c 2007-07-21 23:59:50.000000000 +0200
1686 +++ linux-2.6.22.18-vs2.3.0.32/arch/um/kernel/trap.c 2008-02-11 12:35:33.000000000 +0100
1687 @@ -210,7 +210,8 @@ unsigned long segv(struct faultinfo fi,
1688 current->thread.arch.faultinfo = fi;
1689 force_sig_info(SIGBUS, &si, current);
1690 } else if (err == -ENOMEM) {
1691 - printk("VM: killing process %s\n", current->comm);
1692 + printk("VM: killing process %s(%d:#%u)\n",
1693 + current->comm, current->pid, current->xid);
1696 BUG_ON(err != -EFAULT);
1697 diff -Nurp linux-2.6.22.18/arch/v850/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/v850/Kconfig
1698 --- linux-2.6.22.18/arch/v850/Kconfig 2007-07-21 23:59:50.000000000 +0200
1699 +++ linux-2.6.22.18-vs2.3.0.32/arch/v850/Kconfig 2008-02-11 12:35:33.000000000 +0100
1700 @@ -333,6 +333,8 @@ source "drivers/usb/Kconfig"
1702 source "arch/v850/Kconfig.debug"
1704 +source "kernel/vserver/Kconfig"
1706 source "security/Kconfig"
1708 source "crypto/Kconfig"
1709 diff -Nurp linux-2.6.22.18/arch/v850/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/v850/kernel/process.c
1710 --- linux-2.6.22.18/arch/v850/kernel/process.c 2007-07-21 23:59:50.000000000 +0200
1711 +++ linux-2.6.22.18-vs2.3.0.32/arch/v850/kernel/process.c 2008-02-11 12:35:33.000000000 +0100
1712 @@ -82,7 +82,7 @@ int kernel_thread (int (*fn)(void *), vo
1713 /* Clone this thread. Note that we don't pass the clone syscall's
1714 second argument -- it's ignored for calls from kernel mode (the
1715 child's SP is always set to the top of the kernel stack). */
1716 - arg0 = flags | CLONE_VM;
1717 + arg0 = flags | CLONE_VM | CLONE_KTHREAD;
1718 syscall = __NR_clone;
1719 asm volatile ("trap " SYSCALL_SHORT_TRAP
1720 : "=r" (ret), "=r" (syscall)
1721 diff -Nurp linux-2.6.22.18/arch/v850/kernel/ptrace.c linux-2.6.22.18-vs2.3.0.32/arch/v850/kernel/ptrace.c
1722 --- linux-2.6.22.18/arch/v850/kernel/ptrace.c 2007-07-21 23:59:50.000000000 +0200
1723 +++ linux-2.6.22.18-vs2.3.0.32/arch/v850/kernel/ptrace.c 2008-02-11 12:35:33.000000000 +0100
1725 #include <linux/sched.h>
1726 #include <linux/ptrace.h>
1727 #include <linux/signal.h>
1728 +#include <linux/vs_base.h>
1730 #include <asm/errno.h>
1731 #include <asm/ptrace.h>
1732 @@ -116,6 +117,9 @@ long arch_ptrace(struct task_struct *chi
1736 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
1740 unsigned long val, copied;
1742 diff -Nurp linux-2.6.22.18/arch/x86_64/ia32/ia32_aout.c linux-2.6.22.18-vs2.3.0.32/arch/x86_64/ia32/ia32_aout.c
1743 --- linux-2.6.22.18/arch/x86_64/ia32/ia32_aout.c 2007-05-04 15:58:05.000000000 +0200
1744 +++ linux-2.6.22.18-vs2.3.0.32/arch/x86_64/ia32/ia32_aout.c 2008-02-11 12:35:33.000000000 +0100
1746 #include <linux/binfmts.h>
1747 #include <linux/personality.h>
1748 #include <linux/init.h>
1749 +#include <linux/vs_memory.h>
1751 #include <asm/system.h>
1752 #include <asm/uaccess.h>
1753 diff -Nurp linux-2.6.22.18/arch/x86_64/ia32/ia32_binfmt.c linux-2.6.22.18-vs2.3.0.32/arch/x86_64/ia32/ia32_binfmt.c
1754 --- linux-2.6.22.18/arch/x86_64/ia32/ia32_binfmt.c 2007-07-21 23:59:50.000000000 +0200
1755 +++ linux-2.6.22.18-vs2.3.0.32/arch/x86_64/ia32/ia32_binfmt.c 2008-02-11 12:35:33.000000000 +0100
1756 @@ -324,7 +324,8 @@ int ia32_setup_arg_pages(struct linux_bi
1757 kmem_cache_free(vm_area_cachep, mpnt);
1760 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
1761 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
1762 + mm->stack_vm = mm->total_vm;
1765 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
1766 diff -Nurp linux-2.6.22.18/arch/x86_64/ia32/ia32entry.S linux-2.6.22.18-vs2.3.0.32/arch/x86_64/ia32/ia32entry.S
1767 --- linux-2.6.22.18/arch/x86_64/ia32/ia32entry.S 2007-09-29 14:11:36.000000000 +0200
1768 +++ linux-2.6.22.18-vs2.3.0.32/arch/x86_64/ia32/ia32entry.S 2008-02-11 12:35:33.000000000 +0100
1769 @@ -680,7 +680,7 @@ ia32_sys_call_table:
1770 .quad sys_tgkill /* 270 */
1771 .quad compat_sys_utimes
1772 .quad sys32_fadvise64_64
1773 - .quad quiet_ni_syscall /* sys_vserver */
1774 + .quad sys32_vserver
1776 .quad compat_sys_get_mempolicy /* 275 */
1777 .quad sys_set_mempolicy
1778 diff -Nurp linux-2.6.22.18/arch/x86_64/ia32/syscall32.c linux-2.6.22.18-vs2.3.0.32/arch/x86_64/ia32/syscall32.c
1779 --- linux-2.6.22.18/arch/x86_64/ia32/syscall32.c 2007-07-21 23:59:50.000000000 +0200
1780 +++ linux-2.6.22.18-vs2.3.0.32/arch/x86_64/ia32/syscall32.c 2008-02-11 12:35:33.000000000 +0100
1782 #include <linux/init.h>
1783 #include <linux/stringify.h>
1784 #include <linux/security.h>
1785 +#include <linux/vs_memory.h>
1786 #include <asm/proto.h>
1787 #include <asm/tlbflush.h>
1788 #include <asm/ia32_unistd.h>
1789 diff -Nurp linux-2.6.22.18/arch/x86_64/ia32/sys_ia32.c linux-2.6.22.18-vs2.3.0.32/arch/x86_64/ia32/sys_ia32.c
1790 --- linux-2.6.22.18/arch/x86_64/ia32/sys_ia32.c 2007-07-21 23:59:50.000000000 +0200
1791 +++ linux-2.6.22.18-vs2.3.0.32/arch/x86_64/ia32/sys_ia32.c 2008-02-11 12:35:33.000000000 +0100
1792 @@ -454,7 +454,7 @@ sys32_gettimeofday(struct compat_timeval
1796 - do_gettimeofday(&ktv);
1797 + vx_gettimeofday(&ktv);
1798 if (put_tv32(tv, &ktv))
1801 diff -Nurp linux-2.6.22.18/arch/x86_64/Kconfig linux-2.6.22.18-vs2.3.0.32/arch/x86_64/Kconfig
1802 --- linux-2.6.22.18/arch/x86_64/Kconfig 2007-07-21 23:59:50.000000000 +0200
1803 +++ linux-2.6.22.18-vs2.3.0.32/arch/x86_64/Kconfig 2008-02-11 12:35:33.000000000 +0100
1804 @@ -782,6 +782,8 @@ endmenu
1806 source "arch/x86_64/Kconfig.debug"
1808 +source "kernel/vserver/Kconfig"
1810 source "security/Kconfig"
1812 source "crypto/Kconfig"
1813 diff -Nurp linux-2.6.22.18/arch/x86_64/kernel/process.c linux-2.6.22.18-vs2.3.0.32/arch/x86_64/kernel/process.c
1814 --- linux-2.6.22.18/arch/x86_64/kernel/process.c 2007-07-21 23:59:50.000000000 +0200
1815 +++ linux-2.6.22.18-vs2.3.0.32/arch/x86_64/kernel/process.c 2008-02-11 12:35:33.000000000 +0100
1818 asmlinkage extern void ret_from_fork(void);
1820 -unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
1821 +unsigned long kernel_thread_flags =
1822 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
1824 unsigned long boot_option_idle_override = 0;
1825 EXPORT_SYMBOL(boot_option_idle_override);
1826 @@ -310,8 +311,8 @@ void __show_regs(struct pt_regs * regs)
1830 - printk("Pid: %d, comm: %.20s %s %s %.*s\n",
1831 - current->pid, current->comm, print_tainted(),
1832 + printk("Pid: %d:#%u, comm: %.20s %s %s %.*s\n",
1833 + current->pid, current->xid, current->comm, print_tainted(),
1834 init_utsname()->release,
1835 (int)strcspn(init_utsname()->version, " "),
1836 init_utsname()->version);
1837 diff -Nurp linux-2.6.22.18/arch/x86_64/kernel/traps.c linux-2.6.22.18-vs2.3.0.32/arch/x86_64/kernel/traps.c
1838 --- linux-2.6.22.18/arch/x86_64/kernel/traps.c 2007-07-21 23:59:50.000000000 +0200
1839 +++ linux-2.6.22.18-vs2.3.0.32/arch/x86_64/kernel/traps.c 2008-02-11 12:35:33.000000000 +0100
1841 #include <linux/uaccess.h>
1842 #include <linux/bug.h>
1843 #include <linux/kdebug.h>
1844 +#include <linux/vs_context.h>
1845 +#include <linux/vserver/history.h>
1847 #include <asm/system.h>
1849 @@ -413,8 +415,9 @@ void show_registers(struct pt_regs *regs
1851 printk("CPU %d ", cpu);
1853 - printk("Process %s (pid: %d, threadinfo %p, task %p)\n",
1854 - cur->comm, cur->pid, task_thread_info(cur), cur);
1855 + printk("Process %s (pid: %d[#%u], threadinfo %p, task %p)\n",
1856 + cur->comm, cur->pid, cur->xid,
1857 + task_thread_info(cur), cur);
1860 * When in-kernel, we also print out the stack and code at the
1861 @@ -518,6 +521,7 @@ void __kprobes __die(const char * str, s
1863 notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
1864 show_registers(regs);
1865 + vxh_dump_history();
1866 /* Executive summary in case the oops scrolled away */
1867 printk(KERN_ALERT "RIP ");
1868 printk_address(regs->rip);
1869 @@ -530,6 +534,7 @@ void die(const char * str, struct pt_reg
1871 unsigned long flags = oops_begin();
1874 if (!user_mode(regs))
1875 report_bug(regs->rip);
1877 @@ -542,12 +547,14 @@ void __kprobes die_nmi(char *str, struct
1879 unsigned long flags = oops_begin();
1883 * We are in trouble anyway, lets at least try
1884 * to get a message out.
1886 printk(str, smp_processor_id());
1887 show_registers(regs);
1888 + vxh_dump_history();
1889 if (kexec_should_crash(current))
1891 if (do_panic || panic_on_oops)
1892 @@ -580,8 +587,8 @@ static void __kprobes do_trap(int trapnr
1894 if (exception_trace && unhandled_signal(tsk, signr))
1896 - "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
1897 - tsk->comm, tsk->pid, str,
1898 + "%s[%d:#%u] trap %s rip:%lx rsp:%lx error:%lx\n",
1899 + tsk->comm, tsk->pid, tsk->xid, str,
1900 regs->rip, regs->rsp, error_code);
1903 @@ -684,8 +691,8 @@ asmlinkage void __kprobes do_general_pro
1905 if (exception_trace && unhandled_signal(tsk, SIGSEGV))
1907 - "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
1908 - tsk->comm, tsk->pid,
1909 + "%s[%d:#%u] general protection rip:%lx rsp:%lx error:%lx\n",
1910 + tsk->comm, tsk->pid, tsk->xid,
1911 regs->rip, regs->rsp, error_code);
1913 force_sig(SIGSEGV, tsk);
1914 diff -Nurp linux-2.6.22.18/arch/x86_64/mm/fault.c linux-2.6.22.18-vs2.3.0.32/arch/x86_64/mm/fault.c
1915 --- linux-2.6.22.18/arch/x86_64/mm/fault.c 2007-07-21 23:59:50.000000000 +0200
1916 +++ linux-2.6.22.18-vs2.3.0.32/arch/x86_64/mm/fault.c 2008-02-11 12:35:33.000000000 +0100
1917 @@ -497,10 +497,10 @@ bad_area_nosemaphore:
1919 if (exception_trace && unhandled_signal(tsk, SIGSEGV)) {
1921 - "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
1922 + "%s%s[%d:#%u]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
1923 tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
1924 - tsk->comm, tsk->pid, address, regs->rip,
1925 - regs->rsp, error_code);
1926 + tsk->comm, tsk->pid, tsk->xid, address,
1927 + regs->rip, regs->rsp, error_code);
1930 tsk->thread.cr2 = address;
1931 @@ -567,7 +567,8 @@ out_of_memory:
1935 - printk("VM: killing process %s\n", tsk->comm);
1936 + printk("VM: killing process %s(%d:#%u)\n",
1937 + tsk->comm, tsk->pid, tsk->xid);
1941 diff -Nurp linux-2.6.22.18/Documentation/vserver/debug.txt linux-2.6.22.18-vs2.3.0.32/Documentation/vserver/debug.txt
1942 --- linux-2.6.22.18/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1943 +++ linux-2.6.22.18-vs2.3.0.32/Documentation/vserver/debug.txt 2008-02-11 12:35:31.000000000 +0100
1948 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
1949 + "vx_rmap_tgid: %p/%llx: %d -> %d"
1953 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
1954 + "FREE (%p,#%d)%c inode"
1955 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
1956 + "FREE (%p,#%d)%c %lld bytes"
1957 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
1958 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
1959 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
1960 + "rcu_free_dl_info(%p)"
1961 + 4 10 "alloc_dl_info(%p,%d) = %p"
1962 + "dealloc_dl_info(%p)"
1963 + "get_dl_info(%p[#%d.%d])"
1964 + "put_dl_info(%p[#%d.%d])"
1965 + 5 20 "alloc_dl_info(%p,%d)*"
1966 + 6 40 "__hash_dl_info: %p[#%d]"
1967 + "__unhash_dl_info: %p[#%d]"
1968 + 7 80 "locate_dl_info(%p,#%d) = %p"
1972 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
1973 + "new_dqhash: %p [#0x%08x]"
1974 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
1975 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
1976 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
1977 + "vroot_get_real_bdev not set"
1978 + 1 2 "cow_break_link(»%s«)"
1979 + "temp copy »%s«"
1980 + 2 4 "dentry_open(new): %p"
1981 + "dentry_open(old): %p"
1982 + "lookup_create(new): %p"
1984 + "path_lookup(old): %d"
1985 + "vfs_create(new): %d"
1987 + "vfs_sendfile: %d"
1988 + 3 8 "fput(new_file=%p[#%d])"
1989 + "fput(old_file=%p[#%d])"
1990 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
1991 + "vx_info_kill(%p[#%d],%d,%d)*"
1992 + 5 20 "vs_reboot(%p[#%d],%d)"
1993 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
1997 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
1998 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
1999 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
2000 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
2001 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
2002 + 6 40 "sk,egf: %p [#%d] (from %d)"
2003 + "sk,egn: %p [#%d] (from %d)"
2004 + "sk,req: %p [#%d] (from %d)"
2005 + "sk: %p [#%d] (from %d)"
2006 + "tw: %p [#%d] (from %d)"
2007 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
2008 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
2012 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
2013 + "alloc_nx_info(%d) = %p"
2014 + "create_nx_info(%d) (dynamic rejected)"
2015 + "create_nx_info(%d) = %p (already there)"
2016 + "create_nx_info(%d) = %p (new)"
2017 + "dealloc_nx_info(%p)"
2018 + 1 2 "alloc_nx_info(%d)*"
2019 + "create_nx_info(%d)*"
2020 + 2 4 "get_nx_info(%p[#%d.%d])"
2021 + "put_nx_info(%p[#%d.%d])"
2022 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
2023 + "clr_nx_info(%p[#%d.%d])"
2024 + "init_nx_info(%p[#%d.%d])"
2025 + "release_nx_info(%p[#%d.%d.%d]) %p"
2026 + "set_nx_info(%p[#%d.%d])"
2027 + 4 10 "__hash_nx_info: %p[#%d]"
2028 + "__nx_dynamic_id: [#%d]"
2029 + "__unhash_nx_info: %p[#%d.%d.%d]"
2030 + 5 20 "moved task %p into nxi:%p[#%d]"
2031 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
2032 + "task_get_nx_info(%p)"
2033 + 6 40 "nx_clear_persistent(%p[#%d])"
2037 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
2038 + 1 2 "quota_sync_dqh(%p,%d)"
2039 + "sync_dquots(%p,%d)"
2040 + "sync_dquots_dqh(%p,%d)"
2041 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
2045 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
2046 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
2047 + 4 10 "%s: (%s %s) returned %s with %d"
2051 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
2052 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
2056 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
2057 + "alloc_vx_info(%d) = %p"
2058 + "alloc_vx_info(%d)*"
2059 + "create_vx_info(%d) (dynamic rejected)"
2060 + "create_vx_info(%d) = %p (already there)"
2061 + "create_vx_info(%d) = %p (new)"
2062 + "dealloc_vx_info(%p)"
2063 + "loc_vx_info(%d) = %p (found)"
2064 + "loc_vx_info(%d) = %p (new)"
2065 + "loc_vx_info(%d) = %p (not available)"
2066 + 1 2 "create_vx_info(%d)*"
2067 + "loc_vx_info(%d)*"
2068 + 2 4 "get_vx_info(%p[#%d.%d])"
2069 + "put_vx_info(%p[#%d.%d])"
2070 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
2071 + "clr_vx_info(%p[#%d.%d])"
2072 + "init_vx_info(%p[#%d.%d])"
2073 + "release_vx_info(%p[#%d.%d.%d]) %p"
2074 + "set_vx_info(%p[#%d.%d])"
2075 + 4 10 "__hash_vx_info: %p[#%d]"
2076 + "__unhash_vx_info: %p[#%d.%d.%d]"
2077 + "__vx_dynamic_id: [#%d]"
2078 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
2079 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
2080 + "moved task %p into vxi:%p[#%d]"
2081 + "task_get_vx_info(%p)"
2082 + "vx_migrate_task(%p,%p[#%d.%d])"
2083 + 6 40 "vx_clear_persistent(%p[#%d])"
2084 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
2085 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
2086 + "vx_set_persistent(%p[#%d])"
2087 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
2088 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
2093 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
2094 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
2096 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
2097 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
2098 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
2099 diff -Nurp linux-2.6.22.18/drivers/block/Kconfig linux-2.6.22.18-vs2.3.0.32/drivers/block/Kconfig
2100 --- linux-2.6.22.18/drivers/block/Kconfig 2007-07-21 23:59:50.000000000 +0200
2101 +++ linux-2.6.22.18-vs2.3.0.32/drivers/block/Kconfig 2008-02-11 12:35:33.000000000 +0100
2102 @@ -311,6 +311,13 @@ config BLK_DEV_CRYPTOLOOP
2103 instead, which can be configured to be on-disk compatible with the
2106 +config BLK_DEV_VROOT
2107 + tristate "Virtual Root device support"
2108 + depends on QUOTACTL
2110 + Saying Y here will allow you to use quota/fs ioctls on a shared
2111 + partition within a virtual server without compromising security.
2114 tristate "Network block device support"
2116 diff -Nurp linux-2.6.22.18/drivers/block/loop.c linux-2.6.22.18-vs2.3.0.32/drivers/block/loop.c
2117 --- linux-2.6.22.18/drivers/block/loop.c 2007-07-21 23:59:50.000000000 +0200
2118 +++ linux-2.6.22.18-vs2.3.0.32/drivers/block/loop.c 2008-02-11 12:35:33.000000000 +0100
2120 #include <linux/highmem.h>
2121 #include <linux/gfp.h>
2122 #include <linux/kthread.h>
2123 +#include <linux/vs_context.h>
2125 #include <asm/uaccess.h>
2127 @@ -790,6 +791,7 @@ static int loop_set_fd(struct loop_devic
2128 lo->lo_blocksize = lo_blocksize;
2129 lo->lo_device = bdev;
2130 lo->lo_flags = lo_flags;
2131 + lo->lo_xid = vx_current_xid();
2132 lo->lo_backing_file = file;
2133 lo->transfer = transfer_none;
2135 @@ -909,6 +911,7 @@ static int loop_clr_fd(struct loop_devic
2136 lo->lo_encrypt_key_size = 0;
2138 lo->lo_thread = NULL;
2140 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2141 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2142 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2143 @@ -930,7 +933,7 @@ loop_set_status(struct loop_device *lo,
2144 struct loop_func_table *xfer;
2146 if (lo->lo_encrypt_key_size && lo->lo_key_owner != current->uid &&
2147 - !capable(CAP_SYS_ADMIN))
2148 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2150 if (lo->lo_state != Lo_bound)
2152 @@ -1010,7 +1013,8 @@ loop_get_status(struct loop_device *lo,
2153 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2154 info->lo_encrypt_type =
2155 lo->lo_encryption ? lo->lo_encryption->number : 0;
2156 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2157 + if (lo->lo_encrypt_key_size &&
2158 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2159 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2160 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2161 lo->lo_encrypt_key_size);
2162 @@ -1321,6 +1325,9 @@ static int lo_open(struct inode *inode,
2164 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
2166 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID))
2169 mutex_lock(&lo->lo_ctl_mutex);
2171 mutex_unlock(&lo->lo_ctl_mutex);
2172 diff -Nurp linux-2.6.22.18/drivers/block/Makefile linux-2.6.22.18-vs2.3.0.32/drivers/block/Makefile
2173 --- linux-2.6.22.18/drivers/block/Makefile 2007-05-04 15:58:05.000000000 +0200
2174 +++ linux-2.6.22.18-vs2.3.0.32/drivers/block/Makefile 2008-02-11 12:35:33.000000000 +0100
2175 @@ -28,4 +28,5 @@ obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryp
2176 obj-$(CONFIG_VIODASD) += viodasd.o
2177 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
2178 obj-$(CONFIG_BLK_DEV_UB) += ub.o
2179 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
2181 diff -Nurp linux-2.6.22.18/drivers/block/vroot.c linux-2.6.22.18-vs2.3.0.32/drivers/block/vroot.c
2182 --- linux-2.6.22.18/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
2183 +++ linux-2.6.22.18-vs2.3.0.32/drivers/block/vroot.c 2008-02-11 12:35:33.000000000 +0100
2186 + * linux/drivers/block/vroot.c
2188 + * written by Herbert Pötzl, 9/11/2002
2189 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2191 + * based on the loop.c code by Theodore Ts'o.
2193 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2194 + * Redistribution of this file is permitted under the
2195 + * GNU General Public License.
2199 +#include <linux/module.h>
2200 +#include <linux/moduleparam.h>
2201 +#include <linux/file.h>
2202 +#include <linux/major.h>
2203 +#include <linux/blkdev.h>
2205 +#include <linux/vroot.h>
2206 +#include <linux/vs_context.h>
2209 +static int max_vroot = 8;
2211 +static struct vroot_device *vroot_dev;
2212 +static struct gendisk **disks;
2215 +static int vroot_set_dev(
2216 + struct vroot_device *vr,
2217 + struct file *vr_file,
2218 + struct block_device *bdev,
2221 + struct block_device *real_bdev;
2222 + struct file *file;
2223 + struct inode *inode;
2227 + if (vr->vr_state != Vr_unbound)
2236 + inode = file->f_dentry->d_inode;
2239 + if (S_ISBLK(inode->i_mode)) {
2240 + real_bdev = inode->i_bdev;
2241 + vr->vr_device = real_bdev;
2242 + __iget(real_bdev->bd_inode);
2246 + vxdprintk(VXD_CBIT(misc, 0),
2247 + "vroot[%d]_set_dev: dev=" VXF_DEV,
2248 + vr->vr_number, VXD_DEV(real_bdev));
2250 + vr->vr_state = Vr_bound;
2259 +static int vroot_clr_dev(
2260 + struct vroot_device *vr,
2261 + struct file *vr_file,
2262 + struct block_device *bdev)
2264 + struct block_device *real_bdev;
2266 + if (vr->vr_state != Vr_bound)
2268 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
2271 + real_bdev = vr->vr_device;
2273 + vxdprintk(VXD_CBIT(misc, 0),
2274 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
2275 + vr->vr_number, VXD_DEV(real_bdev));
2278 + vr->vr_state = Vr_unbound;
2279 + vr->vr_device = NULL;
2284 +static int vr_ioctl(struct inode *inode, struct file *file,
2285 + unsigned int cmd, unsigned long arg)
2287 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2290 + down(&vr->vr_ctl_mutex);
2292 + case VROOT_SET_DEV:
2293 + err = vroot_set_dev(vr, file, inode->i_bdev, arg);
2295 + case VROOT_CLR_DEV:
2296 + err = vroot_clr_dev(vr, file, inode->i_bdev);
2302 + up(&vr->vr_ctl_mutex);
2306 +static int vr_open(struct inode *inode, struct file *file)
2308 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2310 + down(&vr->vr_ctl_mutex);
2312 + up(&vr->vr_ctl_mutex);
2316 +static int vr_release(struct inode *inode, struct file *file)
2318 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2320 + down(&vr->vr_ctl_mutex);
2322 + up(&vr->vr_ctl_mutex);
2326 +static struct block_device_operations vr_fops = {
2327 + .owner = THIS_MODULE,
2329 + .release = vr_release,
2330 + .ioctl = vr_ioctl,
2333 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2335 + struct inode *inode = bdev->bd_inode;
2336 + struct vroot_device *vr;
2337 + struct block_device *real_bdev;
2338 + int minor = iminor(inode);
2340 + vr = &vroot_dev[minor];
2341 + real_bdev = vr->vr_device;
2343 + vxdprintk(VXD_CBIT(misc, 0),
2344 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2345 + vr->vr_number, VXD_DEV(real_bdev));
2347 + if (vr->vr_state != Vr_bound)
2348 + return ERR_PTR(-ENXIO);
2350 + __iget(real_bdev->bd_inode);
2355 + * And now the modules code and kernel interface.
2358 +module_param(max_vroot, int, 0);
2360 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
2361 +MODULE_LICENSE("GPL");
2362 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
2364 +MODULE_AUTHOR ("Herbert Pötzl");
2365 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
2368 +int __init vroot_init(void)
2372 + if (max_vroot < 1 || max_vroot > 256) {
2373 + max_vroot = MAX_VROOT_DEFAULT;
2374 + printk(KERN_WARNING "vroot: invalid max_vroot "
2375 + "(must be between 1 and 256), "
2376 + "using default (%d)\n", max_vroot);
2379 + if (register_blkdev(VROOT_MAJOR, "vroot"))
2383 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2386 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2388 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2392 + for (i = 0; i < max_vroot; i++) {
2393 + disks[i] = alloc_disk(1);
2398 + for (i = 0; i < max_vroot; i++) {
2399 + struct vroot_device *vr = &vroot_dev[i];
2400 + struct gendisk *disk = disks[i];
2402 + memset(vr, 0, sizeof(*vr));
2403 + init_MUTEX(&vr->vr_ctl_mutex);
2404 + vr->vr_number = i;
2405 + disk->major = VROOT_MAJOR;
2406 + disk->first_minor = i;
2407 + disk->fops = &vr_fops;
2408 + sprintf(disk->disk_name, "vroot%d", i);
2409 + disk->private_data = vr;
2412 + err = register_vroot_grb(&__vroot_get_real_bdev);
2416 + for (i = 0; i < max_vroot; i++)
2417 + add_disk(disks[i]);
2418 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2423 + put_disk(disks[i]);
2428 + unregister_blkdev(VROOT_MAJOR, "vroot");
2429 + printk(KERN_ERR "vroot: ran out of memory\n");
2433 +void vroot_exit(void)
2437 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
2438 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
2440 + for (i = 0; i < max_vroot; i++) {
2441 + del_gendisk(disks[i]);
2442 + put_disk(disks[i]);
2444 + if (unregister_blkdev(VROOT_MAJOR, "vroot"))
2445 + printk(KERN_WARNING "vroot: cannot unregister blkdev\n");
2451 +module_init(vroot_init);
2452 +module_exit(vroot_exit);
2456 +static int __init max_vroot_setup(char *str)
2458 + max_vroot = simple_strtol(str, NULL, 0);
2462 +__setup("max_vroot=", max_vroot_setup);
2466 diff -Nurp linux-2.6.22.18/drivers/char/sysrq.c linux-2.6.22.18-vs2.3.0.32/drivers/char/sysrq.c
2467 --- linux-2.6.22.18/drivers/char/sysrq.c 2007-07-21 23:59:53.000000000 +0200
2468 +++ linux-2.6.22.18-vs2.3.0.32/drivers/char/sysrq.c 2008-02-11 12:35:33.000000000 +0100
2470 #include <linux/kexec.h>
2471 #include <linux/irq.h>
2472 #include <linux/hrtimer.h>
2473 +#include <linux/vserver/debug.h>
2475 #include <asm/ptrace.h>
2476 #include <asm/irq_regs.h>
2477 @@ -309,6 +310,21 @@ static struct sysrq_key_op sysrq_unrt_op
2478 .enable_mask = SYSRQ_ENABLE_RTNICE,
2482 +#ifdef CONFIG_VSERVER_DEBUG
2483 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
2485 + dump_vx_info_inactive((key == 'x')?0:1);
2488 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2489 + .handler = sysrq_handle_vxinfo,
2490 + .help_msg = "conteXt",
2491 + .action_msg = "Show Context Info",
2492 + .enable_mask = SYSRQ_ENABLE_DUMP,
2496 /* Key Operations table and lock */
2497 static DEFINE_SPINLOCK(sysrq_key_table_lock);
2499 @@ -357,7 +373,11 @@ static struct sysrq_key_op *sysrq_key_ta
2500 /* x: May be registered on ppc/powerpc for xmon */
2504 +#ifdef CONFIG_VSERVER_DEBUG
2505 + &sysrq_showvxinfo_op, /* z */
2511 /* key2index calculation, -1 on invalid index */
2512 @@ -369,6 +389,8 @@ static int sysrq_key_table_key2index(int
2514 else if ((key >= 'a') && (key <= 'z'))
2515 retval = key + 10 - 'a';
2516 + else if ((key >= 'A') && (key <= 'Z'))
2517 + retval = key + 10 - 'A';
2521 diff -Nurp linux-2.6.22.18/drivers/char/tty_io.c linux-2.6.22.18-vs2.3.0.32/drivers/char/tty_io.c
2522 --- linux-2.6.22.18/drivers/char/tty_io.c 2007-07-21 23:59:53.000000000 +0200
2523 +++ linux-2.6.22.18-vs2.3.0.32/drivers/char/tty_io.c 2008-02-11 12:35:33.000000000 +0100
2525 #include <linux/selection.h>
2527 #include <linux/kmod.h>
2528 +#include <linux/vs_pid.h>
2530 #undef TTY_DEBUG_HANGUP
2532 @@ -3049,13 +3050,15 @@ unlock:
2534 static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
2538 * (tty == real_tty) is a cheap way of
2539 * testing if the tty is NOT a master pty.
2541 if (tty == real_tty && current->signal->tty != real_tty)
2543 - return put_user(pid_nr(real_tty->pgrp), p);
2544 + pgrp = vx_map_pid(pid_nr(real_tty->pgrp));
2545 + return put_user(pgrp, p);
2549 @@ -3086,6 +3089,7 @@ static int tiocspgrp(struct tty_struct *
2551 if (get_user(pgrp_nr, p))
2553 + pgrp_nr = vx_rmap_pid(pgrp_nr);
2557 diff -Nurp linux-2.6.22.18/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.22.18-vs2.3.0.32/drivers/infiniband/hw/ipath/ipath_user_pages.c
2558 --- linux-2.6.22.18/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-05-04 15:58:07.000000000 +0200
2559 +++ linux-2.6.22.18-vs2.3.0.32/drivers/infiniband/hw/ipath/ipath_user_pages.c 2008-02-11 12:35:33.000000000 +0100
2562 #include <linux/mm.h>
2563 #include <linux/device.h>
2564 +#include <linux/vs_memory.h>
2566 #include "ipath_kernel.h"
2568 @@ -61,7 +62,8 @@ static int __get_user_pages(unsigned lon
2569 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
2572 - if (num_pages > lock_limit) {
2573 + if (num_pages > lock_limit ||
2574 + !vx_vmlocked_avail(current->mm, num_pages)) {
2578 @@ -78,7 +80,7 @@ static int __get_user_pages(unsigned lon
2582 - current->mm->locked_vm += num_pages;
2583 + vx_vmlocked_add(current->mm, num_pages);
2587 @@ -203,7 +205,7 @@ void ipath_release_user_pages(struct pag
2589 __ipath_release_user_pages(p, num_pages, 1);
2591 - current->mm->locked_vm -= num_pages;
2592 + vx_vmlocked_sub(current->mm, num_pages);
2594 up_write(¤t->mm->mmap_sem);
2596 @@ -220,7 +222,7 @@ static void user_pages_account(struct wo
2597 container_of(_work, struct ipath_user_pages_work, work);
2599 down_write(&work->mm->mmap_sem);
2600 - work->mm->locked_vm -= work->num_pages;
2601 + vx_vmlocked_sub(work->mm, work->num_pages);
2602 up_write(&work->mm->mmap_sem);
2605 diff -Nurp linux-2.6.22.18/drivers/md/dm.c linux-2.6.22.18-vs2.3.0.32/drivers/md/dm.c
2606 --- linux-2.6.22.18/drivers/md/dm.c 2007-08-12 03:54:36.000000000 +0200
2607 +++ linux-2.6.22.18-vs2.3.0.32/drivers/md/dm.c 2008-02-11 12:35:33.000000000 +0100
2609 #include <linux/hdreg.h>
2610 #include <linux/blktrace_api.h>
2611 #include <linux/smp_lock.h>
2612 +#include <linux/vs_base.h>
2614 #define DM_MSG_PREFIX "core"
2616 @@ -77,6 +78,7 @@ struct mapped_device {
2619 atomic_t open_count;
2622 unsigned long flags;
2624 @@ -223,6 +225,7 @@ static void __exit dm_exit(void)
2625 static int dm_blk_open(struct inode *inode, struct file *file)
2627 struct mapped_device *md;
2630 spin_lock(&_minor_lock);
2632 @@ -231,18 +234,19 @@ static int dm_blk_open(struct inode *ino
2635 if (test_bit(DMF_FREEING, &md->flags) ||
2636 - test_bit(DMF_DELETING, &md->flags)) {
2638 + test_bit(DMF_DELETING, &md->flags))
2642 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
2647 atomic_inc(&md->open_count);
2651 spin_unlock(&_minor_lock);
2653 - return md ? 0 : -ENXIO;
2657 static int dm_blk_close(struct inode *inode, struct file *file)
2658 @@ -438,6 +442,14 @@ int dm_set_geometry(struct mapped_device
2663 + * Get the xid associated with a dm device
2665 +xid_t dm_get_xid(struct mapped_device *md)
2670 /*-----------------------------------------------------------------
2672 * A more elegant soln is in the works that uses the queue
2673 @@ -1000,6 +1012,7 @@ static struct mapped_device *alloc_dev(i
2674 atomic_set(&md->holders, 1);
2675 atomic_set(&md->open_count, 0);
2676 atomic_set(&md->event_nr, 0);
2677 + md->xid = vx_current_xid();
2679 md->queue = blk_alloc_queue(GFP_KERNEL);
2681 diff -Nurp linux-2.6.22.18/drivers/md/dm.h linux-2.6.22.18-vs2.3.0.32/drivers/md/dm.h
2682 --- linux-2.6.22.18/drivers/md/dm.h 2007-05-04 15:58:08.000000000 +0200
2683 +++ linux-2.6.22.18-vs2.3.0.32/drivers/md/dm.h 2008-02-11 12:35:33.000000000 +0100
2684 @@ -91,6 +91,8 @@ void dm_put_target_type(struct target_ty
2685 int dm_target_iterate(void (*iter_func)(struct target_type *tt,
2686 void *param), void *param);
2688 +xid_t dm_get_xid(struct mapped_device *md);
2690 /*-----------------------------------------------------------------
2692 *---------------------------------------------------------------*/
2693 diff -Nurp linux-2.6.22.18/drivers/md/dm-ioctl.c linux-2.6.22.18-vs2.3.0.32/drivers/md/dm-ioctl.c
2694 --- linux-2.6.22.18/drivers/md/dm-ioctl.c 2007-07-21 23:58:29.000000000 +0200
2695 +++ linux-2.6.22.18-vs2.3.0.32/drivers/md/dm-ioctl.c 2008-02-11 12:35:33.000000000 +0100
2697 #include <linux/slab.h>
2698 #include <linux/dm-ioctl.h>
2699 #include <linux/hdreg.h>
2700 +#include <linux/vs_context.h>
2702 #include <asm/uaccess.h>
2704 @@ -100,7 +101,8 @@ static struct hash_cell *__get_name_cell
2705 unsigned int h = hash_str(str);
2707 list_for_each_entry (hc, _name_buckets + h, name_list)
2708 - if (!strcmp(hc->name, str)) {
2709 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2710 + !strcmp(hc->name, str)) {
2714 @@ -114,7 +116,8 @@ static struct hash_cell *__get_uuid_cell
2715 unsigned int h = hash_str(str);
2717 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
2718 - if (!strcmp(hc->uuid, str)) {
2719 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2720 + !strcmp(hc->uuid, str)) {
2724 @@ -349,6 +352,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
2726 static int remove_all(struct dm_ioctl *param, size_t param_size)
2728 + if (!vx_check(0, VS_ADMIN))
2731 dm_hash_remove_all(1);
2732 param->data_size = 0;
2734 @@ -396,6 +402,8 @@ static int list_devices(struct dm_ioctl
2736 for (i = 0; i < NUM_BUCKETS; i++) {
2737 list_for_each_entry (hc, _name_buckets + i, name_list) {
2738 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2740 needed += sizeof(struct dm_name_list);
2741 needed += strlen(hc->name) + 1;
2742 needed += ALIGN_MASK;
2743 @@ -419,6 +427,8 @@ static int list_devices(struct dm_ioctl
2745 for (i = 0; i < NUM_BUCKETS; i++) {
2746 list_for_each_entry (hc, _name_buckets + i, name_list) {
2747 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2750 old_nl->next = (uint32_t) ((void *) nl -
2752 @@ -609,10 +619,11 @@ static struct hash_cell *__find_device_h
2756 - mdptr = dm_get_mdptr(md);
2757 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
2758 + mdptr = dm_get_mdptr(md);
2766 @@ -1409,8 +1420,8 @@ static int ctl_ioctl(struct inode *inode
2770 - /* only root can play with this */
2771 - if (!capable(CAP_SYS_ADMIN))
2772 + /* only root and certain contexts can play with this */
2773 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
2776 if (_IOC_TYPE(command) != DM_IOCTL)
2777 diff -Nurp linux-2.6.22.18/fs/attr.c linux-2.6.22.18-vs2.3.0.32/fs/attr.c
2778 --- linux-2.6.22.18/fs/attr.c 2007-07-22 00:00:15.000000000 +0200
2779 +++ linux-2.6.22.18-vs2.3.0.32/fs/attr.c 2008-02-11 12:35:33.000000000 +0100
2781 #include <linux/fcntl.h>
2782 #include <linux/quotaops.h>
2783 #include <linux/security.h>
2784 +#include <linux/proc_fs.h>
2785 +#include <linux/devpts_fs.h>
2786 +#include <linux/vs_base.h>
2788 /* Taken over from the old code... */
2790 @@ -55,6 +58,27 @@ int inode_change_ok(struct inode *inode,
2791 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
2795 + /* Check for evil vserver activity */
2796 + if (vx_check(0, VS_ADMIN))
2799 + if (IS_BARRIER(inode)) {
2800 + vxwprintk_task(1, "messing with the barrier.");
2803 + switch (inode->i_sb->s_magic) {
2804 + case PROC_SUPER_MAGIC:
2805 + /* maybe allow that in the future? */
2806 + vxwprintk_task(1, "messing with the procfs.");
2808 + case DEVPTS_SUPER_MAGIC:
2809 + /* devpts is xid tagged */
2810 + if (vx_check((xid_t)inode->i_tag, VS_IDENT))
2812 + vxwprintk_task(1, "messing with the devpts.");
2818 @@ -78,6 +102,8 @@ int inode_setattr(struct inode * inode,
2819 inode->i_uid = attr->ia_uid;
2820 if (ia_valid & ATTR_GID)
2821 inode->i_gid = attr->ia_gid;
2822 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2823 + inode->i_tag = attr->ia_tag;
2824 if (ia_valid & ATTR_ATIME)
2825 inode->i_atime = timespec_trunc(attr->ia_atime,
2826 inode->i_sb->s_time_gran);
2827 @@ -152,7 +178,8 @@ int notify_change(struct dentry * dentry
2828 error = security_inode_setattr(dentry, attr);
2830 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2831 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2832 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2833 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2834 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
2836 error = inode_setattr(inode, attr);
2837 diff -Nurp linux-2.6.22.18/fs/binfmt_aout.c linux-2.6.22.18-vs2.3.0.32/fs/binfmt_aout.c
2838 --- linux-2.6.22.18/fs/binfmt_aout.c 2007-05-04 15:58:21.000000000 +0200
2839 +++ linux-2.6.22.18-vs2.3.0.32/fs/binfmt_aout.c 2008-02-11 12:35:33.000000000 +0100
2841 #include <linux/binfmts.h>
2842 #include <linux/personality.h>
2843 #include <linux/init.h>
2844 +#include <linux/vs_memory.h>
2846 #include <asm/system.h>
2847 #include <asm/uaccess.h>
2848 diff -Nurp linux-2.6.22.18/fs/binfmt_elf.c linux-2.6.22.18-vs2.3.0.32/fs/binfmt_elf.c
2849 --- linux-2.6.22.18/fs/binfmt_elf.c 2007-07-22 00:00:15.000000000 +0200
2850 +++ linux-2.6.22.18-vs2.3.0.32/fs/binfmt_elf.c 2008-02-11 12:35:33.000000000 +0100
2852 #include <linux/random.h>
2853 #include <linux/elf.h>
2854 #include <linux/utsname.h>
2855 +#include <linux/vs_memory.h>
2856 #include <asm/uaccess.h>
2857 #include <asm/param.h>
2858 #include <asm/page.h>
2859 diff -Nurp linux-2.6.22.18/fs/binfmt_flat.c linux-2.6.22.18-vs2.3.0.32/fs/binfmt_flat.c
2860 --- linux-2.6.22.18/fs/binfmt_flat.c 2007-07-22 00:00:15.000000000 +0200
2861 +++ linux-2.6.22.18-vs2.3.0.32/fs/binfmt_flat.c 2008-02-11 12:35:33.000000000 +0100
2863 #include <linux/init.h>
2864 #include <linux/flat.h>
2865 #include <linux/syscalls.h>
2866 +#include <linux/vs_memory.h>
2868 #include <asm/byteorder.h>
2869 #include <asm/system.h>
2870 diff -Nurp linux-2.6.22.18/fs/binfmt_som.c linux-2.6.22.18-vs2.3.0.32/fs/binfmt_som.c
2871 --- linux-2.6.22.18/fs/binfmt_som.c 2007-05-04 15:57:29.000000000 +0200
2872 +++ linux-2.6.22.18-vs2.3.0.32/fs/binfmt_som.c 2008-02-11 12:35:33.000000000 +0100
2874 #include <linux/shm.h>
2875 #include <linux/personality.h>
2876 #include <linux/init.h>
2877 +#include <linux/vs_memory.h>
2879 #include <asm/a.out.h>
2880 #include <asm/uaccess.h>
2881 diff -Nurp linux-2.6.22.18/fs/block_dev.c linux-2.6.22.18-vs2.3.0.32/fs/block_dev.c
2882 --- linux-2.6.22.18/fs/block_dev.c 2007-07-22 00:00:15.000000000 +0200
2883 +++ linux-2.6.22.18-vs2.3.0.32/fs/block_dev.c 2008-02-11 12:35:33.000000000 +0100
2885 #include <linux/uio.h>
2886 #include <linux/namei.h>
2887 #include <linux/log2.h>
2888 +#include <linux/vs_device.h>
2889 #include <asm/uaccess.h>
2890 #include "internal.h"
2892 @@ -572,6 +573,7 @@ struct block_device *bdget(dev_t dev)
2893 bdev->bd_invalidated = 0;
2894 inode->i_mode = S_IFBLK;
2895 inode->i_rdev = dev;
2896 + inode->i_mdev = dev;
2897 inode->i_bdev = bdev;
2898 inode->i_data.a_ops = &def_blk_aops;
2899 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2900 @@ -610,6 +612,11 @@ EXPORT_SYMBOL(bdput);
2901 static struct block_device *bd_acquire(struct inode *inode)
2903 struct block_device *bdev;
2906 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2908 + inode->i_mdev = mdev;
2910 spin_lock(&bdev_lock);
2911 bdev = inode->i_bdev;
2912 @@ -620,7 +627,7 @@ static struct block_device *bd_acquire(s
2914 spin_unlock(&bdev_lock);
2916 - bdev = bdget(inode->i_rdev);
2917 + bdev = bdget(mdev);
2919 spin_lock(&bdev_lock);
2920 if (!inode->i_bdev) {
2921 diff -Nurp linux-2.6.22.18/fs/char_dev.c linux-2.6.22.18-vs2.3.0.32/fs/char_dev.c
2922 --- linux-2.6.22.18/fs/char_dev.c 2007-07-21 23:58:44.000000000 +0200
2923 +++ linux-2.6.22.18-vs2.3.0.32/fs/char_dev.c 2008-02-11 12:35:33.000000000 +0100
2925 #include <linux/cdev.h>
2926 #include <linux/mutex.h>
2927 #include <linux/backing-dev.h>
2928 +#include <linux/vs_device.h>
2931 #include <linux/kmod.h>
2932 @@ -363,14 +364,21 @@ int chrdev_open(struct inode * inode, st
2934 struct cdev *new = NULL;
2938 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2940 + inode->i_mdev = mdev;
2942 spin_lock(&cdev_lock);
2945 struct kobject *kobj;
2948 spin_unlock(&cdev_lock);
2949 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2951 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2954 new = container_of(kobj, struct cdev, kobj);
2955 diff -Nurp linux-2.6.22.18/fs/dcache.c linux-2.6.22.18-vs2.3.0.32/fs/dcache.c
2956 --- linux-2.6.22.18/fs/dcache.c 2007-07-22 00:00:15.000000000 +0200
2957 +++ linux-2.6.22.18-vs2.3.0.32/fs/dcache.c 2008-02-11 12:35:33.000000000 +0100
2959 #include <linux/seqlock.h>
2960 #include <linux/swap.h>
2961 #include <linux/bootmem.h>
2962 +#include <linux/vs_limit.h>
2963 #include "internal.h"
2966 @@ -176,6 +177,7 @@ void dput(struct dentry *dentry)
2970 + vx_dentry_dec(dentry);
2972 if (atomic_read(&dentry->d_count) == 1)
2974 @@ -189,6 +191,8 @@ repeat:
2978 + vx_dentry_dec(dentry);
2981 * AV: ->d_delete() is _NOT_ allowed to block now.
2983 @@ -288,6 +292,7 @@ static inline struct dentry * __dget_loc
2984 if (!list_empty(&dentry->d_lru)) {
2985 dentry_stat.nr_unused--;
2986 list_del_init(&dentry->d_lru);
2987 + vx_dentry_inc(dentry);
2991 @@ -898,6 +903,9 @@ struct dentry *d_alloc(struct dentry * p
2992 struct dentry *dentry;
2995 + if (!vx_dentry_avail(1))
2998 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
3001 @@ -946,6 +954,7 @@ struct dentry *d_alloc(struct dentry * p
3003 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
3004 dentry_stat.nr_dentry++;
3005 + vx_dentry_inc(dentry);
3006 spin_unlock(&dcache_lock);
3009 @@ -1295,6 +1304,7 @@ struct dentry * __d_lookup(struct dentry
3011 if (!d_unhashed(dentry)) {
3012 atomic_inc(&dentry->d_count);
3013 + vx_dentry_inc(dentry);
3016 spin_unlock(&dentry->d_lock);
3017 diff -Nurp linux-2.6.22.18/fs/devpts/inode.c linux-2.6.22.18-vs2.3.0.32/fs/devpts/inode.c
3018 --- linux-2.6.22.18/fs/devpts/inode.c 2007-07-22 00:00:15.000000000 +0200
3019 +++ linux-2.6.22.18-vs2.3.0.32/fs/devpts/inode.c 2008-02-11 12:35:33.000000000 +0100
3021 #include <linux/namei.h>
3022 #include <linux/mount.h>
3023 #include <linux/tty.h>
3024 +#include <linux/magic.h>
3025 #include <linux/devpts_fs.h>
3026 #include <linux/parser.h>
3027 #include <linux/fsnotify.h>
3028 +#include <linux/vs_base.h>
3030 -#define DEVPTS_SUPER_MAGIC 0x1cd1
3032 +static int devpts_permission(struct inode *inode, int mask, struct nameidata *nd)
3034 + int ret = -EACCES;
3036 + /* devpts is xid tagged */
3037 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
3038 + ret = generic_permission(inode, mask, NULL);
3042 +static struct inode_operations devpts_file_inode_operations = {
3043 + .permission = devpts_permission,
3046 static struct vfsmount *devpts_mnt;
3047 static struct dentry *devpts_root;
3048 @@ -92,6 +107,25 @@ static int devpts_remount(struct super_b
3052 +static int devpts_filter(struct dentry *de)
3054 + /* devpts is xid tagged */
3055 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
3058 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
3060 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
3063 +static struct file_operations devpts_dir_operations = {
3064 + .open = dcache_dir_open,
3065 + .release = dcache_dir_close,
3066 + .llseek = dcache_dir_lseek,
3067 + .read = generic_read_dir,
3068 + .readdir = devpts_readdir,
3071 static const struct super_operations devpts_sops = {
3072 .statfs = simple_statfs,
3073 .remount_fs = devpts_remount,
3074 @@ -117,8 +151,10 @@ devpts_fill_super(struct super_block *s,
3075 inode->i_uid = inode->i_gid = 0;
3076 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
3077 inode->i_op = &simple_dir_inode_operations;
3078 - inode->i_fop = &simple_dir_operations;
3079 + inode->i_fop = &devpts_dir_operations;
3081 + /* devpts is xid tagged */
3082 + inode->i_tag = (tag_t)vx_current_xid();
3084 devpts_root = s->s_root = d_alloc_root(inode);
3086 @@ -176,6 +212,9 @@ int devpts_pty_new(struct tty_struct *tt
3087 inode->i_gid = config.setgid ? config.gid : current->fsgid;
3088 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
3089 init_special_inode(inode, S_IFCHR|config.mode, device);
3090 + /* devpts is xid tagged */
3091 + inode->i_tag = (tag_t)vx_current_xid();
3092 + inode->i_op = &devpts_file_inode_operations;
3093 inode->i_private = tty;
3095 dentry = get_node(number);
3096 diff -Nurp linux-2.6.22.18/fs/ecryptfs/inode.c linux-2.6.22.18-vs2.3.0.32/fs/ecryptfs/inode.c
3097 --- linux-2.6.22.18/fs/ecryptfs/inode.c 2007-08-12 03:54:36.000000000 +0200
3098 +++ linux-2.6.22.18-vs2.3.0.32/fs/ecryptfs/inode.c 2008-02-11 12:35:33.000000000 +0100
3099 @@ -423,7 +423,7 @@ static int ecryptfs_link(struct dentry *
3100 dget(lower_new_dentry);
3101 lower_dir_dentry = lock_parent(lower_new_dentry);
3102 rc = vfs_link(lower_old_dentry, lower_dir_dentry->d_inode,
3103 - lower_new_dentry);
3104 + lower_new_dentry, NULL);
3105 if (rc || !lower_new_dentry->d_inode)
3107 rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
3108 @@ -451,7 +451,7 @@ static int ecryptfs_unlink(struct inode
3109 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
3111 lock_parent(lower_dentry);
3112 - rc = vfs_unlink(lower_dir_inode, lower_dentry);
3113 + rc = vfs_unlink(lower_dir_inode, lower_dentry, NULL);
3115 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
3117 @@ -488,7 +488,7 @@ static int ecryptfs_symlink(struct inode
3120 rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry,
3121 - encoded_symname, mode);
3122 + encoded_symname, mode, NULL);
3123 kfree(encoded_symname);
3124 if (rc || !lower_dentry->d_inode)
3126 @@ -513,7 +513,7 @@ static int ecryptfs_mkdir(struct inode *
3128 lower_dentry = ecryptfs_dentry_to_lower(dentry);
3129 lower_dir_dentry = lock_parent(lower_dentry);
3130 - rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode);
3131 + rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode, NULL);
3132 if (rc || !lower_dentry->d_inode)
3134 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
3135 @@ -539,7 +539,7 @@ static int ecryptfs_rmdir(struct inode *
3137 lower_dir_dentry = lock_parent(lower_dentry);
3139 - rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry);
3140 + rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry, NULL);
3143 d_delete(lower_dentry);
3144 @@ -561,7 +561,7 @@ ecryptfs_mknod(struct inode *dir, struct
3146 lower_dentry = ecryptfs_dentry_to_lower(dentry);
3147 lower_dir_dentry = lock_parent(lower_dentry);
3148 - rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev);
3149 + rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev, NULL);
3150 if (rc || !lower_dentry->d_inode)
3152 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
3153 diff -Nurp linux-2.6.22.18/fs/exec.c linux-2.6.22.18-vs2.3.0.32/fs/exec.c
3154 --- linux-2.6.22.18/fs/exec.c 2008-02-11 12:34:20.000000000 +0100
3155 +++ linux-2.6.22.18-vs2.3.0.32/fs/exec.c 2008-02-11 12:35:33.000000000 +0100
3157 #include <linux/cn_proc.h>
3158 #include <linux/audit.h>
3159 #include <linux/signalfd.h>
3160 +#include <linux/vs_memory.h>
3162 #include <asm/uaccess.h>
3163 #include <asm/mmu_context.h>
3164 @@ -440,7 +441,8 @@ int setup_arg_pages(struct linux_binprm
3165 kmem_cache_free(vm_area_cachep, mpnt);
3168 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
3169 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
3170 + mm->stack_vm = mm->total_vm;
3173 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
3174 @@ -1336,7 +1338,7 @@ static int format_corename(char *corenam
3175 /* UNIX time of coredump */
3178 - do_gettimeofday(&tv);
3179 + vx_gettimeofday(&tv);
3180 rc = snprintf(out_ptr, out_end - out_ptr,
3182 if (rc > out_end - out_ptr)
3183 diff -Nurp linux-2.6.22.18/fs/ext2/balloc.c linux-2.6.22.18-vs2.3.0.32/fs/ext2/balloc.c
3184 --- linux-2.6.22.18/fs/ext2/balloc.c 2007-07-21 23:58:45.000000000 +0200
3185 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext2/balloc.c 2008-02-11 12:35:33.000000000 +0100
3187 #include <linux/sched.h>
3188 #include <linux/buffer_head.h>
3189 #include <linux/capability.h>
3190 +#include <linux/vs_dlimit.h>
3191 +#include <linux/vs_tag.h>
3194 * balloc.c contains the blocks allocation and deallocation routines
3195 @@ -102,12 +104,13 @@ static int reserve_blocks(struct super_b
3197 struct ext2_sb_info *sbi = EXT2_SB(sb);
3198 struct ext2_super_block *es = sbi->s_es;
3199 - unsigned free_blocks;
3200 - unsigned root_blocks;
3201 + unsigned long long free_blocks, root_blocks;
3203 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3204 root_blocks = le32_to_cpu(es->s_r_blocks_count);
3206 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3208 if (free_blocks < count)
3209 count = free_blocks;
3211 @@ -258,6 +261,7 @@ do_more:
3215 + DLIMIT_FREE_BLOCK(inode, freed);
3216 release_blocks(sb, freed);
3217 DQUOT_FREE_BLOCK(inode, freed);
3219 @@ -361,6 +365,10 @@ int ext2_new_block(struct inode *inode,
3223 + if (DLIMIT_ALLOC_BLOCK(inode, es_alloc)) {
3228 ext2_debug ("goal=%lu.\n", goal);
3230 @@ -508,6 +516,8 @@ got_block:
3233 group_release_blocks(sb, group_no, desc, gdp_bh, group_alloc);
3234 + DLIMIT_FREE_BLOCK(inode, es_alloc);
3236 release_blocks(sb, es_alloc);
3238 DQUOT_FREE_BLOCK(inode, dq_alloc);
3239 diff -Nurp linux-2.6.22.18/fs/ext2/ext2.h linux-2.6.22.18-vs2.3.0.32/fs/ext2/ext2.h
3240 --- linux-2.6.22.18/fs/ext2/ext2.h 2007-07-22 00:00:15.000000000 +0200
3241 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext2/ext2.h 2008-02-11 12:35:33.000000000 +0100
3242 @@ -167,6 +167,7 @@ extern const struct file_operations ext2
3243 extern const struct address_space_operations ext2_aops;
3244 extern const struct address_space_operations ext2_aops_xip;
3245 extern const struct address_space_operations ext2_nobh_aops;
3246 +extern int ext2_sync_flags(struct inode *inode);
3249 extern const struct inode_operations ext2_dir_inode_operations;
3250 diff -Nurp linux-2.6.22.18/fs/ext2/file.c linux-2.6.22.18-vs2.3.0.32/fs/ext2/file.c
3251 --- linux-2.6.22.18/fs/ext2/file.c 2007-07-21 23:58:45.000000000 +0200
3252 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext2/file.c 2008-02-11 12:35:33.000000000 +0100
3253 @@ -85,4 +85,5 @@ const struct inode_operations ext2_file_
3255 .setattr = ext2_setattr,
3256 .permission = ext2_permission,
3257 + .sync_flags = ext2_sync_flags,
3259 diff -Nurp linux-2.6.22.18/fs/ext2/ialloc.c linux-2.6.22.18-vs2.3.0.32/fs/ext2/ialloc.c
3260 --- linux-2.6.22.18/fs/ext2/ialloc.c 2007-05-04 15:57:35.000000000 +0200
3261 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext2/ialloc.c 2008-02-11 12:35:33.000000000 +0100
3263 #include <linux/backing-dev.h>
3264 #include <linux/buffer_head.h>
3265 #include <linux/random.h>
3266 +#include <linux/vs_dlimit.h>
3267 +#include <linux/vs_tag.h>
3271 @@ -125,6 +127,7 @@ void ext2_free_inode (struct inode * ino
3272 ext2_xattr_delete_inode(inode);
3273 DQUOT_FREE_INODE(inode);
3275 + DLIMIT_FREE_INODE(inode);
3278 es = EXT2_SB(sb)->s_es;
3279 @@ -464,6 +467,11 @@ struct inode *ext2_new_inode(struct inod
3281 return ERR_PTR(-ENOMEM);
3283 + inode->i_tag = dx_current_fstag(sb);
3284 + if (DLIMIT_ALLOC_INODE(inode)) {
3291 @@ -577,7 +585,8 @@ got:
3292 inode->i_blocks = 0;
3293 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
3294 memset(ei->i_data, 0, sizeof(ei->i_data));
3295 - ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
3296 + ei->i_flags = EXT2_I(dir)->i_flags &
3297 + ~(EXT2_BTREE_FL|EXT2_IUNLINK_FL|EXT2_BARRIER_FL);
3299 ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
3300 /* dirsync is only applied to directories */
3301 @@ -625,12 +634,15 @@ fail_free_drop:
3305 + DLIMIT_FREE_INODE(inode);
3306 inode->i_flags |= S_NOQUOTA;
3309 return ERR_PTR(err);
3312 + DLIMIT_FREE_INODE(inode);
3314 make_bad_inode(inode);
3316 return ERR_PTR(err);
3317 diff -Nurp linux-2.6.22.18/fs/ext2/inode.c linux-2.6.22.18-vs2.3.0.32/fs/ext2/inode.c
3318 --- linux-2.6.22.18/fs/ext2/inode.c 2007-07-22 00:00:15.000000000 +0200
3319 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext2/inode.c 2008-02-11 12:35:33.000000000 +0100
3321 #include <linux/writeback.h>
3322 #include <linux/buffer_head.h>
3323 #include <linux/mpage.h>
3324 +#include <linux/vs_tag.h>
3328 @@ -913,7 +914,7 @@ void ext2_truncate (struct inode * inode
3330 if (ext2_inode_is_fast_symlink(inode))
3332 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3333 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3336 ext2_discard_prealloc(inode);
3337 @@ -1042,13 +1043,20 @@ void ext2_set_inode_flags(struct inode *
3339 unsigned int flags = EXT2_I(inode)->i_flags;
3341 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3342 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3343 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3345 + if (flags & EXT2_IMMUTABLE_FL)
3346 + inode->i_flags |= S_IMMUTABLE;
3347 + if (flags & EXT2_IUNLINK_FL)
3348 + inode->i_flags |= S_IUNLINK;
3349 + if (flags & EXT2_BARRIER_FL)
3350 + inode->i_flags |= S_BARRIER;
3352 if (flags & EXT2_SYNC_FL)
3353 inode->i_flags |= S_SYNC;
3354 if (flags & EXT2_APPEND_FL)
3355 inode->i_flags |= S_APPEND;
3356 - if (flags & EXT2_IMMUTABLE_FL)
3357 - inode->i_flags |= S_IMMUTABLE;
3358 if (flags & EXT2_NOATIME_FL)
3359 inode->i_flags |= S_NOATIME;
3360 if (flags & EXT2_DIRSYNC_FL)
3361 @@ -1074,12 +1082,37 @@ void ext2_get_inode_flags(struct ext2_in
3362 ei->i_flags |= EXT2_DIRSYNC_FL;
3365 +int ext2_sync_flags(struct inode *inode)
3367 + unsigned int oldflags, newflags;
3369 + oldflags = EXT2_I(inode)->i_flags;
3370 + newflags = oldflags & ~(EXT2_IMMUTABLE_FL |
3371 + EXT2_IUNLINK_FL | EXT2_BARRIER_FL);
3373 + if (IS_IMMUTABLE(inode))
3374 + newflags |= EXT2_IMMUTABLE_FL;
3375 + if (IS_IUNLINK(inode))
3376 + newflags |= EXT2_IUNLINK_FL;
3377 + if (IS_BARRIER(inode))
3378 + newflags |= EXT2_BARRIER_FL;
3380 + if (oldflags ^ newflags) {
3381 + EXT2_I(inode)->i_flags = newflags;
3382 + inode->i_ctime = CURRENT_TIME;
3383 + mark_inode_dirty(inode);
3388 void ext2_read_inode (struct inode * inode)
3390 struct ext2_inode_info *ei = EXT2_I(inode);
3391 ino_t ino = inode->i_ino;
3392 struct buffer_head * bh;
3393 struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh);
3398 #ifdef CONFIG_EXT2_FS_POSIX_ACL
3399 @@ -1090,12 +1123,17 @@ void ext2_read_inode (struct inode * ino
3402 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3403 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3404 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3405 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3406 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3407 if (!(test_opt (inode->i_sb, NO_UID32))) {
3408 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3409 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3410 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3411 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3413 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3414 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3415 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3416 + le16_to_cpu(raw_inode->i_raw_tag));
3418 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3419 inode->i_size = le32_to_cpu(raw_inode->i_size);
3420 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3421 @@ -1192,8 +1230,8 @@ static int ext2_update_inode(struct inod
3422 struct ext2_inode_info *ei = EXT2_I(inode);
3423 struct super_block *sb = inode->i_sb;
3424 ino_t ino = inode->i_ino;
3425 - uid_t uid = inode->i_uid;
3426 - gid_t gid = inode->i_gid;
3427 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3428 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3429 struct buffer_head * bh;
3430 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
3432 @@ -1229,6 +1267,9 @@ static int ext2_update_inode(struct inod
3433 raw_inode->i_uid_high = 0;
3434 raw_inode->i_gid_high = 0;
3436 +#ifdef CONFIG_TAGGING_INTERN
3437 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3439 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3440 raw_inode->i_size = cpu_to_le32(inode->i_size);
3441 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3442 @@ -1315,7 +1356,8 @@ int ext2_setattr(struct dentry *dentry,
3445 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3446 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3447 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3448 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3449 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
3452 diff -Nurp linux-2.6.22.18/fs/ext2/ioctl.c linux-2.6.22.18-vs2.3.0.32/fs/ext2/ioctl.c
3453 --- linux-2.6.22.18/fs/ext2/ioctl.c 2007-07-22 00:00:15.000000000 +0200
3454 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext2/ioctl.c 2008-02-11 12:35:33.000000000 +0100
3456 #include <linux/sched.h>
3457 #include <linux/compat.h>
3458 #include <linux/smp_lock.h>
3459 +#include <linux/mount.h>
3460 #include <asm/current.h>
3461 #include <asm/uaccess.h>
3463 @@ -33,7 +34,8 @@ int ext2_ioctl (struct inode * inode, st
3464 case EXT2_IOC_SETFLAGS: {
3465 unsigned int oldflags;
3467 - if (IS_RDONLY(inode))
3468 + if (IS_RDONLY(inode) ||
3469 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3472 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3473 @@ -54,7 +56,9 @@ int ext2_ioctl (struct inode * inode, st
3475 * This test looks nicer. Thanks to Pauline Middelink
3477 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
3478 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3479 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3480 + EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL))) {
3481 if (!capable(CAP_LINUX_IMMUTABLE)) {
3482 mutex_unlock(&inode->i_mutex);
3484 @@ -76,7 +80,8 @@ int ext2_ioctl (struct inode * inode, st
3485 case EXT2_IOC_SETVERSION:
3486 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3488 - if (IS_RDONLY(inode))
3489 + if (IS_RDONLY(inode) ||
3490 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3492 if (get_user(inode->i_generation, (int __user *) arg))
3494 diff -Nurp linux-2.6.22.18/fs/ext2/namei.c linux-2.6.22.18-vs2.3.0.32/fs/ext2/namei.c
3495 --- linux-2.6.22.18/fs/ext2/namei.c 2007-07-21 23:58:45.000000000 +0200
3496 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext2/namei.c 2008-02-11 12:35:33.000000000 +0100
3500 #include <linux/pagemap.h>
3501 +#include <linux/vs_tag.h>
3505 @@ -66,6 +67,7 @@ static struct dentry *ext2_lookup(struct
3506 inode = iget(dir->i_sb, ino);
3508 return ERR_PTR(-EACCES);
3509 + dx_propagate_tag(nd, inode);
3511 return d_splice_alias(inode, dentry);
3513 @@ -391,6 +393,7 @@ const struct inode_operations ext2_dir_i
3515 .setattr = ext2_setattr,
3516 .permission = ext2_permission,
3517 + .sync_flags = ext2_sync_flags,
3520 const struct inode_operations ext2_special_inode_operations = {
3521 @@ -402,4 +405,5 @@ const struct inode_operations ext2_speci
3523 .setattr = ext2_setattr,
3524 .permission = ext2_permission,
3525 + .sync_flags = ext2_sync_flags,
3527 diff -Nurp linux-2.6.22.18/fs/ext2/super.c linux-2.6.22.18-vs2.3.0.32/fs/ext2/super.c
3528 --- linux-2.6.22.18/fs/ext2/super.c 2007-07-22 00:00:15.000000000 +0200
3529 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext2/super.c 2008-02-11 12:35:33.000000000 +0100
3530 @@ -321,7 +321,7 @@ enum {
3531 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3532 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3533 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3534 - Opt_usrquota, Opt_grpquota
3535 + Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3538 static match_table_t tokens = {
3539 @@ -349,6 +349,9 @@ static match_table_t tokens = {
3541 {Opt_noacl, "noacl"},
3544 + {Opt_notag, "notag"},
3545 + {Opt_tagid, "tagid=%u"},
3546 {Opt_grpquota, "grpquota"},
3547 {Opt_ignore, "noquota"},
3548 {Opt_quota, "quota"},
3549 @@ -417,6 +420,20 @@ static int parse_options (char * options
3551 set_opt (sbi->s_mount_opt, NO_UID32);
3553 +#ifndef CONFIG_TAGGING_NONE
3555 + set_opt (sbi->s_mount_opt, TAGGED);
3558 + clear_opt (sbi->s_mount_opt, TAGGED);
3561 +#ifdef CONFIG_PROPAGATE
3564 + set_opt (sbi->s_mount_opt, TAGGED);
3568 clear_opt (sbi->s_mount_opt, CHECK);
3570 @@ -727,6 +744,8 @@ static int ext2_fill_super(struct super_
3571 if (!parse_options ((char *) data, sbi))
3574 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3575 + sb->s_flags |= MS_TAGGED;
3576 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3577 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3579 @@ -1035,6 +1054,13 @@ static int ext2_remount (struct super_bl
3583 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3584 + !(sb->s_flags & MS_TAGGED)) {
3585 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3590 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3591 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3593 diff -Nurp linux-2.6.22.18/fs/ext2/symlink.c linux-2.6.22.18-vs2.3.0.32/fs/ext2/symlink.c
3594 --- linux-2.6.22.18/fs/ext2/symlink.c 2007-07-21 23:58:45.000000000 +0200
3595 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext2/symlink.c 2008-02-11 12:35:33.000000000 +0100
3596 @@ -38,6 +38,7 @@ const struct inode_operations ext2_symli
3597 .listxattr = ext2_listxattr,
3598 .removexattr = generic_removexattr,
3600 + .sync_flags = ext2_sync_flags,
3603 const struct inode_operations ext2_fast_symlink_inode_operations = {
3604 @@ -49,4 +50,5 @@ const struct inode_operations ext2_fast_
3605 .listxattr = ext2_listxattr,
3606 .removexattr = generic_removexattr,
3608 + .sync_flags = ext2_sync_flags,
3610 diff -Nurp linux-2.6.22.18/fs/ext2/xattr.c linux-2.6.22.18-vs2.3.0.32/fs/ext2/xattr.c
3611 --- linux-2.6.22.18/fs/ext2/xattr.c 2007-05-04 15:58:21.000000000 +0200
3612 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext2/xattr.c 2008-02-11 12:35:33.000000000 +0100
3614 #include <linux/mbcache.h>
3615 #include <linux/quotaops.h>
3616 #include <linux/rwsem.h>
3617 +#include <linux/vs_dlimit.h>
3621 @@ -641,8 +642,12 @@ ext2_xattr_set2(struct inode *inode, str
3623 ea_bdebug(new_bh, "reusing block");
3626 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3629 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
3630 + DLIMIT_FREE_BLOCK(inode, 1);
3631 unlock_buffer(new_bh);
3634 @@ -736,6 +741,7 @@ ext2_xattr_set2(struct inode *inode, str
3635 le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
3637 mb_cache_entry_release(ce);
3638 + DLIMIT_FREE_BLOCK(inode, 1);
3639 DQUOT_FREE_BLOCK(inode, 1);
3640 mark_buffer_dirty(old_bh);
3641 ea_bdebug(old_bh, "refcount now=%d",
3642 @@ -800,6 +806,7 @@ ext2_xattr_delete_inode(struct inode *in
3643 mark_buffer_dirty(bh);
3645 sync_dirty_buffer(bh);
3646 + DLIMIT_FREE_BLOCK(inode, 1);
3647 DQUOT_FREE_BLOCK(inode, 1);
3649 EXT2_I(inode)->i_file_acl = 0;
3650 diff -Nurp linux-2.6.22.18/fs/ext3/balloc.c linux-2.6.22.18-vs2.3.0.32/fs/ext3/balloc.c
3651 --- linux-2.6.22.18/fs/ext3/balloc.c 2007-07-21 23:58:45.000000000 +0200
3652 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext3/balloc.c 2008-02-11 12:35:33.000000000 +0100
3654 #include <linux/ext3_jbd.h>
3655 #include <linux/quotaops.h>
3656 #include <linux/buffer_head.h>
3657 +#include <linux/vs_dlimit.h>
3658 +#include <linux/vs_tag.h>
3661 * balloc.c contains the blocks allocation and deallocation routines
3662 @@ -613,8 +615,10 @@ void ext3_free_blocks(handle_t *handle,
3665 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
3666 - if (dquot_freed_blocks)
3667 + if (dquot_freed_blocks) {
3668 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3669 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3674 @@ -1353,18 +1357,33 @@ out:
3676 * Check if filesystem has at least 1 free block available for allocation.
3678 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
3679 +static int ext3_has_free_blocks(struct super_block *sb)
3681 - ext3_fsblk_t free_blocks, root_blocks;
3682 + struct ext3_sb_info *sbi = EXT3_SB(sb);
3683 + unsigned long long free_blocks, root_blocks;
3686 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3687 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
3688 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
3690 + vxdprintk(VXD_CBIT(dlim, 3),
3691 + "ext3_has_free_blocks(%p): free=%llu, root=%llu",
3692 + sb, free_blocks, root_blocks);
3694 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3696 + cond = (free_blocks < root_blocks + 1 &&
3697 + !capable(CAP_SYS_RESOURCE) &&
3698 sbi->s_resuid != current->fsuid &&
3699 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
3703 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
3705 + vxdprintk(VXD_CBIT(dlim, 3),
3706 + "ext3_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
3707 + sb, free_blocks, root_blocks,
3708 + !capable(CAP_SYS_RESOURCE)?'1':'0',
3709 + sbi->s_resuid, current->fsuid, cond?0:1);
3711 + return (cond ? 0 : 1);
3715 @@ -1381,7 +1400,7 @@ static int ext3_has_free_blocks(struct e
3717 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
3719 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
3720 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
3723 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
3724 @@ -1444,6 +1463,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3728 + if (DLIMIT_ALLOC_BLOCK(inode, num))
3732 es = EXT3_SB(sb)->s_es;
3733 @@ -1460,7 +1481,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3734 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
3735 my_rsv = &block_i->rsv_window_node;
3737 - if (!ext3_has_free_blocks(sbi)) {
3738 + if (!ext3_has_free_blocks(sb)) {
3742 @@ -1647,12 +1668,16 @@ allocated:
3745 DQUOT_FREE_BLOCK(inode, *count-num);
3746 + DLIMIT_FREE_BLOCK(inode, *count-num);
3753 + if (!performed_allocation)
3754 + DLIMIT_FREE_BLOCK(inode, *count);
3758 ext3_std_error(sb, fatal);
3759 diff -Nurp linux-2.6.22.18/fs/ext3/file.c linux-2.6.22.18-vs2.3.0.32/fs/ext3/file.c
3760 --- linux-2.6.22.18/fs/ext3/file.c 2007-07-21 23:58:45.000000000 +0200
3761 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext3/file.c 2008-02-11 12:35:33.000000000 +0100
3762 @@ -135,5 +135,6 @@ const struct inode_operations ext3_file_
3763 .removexattr = generic_removexattr,
3765 .permission = ext3_permission,
3766 + .sync_flags = ext3_sync_flags,
3769 diff -Nurp linux-2.6.22.18/fs/ext3/ialloc.c linux-2.6.22.18-vs2.3.0.32/fs/ext3/ialloc.c
3770 --- linux-2.6.22.18/fs/ext3/ialloc.c 2007-05-04 15:57:35.000000000 +0200
3771 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext3/ialloc.c 2008-02-11 12:35:33.000000000 +0100
3773 #include <linux/buffer_head.h>
3774 #include <linux/random.h>
3775 #include <linux/bitops.h>
3776 +#include <linux/vs_dlimit.h>
3777 +#include <linux/vs_tag.h>
3779 #include <asm/byteorder.h>
3781 @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle,
3782 ext3_xattr_delete_inode(handle, inode);
3783 DQUOT_FREE_INODE(inode);
3785 + DLIMIT_FREE_INODE(inode);
3787 is_directory = S_ISDIR(inode->i_mode);
3789 @@ -445,6 +448,12 @@ struct inode *ext3_new_inode(handle_t *h
3790 inode = new_inode(sb);
3792 return ERR_PTR(-ENOMEM);
3794 + inode->i_tag = dx_current_fstag(sb);
3795 + if (DLIMIT_ALLOC_INODE(inode)) {
3802 @@ -566,7 +575,8 @@ got:
3803 ei->i_dir_start_lookup = 0;
3806 - ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
3807 + ei->i_flags = EXT3_I(dir)->i_flags &
3808 + ~(EXT3_INDEX_FL|EXT3_IUNLINK_FL|EXT3_BARRIER_FL);
3810 ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
3811 /* dirsync only applies to directories */
3812 @@ -621,6 +631,8 @@ got:
3814 ext3_std_error(sb, err);
3816 + DLIMIT_FREE_INODE(inode);
3821 @@ -632,6 +644,7 @@ fail_free_drop:
3825 + DLIMIT_FREE_INODE(inode);
3826 inode->i_flags |= S_NOQUOTA;
3829 diff -Nurp linux-2.6.22.18/fs/ext3/inode.c linux-2.6.22.18-vs2.3.0.32/fs/ext3/inode.c
3830 --- linux-2.6.22.18/fs/ext3/inode.c 2007-07-22 00:00:15.000000000 +0200
3831 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext3/inode.c 2008-02-11 12:35:33.000000000 +0100
3833 #include <linux/mpage.h>
3834 #include <linux/uio.h>
3835 #include <linux/bio.h>
3836 +#include <linux/vs_tag.h>
3840 @@ -2237,7 +2238,7 @@ void ext3_truncate(struct inode *inode)
3842 if (ext3_inode_is_fast_symlink(inode))
3844 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3845 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3849 @@ -2559,13 +2560,20 @@ void ext3_set_inode_flags(struct inode *
3851 unsigned int flags = EXT3_I(inode)->i_flags;
3853 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3854 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3855 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3857 + if (flags & EXT3_IMMUTABLE_FL)
3858 + inode->i_flags |= S_IMMUTABLE;
3859 + if (flags & EXT3_IUNLINK_FL)
3860 + inode->i_flags |= S_IUNLINK;
3861 + if (flags & EXT3_BARRIER_FL)
3862 + inode->i_flags |= S_BARRIER;
3864 if (flags & EXT3_SYNC_FL)
3865 inode->i_flags |= S_SYNC;
3866 if (flags & EXT3_APPEND_FL)
3867 inode->i_flags |= S_APPEND;
3868 - if (flags & EXT3_IMMUTABLE_FL)
3869 - inode->i_flags |= S_IMMUTABLE;
3870 if (flags & EXT3_NOATIME_FL)
3871 inode->i_flags |= S_NOATIME;
3872 if (flags & EXT3_DIRSYNC_FL)
3873 @@ -2591,6 +2599,45 @@ void ext3_get_inode_flags(struct ext3_in
3874 ei->i_flags |= EXT3_DIRSYNC_FL;
3877 +int ext3_sync_flags(struct inode *inode)
3879 + unsigned int oldflags, newflags;
3882 + oldflags = EXT3_I(inode)->i_flags;
3883 + newflags = oldflags & ~(EXT3_IMMUTABLE_FL |
3884 + EXT3_IUNLINK_FL | EXT3_BARRIER_FL);
3886 + if (IS_IMMUTABLE(inode))
3887 + newflags |= EXT3_IMMUTABLE_FL;
3888 + if (IS_IUNLINK(inode))
3889 + newflags |= EXT3_IUNLINK_FL;
3890 + if (IS_BARRIER(inode))
3891 + newflags |= EXT3_BARRIER_FL;
3893 + if (oldflags ^ newflags) {
3895 + struct ext3_iloc iloc;
3897 + handle = ext3_journal_start(inode, 1);
3898 + if (IS_ERR(handle))
3899 + return PTR_ERR(handle);
3900 + if (IS_SYNC(inode))
3901 + handle->h_sync = 1;
3902 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3906 + EXT3_I(inode)->i_flags = newflags;
3907 + inode->i_ctime = CURRENT_TIME;
3909 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3911 + ext3_journal_stop(handle);
3916 void ext3_read_inode(struct inode * inode)
3918 struct ext3_iloc iloc;
3919 @@ -2598,6 +2645,8 @@ void ext3_read_inode(struct inode * inod
3920 struct ext3_inode_info *ei = EXT3_I(inode);
3921 struct buffer_head *bh;
3926 #ifdef CONFIG_EXT3_FS_POSIX_ACL
3927 ei->i_acl = EXT3_ACL_NOT_CACHED;
3928 @@ -2610,12 +2659,17 @@ void ext3_read_inode(struct inode * inod
3930 raw_inode = ext3_raw_inode(&iloc);
3931 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3932 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3933 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3934 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3935 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3936 if(!(test_opt (inode->i_sb, NO_UID32))) {
3937 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3938 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3939 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3940 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3942 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3943 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3944 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3945 + le16_to_cpu(raw_inode->i_raw_tag));
3947 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3948 inode->i_size = le32_to_cpu(raw_inode->i_size);
3949 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3950 @@ -2741,6 +2795,8 @@ static int ext3_do_update_inode(handle_t
3951 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3952 struct ext3_inode_info *ei = EXT3_I(inode);
3953 struct buffer_head *bh = iloc->bh;
3954 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3955 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3956 int err = 0, rc, block;
3958 /* For fields not not tracking in the in-memory inode,
3959 @@ -2751,29 +2807,32 @@ static int ext3_do_update_inode(handle_t
3960 ext3_get_inode_flags(ei);
3961 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3962 if(!(test_opt(inode->i_sb, NO_UID32))) {
3963 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3964 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3965 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3966 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3968 * Fix up interoperability with old kernels. Otherwise, old inodes get
3969 * re-used with the upper 16 bits of the uid/gid intact
3972 raw_inode->i_uid_high =
3973 - cpu_to_le16(high_16_bits(inode->i_uid));
3974 + cpu_to_le16(high_16_bits(uid));
3975 raw_inode->i_gid_high =
3976 - cpu_to_le16(high_16_bits(inode->i_gid));
3977 + cpu_to_le16(high_16_bits(gid));
3979 raw_inode->i_uid_high = 0;
3980 raw_inode->i_gid_high = 0;
3983 raw_inode->i_uid_low =
3984 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3985 + cpu_to_le16(fs_high2lowuid(uid));
3986 raw_inode->i_gid_low =
3987 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3988 + cpu_to_le16(fs_high2lowgid(gid));
3989 raw_inode->i_uid_high = 0;
3990 raw_inode->i_gid_high = 0;
3992 +#ifdef CONFIG_TAGGING_INTERN
3993 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3995 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3996 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3997 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3998 @@ -2926,7 +2985,8 @@ int ext3_setattr(struct dentry *dentry,
4001 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4002 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4003 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4004 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4007 /* (user+group)*(old+new) structure, inode write (sb,
4008 @@ -2948,6 +3008,8 @@ int ext3_setattr(struct dentry *dentry,
4009 inode->i_uid = attr->ia_uid;
4010 if (attr->ia_valid & ATTR_GID)
4011 inode->i_gid = attr->ia_gid;
4012 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4013 + inode->i_tag = attr->ia_tag;
4014 error = ext3_mark_inode_dirty(handle, inode);
4015 ext3_journal_stop(handle);
4017 diff -Nurp linux-2.6.22.18/fs/ext3/ioctl.c linux-2.6.22.18-vs2.3.0.32/fs/ext3/ioctl.c
4018 --- linux-2.6.22.18/fs/ext3/ioctl.c 2007-07-22 00:00:15.000000000 +0200
4019 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext3/ioctl.c 2008-02-11 12:35:34.000000000 +0100
4023 #include <linux/fs.h>
4024 +#include <linux/mount.h>
4025 #include <linux/jbd.h>
4026 #include <linux/capability.h>
4027 #include <linux/ext3_fs.h>
4029 #include <linux/time.h>
4030 #include <linux/compat.h>
4031 #include <linux/smp_lock.h>
4032 +#include <linux/vs_tag.h>
4033 #include <asm/uaccess.h>
4035 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
4036 @@ -38,7 +40,8 @@ int ext3_ioctl (struct inode * inode, st
4037 unsigned int oldflags;
4040 - if (IS_RDONLY(inode))
4041 + if (IS_RDONLY(inode) ||
4042 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4045 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4046 @@ -62,7 +65,9 @@ int ext3_ioctl (struct inode * inode, st
4048 * This test looks nicer. Thanks to Pauline Middelink
4050 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
4051 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
4052 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
4053 + EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL))) {
4054 if (!capable(CAP_LINUX_IMMUTABLE)) {
4055 mutex_unlock(&inode->i_mutex);
4057 @@ -124,7 +129,8 @@ flags_err:
4059 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4061 - if (IS_RDONLY(inode))
4062 + if (IS_RDONLY(inode) ||
4063 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4065 if (get_user(generation, (int __user *) arg))
4067 @@ -178,7 +184,8 @@ flags_err:
4068 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
4071 - if (IS_RDONLY(inode))
4072 + if (IS_RDONLY(inode) ||
4073 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4076 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4077 @@ -213,7 +220,8 @@ flags_err:
4078 if (!capable(CAP_SYS_RESOURCE))
4081 - if (IS_RDONLY(inode))
4082 + if (IS_RDONLY(inode) ||
4083 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4086 if (get_user(n_blocks_count, (__u32 __user *)arg))
4087 @@ -234,7 +242,8 @@ flags_err:
4088 if (!capable(CAP_SYS_RESOURCE))
4091 - if (IS_RDONLY(inode))
4092 + if (IS_RDONLY(inode) ||
4093 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4096 if (copy_from_user(&input, (struct ext3_new_group_input __user *)arg,
4097 diff -Nurp linux-2.6.22.18/fs/ext3/namei.c linux-2.6.22.18-vs2.3.0.32/fs/ext3/namei.c
4098 --- linux-2.6.22.18/fs/ext3/namei.c 2007-09-29 14:11:49.000000000 +0200
4099 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext3/namei.c 2008-02-11 12:35:34.000000000 +0100
4101 #include <linux/quotaops.h>
4102 #include <linux/buffer_head.h>
4103 #include <linux/bio.h>
4104 +#include <linux/vs_tag.h>
4108 @@ -1052,6 +1053,7 @@ static struct dentry *ext3_lookup(struct
4111 return ERR_PTR(-EACCES);
4112 + dx_propagate_tag(nd, inode);
4114 return d_splice_alias(inode, dentry);
4116 @@ -2443,6 +2445,7 @@ const struct inode_operations ext3_dir_i
4117 .removexattr = generic_removexattr,
4119 .permission = ext3_permission,
4120 + .sync_flags = ext3_sync_flags,
4123 const struct inode_operations ext3_special_inode_operations = {
4124 @@ -2454,4 +2457,5 @@ const struct inode_operations ext3_speci
4125 .removexattr = generic_removexattr,
4127 .permission = ext3_permission,
4128 + .sync_flags = ext3_sync_flags,
4130 diff -Nurp linux-2.6.22.18/fs/ext3/super.c linux-2.6.22.18-vs2.3.0.32/fs/ext3/super.c
4131 --- linux-2.6.22.18/fs/ext3/super.c 2007-07-22 00:00:15.000000000 +0200
4132 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext3/super.c 2008-02-11 12:35:34.000000000 +0100
4133 @@ -674,7 +674,7 @@ enum {
4134 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4135 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4136 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4138 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
4141 static match_table_t tokens = {
4142 @@ -724,6 +724,9 @@ static match_table_t tokens = {
4143 {Opt_quota, "quota"},
4144 {Opt_usrquota, "usrquota"},
4145 {Opt_barrier, "barrier=%u"},
4147 + {Opt_notag, "notag"},
4148 + {Opt_tagid, "tagid=%u"},
4150 {Opt_resize, "resize"},
4152 @@ -817,6 +820,20 @@ static int parse_options (char *options,
4154 set_opt (sbi->s_mount_opt, NO_UID32);
4156 +#ifndef CONFIG_TAGGING_NONE
4158 + set_opt (sbi->s_mount_opt, TAGGED);
4161 + clear_opt (sbi->s_mount_opt, TAGGED);
4164 +#ifdef CONFIG_PROPAGATE
4167 + set_opt (sbi->s_mount_opt, TAGGED);
4171 clear_opt (sbi->s_mount_opt, CHECK);
4173 @@ -1487,6 +1504,9 @@ static int ext3_fill_super (struct super
4177 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
4178 + sb->s_flags |= MS_TAGGED;
4180 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4181 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4183 @@ -2302,6 +2322,12 @@ static int ext3_remount (struct super_bl
4185 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
4186 ext3_abort(sb, __FUNCTION__, "Abort forced by user");
4187 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
4188 + !(sb->s_flags & MS_TAGGED)) {
4189 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
4194 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4195 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4196 diff -Nurp linux-2.6.22.18/fs/ext3/symlink.c linux-2.6.22.18-vs2.3.0.32/fs/ext3/symlink.c
4197 --- linux-2.6.22.18/fs/ext3/symlink.c 2007-07-21 23:58:45.000000000 +0200
4198 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext3/symlink.c 2008-02-11 12:35:34.000000000 +0100
4199 @@ -40,6 +40,7 @@ const struct inode_operations ext3_symli
4200 .listxattr = ext3_listxattr,
4201 .removexattr = generic_removexattr,
4203 + .sync_flags = ext3_sync_flags,
4206 const struct inode_operations ext3_fast_symlink_inode_operations = {
4207 @@ -51,4 +52,5 @@ const struct inode_operations ext3_fast_
4208 .listxattr = ext3_listxattr,
4209 .removexattr = generic_removexattr,
4211 + .sync_flags = ext3_sync_flags,
4213 diff -Nurp linux-2.6.22.18/fs/ext3/xattr.c linux-2.6.22.18-vs2.3.0.32/fs/ext3/xattr.c
4214 --- linux-2.6.22.18/fs/ext3/xattr.c 2007-07-21 23:58:45.000000000 +0200
4215 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext3/xattr.c 2008-02-11 12:35:34.000000000 +0100
4217 #include <linux/mbcache.h>
4218 #include <linux/quotaops.h>
4219 #include <linux/rwsem.h>
4220 +#include <linux/vs_dlimit.h>
4224 @@ -497,6 +498,7 @@ ext3_xattr_release_block(handle_t *handl
4225 error = ext3_journal_dirty_metadata(handle, bh);
4228 + DLIMIT_FREE_BLOCK(inode, 1);
4229 DQUOT_FREE_BLOCK(inode, 1);
4230 ea_bdebug(bh, "refcount now=%d; releasing",
4231 le32_to_cpu(BHDR(bh)->h_refcount));
4232 @@ -771,11 +773,14 @@ inserted:
4233 if (new_bh == bs->bh)
4234 ea_bdebug(new_bh, "keeping");
4237 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4239 /* The old block is released after updating
4242 if (DQUOT_ALLOC_BLOCK(inode, 1))
4244 + goto cleanup_dlimit;
4245 error = ext3_journal_get_write_access(handle,
4248 @@ -852,6 +857,8 @@ cleanup:
4251 DQUOT_FREE_BLOCK(inode, 1);
4253 + DLIMIT_FREE_BLOCK(inode, 1);
4257 diff -Nurp linux-2.6.22.18/fs/ext4/balloc.c linux-2.6.22.18-vs2.3.0.32/fs/ext4/balloc.c
4258 --- linux-2.6.22.18/fs/ext4/balloc.c 2007-07-22 00:00:15.000000000 +0200
4259 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext4/balloc.c 2008-02-11 12:35:34.000000000 +0100
4261 #include <linux/ext4_jbd2.h>
4262 #include <linux/quotaops.h>
4263 #include <linux/buffer_head.h>
4264 +#include <linux/vs_dlimit.h>
4265 +#include <linux/vs_tag.h>
4268 * balloc.c contains the blocks allocation and deallocation routines
4269 @@ -630,8 +632,10 @@ void ext4_free_blocks(handle_t *handle,
4272 ext4_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
4273 - if (dquot_freed_blocks)
4274 + if (dquot_freed_blocks) {
4275 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
4276 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
4281 @@ -1370,18 +1374,33 @@ out:
4283 * Check if filesystem has at least 1 free block available for allocation.
4285 -static int ext4_has_free_blocks(struct ext4_sb_info *sbi)
4286 +static int ext4_has_free_blocks(struct super_block *sb)
4288 + struct ext4_sb_info *sbi = EXT4_SB(sb);
4289 ext4_fsblk_t free_blocks, root_blocks;
4292 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
4293 root_blocks = ext4_r_blocks_count(sbi->s_es);
4294 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
4296 + vxdprintk(VXD_CBIT(dlim, 3),
4297 + "ext4_has_free_blocks(%p): free=%llu, root=%llu",
4298 + sb, free_blocks, root_blocks);
4300 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
4302 + cond = (free_blocks < root_blocks + 1 &&
4303 + !capable(CAP_SYS_RESOURCE) &&
4304 sbi->s_resuid != current->fsuid &&
4305 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
4309 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
4311 + vxdprintk(VXD_CBIT(dlim, 3),
4312 + "ext4_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
4313 + sb, free_blocks, root_blocks,
4314 + !capable(CAP_SYS_RESOURCE)?'1':'0',
4315 + sbi->s_resuid, current->fsuid, cond?0:1);
4317 + return (cond ? 0 : 1);
4321 @@ -1398,7 +1417,7 @@ static int ext4_has_free_blocks(struct e
4323 int ext4_should_retry_alloc(struct super_block *sb, int *retries)
4325 - if (!ext4_has_free_blocks(EXT4_SB(sb)) || (*retries)++ > 3)
4326 + if (!ext4_has_free_blocks(sb) || (*retries)++ > 3)
4329 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
4330 @@ -1461,6 +1480,8 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
4334 + if (DLIMIT_ALLOC_BLOCK(inode, num))
4338 es = EXT4_SB(sb)->s_es;
4339 @@ -1477,7 +1498,7 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
4340 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
4341 my_rsv = &block_i->rsv_window_node;
4343 - if (!ext4_has_free_blocks(sbi)) {
4344 + if (!ext4_has_free_blocks(sb)) {
4348 @@ -1661,12 +1682,16 @@ allocated:
4351 DQUOT_FREE_BLOCK(inode, *count-num);
4352 + DLIMIT_FREE_BLOCK(inode, *count-num);
4359 + if (!performed_allocation)
4360 + DLIMIT_FREE_BLOCK(inode, *count);
4364 ext4_std_error(sb, fatal);
4365 diff -Nurp linux-2.6.22.18/fs/ext4/file.c linux-2.6.22.18-vs2.3.0.32/fs/ext4/file.c
4366 --- linux-2.6.22.18/fs/ext4/file.c 2007-07-21 23:58:45.000000000 +0200
4367 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext4/file.c 2008-02-11 12:35:34.000000000 +0100
4368 @@ -135,5 +135,6 @@ const struct inode_operations ext4_file_
4369 .removexattr = generic_removexattr,
4371 .permission = ext4_permission,
4372 + .sync_flags = ext4_sync_flags,
4375 diff -Nurp linux-2.6.22.18/fs/ext4/ialloc.c linux-2.6.22.18-vs2.3.0.32/fs/ext4/ialloc.c
4376 --- linux-2.6.22.18/fs/ext4/ialloc.c 2007-05-04 15:57:35.000000000 +0200
4377 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext4/ialloc.c 2008-02-11 12:35:34.000000000 +0100
4379 #include <linux/random.h>
4380 #include <linux/bitops.h>
4381 #include <linux/blkdev.h>
4382 +#include <linux/vs_dlimit.h>
4383 +#include <linux/vs_tag.h>
4384 #include <asm/byteorder.h>
4387 @@ -127,6 +129,7 @@ void ext4_free_inode (handle_t *handle,
4388 ext4_xattr_delete_inode(handle, inode);
4389 DQUOT_FREE_INODE(inode);
4391 + DLIMIT_FREE_INODE(inode);
4393 is_directory = S_ISDIR(inode->i_mode);
4395 @@ -448,6 +451,12 @@ struct inode *ext4_new_inode(handle_t *h
4396 inode = new_inode(sb);
4398 return ERR_PTR(-ENOMEM);
4400 + inode->i_tag = dx_current_fstag(sb);
4401 + if (DLIMIT_ALLOC_INODE(inode)) {
4408 @@ -569,7 +578,8 @@ got:
4409 ei->i_dir_start_lookup = 0;
4412 - ei->i_flags = EXT4_I(dir)->i_flags & ~EXT4_INDEX_FL;
4413 + ei->i_flags = EXT4_I(dir)->i_flags &
4414 + ~(EXT4_INDEX_FL|EXT4_IUNLINK_FL|EXT4_BARRIER_FL);
4416 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
4417 /* dirsync only applies to directories */
4418 @@ -635,6 +645,8 @@ got:
4420 ext4_std_error(sb, err);
4422 + DLIMIT_FREE_INODE(inode);
4427 @@ -646,6 +658,7 @@ fail_free_drop:
4431 + DLIMIT_FREE_INODE(inode);
4432 inode->i_flags |= S_NOQUOTA;
4435 diff -Nurp linux-2.6.22.18/fs/ext4/inode.c linux-2.6.22.18-vs2.3.0.32/fs/ext4/inode.c
4436 --- linux-2.6.22.18/fs/ext4/inode.c 2007-07-22 00:00:15.000000000 +0200
4437 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext4/inode.c 2008-02-11 12:35:34.000000000 +0100
4439 #include <linux/mpage.h>
4440 #include <linux/uio.h>
4441 #include <linux/bio.h>
4442 +#include <linux/vs_tag.h>
4446 @@ -2244,7 +2245,7 @@ void ext4_truncate(struct inode *inode)
4448 if (ext4_inode_is_fast_symlink(inode))
4450 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4451 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4455 @@ -2570,19 +2571,65 @@ void ext4_set_inode_flags(struct inode *
4457 unsigned int flags = EXT4_I(inode)->i_flags;
4459 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4460 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
4461 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4463 + if (flags & EXT4_IMMUTABLE_FL)
4464 + inode->i_flags |= S_IMMUTABLE;
4465 + if (flags & EXT4_IUNLINK_FL)
4466 + inode->i_flags |= S_IUNLINK;
4467 + if (flags & EXT4_BARRIER_FL)
4468 + inode->i_flags |= S_BARRIER;
4470 if (flags & EXT4_SYNC_FL)
4471 inode->i_flags |= S_SYNC;
4472 if (flags & EXT4_APPEND_FL)
4473 inode->i_flags |= S_APPEND;
4474 - if (flags & EXT4_IMMUTABLE_FL)
4475 - inode->i_flags |= S_IMMUTABLE;
4476 if (flags & EXT4_NOATIME_FL)
4477 inode->i_flags |= S_NOATIME;
4478 if (flags & EXT4_DIRSYNC_FL)
4479 inode->i_flags |= S_DIRSYNC;
4482 +int ext4_sync_flags(struct inode *inode)
4484 + unsigned int oldflags, newflags;
4487 + oldflags = EXT4_I(inode)->i_flags;
4488 + newflags = oldflags & ~(EXT4_IMMUTABLE_FL |
4489 + EXT4_IUNLINK_FL | EXT4_BARRIER_FL);
4491 + if (IS_IMMUTABLE(inode))
4492 + newflags |= EXT4_IMMUTABLE_FL;
4493 + if (IS_IUNLINK(inode))
4494 + newflags |= EXT4_IUNLINK_FL;
4495 + if (IS_BARRIER(inode))
4496 + newflags |= EXT4_BARRIER_FL;
4498 + if (oldflags ^ newflags) {
4500 + struct ext4_iloc iloc;
4502 + handle = ext4_journal_start(inode, 1);
4503 + if (IS_ERR(handle))
4504 + return PTR_ERR(handle);
4505 + if (IS_SYNC(inode))
4506 + handle->h_sync = 1;
4507 + err = ext4_reserve_inode_write(handle, inode, &iloc);
4511 + EXT4_I(inode)->i_flags = newflags;
4512 + inode->i_ctime = CURRENT_TIME;
4514 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
4516 + ext4_journal_stop(handle);
4521 void ext4_read_inode(struct inode * inode)
4523 struct ext4_iloc iloc;
4524 @@ -2590,6 +2637,8 @@ void ext4_read_inode(struct inode * inod
4525 struct ext4_inode_info *ei = EXT4_I(inode);
4526 struct buffer_head *bh;
4531 #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
4532 ei->i_acl = EXT4_ACL_NOT_CACHED;
4533 @@ -2602,12 +2651,17 @@ void ext4_read_inode(struct inode * inod
4535 raw_inode = ext4_raw_inode(&iloc);
4536 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4537 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4538 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4539 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4540 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4541 if(!(test_opt (inode->i_sb, NO_UID32))) {
4542 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4543 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4544 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4545 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4547 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4548 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4549 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4550 + le16_to_cpu(raw_inode->i_raw_tag));
4552 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4553 inode->i_size = le32_to_cpu(raw_inode->i_size);
4554 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4555 @@ -2737,6 +2791,8 @@ static int ext4_do_update_inode(handle_t
4556 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
4557 struct ext4_inode_info *ei = EXT4_I(inode);
4558 struct buffer_head *bh = iloc->bh;
4559 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4560 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4561 int err = 0, rc, block;
4563 /* For fields not not tracking in the in-memory inode,
4564 @@ -2746,29 +2802,32 @@ static int ext4_do_update_inode(handle_t
4566 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4567 if(!(test_opt(inode->i_sb, NO_UID32))) {
4568 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4569 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4570 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4571 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4573 * Fix up interoperability with old kernels. Otherwise, old inodes get
4574 * re-used with the upper 16 bits of the uid/gid intact
4577 raw_inode->i_uid_high =
4578 - cpu_to_le16(high_16_bits(inode->i_uid));
4579 + cpu_to_le16(high_16_bits(uid));
4580 raw_inode->i_gid_high =
4581 - cpu_to_le16(high_16_bits(inode->i_gid));
4582 + cpu_to_le16(high_16_bits(gid));
4584 raw_inode->i_uid_high = 0;
4585 raw_inode->i_gid_high = 0;
4588 raw_inode->i_uid_low =
4589 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4590 + cpu_to_le16(fs_high2lowuid(uid));
4591 raw_inode->i_gid_low =
4592 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4593 + cpu_to_le16(fs_high2lowgid(gid));
4594 raw_inode->i_uid_high = 0;
4595 raw_inode->i_gid_high = 0;
4597 +#ifdef CONFIG_TAGGING_INTERN
4598 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4600 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4601 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4602 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4603 @@ -2925,7 +2984,8 @@ int ext4_setattr(struct dentry *dentry,
4606 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4607 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4608 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4609 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4612 /* (user+group)*(old+new) structure, inode write (sb,
4613 @@ -2947,6 +3007,8 @@ int ext4_setattr(struct dentry *dentry,
4614 inode->i_uid = attr->ia_uid;
4615 if (attr->ia_valid & ATTR_GID)
4616 inode->i_gid = attr->ia_gid;
4617 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4618 + inode->i_tag = attr->ia_tag;
4619 error = ext4_mark_inode_dirty(handle, inode);
4620 ext4_journal_stop(handle);
4622 diff -Nurp linux-2.6.22.18/fs/ext4/ioctl.c linux-2.6.22.18-vs2.3.0.32/fs/ext4/ioctl.c
4623 --- linux-2.6.22.18/fs/ext4/ioctl.c 2007-05-04 15:58:21.000000000 +0200
4624 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext4/ioctl.c 2008-02-11 12:35:34.000000000 +0100
4628 #include <linux/fs.h>
4629 +#include <linux/mount.h>
4630 #include <linux/jbd2.h>
4631 #include <linux/capability.h>
4632 #include <linux/ext4_fs.h>
4634 #include <linux/time.h>
4635 #include <linux/compat.h>
4636 #include <linux/smp_lock.h>
4637 +#include <linux/vs_tag.h>
4638 #include <asm/uaccess.h>
4640 int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
4641 @@ -37,7 +39,8 @@ int ext4_ioctl (struct inode * inode, st
4642 unsigned int oldflags;
4645 - if (IS_RDONLY(inode))
4646 + if (IS_RDONLY(inode) ||
4647 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4650 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4651 @@ -61,7 +64,9 @@ int ext4_ioctl (struct inode * inode, st
4653 * This test looks nicer. Thanks to Pauline Middelink
4655 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
4656 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
4657 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
4658 + EXT4_IMMUTABLE_FL | EXT4_IUNLINK_FL))) {
4659 if (!capable(CAP_LINUX_IMMUTABLE)) {
4660 mutex_unlock(&inode->i_mutex);
4662 @@ -123,7 +128,8 @@ flags_err:
4664 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4666 - if (IS_RDONLY(inode))
4667 + if (IS_RDONLY(inode) ||
4668 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4670 if (get_user(generation, (int __user *) arg))
4672 @@ -177,7 +183,8 @@ flags_err:
4673 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
4676 - if (IS_RDONLY(inode))
4677 + if (IS_RDONLY(inode) ||
4678 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4681 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4682 @@ -212,7 +219,8 @@ flags_err:
4683 if (!capable(CAP_SYS_RESOURCE))
4686 - if (IS_RDONLY(inode))
4687 + if (IS_RDONLY(inode) ||
4688 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4691 if (get_user(n_blocks_count, (__u32 __user *)arg))
4692 @@ -233,7 +241,8 @@ flags_err:
4693 if (!capable(CAP_SYS_RESOURCE))
4696 - if (IS_RDONLY(inode))
4697 + if (IS_RDONLY(inode) ||
4698 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4701 if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg,
4702 diff -Nurp linux-2.6.22.18/fs/ext4/namei.c linux-2.6.22.18-vs2.3.0.32/fs/ext4/namei.c
4703 --- linux-2.6.22.18/fs/ext4/namei.c 2007-09-29 14:11:49.000000000 +0200
4704 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext4/namei.c 2008-02-11 12:35:34.000000000 +0100
4706 #include <linux/quotaops.h>
4707 #include <linux/buffer_head.h>
4708 #include <linux/bio.h>
4709 +#include <linux/vs_tag.h>
4713 @@ -1050,6 +1051,7 @@ static struct dentry *ext4_lookup(struct
4716 return ERR_PTR(-EACCES);
4717 + dx_propagate_tag(nd, inode);
4719 return d_splice_alias(inode, dentry);
4721 @@ -2441,6 +2443,7 @@ const struct inode_operations ext4_dir_i
4722 .removexattr = generic_removexattr,
4724 .permission = ext4_permission,
4725 + .sync_flags = ext4_sync_flags,
4728 const struct inode_operations ext4_special_inode_operations = {
4729 @@ -2452,4 +2455,5 @@ const struct inode_operations ext4_speci
4730 .removexattr = generic_removexattr,
4732 .permission = ext4_permission,
4733 + .sync_flags = ext4_sync_flags,
4735 diff -Nurp linux-2.6.22.18/fs/ext4/super.c linux-2.6.22.18-vs2.3.0.32/fs/ext4/super.c
4736 --- linux-2.6.22.18/fs/ext4/super.c 2007-07-22 00:00:15.000000000 +0200
4737 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext4/super.c 2008-02-11 12:35:34.000000000 +0100
4738 @@ -725,7 +725,7 @@ enum {
4739 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4740 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4741 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4742 - Opt_grpquota, Opt_extents,
4743 + Opt_grpquota, Opt_extents, Opt_tag, Opt_notag, Opt_tagid
4746 static match_table_t tokens = {
4747 @@ -776,6 +776,9 @@ static match_table_t tokens = {
4748 {Opt_usrquota, "usrquota"},
4749 {Opt_barrier, "barrier=%u"},
4750 {Opt_extents, "extents"},
4752 + {Opt_notag, "notag"},
4753 + {Opt_tagid, "tagid=%u"},
4755 {Opt_resize, "resize"},
4757 @@ -869,6 +872,20 @@ static int parse_options (char *options,
4759 set_opt (sbi->s_mount_opt, NO_UID32);
4761 +#ifndef CONFIG_TAGGING_NONE
4763 + set_opt (sbi->s_mount_opt, TAGGED);
4766 + clear_opt (sbi->s_mount_opt, TAGGED);
4769 +#ifdef CONFIG_PROPAGATE
4772 + set_opt (sbi->s_mount_opt, TAGGED);
4776 clear_opt (sbi->s_mount_opt, CHECK);
4778 @@ -1546,6 +1563,9 @@ static int ext4_fill_super (struct super
4782 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
4783 + sb->s_flags |= MS_TAGGED;
4785 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4786 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4788 @@ -2377,6 +2397,12 @@ static int ext4_remount (struct super_bl
4790 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
4791 ext4_abort(sb, __FUNCTION__, "Abort forced by user");
4792 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
4793 + !(sb->s_flags & MS_TAGGED)) {
4794 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
4799 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4800 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4801 diff -Nurp linux-2.6.22.18/fs/ext4/symlink.c linux-2.6.22.18-vs2.3.0.32/fs/ext4/symlink.c
4802 --- linux-2.6.22.18/fs/ext4/symlink.c 2007-07-21 23:58:45.000000000 +0200
4803 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext4/symlink.c 2008-02-11 12:35:34.000000000 +0100
4804 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
4805 .listxattr = ext4_listxattr,
4806 .removexattr = generic_removexattr,
4808 + .sync_flags = ext4_sync_flags,
4811 const struct inode_operations ext4_fast_symlink_inode_operations = {
4812 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
4813 .listxattr = ext4_listxattr,
4814 .removexattr = generic_removexattr,
4816 + .sync_flags = ext4_sync_flags,
4818 diff -Nurp linux-2.6.22.18/fs/ext4/xattr.c linux-2.6.22.18-vs2.3.0.32/fs/ext4/xattr.c
4819 --- linux-2.6.22.18/fs/ext4/xattr.c 2007-07-21 23:58:45.000000000 +0200
4820 +++ linux-2.6.22.18-vs2.3.0.32/fs/ext4/xattr.c 2008-02-11 12:35:34.000000000 +0100
4822 #include <linux/mbcache.h>
4823 #include <linux/quotaops.h>
4824 #include <linux/rwsem.h>
4825 +#include <linux/vs_dlimit.h>
4829 @@ -496,6 +497,7 @@ ext4_xattr_release_block(handle_t *handl
4830 error = ext4_journal_dirty_metadata(handle, bh);
4833 + DLIMIT_FREE_BLOCK(inode, 1);
4834 DQUOT_FREE_BLOCK(inode, 1);
4835 ea_bdebug(bh, "refcount now=%d; releasing",
4836 le32_to_cpu(BHDR(bh)->h_refcount));
4837 @@ -769,11 +771,14 @@ inserted:
4838 if (new_bh == bs->bh)
4839 ea_bdebug(new_bh, "keeping");
4842 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4844 /* The old block is released after updating
4847 if (DQUOT_ALLOC_BLOCK(inode, 1))
4849 + goto cleanup_dlimit;
4850 error = ext4_journal_get_write_access(handle,
4853 @@ -850,6 +855,8 @@ cleanup:
4856 DQUOT_FREE_BLOCK(inode, 1);
4858 + DLIMIT_FREE_BLOCK(inode, 1);
4862 diff -Nurp linux-2.6.22.18/fs/fcntl.c linux-2.6.22.18-vs2.3.0.32/fs/fcntl.c
4863 --- linux-2.6.22.18/fs/fcntl.c 2007-05-04 15:58:21.000000000 +0200
4864 +++ linux-2.6.22.18-vs2.3.0.32/fs/fcntl.c 2008-02-11 12:35:34.000000000 +0100
4866 #include <linux/ptrace.h>
4867 #include <linux/signal.h>
4868 #include <linux/rcupdate.h>
4869 +#include <linux/vs_limit.h>
4871 #include <asm/poll.h>
4872 #include <asm/siginfo.h>
4873 @@ -84,6 +85,8 @@ repeat:
4875 if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
4877 + if (!vx_files_avail(1))
4880 error = expand_files(files, newfd);
4882 @@ -124,6 +127,7 @@ static int dupfd(struct file *file, unsi
4883 FD_SET(fd, fdt->open_fds);
4884 FD_CLR(fd, fdt->close_on_exec);
4885 spin_unlock(&files->file_lock);
4886 + vx_openfd_inc(fd);
4887 fd_install(fd, file);
4889 spin_unlock(&files->file_lock);
4890 @@ -176,6 +180,9 @@ asmlinkage long sys_dup2(unsigned int ol
4893 filp_close(tofree, files);
4895 + vx_openfd_inc(newfd); /* fd was unused */
4900 diff -Nurp linux-2.6.22.18/fs/file_table.c linux-2.6.22.18-vs2.3.0.32/fs/file_table.c
4901 --- linux-2.6.22.18/fs/file_table.c 2007-07-22 00:00:15.000000000 +0200
4902 +++ linux-2.6.22.18-vs2.3.0.32/fs/file_table.c 2008-02-11 12:35:34.000000000 +0100
4904 #include <linux/fsnotify.h>
4905 #include <linux/sysctl.h>
4906 #include <linux/percpu_counter.h>
4907 +#include <linux/vs_limit.h>
4908 +#include <linux/vs_context.h>
4910 #include <asm/atomic.h>
4912 @@ -119,6 +121,8 @@ struct file *get_empty_filp(void)
4913 f->f_gid = tsk->fsgid;
4914 eventpoll_init_file(f);
4915 /* f->f_version: 0 */
4916 + f->f_xid = vx_current_xid();
4921 @@ -174,6 +178,8 @@ void fastcall __fput(struct file *file)
4922 if (file->f_mode & FMODE_WRITE)
4923 put_write_access(inode);
4924 put_pid(file->f_owner.pid);
4925 + vx_files_dec(file);
4928 file->f_path.dentry = NULL;
4929 file->f_path.mnt = NULL;
4930 @@ -239,6 +245,8 @@ void put_filp(struct file *file)
4932 if (atomic_dec_and_test(&file->f_count)) {
4933 security_file_free(file);
4934 + vx_files_dec(file);
4939 diff -Nurp linux-2.6.22.18/fs/hfsplus/ioctl.c linux-2.6.22.18-vs2.3.0.32/fs/hfsplus/ioctl.c
4940 --- linux-2.6.22.18/fs/hfsplus/ioctl.c 2007-05-04 15:57:35.000000000 +0200
4941 +++ linux-2.6.22.18-vs2.3.0.32/fs/hfsplus/ioctl.c 2008-02-11 12:35:34.000000000 +0100
4943 #include <linux/fs.h>
4944 #include <linux/sched.h>
4945 #include <linux/xattr.h>
4946 +#include <linux/mount.h>
4947 #include <asm/uaccess.h>
4948 #include "hfsplus_fs.h"
4950 @@ -35,7 +36,8 @@ int hfsplus_ioctl(struct inode *inode, s
4951 flags |= FS_NODUMP_FL; /* EXT2_NODUMP_FL */
4952 return put_user(flags, (int __user *)arg);
4953 case HFSPLUS_IOC_EXT2_SETFLAGS: {
4954 - if (IS_RDONLY(inode))
4955 + if (IS_RDONLY(inode) ||
4956 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4959 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4960 diff -Nurp linux-2.6.22.18/fs/inode.c linux-2.6.22.18-vs2.3.0.32/fs/inode.c
4961 --- linux-2.6.22.18/fs/inode.c 2007-07-22 00:00:16.000000000 +0200
4962 +++ linux-2.6.22.18-vs2.3.0.32/fs/inode.c 2008-02-11 12:35:34.000000000 +0100
4963 @@ -115,6 +115,9 @@ static struct inode *alloc_inode(struct
4964 struct address_space * const mapping = &inode->i_data;
4968 + /* essential because of inode slab reuse */
4970 inode->i_blkbits = sb->s_blocksize_bits;
4972 atomic_set(&inode->i_count, 1);
4973 @@ -133,6 +136,7 @@ static struct inode *alloc_inode(struct
4974 inode->i_bdev = NULL;
4975 inode->i_cdev = NULL;
4977 + inode->i_mdev = 0;
4978 inode->dirtied_when = 0;
4979 if (security_inode_alloc(inode)) {
4980 if (inode->i_sb->s_op->destroy_inode)
4981 @@ -231,6 +235,8 @@ void __iget(struct inode * inode)
4982 inodes_stat.nr_unused--;
4985 +EXPORT_SYMBOL_GPL(__iget);
4988 * clear_inode - clear an inode
4989 * @inode: inode to clear
4990 @@ -1405,9 +1411,11 @@ void init_special_inode(struct inode *in
4991 if (S_ISCHR(mode)) {
4992 inode->i_fop = &def_chr_fops;
4993 inode->i_rdev = rdev;
4994 + inode->i_mdev = rdev;
4995 } else if (S_ISBLK(mode)) {
4996 inode->i_fop = &def_blk_fops;
4997 inode->i_rdev = rdev;
4998 + inode->i_mdev = rdev;
4999 } else if (S_ISFIFO(mode))
5000 inode->i_fop = &def_fifo_fops;
5001 else if (S_ISSOCK(mode))
5002 diff -Nurp linux-2.6.22.18/fs/ioctl.c linux-2.6.22.18-vs2.3.0.32/fs/ioctl.c
5003 --- linux-2.6.22.18/fs/ioctl.c 2007-07-22 00:00:16.000000000 +0200
5004 +++ linux-2.6.22.18-vs2.3.0.32/fs/ioctl.c 2008-02-11 12:35:34.000000000 +0100
5006 #include <linux/security.h>
5007 #include <linux/module.h>
5008 #include <linux/kallsyms.h>
5009 +#include <linux/proc_fs.h>
5010 +#include <linux/vserver/inode.h>
5011 +#include <linux/vs_tag.h>
5013 #include <asm/uaccess.h>
5014 #include <asm/ioctls.h>
5015 diff -Nurp linux-2.6.22.18/fs/ioprio.c linux-2.6.22.18-vs2.3.0.32/fs/ioprio.c
5016 --- linux-2.6.22.18/fs/ioprio.c 2007-07-21 23:58:45.000000000 +0200
5017 +++ linux-2.6.22.18-vs2.3.0.32/fs/ioprio.c 2008-02-11 12:35:34.000000000 +0100
5019 #include <linux/capability.h>
5020 #include <linux/syscalls.h>
5021 #include <linux/security.h>
5022 +#include <linux/vs_base.h>
5024 static int set_task_ioprio(struct task_struct *task, int ioprio)
5026 @@ -103,6 +104,8 @@ asmlinkage long sys_ioprio_set(int which
5028 pgrp = find_pid(who);
5029 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
5030 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5032 ret = set_task_ioprio(p, ioprio);
5035 @@ -112,7 +115,7 @@ asmlinkage long sys_ioprio_set(int which
5037 user = current->user;
5039 - user = find_user(who);
5040 + user = find_user(vx_current_xid(), who);
5044 @@ -190,6 +193,8 @@ asmlinkage long sys_ioprio_get(int which
5046 pgrp = find_pid(who);
5047 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
5048 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5050 tmpio = get_task_ioprio(p);
5053 @@ -203,7 +208,7 @@ asmlinkage long sys_ioprio_get(int which
5055 user = current->user;
5057 - user = find_user(who);
5058 + user = find_user(vx_current_xid(), who);
5062 diff -Nurp linux-2.6.22.18/fs/jffs2/dir.c linux-2.6.22.18-vs2.3.0.32/fs/jffs2/dir.c
5063 --- linux-2.6.22.18/fs/jffs2/dir.c 2007-07-22 00:00:17.000000000 +0200
5064 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/dir.c 2008-02-11 12:35:34.000000000 +0100
5065 @@ -32,7 +32,9 @@ static int jffs2_mkdir (struct inode *,s
5066 static int jffs2_rmdir (struct inode *,struct dentry *);
5067 static int jffs2_mknod (struct inode *,struct dentry *,int,dev_t);
5068 static int jffs2_rename (struct inode *, struct dentry *,
5069 - struct inode *, struct dentry *);
5070 + struct inode *, struct dentry *);
5072 +extern int jffs2_sync_flags(struct inode *);
5074 const struct file_operations jffs2_dir_operations =
5076 @@ -56,6 +58,7 @@ const struct inode_operations jffs2_dir_
5077 .rename = jffs2_rename,
5078 .permission = jffs2_permission,
5079 .setattr = jffs2_setattr,
5080 + .sync_flags = jffs2_sync_flags,
5081 .setxattr = jffs2_setxattr,
5082 .getxattr = jffs2_getxattr,
5083 .listxattr = jffs2_listxattr,
5084 diff -Nurp linux-2.6.22.18/fs/jffs2/file.c linux-2.6.22.18-vs2.3.0.32/fs/jffs2/file.c
5085 --- linux-2.6.22.18/fs/jffs2/file.c 2007-07-22 00:00:17.000000000 +0200
5086 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/file.c 2008-02-11 12:35:34.000000000 +0100
5088 #include <linux/highmem.h>
5089 #include <linux/crc32.h>
5090 #include <linux/jffs2.h>
5091 +#include <linux/vs_tag.h>
5092 #include "nodelist.h"
5094 static int jffs2_commit_write (struct file *filp, struct page *pg,
5095 @@ -25,6 +26,9 @@ static int jffs2_prepare_write (struct f
5096 unsigned start, unsigned end);
5097 static int jffs2_readpage (struct file *filp, struct page *pg);
5099 +extern int jffs2_sync_flags(struct inode *);
5102 int jffs2_fsync(struct file *filp, struct dentry *dentry, int datasync)
5104 struct inode *inode = dentry->d_inode;
5105 @@ -47,7 +51,9 @@ const struct file_operations jffs2_file_
5106 .ioctl = jffs2_ioctl,
5107 .mmap = generic_file_readonly_mmap,
5108 .fsync = jffs2_fsync,
5109 - .sendfile = generic_file_sendfile
5110 + .sendfile = generic_file_sendfile,
5111 + .splice_read = generic_file_splice_read,
5112 + .splice_write = generic_file_splice_write
5115 /* jffs2_file_inode_operations */
5116 @@ -56,6 +62,7 @@ const struct inode_operations jffs2_file
5118 .permission = jffs2_permission,
5119 .setattr = jffs2_setattr,
5120 + .sync_flags = jffs2_sync_flags,
5121 .setxattr = jffs2_setxattr,
5122 .getxattr = jffs2_getxattr,
5123 .listxattr = jffs2_listxattr,
5124 @@ -157,12 +164,14 @@ static int jffs2_prepare_write (struct f
5125 ri.mode = cpu_to_jemode(inode->i_mode);
5126 ri.uid = cpu_to_je16(inode->i_uid);
5127 ri.gid = cpu_to_je16(inode->i_gid);
5128 + ri.tag = cpu_to_je16(TAGINO_TAG(DX_TAG(inode), inode->i_tag));
5129 ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs));
5130 ri.atime = ri.ctime = ri.mtime = cpu_to_je32(get_seconds());
5131 ri.offset = cpu_to_je32(inode->i_size);
5132 ri.dsize = cpu_to_je32(pageofs - inode->i_size);
5133 ri.csize = cpu_to_je32(0);
5134 ri.compr = JFFS2_COMPR_ZERO;
5135 + ri.flags = cpu_to_je16(f->flags);
5136 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
5137 ri.data_crc = cpu_to_je32(0);
5139 @@ -248,8 +257,10 @@ static int jffs2_commit_write (struct fi
5140 ri->mode = cpu_to_jemode(inode->i_mode);
5141 ri->uid = cpu_to_je16(inode->i_uid);
5142 ri->gid = cpu_to_je16(inode->i_gid);
5143 + ri->tag = cpu_to_je16(TAGINO_TAG(DX_TAG(inode), inode->i_tag));
5144 ri->isize = cpu_to_je32((uint32_t)inode->i_size);
5145 ri->atime = ri->ctime = ri->mtime = cpu_to_je32(get_seconds());
5146 + ri->flags = cpu_to_je16(f->flags);
5148 /* In 2.4, it was already kmapped by generic_file_write(). Doesn't
5149 hurt to do it again. The alternative is ifdefs, which are ugly. */
5150 diff -Nurp linux-2.6.22.18/fs/jffs2/fs.c linux-2.6.22.18-vs2.3.0.32/fs/jffs2/fs.c
5151 --- linux-2.6.22.18/fs/jffs2/fs.c 2007-09-29 14:11:49.000000000 +0200
5152 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/fs.c 2008-02-11 12:35:34.000000000 +0100
5154 #include <linux/vmalloc.h>
5155 #include <linux/vfs.h>
5156 #include <linux/crc32.h>
5157 +#include <linux/vs_tag.h>
5158 #include "nodelist.h"
5160 static int jffs2_flash_setup(struct jffs2_sb_info *c);
5161 @@ -97,6 +98,7 @@ static int jffs2_do_setattr (struct inod
5163 ri->uid = cpu_to_je16((ivalid & ATTR_UID)?iattr->ia_uid:inode->i_uid);
5164 ri->gid = cpu_to_je16((ivalid & ATTR_GID)?iattr->ia_gid:inode->i_gid);
5165 + ri->tag = cpu_to_je16((ivalid & ATTR_TAG)?iattr->ia_tag:inode->i_tag);
5167 if (ivalid & ATTR_MODE)
5168 if (iattr->ia_mode & S_ISGID &&
5169 @@ -116,6 +118,8 @@ static int jffs2_do_setattr (struct inod
5170 ri->offset = cpu_to_je32(0);
5171 ri->csize = ri->dsize = cpu_to_je32(mdatalen);
5172 ri->compr = JFFS2_COMPR_NONE;
5173 + ri->flags = cpu_to_je16(f->flags);
5175 if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
5176 /* It's an extension. Make it a hole node */
5177 ri->compr = JFFS2_COMPR_ZERO;
5178 @@ -145,6 +149,7 @@ static int jffs2_do_setattr (struct inod
5179 inode->i_mode = jemode_to_cpu(ri->mode);
5180 inode->i_uid = je16_to_cpu(ri->uid);
5181 inode->i_gid = je16_to_cpu(ri->gid);
5182 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0, je16_to_cpu(ri->tag));
5185 old_metadata = f->metadata;
5186 @@ -179,6 +184,48 @@ static int jffs2_do_setattr (struct inod
5190 +void jffs2_set_inode_flags(struct inode *inode)
5192 + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
5193 + unsigned int flags = f->flags;
5195 + inode->i_flags &= ~(JFFS2_INO_FLAG_IMMUTABLE |
5196 + JFFS2_INO_FLAG_IUNLINK | JFFS2_INO_FLAG_BARRIER);
5198 + if (flags & JFFS2_INO_FLAG_IMMUTABLE)
5199 + inode->i_flags |= S_IMMUTABLE;
5200 + if (flags & JFFS2_INO_FLAG_IUNLINK)
5201 + inode->i_flags |= S_IUNLINK;
5202 + if (flags & JFFS2_INO_FLAG_BARRIER)
5203 + inode->i_flags |= S_BARRIER;
5206 +int jffs2_sync_flags(struct inode *inode)
5208 + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
5209 + unsigned int oldflags, newflags;
5211 + oldflags = f->flags;
5212 + newflags = oldflags & ~(JFFS2_INO_FLAG_IMMUTABLE |
5213 + JFFS2_INO_FLAG_IUNLINK | JFFS2_INO_FLAG_BARRIER);
5215 + if (IS_IMMUTABLE(inode))
5216 + newflags |= JFFS2_INO_FLAG_IMMUTABLE;
5217 + if (IS_IUNLINK(inode))
5218 + newflags |= JFFS2_INO_FLAG_IUNLINK;
5219 + if (IS_BARRIER(inode))
5220 + newflags |= JFFS2_INO_FLAG_BARRIER;
5222 + if (oldflags ^ newflags) {
5223 + f->flags = newflags;
5224 + inode->i_ctime = CURRENT_TIME;
5225 + /* strange requirement, see jffs2_dirty_inode() */
5226 + inode->i_state |= I_DIRTY_DATASYNC;
5227 + mark_inode_dirty(inode);
5232 int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
5235 @@ -254,6 +301,8 @@ void jffs2_read_inode (struct inode *ino
5236 inode->i_mode = jemode_to_cpu(latest_node.mode);
5237 inode->i_uid = je16_to_cpu(latest_node.uid);
5238 inode->i_gid = je16_to_cpu(latest_node.gid);
5239 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0,
5240 + je16_to_cpu(latest_node.tag));
5241 inode->i_size = je32_to_cpu(latest_node.isize);
5242 inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
5243 inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
5244 @@ -285,6 +334,7 @@ void jffs2_read_inode (struct inode *ino
5246 inode->i_op = &jffs2_dir_inode_operations;
5247 inode->i_fop = &jffs2_dir_operations;
5248 + f->flags = je16_to_cpu(latest_node.flags);
5252 @@ -292,6 +342,7 @@ void jffs2_read_inode (struct inode *ino
5253 inode->i_fop = &jffs2_file_operations;
5254 inode->i_mapping->a_ops = &jffs2_file_address_operations;
5255 inode->i_mapping->nrpages = 0;
5256 + f->flags = je16_to_cpu(latest_node.flags);
5260 @@ -328,7 +379,7 @@ void jffs2_read_inode (struct inode *ino
5262 printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino);
5265 + jffs2_set_inode_flags(inode);
5268 D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n"));
5269 @@ -345,10 +396,11 @@ void jffs2_dirty_inode(struct inode *ino
5271 D1(printk(KERN_DEBUG "jffs2_dirty_inode() calling setattr() for ino #%lu\n", inode->i_ino));
5273 - iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME;
5274 + iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME|ATTR_TAG;
5275 iattr.ia_mode = inode->i_mode;
5276 iattr.ia_uid = inode->i_uid;
5277 iattr.ia_gid = inode->i_gid;
5278 + iattr.ia_tag = inode->i_tag;
5279 iattr.ia_atime = inode->i_atime;
5280 iattr.ia_mtime = inode->i_mtime;
5281 iattr.ia_ctime = inode->i_ctime;
5282 @@ -422,6 +474,7 @@ struct inode *jffs2_new_inode (struct in
5284 memset(ri, 0, sizeof(*ri));
5285 /* Set OS-specific defaults for new inodes */
5286 + ri->tag = cpu_to_je16(dx_current_tag());
5287 ri->uid = cpu_to_je16(current->fsuid);
5289 if (dir_i->i_mode & S_ISGID) {
5290 @@ -443,14 +496,16 @@ struct inode *jffs2_new_inode (struct in
5291 inode->i_mode = jemode_to_cpu(ri->mode);
5292 inode->i_gid = je16_to_cpu(ri->gid);
5293 inode->i_uid = je16_to_cpu(ri->uid);
5294 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0, je16_to_cpu(ri->tag));
5295 inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
5296 ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
5298 inode->i_blocks = 0;
5301 + f->flags = je16_to_cpu(ri->flags);
5302 + jffs2_set_inode_flags(inode);
5303 insert_inode_hash(inode);
5308 diff -Nurp linux-2.6.22.18/fs/jffs2/gc.c linux-2.6.22.18-vs2.3.0.32/fs/jffs2/gc.c
5309 --- linux-2.6.22.18/fs/jffs2/gc.c 2007-07-22 00:00:17.000000000 +0200
5310 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/gc.c 2008-02-11 12:35:34.000000000 +0100
5311 @@ -735,6 +735,7 @@ static int jffs2_garbage_collect_metadat
5312 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5313 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5314 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5315 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5316 ri.isize = cpu_to_je32(ilen);
5317 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5318 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5319 @@ -998,6 +999,7 @@ static int jffs2_garbage_collect_hole(st
5320 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5321 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5322 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5323 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5324 ri.isize = cpu_to_je32(ilen);
5325 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5326 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5327 @@ -1256,6 +1258,7 @@ static int jffs2_garbage_collect_dnode(s
5328 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5329 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5330 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5331 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5332 ri.isize = cpu_to_je32(JFFS2_F_I_SIZE(f));
5333 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5334 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5335 diff -Nurp linux-2.6.22.18/fs/jffs2/ioctl.c linux-2.6.22.18-vs2.3.0.32/fs/jffs2/ioctl.c
5336 --- linux-2.6.22.18/fs/jffs2/ioctl.c 2007-07-22 00:00:17.000000000 +0200
5337 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/ioctl.c 2008-02-11 12:35:34.000000000 +0100
5341 #include <linux/fs.h>
5342 +#include <linux/types.h>
5343 +#include <linux/mount.h>
5344 +#include <linux/jffs2.h>
5345 +#include <linux/uaccess.h>
5346 +#include <linux/vs_base.h>
5347 +#include "jffs2_fs_sb.h"
5348 +#include "jffs2_fs_i.h"
5350 +#include "os-linux.h"
5352 +extern void jffs2_set_inode_flags(struct inode *);
5354 int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
5357 - /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which
5358 - will include compression support etc. */
5360 + struct jffs2_inode_info *j = JFFS2_INODE_INFO(inode);
5361 + unsigned int flags, oldflags, newflags;
5364 + case JFFS2_IOC_GETFLAGS:
5365 + flags = j->flags & JFFS2_USER_VISIBLE;
5366 + return put_user(flags, (int __user *) arg);
5368 + case JFFS2_IOC_SETFLAGS:
5369 + if (IS_RDONLY(inode) ||
5370 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
5373 + if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
5376 + if (get_user(flags, (int __user *) arg))
5379 + oldflags = j->flags;
5380 + newflags = flags & JFFS2_USER_MODIFIABLE;
5381 + newflags |= oldflags & ~JFFS2_USER_MODIFIABLE;
5384 + * The IMMUTABLE flags can only be changed by
5385 + * the relevant capability.
5387 + if (((oldflags ^ newflags) &
5388 + (JFFS2_INO_FLAG_IMMUTABLE | JFFS2_INO_FLAG_IUNLINK)) ||
5389 + (oldflags & JFFS2_INO_FLAG_IMMUTABLE)) {
5390 + if (!capable(CAP_LINUX_IMMUTABLE))
5394 + if (oldflags ^ newflags) {
5395 + j->flags = newflags;
5396 + inode->i_ctime = CURRENT_TIME;
5397 + /* strange requirement, see jffs2_dirty_inode() */
5398 + inode->i_state |= I_DIRTY_DATASYNC;
5399 + mark_inode_dirty(inode);
5400 + jffs2_set_inode_flags(inode);
5409 diff -Nurp linux-2.6.22.18/fs/jffs2/jffs2_fs_sb.h linux-2.6.22.18-vs2.3.0.32/fs/jffs2/jffs2_fs_sb.h
5410 --- linux-2.6.22.18/fs/jffs2/jffs2_fs_sb.h 2007-07-22 00:00:17.000000000 +0200
5411 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/jffs2_fs_sb.h 2008-02-11 12:35:34.000000000 +0100
5412 @@ -39,6 +39,7 @@ struct jffs2_sb_info {
5413 uint32_t checked_ino;
5416 + unsigned int s_mount_opt;
5418 struct task_struct *gc_task; /* GC task struct */
5419 struct completion gc_thread_start; /* GC thread start completion */
5420 diff -Nurp linux-2.6.22.18/fs/jffs2/nodelist.h linux-2.6.22.18-vs2.3.0.32/fs/jffs2/nodelist.h
5421 --- linux-2.6.22.18/fs/jffs2/nodelist.h 2007-07-22 00:00:17.000000000 +0200
5422 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/nodelist.h 2008-02-11 12:35:34.000000000 +0100
5424 #elif defined(JFFS2_BIG_ENDIAN)
5425 #define cpu_to_je16(x) ((jint16_t){cpu_to_be16(x)})
5426 #define cpu_to_je32(x) ((jint32_t){cpu_to_be32(x)})
5427 -#define cpu_to_jemode(x) ((jmode_t){cpu_to_be32(os_to_jffs2_mode(x))})
5428 +#define cpu_to_jemode(x) ((jmode_t){cpu_to_be16(os_to_jffs2_mode(x))})
5430 #define constant_cpu_to_je16(x) ((jint16_t){__constant_cpu_to_be16(x)})
5431 #define constant_cpu_to_je32(x) ((jint32_t){__constant_cpu_to_be32(x)})
5433 #define je16_to_cpu(x) (be16_to_cpu(x.v16))
5434 #define je32_to_cpu(x) (be32_to_cpu(x.v32))
5435 -#define jemode_to_cpu(x) (be32_to_cpu(jffs2_to_os_mode((x).m)))
5436 +#define jemode_to_cpu(x) (be16_to_cpu(jffs2_to_os_mode((x).m)))
5437 #elif defined(JFFS2_LITTLE_ENDIAN)
5438 #define cpu_to_je16(x) ((jint16_t){cpu_to_le16(x)})
5439 #define cpu_to_je32(x) ((jint32_t){cpu_to_le32(x)})
5440 -#define cpu_to_jemode(x) ((jmode_t){cpu_to_le32(os_to_jffs2_mode(x))})
5441 +#define cpu_to_jemode(x) ((jmode_t){cpu_to_le16(os_to_jffs2_mode(x))})
5443 #define constant_cpu_to_je16(x) ((jint16_t){__constant_cpu_to_le16(x)})
5444 #define constant_cpu_to_je32(x) ((jint32_t){__constant_cpu_to_le32(x)})
5446 #define je16_to_cpu(x) (le16_to_cpu(x.v16))
5447 #define je32_to_cpu(x) (le32_to_cpu(x.v32))
5448 -#define jemode_to_cpu(x) (le32_to_cpu(jffs2_to_os_mode((x).m)))
5449 +#define jemode_to_cpu(x) (le16_to_cpu(jffs2_to_os_mode((x).m)))
5453 diff -Nurp linux-2.6.22.18/fs/jffs2/os-linux.h linux-2.6.22.18-vs2.3.0.32/fs/jffs2/os-linux.h
5454 --- linux-2.6.22.18/fs/jffs2/os-linux.h 2007-07-22 00:00:17.000000000 +0200
5455 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/os-linux.h 2008-02-11 12:35:34.000000000 +0100
5456 @@ -29,6 +29,7 @@ struct kvec;
5457 #define JFFS2_F_I_MODE(f) (OFNI_EDONI_2SFFJ(f)->i_mode)
5458 #define JFFS2_F_I_UID(f) (OFNI_EDONI_2SFFJ(f)->i_uid)
5459 #define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid)
5460 +#define JFFS2_F_I_TAG(f) (OFNI_EDONI_2SFFJ(f)->i_tag)
5461 #define JFFS2_F_I_RDEV(f) (OFNI_EDONI_2SFFJ(f)->i_rdev)
5463 #define ITIME(sec) ((struct timespec){sec, 0})
5464 @@ -204,6 +205,9 @@ int jffs2_flash_direct_writev(struct jff
5465 int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len,
5466 size_t *retlen, const u_char *buf);
5468 +#define JFFS2_IOC_GETFLAGS FS_IOC_GETFLAGS
5469 +#define JFFS2_IOC_SETFLAGS FS_IOC_SETFLAGS
5471 #endif /* __JFFS2_OS_LINUX_H__ */
5474 diff -Nurp linux-2.6.22.18/fs/jffs2/readinode.c linux-2.6.22.18-vs2.3.0.32/fs/jffs2/readinode.c
5475 --- linux-2.6.22.18/fs/jffs2/readinode.c 2007-07-22 00:00:17.000000000 +0200
5476 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/readinode.c 2008-02-11 12:35:34.000000000 +0100
5477 @@ -1182,6 +1182,8 @@ static int jffs2_do_read_inode_internal(
5478 latest_node->isize = cpu_to_je32(0);
5479 latest_node->gid = cpu_to_je16(0);
5480 latest_node->uid = cpu_to_je16(0);
5481 + latest_node->tag = cpu_to_je16(0);
5482 + latest_node->flags = cpu_to_je16(0);
5483 if (f->inocache->state == INO_STATE_READING)
5484 jffs2_set_inocache_state(c, f->inocache, INO_STATE_PRESENT);
5486 diff -Nurp linux-2.6.22.18/fs/jffs2/super.c linux-2.6.22.18-vs2.3.0.32/fs/jffs2/super.c
5487 --- linux-2.6.22.18/fs/jffs2/super.c 2007-07-22 00:00:17.000000000 +0200
5488 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/super.c 2008-02-11 12:35:34.000000000 +0100
5490 #include <linux/mtd/super.h>
5491 #include <linux/ctype.h>
5492 #include <linux/namei.h>
5493 +#include <linux/parser.h>
5495 #include "nodelist.h"
5497 @@ -75,6 +76,49 @@ static const struct super_operations jff
5498 .sync_fs = jffs2_sync_fs,
5502 + Opt_tag, Opt_notag, Opt_ignore, Opt_err
5505 +static match_table_t tokens = {
5507 + {Opt_notag, "notag"},
5511 +static int parse_options (char * options,
5512 + struct jffs2_sb_info *sbi)
5515 + substring_t args[MAX_OPT_ARGS];
5520 + while ((p = strsep (&options, ",")) != NULL) {
5525 + token = match_token(p, tokens, args);
5527 +#ifndef CONFIG_TAGGING_NONE
5529 + set_opt (sbi->s_mount_opt, TAGGED);
5532 + clear_opt (sbi->s_mount_opt, TAGGED);
5545 * fill in the superblock
5547 @@ -109,6 +153,12 @@ static int jffs2_fill_super(struct super
5548 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
5549 sb->s_flags |= MS_POSIXACL;
5551 + if (!parse_options ((char *) data, c))
5554 + if (c->s_mount_opt & JFFS2_MOUNT_TAGGED)
5555 + sb->s_flags |= MS_TAGGED;
5557 return jffs2_do_fill_super(sb, data, silent);
5560 diff -Nurp linux-2.6.22.18/fs/jffs2/write.c linux-2.6.22.18-vs2.3.0.32/fs/jffs2/write.c
5561 --- linux-2.6.22.18/fs/jffs2/write.c 2007-08-26 03:38:36.000000000 +0200
5562 +++ linux-2.6.22.18-vs2.3.0.32/fs/jffs2/write.c 2008-02-11 12:35:34.000000000 +0100
5563 @@ -44,6 +44,7 @@ int jffs2_do_new_inode(struct jffs2_sb_i
5564 ri->totlen = cpu_to_je32(PAD(sizeof(*ri)));
5565 ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));
5566 ri->mode = cpu_to_jemode(mode);
5567 + ri->flags = cpu_to_je16(0);
5569 f->highest_version = 1;
5570 ri->version = cpu_to_je32(f->highest_version);
5571 diff -Nurp linux-2.6.22.18/fs/jfs/acl.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/acl.c
5572 --- linux-2.6.22.18/fs/jfs/acl.c 2007-05-04 15:57:35.000000000 +0200
5573 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/acl.c 2008-02-11 12:35:34.000000000 +0100
5574 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
5577 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5578 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5579 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5580 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5581 if (DQUOT_TRANSFER(inode, iattr))
5584 diff -Nurp linux-2.6.22.18/fs/jfs/file.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/file.c
5585 --- linux-2.6.22.18/fs/jfs/file.c 2007-07-21 23:58:46.000000000 +0200
5586 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/file.c 2008-02-11 12:35:34.000000000 +0100
5587 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
5588 .setattr = jfs_setattr,
5589 .permission = jfs_permission,
5591 + .sync_flags = jfs_sync_flags,
5594 const struct file_operations jfs_file_operations = {
5595 diff -Nurp linux-2.6.22.18/fs/jfs/inode.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/inode.c
5596 --- linux-2.6.22.18/fs/jfs/inode.c 2007-07-22 00:00:17.000000000 +0200
5597 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/inode.c 2008-02-11 12:35:34.000000000 +0100
5599 #include <linux/buffer_head.h>
5600 #include <linux/pagemap.h>
5601 #include <linux/quotaops.h>
5602 +#include <linux/vs_dlimit.h>
5603 #include "jfs_incore.h"
5604 #include "jfs_inode.h"
5605 #include "jfs_filsys.h"
5606 @@ -143,6 +144,7 @@ void jfs_delete_inode(struct inode *inod
5608 DQUOT_FREE_INODE(inode);
5610 + DLIMIT_FREE_INODE(inode);
5614 diff -Nurp linux-2.6.22.18/fs/jfs/ioctl.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/ioctl.c
5615 --- linux-2.6.22.18/fs/jfs/ioctl.c 2007-07-22 00:00:17.000000000 +0200
5616 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/ioctl.c 2008-02-11 12:35:34.000000000 +0100
5618 #include <linux/capability.h>
5619 #include <linux/time.h>
5620 #include <linux/sched.h>
5621 +#include <linux/mount.h>
5622 #include <asm/current.h>
5623 #include <asm/uaccess.h>
5625 @@ -66,7 +67,8 @@ int jfs_ioctl(struct inode * inode, stru
5626 case JFS_IOC_SETFLAGS: {
5627 unsigned int oldflags;
5629 - if (IS_RDONLY(inode))
5630 + if (IS_RDONLY(inode) ||
5631 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
5634 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
5635 @@ -87,8 +89,8 @@ int jfs_ioctl(struct inode * inode, stru
5636 * the relevant capability.
5638 if ((oldflags & JFS_IMMUTABLE_FL) ||
5639 - ((flags ^ oldflags) &
5640 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5641 + ((flags ^ oldflags) & (JFS_APPEND_FL |
5642 + JFS_IMMUTABLE_FL | JFS_IUNLINK_FL))) {
5643 if (!capable(CAP_LINUX_IMMUTABLE))
5646 diff -Nurp linux-2.6.22.18/fs/jfs/jfs_dinode.h linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_dinode.h
5647 --- linux-2.6.22.18/fs/jfs/jfs_dinode.h 2007-05-04 15:57:35.000000000 +0200
5648 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_dinode.h 2008-02-11 12:35:34.000000000 +0100
5649 @@ -162,9 +162,12 @@ struct dinode {
5650 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
5651 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
5653 -#define JFS_FL_USER_VISIBLE 0x03F80000
5654 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5655 +#define JFS_IUNLINK_FL 0x08000000 /* Immutable unlink */
5657 +#define JFS_FL_USER_VISIBLE 0x0FF80000
5658 #define JFS_FL_USER_MODIFIABLE 0x03F80000
5659 -#define JFS_FL_INHERIT 0x03C80000
5660 +#define JFS_FL_INHERIT 0x0BC80000
5662 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5663 #define JFS_IOC_GETFLAGS _IOR('f', 1, long)
5664 diff -Nurp linux-2.6.22.18/fs/jfs/jfs_dtree.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_dtree.c
5665 --- linux-2.6.22.18/fs/jfs/jfs_dtree.c 2007-05-04 15:58:21.000000000 +0200
5666 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_dtree.c 2008-02-11 12:35:34.000000000 +0100
5669 #include <linux/fs.h>
5670 #include <linux/quotaops.h>
5671 +#include <linux/vs_dlimit.h>
5672 #include "jfs_incore.h"
5673 #include "jfs_superblock.h"
5674 #include "jfs_filsys.h"
5675 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
5677 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
5679 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
5680 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
5683 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
5684 + goto clean_up_dquot;
5685 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
5686 + goto clean_up_dlimit;
5689 * Save the table, we're going to overwrite it with the
5690 @@ -479,6 +480,12 @@ static u32 add_index(tid_t tid, struct i
5695 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
5698 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
5702 jfs_ip->next_index--;
5703 @@ -952,6 +959,7 @@ static int dtSplitUp(tid_t tid,
5706 int quota_allocation = 0;
5707 + int dlimit_allocation = 0;
5709 /* get split page */
5711 @@ -1036,6 +1044,12 @@ static int dtSplitUp(tid_t tid,
5713 quota_allocation += n;
5715 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
5719 + dlimit_allocation += n;
5721 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
5724 @@ -1309,6 +1323,9 @@ static int dtSplitUp(tid_t tid,
5728 + /* Rollback dlimit allocation */
5729 + if (rc && dlimit_allocation)
5730 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
5731 /* Rollback quota allocation */
5732 if (rc && quota_allocation)
5733 DQUOT_FREE_BLOCK(ip, quota_allocation);
5734 @@ -1376,6 +1393,12 @@ static int dtSplitPage(tid_t tid, struct
5735 release_metapage(rmp);
5738 + /* Allocate blocks to dlimit. */
5739 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5740 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5741 + release_metapage(rmp);
5745 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
5747 @@ -1926,6 +1949,12 @@ static int dtSplitRoot(tid_t tid,
5748 release_metapage(rmp);
5751 + /* Allocate blocks to dlimit. */
5752 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5753 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5754 + release_metapage(rmp);
5758 BT_MARK_DIRTY(rmp, ip);
5760 @@ -2292,6 +2321,8 @@ static int dtDeleteUp(tid_t tid, struct
5762 xlen = lengthPXD(&fp->header.self);
5764 + /* Free dlimit allocation. */
5765 + DLIMIT_FREE_BLOCK(ip, xlen);
5766 /* Free quota allocation. */
5767 DQUOT_FREE_BLOCK(ip, xlen);
5769 @@ -2368,6 +2399,8 @@ static int dtDeleteUp(tid_t tid, struct
5771 xlen = lengthPXD(&p->header.self);
5773 + /* Free dlimit allocation */
5774 + DLIMIT_FREE_BLOCK(ip, xlen);
5775 /* Free quota allocation */
5776 DQUOT_FREE_BLOCK(ip, xlen);
5778 diff -Nurp linux-2.6.22.18/fs/jfs/jfs_extent.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_extent.c
5779 --- linux-2.6.22.18/fs/jfs/jfs_extent.c 2007-05-04 15:57:36.000000000 +0200
5780 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_extent.c 2008-02-11 12:35:34.000000000 +0100
5783 #include <linux/fs.h>
5784 #include <linux/quotaops.h>
5785 +#include <linux/vs_dlimit.h>
5786 #include "jfs_incore.h"
5787 #include "jfs_inode.h"
5788 #include "jfs_superblock.h"
5789 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
5793 + /* Allocate blocks to dlimit. */
5794 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
5795 + DQUOT_FREE_BLOCK(ip, nxlen);
5796 + dbFree(ip, nxaddr, (s64) nxlen);
5797 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
5801 /* determine the value of the extent flag */
5802 xflag = abnr ? XAD_NOTRECORDED : 0;
5804 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
5807 dbFree(ip, nxaddr, nxlen);
5808 + DLIMIT_FREE_BLOCK(ip, nxlen);
5809 DQUOT_FREE_BLOCK(ip, nxlen);
5810 mutex_unlock(&JFS_IP(ip)->commit_mutex);
5812 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
5813 mutex_unlock(&JFS_IP(ip)->commit_mutex);
5816 + /* Allocate blocks to dlimit. */
5817 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
5818 + DQUOT_FREE_BLOCK(ip, nxlen);
5819 + dbFree(ip, nxaddr, (s64) nxlen);
5820 + up(&JFS_IP(ip)->commit_sem);
5824 delta = nxlen - xlen;
5826 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
5827 /* extend the extent */
5828 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
5829 dbFree(ip, xaddr + xlen, delta);
5830 + DLIMIT_FREE_BLOCK(ip, nxlen);
5831 DQUOT_FREE_BLOCK(ip, nxlen);
5834 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
5836 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
5837 dbFree(ip, nxaddr, nxlen);
5838 + DLIMIT_FREE_BLOCK(ip, nxlen);
5839 DQUOT_FREE_BLOCK(ip, nxlen);
5842 diff -Nurp linux-2.6.22.18/fs/jfs/jfs_filsys.h linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_filsys.h
5843 --- linux-2.6.22.18/fs/jfs/jfs_filsys.h 2007-05-04 15:58:21.000000000 +0200
5844 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_filsys.h 2008-02-11 12:35:34.000000000 +0100
5846 #define JFS_NAME_MAX 255
5847 #define JFS_PATH_MAX BPSIZE
5849 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
5852 * file system state (superblock state)
5853 diff -Nurp linux-2.6.22.18/fs/jfs/jfs_imap.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_imap.c
5854 --- linux-2.6.22.18/fs/jfs/jfs_imap.c 2007-07-22 00:00:17.000000000 +0200
5855 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_imap.c 2008-02-11 12:35:34.000000000 +0100
5857 #include <linux/buffer_head.h>
5858 #include <linux/pagemap.h>
5859 #include <linux/quotaops.h>
5860 +#include <linux/vs_tag.h>
5862 #include "jfs_incore.h"
5863 #include "jfs_inode.h"
5864 @@ -3075,6 +3076,8 @@ static int copy_from_dinode(struct dinod
5866 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5867 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5871 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5872 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5873 @@ -3095,14 +3098,18 @@ static int copy_from_dinode(struct dinod
5875 ip->i_nlink = le32_to_cpu(dip->di_nlink);
5877 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
5878 + uid = le32_to_cpu(dip->di_uid);
5879 + gid = le32_to_cpu(dip->di_gid);
5880 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
5882 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
5884 ip->i_uid = jfs_ip->saved_uid;
5886 ip->i_uid = sbi->uid;
5889 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
5890 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
5892 ip->i_gid = jfs_ip->saved_gid;
5894 @@ -3167,14 +3174,12 @@ static void copy_to_dinode(struct dinode
5895 dip->di_size = cpu_to_le64(ip->i_size);
5896 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
5897 dip->di_nlink = cpu_to_le32(ip->i_nlink);
5898 - if (sbi->uid == -1)
5899 - dip->di_uid = cpu_to_le32(ip->i_uid);
5901 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
5902 - if (sbi->gid == -1)
5903 - dip->di_gid = cpu_to_le32(ip->i_gid);
5905 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
5907 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
5908 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
5909 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
5910 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
5912 jfs_get_inode_flags(jfs_ip);
5914 * mode2 is only needed for storing the higher order bits.
5915 diff -Nurp linux-2.6.22.18/fs/jfs/jfs_inode.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_inode.c
5916 --- linux-2.6.22.18/fs/jfs/jfs_inode.c 2007-07-22 00:00:17.000000000 +0200
5917 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_inode.c 2008-02-11 12:35:34.000000000 +0100
5920 #include <linux/fs.h>
5921 #include <linux/quotaops.h>
5922 +#include <linux/vs_dlimit.h>
5923 +#include <linux/vs_tag.h>
5924 #include "jfs_incore.h"
5925 #include "jfs_inode.h"
5926 #include "jfs_filsys.h"
5927 @@ -30,19 +32,47 @@ void jfs_set_inode_flags(struct inode *i
5929 unsigned int flags = JFS_IP(inode)->mode2;
5931 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
5932 - S_NOATIME | S_DIRSYNC | S_SYNC);
5933 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
5934 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5936 if (flags & JFS_IMMUTABLE_FL)
5937 inode->i_flags |= S_IMMUTABLE;
5938 + if (flags & JFS_IUNLINK_FL)
5939 + inode->i_flags |= S_IUNLINK;
5940 + if (flags & JFS_BARRIER_FL)
5941 + inode->i_flags |= S_BARRIER;
5943 + if (flags & JFS_SYNC_FL)
5944 + inode->i_flags |= S_SYNC;
5945 if (flags & JFS_APPEND_FL)
5946 inode->i_flags |= S_APPEND;
5947 if (flags & JFS_NOATIME_FL)
5948 inode->i_flags |= S_NOATIME;
5949 if (flags & JFS_DIRSYNC_FL)
5950 inode->i_flags |= S_DIRSYNC;
5951 - if (flags & JFS_SYNC_FL)
5952 - inode->i_flags |= S_SYNC;
5955 +int jfs_sync_flags(struct inode *inode)
5957 + unsigned int oldflags, newflags;
5959 + oldflags = JFS_IP(inode)->mode2;
5960 + newflags = oldflags & ~(JFS_IMMUTABLE_FL |
5961 + JFS_IUNLINK_FL | JFS_BARRIER_FL);
5963 + if (IS_IMMUTABLE(inode))
5964 + newflags |= JFS_IMMUTABLE_FL;
5965 + if (IS_IUNLINK(inode))
5966 + newflags |= JFS_IUNLINK_FL;
5967 + if (IS_BARRIER(inode))
5968 + newflags |= JFS_BARRIER_FL;
5970 + if (oldflags ^ newflags) {
5971 + JFS_IP(inode)->mode2 = newflags;
5972 + inode->i_ctime = CURRENT_TIME;
5973 + mark_inode_dirty(inode);
5978 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
5979 @@ -108,10 +138,17 @@ struct inode *ialloc(struct inode *paren
5980 jfs_inode->saved_uid = inode->i_uid;
5981 jfs_inode->saved_gid = inode->i_gid;
5983 + inode->i_tag = dx_current_fstag(sb);
5984 + if (DLIMIT_ALLOC_INODE(inode)) {
5986 + return ERR_PTR(-ENOSPC);
5990 * Allocate inode to quota.
5992 if (DQUOT_ALLOC_INODE(inode)) {
5993 + DLIMIT_FREE_INODE(inode);
5995 inode->i_flags |= S_NOQUOTA;
5997 diff -Nurp linux-2.6.22.18/fs/jfs/jfs_inode.h linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_inode.h
5998 --- linux-2.6.22.18/fs/jfs/jfs_inode.h 2007-07-22 00:00:17.000000000 +0200
5999 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_inode.h 2008-02-11 12:35:34.000000000 +0100
6000 @@ -33,6 +33,7 @@ extern void jfs_free_zero_link(struct in
6001 extern struct dentry *jfs_get_parent(struct dentry *dentry);
6002 extern void jfs_get_inode_flags(struct jfs_inode_info *);
6003 extern void jfs_set_inode_flags(struct inode *);
6004 +extern int jfs_sync_flags(struct inode *);
6005 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
6007 extern const struct address_space_operations jfs_aops;
6008 diff -Nurp linux-2.6.22.18/fs/jfs/jfs_xtree.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_xtree.c
6009 --- linux-2.6.22.18/fs/jfs/jfs_xtree.c 2007-07-21 23:58:46.000000000 +0200
6010 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/jfs_xtree.c 2008-02-11 12:35:34.000000000 +0100
6013 #include <linux/fs.h>
6014 #include <linux/quotaops.h>
6015 +#include <linux/vs_dlimit.h>
6016 #include "jfs_incore.h"
6017 #include "jfs_filsys.h"
6018 #include "jfs_metapage.h"
6019 @@ -846,7 +847,12 @@ int xtInsert(tid_t tid, /* transaction
6021 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
6023 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
6024 + DQUOT_FREE_BLOCK(ip, xlen);
6027 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
6028 + DLIMIT_FREE_BLOCK(ip, xlen);
6029 DQUOT_FREE_BLOCK(ip, xlen);
6032 @@ -876,6 +882,7 @@ int xtInsert(tid_t tid, /* transaction
6033 /* undo data extent allocation */
6035 dbFree(ip, xaddr, (s64) xlen);
6036 + DLIMIT_FREE_BLOCK(ip, xlen);
6037 DQUOT_FREE_BLOCK(ip, xlen);
6040 @@ -1236,6 +1243,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
6042 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
6043 int quota_allocation = 0;
6044 + int dlimit_allocation = 0;
6047 sp = XT_PAGE(ip, smp);
6048 @@ -1255,6 +1263,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
6050 quota_allocation += lengthPXD(pxd);
6052 + /* Allocate blocks to dlimit. */
6053 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
6057 + dlimit_allocation += lengthPXD(pxd);
6060 * allocate the new right page for the split
6062 @@ -1456,6 +1471,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
6066 + /* Rollback dlimit allocation. */
6067 + if (dlimit_allocation)
6068 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
6069 /* Rollback quota allocation. */
6070 if (quota_allocation)
6071 DQUOT_FREE_BLOCK(ip, quota_allocation);
6072 @@ -1520,6 +1538,12 @@ xtSplitRoot(tid_t tid,
6073 release_metapage(rmp);
6076 + /* Allocate blocks to dlimit. */
6077 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
6078 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
6079 + release_metapage(rmp);
6083 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
6085 @@ -3951,6 +3975,8 @@ s64 xtTruncate(tid_t tid, struct inode *
6087 ip->i_size = newsize;
6089 + /* update dlimit allocation to reflect freed blocks */
6090 + DLIMIT_FREE_BLOCK(ip, nfreed);
6091 /* update quota allocation to reflect freed blocks */
6092 DQUOT_FREE_BLOCK(ip, nfreed);
6094 diff -Nurp linux-2.6.22.18/fs/jfs/namei.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/namei.c
6095 --- linux-2.6.22.18/fs/jfs/namei.c 2007-07-21 23:58:46.000000000 +0200
6096 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/namei.c 2008-02-11 12:35:34.000000000 +0100
6098 #include <linux/fs.h>
6099 #include <linux/ctype.h>
6100 #include <linux/quotaops.h>
6101 +#include <linux/vs_tag.h>
6102 #include "jfs_incore.h"
6103 #include "jfs_superblock.h"
6104 #include "jfs_inode.h"
6105 @@ -1469,6 +1470,7 @@ static struct dentry *jfs_lookup(struct
6106 return ERR_PTR(-EACCES);
6109 + dx_propagate_tag(nd, ip);
6110 dentry = d_splice_alias(ip, dentry);
6112 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
6113 @@ -1521,6 +1523,7 @@ const struct inode_operations jfs_dir_in
6114 .setattr = jfs_setattr,
6115 .permission = jfs_permission,
6117 + .sync_flags = jfs_sync_flags,
6120 const struct file_operations jfs_dir_operations = {
6121 diff -Nurp linux-2.6.22.18/fs/jfs/super.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/super.c
6122 --- linux-2.6.22.18/fs/jfs/super.c 2007-07-22 00:00:17.000000000 +0200
6123 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/super.c 2008-02-11 12:35:34.000000000 +0100
6124 @@ -194,7 +194,8 @@ static void jfs_put_super(struct super_b
6126 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
6127 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
6128 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
6129 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
6130 + Opt_tag, Opt_notag, Opt_tagid
6133 static match_table_t tokens = {
6134 @@ -204,6 +205,10 @@ static match_table_t tokens = {
6135 {Opt_resize, "resize=%u"},
6136 {Opt_resize_nosize, "resize"},
6137 {Opt_errors, "errors=%s"},
6139 + {Opt_notag, "notag"},
6140 + {Opt_tagid, "tagid=%u"},
6141 + {Opt_tag, "tagxid"},
6142 {Opt_ignore, "noquota"},
6143 {Opt_ignore, "quota"},
6144 {Opt_usrquota, "usrquota"},
6145 @@ -338,6 +343,20 @@ static int parse_options(char *options,
6149 +#ifndef CONFIG_TAGGING_NONE
6151 + *flag |= JFS_TAGGED;
6154 + *flag &= JFS_TAGGED;
6157 +#ifdef CONFIG_PROPAGATE
6160 + *flag |= JFS_TAGGED;
6164 printk("jfs: Unrecognized mount option \"%s\" "
6165 " or missing value\n", p);
6166 @@ -368,6 +387,13 @@ static int jfs_remount(struct super_bloc
6167 if (!parse_options(data, sb, &newLVSize, &flag)) {
6171 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
6172 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
6178 if (sb->s_flags & MS_RDONLY) {
6180 @@ -439,6 +465,9 @@ static int jfs_fill_super(struct super_b
6181 #ifdef CONFIG_JFS_POSIX_ACL
6182 sb->s_flags |= MS_POSIXACL;
6184 + /* map mount option tagxid */
6185 + if (sbi->flag & JFS_TAGGED)
6186 + sb->s_flags |= MS_TAGGED;
6189 printk(KERN_ERR "resize option for remount only\n");
6190 diff -Nurp linux-2.6.22.18/fs/jfs/xattr.c linux-2.6.22.18-vs2.3.0.32/fs/jfs/xattr.c
6191 --- linux-2.6.22.18/fs/jfs/xattr.c 2007-05-04 15:57:36.000000000 +0200
6192 +++ linux-2.6.22.18-vs2.3.0.32/fs/jfs/xattr.c 2008-02-11 12:35:34.000000000 +0100
6194 #include <linux/posix_acl_xattr.h>
6195 #include <linux/quotaops.h>
6196 #include <linux/security.h>
6197 +#include <linux/vs_dlimit.h>
6198 #include "jfs_incore.h"
6199 #include "jfs_superblock.h"
6200 #include "jfs_dmap.h"
6201 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
6202 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
6205 + /* Allocate new blocks to dlimit. */
6206 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
6207 + DQUOT_FREE_BLOCK(ip, nblocks);
6211 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
6213 + /*Rollback dlimit allocation. */
6214 + DLIMIT_FREE_BLOCK(ip, nblocks);
6215 /*Rollback quota allocation. */
6216 DQUOT_FREE_BLOCK(ip, nblocks);
6218 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
6221 /* Rollback quota allocation. */
6222 + DLIMIT_FREE_BLOCK(ip, nblocks);
6223 + /* Rollback quota allocation. */
6224 DQUOT_FREE_BLOCK(ip, nblocks);
6226 dbFree(ip, blkno, nblocks);
6227 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
6230 int quota_allocation = 0;
6231 + int dlimit_allocation = 0;
6233 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
6234 if (ji->ea.flag == 0)
6235 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
6237 quota_allocation = blocks_needed;
6239 + /* Allocate new blocks to dlimit. */
6241 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
6243 + dlimit_allocation = blocks_needed;
6245 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
6248 @@ -599,6 +616,9 @@ static int ea_get(struct inode *inode, s
6252 + /* Rollback dlimit allocation */
6253 + if (dlimit_allocation)
6254 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
6255 /* Rollback quota allocation */
6256 if (quota_allocation)
6257 DQUOT_FREE_BLOCK(inode, quota_allocation);
6258 @@ -675,8 +695,10 @@ static int ea_put(tid_t tid, struct inod
6261 /* If old blocks exist, they must be removed from quota allocation. */
6264 + DLIMIT_FREE_BLOCK(inode, old_blocks);
6265 DQUOT_FREE_BLOCK(inode, old_blocks);
6268 inode->i_ctime = CURRENT_TIME;
6270 diff -Nurp linux-2.6.22.18/fs/Kconfig linux-2.6.22.18-vs2.3.0.32/fs/Kconfig
6271 --- linux-2.6.22.18/fs/Kconfig 2007-07-22 00:00:15.000000000 +0200
6272 +++ linux-2.6.22.18-vs2.3.0.32/fs/Kconfig 2008-02-11 12:35:33.000000000 +0100
6273 @@ -2026,7 +2026,7 @@ config CODA_FS_OLD_API
6276 tristate "Andrew File System support (AFS) (EXPERIMENTAL)"
6277 - depends on INET && EXPERIMENTAL
6278 + depends on INET && EXPERIMENTAL && !VSERVER_SECURITY
6281 If you say Y here, you will get an experimental Andrew File System
6282 diff -Nurp linux-2.6.22.18/fs/libfs.c linux-2.6.22.18-vs2.3.0.32/fs/libfs.c
6283 --- linux-2.6.22.18/fs/libfs.c 2007-07-22 00:00:17.000000000 +0200
6284 +++ linux-2.6.22.18-vs2.3.0.32/fs/libfs.c 2008-02-11 12:35:34.000000000 +0100
6285 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
6286 * both impossible due to the lock on directory.
6289 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6290 +static inline int do_dcache_readdir_filter(struct file *filp,
6291 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6293 struct dentry *dentry = filp->f_path.dentry;
6294 struct dentry *cursor = filp->private_data;
6295 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
6296 next = list_entry(p, struct dentry, d_u.d_child);
6297 if (d_unhashed(next) || !next->d_inode)
6299 + if (filter && !filter(next))
6302 spin_unlock(&dcache_lock);
6303 if (filldir(dirent, next->d_name.name,
6304 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
6308 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6310 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6313 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6314 + int (*filter)(struct dentry *))
6316 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6320 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6323 @@ -640,6 +655,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6324 EXPORT_SYMBOL(dcache_dir_lseek);
6325 EXPORT_SYMBOL(dcache_dir_open);
6326 EXPORT_SYMBOL(dcache_readdir);
6327 +EXPORT_SYMBOL(dcache_readdir_filter);
6328 EXPORT_SYMBOL(generic_read_dir);
6329 EXPORT_SYMBOL(get_sb_pseudo);
6330 EXPORT_SYMBOL(simple_commit_write);
6331 diff -Nurp linux-2.6.22.18/fs/locks.c linux-2.6.22.18-vs2.3.0.32/fs/locks.c
6332 --- linux-2.6.22.18/fs/locks.c 2007-09-29 14:11:49.000000000 +0200
6333 +++ linux-2.6.22.18-vs2.3.0.32/fs/locks.c 2008-02-11 12:35:34.000000000 +0100
6335 #include <linux/syscalls.h>
6336 #include <linux/time.h>
6337 #include <linux/rcupdate.h>
6338 +#include <linux/vs_base.h>
6339 +#include <linux/vs_limit.h>
6341 #include <asm/semaphore.h>
6342 #include <asm/uaccess.h>
6343 @@ -147,6 +149,8 @@ static struct kmem_cache *filelock_cache
6344 /* Allocate an empty lock structure. */
6345 static struct file_lock *locks_alloc_lock(void)
6347 + if (!vx_locks_avail(1))
6349 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6352 @@ -172,6 +176,7 @@ static void locks_free_lock(struct file_
6353 BUG_ON(!list_empty(&fl->fl_block));
6354 BUG_ON(!list_empty(&fl->fl_link));
6357 locks_release_private(fl);
6358 kmem_cache_free(filelock_cache, fl);
6360 @@ -191,6 +196,7 @@ void locks_init_lock(struct file_lock *f
6361 fl->fl_start = fl->fl_end = 0;
6363 fl->fl_lmops = NULL;
6367 EXPORT_SYMBOL(locks_init_lock);
6368 @@ -244,6 +250,7 @@ void locks_copy_lock(struct file_lock *n
6369 new->fl_file = fl->fl_file;
6370 new->fl_ops = fl->fl_ops;
6371 new->fl_lmops = fl->fl_lmops;
6372 + new->fl_xid = fl->fl_xid;
6374 locks_copy_private(new, fl);
6376 @@ -282,6 +289,11 @@ static int flock_make_lock(struct file *
6377 fl->fl_flags = FL_FLOCK;
6379 fl->fl_end = OFFSET_MAX;
6381 + vxd_assert(filp->f_xid == vx_current_xid(),
6382 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6383 + fl->fl_xid = filp->f_xid;
6388 @@ -447,6 +459,7 @@ static int lease_init(struct file *filp,
6390 fl->fl_owner = current->files;
6391 fl->fl_pid = current->tgid;
6392 + fl->fl_xid = vx_current_xid();
6395 fl->fl_flags = FL_LEASE;
6396 @@ -466,6 +479,11 @@ static int lease_alloc(struct file *filp
6400 + fl->fl_xid = vx_current_xid();
6402 + vxd_assert(filp->f_xid == fl->fl_xid,
6403 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6405 error = lease_init(filp, type, fl);
6407 locks_free_lock(fl);
6408 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
6412 + new_fl->fl_xid = -1;
6414 for_each_lock(inode, before) {
6415 struct file_lock *fl = *before;
6416 @@ -787,6 +806,7 @@ find_conflict:
6418 locks_copy_lock(new_fl, request);
6419 locks_insert_lock(before, new_fl);
6420 + vx_locks_inc(new_fl);
6424 @@ -797,7 +817,8 @@ out:
6428 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6429 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6430 + struct file_lock *conflock, xid_t xid)
6432 struct file_lock *fl;
6433 struct file_lock *new_fl = NULL;
6434 @@ -807,6 +828,8 @@ static int __posix_lock_file(struct inod
6435 struct file_lock **before;
6436 int error, added = 0;
6438 + vxd_assert(xid == vx_current_xid(),
6439 + "xid(%d) == current(%d)", xid, vx_current_xid());
6441 * We may need two file_lock structures for this operation,
6442 * so we get them in advance to avoid races.
6443 @@ -817,7 +840,11 @@ static int __posix_lock_file(struct inod
6444 (request->fl_type != F_UNLCK ||
6445 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6446 new_fl = locks_alloc_lock();
6447 + new_fl->fl_xid = xid;
6448 + vx_locks_inc(new_fl);
6449 new_fl2 = locks_alloc_lock();
6450 + new_fl2->fl_xid = xid;
6451 + vx_locks_inc(new_fl2);
6455 @@ -1016,7 +1043,8 @@ static int __posix_lock_file(struct inod
6456 int posix_lock_file(struct file *filp, struct file_lock *fl,
6457 struct file_lock *conflock)
6459 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6460 + return __posix_lock_file(filp->f_path.dentry->d_inode,
6461 + fl, conflock, filp->f_xid);
6463 EXPORT_SYMBOL(posix_lock_file);
6465 @@ -1106,7 +1134,7 @@ int locks_mandatory_area(int read_write,
6466 fl.fl_end = offset + count - 1;
6469 - error = __posix_lock_file(inode, &fl, NULL);
6470 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6471 if (error != -EAGAIN)
6473 if (!(fl.fl_flags & FL_SLEEP))
6474 @@ -1410,8 +1438,8 @@ static int __setlease(struct file *filp,
6477 locks_copy_lock(fl, lease);
6479 locks_insert_lock(before, fl);
6484 @@ -1738,6 +1766,11 @@ int fcntl_setlk(unsigned int fd, struct
6485 if (file_lock == NULL)
6488 + vxd_assert(filp->f_xid == vx_current_xid(),
6489 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6490 + file_lock->fl_xid = filp->f_xid;
6491 + vx_locks_inc(file_lock);
6494 * This might block, so we do it before checking the inode.
6496 @@ -1864,6 +1897,11 @@ int fcntl_setlk64(unsigned int fd, struc
6497 if (file_lock == NULL)
6500 + vxd_assert(filp->f_xid == vx_current_xid(),
6501 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6502 + file_lock->fl_xid = filp->f_xid;
6503 + vx_locks_inc(file_lock);
6506 * This might block, so we do it before checking the inode.
6508 @@ -2168,6 +2206,10 @@ int get_locks_status(char *buffer, char
6509 list_for_each(tmp, &file_lock_list) {
6510 struct list_head *btmp;
6511 struct file_lock *fl = list_entry(tmp, struct file_lock, fl_link);
6513 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6516 lock_get_status(q, fl, ++i, "");
6517 move_lock_status(&q, &pos, offset);
6519 diff -Nurp linux-2.6.22.18/fs/namei.c linux-2.6.22.18-vs2.3.0.32/fs/namei.c
6520 --- linux-2.6.22.18/fs/namei.c 2008-01-15 16:00:53.000000000 +0100
6521 +++ linux-2.6.22.18-vs2.3.0.32/fs/namei.c 2008-02-11 12:35:34.000000000 +0100
6523 #include <linux/file.h>
6524 #include <linux/fcntl.h>
6525 #include <linux/namei.h>
6526 +#include <linux/proc_fs.h>
6527 +#include <linux/vserver/inode.h>
6528 +#include <linux/vs_base.h>
6529 +#include <linux/vs_tag.h>
6530 +#include <linux/vs_cowbl.h>
6531 +#include <linux/vs_device.h>
6532 +#include <linux/vs_context.h>
6533 #include <asm/namei.h>
6534 #include <asm/uaccess.h>
6536 @@ -224,6 +231,28 @@ int generic_permission(struct inode *ino
6540 +static inline int dx_barrier(struct inode *inode)
6542 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN)) {
6543 + vxwprintk_task(1, "did hit the barrier.");
6549 +static inline int dx_permission(struct inode *inode, int mask, struct nameidata *nd)
6551 + if (dx_barrier(inode))
6553 + if (dx_notagcheck(nd) ||
6554 + dx_check(inode->i_tag, DX_HOSTID|DX_ADMIN|DX_WATCH|DX_IDENT))
6557 + vxwprintk_task(1, "denied access to %p[#%d,%lu] »%s«.",
6558 + inode, inode->i_tag, inode->i_ino, vxd_cond_path(nd));
6562 int permission(struct inode *inode, int mask, struct nameidata *nd)
6564 umode_t mode = inode->i_mode;
6565 @@ -234,14 +263,14 @@ int permission(struct inode *inode, int
6567 * Nobody gets write access to a read-only fs.
6569 - if (IS_RDONLY(inode) &&
6570 + if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
6571 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
6575 * Nobody gets write access to an immutable file.
6577 - if (IS_IMMUTABLE(inode))
6578 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6582 @@ -257,6 +286,12 @@ int permission(struct inode *inode, int
6584 /* Ordinary permission routines do not understand MAY_APPEND. */
6585 submask = mask & ~MAY_APPEND;
6587 + if ((inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC) &&
6588 + (inode->i_sb->s_magic != PROC_SUPER_MAGIC) &&
6589 + (retval = dx_permission(inode, mask, nd)))
6592 if (inode->i_op && inode->i_op->permission)
6593 retval = inode->i_op->permission(inode, submask, nd);
6595 @@ -432,6 +467,8 @@ static int exec_permission_lite(struct i
6597 umode_t mode = inode->i_mode;
6599 + if (dx_barrier(inode))
6601 if (inode->i_op && inode->i_op->permission)
6604 @@ -732,7 +769,8 @@ static __always_inline void follow_dotdo
6605 if (nd->dentry == fs->root &&
6606 nd->mnt == fs->rootmnt) {
6607 read_unlock(&fs->lock);
6609 + /* for sane '/' avoid follow_mount() */
6612 read_unlock(&fs->lock);
6613 spin_lock(&dcache_lock);
6614 @@ -769,16 +807,39 @@ static int do_lookup(struct nameidata *n
6616 struct vfsmount *mnt = nd->mnt;
6617 struct dentry *dentry = __d_lookup(nd->dentry, name);
6618 + struct inode *inode;
6622 if (dentry->d_op && dentry->d_op->d_revalidate)
6623 goto need_revalidate;
6624 + inode = dentry->d_inode;
6628 + if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6629 + struct proc_dir_entry *de = PDE(inode);
6631 + if (de && !vx_hide_check(0, de->vx_flags))
6633 + } else if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6634 + if (!vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
6637 + if (!dx_notagcheck(nd) && !dx_check(inode->i_tag,
6638 + DX_WATCH | DX_ADMIN | DX_HOSTID | DX_IDENT))
6643 path->dentry = dentry;
6644 __follow_mount(path);
6647 + vxwprintk_task(1, "did lookup hidden %p[#%d,%lu] »%s«.",
6648 + inode, inode->i_tag, inode->i_ino, vxd_path(dentry, mnt));
6653 dentry = real_lookup(nd->dentry, name, nd);
6654 @@ -1399,7 +1460,8 @@ static inline int check_sticky(struct in
6655 * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
6656 * nfs_async_unlink().
6658 -static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
6659 +static int may_delete(struct inode *dir, struct dentry *victim,
6660 + int isdir, struct nameidata *nd)
6664 @@ -1409,13 +1471,13 @@ static int may_delete(struct inode *dir,
6665 BUG_ON(victim->d_parent->d_inode != dir);
6666 audit_inode_child(victim->d_name.name, victim->d_inode, dir);
6668 - error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
6669 + error = permission(dir,MAY_WRITE | MAY_EXEC, nd);
6674 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6675 - IS_IMMUTABLE(victim->d_inode))
6676 + IS_IXORUNLINK(victim->d_inode))
6679 if (!S_ISDIR(victim->d_inode->i_mode))
6680 @@ -1546,6 +1608,14 @@ int may_open(struct nameidata *nd, int a
6681 if (S_ISDIR(inode->i_mode) && (acc_mode & MAY_WRITE))
6684 +#ifdef CONFIG_VSERVER_COWBL
6685 + if (IS_COW(inode) && (acc_mode & MAY_WRITE)) {
6686 + if (IS_COW_LINK(inode))
6688 + inode->i_flags &= ~(S_IUNLINK|S_IMMUTABLE);
6689 + mark_inode_dirty(inode);
6692 error = vfs_permission(nd, acc_mode);
6695 @@ -1562,7 +1632,8 @@ int may_open(struct nameidata *nd, int a
6699 - } else if (IS_RDONLY(inode) && (acc_mode & MAY_WRITE))
6700 + } else if ((IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
6701 + && (acc_mode & MAY_WRITE))
6704 * An append-only file must be opened in append mode for writing.
6705 @@ -1650,6 +1721,11 @@ int open_namei(int dfd, const char *path
6709 +#ifdef CONFIG_VSERVER_COWBL
6714 acc_mode = ACC_MODE(flag);
6716 /* O_TRUNC implies we need access checks for write permissions */
6717 @@ -1743,6 +1819,22 @@ do_last:
6720 error = may_open(nd, acc_mode, flag);
6721 +#ifdef CONFIG_VSERVER_COWBL
6722 + if (error == -EMLINK) {
6723 + struct dentry *dentry;
6724 + dentry = cow_break_link(pathname);
6725 + if (IS_ERR(dentry)) {
6726 + error = PTR_ERR(dentry);
6730 + release_open_intent(nd);
6740 @@ -1854,16 +1946,25 @@ fail:
6742 EXPORT_SYMBOL_GPL(lookup_create);
6744 -int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
6745 +int vfs_mknod(struct inode *dir, struct dentry *dentry,
6746 + int mode, dev_t dev, struct nameidata *nd)
6748 - int error = may_create(dir, dentry, NULL);
6749 + int error = may_create(dir, dentry, nd);
6754 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
6755 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
6758 + if (!capable(CAP_MKNOD))
6761 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
6763 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
6766 if (!dir->i_op || !dir->i_op->mknod)
6769 @@ -1906,11 +2007,12 @@ asmlinkage long sys_mknodat(int dfd, con
6770 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
6772 case S_IFCHR: case S_IFBLK:
6773 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
6774 - new_decode_dev(dev));
6775 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6776 + new_decode_dev(dev), &nd);
6778 case S_IFIFO: case S_IFSOCK:
6779 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
6780 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6785 @@ -1933,9 +2035,10 @@ asmlinkage long sys_mknod(const char __u
6786 return sys_mknodat(AT_FDCWD, filename, mode, dev);
6789 -int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
6790 +int vfs_mkdir(struct inode *dir, struct dentry *dentry,
6791 + int mode, struct nameidata *nd)
6793 - int error = may_create(dir, dentry, NULL);
6794 + int error = may_create(dir, dentry, nd);
6798 @@ -1977,7 +2080,7 @@ asmlinkage long sys_mkdirat(int dfd, con
6800 if (!IS_POSIXACL(nd.dentry->d_inode))
6801 mode &= ~current->fs->umask;
6802 - error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
6803 + error = vfs_mkdir(nd.dentry->d_inode, dentry, mode, &nd);
6806 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6807 @@ -2020,9 +2123,10 @@ void dentry_unhash(struct dentry *dentry
6808 spin_unlock(&dcache_lock);
6811 -int vfs_rmdir(struct inode *dir, struct dentry *dentry)
6812 +int vfs_rmdir(struct inode *dir, struct dentry *dentry,
6813 + struct nameidata *nd)
6815 - int error = may_delete(dir, dentry, 1);
6816 + int error = may_delete(dir, dentry, 1, nd);
6820 @@ -2084,7 +2188,7 @@ static long do_rmdir(int dfd, const char
6821 error = PTR_ERR(dentry);
6824 - error = vfs_rmdir(nd.dentry->d_inode, dentry);
6825 + error = vfs_rmdir(nd.dentry->d_inode, dentry, &nd);
6828 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6829 @@ -2100,9 +2204,10 @@ asmlinkage long sys_rmdir(const char __u
6830 return do_rmdir(AT_FDCWD, pathname);
6833 -int vfs_unlink(struct inode *dir, struct dentry *dentry)
6834 +int vfs_unlink(struct inode *dir, struct dentry *dentry,
6835 + struct nameidata *nd)
6837 - int error = may_delete(dir, dentry, 0);
6838 + int error = may_delete(dir, dentry, 0, nd);
6842 @@ -2164,7 +2269,7 @@ static long do_unlinkat(int dfd, const c
6843 inode = dentry->d_inode;
6845 atomic_inc(&inode->i_count);
6846 - error = vfs_unlink(nd.dentry->d_inode, dentry);
6847 + error = vfs_unlink(nd.dentry->d_inode, dentry, &nd);
6851 @@ -2199,9 +2304,10 @@ asmlinkage long sys_unlink(const char __
6852 return do_unlinkat(AT_FDCWD, pathname);
6855 -int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode)
6856 +int vfs_symlink(struct inode *dir, struct dentry *dentry,
6857 + const char *oldname, int mode, struct nameidata *nd)
6859 - int error = may_create(dir, dentry, NULL);
6860 + int error = may_create(dir, dentry, nd);
6864 @@ -2245,7 +2351,7 @@ asmlinkage long sys_symlinkat(const char
6868 - error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
6869 + error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO, &nd);
6872 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6873 @@ -2262,7 +2368,8 @@ asmlinkage long sys_symlink(const char _
6874 return sys_symlinkat(oldname, AT_FDCWD, newname);
6877 -int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
6878 +int vfs_link(struct dentry *old_dentry, struct inode *dir,
6879 + struct dentry *new_dentry, struct nameidata *nd)
6881 struct inode *inode = old_dentry->d_inode;
6883 @@ -2270,7 +2377,7 @@ int vfs_link(struct dentry *old_dentry,
6887 - error = may_create(dir, new_dentry, NULL);
6888 + error = may_create(dir, new_dentry, nd);
6892 @@ -2280,7 +2387,7 @@ int vfs_link(struct dentry *old_dentry,
6894 * A link to an append-only or immutable file cannot be created.
6896 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6897 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6899 if (!dir->i_op || !dir->i_op->link)
6901 @@ -2340,7 +2447,7 @@ asmlinkage long sys_linkat(int olddfd, c
6902 error = PTR_ERR(new_dentry);
6903 if (IS_ERR(new_dentry))
6905 - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
6906 + error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry, &nd);
6909 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6910 @@ -2472,14 +2579,14 @@ int vfs_rename(struct inode *old_dir, st
6911 if (old_dentry->d_inode == new_dentry->d_inode)
6914 - error = may_delete(old_dir, old_dentry, is_dir);
6915 + error = may_delete(old_dir, old_dentry, is_dir, NULL);
6919 if (!new_dentry->d_inode)
6920 error = may_create(new_dir, new_dentry, NULL);
6922 - error = may_delete(new_dir, new_dentry, is_dir);
6923 + error = may_delete(new_dir, new_dentry, is_dir, NULL);
6927 @@ -2557,6 +2664,9 @@ static int do_rename(int olddfd, const c
6929 if (old_dentry == trap)
6932 + if (MNT_IS_RDONLY(newnd.mnt))
6934 new_dentry = lookup_hash(&newnd);
6935 error = PTR_ERR(new_dentry);
6936 if (IS_ERR(new_dentry))
6937 @@ -2650,6 +2760,216 @@ int vfs_follow_link(struct nameidata *nd
6938 return __vfs_follow_link(nd, link);
6942 +#ifdef CONFIG_VSERVER_COWBL
6944 +#include <linux/file.h>
6947 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6951 + return do_splice_direct(in, &ppos, out, len, 0);
6954 +struct dentry *cow_break_link(const char *pathname)
6956 + int ret, mode, pathlen, redo = 0;
6957 + struct nameidata old_nd, dir_nd;
6958 + struct dentry *old_dentry, *new_dentry;
6959 + struct dentry *dir, *res = NULL;
6960 + struct vfsmount *old_mnt, *new_mnt;
6961 + struct file *old_file;
6962 + struct file *new_file;
6963 + char *to, *path, pad='\251';
6966 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6967 + path = kmalloc(PATH_MAX, GFP_KERNEL);
6972 + /* old_nd will have refs to dentry and mnt */
6973 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6974 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6976 + goto out_free_path;
6978 + old_dentry = old_nd.dentry;
6979 + old_mnt = old_nd.mnt;
6980 + mode = old_dentry->d_inode->i_mode;
6982 + to = d_path(old_dentry, old_mnt, path, PATH_MAX-2);
6983 + pathlen = strlen(to);
6984 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
6985 + old_dentry->d_name.len, old_dentry->d_name.name,
6986 + old_dentry->d_name.len);
6988 + to[pathlen + 1] = 0;
6990 + to[pathlen] = pad--;
6992 + if (pad <= '\240')
6995 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
6996 + /* dir_nd will have refs to dentry and mnt */
6997 + ret = path_lookup(to,
6998 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6999 + vxdprintk(VXD_CBIT(misc, 2),
7000 + "path_lookup(new): %d", ret);
7004 + /* this puppy downs the inode mutex */
7005 + new_dentry = lookup_create(&dir_nd, 0);
7006 + vxdprintk(VXD_CBIT(misc, 2),
7007 + "lookup_create(new): %p [»%.*s«:%d]", new_dentry,
7008 + new_dentry->d_name.len, new_dentry->d_name.name,
7009 + new_dentry->d_name.len);
7010 + if (!new_dentry || IS_ERR(new_dentry)) {
7011 + path_release(&dir_nd);
7014 + dir = dir_nd.dentry;
7016 + ret = vfs_create(dir_nd.dentry->d_inode, new_dentry, mode, &dir_nd);
7017 + vxdprintk(VXD_CBIT(misc, 2),
7018 + "vfs_create(new): %d", ret);
7019 + if (ret == -EEXIST) {
7020 + mutex_unlock(&dir->d_inode->i_mutex);
7022 + path_release(&dir_nd);
7026 + goto out_unlock_new;
7028 + /* drop out early, ret passes ENOENT */
7030 + if ((redo = d_unhashed(old_dentry)))
7031 + goto out_unlock_new;
7033 + new_mnt = dir_nd.mnt;
7036 + /* this one cleans up the dentry/mnt in case of failure */
7037 + old_file = dentry_open(old_dentry, old_mnt, O_RDONLY);
7038 + vxdprintk(VXD_CBIT(misc, 2),
7039 + "dentry_open(old): %p", old_file);
7040 + if (!old_file || IS_ERR(old_file)) {
7041 + res = IS_ERR(old_file) ? (void *) old_file : res;
7042 + goto out_unlock_new;
7047 + /* this one cleans up the dentry/mnt in case of failure */
7048 + new_file = dentry_open(new_dentry, new_mnt, O_WRONLY);
7049 + vxdprintk(VXD_CBIT(misc, 2),
7050 + "dentry_open(new): %p", new_file);
7052 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
7053 + if (!new_file || IS_ERR(new_file))
7054 + goto out_fput_old;
7056 + size = i_size_read(old_file->f_dentry->d_inode);
7057 + ret = do_cow_splice(old_file, new_file, size);
7058 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
7060 + goto out_fput_both;
7061 + } else if (ret < size) {
7063 + goto out_fput_both;
7065 + struct inode *old_inode = old_dentry->d_inode;
7066 + struct inode *new_inode = new_dentry->d_inode;
7067 + struct iattr attr = {
7068 + .ia_uid = old_inode->i_uid,
7069 + .ia_gid = old_inode->i_gid,
7070 + .ia_valid = ATTR_UID | ATTR_GID
7073 + ret = inode_setattr(new_inode, &attr);
7075 + goto out_fput_both;
7078 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
7080 + /* drop out late */
7082 + if ((redo = d_unhashed(old_dentry)))
7085 + vxdprintk(VXD_CBIT(misc, 2),
7086 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
7087 + new_dentry->d_name.len, new_dentry->d_name.name,
7088 + new_dentry->d_name.len,
7089 + old_dentry->d_name.len, old_dentry->d_name.name,
7090 + old_dentry->d_name.len);
7091 + ret = vfs_rename(dir_nd.dentry->d_inode, new_dentry,
7092 + old_nd.dentry->d_parent->d_inode, old_dentry);
7093 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
7097 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
7100 + vxdprintk(VXD_CBIT(misc, 3),
7101 + "fput(new_file=%p[#%d])", new_file,
7102 + atomic_read(&new_file->f_count));
7106 + vxdprintk(VXD_CBIT(misc, 3),
7107 + "fput(old_file=%p[#%d])", old_file,
7108 + atomic_read(&old_file->f_count));
7112 + mutex_unlock(&dir->d_inode->i_mutex);
7116 + /* error path cleanup */
7117 + vfs_unlink(dir->d_inode, new_dentry, &dir_nd);
7122 + goto out_rel_both;
7123 + /* lookup dentry once again */
7124 + path_release(&old_nd);
7125 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
7127 + goto out_rel_both;
7129 + new_dentry = old_nd.dentry;
7130 + vxdprintk(VXD_CBIT(misc, 2),
7131 + "path_lookup(redo): %p [»%.*s«:%d]", new_dentry,
7132 + new_dentry->d_name.len, new_dentry->d_name.name,
7133 + new_dentry->d_name.len);
7138 + path_release(&dir_nd);
7140 + path_release(&old_nd);
7145 + res = ERR_PTR(ret);
7151 /* get the link contents into pagecache */
7152 static char *page_getlink(struct dentry * dentry, struct page **ppage)
7154 diff -Nurp linux-2.6.22.18/fs/namespace.c linux-2.6.22.18-vs2.3.0.32/fs/namespace.c
7155 --- linux-2.6.22.18/fs/namespace.c 2007-07-22 00:00:17.000000000 +0200
7156 +++ linux-2.6.22.18-vs2.3.0.32/fs/namespace.c 2008-02-11 12:35:34.000000000 +0100
7158 #include <linux/security.h>
7159 #include <linux/mount.h>
7160 #include <linux/ramfs.h>
7161 +#include <linux/vs_base.h>
7162 +#include <linux/vs_context.h>
7163 +#include <linux/vs_tag.h>
7164 +#include <linux/vserver/space.h>
7165 +#include <linux/vserver/global.h>
7166 #include <asm/uaccess.h>
7167 #include <asm/unistd.h>
7169 @@ -240,6 +245,7 @@ static struct vfsmount *clone_mnt(struct
7170 mnt->mnt_root = dget(root);
7171 mnt->mnt_mountpoint = mnt->mnt_root;
7172 mnt->mnt_parent = mnt;
7173 + mnt->mnt_tag = old->mnt_tag;
7175 if (flag & CL_SLAVE) {
7176 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
7177 @@ -348,48 +354,91 @@ static inline void mangle(struct seq_fil
7178 seq_escape(m, s, " \t\n\\");
7181 +static int mnt_is_reachable(struct vfsmount *mnt)
7183 + struct vfsmount *root_mnt;
7184 + struct dentry *root, *point;
7187 + if (mnt == mnt->mnt_ns->root)
7190 + spin_lock(&vfsmount_lock);
7191 + root_mnt = current->fs->rootmnt;
7192 + root = current->fs->root;
7195 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
7196 + point = mnt->mnt_mountpoint;
7197 + mnt = mnt->mnt_parent;
7200 + ret = (mnt == root_mnt) && is_subdir(point, root);
7202 + spin_unlock(&vfsmount_lock);
7207 static int show_vfsmnt(struct seq_file *m, void *v)
7209 struct vfsmount *mnt = v;
7211 static struct proc_fs_info {
7219 - { MS_SYNCHRONOUS, ",sync" },
7220 - { MS_DIRSYNC, ",dirsync" },
7221 - { MS_MANDLOCK, ",mand" },
7224 - static struct proc_fs_info mnt_info[] = {
7225 - { MNT_NOSUID, ",nosuid" },
7226 - { MNT_NODEV, ",nodev" },
7227 - { MNT_NOEXEC, ",noexec" },
7228 - { MNT_NOATIME, ",noatime" },
7229 - { MNT_NODIRATIME, ",nodiratime" },
7230 - { MNT_RELATIME, ",relatime" },
7232 + { MS_RDONLY, MNT_RDONLY, "ro", "rw" },
7233 + { MS_SYNCHRONOUS, 0, ",sync", NULL },
7234 + { MS_DIRSYNC, 0, ",dirsync", NULL },
7235 + { MS_MANDLOCK, 0, ",mand", NULL },
7236 + { MS_TAGGED, 0, ",tag", NULL },
7237 + { MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
7238 + { MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
7239 + { MS_RELATIME, MNT_RELATIME, ",relatime", NULL },
7240 + { 0, MNT_NOSUID, ",nosuid", NULL },
7241 + { 0, MNT_NODEV, ",nodev", NULL },
7242 + { 0, MNT_NOEXEC, ",noexec", NULL },
7243 + { 0, 0, NULL, NULL }
7245 - struct proc_fs_info *fs_infop;
7246 + struct proc_fs_info *p;
7247 + unsigned long s_flags = mnt->mnt_sb->s_flags;
7248 + int mnt_flags = mnt->mnt_flags;
7250 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7252 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7254 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7256 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7259 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7260 + mnt == current->fs->rootmnt) {
7261 + seq_puts(m, "/dev/root / ");
7263 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7265 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7268 + if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
7270 + mangle(m, mnt->mnt_sb->s_subtype);
7273 mangle(m, mnt->mnt_sb->s_type->name);
7274 - if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
7276 - mangle(m, mnt->mnt_sb->s_subtype);
7278 - seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
7279 - for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
7280 - if (mnt->mnt_sb->s_flags & fs_infop->flag)
7281 - seq_puts(m, fs_infop->str);
7283 - for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
7284 - if (mnt->mnt_flags & fs_infop->flag)
7285 - seq_puts(m, fs_infop->str);
7287 + for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
7288 + if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
7290 + seq_puts(m, p->set_str);
7293 + seq_puts(m, p->unset_str);
7296 + if (mnt->mnt_flags & MNT_TAGID)
7297 + seq_printf(m, ",tag=%d", mnt->mnt_tag);
7298 if (mnt->mnt_sb->s_op->show_options)
7299 err = mnt->mnt_sb->s_op->show_options(m, mnt);
7300 seq_puts(m, " 0 0\n");
7301 @@ -408,17 +457,27 @@ static int show_vfsstat(struct seq_file
7302 struct vfsmount *mnt = v;
7306 - if (mnt->mnt_devname) {
7307 - seq_puts(m, "device ");
7308 - mangle(m, mnt->mnt_devname);
7310 - seq_puts(m, "no device");
7313 - seq_puts(m, " mounted on ");
7314 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7316 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7318 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7321 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7322 + mnt == current->fs->rootmnt) {
7323 + seq_puts(m, "device /dev/root mounted on / ");
7326 + if (mnt->mnt_devname) {
7327 + seq_puts(m, "device ");
7328 + mangle(m, mnt->mnt_devname);
7330 + seq_puts(m, "no device");
7333 + seq_puts(m, " mounted on ");
7334 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7338 /* file system type */
7339 seq_puts(m, "with fstype ");
7340 @@ -648,7 +707,7 @@ asmlinkage long sys_umount(char __user *
7344 - if (!capable(CAP_SYS_ADMIN))
7345 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7348 retval = do_umount(nd.mnt, flags);
7349 @@ -672,7 +731,7 @@ asmlinkage long sys_oldumount(char __use
7351 static int mount_is_safe(struct nameidata *nd)
7353 - if (capable(CAP_SYS_ADMIN))
7354 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7358 @@ -904,11 +963,13 @@ static int do_change_type(struct nameida
7360 * do loopback mount.
7362 -static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
7363 +static int do_loopback(struct nameidata *nd, char *old_name, tag_t tag,
7364 + unsigned long flags, int mnt_flags)
7366 struct nameidata old_nd;
7367 struct vfsmount *mnt = NULL;
7368 int err = mount_is_safe(nd);
7369 + int recurse = flags & MS_REC;
7372 if (!old_name || !*old_name)
7373 @@ -934,6 +995,12 @@ static int do_loopback(struct nameidata
7377 + mnt->mnt_flags = mnt_flags;
7378 + if (flags & MS_TAGID) {
7379 + mnt->mnt_tag = tag;
7380 + mnt->mnt_flags |= MNT_TAGID;
7383 err = graft_tree(mnt, nd);
7385 LIST_HEAD(umount_list);
7386 @@ -942,6 +1009,7 @@ static int do_loopback(struct nameidata
7387 spin_unlock(&vfsmount_lock);
7388 release_mounts(&umount_list);
7390 + mnt->mnt_flags = mnt_flags;
7393 up_write(&namespace_sem);
7394 @@ -955,12 +1023,12 @@ out:
7395 * on it - tough luck.
7397 static int do_remount(struct nameidata *nd, int flags, int mnt_flags,
7399 + void *data, xid_t xid)
7402 struct super_block *sb = nd->mnt->mnt_sb;
7404 - if (!capable(CAP_SYS_ADMIN))
7405 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7408 if (!check_mnt(nd->mnt))
7409 @@ -994,7 +1062,7 @@ static int do_move_mount(struct nameidat
7410 struct nameidata old_nd, parent_nd;
7413 - if (!capable(CAP_SYS_ADMIN))
7414 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7416 if (!old_name || !*old_name)
7418 @@ -1074,7 +1142,7 @@ static int do_new_mount(struct nameidata
7421 /* we need capabilities... */
7422 - if (!capable(CAP_SYS_ADMIN))
7423 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7426 mnt = do_kern_mount(type, flags, name, data);
7427 @@ -1386,6 +1454,7 @@ long do_mount(char *dev_name, char *dir_
7428 struct nameidata nd;
7434 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7435 @@ -1401,7 +1470,17 @@ long do_mount(char *dev_name, char *dir_
7437 ((char *)data_page)[PAGE_SIZE - 1] = 0;
7439 + retval = dx_parse_tag(data_page, &tag, 1);
7441 + mnt_flags |= retval;
7442 + /* FIXME: bind and re-mounts get the tag flag? */
7443 + if (flags & (MS_BIND|MS_REMOUNT))
7444 + flags |= MS_TAGID;
7447 /* Separate the per-mountpoint flags */
7448 + if (flags & MS_RDONLY)
7449 + mnt_flags |= MNT_RDONLY;
7450 if (flags & MS_NOSUID)
7451 mnt_flags |= MNT_NOSUID;
7452 if (flags & MS_NODEV)
7453 @@ -1415,6 +1494,8 @@ long do_mount(char *dev_name, char *dir_
7454 if (flags & MS_RELATIME)
7455 mnt_flags |= MNT_RELATIME;
7457 + if (!capable(CAP_SYS_ADMIN))
7458 + mnt_flags |= MNT_NODEV;
7459 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
7460 MS_NOATIME | MS_NODIRATIME | MS_RELATIME);
7462 @@ -1429,9 +1510,9 @@ long do_mount(char *dev_name, char *dir_
7464 if (flags & MS_REMOUNT)
7465 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
7468 else if (flags & MS_BIND)
7469 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
7470 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
7471 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7472 retval = do_change_type(&nd, flags);
7473 else if (flags & MS_MOVE)
7474 @@ -1504,6 +1585,7 @@ static struct mnt_namespace *dup_mnt_ns(
7475 q = next_mnt(q, new_ns->root);
7477 up_write(&namespace_sem);
7478 + atomic_inc(&vs_global_mnt_ns);
7482 @@ -1866,5 +1948,6 @@ void __put_mnt_ns(struct mnt_namespace *
7483 spin_unlock(&vfsmount_lock);
7484 up_write(&namespace_sem);
7485 release_mounts(&umount_list);
7486 + atomic_dec(&vs_global_mnt_ns);
7489 diff -Nurp linux-2.6.22.18/fs/nfs/client.c linux-2.6.22.18-vs2.3.0.32/fs/nfs/client.c
7490 --- linux-2.6.22.18/fs/nfs/client.c 2007-07-22 00:00:17.000000000 +0200
7491 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfs/client.c 2008-02-11 12:35:34.000000000 +0100
7492 @@ -521,6 +521,9 @@ static int nfs_init_server_rpcclient(str
7493 if (server->flags & NFS4_MOUNT_INTR)
7494 server->client->cl_intr = 1;
7496 + server->client->cl_tag = 0;
7497 + if (server->flags & NFS_MOUNT_TAGGED)
7498 + server->client->cl_tag = 1;
7502 @@ -678,6 +681,10 @@ static void nfs_server_set_fsinfo(struct
7503 server->acdirmin = server->acdirmax = 0;
7506 + /* FIXME: needs fsinfo
7507 + if (server->flags & NFS_MOUNT_TAGGED)
7508 + sb->s_flags |= MS_TAGGED; */
7510 server->maxfilesize = fsinfo->maxfilesize;
7512 /* We're airborne Set socket buffersize */
7513 diff -Nurp linux-2.6.22.18/fs/nfs/dir.c linux-2.6.22.18-vs2.3.0.32/fs/nfs/dir.c
7514 --- linux-2.6.22.18/fs/nfs/dir.c 2007-07-22 00:00:17.000000000 +0200
7515 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfs/dir.c 2008-02-11 12:35:34.000000000 +0100
7517 #include <linux/namei.h>
7518 #include <linux/mount.h>
7519 #include <linux/sched.h>
7520 +#include <linux/vs_tag.h>
7522 #include "nfs4_fs.h"
7523 #include "delegation.h"
7524 @@ -956,6 +957,7 @@ static struct dentry *nfs_lookup(struct
7528 + dx_propagate_tag(nd, inode);
7530 res = d_materialise_unique(dentry, inode);
7532 @@ -998,7 +1000,8 @@ static int is_atomic_open(struct inode *
7533 if (nd->flags & LOOKUP_DIRECTORY)
7535 /* Are we trying to write to a read only partition? */
7536 - if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7537 + if ((IS_RDONLY(dir) || MNT_IS_RDONLY(nd->mnt)) &&
7538 + (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7542 diff -Nurp linux-2.6.22.18/fs/nfs/inode.c linux-2.6.22.18-vs2.3.0.32/fs/nfs/inode.c
7543 --- linux-2.6.22.18/fs/nfs/inode.c 2007-07-22 00:00:17.000000000 +0200
7544 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfs/inode.c 2008-02-11 12:35:34.000000000 +0100
7546 #include <linux/vfs.h>
7547 #include <linux/inet.h>
7548 #include <linux/nfs_xdr.h>
7549 +#include <linux/vs_tag.h>
7551 #include <asm/system.h>
7552 #include <asm/uaccess.h>
7553 @@ -285,8 +286,10 @@ nfs_fhget(struct super_block *sb, struct
7554 nfsi->change_attr = fattr->change_attr;
7555 inode->i_size = nfs_size_to_loff_t(fattr->size);
7556 inode->i_nlink = fattr->nlink;
7557 - inode->i_uid = fattr->uid;
7558 - inode->i_gid = fattr->gid;
7559 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7560 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7561 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7562 + /* maybe fattr->xid someday */
7563 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7565 * report the blocks in 512byte units
7566 @@ -377,6 +380,8 @@ void nfs_setattr_update_inode(struct ino
7567 inode->i_uid = attr->ia_uid;
7568 if ((attr->ia_valid & ATTR_GID) != 0)
7569 inode->i_gid = attr->ia_gid;
7570 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7571 + inode->i_tag = attr->ia_tag;
7572 spin_lock(&inode->i_lock);
7573 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7574 spin_unlock(&inode->i_lock);
7575 @@ -825,6 +830,9 @@ static int nfs_check_inode_attributes(st
7576 struct nfs_inode *nfsi = NFS_I(inode);
7577 loff_t cur_size, new_isize;
7584 /* Has the inode gone and changed behind our back? */
7585 @@ -852,10 +860,15 @@ static int nfs_check_inode_attributes(st
7586 if (cur_size != new_isize && nfsi->npages == 0)
7587 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7589 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7590 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7591 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7593 /* Have any file permissions changed? */
7594 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
7595 - || inode->i_uid != fattr->uid
7596 - || inode->i_gid != fattr->gid)
7597 + || inode->i_uid != uid
7598 + || inode->i_gid != gid
7599 + || inode->i_tag != tag)
7600 nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7602 /* Has the link count changed? */
7603 @@ -946,6 +959,9 @@ static int nfs_update_inode(struct inode
7604 unsigned int invalid = 0;
7605 unsigned long now = jiffies;
7611 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7612 __FUNCTION__, inode->i_sb->s_id, inode->i_ino,
7613 @@ -1022,15 +1038,21 @@ static int nfs_update_inode(struct inode
7615 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7617 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7618 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7619 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7621 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
7622 - inode->i_uid != fattr->uid ||
7623 - inode->i_gid != fattr->gid)
7624 + inode->i_uid != uid ||
7625 + inode->i_gid != gid ||
7626 + inode->i_tag != tag)
7627 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7629 inode->i_mode = fattr->mode;
7630 inode->i_nlink = fattr->nlink;
7631 - inode->i_uid = fattr->uid;
7632 - inode->i_gid = fattr->gid;
7633 + inode->i_uid = uid;
7634 + inode->i_gid = gid;
7635 + inode->i_tag = tag;
7637 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7639 diff -Nurp linux-2.6.22.18/fs/nfs/nfs3xdr.c linux-2.6.22.18-vs2.3.0.32/fs/nfs/nfs3xdr.c
7640 --- linux-2.6.22.18/fs/nfs/nfs3xdr.c 2007-07-22 00:00:17.000000000 +0200
7641 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfs/nfs3xdr.c 2008-02-11 12:35:34.000000000 +0100
7643 #include <linux/nfs3.h>
7644 #include <linux/nfs_fs.h>
7645 #include <linux/nfsacl.h>
7646 +#include <linux/vs_tag.h>
7647 #include "internal.h"
7649 #define NFSDBG_FACILITY NFSDBG_XDR
7650 @@ -178,7 +179,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7653 static inline __be32 *
7654 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7655 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7657 if (attr->ia_valid & ATTR_MODE) {
7659 @@ -186,15 +187,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7663 - if (attr->ia_valid & ATTR_UID) {
7664 + if (attr->ia_valid & ATTR_UID ||
7665 + (tag && (attr->ia_valid & ATTR_TAG))) {
7667 - *p++ = htonl(attr->ia_uid);
7668 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7672 - if (attr->ia_valid & ATTR_GID) {
7673 + if (attr->ia_valid & ATTR_GID ||
7674 + (tag && (attr->ia_valid & ATTR_TAG))) {
7676 - *p++ = htonl(attr->ia_gid);
7677 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7681 @@ -279,7 +282,8 @@ static int
7682 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7684 p = xdr_encode_fhandle(p, args->fh);
7685 - p = xdr_encode_sattr(p, args->sattr);
7686 + p = xdr_encode_sattr(p, args->sattr,
7687 + req->rq_task->tk_client->cl_tag);
7688 *p++ = htonl(args->guard);
7690 p = xdr_encode_time3(p, &args->guardtime);
7691 @@ -370,7 +374,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7692 *p++ = args->verifier[0];
7693 *p++ = args->verifier[1];
7695 - p = xdr_encode_sattr(p, args->sattr);
7696 + p = xdr_encode_sattr(p, args->sattr,
7697 + req->rq_task->tk_client->cl_tag);
7699 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7701 @@ -384,7 +389,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7703 p = xdr_encode_fhandle(p, args->fh);
7704 p = xdr_encode_array(p, args->name, args->len);
7705 - p = xdr_encode_sattr(p, args->sattr);
7706 + p = xdr_encode_sattr(p, args->sattr,
7707 + req->rq_task->tk_client->cl_tag);
7708 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7711 @@ -397,7 +403,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7713 p = xdr_encode_fhandle(p, args->fromfh);
7714 p = xdr_encode_array(p, args->fromname, args->fromlen);
7715 - p = xdr_encode_sattr(p, args->sattr);
7716 + p = xdr_encode_sattr(p, args->sattr,
7717 + req->rq_task->tk_client->cl_tag);
7718 *p++ = htonl(args->pathlen);
7719 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7721 @@ -415,7 +422,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7722 p = xdr_encode_fhandle(p, args->fh);
7723 p = xdr_encode_array(p, args->name, args->len);
7724 *p++ = htonl(args->type);
7725 - p = xdr_encode_sattr(p, args->sattr);
7726 + p = xdr_encode_sattr(p, args->sattr,
7727 + req->rq_task->tk_client->cl_tag);
7728 if (args->type == NF3CHR || args->type == NF3BLK) {
7729 *p++ = htonl(MAJOR(args->rdev));
7730 *p++ = htonl(MINOR(args->rdev));
7731 diff -Nurp linux-2.6.22.18/fs/nfs/nfsroot.c linux-2.6.22.18-vs2.3.0.32/fs/nfs/nfsroot.c
7732 --- linux-2.6.22.18/fs/nfs/nfsroot.c 2007-07-22 00:00:17.000000000 +0200
7733 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfs/nfsroot.c 2008-02-11 12:35:34.000000000 +0100
7734 @@ -118,12 +118,12 @@ static int mount_port __initdata = 0; /
7736 /* Options that take integer arguments */
7737 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7738 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7739 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7740 /* Options that take no arguments */
7741 Opt_soft, Opt_hard, Opt_intr,
7742 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
7743 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7744 - Opt_acl, Opt_noacl,
7745 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7749 @@ -160,6 +160,9 @@ static match_table_t __initdata tokens =
7752 {Opt_noacl, "noacl"},
7754 + {Opt_notag, "notag"},
7755 + {Opt_tagid, "tagid=%u"},
7759 @@ -274,6 +277,20 @@ static int __init root_nfs_parse(char *n
7761 nfs_data.flags |= NFS_MOUNT_NOACL;
7763 +#ifndef CONFIG_TAGGING_NONE
7765 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7768 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7771 +#ifdef CONFIG_PROPAGATE
7774 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7778 printk(KERN_WARNING "Root-NFS: unknown "
7780 diff -Nurp linux-2.6.22.18/fs/nfs/super.c linux-2.6.22.18-vs2.3.0.32/fs/nfs/super.c
7781 --- linux-2.6.22.18/fs/nfs/super.c 2007-09-29 14:11:49.000000000 +0200
7782 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfs/super.c 2008-02-11 12:35:34.000000000 +0100
7784 #include <linux/inet.h>
7785 #include <linux/nfs_xdr.h>
7786 #include <linux/magic.h>
7787 +#include <linux/vs_tag.h>
7789 #include <asm/system.h>
7790 #include <asm/uaccess.h>
7791 @@ -291,6 +292,7 @@ static void nfs_show_mount_options(struc
7792 { NFS_MOUNT_NONLM, ",nolock", "" },
7793 { NFS_MOUNT_NOACL, ",noacl", "" },
7794 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7795 + { NFS_MOUNT_TAGGED, ",tag", "" },
7798 const struct proc_nfs_info *nfs_infop;
7799 diff -Nurp linux-2.6.22.18/fs/nfsd/auth.c linux-2.6.22.18-vs2.3.0.32/fs/nfsd/auth.c
7800 --- linux-2.6.22.18/fs/nfsd/auth.c 2006-06-18 03:49:35.000000000 +0200
7801 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfsd/auth.c 2008-02-11 12:35:34.000000000 +0100
7803 #include <linux/sunrpc/svc.h>
7804 #include <linux/sunrpc/svcauth.h>
7805 #include <linux/nfsd/nfsd.h>
7806 +#include <linux/vs_tag.h>
7808 #define CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
7810 @@ -41,19 +42,22 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7811 get_group_info(cred.cr_group_info);
7813 if (cred.cr_uid != (uid_t) -1)
7814 - current->fsuid = cred.cr_uid;
7815 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7817 current->fsuid = exp->ex_anon_uid;
7818 if (cred.cr_gid != (gid_t) -1)
7819 - current->fsgid = cred.cr_gid;
7820 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7822 current->fsgid = exp->ex_anon_gid;
7824 + /* this desperately needs a tag :) */
7825 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7827 if (!cred.cr_group_info)
7829 ret = set_current_groups(cred.cr_group_info);
7830 put_group_info(cred.cr_group_info);
7831 - if ((cred.cr_uid)) {
7832 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
7833 cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
7835 cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
7836 diff -Nurp linux-2.6.22.18/fs/nfsd/nfs3xdr.c linux-2.6.22.18-vs2.3.0.32/fs/nfsd/nfs3xdr.c
7837 --- linux-2.6.22.18/fs/nfsd/nfs3xdr.c 2007-07-22 00:00:17.000000000 +0200
7838 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfsd/nfs3xdr.c 2008-02-11 12:35:34.000000000 +0100
7840 #include <linux/sunrpc/svc.h>
7841 #include <linux/nfsd/nfsd.h>
7842 #include <linux/nfsd/xdr3.h>
7843 +#include <linux/vs_tag.h>
7845 #define NFSDDBG_FACILITY NFSDDBG_XDR
7847 @@ -107,6 +108,8 @@ static __be32 *
7848 decode_sattr3(__be32 *p, struct iattr *iap)
7856 @@ -116,12 +119,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7859 iap->ia_valid |= ATTR_UID;
7860 - iap->ia_uid = ntohl(*p++);
7861 + uid = ntohl(*p++);
7864 iap->ia_valid |= ATTR_GID;
7865 - iap->ia_gid = ntohl(*p++);
7866 + gid = ntohl(*p++);
7868 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7869 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7870 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7874 @@ -180,8 +186,10 @@ encode_fattr3(struct svc_rqst *rqstp, __
7875 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7876 *p++ = htonl((u32) stat->mode);
7877 *p++ = htonl((u32) stat->nlink);
7878 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7879 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7880 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7881 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7882 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7883 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7884 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7885 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7887 diff -Nurp linux-2.6.22.18/fs/nfsd/nfs4recover.c linux-2.6.22.18-vs2.3.0.32/fs/nfsd/nfs4recover.c
7888 --- linux-2.6.22.18/fs/nfsd/nfs4recover.c 2007-07-22 00:00:17.000000000 +0200
7889 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfsd/nfs4recover.c 2008-02-11 12:35:34.000000000 +0100
7890 @@ -156,7 +156,7 @@ nfsd4_create_clid_dir(struct nfs4_client
7891 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n");
7894 - status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU);
7895 + status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU, NULL);
7899 @@ -260,7 +260,7 @@ nfsd4_remove_clid_file(struct dentry *di
7902 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7903 - status = vfs_unlink(dir->d_inode, dentry);
7904 + status = vfs_unlink(dir->d_inode, dentry, NULL);
7905 mutex_unlock(&dir->d_inode->i_mutex);
7908 @@ -275,7 +275,7 @@ nfsd4_clear_clid_dir(struct dentry *dir,
7909 * a kernel from the future.... */
7910 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
7911 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7912 - status = vfs_rmdir(dir->d_inode, dentry);
7913 + status = vfs_rmdir(dir->d_inode, dentry, NULL);
7914 mutex_unlock(&dir->d_inode->i_mutex);
7917 diff -Nurp linux-2.6.22.18/fs/nfsd/nfs4xdr.c linux-2.6.22.18-vs2.3.0.32/fs/nfsd/nfs4xdr.c
7918 --- linux-2.6.22.18/fs/nfsd/nfs4xdr.c 2007-07-22 00:00:17.000000000 +0200
7919 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfsd/nfs4xdr.c 2008-02-11 12:35:34.000000000 +0100
7921 #include <linux/nfsd_idmap.h>
7922 #include <linux/nfs4.h>
7923 #include <linux/nfs4_acl.h>
7924 +#include <linux/vs_tag.h>
7926 #define NFSDDBG_FACILITY NFSDDBG_XDR
7928 @@ -1727,14 +1728,18 @@ out_acl:
7929 WRITE32(stat.nlink);
7931 if (bmval1 & FATTR4_WORD1_OWNER) {
7932 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7933 + status = nfsd4_encode_user(rqstp,
7934 + TAGINO_UID(DX_TAG(dentry->d_inode),
7935 + stat.uid, stat.tag), &p, &buflen);
7936 if (status == nfserr_resource)
7941 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7942 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7943 + status = nfsd4_encode_group(rqstp,
7944 + TAGINO_GID(DX_TAG(dentry->d_inode),
7945 + stat.gid, stat.tag), &p, &buflen);
7946 if (status == nfserr_resource)
7949 diff -Nurp linux-2.6.22.18/fs/nfsd/nfsxdr.c linux-2.6.22.18-vs2.3.0.32/fs/nfsd/nfsxdr.c
7950 --- linux-2.6.22.18/fs/nfsd/nfsxdr.c 2007-07-22 00:00:17.000000000 +0200
7951 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfsd/nfsxdr.c 2008-02-11 12:35:34.000000000 +0100
7953 #include <linux/nfsd/nfsd.h>
7954 #include <linux/nfsd/xdr.h>
7955 #include <linux/mm.h>
7956 +#include <linux/vs_tag.h>
7958 #define NFSDDBG_FACILITY NFSDDBG_XDR
7960 @@ -97,6 +98,8 @@ static __be32 *
7961 decode_sattr(__be32 *p, struct iattr *iap)
7969 @@ -110,12 +113,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7971 if ((tmp = ntohl(*p++)) != (u32)-1) {
7972 iap->ia_valid |= ATTR_UID;
7973 - iap->ia_uid = tmp;
7976 if ((tmp = ntohl(*p++)) != (u32)-1) {
7977 iap->ia_valid |= ATTR_GID;
7978 - iap->ia_gid = tmp;
7981 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7982 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7983 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7984 if ((tmp = ntohl(*p++)) != (u32)-1) {
7985 iap->ia_valid |= ATTR_SIZE;
7987 @@ -160,8 +166,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7988 *p++ = htonl(nfs_ftypes[type >> 12]);
7989 *p++ = htonl((u32) stat->mode);
7990 *p++ = htonl((u32) stat->nlink);
7991 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7992 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7993 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7994 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7995 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7996 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7998 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7999 *p++ = htonl(NFS_MAXPATHLEN);
8000 diff -Nurp linux-2.6.22.18/fs/nfsd/vfs.c linux-2.6.22.18-vs2.3.0.32/fs/nfsd/vfs.c
8001 --- linux-2.6.22.18/fs/nfsd/vfs.c 2007-08-12 03:54:36.000000000 +0200
8002 +++ linux-2.6.22.18-vs2.3.0.32/fs/nfsd/vfs.c 2008-02-11 12:35:34.000000000 +0100
8003 @@ -1186,13 +1186,13 @@ nfsd_create(struct svc_rqst *rqstp, stru
8004 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
8007 - host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
8008 + host_err = vfs_mkdir(dirp, dchild, iap->ia_mode, NULL);
8014 - host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
8015 + host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev, NULL);
8018 printk("nfsd: bad file type %o in nfsd_create\n", type);
8019 @@ -1466,11 +1466,13 @@ nfsd_symlink(struct svc_rqst *rqstp, str
8021 strncpy(path_alloced, path, plen);
8022 path_alloced[plen] = 0;
8023 - host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
8024 + host_err = vfs_symlink(dentry->d_inode, dnew,
8025 + path_alloced, mode, NULL);
8026 kfree(path_alloced);
8029 - host_err = vfs_symlink(dentry->d_inode, dnew, path, mode);
8030 + host_err = vfs_symlink(dentry->d_inode, dnew,
8031 + path, mode, NULL);
8034 if (EX_ISSYNC(fhp->fh_export))
8035 @@ -1529,7 +1531,7 @@ nfsd_link(struct svc_rqst *rqstp, struct
8036 dold = tfhp->fh_dentry;
8037 dest = dold->d_inode;
8039 - host_err = vfs_link(dold, dirp, dnew);
8040 + host_err = vfs_link(dold, dirp, dnew, NULL);
8042 if (EX_ISSYNC(ffhp->fh_export)) {
8043 err = nfserrno(nfsd_sync_dir(ddir));
8044 @@ -1694,9 +1696,9 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
8048 - host_err = vfs_unlink(dirp, rdentry);
8049 + host_err = vfs_unlink(dirp, rdentry, NULL);
8050 } else { /* It's RMDIR */
8051 - host_err = vfs_rmdir(dirp, rdentry);
8052 + host_err = vfs_rmdir(dirp, rdentry, NULL);
8056 @@ -1807,7 +1809,8 @@ nfsd_permission(struct svc_export *exp,
8058 if (!(acc & MAY_LOCAL_ACCESS))
8059 if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
8060 - if (EX_RDONLY(exp) || IS_RDONLY(inode))
8061 + if (EX_RDONLY(exp) || IS_RDONLY(inode)
8062 + || MNT_IS_RDONLY(exp->ex_mnt))
8064 if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
8066 diff -Nurp linux-2.6.22.18/fs/ocfs2/dlm/dlmfs.c linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/dlm/dlmfs.c
8067 --- linux-2.6.22.18/fs/ocfs2/dlm/dlmfs.c 2007-07-22 00:00:17.000000000 +0200
8068 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/dlm/dlmfs.c 2008-02-11 12:35:34.000000000 +0100
8070 #include <linux/init.h>
8071 #include <linux/string.h>
8072 #include <linux/backing-dev.h>
8073 +#include <linux/vs_tag.h>
8075 #include <asm/uaccess.h>
8077 @@ -331,6 +332,7 @@ static struct inode *dlmfs_get_root_inod
8078 inode->i_mode = mode;
8079 inode->i_uid = current->fsuid;
8080 inode->i_gid = current->fsgid;
8081 + inode->i_tag = dx_current_fstag(sb);
8082 inode->i_blocks = 0;
8083 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
8084 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
8085 @@ -357,6 +359,7 @@ static struct inode *dlmfs_get_inode(str
8086 inode->i_mode = mode;
8087 inode->i_uid = current->fsuid;
8088 inode->i_gid = current->fsgid;
8089 + inode->i_tag = dx_current_fstag(sb);
8090 inode->i_blocks = 0;
8091 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
8092 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
8093 diff -Nurp linux-2.6.22.18/fs/ocfs2/dlmglue.c linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/dlmglue.c
8094 --- linux-2.6.22.18/fs/ocfs2/dlmglue.c 2007-07-22 00:00:18.000000000 +0200
8095 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/dlmglue.c 2008-02-11 12:35:34.000000000 +0100
8096 @@ -1475,6 +1475,7 @@ static void __ocfs2_stuff_meta_lvb(struc
8097 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
8098 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
8099 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
8100 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
8101 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
8102 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
8103 lvb->lvb_iatime_packed =
8104 @@ -1527,6 +1528,7 @@ static void ocfs2_refresh_inode_from_lvb
8106 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
8107 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
8108 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
8109 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
8110 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
8111 ocfs2_unpack_timespec(&inode->i_atime,
8112 diff -Nurp linux-2.6.22.18/fs/ocfs2/dlmglue.h linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/dlmglue.h
8113 --- linux-2.6.22.18/fs/ocfs2/dlmglue.h 2007-07-22 00:00:18.000000000 +0200
8114 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/dlmglue.h 2008-02-11 12:35:34.000000000 +0100
8116 struct ocfs2_meta_lvb {
8119 - __be16 lvb_reserved1;
8121 __be32 lvb_iclusters;
8124 diff -Nurp linux-2.6.22.18/fs/ocfs2/file.c linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/file.c
8125 --- linux-2.6.22.18/fs/ocfs2/file.c 2007-09-05 07:07:59.000000000 +0200
8126 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/file.c 2008-02-11 12:35:34.000000000 +0100
8127 @@ -943,13 +943,15 @@ int ocfs2_setattr(struct dentry *dentry,
8128 mlog(0, "uid change: %d\n", attr->ia_uid);
8129 if (attr->ia_valid & ATTR_GID)
8130 mlog(0, "gid change: %d\n", attr->ia_gid);
8131 + if (attr->ia_valid & ATTR_TAG)
8132 + mlog(0, "tag change: %d\n", attr->ia_tag);
8133 if (attr->ia_valid & ATTR_SIZE)
8134 mlog(0, "size change...\n");
8135 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
8136 mlog(0, "time change...\n");
8138 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
8139 - | ATTR_GID | ATTR_UID | ATTR_MODE)
8140 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
8141 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
8142 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
8144 @@ -1805,6 +1807,7 @@ bail:
8145 const struct inode_operations ocfs2_file_iops = {
8146 .setattr = ocfs2_setattr,
8147 .getattr = ocfs2_getattr,
8148 + .sync_flags = ocfs2_sync_flags,
8149 .permission = ocfs2_permission,
8152 diff -Nurp linux-2.6.22.18/fs/ocfs2/inode.c linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/inode.c
8153 --- linux-2.6.22.18/fs/ocfs2/inode.c 2007-07-22 00:00:18.000000000 +0200
8154 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/inode.c 2008-02-11 12:35:34.000000000 +0100
8156 #include <linux/slab.h>
8157 #include <linux/highmem.h>
8158 #include <linux/pagemap.h>
8159 +#include <linux/vs_tag.h>
8161 #include <asm/byteorder.h>
8165 #include "heartbeat.h"
8168 #include "journal.h"
8170 #include "suballoc.h"
8171 @@ -77,6 +79,10 @@ void ocfs2_set_inode_flags(struct inode
8173 if (flags & OCFS2_IMMUTABLE_FL)
8174 inode->i_flags |= S_IMMUTABLE;
8175 + if (flags & OCFS2_IUNLINK_FL)
8176 + inode->i_flags |= S_IUNLINK;
8177 + if (flags & OCFS2_BARRIER_FL)
8178 + inode->i_flags |= S_BARRIER;
8180 if (flags & OCFS2_SYNC_FL)
8181 inode->i_flags |= S_SYNC;
8182 @@ -107,6 +113,27 @@ void ocfs2_get_inode_flags(struct ocfs2_
8183 oi->ip_attr |= OCFS2_DIRSYNC_FL;
8186 +int ocfs2_sync_flags(struct inode *inode)
8188 + unsigned int oldflags, newflags;
8190 + oldflags = OCFS2_I(inode)->ip_flags;
8191 + newflags = oldflags & ~(OCFS2_IMMUTABLE_FL |
8192 + OCFS2_IUNLINK_FL | OCFS2_BARRIER_FL);
8194 + if (IS_IMMUTABLE(inode))
8195 + newflags |= OCFS2_IMMUTABLE_FL;
8196 + if (IS_IUNLINK(inode))
8197 + newflags |= OCFS2_IUNLINK_FL;
8198 + if (IS_BARRIER(inode))
8199 + newflags |= OCFS2_BARRIER_FL;
8201 + if (oldflags ^ newflags)
8202 + return ocfs2_set_inode_attr(inode,
8203 + newflags, OCFS2_FL_MASK);
8207 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags)
8209 struct inode *inode = NULL;
8210 @@ -212,6 +239,8 @@ int ocfs2_populate_inode(struct inode *i
8211 struct super_block *sb;
8212 struct ocfs2_super *osb;
8213 int status = -EINVAL;
8217 mlog_entry("(0x%p, size:%llu)\n", inode,
8218 (unsigned long long)le64_to_cpu(fe->i_size));
8219 @@ -246,8 +275,12 @@ int ocfs2_populate_inode(struct inode *i
8220 inode->i_generation = le32_to_cpu(fe->i_generation);
8221 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
8222 inode->i_mode = le16_to_cpu(fe->i_mode);
8223 - inode->i_uid = le32_to_cpu(fe->i_uid);
8224 - inode->i_gid = le32_to_cpu(fe->i_gid);
8225 + uid = le32_to_cpu(fe->i_uid);
8226 + gid = le32_to_cpu(fe->i_gid);
8227 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8228 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8229 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8230 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8232 /* Fast symlinks will have i_size but no allocated clusters. */
8233 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
8234 @@ -1224,8 +1257,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
8236 fe->i_size = cpu_to_le64(i_size_read(inode));
8237 fe->i_links_count = cpu_to_le16(inode->i_nlink);
8238 - fe->i_uid = cpu_to_le32(inode->i_uid);
8239 - fe->i_gid = cpu_to_le32(inode->i_gid);
8240 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
8241 + inode->i_uid, inode->i_tag));
8242 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
8243 + inode->i_gid, inode->i_tag));
8244 + /* i_tag = = cpu_to_le16(inode->i_tag); */
8245 fe->i_mode = cpu_to_le16(inode->i_mode);
8246 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
8247 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
8248 @@ -1253,15 +1289,24 @@ leave:
8249 void ocfs2_refresh_inode(struct inode *inode,
8250 struct ocfs2_dinode *fe)
8255 spin_lock(&OCFS2_I(inode)->ip_lock);
8257 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
8258 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
8259 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
8260 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
8261 ocfs2_set_inode_flags(inode);
8262 i_size_write(inode, le64_to_cpu(fe->i_size));
8263 inode->i_nlink = le16_to_cpu(fe->i_links_count);
8264 - inode->i_uid = le32_to_cpu(fe->i_uid);
8265 - inode->i_gid = le32_to_cpu(fe->i_gid);
8266 + uid = le32_to_cpu(fe->i_uid);
8267 + gid = le32_to_cpu(fe->i_gid);
8268 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8269 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8270 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8271 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8272 inode->i_mode = le16_to_cpu(fe->i_mode);
8273 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
8274 inode->i_blocks = 0;
8275 diff -Nurp linux-2.6.22.18/fs/ocfs2/inode.h linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/inode.h
8276 --- linux-2.6.22.18/fs/ocfs2/inode.h 2007-07-22 00:00:18.000000000 +0200
8277 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/inode.h 2008-02-11 12:35:34.000000000 +0100
8278 @@ -142,6 +142,7 @@ int ocfs2_aio_write(struct file *file, s
8280 void ocfs2_set_inode_flags(struct inode *inode);
8281 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
8282 +int ocfs2_sync_flags(struct inode *inode);
8284 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
8286 diff -Nurp linux-2.6.22.18/fs/ocfs2/ioctl.c linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/ioctl.c
8287 --- linux-2.6.22.18/fs/ocfs2/ioctl.c 2007-07-22 00:00:18.000000000 +0200
8288 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/ioctl.c 2008-02-11 12:35:34.000000000 +0100
8289 @@ -39,7 +39,8 @@ static int ocfs2_get_inode_attr(struct i
8293 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8294 +/* Called with inode->i_mutex locked */
8295 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8298 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
8299 @@ -49,8 +50,6 @@ static int ocfs2_set_inode_attr(struct i
8303 - mutex_lock(&inode->i_mutex);
8305 status = ocfs2_meta_lock(inode, &bh, 1);
8308 @@ -101,8 +100,6 @@ static int ocfs2_set_inode_attr(struct i
8310 ocfs2_meta_unlock(inode, 1);
8312 - mutex_unlock(&inode->i_mutex);
8317 @@ -110,6 +107,16 @@ bail:
8321 +static inline int ocfs2_set_inode_attr_lock(struct inode *inode,
8322 + unsigned flags, unsigned mask)
8325 + mutex_lock(&inode->i_mutex);
8326 + ret = ocfs2_set_inode_attr(inode, flags, mask);
8327 + mutex_unlock(&inode->i_mutex);
8331 int ocfs2_ioctl(struct inode * inode, struct file * filp,
8332 unsigned int cmd, unsigned long arg)
8334 @@ -128,7 +135,7 @@ int ocfs2_ioctl(struct inode * inode, st
8335 if (get_user(flags, (int __user *) arg))
8338 - return ocfs2_set_inode_attr(inode, flags,
8339 + return ocfs2_set_inode_attr_lock(inode, flags,
8340 OCFS2_FL_MODIFIABLE);
8343 diff -Nurp linux-2.6.22.18/fs/ocfs2/ioctl.h linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/ioctl.h
8344 --- linux-2.6.22.18/fs/ocfs2/ioctl.h 2007-07-22 00:00:18.000000000 +0200
8345 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/ioctl.h 2008-02-11 12:35:34.000000000 +0100
8347 #ifndef OCFS2_IOCTL_H
8348 #define OCFS2_IOCTL_H
8350 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8353 int ocfs2_ioctl(struct inode * inode, struct file * filp,
8354 unsigned int cmd, unsigned long arg);
8355 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
8356 diff -Nurp linux-2.6.22.18/fs/ocfs2/namei.c linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/namei.c
8357 --- linux-2.6.22.18/fs/ocfs2/namei.c 2007-07-22 00:00:18.000000000 +0200
8358 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/namei.c 2008-02-11 12:35:34.000000000 +0100
8360 #include <linux/types.h>
8361 #include <linux/slab.h>
8362 #include <linux/highmem.h>
8363 +#include <linux/vs_tag.h>
8365 #define MLOG_MASK_PREFIX ML_NAMEI
8366 #include <cluster/masklog.h>
8367 @@ -483,6 +484,9 @@ static int ocfs2_mknod_locked(struct ocf
8370 struct inode *inode = NULL;
8375 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
8376 (unsigned long)dev, dentry->d_name.len,
8377 @@ -542,13 +546,19 @@ static int ocfs2_mknod_locked(struct ocf
8378 fe->i_blkno = cpu_to_le64(fe_blkno);
8379 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
8380 fe->i_suballoc_slot = cpu_to_le16(osb->slot_num);
8381 - fe->i_uid = cpu_to_le32(current->fsuid);
8383 + tag = dx_current_fstag(osb->sb);
8384 + uid = current->fsuid;
8385 if (dir->i_mode & S_ISGID) {
8386 - fe->i_gid = cpu_to_le32(dir->i_gid);
8391 - fe->i_gid = cpu_to_le32(current->fsgid);
8392 + gid = current->fsgid;
8394 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
8395 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
8396 + inode->i_tag = tag;
8397 fe->i_mode = cpu_to_le16(mode);
8398 if (S_ISCHR(mode) || S_ISBLK(mode))
8399 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
8400 @@ -2316,5 +2326,6 @@ const struct inode_operations ocfs2_dir_
8401 .rename = ocfs2_rename,
8402 .setattr = ocfs2_setattr,
8403 .getattr = ocfs2_getattr,
8404 + .sync_flags = ocfs2_sync_flags,
8405 .permission = ocfs2_permission,
8407 diff -Nurp linux-2.6.22.18/fs/ocfs2/ocfs2_fs.h linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/ocfs2_fs.h
8408 --- linux-2.6.22.18/fs/ocfs2/ocfs2_fs.h 2007-07-22 00:00:18.000000000 +0200
8409 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/ocfs2_fs.h 2008-02-11 12:35:34.000000000 +0100
8410 @@ -152,8 +152,12 @@
8411 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
8412 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
8414 +#define OCFS2_BARRIER_FL (0x04000000) /* Barrier for chroot() */
8415 +#define OCFS2_IUNLINK_FL (0x08000000) /* Immutable unlink */
8417 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
8418 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
8419 +#define OCFS2_FL_MASK (0x0F0100FF)
8422 * Extent record flags (e_node.leaf.flags)
8423 diff -Nurp linux-2.6.22.18/fs/ocfs2/ocfs2.h linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/ocfs2.h
8424 --- linux-2.6.22.18/fs/ocfs2/ocfs2.h 2007-07-22 00:00:18.000000000 +0200
8425 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/ocfs2.h 2008-02-11 12:35:34.000000000 +0100
8426 @@ -170,6 +170,7 @@ enum ocfs2_mount_options
8427 OCFS2_MOUNT_NOINTR = 1 << 2, /* Don't catch signals */
8428 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
8429 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
8430 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
8433 #define OCFS2_OSB_SOFT_RO 0x0001
8434 diff -Nurp linux-2.6.22.18/fs/ocfs2/super.c linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/super.c
8435 --- linux-2.6.22.18/fs/ocfs2/super.c 2007-07-22 00:00:18.000000000 +0200
8436 +++ linux-2.6.22.18-vs2.3.0.32/fs/ocfs2/super.c 2008-02-11 12:35:34.000000000 +0100
8437 @@ -140,6 +140,7 @@ enum {
8441 + Opt_tag, Opt_notag, Opt_tagid,
8445 @@ -154,6 +155,9 @@ static match_table_t tokens = {
8446 {Opt_data_ordered, "data=ordered"},
8447 {Opt_data_writeback, "data=writeback"},
8448 {Opt_atime_quantum, "atime_quantum=%u"},
8450 + {Opt_notag, "notag"},
8451 + {Opt_tagid, "tagid=%u"},
8455 @@ -362,6 +366,13 @@ static int ocfs2_remount(struct super_bl
8459 + if ((parsed_options & OCFS2_MOUNT_TAGGED) &&
8460 + !(sb->s_flags & MS_TAGGED)) {
8462 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
8466 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
8467 (parsed_options & OCFS2_MOUNT_HB_LOCAL)) {
8469 @@ -654,6 +665,9 @@ static int ocfs2_fill_super(struct super
8471 ocfs2_complete_mount_recovery(osb);
8473 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
8474 + sb->s_flags |= MS_TAGGED;
8476 if (ocfs2_mount_local(osb))
8477 snprintf(nodestr, sizeof(nodestr), "local");
8479 @@ -782,6 +796,20 @@ static int ocfs2_parse_options(struct su
8481 osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
8483 +#ifndef CONFIG_TAGGING_NONE
8485 + *mount_opt |= OCFS2_MOUNT_TAGGED;
8488 + *mount_opt &= ~OCFS2_MOUNT_TAGGED;
8491 +#ifdef CONFIG_PROPAGATE
8494 + *mount_opt |= OCFS2_MOUNT_TAGGED;
8499 "Unrecognized mount option \"%s\" "
8500 diff -Nurp linux-2.6.22.18/fs/open.c linux-2.6.22.18-vs2.3.0.32/fs/open.c
8501 --- linux-2.6.22.18/fs/open.c 2007-07-22 00:00:18.000000000 +0200
8502 +++ linux-2.6.22.18-vs2.3.0.32/fs/open.c 2008-02-11 12:35:34.000000000 +0100
8504 #include <linux/syscalls.h>
8505 #include <linux/rcupdate.h>
8506 #include <linux/audit.h>
8507 +#include <linux/vs_base.h>
8508 +#include <linux/vs_limit.h>
8509 +#include <linux/vs_dlimit.h>
8510 +#include <linux/vs_tag.h>
8511 +#include <linux/vs_cowbl.h>
8513 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
8515 int retval = -ENODEV;
8518 + struct super_block *sb = dentry->d_sb;
8521 - if (dentry->d_sb->s_op->statfs) {
8522 + if (sb->s_op->statfs) {
8523 memset(buf, 0, sizeof(*buf));
8524 retval = security_sb_statfs(dentry);
8527 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
8528 + retval = sb->s_op->statfs(dentry, buf);
8529 if (retval == 0 && buf->f_frsize == 0)
8530 buf->f_frsize = buf->f_bsize;
8532 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
8533 + vx_vsi_statfs(sb, buf);
8537 @@ -248,7 +257,7 @@ static long do_sys_truncate(const char _
8541 - if (IS_RDONLY(inode))
8542 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
8546 @@ -397,7 +406,7 @@ asmlinkage long sys_faccessat(int dfd, c
8547 special_file(nd.dentry->d_inode->i_mode))
8548 goto out_path_release;
8550 - if(IS_RDONLY(nd.dentry->d_inode))
8551 + if(IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
8555 @@ -511,7 +520,7 @@ asmlinkage long sys_fchmod(unsigned int
8556 audit_inode(NULL, inode);
8559 - if (IS_RDONLY(inode))
8560 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
8563 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8564 @@ -541,11 +550,11 @@ asmlinkage long sys_fchmodat(int dfd, co
8565 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
8568 - inode = nd.dentry->d_inode;
8571 - if (IS_RDONLY(inode))
8572 + error = cow_check_and_break(&nd);
8575 + inode = nd.dentry->d_inode;
8578 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8579 @@ -570,7 +579,8 @@ asmlinkage long sys_chmod(const char __u
8580 return sys_fchmodat(AT_FDCWD, filename, mode);
8583 -static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
8584 +static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
8585 + uid_t user, gid_t group)
8587 struct inode * inode;
8589 @@ -582,7 +592,7 @@ static int chown_common(struct dentry *
8593 - if (IS_RDONLY(inode))
8594 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
8597 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8598 @@ -590,11 +600,11 @@ static int chown_common(struct dentry *
8599 newattrs.ia_valid = ATTR_CTIME;
8600 if (user != (uid_t) -1) {
8601 newattrs.ia_valid |= ATTR_UID;
8602 - newattrs.ia_uid = user;
8603 + newattrs.ia_uid = dx_map_uid(user);
8605 if (group != (gid_t) -1) {
8606 newattrs.ia_valid |= ATTR_GID;
8607 - newattrs.ia_gid = group;
8608 + newattrs.ia_gid = dx_map_gid(group);
8610 if (!S_ISDIR(inode->i_mode))
8611 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
8612 @@ -613,7 +623,11 @@ asmlinkage long sys_chown(const char __u
8613 error = user_path_walk(filename, &nd);
8616 - error = chown_common(nd.dentry, user, group);
8617 +#ifdef CONFIG_VSERVER_COWBL
8618 + error = cow_check_and_break(&nd);
8621 + error = chown_common(nd.dentry, nd.mnt, user, group);
8625 @@ -633,7 +647,11 @@ asmlinkage long sys_fchownat(int dfd, co
8626 error = __user_walk_fd(dfd, filename, follow, &nd);
8629 - error = chown_common(nd.dentry, user, group);
8630 +#ifdef CONFIG_VSERVER_COWBL
8631 + error = cow_check_and_break(&nd);
8634 + error = chown_common(nd.dentry, nd.mnt, user, group);
8638 @@ -647,7 +665,11 @@ asmlinkage long sys_lchown(const char __
8639 error = user_path_walk_link(filename, &nd);
8642 - error = chown_common(nd.dentry, user, group);
8643 +#ifdef CONFIG_VSERVER_COWBL
8644 + error = cow_check_and_break(&nd);
8647 + error = chown_common(nd.dentry, nd.mnt, user, group);
8651 @@ -666,7 +688,7 @@ asmlinkage long sys_fchown(unsigned int
8653 dentry = file->f_path.dentry;
8654 audit_inode(NULL, dentry->d_inode);
8655 - error = chown_common(dentry, user, group);
8656 + error = chown_common(dentry, file->f_vfsmnt, user, group);
8660 @@ -893,6 +915,7 @@ repeat:
8661 FD_SET(fd, fdt->open_fds);
8662 FD_CLR(fd, fdt->close_on_exec);
8663 files->next_fd = fd + 1;
8664 + vx_openfd_inc(fd);
8667 if (fdt->fd[fd] != NULL) {
8668 @@ -915,6 +938,7 @@ static void __put_unused_fd(struct files
8669 __FD_CLR(fd, fdt->open_fds);
8670 if (fd < files->next_fd)
8671 files->next_fd = fd;
8672 + vx_openfd_dec(fd);
8675 void fastcall put_unused_fd(unsigned int fd)
8676 diff -Nurp linux-2.6.22.18/fs/proc/array.c linux-2.6.22.18-vs2.3.0.32/fs/proc/array.c
8677 --- linux-2.6.22.18/fs/proc/array.c 2007-07-22 00:00:18.000000000 +0200
8678 +++ linux-2.6.22.18-vs2.3.0.32/fs/proc/array.c 2008-02-11 12:35:35.000000000 +0100
8680 #include <linux/cpuset.h>
8681 #include <linux/rcupdate.h>
8682 #include <linux/delayacct.h>
8683 +#include <linux/vs_context.h>
8684 +#include <linux/vs_network.h>
8686 #include <asm/uaccess.h>
8687 #include <asm/pgtable.h>
8688 @@ -134,8 +136,9 @@ static const char *task_state_array[] =
8689 "D (disk sleep)", /* 2 */
8690 "T (stopped)", /* 4 */
8691 "T (tracing stop)", /* 8 */
8692 - "Z (zombie)", /* 16 */
8693 - "X (dead)" /* 32 */
8694 + "H (on hold)", /* 16 */
8695 + "Z (zombie)", /* 32 */
8696 + "X (dead)", /* 64 */
8699 static inline const char * get_task_state(struct task_struct *tsk)
8700 @@ -144,7 +147,8 @@ static inline const char * get_task_stat
8701 TASK_INTERRUPTIBLE |
8702 TASK_UNINTERRUPTIBLE |
8707 (tsk->exit_state & (EXIT_ZOMBIE |
8709 const char **p = &task_state_array[0];
8710 @@ -161,8 +165,16 @@ static inline char * task_state(struct t
8711 struct group_info *group_info;
8713 struct fdtable *fdt = NULL;
8714 + pid_t pid, ptgid, tppid, tgid;
8717 + tgid = vx_map_tgid(p->tgid);
8718 + pid = vx_map_pid(p->pid);
8719 + ptgid = vx_map_pid(pid_alive(p) ?
8720 + rcu_dereference(p->real_parent)->tgid : 0);
8721 + tppid = vx_map_pid(pid_alive(p) && p->ptrace ?
8722 + rcu_dereference(p->parent)->pid : 0);
8724 buffer += sprintf(buffer,
8726 "SleepAVG:\t%lu%%\n"
8727 @@ -174,9 +186,7 @@ static inline char * task_state(struct t
8728 "Gid:\t%d\t%d\t%d\t%d\n",
8730 (p->sleep_avg/1024)*100/(1020000000/1024),
8732 - pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0,
8733 - pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0,
8734 + tgid, pid, (pid > 1) ? ptgid : 0, tppid,
8735 p->uid, p->euid, p->suid, p->fsuid,
8736 p->gid, p->egid, p->sgid, p->fsgid);
8738 @@ -283,12 +293,15 @@ static inline char * task_sig(struct tas
8740 static inline char *task_cap(struct task_struct *p, char *buffer)
8742 - return buffer + sprintf(buffer, "CapInh:\t%016x\n"
8743 - "CapPrm:\t%016x\n"
8744 - "CapEff:\t%016x\n",
8745 - cap_t(p->cap_inheritable),
8746 - cap_t(p->cap_permitted),
8747 - cap_t(p->cap_effective));
8748 + struct vx_info *vxi = p->vx_info;
8750 + return buffer + sprintf(buffer,
8751 + "CapInh:\t%016x\n"
8752 + "CapPrm:\t%016x\n"
8753 + "CapEff:\t%016x\n",
8754 + (unsigned)vx_info_mbcap(vxi, p->cap_inheritable),
8755 + (unsigned)vx_info_mbcap(vxi, p->cap_permitted),
8756 + (unsigned)vx_info_mbcap(vxi, p->cap_effective));
8759 int proc_pid_status(struct task_struct *task, char * buffer)
8760 @@ -306,6 +319,12 @@ int proc_pid_status(struct task_struct *
8761 buffer = task_sig(task, buffer);
8762 buffer = task_cap(task, buffer);
8763 buffer = cpuset_task_status_allowed(task, buffer);
8765 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8767 + buffer += sprintf (buffer,"VxID: %d\n", vx_task_xid(task));
8768 + buffer += sprintf (buffer,"NxID: %d\n", nx_task_nid(task));
8770 #if defined(CONFIG_S390)
8771 buffer = task_show_regs(task, buffer);
8773 @@ -320,7 +339,7 @@ static int do_task_stat(struct task_stru
8774 sigset_t sigign, sigcatch;
8777 - pid_t ppid = 0, pgid = -1, sid = -1;
8778 + pid_t pid = 0, ppid = 0, pgid = -1, sid = -1;
8779 int num_threads = 0;
8780 struct mm_struct *mm;
8781 unsigned long long start_time;
8782 @@ -382,8 +401,10 @@ static int do_task_stat(struct task_stru
8785 sid = signal_session(sig);
8786 - pgid = process_group(task);
8787 - ppid = rcu_dereference(task->real_parent)->tgid;
8788 + pid = vx_info_map_pid(task->vx_info, task->pid);
8789 + pgid = vx_info_map_pid(task->vx_info, process_group(task));
8790 + ppid = (pid > 1) ? vx_info_map_tgid(task->vx_info,
8791 + rcu_dereference(task->real_parent)->tgid) : 0;
8793 unlock_task_sighand(task, &flags);
8795 @@ -410,10 +431,21 @@ static int do_task_stat(struct task_stru
8796 /* convert nsec -> ticks */
8797 start_time = nsec_to_clock_t(start_time);
8799 + /* fixup start time for virt uptime */
8800 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8801 + unsigned long long bias =
8802 + current->vx_info->cvirt.bias_clock;
8804 + if (start_time > bias)
8805 + start_time -= bias;
8810 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %u %lu \
8811 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8812 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n",
8818 diff -Nurp linux-2.6.22.18/fs/proc/base.c linux-2.6.22.18-vs2.3.0.32/fs/proc/base.c
8819 --- linux-2.6.22.18/fs/proc/base.c 2007-07-22 00:00:18.000000000 +0200
8820 +++ linux-2.6.22.18-vs2.3.0.32/fs/proc/base.c 2008-02-11 12:35:35.000000000 +0100
8822 #include <linux/poll.h>
8823 #include <linux/nsproxy.h>
8824 #include <linux/oom.h>
8825 +#include <linux/vs_context.h>
8826 +#include <linux/vs_network.h>
8828 #include "internal.h"
8831 @@ -1049,6 +1052,8 @@ static struct inode *proc_pid_make_inode
8832 inode->i_uid = task->euid;
8833 inode->i_gid = task->egid;
8835 + /* procfs is xid tagged */
8836 + inode->i_tag = (tag_t)vx_task_xid(task);
8837 security_task_to_inode(task, inode);
8840 @@ -1082,6 +1087,8 @@ static int pid_getattr(struct vfsmount *
8844 +static unsigned name_to_int(struct dentry *dentry);
8847 * Exceptional case: normally we are not allowed to unhash a busy
8848 * directory. In this case, however, we can do it - no aliasing problems
8849 @@ -1102,6 +1109,12 @@ static int pid_revalidate(struct dentry
8850 struct inode *inode = dentry->d_inode;
8851 struct task_struct *task = get_proc_task(inode);
8853 + unsigned pid = name_to_int(dentry);
8854 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
8855 + put_task_struct(task);
8859 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
8860 task_dumpable(task)) {
8861 inode->i_uid = task->euid;
8862 @@ -1115,6 +1128,7 @@ static int pid_revalidate(struct dentry
8863 put_task_struct(task);
8870 @@ -1595,6 +1609,13 @@ static struct dentry *proc_pident_lookup
8874 + /* TODO: maybe we can come up with a generic approach? */
8875 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8876 + (dentry->d_name.len == 5) &&
8877 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8878 + !memcmp(dentry->d_name.name, "ninfo", 5)))
8882 * Yes, it does not scale. And it should not. Don't add
8883 * new entries into /proc/<tgid>/ without very good reasons.
8884 @@ -1790,14 +1811,14 @@ static int proc_self_readlink(struct den
8887 char tmp[PROC_NUMBUF];
8888 - sprintf(tmp, "%d", current->tgid);
8889 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8890 return vfs_readlink(dentry,buffer,buflen,tmp);
8893 static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
8895 char tmp[PROC_NUMBUF];
8896 - sprintf(tmp, "%d", current->tgid);
8897 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8898 return ERR_PTR(vfs_follow_link(nd,tmp));
8901 @@ -1891,7 +1912,7 @@ out_iput:
8902 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8904 struct dentry *error;
8905 - struct task_struct *task = get_proc_task(dir);
8906 + struct task_struct *task = get_proc_task_real(dir);
8907 const struct pid_entry *p, *last;
8909 error = ERR_PTR(-ENOENT);
8910 @@ -1956,6 +1977,9 @@ static int proc_pid_io_accounting(struct
8911 static const struct file_operations proc_task_operations;
8912 static const struct inode_operations proc_task_inode_operations;
8914 +extern int proc_pid_vx_info(struct task_struct *, char *);
8915 +extern int proc_pid_nx_info(struct task_struct *, char *);
8917 static const struct pid_entry tgid_base_stuff[] = {
8918 DIR("task", S_IRUGO|S_IXUGO, task),
8919 DIR("fd", S_IRUSR|S_IXUSR, fd),
8920 @@ -1995,6 +2019,8 @@ static const struct pid_entry tgid_base_
8921 #ifdef CONFIG_CPUSETS
8922 REG("cpuset", S_IRUGO, cpuset),
8924 + INF("vinfo", S_IRUGO, pid_vx_info),
8925 + INF("ninfo", S_IRUGO, pid_nx_info),
8926 INF("oom_score", S_IRUGO, oom_score),
8927 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
8928 #ifdef CONFIG_AUDITSYSCALL
8929 @@ -2141,9 +2167,11 @@ struct dentry *proc_pid_lookup(struct in
8930 tgid = name_to_int(dentry);
8933 + if (vx_current_initpid(tgid))
8937 - task = find_task_by_pid(tgid);
8938 + task = vx_find_proc_task_by_pid(tgid);
8940 get_task_struct(task);
8942 @@ -2198,7 +2226,7 @@ static int proc_pid_fill_cache(struct fi
8943 struct task_struct *task, int tgid)
8945 char name[PROC_NUMBUF];
8946 - int len = snprintf(name, sizeof(name), "%d", tgid);
8947 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(tgid));
8948 return proc_fill_cache(filp, dirent, filldir, name, len,
8949 proc_pid_instantiate, task, NULL);
8951 @@ -2207,7 +2235,7 @@ static int proc_pid_fill_cache(struct fi
8952 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8954 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8955 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8956 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8957 struct task_struct *task;
8960 @@ -2226,6 +2254,8 @@ int proc_pid_readdir(struct file * filp,
8961 put_task_struct(task), task = next_tgid(tgid + 1)) {
8963 filp->f_pos = tgid + TGID_OFFSET;
8964 + if (!vx_proc_task_visible(task))
8966 if (proc_pid_fill_cache(filp, dirent, filldir, task, tgid) < 0) {
8967 put_task_struct(task);
8969 @@ -2352,9 +2382,11 @@ static struct dentry *proc_task_lookup(s
8970 tid = name_to_int(dentry);
8973 + if (vx_current_initpid(tid))
8977 - task = find_task_by_pid(tid);
8978 + task = vx_find_proc_task_by_pid(tid);
8980 get_task_struct(task);
8982 @@ -2499,7 +2531,7 @@ static int proc_task_readdir(struct file
8983 for (task = first_tid(leader, tid, pos - 2);
8985 task = next_tid(task), pos++) {
8987 + tid = vx_map_pid(task->pid);
8988 if (proc_task_fill_cache(filp, dirent, filldir, task, tid) < 0) {
8989 /* returning this tgid failed, save it as the first
8990 * pid for the next readir call */
8991 diff -Nurp linux-2.6.22.18/fs/proc/generic.c linux-2.6.22.18-vs2.3.0.32/fs/proc/generic.c
8992 --- linux-2.6.22.18/fs/proc/generic.c 2007-07-22 00:00:18.000000000 +0200
8993 +++ linux-2.6.22.18-vs2.3.0.32/fs/proc/generic.c 2008-02-11 12:35:35.000000000 +0100
8995 #include <linux/namei.h>
8996 #include <linux/bitops.h>
8997 #include <linux/spinlock.h>
8998 +#include <linux/vserver/inode.h>
8999 #include <asm/uaccess.h>
9001 #include "internal.h"
9002 @@ -395,6 +396,8 @@ struct dentry *proc_lookup(struct inode
9003 for (de = de->subdir; de ; de = de->next) {
9004 if (de->namelen != dentry->d_name.len)
9006 + if (!vx_hide_check(0, de->vx_flags))
9008 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
9009 unsigned int ino = de->low_ino;
9011 @@ -402,6 +405,8 @@ struct dentry *proc_lookup(struct inode
9012 spin_unlock(&proc_subdir_lock);
9014 inode = proc_get_inode(dir->i_sb, ino, de);
9015 + /* generic proc entries belong to the host */
9017 spin_lock(&proc_subdir_lock);
9020 @@ -482,6 +487,8 @@ int proc_readdir(struct file * filp,
9022 /* filldir passes info to user space */
9024 + if (!vx_hide_check(0, de->vx_flags))
9026 spin_unlock(&proc_subdir_lock);
9027 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
9028 de->low_ino, de->mode >> 12) < 0) {
9029 @@ -489,6 +496,7 @@ int proc_readdir(struct file * filp,
9032 spin_lock(&proc_subdir_lock);
9037 @@ -613,6 +621,7 @@ static struct proc_dir_entry *proc_creat
9041 + ent->vx_flags = IATTR_PROC_DEFAULT;
9045 @@ -633,7 +642,8 @@ struct proc_dir_entry *proc_symlink(cons
9051 + ent->vx_flags = IATTR_PROC_SYMLINK;
9055 diff -Nurp linux-2.6.22.18/fs/proc/inode.c linux-2.6.22.18-vs2.3.0.32/fs/proc/inode.c
9056 --- linux-2.6.22.18/fs/proc/inode.c 2007-07-22 00:00:18.000000000 +0200
9057 +++ linux-2.6.22.18-vs2.3.0.32/fs/proc/inode.c 2008-02-11 12:35:35.000000000 +0100
9058 @@ -160,6 +160,8 @@ struct inode *proc_get_inode(struct supe
9059 inode->i_uid = de->uid;
9060 inode->i_gid = de->gid;
9063 + PROC_I(inode)->vx_flags = de->vx_flags;
9065 inode->i_size = de->size;
9067 diff -Nurp linux-2.6.22.18/fs/proc/internal.h linux-2.6.22.18-vs2.3.0.32/fs/proc/internal.h
9068 --- linux-2.6.22.18/fs/proc/internal.h 2007-07-22 00:00:18.000000000 +0200
9069 +++ linux-2.6.22.18-vs2.3.0.32/fs/proc/internal.h 2008-02-11 12:35:35.000000000 +0100
9073 #include <linux/proc_fs.h>
9074 +#include <linux/vs_pid.h>
9076 #ifdef CONFIG_PROC_SYSCTL
9077 extern int proc_sys_init(void);
9078 @@ -64,11 +65,16 @@ static inline struct pid *proc_pid(struc
9079 return PROC_I(inode)->pid;
9082 -static inline struct task_struct *get_proc_task(struct inode *inode)
9083 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
9085 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
9088 +static inline struct task_struct *get_proc_task(struct inode *inode)
9090 + return vx_get_proc_task(inode, proc_pid(inode));
9093 static inline int proc_fd(struct inode *inode)
9095 return PROC_I(inode)->fd;
9096 diff -Nurp linux-2.6.22.18/fs/proc/proc_misc.c linux-2.6.22.18-vs2.3.0.32/fs/proc/proc_misc.c
9097 --- linux-2.6.22.18/fs/proc/proc_misc.c 2007-07-22 00:00:18.000000000 +0200
9098 +++ linux-2.6.22.18-vs2.3.0.32/fs/proc/proc_misc.c 2008-02-11 12:35:35.000000000 +0100
9100 #include <asm/div64.h>
9101 #include "internal.h"
9103 +#include <linux/vs_cvirt.h>
9105 #define LOAD_INT(x) ((x) >> FSHIFT)
9106 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
9108 @@ -82,17 +84,32 @@ static int proc_calc_metrics(char *page,
9109 static int loadavg_read_proc(char *page, char **start, off_t off,
9110 int count, int *eof, void *data)
9112 + unsigned int running, threads;
9116 - a = avenrun[0] + (FIXED_1/200);
9117 - b = avenrun[1] + (FIXED_1/200);
9118 - c = avenrun[2] + (FIXED_1/200);
9119 - len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
9120 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
9121 + struct vx_info *vxi = current->vx_info;
9123 + a = vxi->cvirt.load[0] + (FIXED_1/200);
9124 + b = vxi->cvirt.load[1] + (FIXED_1/200);
9125 + c = vxi->cvirt.load[2] + (FIXED_1/200);
9127 + running = atomic_read(&vxi->cvirt.nr_running);
9128 + threads = atomic_read(&vxi->cvirt.nr_threads);
9130 + a = avenrun[0] + (FIXED_1/200);
9131 + b = avenrun[1] + (FIXED_1/200);
9132 + c = avenrun[2] + (FIXED_1/200);
9134 + running = nr_running();
9135 + threads = nr_threads;
9137 + len = sprintf(page,"%d.%02d %d.%02d %d.%02d %d/%d %d\n",
9138 LOAD_INT(a), LOAD_FRAC(a),
9139 LOAD_INT(b), LOAD_FRAC(b),
9140 LOAD_INT(c), LOAD_FRAC(c),
9141 - nr_running(), nr_threads, current->nsproxy->pid_ns->last_pid);
9142 + running, threads, current->nsproxy->pid_ns->last_pid);
9143 return proc_calc_metrics(page, start, off, count, eof, len);
9146 @@ -106,6 +123,9 @@ static int uptime_read_proc(char *page,
9148 do_posix_clock_monotonic_gettime(&uptime);
9149 cputime_to_timespec(idletime, &idle);
9150 + if (vx_flags(VXF_VIRT_UPTIME, 0))
9151 + vx_vsi_uptime(&uptime, &idle);
9153 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
9154 (unsigned long) uptime.tv_sec,
9155 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
9156 @@ -137,7 +157,7 @@ static int meminfo_read_proc(char *page,
9158 cached = global_page_state(NR_FILE_PAGES) -
9159 total_swapcache_pages - i.bufferram;
9161 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
9164 get_vmalloc_info(&vmi);
9165 diff -Nurp linux-2.6.22.18/fs/proc/root.c linux-2.6.22.18-vs2.3.0.32/fs/proc/root.c
9166 --- linux-2.6.22.18/fs/proc/root.c 2007-07-21 23:58:48.000000000 +0200
9167 +++ linux-2.6.22.18-vs2.3.0.32/fs/proc/root.c 2008-02-11 12:35:35.000000000 +0100
9169 #include "internal.h"
9171 struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
9172 +struct proc_dir_entry *proc_virtual;
9174 +extern void proc_vx_init(void);
9176 static int proc_get_sb(struct file_system_type *fs_type,
9177 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
9178 @@ -79,6 +82,7 @@ void __init proc_root_init(void)
9179 proc_device_tree_init();
9181 proc_bus = proc_mkdir("bus", NULL);
9186 diff -Nurp linux-2.6.22.18/fs/quota.c linux-2.6.22.18-vs2.3.0.32/fs/quota.c
9187 --- linux-2.6.22.18/fs/quota.c 2007-07-22 00:00:18.000000000 +0200
9188 +++ linux-2.6.22.18-vs2.3.0.32/fs/quota.c 2008-02-11 12:35:35.000000000 +0100
9190 #include <linux/buffer_head.h>
9191 #include <linux/capability.h>
9192 #include <linux/quotaops.h>
9193 +#include <linux/vs_context.h>
9195 /* Check validity of generic quotactl commands */
9196 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
9197 @@ -80,11 +81,11 @@ static int generic_quotactl_valid(struct
9198 if (cmd == Q_GETQUOTA) {
9199 if (((type == USRQUOTA && current->euid != id) ||
9200 (type == GRPQUOTA && !in_egroup_p(id))) &&
9201 - !capable(CAP_SYS_ADMIN))
9202 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9205 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
9206 - if (!capable(CAP_SYS_ADMIN))
9207 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9211 @@ -131,10 +132,10 @@ static int xqm_quotactl_valid(struct sup
9212 if (cmd == Q_XGETQUOTA) {
9213 if (((type == XQM_USRQUOTA && current->euid != id) ||
9214 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
9215 - !capable(CAP_SYS_ADMIN))
9216 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9218 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
9219 - if (!capable(CAP_SYS_ADMIN))
9220 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9224 @@ -327,6 +328,46 @@ static int do_quotactl(struct super_bloc
9228 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
9230 +#include <linux/vroot.h>
9231 +#include <linux/major.h>
9232 +#include <linux/module.h>
9233 +#include <linux/kallsyms.h>
9234 +#include <linux/vserver/debug.h>
9236 +static vroot_grb_func *vroot_get_real_bdev = NULL;
9238 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
9240 +int register_vroot_grb(vroot_grb_func *func) {
9243 + spin_lock(&vroot_grb_lock);
9244 + if (!vroot_get_real_bdev) {
9245 + vroot_get_real_bdev = func;
9248 + spin_unlock(&vroot_grb_lock);
9251 +EXPORT_SYMBOL(register_vroot_grb);
9253 +int unregister_vroot_grb(vroot_grb_func *func) {
9254 + int ret = -EINVAL;
9256 + spin_lock(&vroot_grb_lock);
9257 + if (vroot_get_real_bdev) {
9258 + vroot_get_real_bdev = NULL;
9261 + spin_unlock(&vroot_grb_lock);
9264 +EXPORT_SYMBOL(unregister_vroot_grb);
9269 * look up a superblock on which quota ops will be performed
9270 * - use the name of a block device to find the superblock thereon
9271 @@ -344,6 +385,22 @@ static inline struct super_block *quotac
9274 return ERR_PTR(PTR_ERR(bdev));
9275 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
9276 + if (bdev && bdev->bd_inode &&
9277 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
9278 + struct block_device *bdnew = (void *)-EINVAL;
9280 + if (vroot_get_real_bdev)
9281 + bdnew = vroot_get_real_bdev(bdev);
9283 + vxdprintk(VXD_CBIT(misc, 0),
9284 + "vroot_get_real_bdev not set");
9286 + if (IS_ERR(bdnew))
9287 + return ERR_PTR(PTR_ERR(bdnew));
9291 sb = get_super(bdev);
9294 diff -Nurp linux-2.6.22.18/fs/reiserfs/bitmap.c linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/bitmap.c
9295 --- linux-2.6.22.18/fs/reiserfs/bitmap.c 2007-05-04 15:58:22.000000000 +0200
9296 +++ linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/bitmap.c 2008-02-11 12:35:35.000000000 +0100
9298 #include <linux/reiserfs_fs_sb.h>
9299 #include <linux/reiserfs_fs_i.h>
9300 #include <linux/quotaops.h>
9301 +#include <linux/vs_dlimit.h>
9303 #define PREALLOCATION_SIZE 9
9305 @@ -425,8 +426,10 @@ static void _reiserfs_free_block(struct
9306 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
9308 journal_mark_dirty(th, s, sbh);
9309 - if (for_unformatted)
9310 + if (for_unformatted) {
9311 + DLIMIT_FREE_BLOCK(inode, 1);
9312 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
9316 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
9317 @@ -1034,6 +1037,7 @@ static inline int blocknrs_and_prealloc_
9318 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
9320 int nr_allocated = 0;
9323 determine_prealloc_size(hint);
9324 if (!hint->formatted_node) {
9325 @@ -1043,19 +1047,30 @@ static inline int blocknrs_and_prealloc_
9326 "reiserquota: allocating %d blocks id=%u",
9327 amount_needed, hint->inode->i_uid);
9330 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
9331 - if (quota_ret) /* Quota exceeded? */
9332 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
9335 return QUOTA_EXCEEDED;
9336 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
9337 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
9339 + return NO_DISK_SPACE;
9342 if (hint->preallocate && hint->prealloc_size) {
9343 #ifdef REISERQUOTA_DEBUG
9344 reiserfs_debug(s, REISERFS_DEBUG_CODE,
9345 "reiserquota: allocating (prealloc) %d blocks id=%u",
9346 hint->prealloc_size, hint->inode->i_uid);
9349 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
9350 - hint->prealloc_size);
9351 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
9352 + hint->prealloc_size);
9354 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
9355 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
9356 + hint->prealloc_size);
9360 hint->preallocate = hint->prealloc_size = 0;
9362 @@ -1087,7 +1102,10 @@ static inline int blocknrs_and_prealloc_
9364 hint->inode->i_uid);
9366 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
9367 + /* Free not allocated blocks */
9368 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
9369 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
9370 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
9372 while (nr_allocated--)
9373 reiserfs_free_block(hint->th, hint->inode,
9374 @@ -1118,10 +1136,10 @@ static inline int blocknrs_and_prealloc_
9375 REISERFS_I(hint->inode)->i_prealloc_count,
9376 hint->inode->i_uid);
9378 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
9379 - hint->prealloc_size - nr_allocated -
9380 - REISERFS_I(hint->inode)->
9381 - i_prealloc_count);
9382 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
9383 + REISERFS_I(hint->inode)->i_prealloc_count;
9384 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
9385 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
9389 diff -Nurp linux-2.6.22.18/fs/reiserfs/file.c linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/file.c
9390 --- linux-2.6.22.18/fs/reiserfs/file.c 2007-07-22 00:00:18.000000000 +0200
9391 +++ linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/file.c 2008-02-11 12:35:35.000000000 +0100
9392 @@ -1546,4 +1546,5 @@ const struct inode_operations reiserfs_f
9393 .listxattr = reiserfs_listxattr,
9394 .removexattr = reiserfs_removexattr,
9395 .permission = reiserfs_permission,
9396 + .sync_flags = reiserfs_sync_flags,
9398 diff -Nurp linux-2.6.22.18/fs/reiserfs/inode.c linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/inode.c
9399 --- linux-2.6.22.18/fs/reiserfs/inode.c 2007-07-22 00:00:18.000000000 +0200
9400 +++ linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/inode.c 2008-02-11 12:35:35.000000000 +0100
9402 #include <linux/mpage.h>
9403 #include <linux/writeback.h>
9404 #include <linux/quotaops.h>
9405 +#include <linux/vs_dlimit.h>
9406 +#include <linux/vs_tag.h>
9408 static int reiserfs_commit_write(struct file *f, struct page *page,
9409 unsigned from, unsigned to);
9410 @@ -50,6 +52,7 @@ void reiserfs_delete_inode(struct inode
9411 * stat data deletion */
9413 DQUOT_FREE_INODE(inode);
9414 + DLIMIT_FREE_INODE(inode);
9416 if (journal_end(&th, inode->i_sb, jbegin_count))
9418 @@ -1112,6 +1115,8 @@ static void init_inode(struct inode *ino
9419 struct buffer_head *bh;
9420 struct item_head *ih;
9424 //int version = ITEM_VERSION_1;
9426 bh = PATH_PLAST_BUFFER(path);
9427 @@ -1135,12 +1140,13 @@ static void init_inode(struct inode *ino
9428 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
9429 unsigned long blocks;
9431 + uid = sd_v1_uid(sd);
9432 + gid = sd_v1_gid(sd);
9434 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
9435 set_inode_sd_version(inode, STAT_DATA_V1);
9436 inode->i_mode = sd_v1_mode(sd);
9437 inode->i_nlink = sd_v1_nlink(sd);
9438 - inode->i_uid = sd_v1_uid(sd);
9439 - inode->i_gid = sd_v1_gid(sd);
9440 inode->i_size = sd_v1_size(sd);
9441 inode->i_atime.tv_sec = sd_v1_atime(sd);
9442 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
9443 @@ -1182,11 +1188,12 @@ static void init_inode(struct inode *ino
9444 // (directories and symlinks)
9445 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
9447 + uid = sd_v2_uid(sd);
9448 + gid = sd_v2_gid(sd);
9450 inode->i_mode = sd_v2_mode(sd);
9451 inode->i_nlink = sd_v2_nlink(sd);
9452 - inode->i_uid = sd_v2_uid(sd);
9453 inode->i_size = sd_v2_size(sd);
9454 - inode->i_gid = sd_v2_gid(sd);
9455 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
9456 inode->i_atime.tv_sec = sd_v2_atime(sd);
9457 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
9458 @@ -1216,6 +1223,10 @@ static void init_inode(struct inode *ino
9459 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
9462 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
9463 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
9464 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
9467 if (S_ISREG(inode->i_mode)) {
9468 inode->i_op = &reiserfs_file_inode_operations;
9469 @@ -1238,13 +1249,15 @@ static void init_inode(struct inode *ino
9470 static void inode2sd(void *sd, struct inode *inode, loff_t size)
9472 struct stat_data *sd_v2 = (struct stat_data *)sd;
9473 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
9474 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
9477 + set_sd_v2_uid(sd_v2, uid);
9478 + set_sd_v2_gid(sd_v2, gid);
9479 set_sd_v2_mode(sd_v2, inode->i_mode);
9480 set_sd_v2_nlink(sd_v2, inode->i_nlink);
9481 - set_sd_v2_uid(sd_v2, inode->i_uid);
9482 set_sd_v2_size(sd_v2, size);
9483 - set_sd_v2_gid(sd_v2, inode->i_gid);
9484 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
9485 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
9486 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
9487 @@ -1775,6 +1788,10 @@ int reiserfs_new_inode(struct reiserfs_t
9489 BUG_ON(!th->t_trans_id);
9491 + if (DLIMIT_ALLOC_INODE(inode)) {
9493 + goto out_bad_dlimit;
9495 if (DQUOT_ALLOC_INODE(inode)) {
9498 @@ -1960,6 +1977,9 @@ int reiserfs_new_inode(struct reiserfs_t
9499 DQUOT_FREE_INODE(inode);
9502 + DLIMIT_FREE_INODE(inode);
9505 journal_end(th, th->t_super, th->t_blocks_allocated);
9506 /* Drop can be outside and it needs more credits so it's better to have it outside */
9508 @@ -2690,6 +2710,14 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
9509 inode->i_flags |= S_IMMUTABLE;
9511 inode->i_flags &= ~S_IMMUTABLE;
9512 + if (sd_attrs & REISERFS_IUNLINK_FL)
9513 + inode->i_flags |= S_IUNLINK;
9515 + inode->i_flags &= ~S_IUNLINK;
9516 + if (sd_attrs & REISERFS_BARRIER_FL)
9517 + inode->i_flags |= S_BARRIER;
9519 + inode->i_flags &= ~S_BARRIER;
9520 if (sd_attrs & REISERFS_APPEND_FL)
9521 inode->i_flags |= S_APPEND;
9523 @@ -2712,6 +2740,14 @@ void i_attrs_to_sd_attrs(struct inode *i
9524 *sd_attrs |= REISERFS_IMMUTABLE_FL;
9526 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
9527 + if (inode->i_flags & S_IUNLINK)
9528 + *sd_attrs |= REISERFS_IUNLINK_FL;
9530 + *sd_attrs &= ~REISERFS_IUNLINK_FL;
9531 + if (inode->i_flags & S_BARRIER)
9532 + *sd_attrs |= REISERFS_BARRIER_FL;
9534 + *sd_attrs &= ~REISERFS_BARRIER_FL;
9535 if (inode->i_flags & S_SYNC)
9536 *sd_attrs |= REISERFS_SYNC_FL;
9538 @@ -2891,6 +2927,22 @@ static ssize_t reiserfs_direct_IO(int rw
9539 reiserfs_get_blocks_direct_io, NULL);
9542 +int reiserfs_sync_flags(struct inode *inode)
9544 + u16 oldflags, newflags;
9546 + oldflags = REISERFS_I(inode)->i_attrs;
9547 + newflags = oldflags;
9548 + i_attrs_to_sd_attrs(inode, &newflags);
9550 + if (oldflags ^ newflags) {
9551 + REISERFS_I(inode)->i_attrs = newflags;
9552 + inode->i_ctime = CURRENT_TIME_SEC;
9553 + mark_inode_dirty(inode);
9558 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
9560 struct inode *inode = dentry->d_inode;
9561 @@ -2940,9 +2992,11 @@ int reiserfs_setattr(struct dentry *dent
9564 error = inode_change_ok(inode, attr);
9567 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
9568 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
9569 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
9570 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
9571 error = reiserfs_chown_xattrs(inode, attr);
9574 @@ -2972,6 +3026,9 @@ int reiserfs_setattr(struct dentry *dent
9575 inode->i_uid = attr->ia_uid;
9576 if (attr->ia_valid & ATTR_GID)
9577 inode->i_gid = attr->ia_gid;
9578 + if ((attr->ia_valid & ATTR_TAG) &&
9580 + inode->i_tag = attr->ia_tag;
9581 mark_inode_dirty(inode);
9583 journal_end(&th, inode->i_sb, jbegin_count);
9584 diff -Nurp linux-2.6.22.18/fs/reiserfs/ioctl.c linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/ioctl.c
9585 --- linux-2.6.22.18/fs/reiserfs/ioctl.c 2007-05-04 15:58:22.000000000 +0200
9586 +++ linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/ioctl.c 2008-02-11 12:35:35.000000000 +0100
9588 #include <linux/fs.h>
9589 #include <linux/reiserfs_fs.h>
9590 #include <linux/time.h>
9591 +#include <linux/mount.h>
9592 #include <asm/uaccess.h>
9593 #include <linux/pagemap.h>
9594 #include <linux/smp_lock.h>
9595 @@ -24,7 +25,7 @@ static int reiserfs_unpack(struct inode
9596 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
9599 - unsigned int flags;
9600 + unsigned int flags, oldflags;
9603 case REISERFS_IOC_UNPACK:
9604 @@ -43,12 +44,14 @@ int reiserfs_ioctl(struct inode *inode,
9606 flags = REISERFS_I(inode)->i_attrs;
9607 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
9608 + flags &= REISERFS_FL_USER_VISIBLE;
9609 return put_user(flags, (int __user *)arg);
9610 case REISERFS_IOC_SETFLAGS:{
9611 if (!reiserfs_attrs(inode->i_sb))
9614 - if (IS_RDONLY(inode))
9615 + if (IS_RDONLY(inode) ||
9616 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9619 if ((current->fsuid != inode->i_uid)
9620 @@ -58,10 +61,12 @@ int reiserfs_ioctl(struct inode *inode,
9621 if (get_user(flags, (int __user *)arg))
9624 - if (((flags ^ REISERFS_I(inode)->
9625 - i_attrs) & (REISERFS_IMMUTABLE_FL |
9626 - REISERFS_APPEND_FL))
9627 - && !capable(CAP_LINUX_IMMUTABLE))
9628 + oldflags = REISERFS_I(inode) -> i_attrs;
9629 + if (((oldflags & REISERFS_IMMUTABLE_FL) ||
9630 + ((flags ^ oldflags) &
9631 + (REISERFS_IMMUTABLE_FL | REISERFS_IUNLINK_FL |
9632 + REISERFS_APPEND_FL))) &&
9633 + !capable(CAP_LINUX_IMMUTABLE))
9636 if ((flags & REISERFS_NOTAIL_FL) &&
9637 @@ -72,6 +77,9 @@ int reiserfs_ioctl(struct inode *inode,
9642 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
9643 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
9644 sd_attrs_to_i_attrs(flags, inode);
9645 REISERFS_I(inode)->i_attrs = flags;
9646 inode->i_ctime = CURRENT_TIME_SEC;
9647 @@ -83,7 +91,8 @@ int reiserfs_ioctl(struct inode *inode,
9648 case REISERFS_IOC_SETVERSION:
9649 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
9651 - if (IS_RDONLY(inode))
9652 + if (IS_RDONLY(inode) ||
9653 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9655 if (get_user(inode->i_generation, (int __user *)arg))
9657 diff -Nurp linux-2.6.22.18/fs/reiserfs/namei.c linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/namei.c
9658 --- linux-2.6.22.18/fs/reiserfs/namei.c 2007-07-22 00:00:18.000000000 +0200
9659 +++ linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/namei.c 2008-02-11 12:35:35.000000000 +0100
9661 #include <linux/reiserfs_acl.h>
9662 #include <linux/reiserfs_xattr.h>
9663 #include <linux/quotaops.h>
9664 +#include <linux/vs_tag.h>
9666 #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; }
9667 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
9668 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
9669 reiserfs_write_unlock(dir->i_sb);
9670 return ERR_PTR(-EACCES);
9672 + dx_propagate_tag(nd, inode);
9674 /* Propogate the priv_object flag so we know we're in the priv tree */
9675 if (is_reiserfs_priv_object(dir))
9676 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
9678 inode->i_gid = current->fsgid;
9680 + inode->i_tag = dx_current_fstag(inode->i_sb);
9684 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
9685 .listxattr = reiserfs_listxattr,
9686 .removexattr = reiserfs_removexattr,
9687 .permission = reiserfs_permission,
9688 + .sync_flags = reiserfs_sync_flags,
9692 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
9693 .listxattr = reiserfs_listxattr,
9694 .removexattr = reiserfs_removexattr,
9695 .permission = reiserfs_permission,
9696 + .sync_flags = reiserfs_sync_flags,
9700 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
9701 .listxattr = reiserfs_listxattr,
9702 .removexattr = reiserfs_removexattr,
9703 .permission = reiserfs_permission,
9704 + .sync_flags = reiserfs_sync_flags,
9707 diff -Nurp linux-2.6.22.18/fs/reiserfs/stree.c linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/stree.c
9708 --- linux-2.6.22.18/fs/reiserfs/stree.c 2007-07-22 00:00:18.000000000 +0200
9709 +++ linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/stree.c 2008-02-11 12:35:35.000000000 +0100
9711 #include <linux/reiserfs_fs.h>
9712 #include <linux/buffer_head.h>
9713 #include <linux/quotaops.h>
9714 +#include <linux/vs_dlimit.h>
9716 /* Does the buffer contain a disk block which is in the tree. */
9717 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
9718 @@ -1296,6 +1297,7 @@ int reiserfs_delete_item(struct reiserfs
9719 "reiserquota delete_item(): freeing %u, id=%u type=%c",
9720 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
9722 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9723 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9725 /* Return deleted body length */
9726 @@ -1384,6 +1386,7 @@ void reiserfs_delete_solid_item(struct r
9728 DQUOT_FREE_SPACE_NODIRTY(inode,
9730 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
9734 @@ -1737,6 +1740,7 @@ int reiserfs_cut_from_item(struct reiser
9735 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
9736 quota_cut_bytes, p_s_inode->i_uid, '?');
9738 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9739 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9742 @@ -1978,6 +1982,11 @@ int reiserfs_paste_into_item(struct reis
9743 pathrelse(p_s_search_path);
9746 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
9747 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9748 + pathrelse(p_s_search_path);
9751 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
9753 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
9754 @@ -2030,6 +2039,7 @@ int reiserfs_paste_into_item(struct reis
9755 n_pasted_size, inode->i_uid,
9756 key2type(&(p_s_key->on_disk_key)));
9758 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
9759 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9762 @@ -2067,6 +2077,11 @@ int reiserfs_insert_item(struct reiserfs
9763 pathrelse(p_s_path);
9766 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
9767 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9768 + pathrelse(p_s_path);
9772 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
9773 IH_SIZE + ih_item_len(p_s_ih));
9774 @@ -2114,7 +2129,9 @@ int reiserfs_insert_item(struct reiserfs
9775 "reiserquota insert_item(): freeing %u id=%u type=%c",
9776 quota_bytes, inode->i_uid, head2type(p_s_ih));
9780 + DLIMIT_FREE_SPACE(inode, quota_bytes);
9781 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9785 diff -Nurp linux-2.6.22.18/fs/reiserfs/super.c linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/super.c
9786 --- linux-2.6.22.18/fs/reiserfs/super.c 2007-07-22 00:00:18.000000000 +0200
9787 +++ linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/super.c 2008-02-11 12:35:35.000000000 +0100
9788 @@ -882,6 +882,14 @@ static int reiserfs_parse_options(struct
9789 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9790 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9792 +#ifndef CONFIG_TAGGING_NONE
9793 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9794 + {"tag",.setmask = 1 << REISERFS_TAGGED},
9795 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
9797 +#ifdef CONFIG_PROPAGATE
9798 + {"tag",.arg_required = 'T',.values = NULL},
9800 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9801 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9802 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9803 @@ -1143,6 +1151,12 @@ static int reiserfs_remount(struct super
9807 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
9808 + !(s->s_flags & MS_TAGGED)) {
9809 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
9815 /* Add options that are safe here */
9816 @@ -1591,6 +1605,10 @@ static int reiserfs_fill_super(struct su
9820 + /* map mount option tagxid */
9821 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9822 + s->s_flags |= MS_TAGGED;
9824 rs = SB_DISK_SUPER_BLOCK(s);
9825 /* Let's do basic sanity check to verify that underlying device is not
9826 smaller than the filesystem. If the check fails then abort and scream,
9827 diff -Nurp linux-2.6.22.18/fs/reiserfs/xattr.c linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/xattr.c
9828 --- linux-2.6.22.18/fs/reiserfs/xattr.c 2007-07-22 00:00:18.000000000 +0200
9829 +++ linux-2.6.22.18-vs2.3.0.32/fs/reiserfs/xattr.c 2008-02-11 12:35:35.000000000 +0100
9831 #include <linux/namei.h>
9832 #include <linux/errno.h>
9833 #include <linux/fs.h>
9834 +#include <linux/mount.h>
9835 #include <linux/file.h>
9836 #include <linux/pagemap.h>
9837 #include <linux/xattr.h>
9838 @@ -775,7 +776,7 @@ int reiserfs_delete_xattrs(struct inode
9839 if (dir->d_inode->i_nlink <= 2) {
9840 root = get_xa_root(inode->i_sb, XATTR_REPLACE);
9841 reiserfs_write_lock_xattrs(inode->i_sb);
9842 - err = vfs_rmdir(root->d_inode, dir);
9843 + err = vfs_rmdir(root->d_inode, dir, NULL);
9844 reiserfs_write_unlock_xattrs(inode->i_sb);
9847 diff -Nurp linux-2.6.22.18/fs/stat.c linux-2.6.22.18-vs2.3.0.32/fs/stat.c
9848 --- linux-2.6.22.18/fs/stat.c 2007-07-22 00:00:18.000000000 +0200
9849 +++ linux-2.6.22.18-vs2.3.0.32/fs/stat.c 2008-02-11 12:35:35.000000000 +0100
9850 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9851 stat->nlink = inode->i_nlink;
9852 stat->uid = inode->i_uid;
9853 stat->gid = inode->i_gid;
9854 + stat->tag = inode->i_tag;
9855 stat->rdev = inode->i_rdev;
9856 stat->atime = inode->i_atime;
9857 stat->mtime = inode->i_mtime;
9858 diff -Nurp linux-2.6.22.18/fs/super.c linux-2.6.22.18-vs2.3.0.32/fs/super.c
9859 --- linux-2.6.22.18/fs/super.c 2007-07-22 00:00:18.000000000 +0200
9860 +++ linux-2.6.22.18-vs2.3.0.32/fs/super.c 2008-02-11 12:35:35.000000000 +0100
9862 #include <linux/idr.h>
9863 #include <linux/kobject.h>
9864 #include <linux/mutex.h>
9865 +#include <linux/devpts_fs.h>
9866 +#include <linux/proc_fs.h>
9867 +#include <linux/vs_context.h>
9868 #include <asm/uaccess.h>
9871 @@ -860,12 +863,18 @@ struct vfsmount *
9872 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9874 struct vfsmount *mnt;
9875 + struct super_block *sb;
9876 char *secdata = NULL;
9880 return ERR_PTR(-ENODEV);
9883 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9884 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9888 mnt = alloc_vfsmnt(name);
9890 @@ -885,7 +894,14 @@ vfs_kern_mount(struct file_system_type *
9892 goto out_free_secdata;
9894 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
9897 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9898 + (sb->s_magic != PROC_SUPER_MAGIC) &&
9899 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
9902 + error = security_sb_kern_mount(sb, secdata);
9906 diff -Nurp linux-2.6.22.18/fs/sysfs/mount.c linux-2.6.22.18-vs2.3.0.32/fs/sysfs/mount.c
9907 --- linux-2.6.22.18/fs/sysfs/mount.c 2007-07-22 00:00:18.000000000 +0200
9908 +++ linux-2.6.22.18-vs2.3.0.32/fs/sysfs/mount.c 2008-02-11 12:35:35.000000000 +0100
9913 -/* Random magic number */
9914 -#define SYSFS_MAGIC 0x62656572
9916 struct vfsmount *sysfs_mount;
9917 struct super_block * sysfs_sb = NULL;
9918 @@ -48,7 +46,7 @@ static int sysfs_fill_super(struct super
9920 sb->s_blocksize = PAGE_CACHE_SIZE;
9921 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9922 - sb->s_magic = SYSFS_MAGIC;
9923 + sb->s_magic = SYSFS_SUPER_MAGIC;
9924 sb->s_op = &sysfs_ops;
9925 sb->s_time_gran = 1;
9927 diff -Nurp linux-2.6.22.18/fs/utimes.c linux-2.6.22.18-vs2.3.0.32/fs/utimes.c
9928 --- linux-2.6.22.18/fs/utimes.c 2007-07-22 00:00:18.000000000 +0200
9929 +++ linux-2.6.22.18-vs2.3.0.32/fs/utimes.c 2008-02-11 12:35:35.000000000 +0100
9931 #include <linux/sched.h>
9932 #include <linux/stat.h>
9933 #include <linux/utime.h>
9934 +#include <linux/mount.h>
9935 +#include <linux/vs_cowbl.h>
9936 #include <asm/uaccess.h>
9937 #include <asm/unistd.h>
9939 @@ -70,11 +72,13 @@ long do_utimes(int dfd, char __user *fil
9943 + error = cow_check_and_break(&nd);
9945 + goto dput_and_out;
9949 inode = dentry->d_inode;
9952 if (IS_RDONLY(inode))
9954 diff -Nurp linux-2.6.22.18/fs/xattr.c linux-2.6.22.18-vs2.3.0.32/fs/xattr.c
9955 --- linux-2.6.22.18/fs/xattr.c 2007-07-22 00:00:18.000000000 +0200
9956 +++ linux-2.6.22.18-vs2.3.0.32/fs/xattr.c 2008-02-11 12:35:35.000000000 +0100
9958 #include <linux/module.h>
9959 #include <linux/fsnotify.h>
9960 #include <linux/audit.h>
9961 +#include <linux/mount.h>
9962 #include <asm/uaccess.h>
9965 @@ -194,7 +195,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
9968 setxattr(struct dentry *d, char __user *name, void __user *value,
9969 - size_t size, int flags)
9970 + size_t size, int flags, struct vfsmount *mnt)
9973 void *kvalue = NULL;
9974 @@ -221,6 +222,9 @@ setxattr(struct dentry *d, char __user *
9978 + if (MNT_IS_RDONLY(mnt))
9981 error = vfs_setxattr(d, kname, kvalue, size, flags);
9984 @@ -236,7 +240,7 @@ sys_setxattr(char __user *path, char __u
9985 error = user_path_walk(path, &nd);
9988 - error = setxattr(nd.dentry, name, value, size, flags);
9989 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
9993 @@ -251,7 +255,7 @@ sys_lsetxattr(char __user *path, char __
9994 error = user_path_walk_link(path, &nd);
9997 - error = setxattr(nd.dentry, name, value, size, flags);
9998 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
10002 @@ -269,7 +273,7 @@ sys_fsetxattr(int fd, char __user *name,
10004 dentry = f->f_path.dentry;
10005 audit_inode(NULL, dentry->d_inode);
10006 - error = setxattr(dentry, name, value, size, flags);
10007 + error = setxattr(dentry, name, value, size, flags, f->f_vfsmnt);
10011 @@ -433,7 +437,7 @@ sys_flistxattr(int fd, char __user *list
10012 * Extended attribute REMOVE operations
10015 -removexattr(struct dentry *d, char __user *name)
10016 +removexattr(struct dentry *d, char __user *name, struct vfsmount *mnt)
10019 char kname[XATTR_NAME_MAX + 1];
10020 @@ -444,6 +448,9 @@ removexattr(struct dentry *d, char __use
10024 + if (MNT_IS_RDONLY(mnt))
10027 return vfs_removexattr(d, kname);
10030 @@ -456,7 +463,7 @@ sys_removexattr(char __user *path, char
10031 error = user_path_walk(path, &nd);
10034 - error = removexattr(nd.dentry, name);
10035 + error = removexattr(nd.dentry, name, nd.mnt);
10039 @@ -470,7 +477,7 @@ sys_lremovexattr(char __user *path, char
10040 error = user_path_walk_link(path, &nd);
10043 - error = removexattr(nd.dentry, name);
10044 + error = removexattr(nd.dentry, name, nd.mnt);
10048 @@ -487,7 +494,7 @@ sys_fremovexattr(int fd, char __user *na
10050 dentry = f->f_path.dentry;
10051 audit_inode(NULL, dentry->d_inode);
10052 - error = removexattr(dentry, name);
10053 + error = removexattr(dentry, name, f->f_vfsmnt);
10057 diff -Nurp linux-2.6.22.18/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_ioctl.c
10058 --- linux-2.6.22.18/fs/xfs/linux-2.6/xfs_ioctl.c 2007-07-21 23:58:49.000000000 +0200
10059 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_ioctl.c 2008-02-11 12:35:35.000000000 +0100
10060 @@ -1128,6 +1128,10 @@ xfs_di2lxflags(
10062 if (di_flags & XFS_DIFLAG_IMMUTABLE)
10063 flags |= FS_IMMUTABLE_FL;
10064 + if (di_flags & XFS_DIFLAG_IUNLINK)
10065 + flags |= FS_IUNLINK_FL;
10066 + if (di_flags & XFS_DIFLAG_BARRIER)
10067 + flags |= FS_BARRIER_FL;
10068 if (di_flags & XFS_DIFLAG_APPEND)
10069 flags |= FS_APPEND_FL;
10070 if (di_flags & XFS_DIFLAG_SYNC)
10071 diff -Nurp linux-2.6.22.18/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_iops.c
10072 --- linux-2.6.22.18/fs/xfs/linux-2.6/xfs_iops.c 2007-07-21 23:58:49.000000000 +0200
10073 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_iops.c 2008-02-11 12:35:35.000000000 +0100
10075 #include <linux/xattr.h>
10076 #include <linux/namei.h>
10077 #include <linux/security.h>
10078 +#include <linux/vs_tag.h>
10081 * Get a XFS inode from a given vnode.
10082 @@ -400,6 +401,7 @@ xfs_vn_lookup(
10083 d_add(dentry, NULL);
10086 + dx_propagate_tag(nd, vn_to_inode(cvp));
10088 return d_splice_alias(vn_to_inode(cvp), dentry);
10090 @@ -657,6 +659,10 @@ xfs_vn_setattr(
10094 + error = inode_change_ok(inode, attr);
10098 if (ia_valid & ATTR_UID) {
10099 vattr.va_mask |= XFS_AT_UID;
10100 vattr.va_uid = attr->ia_uid;
10101 @@ -665,6 +671,10 @@ xfs_vn_setattr(
10102 vattr.va_mask |= XFS_AT_GID;
10103 vattr.va_gid = attr->ia_gid;
10105 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode)) {
10106 + vattr.va_mask |= XFS_AT_TAG;
10107 + vattr.va_tag = attr->ia_tag;
10109 if (ia_valid & ATTR_SIZE) {
10110 vattr.va_mask |= XFS_AT_SIZE;
10111 vattr.va_size = attr->ia_size;
10112 @@ -710,6 +720,42 @@ xfs_vn_truncate(
10116 +xfs_vn_sync_flags(struct inode *inode)
10118 + unsigned int oldflags, newflags;
10121 + bhv_vattr_t vattr;
10122 + bhv_vnode_t *vp = vn_from_inode(inode);
10124 + memset(&vattr, 0, sizeof vattr);
10126 + vattr.va_mask = XFS_AT_XFLAGS;
10127 + error = bhv_vop_getattr(vp, &vattr, 0, NULL);
10131 + oldflags = vattr.va_xflags;
10132 + newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
10133 + XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
10135 + if (IS_IMMUTABLE(inode))
10136 + newflags |= XFS_XFLAG_IMMUTABLE;
10137 + if (IS_IUNLINK(inode))
10138 + newflags |= XFS_XFLAG_IUNLINK;
10139 + if (IS_BARRIER(inode))
10140 + newflags |= XFS_XFLAG_BARRIER;
10142 + if (oldflags ^ newflags) {
10143 + vattr.va_xflags = newflags;
10144 + vattr.va_mask |= XFS_AT_XFLAGS;
10145 + error = bhv_vop_setattr(vp, &vattr, flags, NULL);
10147 + vn_revalidate(vp);
10153 struct dentry *dentry,
10155 @@ -822,6 +868,7 @@ const struct inode_operations xfs_inode_
10156 .getxattr = xfs_vn_getxattr,
10157 .listxattr = xfs_vn_listxattr,
10158 .removexattr = xfs_vn_removexattr,
10159 + .sync_flags = xfs_vn_sync_flags,
10162 const struct inode_operations xfs_dir_inode_operations = {
10163 @@ -841,6 +888,7 @@ const struct inode_operations xfs_dir_in
10164 .getxattr = xfs_vn_getxattr,
10165 .listxattr = xfs_vn_listxattr,
10166 .removexattr = xfs_vn_removexattr,
10167 + .sync_flags = xfs_vn_sync_flags,
10170 const struct inode_operations xfs_symlink_inode_operations = {
10171 @@ -854,4 +902,5 @@ const struct inode_operations xfs_symlin
10172 .getxattr = xfs_vn_getxattr,
10173 .listxattr = xfs_vn_listxattr,
10174 .removexattr = xfs_vn_removexattr,
10175 + .sync_flags = xfs_vn_sync_flags,
10177 diff -Nurp linux-2.6.22.18/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_linux.h
10178 --- linux-2.6.22.18/fs/xfs/linux-2.6/xfs_linux.h 2007-07-21 23:58:49.000000000 +0200
10179 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_linux.h 2008-02-11 12:35:35.000000000 +0100
10180 @@ -129,6 +129,7 @@
10181 #define current_pid() (current->pid)
10182 #define current_fsuid(cred) (current->fsuid)
10183 #define current_fsgid(cred) (current->fsgid)
10184 +#define current_fstag(cred,vp) (dx_current_fstag(vn_to_inode(vp)->i_sb))
10185 #define current_test_flags(f) (current->flags & (f))
10186 #define current_set_flags_nested(sp, f) \
10187 (*(sp) = current->flags, current->flags |= (f))
10188 diff -Nurp linux-2.6.22.18/fs/xfs/linux-2.6/xfs_super.c linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_super.c
10189 --- linux-2.6.22.18/fs/xfs/linux-2.6/xfs_super.c 2007-07-22 00:00:18.000000000 +0200
10190 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_super.c 2008-02-11 12:35:35.000000000 +0100
10191 @@ -157,6 +157,7 @@ xfs_revalidate_inode(
10192 inode->i_nlink = ip->i_d.di_nlink;
10193 inode->i_uid = ip->i_d.di_uid;
10194 inode->i_gid = ip->i_d.di_gid;
10195 + inode->i_tag = ip->i_d.di_tag;
10197 switch (inode->i_mode & S_IFMT) {
10199 @@ -184,6 +185,14 @@ xfs_revalidate_inode(
10200 inode->i_flags |= S_IMMUTABLE;
10202 inode->i_flags &= ~S_IMMUTABLE;
10203 + if (ip->i_d.di_flags & XFS_DIFLAG_IUNLINK)
10204 + inode->i_flags |= S_IUNLINK;
10206 + inode->i_flags &= ~S_IUNLINK;
10207 + if (ip->i_d.di_flags & XFS_DIFLAG_BARRIER)
10208 + inode->i_flags |= S_BARRIER;
10210 + inode->i_flags &= ~S_BARRIER;
10211 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
10212 inode->i_flags |= S_APPEND;
10214 @@ -712,6 +721,12 @@ xfs_fs_remount(
10217 error = bhv_vfs_parseargs(vfsp, options, args, 1);
10218 + if ((args->flags2 & XFSMNT2_TAGGED) &&
10219 + !(sb->s_flags & MS_TAGGED)) {
10220 + printk("XFS: %s: tagging not permitted on remount.\n",
10225 error = bhv_vfs_mntupdate(vfsp, flags, args);
10226 kmem_free(args, sizeof(*args));
10227 diff -Nurp linux-2.6.22.18/fs/xfs/linux-2.6/xfs_vnode.c linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_vnode.c
10228 --- linux-2.6.22.18/fs/xfs/linux-2.6/xfs_vnode.c 2007-07-21 23:58:49.000000000 +0200
10229 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_vnode.c 2008-02-11 12:35:35.000000000 +0100
10230 @@ -119,6 +119,7 @@ vn_revalidate_core(
10231 inode->i_nlink = vap->va_nlink;
10232 inode->i_uid = vap->va_uid;
10233 inode->i_gid = vap->va_gid;
10234 + inode->i_tag = vap->va_tag;
10235 inode->i_blocks = vap->va_nblocks;
10236 inode->i_mtime = vap->va_mtime;
10237 inode->i_ctime = vap->va_ctime;
10238 @@ -126,6 +127,14 @@ vn_revalidate_core(
10239 inode->i_flags |= S_IMMUTABLE;
10241 inode->i_flags &= ~S_IMMUTABLE;
10242 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10243 + inode->i_flags |= S_IUNLINK;
10245 + inode->i_flags &= ~S_IUNLINK;
10246 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10247 + inode->i_flags |= S_BARRIER;
10249 + inode->i_flags &= ~S_BARRIER;
10250 if (vap->va_xflags & XFS_XFLAG_APPEND)
10251 inode->i_flags |= S_APPEND;
10253 diff -Nurp linux-2.6.22.18/fs/xfs/linux-2.6/xfs_vnode.h linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_vnode.h
10254 --- linux-2.6.22.18/fs/xfs/linux-2.6/xfs_vnode.h 2007-07-22 00:00:18.000000000 +0200
10255 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/linux-2.6/xfs_vnode.h 2008-02-11 12:35:35.000000000 +0100
10256 @@ -350,6 +350,7 @@ typedef struct bhv_vattr {
10257 xfs_nlink_t va_nlink; /* number of references to file */
10258 uid_t va_uid; /* owner user id */
10259 gid_t va_gid; /* owner group id */
10260 + tag_t va_tag; /* owner group id */
10261 xfs_ino_t va_nodeid; /* file id */
10262 xfs_off_t va_size; /* file size in bytes */
10263 u_long va_blocksize; /* blocksize preferred for i/o */
10264 @@ -398,13 +399,15 @@ typedef struct bhv_vattr {
10265 #define XFS_AT_PROJID 0x04000000
10266 #define XFS_AT_SIZE_NOPERM 0x08000000
10267 #define XFS_AT_GENCOUNT 0x10000000
10268 +#define XFS_AT_TAG 0x20000000
10270 #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
10271 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
10272 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
10273 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
10274 XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
10275 - XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
10276 + XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT\
10279 #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
10280 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
10281 diff -Nurp linux-2.6.22.18/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.22.18-vs2.3.0.32/fs/xfs/quota/xfs_qm_syscalls.c
10282 --- linux-2.6.22.18/fs/xfs/quota/xfs_qm_syscalls.c 2007-07-22 00:00:18.000000000 +0200
10283 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/quota/xfs_qm_syscalls.c 2008-02-11 12:35:35.000000000 +0100
10287 #include <linux/capability.h>
10288 +#include <linux/vs_context.h>
10291 #include "xfs_fs.h"
10292 @@ -211,7 +212,7 @@ xfs_qm_scall_quotaoff(
10293 xfs_qoff_logitem_t *qoffstart;
10296 - if (!force && !capable(CAP_SYS_ADMIN))
10297 + if (!force && !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10298 return XFS_ERROR(EPERM);
10300 * No file system can have quotas enabled on disk but not in core.
10301 @@ -380,7 +381,7 @@ xfs_qm_scall_trunc_qfiles(
10305 - if (!capable(CAP_SYS_ADMIN))
10306 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10307 return XFS_ERROR(EPERM);
10309 if (!XFS_SB_VERSION_HASQUOTA(&mp->m_sb) || flags == 0) {
10310 @@ -425,7 +426,7 @@ xfs_qm_scall_quotaon(
10314 - if (!capable(CAP_SYS_ADMIN))
10315 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10316 return XFS_ERROR(EPERM);
10318 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
10319 @@ -594,7 +595,7 @@ xfs_qm_scall_setqlim(
10321 xfs_qcnt_t hard, soft;
10323 - if (!capable(CAP_SYS_ADMIN))
10324 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10325 return XFS_ERROR(EPERM);
10327 if ((newlim->d_fieldmask &
10328 diff -Nurp linux-2.6.22.18/fs/xfs/xfs_clnt.h linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_clnt.h
10329 --- linux-2.6.22.18/fs/xfs/xfs_clnt.h 2006-06-18 03:49:35.000000000 +0200
10330 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_clnt.h 2008-02-11 12:35:35.000000000 +0100
10331 @@ -99,5 +99,7 @@ struct xfs_mount_args {
10333 #define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred
10334 * I/O size in stat(2) */
10335 +#define XFSMNT2_TAGGED 0x80000000 /* context tagging */
10338 #endif /* __XFS_CLNT_H__ */
10339 diff -Nurp linux-2.6.22.18/fs/xfs/xfs_dinode.h linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_dinode.h
10340 --- linux-2.6.22.18/fs/xfs/xfs_dinode.h 2007-05-04 15:55:41.000000000 +0200
10341 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_dinode.h 2008-02-11 12:35:35.000000000 +0100
10342 @@ -53,7 +53,8 @@ typedef struct xfs_dinode_core
10343 __uint32_t di_gid; /* owner's group id */
10344 __uint32_t di_nlink; /* number of links to file */
10345 __uint16_t di_projid; /* owner's project id */
10346 - __uint8_t di_pad[8]; /* unused, zeroed space */
10347 + __uint16_t di_tag; /* context tagging */
10348 + __uint8_t di_pad[6]; /* unused, zeroed space */
10349 __uint16_t di_flushiter; /* incremented on flush */
10350 xfs_timestamp_t di_atime; /* time last accessed */
10351 xfs_timestamp_t di_mtime; /* time last modified */
10352 @@ -257,6 +258,9 @@ typedef enum xfs_dinode_fmt
10353 #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */
10354 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
10355 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
10356 +#define XFS_DIFLAG_BARRIER_BIT 14 /* chroot() barrier */
10357 +#define XFS_DIFLAG_IUNLINK_BIT 15 /* immutable unlink */
10359 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
10360 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
10361 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
10362 @@ -271,12 +275,15 @@ typedef enum xfs_dinode_fmt
10363 #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT)
10364 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
10365 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
10366 +#define XFS_DIFLAG_BARRIER (1 << XFS_DIFLAG_BARRIER_BIT)
10367 +#define XFS_DIFLAG_IUNLINK (1 << XFS_DIFLAG_IUNLINK_BIT)
10369 #define XFS_DIFLAG_ANY \
10370 (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
10371 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
10372 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
10373 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
10374 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG)
10375 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_BARRIER | \
10376 + XFS_DIFLAG_IUNLINK)
10378 #endif /* __XFS_DINODE_H__ */
10379 diff -Nurp linux-2.6.22.18/fs/xfs/xfs_fs.h linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_fs.h
10380 --- linux-2.6.22.18/fs/xfs/xfs_fs.h 2007-05-04 15:57:37.000000000 +0200
10381 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_fs.h 2008-02-11 12:35:35.000000000 +0100
10382 @@ -66,6 +66,8 @@ struct fsxattr {
10383 #define XFS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */
10384 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
10385 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
10386 +#define XFS_XFLAG_BARRIER 0x00004000 /* chroot() barrier */
10387 +#define XFS_XFLAG_IUNLINK 0x00008000 /* immutable unlink */
10388 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
10391 @@ -294,7 +296,8 @@ typedef struct xfs_bstat {
10392 __s32 bs_extents; /* number of extents */
10393 __u32 bs_gen; /* generation count */
10394 __u16 bs_projid; /* project id */
10395 - unsigned char bs_pad[14]; /* pad space, unused */
10396 + __u16 bs_tag; /* context tagging */
10397 + unsigned char bs_pad[12]; /* pad space, unused */
10398 __u32 bs_dmevmask; /* DMIG event mask */
10399 __u16 bs_dmstate; /* DMIG state info */
10400 __u16 bs_aextents; /* attribute number of extents */
10401 diff -Nurp linux-2.6.22.18/fs/xfs/xfs_inode.c linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_inode.c
10402 --- linux-2.6.22.18/fs/xfs/xfs_inode.c 2007-07-22 00:00:18.000000000 +0200
10403 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_inode.c 2008-02-11 12:35:35.000000000 +0100
10405 #include "xfs_quota.h"
10406 #include "xfs_acl.h"
10408 +#include <linux/vs_tag.h>
10410 kmem_zone_t *xfs_ifork_zone;
10411 kmem_zone_t *xfs_inode_zone;
10412 @@ -736,20 +737,35 @@ xfs_xlate_dinode_core(
10413 xfs_dinode_core_t *buf_core = (xfs_dinode_core_t *)buf;
10414 xfs_dinode_core_t *mem_core = (xfs_dinode_core_t *)dip;
10415 xfs_arch_t arch = ARCH_CONVERT;
10416 + uint32_t uid = 0, gid = 0;
10417 + uint16_t tag = 0;
10422 + tag = mem_core->di_tag;
10423 + /* FIXME: supposed to use superblock flag */
10424 + uid = TAGINO_UID(1, mem_core->di_uid, tag);
10425 + gid = TAGINO_GID(1, mem_core->di_gid, tag);
10426 + tag = TAGINO_TAG(1, tag);
10429 INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch);
10430 INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch);
10431 INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch);
10432 INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch);
10433 INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch);
10434 - INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch);
10435 - INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch);
10436 + INT_XLATE(buf_core->di_uid, uid, dir, arch);
10437 + INT_XLATE(buf_core->di_gid, gid, dir, arch);
10438 + INT_XLATE(buf_core->di_tag, tag, dir, arch);
10439 INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch);
10440 INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch);
10443 + /* FIXME: supposed to use superblock flag */
10444 + mem_core->di_uid = INOTAG_UID(1, uid, gid);
10445 + mem_core->di_gid = INOTAG_GID(1, uid, gid);
10446 + mem_core->di_tag = INOTAG_TAG(1, uid, gid, tag);
10447 memcpy(mem_core->di_pad, buf_core->di_pad,
10448 sizeof(buf_core->di_pad));
10450 @@ -797,6 +813,10 @@ _xfs_dic2xflags(
10451 flags |= XFS_XFLAG_PREALLOC;
10452 if (di_flags & XFS_DIFLAG_IMMUTABLE)
10453 flags |= XFS_XFLAG_IMMUTABLE;
10454 + if (di_flags & XFS_DIFLAG_IUNLINK)
10455 + flags |= XFS_XFLAG_IUNLINK;
10456 + if (di_flags & XFS_DIFLAG_BARRIER)
10457 + flags |= XFS_XFLAG_BARRIER;
10458 if (di_flags & XFS_DIFLAG_APPEND)
10459 flags |= XFS_XFLAG_APPEND;
10460 if (di_flags & XFS_DIFLAG_SYNC)
10461 @@ -1129,6 +1149,7 @@ xfs_ialloc(
10462 ASSERT(ip->i_d.di_nlink == nlink);
10463 ip->i_d.di_uid = current_fsuid(cr);
10464 ip->i_d.di_gid = current_fsgid(cr);
10465 + ip->i_d.di_tag = current_fstag(cr, vp);
10466 ip->i_d.di_projid = prid;
10467 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
10469 diff -Nurp linux-2.6.22.18/fs/xfs/xfs_itable.c linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_itable.c
10470 --- linux-2.6.22.18/fs/xfs/xfs_itable.c 2007-07-22 00:00:18.000000000 +0200
10471 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_itable.c 2008-02-11 12:35:35.000000000 +0100
10472 @@ -89,6 +89,7 @@ xfs_bulkstat_one_iget(
10473 buf->bs_mode = dic->di_mode;
10474 buf->bs_uid = dic->di_uid;
10475 buf->bs_gid = dic->di_gid;
10476 + buf->bs_tag = dic->di_tag;
10477 buf->bs_size = dic->di_size;
10478 vn_atime_to_bstime(vp, &buf->bs_atime);
10479 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
10480 @@ -163,6 +164,7 @@ xfs_bulkstat_one_dinode(
10481 buf->bs_mode = INT_GET(dic->di_mode, ARCH_CONVERT);
10482 buf->bs_uid = INT_GET(dic->di_uid, ARCH_CONVERT);
10483 buf->bs_gid = INT_GET(dic->di_gid, ARCH_CONVERT);
10484 + buf->bs_tag = INT_GET(dic->di_tag, ARCH_CONVERT);
10485 buf->bs_size = INT_GET(dic->di_size, ARCH_CONVERT);
10486 buf->bs_atime.tv_sec = INT_GET(dic->di_atime.t_sec, ARCH_CONVERT);
10487 buf->bs_atime.tv_nsec = INT_GET(dic->di_atime.t_nsec, ARCH_CONVERT);
10488 diff -Nurp linux-2.6.22.18/fs/xfs/xfs_mount.h linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_mount.h
10489 --- linux-2.6.22.18/fs/xfs/xfs_mount.h 2007-07-21 23:58:49.000000000 +0200
10490 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_mount.h 2008-02-11 12:35:35.000000000 +0100
10491 @@ -464,6 +464,7 @@ typedef struct xfs_mount {
10492 #define XFS_MOUNT_NO_PERCPU_SB (1ULL << 23) /* don't use per-cpu superblock
10495 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
10498 * Default minimum read and write sizes.
10499 diff -Nurp linux-2.6.22.18/fs/xfs/xfs_vfsops.c linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_vfsops.c
10500 --- linux-2.6.22.18/fs/xfs/xfs_vfsops.c 2007-07-22 00:00:18.000000000 +0200
10501 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_vfsops.c 2008-02-11 12:35:35.000000000 +0100
10502 @@ -300,6 +300,8 @@ xfs_start_flags(
10504 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
10505 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
10506 + if (ap->flags2 & XFSMNT2_TAGGED)
10507 + mp->m_flags |= XFS_MOUNT_TAGGED;
10510 * no recovery flag requires a read-only mount
10511 @@ -394,6 +396,8 @@ xfs_finish_flags(
10512 return XFS_ERROR(EINVAL);
10515 + if (ap->flags2 & XFSMNT2_TAGGED)
10516 + vfs->vfs_super->s_flags |= MS_TAGGED;
10520 @@ -1645,6 +1649,9 @@ xfs_vget(
10522 #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
10523 #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
10524 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
10525 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
10526 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
10528 STATIC unsigned long
10529 suffix_strtoul(char *s, char **endp, unsigned int base)
10530 @@ -1831,6 +1838,19 @@ xfs_parseargs(
10531 args->flags |= XFSMNT_ATTR2;
10532 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
10533 args->flags &= ~XFSMNT_ATTR2;
10534 +#ifndef CONFIG_TAGGING_NONE
10535 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
10536 + args->flags2 |= XFSMNT2_TAGGED;
10537 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
10538 + args->flags2 &= ~XFSMNT2_TAGGED;
10539 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
10540 + args->flags2 |= XFSMNT2_TAGGED;
10542 +#ifdef CONFIG_PROPAGATE
10543 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
10545 + args->flags2 |= XFSMNT2_TAGGED;
10547 } else if (!strcmp(this_char, "osyncisdsync")) {
10548 /* no-op, this is now the default */
10550 diff -Nurp linux-2.6.22.18/fs/xfs/xfs_vnodeops.c linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_vnodeops.c
10551 --- linux-2.6.22.18/fs/xfs/xfs_vnodeops.c 2007-07-22 00:00:18.000000000 +0200
10552 +++ linux-2.6.22.18-vs2.3.0.32/fs/xfs/xfs_vnodeops.c 2008-02-11 12:35:35.000000000 +0100
10553 @@ -159,6 +159,7 @@ xfs_getattr(
10554 vap->va_mode = ip->i_d.di_mode;
10555 vap->va_uid = ip->i_d.di_uid;
10556 vap->va_gid = ip->i_d.di_gid;
10557 + vap->va_tag = ip->i_d.di_tag;
10558 vap->va_projid = ip->i_d.di_projid;
10561 @@ -259,6 +260,7 @@ xfs_setattr(
10562 uint commit_flags=0;
10563 uid_t uid=0, iuid=0;
10564 gid_t gid=0, igid=0;
10565 + tag_t tag=0, itag=0;
10568 xfs_prid_t projid=0, iprojid=0;
10569 @@ -315,6 +317,7 @@ xfs_setattr(
10570 (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID))) {
10573 + /* TODO: handle tagging? */
10574 if ((mask & XFS_AT_UID) && XFS_IS_UQUOTA_ON(mp)) {
10576 qflags |= XFS_QMOPT_UQUOTA;
10577 @@ -394,6 +397,8 @@ xfs_setattr(
10579 (XFS_AT_MODE|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_UID|
10580 XFS_AT_GID|XFS_AT_PROJID)) {
10581 + /* TODO: handle tagging? */
10584 * CAP_FOWNER overrides the following restrictions:
10586 @@ -442,7 +447,7 @@ xfs_setattr(
10587 * and can change the group id only to a group of which he
10588 * or she is a member.
10590 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10591 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10593 * These IDs could have changed since we last looked at them.
10594 * But, we're assured that if the ownership did change
10595 @@ -450,10 +455,12 @@ xfs_setattr(
10596 * would have changed also.
10598 iuid = ip->i_d.di_uid;
10599 - iprojid = ip->i_d.di_projid;
10600 igid = ip->i_d.di_gid;
10601 - gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10602 + itag = ip->i_d.di_tag;
10603 + iprojid = ip->i_d.di_projid;
10604 uid = (mask & XFS_AT_UID) ? vap->va_uid : iuid;
10605 + gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10606 + tag = (mask & XFS_AT_TAG) ? vap->va_tag : itag;
10607 projid = (mask & XFS_AT_PROJID) ? (xfs_prid_t)vap->va_projid :
10610 @@ -481,6 +488,7 @@ xfs_setattr(
10611 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
10612 (XFS_IS_PQUOTA_ON(mp) && iprojid != projid) ||
10613 (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
10614 + /* TODO: handle tagging? */
10616 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
10617 capable(CAP_FOWNER) ?
10618 @@ -706,7 +714,7 @@ xfs_setattr(
10619 * and can change the group id only to a group of which he
10620 * or she is a member.
10622 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10623 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10625 * CAP_FSETID overrides the following restrictions:
10627 @@ -722,6 +730,9 @@ xfs_setattr(
10628 * Change the ownerships and register quota modifications
10629 * in the transaction.
10631 + if (itag != tag) {
10632 + ip->i_d.di_tag = tag;
10635 if (XFS_IS_UQUOTA_ON(mp)) {
10636 ASSERT(mask & XFS_AT_UID);
10637 @@ -802,6 +813,10 @@ xfs_setattr(
10638 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
10639 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
10640 di_flags |= XFS_DIFLAG_IMMUTABLE;
10641 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10642 + di_flags |= XFS_DIFLAG_IUNLINK;
10643 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10644 + di_flags |= XFS_DIFLAG_BARRIER;
10645 if (vap->va_xflags & XFS_XFLAG_APPEND)
10646 di_flags |= XFS_DIFLAG_APPEND;
10647 if (vap->va_xflags & XFS_XFLAG_SYNC)
10648 diff -Nurp linux-2.6.22.18/include/asm-alpha/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-alpha/socket.h
10649 --- linux-2.6.22.18/include/asm-alpha/socket.h 2007-07-22 00:00:18.000000000 +0200
10650 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-alpha/socket.h 2008-02-11 12:35:35.000000000 +0100
10652 #define SO_TIMESTAMPNS 35
10653 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10655 +#define SO_PEERTAG 36
10657 /* Security levels - as per NRL IPv6 - don't actually do anything */
10658 #define SO_SECURITY_AUTHENTICATION 19
10659 #define SO_SECURITY_ENCRYPTION_TRANSPORT 20
10660 diff -Nurp linux-2.6.22.18/include/asm-arm/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-arm/socket.h
10661 --- linux-2.6.22.18/include/asm-arm/socket.h 2007-07-22 00:00:19.000000000 +0200
10662 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-arm/socket.h 2008-02-11 12:35:35.000000000 +0100
10664 #define SO_TIMESTAMPNS 35
10665 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10667 +#define SO_PEERTAG 36
10669 #endif /* _ASM_SOCKET_H */
10670 diff -Nurp linux-2.6.22.18/include/asm-arm/tlb.h linux-2.6.22.18-vs2.3.0.32/include/asm-arm/tlb.h
10671 --- linux-2.6.22.18/include/asm-arm/tlb.h 2006-06-18 03:49:35.000000000 +0200
10672 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-arm/tlb.h 2008-02-11 12:35:35.000000000 +0100
10674 #else /* !CONFIG_MMU */
10676 #include <asm/pgalloc.h>
10677 +#include <linux/vs_memory.h>
10680 * TLB handling. This allows us to remove pages from the page
10681 diff -Nurp linux-2.6.22.18/include/asm-arm26/tlb.h linux-2.6.22.18-vs2.3.0.32/include/asm-arm26/tlb.h
10682 --- linux-2.6.22.18/include/asm-arm26/tlb.h 2006-06-18 03:49:35.000000000 +0200
10683 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-arm26/tlb.h 2008-02-11 12:35:35.000000000 +0100
10686 #include <asm/pgalloc.h>
10687 #include <asm/tlbflush.h>
10688 +#include <linux/vs_memory.h>
10691 * TLB handling. This allows us to remove pages from the page
10692 diff -Nurp linux-2.6.22.18/include/asm-arm26/unistd.h linux-2.6.22.18-vs2.3.0.32/include/asm-arm26/unistd.h
10693 --- linux-2.6.22.18/include/asm-arm26/unistd.h 2007-05-04 15:58:22.000000000 +0200
10694 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-arm26/unistd.h 2008-02-11 12:35:35.000000000 +0100
10695 @@ -302,6 +302,8 @@
10696 #define __NR_mq_getsetattr (__NR_SYSCALL_BASE+279)
10697 #define __NR_waitid (__NR_SYSCALL_BASE+280)
10699 +#define __NR_vserver (__NR_SYSCALL_BASE+313)
10702 * The following SWIs are ARM private. FIXME - make appropriate for arm26
10704 diff -Nurp linux-2.6.22.18/include/asm-cris/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-cris/socket.h
10705 --- linux-2.6.22.18/include/asm-cris/socket.h 2007-07-22 00:00:19.000000000 +0200
10706 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-cris/socket.h 2008-02-11 12:35:35.000000000 +0100
10708 #define SO_TIMESTAMPNS 35
10709 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10711 +#define SO_PEERTAG 36
10713 #endif /* _ASM_SOCKET_H */
10716 diff -Nurp linux-2.6.22.18/include/asm-frv/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-frv/socket.h
10717 --- linux-2.6.22.18/include/asm-frv/socket.h 2007-07-22 00:00:19.000000000 +0200
10718 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-frv/socket.h 2008-02-11 12:35:35.000000000 +0100
10720 #define SO_TIMESTAMPNS 35
10721 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10723 +#define SO_PEERTAG 36
10725 #endif /* _ASM_SOCKET_H */
10727 diff -Nurp linux-2.6.22.18/include/asm-generic/tlb.h linux-2.6.22.18-vs2.3.0.32/include/asm-generic/tlb.h
10728 --- linux-2.6.22.18/include/asm-generic/tlb.h 2007-05-04 15:57:38.000000000 +0200
10729 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-generic/tlb.h 2008-02-11 12:35:35.000000000 +0100
10731 #define _ASM_GENERIC__TLB_H
10733 #include <linux/swap.h>
10734 +#include <linux/vs_memory.h>
10735 #include <asm/pgalloc.h>
10736 #include <asm/tlbflush.h>
10738 diff -Nurp linux-2.6.22.18/include/asm-h8300/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-h8300/socket.h
10739 --- linux-2.6.22.18/include/asm-h8300/socket.h 2007-07-22 00:00:19.000000000 +0200
10740 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-h8300/socket.h 2008-02-11 12:35:35.000000000 +0100
10742 #define SO_TIMESTAMPNS 35
10743 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10745 +#define SO_PEERTAG 36
10747 #endif /* _ASM_SOCKET_H */
10748 diff -Nurp linux-2.6.22.18/include/asm-i386/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-i386/socket.h
10749 --- linux-2.6.22.18/include/asm-i386/socket.h 2007-07-22 00:00:19.000000000 +0200
10750 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-i386/socket.h 2008-02-11 12:35:35.000000000 +0100
10752 #define SO_TIMESTAMPNS 35
10753 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10755 +#define SO_PEERTAG 36
10757 #endif /* _ASM_SOCKET_H */
10758 diff -Nurp linux-2.6.22.18/include/asm-ia64/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-ia64/socket.h
10759 --- linux-2.6.22.18/include/asm-ia64/socket.h 2007-07-22 00:00:19.000000000 +0200
10760 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-ia64/socket.h 2008-02-11 12:35:35.000000000 +0100
10762 #define SO_TIMESTAMPNS 35
10763 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10765 +#define SO_PEERTAG 36
10767 #endif /* _ASM_IA64_SOCKET_H */
10768 diff -Nurp linux-2.6.22.18/include/asm-ia64/tlb.h linux-2.6.22.18-vs2.3.0.32/include/asm-ia64/tlb.h
10769 --- linux-2.6.22.18/include/asm-ia64/tlb.h 2007-05-04 15:55:44.000000000 +0200
10770 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-ia64/tlb.h 2008-02-11 12:35:35.000000000 +0100
10772 #include <linux/mm.h>
10773 #include <linux/pagemap.h>
10774 #include <linux/swap.h>
10775 +#include <linux/vs_memory.h>
10777 #include <asm/pgalloc.h>
10778 #include <asm/processor.h>
10779 diff -Nurp linux-2.6.22.18/include/asm-m32r/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-m32r/socket.h
10780 --- linux-2.6.22.18/include/asm-m32r/socket.h 2007-07-22 00:00:19.000000000 +0200
10781 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-m32r/socket.h 2008-02-11 12:35:35.000000000 +0100
10783 #define SO_TIMESTAMPNS 35
10784 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10786 +#define SO_PEERTAG 36
10788 #endif /* _ASM_M32R_SOCKET_H */
10789 diff -Nurp linux-2.6.22.18/include/asm-mips/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-mips/socket.h
10790 --- linux-2.6.22.18/include/asm-mips/socket.h 2007-07-22 00:00:19.000000000 +0200
10791 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-mips/socket.h 2008-02-11 12:35:35.000000000 +0100
10792 @@ -73,6 +73,8 @@ To add: #define SO_REUSEPORT 0x0200 /* A
10793 #define SO_TIMESTAMPNS 35
10794 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10796 +#define SO_PEERTAG 36
10800 /** sock_type - Socket types
10801 diff -Nurp linux-2.6.22.18/include/asm-parisc/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-parisc/socket.h
10802 --- linux-2.6.22.18/include/asm-parisc/socket.h 2007-07-22 00:00:20.000000000 +0200
10803 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-parisc/socket.h 2008-02-11 12:35:35.000000000 +0100
10806 #define SO_PEERSEC 0x401d
10807 #define SO_PASSSEC 0x401e
10808 +#define SO_PEERTAG 0x401f
10810 #endif /* _ASM_SOCKET_H */
10811 diff -Nurp linux-2.6.22.18/include/asm-powerpc/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-powerpc/socket.h
10812 --- linux-2.6.22.18/include/asm-powerpc/socket.h 2007-07-22 00:00:20.000000000 +0200
10813 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-powerpc/socket.h 2008-02-11 12:35:35.000000000 +0100
10815 #define SO_TIMESTAMPNS 35
10816 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10818 +#define SO_PEERTAG 36
10820 #endif /* _ASM_POWERPC_SOCKET_H */
10821 diff -Nurp linux-2.6.22.18/include/asm-powerpc/systbl.h linux-2.6.22.18-vs2.3.0.32/include/asm-powerpc/systbl.h
10822 --- linux-2.6.22.18/include/asm-powerpc/systbl.h 2007-07-22 00:00:20.000000000 +0200
10823 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-powerpc/systbl.h 2008-02-11 12:35:35.000000000 +0100
10824 @@ -260,7 +260,7 @@ COMPAT_SYS_SPU(fstatfs64)
10825 SYSX(sys_ni_syscall, ppc_fadvise64_64, ppc_fadvise64_64)
10827 OLDSYS(debug_setcontext)
10828 -SYSCALL(ni_syscall)
10829 +SYSX(sys_vserver, sys32_vserver, sys_vserver)
10830 COMPAT_SYS(migrate_pages)
10832 COMPAT_SYS(get_mempolicy)
10833 diff -Nurp linux-2.6.22.18/include/asm-powerpc/unistd.h linux-2.6.22.18-vs2.3.0.32/include/asm-powerpc/unistd.h
10834 --- linux-2.6.22.18/include/asm-powerpc/unistd.h 2007-07-22 00:00:20.000000000 +0200
10835 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-powerpc/unistd.h 2008-02-11 12:35:35.000000000 +0100
10836 @@ -275,7 +275,7 @@
10838 #define __NR_rtas 255
10839 #define __NR_sys_debug_setcontext 256
10840 -/* Number 257 is reserved for vserver */
10841 +#define __NR_vserver 257
10842 #define __NR_migrate_pages 258
10843 #define __NR_mbind 259
10844 #define __NR_get_mempolicy 260
10845 diff -Nurp linux-2.6.22.18/include/asm-s390/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-s390/socket.h
10846 --- linux-2.6.22.18/include/asm-s390/socket.h 2007-07-22 00:00:20.000000000 +0200
10847 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-s390/socket.h 2008-02-11 12:35:35.000000000 +0100
10849 #define SO_TIMESTAMPNS 35
10850 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10852 +#define SO_PEERTAG 36
10854 #endif /* _ASM_SOCKET_H */
10855 diff -Nurp linux-2.6.22.18/include/asm-s390/unistd.h linux-2.6.22.18-vs2.3.0.32/include/asm-s390/unistd.h
10856 --- linux-2.6.22.18/include/asm-s390/unistd.h 2007-07-22 00:00:20.000000000 +0200
10857 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-s390/unistd.h 2008-02-11 12:35:35.000000000 +0100
10858 @@ -202,7 +202,7 @@
10859 #define __NR_clock_gettime (__NR_timer_create+6)
10860 #define __NR_clock_getres (__NR_timer_create+7)
10861 #define __NR_clock_nanosleep (__NR_timer_create+8)
10862 -/* Number 263 is reserved for vserver */
10863 +#define __NR_vserver 263
10864 #define __NR_statfs64 265
10865 #define __NR_fstatfs64 266
10866 #define __NR_remap_file_pages 267
10867 diff -Nurp linux-2.6.22.18/include/asm-sh/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-sh/socket.h
10868 --- linux-2.6.22.18/include/asm-sh/socket.h 2007-07-22 00:00:20.000000000 +0200
10869 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-sh/socket.h 2008-02-11 12:35:35.000000000 +0100
10871 #define SO_TIMESTAMPNS 35
10872 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10874 +#define SO_PEERTAG 36
10876 #endif /* __ASM_SH_SOCKET_H */
10877 diff -Nurp linux-2.6.22.18/include/asm-sparc/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-sparc/socket.h
10878 --- linux-2.6.22.18/include/asm-sparc/socket.h 2007-07-22 00:00:20.000000000 +0200
10879 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-sparc/socket.h 2008-02-11 12:35:35.000000000 +0100
10881 #define SO_TIMESTAMPNS 0x0021
10882 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10884 +#define SO_PEERTAG 36
10886 /* Security levels - as per NRL IPv6 - don't actually do anything */
10887 #define SO_SECURITY_AUTHENTICATION 0x5001
10888 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
10889 diff -Nurp linux-2.6.22.18/include/asm-sparc/unistd.h linux-2.6.22.18-vs2.3.0.32/include/asm-sparc/unistd.h
10890 --- linux-2.6.22.18/include/asm-sparc/unistd.h 2007-07-22 00:00:20.000000000 +0200
10891 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-sparc/unistd.h 2008-02-11 12:35:35.000000000 +0100
10892 @@ -283,7 +283,7 @@
10893 #define __NR_timer_getoverrun 264
10894 #define __NR_timer_delete 265
10895 #define __NR_timer_create 266
10896 -/* #define __NR_vserver 267 Reserved for VSERVER */
10897 +#define __NR_vserver 267
10898 #define __NR_io_setup 268
10899 #define __NR_io_destroy 269
10900 #define __NR_io_submit 270
10901 diff -Nurp linux-2.6.22.18/include/asm-sparc64/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-sparc64/socket.h
10902 --- linux-2.6.22.18/include/asm-sparc64/socket.h 2007-07-22 00:00:20.000000000 +0200
10903 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-sparc64/socket.h 2008-02-11 12:35:35.000000000 +0100
10905 #define SO_TIMESTAMPNS 0x0021
10906 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10908 +#define SO_PEERTAG 0x0022
10910 /* Security levels - as per NRL IPv6 - don't actually do anything */
10911 #define SO_SECURITY_AUTHENTICATION 0x5001
10912 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
10913 diff -Nurp linux-2.6.22.18/include/asm-sparc64/tlb.h linux-2.6.22.18-vs2.3.0.32/include/asm-sparc64/tlb.h
10914 --- linux-2.6.22.18/include/asm-sparc64/tlb.h 2007-07-22 00:00:20.000000000 +0200
10915 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-sparc64/tlb.h 2008-02-11 12:35:35.000000000 +0100
10918 #include <linux/swap.h>
10919 #include <linux/pagemap.h>
10920 +#include <linux/vs_memory.h>
10921 #include <asm/pgalloc.h>
10922 #include <asm/tlbflush.h>
10923 #include <asm/mmu_context.h>
10924 diff -Nurp linux-2.6.22.18/include/asm-sparc64/unistd.h linux-2.6.22.18-vs2.3.0.32/include/asm-sparc64/unistd.h
10925 --- linux-2.6.22.18/include/asm-sparc64/unistd.h 2007-07-22 00:00:20.000000000 +0200
10926 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-sparc64/unistd.h 2008-02-11 12:35:35.000000000 +0100
10927 @@ -285,7 +285,7 @@
10928 #define __NR_timer_getoverrun 264
10929 #define __NR_timer_delete 265
10930 #define __NR_timer_create 266
10931 -/* #define __NR_vserver 267 Reserved for VSERVER */
10932 +#define __NR_vserver 267
10933 #define __NR_io_setup 268
10934 #define __NR_io_destroy 269
10935 #define __NR_io_submit 270
10936 diff -Nurp linux-2.6.22.18/include/asm-v850/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-v850/socket.h
10937 --- linux-2.6.22.18/include/asm-v850/socket.h 2007-07-22 00:00:20.000000000 +0200
10938 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-v850/socket.h 2008-02-11 12:35:35.000000000 +0100
10940 #define SO_TIMESTAMPNS 35
10941 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10943 +#define SO_PEERTAG 36
10945 #endif /* __V850_SOCKET_H__ */
10946 diff -Nurp linux-2.6.22.18/include/asm-x86_64/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-x86_64/socket.h
10947 --- linux-2.6.22.18/include/asm-x86_64/socket.h 2007-07-22 00:00:20.000000000 +0200
10948 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-x86_64/socket.h 2008-02-11 12:35:35.000000000 +0100
10950 #define SO_TIMESTAMPNS 35
10951 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10953 +#define SO_PEERTAG 36
10955 #endif /* _ASM_SOCKET_H */
10956 diff -Nurp linux-2.6.22.18/include/asm-x86_64/unistd.h linux-2.6.22.18-vs2.3.0.32/include/asm-x86_64/unistd.h
10957 --- linux-2.6.22.18/include/asm-x86_64/unistd.h 2007-07-22 00:00:20.000000000 +0200
10958 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-x86_64/unistd.h 2008-02-11 12:35:35.000000000 +0100
10959 @@ -532,7 +532,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
10960 #define __NR_utimes 235
10961 __SYSCALL(__NR_utimes, sys_utimes)
10962 #define __NR_vserver 236
10963 -__SYSCALL(__NR_vserver, sys_ni_syscall)
10964 +__SYSCALL(__NR_vserver, sys_vserver)
10965 #define __NR_mbind 237
10966 __SYSCALL(__NR_mbind, sys_mbind)
10967 #define __NR_set_mempolicy 238
10968 diff -Nurp linux-2.6.22.18/include/asm-xtensa/socket.h linux-2.6.22.18-vs2.3.0.32/include/asm-xtensa/socket.h
10969 --- linux-2.6.22.18/include/asm-xtensa/socket.h 2007-07-22 00:00:20.000000000 +0200
10970 +++ linux-2.6.22.18-vs2.3.0.32/include/asm-xtensa/socket.h 2008-02-11 12:35:35.000000000 +0100
10972 #define SO_TIMESTAMPNS 35
10973 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10975 +#define SO_PEERTAG 36
10977 #endif /* _XTENSA_SOCKET_H */
10978 diff -Nurp linux-2.6.22.18/include/linux/capability.h linux-2.6.22.18-vs2.3.0.32/include/linux/capability.h
10979 --- linux-2.6.22.18/include/linux/capability.h 2007-07-22 00:00:20.000000000 +0200
10980 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/capability.h 2008-02-11 12:35:35.000000000 +0100
10981 @@ -237,6 +237,7 @@ typedef __u32 kernel_cap_t;
10982 arbitrary SCSI commands */
10983 /* Allow setting encryption key on loopback filesystem */
10984 /* Allow setting zone reclaim policy */
10985 +/* Allow the selection of a security context */
10987 #define CAP_SYS_ADMIN 21
10989 @@ -290,6 +291,11 @@ typedef __u32 kernel_cap_t;
10991 #define CAP_AUDIT_CONTROL 30
10993 +/* Allow context manipulations */
10994 +/* Allow changing context info on files */
10996 +#define CAP_CONTEXT 31
11001 diff -Nurp linux-2.6.22.18/include/linux/devpts_fs.h linux-2.6.22.18-vs2.3.0.32/include/linux/devpts_fs.h
11002 --- linux-2.6.22.18/include/linux/devpts_fs.h 2006-06-18 03:49:35.000000000 +0200
11003 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/devpts_fs.h 2008-02-11 12:35:35.000000000 +0100
11004 @@ -30,5 +30,4 @@ static inline void devpts_pty_kill(int n
11009 #endif /* _LINUX_DEVPTS_FS_H */
11010 diff -Nurp linux-2.6.22.18/include/linux/ext2_fs.h linux-2.6.22.18-vs2.3.0.32/include/linux/ext2_fs.h
11011 --- linux-2.6.22.18/include/linux/ext2_fs.h 2007-05-04 15:57:41.000000000 +0200
11012 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/ext2_fs.h 2008-02-11 12:35:35.000000000 +0100
11013 @@ -188,6 +188,8 @@ struct ext2_group_desc
11014 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
11015 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
11016 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
11017 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
11018 +#define EXT2_IUNLINK_FL FS_IUNLINK_FL /* Immutable unlink */
11019 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
11021 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
11022 @@ -244,7 +246,7 @@ struct ext2_inode {
11024 __u8 l_i_frag; /* Fragment number */
11025 __u8 l_i_fsize; /* Fragment size */
11027 + __u16 l_i_tag; /* Context Tag */
11028 __le16 l_i_uid_high; /* these 2 fields */
11029 __le16 l_i_gid_high; /* were reserved2[0] */
11030 __u32 l_i_reserved2;
11031 @@ -276,6 +278,7 @@ struct ext2_inode {
11032 #define i_gid_low i_gid
11033 #define i_uid_high osd2.linux2.l_i_uid_high
11034 #define i_gid_high osd2.linux2.l_i_gid_high
11035 +#define i_raw_tag osd2.linux2.l_i_tag
11036 #define i_reserved2 osd2.linux2.l_i_reserved2
11039 @@ -317,8 +320,9 @@ struct ext2_inode {
11040 #define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */
11041 #define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */
11042 #define EXT2_MOUNT_XIP 0x010000 /* Execute in place */
11043 -#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
11044 -#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
11045 +#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
11046 +#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
11047 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11050 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
11051 diff -Nurp linux-2.6.22.18/include/linux/ext3_fs.h linux-2.6.22.18-vs2.3.0.32/include/linux/ext3_fs.h
11052 --- linux-2.6.22.18/include/linux/ext3_fs.h 2007-07-22 00:00:20.000000000 +0200
11053 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/ext3_fs.h 2008-02-11 12:35:35.000000000 +0100
11054 @@ -177,6 +177,8 @@ struct ext3_group_desc
11055 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
11056 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
11057 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11058 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11059 +#define EXT3_IUNLINK_FL 0x08000000 /* Immutable unlink */
11060 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
11062 #define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
11063 @@ -296,7 +298,7 @@ struct ext3_inode {
11065 __u8 l_i_frag; /* Fragment number */
11066 __u8 l_i_fsize; /* Fragment size */
11068 + __u16 l_i_tag; /* Context Tag */
11069 __le16 l_i_uid_high; /* these 2 fields */
11070 __le16 l_i_gid_high; /* were reserved2[0] */
11071 __u32 l_i_reserved2;
11072 @@ -330,6 +332,7 @@ struct ext3_inode {
11073 #define i_gid_low i_gid
11074 #define i_uid_high osd2.linux2.l_i_uid_high
11075 #define i_gid_high osd2.linux2.l_i_gid_high
11076 +#define i_raw_tag osd2.linux2.l_i_tag
11077 #define i_reserved2 osd2.linux2.l_i_reserved2
11079 #elif defined(__GNU__)
11080 @@ -384,6 +387,7 @@ struct ext3_inode {
11081 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
11082 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
11083 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
11084 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11086 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
11087 #ifndef _LINUX_EXT2_FS_H
11088 @@ -812,6 +816,7 @@ struct buffer_head * ext3_bread (handle_
11089 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
11090 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
11091 int create, int extend_disksize);
11092 +extern int ext3_sync_flags(struct inode *inode);
11094 extern void ext3_read_inode (struct inode *);
11095 extern int ext3_write_inode (struct inode *, int);
11096 diff -Nurp linux-2.6.22.18/include/linux/ext4_fs.h linux-2.6.22.18-vs2.3.0.32/include/linux/ext4_fs.h
11097 --- linux-2.6.22.18/include/linux/ext4_fs.h 2007-07-22 00:00:22.000000000 +0200
11098 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/ext4_fs.h 2008-02-11 12:35:35.000000000 +0100
11099 @@ -189,8 +189,10 @@ struct ext4_group_desc
11100 #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
11101 #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
11102 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11103 -#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
11104 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
11105 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11106 +#define EXT4_IUNLINK_FL 0x08000000 /* Immutable unlink */
11107 +#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
11109 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
11110 #define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
11111 @@ -312,7 +314,8 @@ struct ext4_inode {
11112 __le16 l_i_file_acl_high;
11113 __le16 l_i_uid_high; /* these 2 fields */
11114 __le16 l_i_gid_high; /* were reserved2[0] */
11115 - __u32 l_i_reserved2;
11116 + __u16 l_i_tag; /* Context Tag */
11117 + __u16 l_i_reserved2;
11120 __u8 h_i_frag; /* Fragment number */
11121 @@ -344,6 +347,7 @@ struct ext4_inode {
11122 #define i_gid_low i_gid
11123 #define i_uid_high osd2.linux2.l_i_uid_high
11124 #define i_gid_high osd2.linux2.l_i_gid_high
11125 +#define i_raw_tag osd2.linux2.l_i_tag
11126 #define i_reserved2 osd2.linux2.l_i_reserved2
11128 #elif defined(__GNU__)
11129 @@ -400,6 +404,7 @@ struct ext4_inode {
11130 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
11131 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
11132 #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
11133 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11135 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
11136 #ifndef _LINUX_EXT2_FS_H
11137 @@ -850,6 +855,7 @@ struct buffer_head * ext4_bread (handle_
11138 int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
11139 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
11140 int create, int extend_disksize);
11141 +extern int ext4_sync_flags(struct inode *inode);
11143 extern void ext4_read_inode (struct inode *);
11144 extern int ext4_write_inode (struct inode *, int);
11145 diff -Nurp linux-2.6.22.18/include/linux/fs.h linux-2.6.22.18-vs2.3.0.32/include/linux/fs.h
11146 --- linux-2.6.22.18/include/linux/fs.h 2007-07-22 00:00:23.000000000 +0200
11147 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/fs.h 2008-02-11 12:35:35.000000000 +0100
11148 @@ -123,6 +123,8 @@ extern int dir_notify_enable;
11149 #define MS_SLAVE (1<<19) /* change to slave */
11150 #define MS_SHARED (1<<20) /* change to shared */
11151 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
11152 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
11153 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
11154 #define MS_ACTIVE (1<<30)
11155 #define MS_NOUSER (1<<31)
11157 @@ -149,6 +151,8 @@ extern int dir_notify_enable;
11158 #define S_NOCMTIME 128 /* Do not update file c/mtime */
11159 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
11160 #define S_PRIVATE 512 /* Inode is fs-internal */
11161 +#define S_BARRIER 1024 /* Barrier for chroot() */
11162 +#define S_IUNLINK 2048 /* Immutable unlink */
11165 * Note that nosuid etc flags are inode-specific: setting some file-system
11166 @@ -165,24 +169,36 @@ extern int dir_notify_enable;
11168 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
11170 -#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
11171 +#define IS_RDONLY(inode) __IS_FLG(inode, MS_RDONLY)
11172 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
11173 ((inode)->i_flags & S_SYNC))
11174 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
11175 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
11176 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
11177 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
11178 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
11179 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
11181 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
11182 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
11183 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
11184 +#define IS_IUNLINK(inode) ((inode)->i_flags & S_IUNLINK)
11185 +#define IS_IXORUNLINK(inode) ((IS_IUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
11186 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
11188 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_flags & S_BARRIER))
11189 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
11190 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
11191 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
11192 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
11194 +#ifdef CONFIG_VSERVER_COWBL
11195 +# define IS_COW(inode) (IS_IUNLINK(inode) && IS_IMMUTABLE(inode))
11196 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
11198 +# define IS_COW(inode) (0)
11199 +# define IS_COW_LINK(inode) (0)
11202 /* the read-only stuff doesn't really belong here, but any other place is
11203 probably as bad and I don't want to create yet another include file. */
11205 @@ -256,12 +272,13 @@ extern int dir_notify_enable;
11206 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11207 #define FS_EXTENT_FL 0x00080000 /* Extents */
11208 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
11209 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11210 +#define FS_IUNLINK_FL 0x08000000 /* Immutable unlink */
11211 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
11213 #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
11214 #define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
11217 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
11218 #define SYNC_FILE_RANGE_WRITE 2
11219 #define SYNC_FILE_RANGE_WAIT_AFTER 4
11220 @@ -327,6 +344,7 @@ typedef void (dio_iodone_t)(struct kiocb
11221 #define ATTR_KILL_SUID 2048
11222 #define ATTR_KILL_SGID 4096
11223 #define ATTR_FILE 8192
11224 +#define ATTR_TAG 16384
11227 * This is the Inode Attributes structure, used for notify_change(). It
11228 @@ -342,6 +360,7 @@ struct iattr {
11234 struct timespec ia_atime;
11235 struct timespec ia_mtime;
11236 @@ -355,6 +374,9 @@ struct iattr {
11237 struct file *ia_file;
11240 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
11241 +#define ATTR_FLAG_IUNLINK 1024 /* Immutable unlink */
11244 * Includes for diskquotas.
11246 @@ -537,7 +559,9 @@ struct inode {
11247 unsigned int i_nlink;
11253 unsigned long i_version;
11255 #ifdef __NEED_I_SIZE_ORDERED
11256 @@ -672,12 +696,12 @@ static inline void i_size_write(struct i
11258 static inline unsigned iminor(const struct inode *inode)
11260 - return MINOR(inode->i_rdev);
11261 + return MINOR(inode->i_mdev);
11264 static inline unsigned imajor(const struct inode *inode)
11266 - return MAJOR(inode->i_rdev);
11267 + return MAJOR(inode->i_mdev);
11270 extern struct block_device *I_BDEV(struct inode *inode);
11271 @@ -728,6 +752,7 @@ struct file {
11273 struct fown_struct f_owner;
11274 unsigned int f_uid, f_gid;
11276 struct file_ra_state f_ra;
11278 unsigned long f_version;
11279 @@ -811,6 +836,7 @@ struct file_lock {
11280 unsigned char fl_type;
11285 struct fasync_struct * fl_fasync; /* for lease break notifications */
11286 unsigned long fl_break_time; /* for nonblocking lease breaks */
11287 @@ -993,12 +1019,12 @@ extern void unlock_super(struct super_bl
11289 extern int vfs_permission(struct nameidata *, int);
11290 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
11291 -extern int vfs_mkdir(struct inode *, struct dentry *, int);
11292 -extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
11293 -extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
11294 -extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
11295 -extern int vfs_rmdir(struct inode *, struct dentry *);
11296 -extern int vfs_unlink(struct inode *, struct dentry *);
11297 +extern int vfs_mkdir(struct inode *, struct dentry *, int, struct nameidata *);
11298 +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t, struct nameidata *);
11299 +extern int vfs_symlink(struct inode *, struct dentry *, const char *, int, struct nameidata *);
11300 +extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct nameidata *);
11301 +extern int vfs_rmdir(struct inode *, struct dentry *, struct nameidata *);
11302 +extern int vfs_unlink(struct inode *, struct dentry *, struct nameidata *);
11303 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
11306 @@ -1138,6 +1164,7 @@ struct inode_operations {
11307 ssize_t (*listxattr) (struct dentry *, char *, size_t);
11308 int (*removexattr) (struct dentry *, const char *);
11309 void (*truncate_range)(struct inode *, loff_t, loff_t);
11310 + int (*sync_flags) (struct inode *);
11314 @@ -1153,6 +1180,7 @@ extern ssize_t vfs_readv(struct file *,
11315 unsigned long, loff_t *);
11316 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
11317 unsigned long, loff_t *);
11318 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
11321 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
11322 @@ -1898,6 +1926,7 @@ extern int dcache_dir_open(struct inode
11323 extern int dcache_dir_close(struct inode *, struct file *);
11324 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
11325 extern int dcache_readdir(struct file *, void *, filldir_t);
11326 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
11327 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
11328 extern int simple_statfs(struct dentry *, struct kstatfs *);
11329 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
11330 diff -Nurp linux-2.6.22.18/include/linux/init_task.h linux-2.6.22.18-vs2.3.0.32/include/linux/init_task.h
11331 --- linux-2.6.22.18/include/linux/init_task.h 2007-07-22 00:00:23.000000000 +0200
11332 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/init_task.h 2008-02-11 12:35:35.000000000 +0100
11333 @@ -169,6 +169,10 @@ extern struct group_info init_groups;
11335 INIT_TRACE_IRQFLAGS \
11338 + .vx_info = NULL, \
11340 + .nx_info = NULL, \
11344 diff -Nurp linux-2.6.22.18/include/linux/ipc.h linux-2.6.22.18-vs2.3.0.32/include/linux/ipc.h
11345 --- linux-2.6.22.18/include/linux/ipc.h 2007-07-22 00:00:23.000000000 +0200
11346 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/ipc.h 2008-02-11 12:35:35.000000000 +0100
11347 @@ -63,6 +63,7 @@ struct kern_ipc_perm
11355 diff -Nurp linux-2.6.22.18/include/linux/jffs2.h linux-2.6.22.18-vs2.3.0.32/include/linux/jffs2.h
11356 --- linux-2.6.22.18/include/linux/jffs2.h 2007-05-04 15:57:43.000000000 +0200
11357 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/jffs2.h 2008-02-11 12:35:36.000000000 +0100
11358 @@ -82,12 +82,36 @@
11359 //#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
11362 -#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
11363 +#define JFFS2_INO_FLAG_PREREAD 0x01 /* Do read_inode() for this one at
11364 mount time, don't wait for it to
11366 -#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
11367 +#define JFFS2_INO_FLAG_USERCOMPR 0x02 /* User has requested a specific
11368 compression type */
11370 +#define JFFS2_INO_FLAG_IMMUTABLE 0x10 /* immutable node */
11371 +#define JFFS2_INO_FLAG_IUNLINK 0x20 /* immutable unlink */
11372 +#define JFFS2_INO_FLAG_BARRIER 0x40 /* barrier */
11374 +#define JFFS2_USER_VISIBLE 0x10
11375 +#define JFFS2_USER_MODIFIABLE 0x10
11380 +#define JFFS2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11382 +#define clear_opt(o, opt) o &= ~JFFS2_MOUNT_##opt
11383 +#define set_opt(o, opt) o |= JFFS2_MOUNT_##opt
11386 + * Maximal mount counts between two filesystem checks
11388 +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
11389 +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
11392 + * Behaviour when detecting errors
11395 /* These can go once we've made sure we've caught all uses without
11397 @@ -97,7 +121,7 @@ typedef struct {
11398 } __attribute__((packed)) jint32_t;
11403 } __attribute__((packed)) jmode_t;
11406 @@ -145,7 +169,8 @@ struct jffs2_raw_inode
11408 jint32_t ino; /* Inode number. */
11409 jint32_t version; /* Version number. */
11410 - jmode_t mode; /* The file's type or mode. */
11411 + jmode_t mode; /* The file's type or mode. */
11412 + jint16_t tag; /* context tagging */
11413 jint16_t uid; /* The file's owner. */
11414 jint16_t gid; /* The file's group. */
11415 jint32_t isize; /* Total resultant size of this inode (used for truncations) */
11416 diff -Nurp linux-2.6.22.18/include/linux/Kbuild linux-2.6.22.18-vs2.3.0.32/include/linux/Kbuild
11417 --- linux-2.6.22.18/include/linux/Kbuild 2007-09-29 14:11:49.000000000 +0200
11418 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/Kbuild 2008-02-11 12:35:35.000000000 +0100
11419 @@ -351,3 +351,6 @@ unifdef-y += xattr.h
11420 unifdef-y += xfrm.h
11422 objhdr-y += version.h
11424 +header-y += vserver/
11426 diff -Nurp linux-2.6.22.18/include/linux/loop.h linux-2.6.22.18-vs2.3.0.32/include/linux/loop.h
11427 --- linux-2.6.22.18/include/linux/loop.h 2007-07-22 00:00:24.000000000 +0200
11428 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/loop.h 2008-02-11 12:35:36.000000000 +0100
11429 @@ -45,6 +45,7 @@ struct loop_device {
11430 struct loop_func_table *lo_encryption;
11432 uid_t lo_key_owner; /* Who set the key */
11434 int (*ioctl)(struct loop_device *, int cmd,
11435 unsigned long arg);
11437 diff -Nurp linux-2.6.22.18/include/linux/magic.h linux-2.6.22.18-vs2.3.0.32/include/linux/magic.h
11438 --- linux-2.6.22.18/include/linux/magic.h 2007-07-22 00:00:24.000000000 +0200
11439 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/magic.h 2008-02-11 12:35:36.000000000 +0100
11442 #define ADFS_SUPER_MAGIC 0xadf5
11443 #define AFFS_SUPER_MAGIC 0xadff
11444 -#define AFS_SUPER_MAGIC 0x5346414F
11445 +#define AFS_SUPER_MAGIC 0x5346414F
11446 #define AUTOFS_SUPER_MAGIC 0x0187
11447 #define CODA_SUPER_MAGIC 0x73757245
11448 #define EFS_SUPER_MAGIC 0x414A53
11450 #define NFS_SUPER_MAGIC 0x6969
11451 #define OPENPROM_SUPER_MAGIC 0x9fa1
11452 #define PROC_SUPER_MAGIC 0x9fa0
11453 +#define DEVPTS_SUPER_MAGIC 0x1cd1
11454 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
11456 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
11457 diff -Nurp linux-2.6.22.18/include/linux/major.h linux-2.6.22.18-vs2.3.0.32/include/linux/major.h
11458 --- linux-2.6.22.18/include/linux/major.h 2007-07-22 00:00:24.000000000 +0200
11459 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/major.h 2008-02-11 12:35:36.000000000 +0100
11461 #define HD_MAJOR IDE0_MAJOR
11462 #define PTY_SLAVE_MAJOR 3
11463 #define TTY_MAJOR 4
11464 +#define VROOT_MAJOR 4
11465 #define TTYAUX_MAJOR 5
11467 #define VCS_MAJOR 7
11468 diff -Nurp linux-2.6.22.18/include/linux/mount.h linux-2.6.22.18-vs2.3.0.32/include/linux/mount.h
11469 --- linux-2.6.22.18/include/linux/mount.h 2007-07-22 00:00:24.000000000 +0200
11470 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/mount.h 2008-02-11 12:35:36.000000000 +0100
11471 @@ -28,6 +28,9 @@ struct mnt_namespace;
11472 #define MNT_NOATIME 0x08
11473 #define MNT_NODIRATIME 0x10
11474 #define MNT_RELATIME 0x20
11475 +#define MNT_RDONLY 0x40
11477 +#define MNT_IS_RDONLY(m) ((m) && ((m)->mnt_flags & MNT_RDONLY))
11479 #define MNT_SHRINKABLE 0x100
11481 @@ -35,6 +38,10 @@ struct mnt_namespace;
11482 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
11483 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
11485 +#define MNT_TAGID 0x10000
11486 +#define MNT_NOTAG 0x20000
11487 +#define MNT_NOTAGCHECK 0x40000
11490 struct list_head mnt_hash;
11491 struct vfsmount *mnt_parent; /* fs we are mounted on */
11492 @@ -61,6 +68,7 @@ struct vfsmount {
11493 atomic_t mnt_count;
11494 int mnt_expiry_mark; /* true if marked for expiry */
11496 + tag_t mnt_tag; /* tagging used for vfsmount */
11499 static inline struct vfsmount *mntget(struct vfsmount *mnt)
11500 diff -Nurp linux-2.6.22.18/include/linux/net.h linux-2.6.22.18-vs2.3.0.32/include/linux/net.h
11501 --- linux-2.6.22.18/include/linux/net.h 2007-07-22 00:00:24.000000000 +0200
11502 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/net.h 2008-02-11 12:35:36.000000000 +0100
11503 @@ -63,6 +63,7 @@ typedef enum {
11504 #define SOCK_NOSPACE 2
11505 #define SOCK_PASSCRED 3
11506 #define SOCK_PASSSEC 4
11507 +#define SOCK_USER_SOCKET 5
11509 #ifndef ARCH_HAS_SOCKET_TYPES
11511 diff -Nurp linux-2.6.22.18/include/linux/nfs_mount.h linux-2.6.22.18-vs2.3.0.32/include/linux/nfs_mount.h
11512 --- linux-2.6.22.18/include/linux/nfs_mount.h 2007-07-22 00:00:24.000000000 +0200
11513 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/nfs_mount.h 2008-02-11 12:35:36.000000000 +0100
11514 @@ -62,6 +62,7 @@ struct nfs_mount_data {
11515 #define NFS_MOUNT_STRICTLOCK 0x1000 /* reserved for NFSv4 */
11516 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
11517 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
11518 +#define NFS_MOUNT_TAGGED 0x8000 /* context tagging */
11519 #define NFS_MOUNT_FLAGMASK 0xFFFF
11522 diff -Nurp linux-2.6.22.18/include/linux/nsproxy.h linux-2.6.22.18-vs2.3.0.32/include/linux/nsproxy.h
11523 --- linux-2.6.22.18/include/linux/nsproxy.h 2007-07-22 00:00:24.000000000 +0200
11524 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/nsproxy.h 2008-02-11 12:35:36.000000000 +0100
11527 #include <linux/spinlock.h>
11528 #include <linux/sched.h>
11529 +#include <linux/vserver/debug.h>
11531 struct mnt_namespace;
11532 struct uts_namespace;
11533 @@ -32,26 +33,46 @@ struct nsproxy {
11534 extern struct nsproxy init_nsproxy;
11536 int copy_namespaces(int flags, struct task_struct *tsk);
11537 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
11538 void get_task_namespaces(struct task_struct *tsk);
11539 void free_nsproxy(struct nsproxy *ns);
11540 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
11541 struct fs_struct *);
11543 -static inline void put_nsproxy(struct nsproxy *ns)
11544 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
11546 +static inline void __get_nsproxy(struct nsproxy *ns,
11547 + const char *_file, int _line)
11549 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
11550 + ns, atomic_read(&ns->count), _file, _line);
11551 + atomic_inc(&ns->count);
11554 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
11556 +static inline void __put_nsproxy(struct nsproxy *ns,
11557 + const char *_file, int _line)
11559 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
11560 + ns, atomic_read(&ns->count), _file, _line);
11561 if (atomic_dec_and_test(&ns->count)) {
11566 -static inline void exit_task_namespaces(struct task_struct *p)
11567 +#define exit_task_namespaces(p) __exit_task_namespaces(p, __FILE__, __LINE__)
11569 +static inline void __exit_task_namespaces(struct task_struct *p,
11570 + const char *_file, int _line)
11572 struct nsproxy *ns = p->nsproxy;
11578 + __put_nsproxy(ns, _file, _line);
11583 diff -Nurp linux-2.6.22.18/include/linux/pid.h linux-2.6.22.18-vs2.3.0.32/include/linux/pid.h
11584 --- linux-2.6.22.18/include/linux/pid.h 2007-07-22 00:00:24.000000000 +0200
11585 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/pid.h 2008-02-11 12:35:36.000000000 +0100
11586 @@ -8,7 +8,8 @@ enum pid_type
11596 diff -Nurp linux-2.6.22.18/include/linux/proc_fs.h linux-2.6.22.18-vs2.3.0.32/include/linux/proc_fs.h
11597 --- linux-2.6.22.18/include/linux/proc_fs.h 2007-07-22 00:00:24.000000000 +0200
11598 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/proc_fs.h 2008-02-11 12:35:36.000000000 +0100
11599 @@ -54,6 +54,7 @@ struct proc_dir_entry {
11605 const struct inode_operations *proc_iops;
11606 const struct file_operations *proc_fops;
11607 @@ -246,13 +247,20 @@ static inline void kclist_add(struct kco
11608 extern void kclist_add(struct kcore_list *, void *, size_t);
11615 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
11616 int (*proc_read)(struct task_struct *task, char *page);
11617 + int (*proc_vs_read)(char *page);
11618 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
11619 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
11622 struct proc_inode {
11627 struct proc_dir_entry *pde;
11628 diff -Nurp linux-2.6.22.18/include/linux/reiserfs_fs.h linux-2.6.22.18-vs2.3.0.32/include/linux/reiserfs_fs.h
11629 --- linux-2.6.22.18/include/linux/reiserfs_fs.h 2007-07-21 23:58:53.000000000 +0200
11630 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/reiserfs_fs.h 2008-02-11 12:35:36.000000000 +0100
11631 @@ -821,6 +821,10 @@ struct stat_data_v1 {
11632 #define REISERFS_COMPR_FL FS_COMPR_FL
11633 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
11635 +/* unfortunately reiserfs sdattr is only 16 bit */
11636 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
11637 +#define REISERFS_IUNLINK_FL (FS_IUNLINK_FL >> 16)
11639 /* persistent flags that file inherits from the parent directory */
11640 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
11641 REISERFS_SYNC_FL | \
11642 @@ -830,6 +834,9 @@ struct stat_data_v1 {
11643 REISERFS_COMPR_FL | \
11644 REISERFS_NOTAIL_FL )
11646 +#define REISERFS_FL_USER_VISIBLE 0x80FF
11647 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
11649 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
11652 @@ -1901,6 +1908,7 @@ static inline void reiserfs_update_sd(st
11653 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
11654 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
11655 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
11656 +int reiserfs_sync_flags(struct inode *inode);
11659 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
11660 diff -Nurp linux-2.6.22.18/include/linux/reiserfs_fs_sb.h linux-2.6.22.18-vs2.3.0.32/include/linux/reiserfs_fs_sb.h
11661 --- linux-2.6.22.18/include/linux/reiserfs_fs_sb.h 2007-07-22 00:00:24.000000000 +0200
11662 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/reiserfs_fs_sb.h 2008-02-11 12:35:36.000000000 +0100
11663 @@ -458,6 +458,7 @@ enum reiserfs_mount_options {
11665 REISERFS_BARRIER_NONE,
11666 REISERFS_BARRIER_FLUSH,
11669 /* Actions on error */
11670 REISERFS_ERROR_PANIC,
11671 diff -Nurp linux-2.6.22.18/include/linux/sched.h linux-2.6.22.18-vs2.3.0.32/include/linux/sched.h
11672 --- linux-2.6.22.18/include/linux/sched.h 2007-07-22 00:00:24.000000000 +0200
11673 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/sched.h 2008-02-11 12:35:36.000000000 +0100
11675 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
11676 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
11677 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
11678 +#define CLONE_KTHREAD 0x10000000 /* clone a kernel thread */
11681 * Scheduling policies
11682 @@ -94,7 +95,7 @@ struct bio;
11683 * List of flags we want to share for kernel threads,
11684 * if only because they are not used by them anyway.
11686 -#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
11687 +#define CLONE_KERNEL (CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_KTHREAD)
11690 * These are the constant used to fake the fixed-point load-average
11691 @@ -146,12 +147,13 @@ extern unsigned long weighted_cpuload(co
11692 #define TASK_UNINTERRUPTIBLE 2
11693 #define TASK_STOPPED 4
11694 #define TASK_TRACED 8
11695 +#define TASK_ONHOLD 16
11696 /* in tsk->exit_state */
11697 -#define EXIT_ZOMBIE 16
11698 -#define EXIT_DEAD 32
11699 +#define EXIT_ZOMBIE 32
11700 +#define EXIT_DEAD 64
11701 /* in tsk->state again */
11702 -#define TASK_NONINTERACTIVE 64
11703 -#define TASK_DEAD 128
11704 +#define TASK_NONINTERACTIVE 128
11705 +#define TASK_DEAD 256
11707 #define __set_task_state(tsk, state_value) \
11708 do { (tsk)->state = (state_value); } while (0)
11709 @@ -287,27 +289,30 @@ extern void arch_unmap_area_topdown(stru
11710 * The mm counters are not protected by its page_table_lock,
11711 * so must be incremented atomically.
11713 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
11714 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
11715 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
11716 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
11717 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
11718 typedef atomic_long_t mm_counter_t;
11719 +#define __set_mm_counter(mm, member, value) \
11720 + atomic_long_set(&(mm)->_##member, value)
11721 +#define get_mm_counter(mm, member) \
11722 + ((unsigned long)atomic_long_read(&(mm)->_##member))
11724 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11726 * The mm counters are protected by its page_table_lock,
11727 * so can be incremented directly.
11729 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
11730 -#define get_mm_counter(mm, member) ((mm)->_##member)
11731 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
11732 -#define inc_mm_counter(mm, member) (mm)->_##member++
11733 -#define dec_mm_counter(mm, member) (mm)->_##member--
11734 typedef unsigned long mm_counter_t;
11735 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
11736 +#define get_mm_counter(mm, member) ((mm)->_##member)
11738 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11740 +#define set_mm_counter(mm, member, value) \
11741 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
11742 +#define add_mm_counter(mm, member, value) \
11743 + vx_ ## member ## pages_add((mm), (value))
11744 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
11745 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
11747 #define get_mm_rss(mm) \
11748 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
11749 #define update_hiwater_rss(mm) do { \
11750 @@ -365,6 +370,7 @@ struct mm_struct {
11752 /* Architecture-specific MM context */
11753 mm_context_t context;
11754 + struct vx_info *mm_vx_info;
11756 /* Swap token stuff */
11758 @@ -570,9 +576,10 @@ struct user_struct {
11759 /* Hash table maintenance information */
11760 struct list_head uidhash_list;
11765 -extern struct user_struct *find_user(uid_t);
11766 +extern struct user_struct *find_user(xid_t, uid_t);
11768 extern struct user_struct root_user;
11769 #define INIT_USER (&root_user)
11770 @@ -969,6 +976,15 @@ struct task_struct {
11773 struct audit_context *audit_context;
11775 +/* vserver context data */
11776 + struct vx_info *vx_info;
11777 + struct nx_info *nx_info;
11785 /* Thread group tracking */
11786 @@ -1290,12 +1306,16 @@ extern struct task_struct init_task;
11788 extern struct mm_struct init_mm;
11790 -#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr)
11791 +#define find_task_by_real_pid(nr) \
11792 + find_task_by_pid_type(PIDTYPE_REALPID, nr)
11793 +#define find_task_by_pid(nr) \
11794 + find_task_by_pid_type(PIDTYPE_PID, nr)
11796 extern struct task_struct *find_task_by_pid_type(int type, int pid);
11797 extern void __set_special_pids(pid_t session, pid_t pgrp);
11799 /* per-UID process charging. */
11800 -extern struct user_struct * alloc_uid(uid_t);
11801 +extern struct user_struct * alloc_uid(xid_t, uid_t);
11802 static inline struct user_struct *get_uid(struct user_struct *u)
11804 atomic_inc(&u->__count);
11805 diff -Nurp linux-2.6.22.18/include/linux/shmem_fs.h linux-2.6.22.18-vs2.3.0.32/include/linux/shmem_fs.h
11806 --- linux-2.6.22.18/include/linux/shmem_fs.h 2007-05-04 15:57:44.000000000 +0200
11807 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/shmem_fs.h 2008-02-11 12:35:36.000000000 +0100
11810 #define SHMEM_NR_DIRECT 16
11812 +#define TMPFS_SUPER_MAGIC 0x01021994
11815 struct shmem_inode_info {
11817 unsigned long flags;
11818 diff -Nurp linux-2.6.22.18/include/linux/stat.h linux-2.6.22.18-vs2.3.0.32/include/linux/stat.h
11819 --- linux-2.6.22.18/include/linux/stat.h 2007-07-22 00:00:24.000000000 +0200
11820 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/stat.h 2008-02-11 12:35:36.000000000 +0100
11821 @@ -66,6 +66,7 @@ struct kstat {
11822 unsigned int nlink;
11828 struct timespec atime;
11829 diff -Nurp linux-2.6.22.18/include/linux/sunrpc/auth.h linux-2.6.22.18-vs2.3.0.32/include/linux/sunrpc/auth.h
11830 --- linux-2.6.22.18/include/linux/sunrpc/auth.h 2007-05-04 15:57:44.000000000 +0200
11831 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/sunrpc/auth.h 2008-02-11 12:35:36.000000000 +0100
11837 struct group_info *group_info;
11840 diff -Nurp linux-2.6.22.18/include/linux/sunrpc/clnt.h linux-2.6.22.18-vs2.3.0.32/include/linux/sunrpc/clnt.h
11841 --- linux-2.6.22.18/include/linux/sunrpc/clnt.h 2007-07-22 00:00:24.000000000 +0200
11842 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/sunrpc/clnt.h 2008-02-11 12:35:36.000000000 +0100
11843 @@ -43,7 +43,8 @@ struct rpc_clnt {
11844 cl_discrtry : 1,/* disconnect before retry */
11845 cl_autobind : 1,/* use getport() */
11846 cl_oneshot : 1,/* dispose after use */
11847 - cl_dead : 1;/* abandoned */
11848 + cl_dead : 1,/* abandoned */
11849 + cl_tag : 1;/* context tagging */
11851 struct rpc_rtt * cl_rtt; /* RTO estimator data */
11853 diff -Nurp linux-2.6.22.18/include/linux/syscalls.h linux-2.6.22.18-vs2.3.0.32/include/linux/syscalls.h
11854 --- linux-2.6.22.18/include/linux/syscalls.h 2007-07-22 00:00:24.000000000 +0200
11855 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/syscalls.h 2008-02-11 12:35:36.000000000 +0100
11856 @@ -294,6 +294,8 @@ asmlinkage long sys_symlink(const char _
11857 asmlinkage long sys_unlink(const char __user *pathname);
11858 asmlinkage long sys_rename(const char __user *oldname,
11859 const char __user *newname);
11860 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
11862 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
11863 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
11865 diff -Nurp linux-2.6.22.18/include/linux/sysctl.h linux-2.6.22.18-vs2.3.0.32/include/linux/sysctl.h
11866 --- linux-2.6.22.18/include/linux/sysctl.h 2007-07-22 00:00:24.000000000 +0200
11867 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/sysctl.h 2008-02-11 12:35:36.000000000 +0100
11868 @@ -106,6 +106,7 @@ enum
11869 KERN_CAP_BSET=14, /* int: capability bounding set */
11870 KERN_PANIC=15, /* int: panic timeout */
11871 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
11872 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
11874 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
11875 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
11876 diff -Nurp linux-2.6.22.18/include/linux/sysfs.h linux-2.6.22.18-vs2.3.0.32/include/linux/sysfs.h
11877 --- linux-2.6.22.18/include/linux/sysfs.h 2007-07-22 00:00:24.000000000 +0200
11878 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/sysfs.h 2008-02-11 12:35:36.000000000 +0100
11880 #include <linux/list.h>
11881 #include <asm/atomic.h>
11883 +#define SYSFS_SUPER_MAGIC 0x62656572
11888 diff -Nurp linux-2.6.22.18/include/linux/time.h linux-2.6.22.18-vs2.3.0.32/include/linux/time.h
11889 --- linux-2.6.22.18/include/linux/time.h 2007-07-22 00:00:24.000000000 +0200
11890 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/time.h 2008-02-11 12:35:36.000000000 +0100
11891 @@ -176,6 +176,9 @@ static inline void timespec_add_ns(struc
11896 +#include <linux/vs_time.h>
11898 #endif /* __KERNEL__ */
11900 #define NFDBITS __NFDBITS
11901 diff -Nurp linux-2.6.22.18/include/linux/types.h linux-2.6.22.18-vs2.3.0.32/include/linux/types.h
11902 --- linux-2.6.22.18/include/linux/types.h 2007-05-04 15:58:24.000000000 +0200
11903 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/types.h 2008-02-11 12:35:36.000000000 +0100
11904 @@ -39,6 +39,9 @@ typedef __kernel_uid32_t uid_t;
11905 typedef __kernel_gid32_t gid_t;
11906 typedef __kernel_uid16_t uid16_t;
11907 typedef __kernel_gid16_t gid16_t;
11908 +typedef unsigned int xid_t;
11909 +typedef unsigned int nid_t;
11910 +typedef unsigned int tag_t;
11912 #ifdef CONFIG_UID16
11913 /* This is defined by include/asm-{arch}/posix_types.h */
11914 diff -Nurp linux-2.6.22.18/include/linux/vroot.h linux-2.6.22.18-vs2.3.0.32/include/linux/vroot.h
11915 --- linux-2.6.22.18/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
11916 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vroot.h 2008-02-11 12:35:36.000000000 +0100
11920 + * include/linux/vroot.h
11922 + * written by Herbert Pötzl, 9/11/2002
11923 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
11925 + * Copyright (C) 2002-2007 by Herbert Pötzl.
11926 + * Redistribution of this file is permitted under the
11927 + * GNU General Public License.
11930 +#ifndef _LINUX_VROOT_H
11931 +#define _LINUX_VROOT_H
11936 +/* Possible states of device */
11942 +struct vroot_device {
11946 + struct semaphore vr_ctl_mutex;
11947 + struct block_device *vr_device;
11952 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
11954 +extern int register_vroot_grb(vroot_grb_func *);
11955 +extern int unregister_vroot_grb(vroot_grb_func *);
11957 +#endif /* __KERNEL__ */
11959 +#define MAX_VROOT_DEFAULT 8
11962 + * IOCTL commands --- we will commandeer 0x56 ('V')
11965 +#define VROOT_SET_DEV 0x5600
11966 +#define VROOT_CLR_DEV 0x5601
11968 +#endif /* _LINUX_VROOT_H */
11969 diff -Nurp linux-2.6.22.18/include/linux/vs_base.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_base.h
11970 --- linux-2.6.22.18/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
11971 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_base.h 2008-02-11 12:35:36.000000000 +0100
11973 +#ifndef _VS_BASE_H
11974 +#define _VS_BASE_H
11976 +#include "vserver/base.h"
11977 +#include "vserver/debug.h"
11980 +#warning duplicate inclusion
11982 diff -Nurp linux-2.6.22.18/include/linux/vs_context.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_context.h
11983 --- linux-2.6.22.18/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
11984 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_context.h 2008-02-11 12:35:36.000000000 +0100
11986 +#ifndef _VS_CONTEXT_H
11987 +#define _VS_CONTEXT_H
11989 +#include "vserver/base.h"
11990 +#include "vserver/context.h"
11991 +#include "vserver/history.h"
11992 +#include "vserver/debug.h"
11995 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
11997 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
11998 + const char *_file, int _line, void *_here)
12003 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
12004 + vxi, vxi ? vxi->vx_id : 0,
12005 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12007 + __vxh_get_vx_info(vxi, _here);
12009 + atomic_inc(&vxi->vx_usecnt);
12014 +extern void free_vx_info(struct vx_info *);
12016 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
12018 +static inline void __put_vx_info(struct vx_info *vxi,
12019 + const char *_file, int _line, void *_here)
12024 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
12025 + vxi, vxi ? vxi->vx_id : 0,
12026 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12028 + __vxh_put_vx_info(vxi, _here);
12030 + if (atomic_dec_and_test(&vxi->vx_usecnt))
12031 + free_vx_info(vxi);
12035 +#define init_vx_info(p, i) \
12036 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
12038 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
12039 + const char *_file, int _line, void *_here)
12042 + vxlprintk(VXD_CBIT(xid, 3),
12043 + "init_vx_info(%p[#%d.%d])",
12044 + vxi, vxi ? vxi->vx_id : 0,
12045 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12047 + __vxh_init_vx_info(vxi, vxp, _here);
12049 + atomic_inc(&vxi->vx_usecnt);
12055 +#define set_vx_info(p, i) \
12056 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
12058 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
12059 + const char *_file, int _line, void *_here)
12061 + struct vx_info *vxo;
12066 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
12067 + vxi, vxi ? vxi->vx_id : 0,
12068 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12070 + __vxh_set_vx_info(vxi, vxp, _here);
12072 + atomic_inc(&vxi->vx_usecnt);
12073 + vxo = xchg(vxp, vxi);
12078 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
12080 +static inline void __clr_vx_info(struct vx_info **vxp,
12081 + const char *_file, int _line, void *_here)
12083 + struct vx_info *vxo;
12085 + vxo = xchg(vxp, NULL);
12089 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
12090 + vxo, vxo ? vxo->vx_id : 0,
12091 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
12093 + __vxh_clr_vx_info(vxo, vxp, _here);
12095 + if (atomic_dec_and_test(&vxo->vx_usecnt))
12096 + free_vx_info(vxo);
12100 +#define claim_vx_info(v, p) \
12101 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
12103 +static inline void __claim_vx_info(struct vx_info *vxi,
12104 + struct task_struct *task,
12105 + const char *_file, int _line, void *_here)
12107 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
12108 + vxi, vxi ? vxi->vx_id : 0,
12109 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12110 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
12111 + task, _file, _line);
12112 + __vxh_claim_vx_info(vxi, task, _here);
12114 + atomic_inc(&vxi->vx_tasks);
12118 +extern void unhash_vx_info(struct vx_info *);
12120 +#define release_vx_info(v, p) \
12121 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
12123 +static inline void __release_vx_info(struct vx_info *vxi,
12124 + struct task_struct *task,
12125 + const char *_file, int _line, void *_here)
12127 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
12128 + vxi, vxi ? vxi->vx_id : 0,
12129 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12130 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
12131 + task, _file, _line);
12132 + __vxh_release_vx_info(vxi, task, _here);
12136 + if (atomic_dec_and_test(&vxi->vx_tasks))
12137 + unhash_vx_info(vxi);
12141 +#define task_get_vx_info(p) \
12142 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
12144 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
12145 + const char *_file, int _line, void *_here)
12147 + struct vx_info *vxi;
12150 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
12151 + p, _file, _line);
12152 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
12158 +static inline void __wakeup_vx_info(struct vx_info *vxi)
12160 + if (waitqueue_active(&vxi->vx_wait))
12161 + wake_up_interruptible(&vxi->vx_wait);
12165 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
12167 +static inline void __enter_vx_info(struct vx_info *vxi,
12168 + struct vx_info_save *vxis, const char *_file, int _line)
12170 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
12171 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
12172 + current->xid, current->vx_info, _file, _line);
12173 + vxis->vxi = xchg(¤t->vx_info, vxi);
12174 + vxis->xid = current->xid;
12175 + current->xid = vxi ? vxi->vx_id : 0;
12178 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
12180 +static inline void __leave_vx_info(struct vx_info_save *vxis,
12181 + const char *_file, int _line)
12183 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
12184 + vxis, vxis->xid, vxis->vxi, current,
12185 + current->xid, current->vx_info, _file, _line);
12186 + (void)xchg(¤t->vx_info, vxis->vxi);
12187 + current->xid = vxis->xid;
12191 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
12193 + vxis->vxi = xchg(¤t->vx_info, NULL);
12194 + vxis->xid = xchg(¤t->xid, (xid_t)0);
12197 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
12199 + (void)xchg(¤t->xid, vxis->xid);
12200 + (void)xchg(¤t->vx_info, vxis->vxi);
12203 +extern void exit_vx_info(struct task_struct *, int);
12204 +extern void exit_vx_info_early(struct task_struct *, int);
12208 +#warning duplicate inclusion
12210 diff -Nurp linux-2.6.22.18/include/linux/vs_cowbl.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_cowbl.h
12211 --- linux-2.6.22.18/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
12212 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_cowbl.h 2008-02-11 12:35:36.000000000 +0100
12214 +#ifndef _VS_COWBL_H
12215 +#define _VS_COWBL_H
12217 +#include <linux/fs.h>
12218 +#include <linux/dcache.h>
12219 +#include <linux/namei.h>
12221 +extern struct dentry *cow_break_link(const char *pathname);
12223 +static inline int cow_check_and_break(struct nameidata *nd)
12225 + struct inode *inode = nd->dentry->d_inode;
12227 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
12229 + if (IS_COW(inode)) {
12230 + if (IS_COW_LINK(inode)) {
12231 + struct dentry *new_dentry, *old_dentry = nd->dentry;
12232 + char *path, *buf;
12234 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
12238 + path = d_path(nd->dentry, nd->mnt, buf, PATH_MAX);
12239 + new_dentry = cow_break_link(path);
12241 + if (!IS_ERR(new_dentry)) {
12242 + nd->dentry = new_dentry;
12243 + dput(old_dentry);
12245 + error = PTR_ERR(new_dentry);
12247 + inode->i_flags &= ~(S_IUNLINK | S_IMMUTABLE);
12248 + inode->i_ctime = CURRENT_TIME;
12249 + mark_inode_dirty(inode);
12256 +#warning duplicate inclusion
12258 diff -Nurp linux-2.6.22.18/include/linux/vs_cvirt.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_cvirt.h
12259 --- linux-2.6.22.18/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
12260 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_cvirt.h 2008-02-11 12:35:36.000000000 +0100
12262 +#ifndef _VS_CVIRT_H
12263 +#define _VS_CVIRT_H
12265 +#include "vserver/cvirt.h"
12266 +#include "vserver/context.h"
12267 +#include "vserver/base.h"
12268 +#include "vserver/debug.h"
12271 +static inline void vx_activate_task(struct task_struct *p)
12273 + struct vx_info *vxi;
12275 + if ((vxi = p->vx_info)) {
12276 + vx_update_load(vxi);
12277 + atomic_inc(&vxi->cvirt.nr_running);
12281 +static inline void vx_deactivate_task(struct task_struct *p)
12283 + struct vx_info *vxi;
12285 + if ((vxi = p->vx_info)) {
12286 + vx_update_load(vxi);
12287 + atomic_dec(&vxi->cvirt.nr_running);
12291 +static inline void vx_uninterruptible_inc(struct task_struct *p)
12293 + struct vx_info *vxi;
12295 + if ((vxi = p->vx_info))
12296 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
12299 +static inline void vx_uninterruptible_dec(struct task_struct *p)
12301 + struct vx_info *vxi;
12303 + if ((vxi = p->vx_info))
12304 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
12309 +#warning duplicate inclusion
12311 diff -Nurp linux-2.6.22.18/include/linux/vs_device.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_device.h
12312 --- linux-2.6.22.18/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
12313 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_device.h 2008-02-11 12:35:36.000000000 +0100
12315 +#ifndef _VS_DEVICE_H
12316 +#define _VS_DEVICE_H
12318 +#include "vserver/base.h"
12319 +#include "vserver/device.h"
12320 +#include "vserver/debug.h"
12323 +#ifdef CONFIG_VSERVER_DEVICE
12325 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
12327 +#define vs_device_perm(v, d, m, p) \
12328 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
12333 +int vs_map_device(struct vx_info *vxi,
12334 + dev_t device, dev_t *target, umode_t mode)
12337 + *target = device;
12341 +#define vs_device_perm(v, d, m, p) ((p) == (p))
12346 +#define vs_map_chrdev(d, t, p) \
12347 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
12348 +#define vs_map_blkdev(d, t, p) \
12349 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
12351 +#define vs_chrdev_perm(d, p) \
12352 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
12353 +#define vs_blkdev_perm(d, p) \
12354 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
12358 +#warning duplicate inclusion
12360 diff -Nurp linux-2.6.22.18/include/linux/vs_dlimit.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_dlimit.h
12361 --- linux-2.6.22.18/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
12362 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_dlimit.h 2008-02-11 12:35:36.000000000 +0100
12364 +#ifndef _VS_DLIMIT_H
12365 +#define _VS_DLIMIT_H
12367 +#include <linux/fs.h>
12369 +#include "vserver/dlimit.h"
12370 +#include "vserver/base.h"
12371 +#include "vserver/debug.h"
12374 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
12376 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
12377 + const char *_file, int _line)
12381 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
12382 + dli, dli ? dli->dl_tag : 0,
12383 + dli ? atomic_read(&dli->dl_usecnt) : 0,
12385 + atomic_inc(&dli->dl_usecnt);
12390 +#define free_dl_info(i) \
12391 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
12393 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
12395 +static inline void __put_dl_info(struct dl_info *dli,
12396 + const char *_file, int _line)
12400 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
12401 + dli, dli ? dli->dl_tag : 0,
12402 + dli ? atomic_read(&dli->dl_usecnt) : 0,
12404 + if (atomic_dec_and_test(&dli->dl_usecnt))
12405 + free_dl_info(dli);
12409 +#define __dlimit_char(d) ((d) ? '*' : ' ')
12411 +static inline int __dl_alloc_space(struct super_block *sb,
12412 + tag_t tag, dlsize_t nr, const char *file, int line)
12414 + struct dl_info *dli = NULL;
12419 + dli = locate_dl_info(sb, tag);
12423 + spin_lock(&dli->dl_lock);
12424 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
12426 + dli->dl_space_used += nr;
12427 + spin_unlock(&dli->dl_lock);
12428 + put_dl_info(dli);
12430 + vxlprintk(VXD_CBIT(dlim, 1),
12431 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
12432 + sb, tag, __dlimit_char(dli), (long long)nr,
12433 + ret, file, line);
12437 +static inline void __dl_free_space(struct super_block *sb,
12438 + tag_t tag, dlsize_t nr, const char *_file, int _line)
12440 + struct dl_info *dli = NULL;
12444 + dli = locate_dl_info(sb, tag);
12448 + spin_lock(&dli->dl_lock);
12449 + if (dli->dl_space_used > nr)
12450 + dli->dl_space_used -= nr;
12452 + dli->dl_space_used = 0;
12453 + spin_unlock(&dli->dl_lock);
12454 + put_dl_info(dli);
12456 + vxlprintk(VXD_CBIT(dlim, 1),
12457 + "FREE (%p,#%d)%c %lld bytes",
12458 + sb, tag, __dlimit_char(dli), (long long)nr,
12462 +static inline int __dl_alloc_inode(struct super_block *sb,
12463 + tag_t tag, const char *_file, int _line)
12465 + struct dl_info *dli;
12468 + dli = locate_dl_info(sb, tag);
12472 + spin_lock(&dli->dl_lock);
12473 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
12475 + dli->dl_inodes_used++;
12476 + spin_unlock(&dli->dl_lock);
12477 + put_dl_info(dli);
12479 + vxlprintk(VXD_CBIT(dlim, 0),
12480 + "ALLOC (%p,#%d)%c inode (%d)",
12481 + sb, tag, __dlimit_char(dli), ret, _file, _line);
12485 +static inline void __dl_free_inode(struct super_block *sb,
12486 + tag_t tag, const char *_file, int _line)
12488 + struct dl_info *dli;
12490 + dli = locate_dl_info(sb, tag);
12494 + spin_lock(&dli->dl_lock);
12495 + if (dli->dl_inodes_used > 1)
12496 + dli->dl_inodes_used--;
12498 + dli->dl_inodes_used = 0;
12499 + spin_unlock(&dli->dl_lock);
12500 + put_dl_info(dli);
12502 + vxlprintk(VXD_CBIT(dlim, 0),
12503 + "FREE (%p,#%d)%c inode",
12504 + sb, tag, __dlimit_char(dli), _file, _line);
12507 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
12508 + unsigned long long *free_blocks, unsigned long long *root_blocks,
12509 + const char *_file, int _line)
12511 + struct dl_info *dli;
12512 + uint64_t broot, bfree;
12514 + dli = locate_dl_info(sb, tag);
12518 + spin_lock(&dli->dl_lock);
12519 + broot = (dli->dl_space_total -
12520 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
12521 + >> sb->s_blocksize_bits;
12522 + bfree = (dli->dl_space_total - dli->dl_space_used)
12523 + >> sb->s_blocksize_bits;
12524 + spin_unlock(&dli->dl_lock);
12526 + vxlprintk(VXD_CBIT(dlim, 2),
12527 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
12528 + (long long)bfree, (long long)broot,
12529 + *free_blocks, *root_blocks, dli->dl_nrlmult,
12531 + if (free_blocks) {
12532 + if (*free_blocks > bfree)
12533 + *free_blocks = bfree;
12535 + if (root_blocks) {
12536 + if (*root_blocks > broot)
12537 + *root_blocks = broot;
12539 + put_dl_info(dli);
12542 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
12543 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
12544 + __FILE__, __LINE__ )
12546 +#define DLIMIT_FREE_SPACE(in, bytes) \
12547 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
12548 + __FILE__, __LINE__ )
12550 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
12551 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
12552 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
12553 + __FILE__, __LINE__ )
12555 +#define DLIMIT_FREE_BLOCK(in, nr) \
12556 + __dl_free_space((in)->i_sb, (in)->i_tag, \
12557 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
12558 + __FILE__, __LINE__ )
12561 +#define DLIMIT_ALLOC_INODE(in) \
12562 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
12564 +#define DLIMIT_FREE_INODE(in) \
12565 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
12568 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
12569 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
12573 +#warning duplicate inclusion
12575 diff -Nurp linux-2.6.22.18/include/linux/vserver/base.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/base.h
12576 --- linux-2.6.22.18/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
12577 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/base.h 2008-02-11 12:35:36.000000000 +0100
12579 +#ifndef _VX_BASE_H
12580 +#define _VX_BASE_H
12583 +/* context state changes */
12594 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
12596 +/* check conditions */
12598 +#define VS_ADMIN 0x0001
12599 +#define VS_WATCH 0x0002
12600 +#define VS_HIDE 0x0004
12601 +#define VS_HOSTID 0x0008
12603 +#define VS_IDENT 0x0010
12604 +#define VS_EQUIV 0x0020
12605 +#define VS_PARENT 0x0040
12606 +#define VS_CHILD 0x0080
12608 +#define VS_ARG_MASK 0x00F0
12610 +#ifdef CONFIG_VSERVER_PRIVACY
12611 +#define VS_ADMIN_P (0)
12612 +#define VS_WATCH_P (0)
12614 +#define VS_ADMIN_P VS_ADMIN
12615 +#define VS_WATCH_P VS_WATCH
12618 +#define VS_HARDIRQ 0x1000
12619 +#define VS_SOFTIRQ 0x2000
12620 +#define VS_IRQ 0x4000
12622 +#define VS_IRQ_MASK 0xF000
12624 +#include <linux/hardirq.h>
12627 + * check current context for ADMIN/WATCH and
12628 + * optionally against supplied argument
12630 +static inline int __vs_check(int cid, int id, unsigned int mode)
12632 + if (mode & VS_ARG_MASK) {
12633 + if ((mode & VS_IDENT) && (id == cid))
12636 + if (mode & VS_IRQ_MASK) {
12637 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
12639 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
12641 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
12644 + return (((mode & VS_ADMIN) && (cid == 0)) ||
12645 + ((mode & VS_WATCH) && (cid == 1)) ||
12646 + ((mode & VS_HOSTID) && (id == 0)));
12649 +#define vx_task_xid(t) ((t)->xid)
12651 +#define vx_current_xid() vx_task_xid(current)
12653 +#define current_vx_info() (current->vx_info)
12656 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
12658 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
12661 +#define nx_task_nid(t) ((t)->nid)
12663 +#define nx_current_nid() nx_task_nid(current)
12665 +#define current_nx_info() (current->nx_info)
12668 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
12670 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
12674 +/* generic flag merging */
12676 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
12678 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
12680 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
12682 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
12685 +/* context flags */
12687 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
12689 +#define vx_current_flags() __vx_flags(current->vx_info)
12691 +#define vx_info_flags(v, m, f) \
12692 + vs_check_flags(__vx_flags(v), m, f)
12694 +#define task_vx_flags(t, m, f) \
12695 + ((t) && vx_info_flags((t)->vx_info, m, f))
12697 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
12700 +/* context caps */
12702 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
12704 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
12706 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
12708 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
12712 +/* network flags */
12714 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
12716 +#define nx_current_flags() __nx_flags(current->nx_info)
12718 +#define nx_info_flags(n, m, f) \
12719 + vs_check_flags(__nx_flags(n), m, f)
12721 +#define task_nx_flags(t, m, f) \
12722 + ((t) && nx_info_flags((t)->nx_info, m, f))
12724 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
12727 +/* network caps */
12729 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
12731 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
12733 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
12735 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
12738 +/* context mask capabilities */
12740 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
12742 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
12744 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
12747 +/* context bcap mask */
12749 +#define __vx_bcaps(v) ((v) ? (v)->vx_bcaps : ~0 )
12751 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
12753 +#define vx_info_bcaps(v, c) (__vx_bcaps(v) & (c))
12755 +#define vx_bcaps(c) vx_info_bcaps(current->vx_info, c)
12758 +#define vx_info_cap_bset(v) ((v) ? (v)->vx_cap_bset : cap_bset)
12760 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
12763 +#define __vx_info_mbcap(v, b) \
12764 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
12765 + vx_info_bcaps(v, b) : (b))
12767 +#define vx_info_mbcap(v, b) __vx_info_mbcap(v, cap_t(b))
12769 +#define task_vx_mbcap(t, b) \
12770 + vx_info_mbcap((t)->vx_info, (t)->b)
12772 +#define vx_mbcap(b) task_vx_mbcap(current, b)
12774 +#define vx_cap_raised(v, c, f) (vx_info_mbcap(v, c) & CAP_TO_MASK(f))
12776 +#define vx_capable(b, c) (capable(b) || \
12777 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
12779 +#define nx_capable(b, c) (capable(b) || \
12780 + (cap_raised(current->cap_effective, b) && nx_ncaps(c)))
12782 +#define vx_current_initpid(n) \
12783 + (current->vx_info && \
12784 + (current->vx_info->vx_initpid == (n)))
12787 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
12789 +#define vx_info_state(v, m) (__vx_state(v) & (m))
12792 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
12794 +#define nx_info_state(n, m) (__nx_state(n) & (m))
12797 diff -Nurp linux-2.6.22.18/include/linux/vserver/cacct_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cacct_cmd.h
12798 --- linux-2.6.22.18/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
12799 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cacct_cmd.h 2008-02-11 12:35:36.000000000 +0100
12801 +#ifndef _VX_CACCT_CMD_H
12802 +#define _VX_CACCT_CMD_H
12805 +/* virtual host info name commands */
12807 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
12809 +struct vcmd_sock_stat_v0 {
12811 + uint32_t count[3];
12812 + uint64_t total[3];
12818 +#include <linux/compiler.h>
12820 +extern int vc_sock_stat(struct vx_info *, void __user *);
12822 +#endif /* __KERNEL__ */
12823 +#endif /* _VX_CACCT_CMD_H */
12824 diff -Nurp linux-2.6.22.18/include/linux/vserver/cacct_def.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cacct_def.h
12825 --- linux-2.6.22.18/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
12826 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cacct_def.h 2008-02-11 12:35:36.000000000 +0100
12828 +#ifndef _VX_CACCT_DEF_H
12829 +#define _VX_CACCT_DEF_H
12831 +#include <asm/atomic.h>
12832 +#include <linux/vserver/cacct.h>
12835 +struct _vx_sock_acc {
12836 + atomic_long_t count;
12837 + atomic_long_t total;
12840 +/* context sub struct */
12842 +struct _vx_cacct {
12843 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
12844 + atomic_t slab[8];
12845 + atomic_t page[6][8];
12848 +#ifdef CONFIG_VSERVER_DEBUG
12850 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
12854 + printk("\t_vx_cacct:");
12855 + for (i = 0; i < 6; i++) {
12856 + struct _vx_sock_acc *ptr = cacct->sock[i];
12858 + printk("\t [%d] =", i);
12859 + for (j = 0; j < 3; j++) {
12860 + printk(" [%d] = %8lu, %8lu", j,
12861 + atomic_long_read(&ptr[j].count),
12862 + atomic_long_read(&ptr[j].total));
12870 +#endif /* _VX_CACCT_DEF_H */
12871 diff -Nurp linux-2.6.22.18/include/linux/vserver/cacct.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cacct.h
12872 --- linux-2.6.22.18/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
12873 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cacct.h 2008-02-11 12:35:36.000000000 +0100
12875 +#ifndef _VX_CACCT_H
12876 +#define _VX_CACCT_H
12879 +enum sock_acc_field {
12880 + VXA_SOCK_UNSPEC = 0,
12886 + VXA_SOCK_SIZE /* array size */
12889 +#endif /* _VX_CACCT_H */
12890 diff -Nurp linux-2.6.22.18/include/linux/vserver/cacct_int.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cacct_int.h
12891 --- linux-2.6.22.18/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
12892 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cacct_int.h 2008-02-11 12:35:36.000000000 +0100
12894 +#ifndef _VX_CACCT_INT_H
12895 +#define _VX_CACCT_INT_H
12901 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
12903 + return atomic_long_read(&cacct->sock[type][pos].count);
12908 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
12910 + return atomic_long_read(&cacct->sock[type][pos].total);
12913 +#endif /* __KERNEL__ */
12914 +#endif /* _VX_CACCT_INT_H */
12915 diff -Nurp linux-2.6.22.18/include/linux/vserver/context_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/context_cmd.h
12916 --- linux-2.6.22.18/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
12917 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/context_cmd.h 2008-02-11 12:35:36.000000000 +0100
12919 +#ifndef _VX_CONTEXT_CMD_H
12920 +#define _VX_CONTEXT_CMD_H
12923 +/* vinfo commands */
12925 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
12928 +extern int vc_task_xid(uint32_t);
12930 +#endif /* __KERNEL__ */
12932 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
12934 +struct vcmd_vx_info_v0 {
12936 + uint32_t initpid;
12937 + /* more to come */
12941 +extern int vc_vx_info(struct vx_info *, void __user *);
12943 +#endif /* __KERNEL__ */
12945 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
12947 +struct vcmd_ctx_stat_v0 {
12950 + /* more to come */
12954 +extern int vc_ctx_stat(struct vx_info *, void __user *);
12956 +#endif /* __KERNEL__ */
12958 +/* context commands */
12960 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
12961 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
12963 +struct vcmd_ctx_create {
12964 + uint64_t flagword;
12967 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
12968 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
12970 +struct vcmd_ctx_migrate {
12971 + uint64_t flagword;
12975 +extern int vc_ctx_create(uint32_t, void __user *);
12976 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
12978 +#endif /* __KERNEL__ */
12981 +/* flag commands */
12983 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
12984 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
12986 +struct vcmd_ctx_flags_v0 {
12987 + uint64_t flagword;
12992 +extern int vc_get_cflags(struct vx_info *, void __user *);
12993 +extern int vc_set_cflags(struct vx_info *, void __user *);
12995 +#endif /* __KERNEL__ */
12998 +/* context caps commands */
13000 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
13001 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
13003 +struct vcmd_ctx_caps_v1 {
13009 +extern int vc_get_ccaps(struct vx_info *, void __user *);
13010 +extern int vc_set_ccaps(struct vx_info *, void __user *);
13012 +#endif /* __KERNEL__ */
13015 +/* bcaps commands */
13017 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
13018 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
13020 +struct vcmd_bcaps {
13026 +extern int vc_get_bcaps(struct vx_info *, void __user *);
13027 +extern int vc_set_bcaps(struct vx_info *, void __user *);
13029 +#endif /* __KERNEL__ */
13034 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
13035 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
13037 +struct vcmd_badness_v0 {
13042 +extern int vc_get_badness(struct vx_info *, void __user *);
13043 +extern int vc_set_badness(struct vx_info *, void __user *);
13045 +#endif /* __KERNEL__ */
13046 +#endif /* _VX_CONTEXT_CMD_H */
13047 diff -Nurp linux-2.6.22.18/include/linux/vserver/context.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/context.h
13048 --- linux-2.6.22.18/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
13049 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/context.h 2008-02-11 12:35:36.000000000 +0100
13051 +#ifndef _VX_CONTEXT_H
13052 +#define _VX_CONTEXT_H
13054 +#include <linux/types.h>
13055 +#include <linux/capability.h>
13058 +/* context flags */
13060 +#define VXF_INFO_SCHED 0x00000002
13061 +#define VXF_INFO_NPROC 0x00000004
13062 +#define VXF_INFO_PRIVATE 0x00000008
13064 +#define VXF_INFO_INIT 0x00000010
13065 +#define VXF_INFO_HIDE 0x00000020
13066 +#define VXF_INFO_ULIMIT 0x00000040
13067 +#define VXF_INFO_NSPACE 0x00000080
13069 +#define VXF_SCHED_HARD 0x00000100
13070 +#define VXF_SCHED_PRIO 0x00000200
13071 +#define VXF_SCHED_PAUSE 0x00000400
13073 +#define VXF_VIRT_MEM 0x00010000
13074 +#define VXF_VIRT_UPTIME 0x00020000
13075 +#define VXF_VIRT_CPU 0x00040000
13076 +#define VXF_VIRT_LOAD 0x00080000
13077 +#define VXF_VIRT_TIME 0x00100000
13079 +#define VXF_HIDE_MOUNT 0x01000000
13080 +/* was VXF_HIDE_NETIF 0x02000000 */
13081 +#define VXF_HIDE_VINFO 0x04000000
13083 +#define VXF_STATE_SETUP (1ULL << 32)
13084 +#define VXF_STATE_INIT (1ULL << 33)
13085 +#define VXF_STATE_ADMIN (1ULL << 34)
13087 +#define VXF_SC_HELPER (1ULL << 36)
13088 +#define VXF_REBOOT_KILL (1ULL << 37)
13089 +#define VXF_PERSISTENT (1ULL << 38)
13091 +#define VXF_FORK_RSS (1ULL << 48)
13092 +#define VXF_PROLIFIC (1ULL << 49)
13094 +#define VXF_IGNEG_NICE (1ULL << 52)
13096 +#define VXF_ONE_TIME (0x0007ULL << 32)
13098 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
13101 +/* context migration */
13103 +#define VXM_SET_INIT 0x00000001
13104 +#define VXM_SET_REAPER 0x00000002
13106 +/* context caps */
13108 +#define VXC_CAP_MASK 0x00000000
13110 +#define VXC_SET_UTSNAME 0x00000001
13111 +#define VXC_SET_RLIMIT 0x00000002
13113 +/* was VXC_RAW_ICMP 0x00000100 */
13114 +#define VXC_SYSLOG 0x00001000
13116 +#define VXC_SECURE_MOUNT 0x00010000
13117 +#define VXC_SECURE_REMOUNT 0x00020000
13118 +#define VXC_BINARY_MOUNT 0x00040000
13120 +#define VXC_QUOTA_CTL 0x00100000
13121 +#define VXC_ADMIN_MAPPER 0x00200000
13122 +#define VXC_ADMIN_CLOOP 0x00400000
13124 +#define VXC_KTHREAD 0x01000000
13129 +#include <linux/list.h>
13130 +#include <linux/spinlock.h>
13131 +#include <linux/rcupdate.h>
13133 +#include "limit_def.h"
13134 +#include "sched_def.h"
13135 +#include "cvirt_def.h"
13136 +#include "cacct_def.h"
13137 +#include "device_def.h"
13139 +struct _vx_info_pc {
13140 + struct _vx_sched_pc sched_pc;
13141 + struct _vx_cvirt_pc cvirt_pc;
13145 + struct hlist_node vx_hlist; /* linked list of contexts */
13146 + xid_t vx_id; /* context id */
13147 + atomic_t vx_usecnt; /* usage count */
13148 + atomic_t vx_tasks; /* tasks count */
13149 + struct vx_info *vx_parent; /* parent context */
13150 + int vx_state; /* context state */
13152 + unsigned long vx_nsmask; /* assignment mask */
13153 + struct nsproxy *vx_nsproxy; /* private namespace */
13154 + struct fs_struct *vx_fs; /* private namespace fs */
13156 + uint64_t vx_flags; /* context flags */
13157 + uint64_t vx_bcaps; /* bounding caps (system) */
13158 + uint64_t vx_ccaps; /* context caps (vserver) */
13159 + kernel_cap_t vx_cap_bset; /* the guest's bset */
13161 + struct task_struct *vx_reaper; /* guest reaper process */
13162 + pid_t vx_initpid; /* PID of guest init */
13163 + int64_t vx_badness_bias; /* OOM points bias */
13165 + struct _vx_limit limit; /* vserver limits */
13166 + struct _vx_sched sched; /* vserver scheduler */
13167 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
13168 + struct _vx_cacct cacct; /* context accounting */
13170 + struct _vx_device dmap; /* default device map targets */
13172 +#ifndef CONFIG_SMP
13173 + struct _vx_info_pc info_pc; /* per cpu data */
13175 + struct _vx_info_pc *ptr_pc; /* per cpu array */
13178 + wait_queue_head_t vx_wait; /* context exit waitqueue */
13179 + int reboot_cmd; /* last sys_reboot() cmd */
13180 + int exit_code; /* last process exit code */
13182 + char vx_name[65]; /* vserver name */
13185 +#ifndef CONFIG_SMP
13186 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
13187 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
13189 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
13190 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
13193 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
13196 +struct vx_info_save {
13197 + struct vx_info *vxi;
13202 +/* status flags */
13204 +#define VXS_HASHED 0x0001
13205 +#define VXS_PAUSED 0x0010
13206 +#define VXS_SHUTDOWN 0x0100
13207 +#define VXS_HELPER 0x1000
13208 +#define VXS_RELEASED 0x8000
13211 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
13212 +extern void release_vx_info(struct vx_info *, struct task_struct *);
13214 +extern struct vx_info *lookup_vx_info(int);
13215 +extern struct vx_info *lookup_or_create_vx_info(int);
13217 +extern int get_xid_list(int, unsigned int *, int);
13218 +extern int xid_is_hashed(xid_t);
13220 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
13222 +extern long vs_state_change(struct vx_info *, unsigned int);
13225 +#endif /* __KERNEL__ */
13226 +#endif /* _VX_CONTEXT_H */
13227 diff -Nurp linux-2.6.22.18/include/linux/vserver/cvirt_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cvirt_cmd.h
13228 --- linux-2.6.22.18/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
13229 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cvirt_cmd.h 2008-02-11 12:35:36.000000000 +0100
13231 +#ifndef _VX_CVIRT_CMD_H
13232 +#define _VX_CVIRT_CMD_H
13235 +/* virtual host info name commands */
13237 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
13238 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
13240 +struct vcmd_vhi_name_v0 {
13246 +enum vhi_name_field {
13247 + VHIN_CONTEXT = 0,
13259 +#include <linux/compiler.h>
13261 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
13262 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
13264 +#endif /* __KERNEL__ */
13266 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
13268 +struct vcmd_virt_stat_v0 {
13271 + uint32_t nr_threads;
13272 + uint32_t nr_running;
13273 + uint32_t nr_uninterruptible;
13274 + uint32_t nr_onhold;
13275 + uint32_t nr_forks;
13276 + uint32_t load[3];
13280 +extern int vc_virt_stat(struct vx_info *, void __user *);
13282 +#endif /* __KERNEL__ */
13283 +#endif /* _VX_CVIRT_CMD_H */
13284 diff -Nurp linux-2.6.22.18/include/linux/vserver/cvirt_def.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cvirt_def.h
13285 --- linux-2.6.22.18/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
13286 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cvirt_def.h 2008-02-11 12:35:36.000000000 +0100
13288 +#ifndef _VX_CVIRT_DEF_H
13289 +#define _VX_CVIRT_DEF_H
13291 +#include <linux/jiffies.h>
13292 +#include <linux/spinlock.h>
13293 +#include <linux/wait.h>
13294 +#include <linux/time.h>
13295 +#include <linux/utsname.h>
13296 +#include <asm/atomic.h>
13299 +struct _vx_usage_stat {
13303 + uint64_t softirq;
13309 +struct _vx_syslog {
13310 + wait_queue_head_t log_wait;
13311 + spinlock_t logbuf_lock; /* lock for the log buffer */
13313 + unsigned long log_start; /* next char to be read by syslog() */
13314 + unsigned long con_start; /* next char to be sent to consoles */
13315 + unsigned long log_end; /* most-recently-written-char + 1 */
13316 + unsigned long logged_chars; /* #chars since last read+clear operation */
13318 + char log_buf[1024];
13322 +/* context sub struct */
13324 +struct _vx_cvirt {
13325 + atomic_t nr_threads; /* number of current threads */
13326 + atomic_t nr_running; /* number of running threads */
13327 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
13329 + atomic_t nr_onhold; /* processes on hold */
13330 + uint32_t onhold_last; /* jiffies when put on hold */
13332 + struct timeval bias_tv; /* time offset to the host */
13333 + struct timespec bias_idle;
13334 + struct timespec bias_uptime; /* context creation point */
13335 + uint64_t bias_clock; /* offset in clock_t */
13337 + spinlock_t load_lock; /* lock for the load averages */
13338 + atomic_t load_updates; /* nr of load updates done so far */
13339 + uint32_t load_last; /* last time load was calculated */
13340 + uint32_t load[3]; /* load averages 1,5,15 */
13342 + atomic_t total_forks; /* number of forks so far */
13344 + struct _vx_syslog syslog;
13347 +struct _vx_cvirt_pc {
13348 + struct _vx_usage_stat cpustat;
13352 +#ifdef CONFIG_VSERVER_DEBUG
13354 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
13356 + printk("\t_vx_cvirt:\n");
13357 + printk("\t threads: %4d, %4d, %4d, %4d\n",
13358 + atomic_read(&cvirt->nr_threads),
13359 + atomic_read(&cvirt->nr_running),
13360 + atomic_read(&cvirt->nr_uninterruptible),
13361 + atomic_read(&cvirt->nr_onhold));
13362 + /* add rest here */
13363 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
13368 +#endif /* _VX_CVIRT_DEF_H */
13369 diff -Nurp linux-2.6.22.18/include/linux/vserver/cvirt.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cvirt.h
13370 --- linux-2.6.22.18/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
13371 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/cvirt.h 2008-02-11 12:35:36.000000000 +0100
13373 +#ifndef _VX_CVIRT_H
13374 +#define _VX_CVIRT_H
13381 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13386 +void vx_update_load(struct vx_info *);
13389 +int vx_do_syslog(int, char __user *, int);
13391 +#endif /* __KERNEL__ */
13392 +#endif /* _VX_CVIRT_H */
13393 diff -Nurp linux-2.6.22.18/include/linux/vserver/debug_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/debug_cmd.h
13394 --- linux-2.6.22.18/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
13395 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/debug_cmd.h 2008-02-11 12:35:36.000000000 +0100
13397 +#ifndef _VX_DEBUG_CMD_H
13398 +#define _VX_DEBUG_CMD_H
13401 +/* debug commands */
13403 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
13405 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
13406 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
13408 +struct vcmd_read_history_v0 {
13411 + char __user *data;
13414 +struct vcmd_read_monitor_v0 {
13417 + char __user *data;
13423 +#ifdef CONFIG_COMPAT
13425 +#include <asm/compat.h>
13427 +struct vcmd_read_history_v0_x32 {
13430 + compat_uptr_t data_ptr;
13433 +struct vcmd_read_monitor_v0_x32 {
13436 + compat_uptr_t data_ptr;
13439 +#endif /* CONFIG_COMPAT */
13441 +extern int vc_dump_history(uint32_t);
13443 +extern int vc_read_history(uint32_t, void __user *);
13444 +extern int vc_read_monitor(uint32_t, void __user *);
13446 +#ifdef CONFIG_COMPAT
13448 +extern int vc_read_history_x32(uint32_t, void __user *);
13449 +extern int vc_read_monitor_x32(uint32_t, void __user *);
13451 +#endif /* CONFIG_COMPAT */
13453 +#endif /* __KERNEL__ */
13454 +#endif /* _VX_DEBUG_CMD_H */
13455 diff -Nurp linux-2.6.22.18/include/linux/vserver/debug.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/debug.h
13456 --- linux-2.6.22.18/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
13457 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/debug.h 2008-02-11 12:35:36.000000000 +0100
13459 +#ifndef _VX_DEBUG_H
13460 +#define _VX_DEBUG_H
13463 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
13464 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
13465 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
13467 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
13468 + imajor((d)->bd_inode), iminor((d)->bd_inode)
13469 +#define VXF_DEV "%p[%lu,%d:%d]"
13472 +#define __FUNC__ __func__
13475 +#define vxd_path(d, m) \
13476 + ({ static char _buffer[PATH_MAX]; \
13477 + d_path(d, m, _buffer, sizeof(_buffer)); })
13479 +#define vxd_cond_path(n) \
13480 + ((n) ? vxd_path((n)->dentry, (n)->mnt) : "<null>" )
13483 +#ifdef CONFIG_VSERVER_DEBUG
13485 +extern unsigned int vx_debug_switch;
13486 +extern unsigned int vx_debug_xid;
13487 +extern unsigned int vx_debug_nid;
13488 +extern unsigned int vx_debug_tag;
13489 +extern unsigned int vx_debug_net;
13490 +extern unsigned int vx_debug_limit;
13491 +extern unsigned int vx_debug_cres;
13492 +extern unsigned int vx_debug_dlim;
13493 +extern unsigned int vx_debug_quota;
13494 +extern unsigned int vx_debug_cvirt;
13495 +extern unsigned int vx_debug_space;
13496 +extern unsigned int vx_debug_misc;
13499 +#define VX_LOGLEVEL "vxD: "
13500 +#define VX_PROC_FMT "%p: "
13501 +#define VX_PROCESS current
13503 +#define vxdprintk(c, f, x...) \
13506 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
13507 + VX_PROCESS , ##x); \
13510 +#define vxlprintk(c, f, x...) \
13513 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
13516 +#define vxfprintk(c, f, x...) \
13519 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
13525 +void dump_vx_info(struct vx_info *, int);
13526 +void dump_vx_info_inactive(int);
13528 +#else /* CONFIG_VSERVER_DEBUG */
13530 +#define vx_debug_switch 0
13531 +#define vx_debug_xid 0
13532 +#define vx_debug_nid 0
13533 +#define vx_debug_tag 0
13534 +#define vx_debug_net 0
13535 +#define vx_debug_limit 0
13536 +#define vx_debug_cres 0
13537 +#define vx_debug_dlim 0
13538 +#define vx_debug_cvirt 0
13540 +#define vxdprintk(x...) do { } while (0)
13541 +#define vxlprintk(x...) do { } while (0)
13542 +#define vxfprintk(x...) do { } while (0)
13544 +#endif /* CONFIG_VSERVER_DEBUG */
13547 +#ifdef CONFIG_VSERVER_WARN
13549 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
13550 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
13551 +#define VX_WARN_XID "[xid #%u] "
13552 +#define VX_WARN_NID "[nid #%u] "
13553 +#define VX_WARN_TAG "[tag #%u] "
13555 +#define vxwprintk(c, f, x...) \
13558 + printk(VX_WARNLEVEL f "\n", ##x); \
13561 +#else /* CONFIG_VSERVER_WARN */
13563 +#define vxwprintk(x...) do { } while (0)
13565 +#endif /* CONFIG_VSERVER_WARN */
13567 +#define vxwprintk_task(c, f, x...) \
13568 + vxwprintk(c, VX_WARN_TASK f, \
13569 + current->comm, current->pid, \
13570 + current->xid, current->nid, current->tag, ##x)
13571 +#define vxwprintk_xid(c, f, x...) \
13572 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
13573 +#define vxwprintk_nid(c, f, x...) \
13574 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
13575 +#define vxwprintk_tag(c, f, x...) \
13576 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
13578 +#ifdef CONFIG_VSERVER_DEBUG
13579 +#define vxd_assert_lock(l) assert_spin_locked(l)
13580 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
13581 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
13583 +#define vxd_assert_lock(l) do { } while (0)
13584 +#define vxd_assert(c, f, x...) do { } while (0)
13588 +#endif /* _VX_DEBUG_H */
13589 diff -Nurp linux-2.6.22.18/include/linux/vserver/device_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/device_cmd.h
13590 --- linux-2.6.22.18/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
13591 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/device_cmd.h 2008-02-11 12:35:36.000000000 +0100
13593 +#ifndef _VX_DEVICE_CMD_H
13594 +#define _VX_DEVICE_CMD_H
13597 +/* device vserver commands */
13599 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
13600 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
13602 +struct vcmd_set_mapping_v0 {
13603 + const char __user *device;
13604 + const char __user *target;
13611 +#ifdef CONFIG_COMPAT
13613 +#include <asm/compat.h>
13615 +struct vcmd_set_mapping_v0_x32 {
13616 + compat_uptr_t device_ptr;
13617 + compat_uptr_t target_ptr;
13621 +#endif /* CONFIG_COMPAT */
13623 +#include <linux/compiler.h>
13625 +extern int vc_set_mapping(struct vx_info *, void __user *);
13626 +extern int vc_unset_mapping(struct vx_info *, void __user *);
13628 +#ifdef CONFIG_COMPAT
13630 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
13631 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
13633 +#endif /* CONFIG_COMPAT */
13635 +#endif /* __KERNEL__ */
13636 +#endif /* _VX_DEVICE_CMD_H */
13637 diff -Nurp linux-2.6.22.18/include/linux/vserver/device_def.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/device_def.h
13638 --- linux-2.6.22.18/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
13639 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/device_def.h 2008-02-11 12:35:36.000000000 +0100
13641 +#ifndef _VX_DEVICE_DEF_H
13642 +#define _VX_DEVICE_DEF_H
13644 +#include <linux/types.h>
13646 +struct vx_dmap_target {
13651 +struct _vx_device {
13652 +#ifdef CONFIG_VSERVER_DEVICE
13653 + struct vx_dmap_target targets[2];
13657 +#endif /* _VX_DEVICE_DEF_H */
13658 diff -Nurp linux-2.6.22.18/include/linux/vserver/device.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/device.h
13659 --- linux-2.6.22.18/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
13660 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/device.h 2008-02-11 12:35:36.000000000 +0100
13662 +#ifndef _VX_DEVICE_H
13663 +#define _VX_DEVICE_H
13666 +#define DATTR_CREATE 0x00000001
13667 +#define DATTR_OPEN 0x00000002
13669 +#define DATTR_REMAP 0x00000010
13671 +#define DATTR_MASK 0x00000013
13674 +#else /* _VX_DEVICE_H */
13675 +#warning duplicate inclusion
13676 +#endif /* _VX_DEVICE_H */
13677 diff -Nurp linux-2.6.22.18/include/linux/vserver/dlimit_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/dlimit_cmd.h
13678 --- linux-2.6.22.18/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
13679 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/dlimit_cmd.h 2008-02-11 12:35:36.000000000 +0100
13681 +#ifndef _VX_DLIMIT_CMD_H
13682 +#define _VX_DLIMIT_CMD_H
13685 +/* dlimit vserver commands */
13687 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
13688 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
13690 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
13691 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
13693 +struct vcmd_ctx_dlimit_base_v0 {
13694 + const char __user *name;
13698 +struct vcmd_ctx_dlimit_v0 {
13699 + const char __user *name;
13700 + uint32_t space_used; /* used space in kbytes */
13701 + uint32_t space_total; /* maximum space in kbytes */
13702 + uint32_t inodes_used; /* used inodes */
13703 + uint32_t inodes_total; /* maximum inodes */
13704 + uint32_t reserved; /* reserved for root in % */
13708 +#define CDLIM_UNSET ((uint32_t)0UL)
13709 +#define CDLIM_INFINITY ((uint32_t)~0UL)
13710 +#define CDLIM_KEEP ((uint32_t)~1UL)
13714 +#ifdef CONFIG_COMPAT
13716 +#include <asm/compat.h>
13718 +struct vcmd_ctx_dlimit_base_v0_x32 {
13719 + compat_uptr_t name_ptr;
13723 +struct vcmd_ctx_dlimit_v0_x32 {
13724 + compat_uptr_t name_ptr;
13725 + uint32_t space_used; /* used space in kbytes */
13726 + uint32_t space_total; /* maximum space in kbytes */
13727 + uint32_t inodes_used; /* used inodes */
13728 + uint32_t inodes_total; /* maximum inodes */
13729 + uint32_t reserved; /* reserved for root in % */
13733 +#endif /* CONFIG_COMPAT */
13735 +#include <linux/compiler.h>
13737 +extern int vc_add_dlimit(uint32_t, void __user *);
13738 +extern int vc_rem_dlimit(uint32_t, void __user *);
13740 +extern int vc_set_dlimit(uint32_t, void __user *);
13741 +extern int vc_get_dlimit(uint32_t, void __user *);
13743 +#ifdef CONFIG_COMPAT
13745 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
13746 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
13748 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
13749 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
13751 +#endif /* CONFIG_COMPAT */
13753 +#endif /* __KERNEL__ */
13754 +#endif /* _VX_DLIMIT_CMD_H */
13755 diff -Nurp linux-2.6.22.18/include/linux/vserver/dlimit.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/dlimit.h
13756 --- linux-2.6.22.18/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
13757 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/dlimit.h 2008-02-11 12:35:36.000000000 +0100
13759 +#ifndef _VX_DLIMIT_H
13760 +#define _VX_DLIMIT_H
13762 +#include "switch.h"
13767 +/* keep in sync with CDLIM_INFINITY */
13769 +#define DLIM_INFINITY (~0ULL)
13771 +#include <linux/spinlock.h>
13772 +#include <linux/rcupdate.h>
13774 +struct super_block;
13777 + struct hlist_node dl_hlist; /* linked list of contexts */
13778 + struct rcu_head dl_rcu; /* the rcu head */
13779 + tag_t dl_tag; /* context tag */
13780 + atomic_t dl_usecnt; /* usage count */
13781 + atomic_t dl_refcnt; /* reference count */
13783 + struct super_block *dl_sb; /* associated superblock */
13785 + spinlock_t dl_lock; /* protect the values */
13787 + unsigned long long dl_space_used; /* used space in bytes */
13788 + unsigned long long dl_space_total; /* maximum space in bytes */
13789 + unsigned long dl_inodes_used; /* used inodes */
13790 + unsigned long dl_inodes_total; /* maximum inodes */
13792 + unsigned int dl_nrlmult; /* non root limit mult */
13797 +extern void rcu_free_dl_info(struct rcu_head *);
13798 +extern void unhash_dl_info(struct dl_info *);
13800 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
13805 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
13807 +typedef uint64_t dlsize_t;
13809 +#endif /* __KERNEL__ */
13810 +#else /* _VX_DLIMIT_H */
13811 +#warning duplicate inclusion
13812 +#endif /* _VX_DLIMIT_H */
13813 diff -Nurp linux-2.6.22.18/include/linux/vserver/global.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/global.h
13814 --- linux-2.6.22.18/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
13815 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/global.h 2008-02-11 12:35:36.000000000 +0100
13817 +#ifndef _VX_GLOBAL_H
13818 +#define _VX_GLOBAL_H
13821 +extern atomic_t vx_global_ctotal;
13822 +extern atomic_t vx_global_cactive;
13824 +extern atomic_t nx_global_ctotal;
13825 +extern atomic_t nx_global_cactive;
13827 +extern atomic_t vs_global_nsproxy;
13828 +extern atomic_t vs_global_fs;
13829 +extern atomic_t vs_global_mnt_ns;
13830 +extern atomic_t vs_global_uts_ns;
13831 +extern atomic_t vs_global_ipc_ns;
13834 +#endif /* _VX_GLOBAL_H */
13835 diff -Nurp linux-2.6.22.18/include/linux/vserver/history.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/history.h
13836 --- linux-2.6.22.18/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
13837 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/history.h 2008-02-11 12:35:36.000000000 +0100
13839 +#ifndef _VX_HISTORY_H
13840 +#define _VX_HISTORY_H
13845 + VXH_THROW_OOPS = 1,
13849 + VXH_INIT_VX_INFO,
13852 + VXH_CLAIM_VX_INFO,
13853 + VXH_RELEASE_VX_INFO,
13854 + VXH_ALLOC_VX_INFO,
13855 + VXH_DEALLOC_VX_INFO,
13856 + VXH_HASH_VX_INFO,
13857 + VXH_UNHASH_VX_INFO,
13859 + VXH_LOOKUP_VX_INFO,
13860 + VXH_CREATE_VX_INFO,
13863 +struct _vxhe_vxi {
13864 + struct vx_info *ptr;
13870 +struct _vxhe_set_clr {
13874 +struct _vxhe_loc_lookup {
13878 +struct _vx_hist_entry {
13880 + unsigned short seq;
13881 + unsigned short type;
13882 + struct _vxhe_vxi vxi;
13884 + struct _vxhe_set_clr sc;
13885 + struct _vxhe_loc_lookup ll;
13889 +#ifdef CONFIG_VSERVER_HISTORY
13891 +extern unsigned volatile int vxh_active;
13893 +struct _vx_hist_entry *vxh_advance(void *loc);
13897 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
13899 + entry->vxi.ptr = vxi;
13901 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
13902 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
13903 + entry->vxi.xid = vxi->vx_id;
13908 +#define __HERE__ current_text_addr()
13910 +#define __VXH_BODY(__type, __data, __here) \
13911 + struct _vx_hist_entry *entry; \
13913 + preempt_disable(); \
13914 + entry = vxh_advance(__here); \
13916 + entry->type = __type; \
13917 + preempt_enable();
13920 + /* pass vxi only */
13922 +#define __VXH_SMPL \
13923 + __vxh_copy_vxi(entry, vxi)
13926 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
13928 + __VXH_BODY(__type, __VXH_SMPL, __here)
13931 + /* pass vxi and data (void *) */
13933 +#define __VXH_DATA \
13934 + __vxh_copy_vxi(entry, vxi); \
13935 + entry->sc.data = data
13938 +void __vxh_data(struct vx_info *vxi, void *data,
13939 + int __type, void *__here)
13941 + __VXH_BODY(__type, __VXH_DATA, __here)
13944 + /* pass vxi and arg (long) */
13946 +#define __VXH_LONG \
13947 + __vxh_copy_vxi(entry, vxi); \
13948 + entry->ll.arg = arg
13951 +void __vxh_long(struct vx_info *vxi, long arg,
13952 + int __type, void *__here)
13954 + __VXH_BODY(__type, __VXH_LONG, __here)
13959 +void __vxh_throw_oops(void *__here)
13961 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
13962 + /* prevent further acquisition */
13967 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
13969 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
13970 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13972 +#define __vxh_init_vx_info(v, d, h) \
13973 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13974 +#define __vxh_set_vx_info(v, d, h) \
13975 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
13976 +#define __vxh_clr_vx_info(v, d, h) \
13977 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13979 +#define __vxh_claim_vx_info(v, d, h) \
13980 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13981 +#define __vxh_release_vx_info(v, d, h) \
13982 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13984 +#define vxh_alloc_vx_info(v) \
13985 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13986 +#define vxh_dealloc_vx_info(v) \
13987 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13989 +#define vxh_hash_vx_info(v) \
13990 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13991 +#define vxh_unhash_vx_info(v) \
13992 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13994 +#define vxh_loc_vx_info(v, l) \
13995 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13996 +#define vxh_lookup_vx_info(v, l) \
13997 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13998 +#define vxh_create_vx_info(v, l) \
13999 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
14001 +extern void vxh_dump_history(void);
14004 +#else /* CONFIG_VSERVER_HISTORY */
14006 +#define __HERE__ 0
14008 +#define vxh_throw_oops() do { } while (0)
14010 +#define __vxh_get_vx_info(v, h) do { } while (0)
14011 +#define __vxh_put_vx_info(v, h) do { } while (0)
14013 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
14014 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
14015 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
14017 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
14018 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
14020 +#define vxh_alloc_vx_info(v) do { } while (0)
14021 +#define vxh_dealloc_vx_info(v) do { } while (0)
14023 +#define vxh_hash_vx_info(v) do { } while (0)
14024 +#define vxh_unhash_vx_info(v) do { } while (0)
14026 +#define vxh_loc_vx_info(v, l) do { } while (0)
14027 +#define vxh_lookup_vx_info(v, l) do { } while (0)
14028 +#define vxh_create_vx_info(v, l) do { } while (0)
14030 +#define vxh_dump_history() do { } while (0)
14033 +#endif /* CONFIG_VSERVER_HISTORY */
14035 +#endif /* _VX_HISTORY_H */
14036 diff -Nurp linux-2.6.22.18/include/linux/vserver/inode_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/inode_cmd.h
14037 --- linux-2.6.22.18/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
14038 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/inode_cmd.h 2008-02-11 12:35:36.000000000 +0100
14040 +#ifndef _VX_INODE_CMD_H
14041 +#define _VX_INODE_CMD_H
14044 +/* inode vserver commands */
14046 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
14047 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
14049 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
14050 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
14052 +struct vcmd_ctx_iattr_v1 {
14053 + const char __user *name;
14059 +struct vcmd_ctx_fiattr_v0 {
14069 +#ifdef CONFIG_COMPAT
14071 +#include <asm/compat.h>
14073 +struct vcmd_ctx_iattr_v1_x32 {
14074 + compat_uptr_t name_ptr;
14080 +#endif /* CONFIG_COMPAT */
14082 +#include <linux/compiler.h>
14084 +extern int vc_get_iattr(void __user *);
14085 +extern int vc_set_iattr(void __user *);
14087 +extern int vc_fget_iattr(uint32_t, void __user *);
14088 +extern int vc_fset_iattr(uint32_t, void __user *);
14090 +#ifdef CONFIG_COMPAT
14092 +extern int vc_get_iattr_x32(void __user *);
14093 +extern int vc_set_iattr_x32(void __user *);
14095 +#endif /* CONFIG_COMPAT */
14097 +#endif /* __KERNEL__ */
14098 +#endif /* _VX_INODE_CMD_H */
14099 diff -Nurp linux-2.6.22.18/include/linux/vserver/inode.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/inode.h
14100 --- linux-2.6.22.18/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
14101 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/inode.h 2008-02-11 12:35:36.000000000 +0100
14103 +#ifndef _VX_INODE_H
14104 +#define _VX_INODE_H
14107 +#define IATTR_TAG 0x01000000
14109 +#define IATTR_ADMIN 0x00000001
14110 +#define IATTR_WATCH 0x00000002
14111 +#define IATTR_HIDE 0x00000004
14112 +#define IATTR_FLAGS 0x00000007
14114 +#define IATTR_BARRIER 0x00010000
14115 +#define IATTR_IUNLINK 0x00020000
14116 +#define IATTR_IMMUTABLE 0x00040000
14121 +#ifdef CONFIG_VSERVER_PROC_SECURE
14122 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
14123 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
14125 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
14126 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
14129 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
14131 +#endif /* __KERNEL__ */
14133 +/* inode ioctls */
14135 +#define FIOC_GETXFLG _IOR('x', 5, long)
14136 +#define FIOC_SETXFLG _IOW('x', 6, long)
14138 +#else /* _VX_INODE_H */
14139 +#warning duplicate inclusion
14140 +#endif /* _VX_INODE_H */
14141 diff -Nurp linux-2.6.22.18/include/linux/vserver/Kbuild linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/Kbuild
14142 --- linux-2.6.22.18/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
14143 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/Kbuild 2008-02-11 12:35:36.000000000 +0100
14146 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
14147 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
14148 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
14149 + debug_cmd.h device_cmd.h
14151 +unifdef-y += switch.h network.h monitor.h inode.h device.h
14153 diff -Nurp linux-2.6.22.18/include/linux/vserver/limit_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/limit_cmd.h
14154 --- linux-2.6.22.18/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
14155 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/limit_cmd.h 2008-02-11 12:35:36.000000000 +0100
14157 +#ifndef _VX_LIMIT_CMD_H
14158 +#define _VX_LIMIT_CMD_H
14161 +/* rlimit vserver commands */
14163 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
14164 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
14165 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
14166 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
14168 +struct vcmd_ctx_rlimit_v0 {
14170 + uint64_t minimum;
14171 + uint64_t softlimit;
14172 + uint64_t maximum;
14175 +struct vcmd_ctx_rlimit_mask_v0 {
14176 + uint32_t minimum;
14177 + uint32_t softlimit;
14178 + uint32_t maximum;
14181 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
14183 +struct vcmd_rlimit_stat_v0 {
14187 + uint64_t minimum;
14188 + uint64_t maximum;
14191 +#define CRLIM_UNSET (0ULL)
14192 +#define CRLIM_INFINITY (~0ULL)
14193 +#define CRLIM_KEEP (~1ULL)
14197 +#ifdef CONFIG_IA32_EMULATION
14199 +struct vcmd_ctx_rlimit_v0_x32 {
14201 + uint64_t minimum;
14202 + uint64_t softlimit;
14203 + uint64_t maximum;
14204 +} __attribute__ ((aligned (4)));
14206 +#endif /* CONFIG_IA32_EMULATION */
14208 +#include <linux/compiler.h>
14210 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
14211 +extern int vc_get_rlimit(struct vx_info *, void __user *);
14212 +extern int vc_set_rlimit(struct vx_info *, void __user *);
14213 +extern int vc_reset_minmax(struct vx_info *, void __user *);
14215 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
14217 +#ifdef CONFIG_IA32_EMULATION
14219 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
14220 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
14222 +#endif /* CONFIG_IA32_EMULATION */
14224 +#endif /* __KERNEL__ */
14225 +#endif /* _VX_LIMIT_CMD_H */
14226 diff -Nurp linux-2.6.22.18/include/linux/vserver/limit_def.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/limit_def.h
14227 --- linux-2.6.22.18/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
14228 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/limit_def.h 2008-02-11 12:35:36.000000000 +0100
14230 +#ifndef _VX_LIMIT_DEF_H
14231 +#define _VX_LIMIT_DEF_H
14233 +#include <asm/atomic.h>
14234 +#include <asm/resource.h>
14236 +#include "limit.h"
14239 +struct _vx_res_limit {
14240 + rlim_t soft; /* Context soft limit */
14241 + rlim_t hard; /* Context hard limit */
14243 + rlim_atomic_t rcur; /* Current value */
14244 + rlim_t rmin; /* Context minimum */
14245 + rlim_t rmax; /* Context maximum */
14247 + atomic_t lhit; /* Limit hits */
14250 +/* context sub struct */
14252 +struct _vx_limit {
14253 + struct _vx_res_limit res[NUM_LIMITS];
14256 +#ifdef CONFIG_VSERVER_DEBUG
14258 +static inline void __dump_vx_limit(struct _vx_limit *limit)
14262 + printk("\t_vx_limit:");
14263 + for (i = 0; i < NUM_LIMITS; i++) {
14264 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
14265 + i, (unsigned long)__rlim_get(limit, i),
14266 + (unsigned long)__rlim_rmin(limit, i),
14267 + (unsigned long)__rlim_rmax(limit, i),
14268 + (long)__rlim_soft(limit, i),
14269 + (long)__rlim_hard(limit, i),
14270 + atomic_read(&__rlim_lhit(limit, i)));
14276 +#endif /* _VX_LIMIT_DEF_H */
14277 diff -Nurp linux-2.6.22.18/include/linux/vserver/limit.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/limit.h
14278 --- linux-2.6.22.18/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
14279 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/limit.h 2008-02-11 12:35:36.000000000 +0100
14281 +#ifndef _VX_LIMIT_H
14282 +#define _VX_LIMIT_H
14284 +#define VLIMIT_NSOCK 16
14285 +#define VLIMIT_OPENFD 17
14286 +#define VLIMIT_ANON 18
14287 +#define VLIMIT_SHMEM 19
14288 +#define VLIMIT_SEMARY 20
14289 +#define VLIMIT_NSEMS 21
14290 +#define VLIMIT_DENTRY 22
14291 +#define VLIMIT_MAPPED 23
14296 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
14298 +/* keep in sync with CRLIM_INFINITY */
14300 +#define VLIM_INFINITY (~0ULL)
14302 +#include <asm/atomic.h>
14303 +#include <asm/resource.h>
14305 +#ifndef RLIM_INFINITY
14306 +#warning RLIM_INFINITY is undefined
14309 +#define __rlim_val(l, r, v) ((l)->res[r].v)
14311 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
14312 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
14314 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
14315 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
14316 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
14318 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
14319 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
14321 +typedef atomic_long_t rlim_atomic_t;
14322 +typedef unsigned long rlim_t;
14324 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
14325 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
14326 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
14327 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
14328 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
14329 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
14332 +#if (RLIM_INFINITY == VLIM_INFINITY)
14333 +#define VX_VLIM(r) ((long long)(long)(r))
14334 +#define VX_RLIM(v) ((rlim_t)(v))
14336 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
14337 + ? VLIM_INFINITY : (long long)(r))
14338 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
14339 + ? RLIM_INFINITY : (rlim_t)(v))
14344 +void vx_vsi_meminfo(struct sysinfo *);
14345 +void vx_vsi_swapinfo(struct sysinfo *);
14347 +#define NUM_LIMITS 24
14349 +#endif /* __KERNEL__ */
14350 +#endif /* _VX_LIMIT_H */
14351 diff -Nurp linux-2.6.22.18/include/linux/vserver/limit_int.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/limit_int.h
14352 --- linux-2.6.22.18/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
14353 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/limit_int.h 2008-02-11 12:35:36.000000000 +0100
14355 +#ifndef _VX_LIMIT_INT_H
14356 +#define _VX_LIMIT_INT_H
14358 +#include "context.h"
14362 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
14363 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
14365 +extern const char *vlimit_name[NUM_LIMITS];
14367 +static inline void __vx_acc_cres(struct vx_info *vxi,
14368 + int res, int dir, void *_data, char *_file, int _line)
14370 + if (VXD_RCRES_COND(res))
14371 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
14372 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14373 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14374 + (dir > 0) ? "++" : "--", _data, _file, _line);
14379 + __rlim_inc(&vxi->limit, res);
14381 + __rlim_dec(&vxi->limit, res);
14384 +static inline void __vx_add_cres(struct vx_info *vxi,
14385 + int res, int amount, void *_data, char *_file, int _line)
14387 + if (VXD_RCRES_COND(res))
14388 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
14389 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14390 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14391 + amount, _data, _file, _line);
14396 + __rlim_add(&vxi->limit, res, amount);
14400 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
14402 + int cond = (value > __rlim_rmax(limit, res));
14405 + __rlim_rmax(limit, res) = value;
14410 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
14412 + int cond = (value < __rlim_rmin(limit, res));
14415 + __rlim_rmin(limit, res) = value;
14420 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
14422 + if (!__vx_cres_adjust_max(limit, res, value))
14423 + __vx_cres_adjust_min(limit, res, value);
14428 + +1 ... no limit hit
14429 + -1 ... over soft limit
14430 + 0 ... over hard limit */
14432 +static inline int __vx_cres_avail(struct vx_info *vxi,
14433 + int res, int num, char *_file, int _line)
14435 + struct _vx_limit *limit;
14438 + if (VXD_RLIMIT_COND(res))
14439 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
14440 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14441 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
14442 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
14443 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14444 + num, _file, _line);
14448 + limit = &vxi->limit;
14449 + value = __rlim_get(limit, res);
14451 + if (!__vx_cres_adjust_max(limit, res, value))
14452 + __vx_cres_adjust_min(limit, res, value);
14457 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
14459 + if (value + num <= __rlim_soft(limit, res))
14462 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
14464 + if (value + num <= __rlim_hard(limit, res))
14467 + __rlim_hit(limit, res);
14472 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
14475 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
14477 + rlim_t value, sum = 0;
14480 + while ((res = *array++)) {
14481 + value = __rlim_get(limit, res);
14482 + __vx_cres_fixup(limit, res, value);
14489 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
14491 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
14492 + int res = *array;
14494 + if (value == __rlim_get(limit, res))
14497 + __rlim_set(limit, res, value);
14498 + /* now adjust min/max */
14499 + if (!__vx_cres_adjust_max(limit, res, value))
14500 + __vx_cres_adjust_min(limit, res, value);
14505 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
14506 + const int *array, int num, char *_file, int _line)
14508 + struct _vx_limit *limit;
14509 + rlim_t value = 0;
14517 + limit = &vxi->limit;
14519 + value = __vx_cres_array_sum(limit, array + 1);
14521 + __rlim_set(limit, res, value);
14522 + __vx_cres_fixup(limit, res, value);
14524 + return __vx_cres_avail(vxi, res, num, _file, _line);
14528 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
14533 + /* complex resources first */
14534 + if ((id < 0) || (id == RLIMIT_RSS))
14535 + __vx_cres_array_fixup(limit, VLA_RSS);
14537 + for (res = 0; res < NUM_LIMITS; res++) {
14538 + if ((id > 0) && (res != id))
14541 + value = __rlim_get(limit, res);
14542 + __vx_cres_fixup(limit, res, value);
14544 + /* not supposed to happen, maybe warn? */
14545 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
14546 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
14551 +#endif /* __KERNEL__ */
14552 +#endif /* _VX_LIMIT_INT_H */
14553 diff -Nurp linux-2.6.22.18/include/linux/vserver/monitor.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/monitor.h
14554 --- linux-2.6.22.18/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
14555 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/monitor.h 2008-02-11 12:35:36.000000000 +0100
14557 +#ifndef _VX_MONITOR_H
14558 +#define _VX_MONITOR_H
14560 +#include <linux/types.h>
14567 + VXM_UPDATE = 0x20,
14571 + VXM_RQINFO_1 = 0x24,
14574 + VXM_ACTIVATE = 0x40,
14581 + VXM_MIGRATE = 0x48,
14584 + /* all other bits are flags */
14585 + VXM_SCHED = 0x80,
14588 +struct _vxm_update_1 {
14589 + uint32_t tokens_max;
14590 + uint32_t fill_rate;
14591 + uint32_t interval;
14594 +struct _vxm_update_2 {
14595 + uint32_t tokens_min;
14596 + uint32_t fill_rate;
14597 + uint32_t interval;
14600 +struct _vxm_rqinfo_1 {
14601 + uint16_t running;
14605 + uint32_t idle_tokens;
14608 +struct _vxm_rqinfo_2 {
14609 + uint32_t norm_time;
14610 + uint32_t idle_time;
14611 + uint32_t idle_skip;
14614 +struct _vxm_sched {
14616 + uint32_t norm_time;
14617 + uint32_t idle_time;
14620 +struct _vxm_task {
14625 +struct _vxm_event {
14634 + struct _vxm_task tsk;
14638 +struct _vx_mon_entry {
14642 + struct _vxm_event ev;
14643 + struct _vxm_sched sd;
14644 + struct _vxm_update_1 u1;
14645 + struct _vxm_update_2 u2;
14646 + struct _vxm_rqinfo_1 q1;
14647 + struct _vxm_rqinfo_2 q2;
14652 +#endif /* _VX_MONITOR_H */
14653 diff -Nurp linux-2.6.22.18/include/linux/vserver/network_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/network_cmd.h
14654 --- linux-2.6.22.18/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
14655 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/network_cmd.h 2008-02-11 12:35:36.000000000 +0100
14657 +#ifndef _VX_NETWORK_CMD_H
14658 +#define _VX_NETWORK_CMD_H
14661 +/* vinfo commands */
14663 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
14666 +extern int vc_task_nid(uint32_t);
14668 +#endif /* __KERNEL__ */
14670 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
14672 +struct vcmd_nx_info_v0 {
14674 + /* more to come */
14678 +extern int vc_nx_info(struct nx_info *, void __user *);
14680 +#endif /* __KERNEL__ */
14682 +#include <linux/in.h>
14683 +#include <linux/in6.h>
14685 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
14686 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
14688 +struct vcmd_net_create {
14689 + uint64_t flagword;
14692 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
14694 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
14695 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
14697 +struct vcmd_net_addr_v0 {
14700 + struct in_addr ip[4];
14701 + struct in_addr mask[4];
14704 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
14705 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
14707 +struct vcmd_net_addr_ipv4_v1 {
14710 + struct in_addr ip;
14711 + struct in_addr mask;
14714 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
14715 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
14717 +struct vcmd_net_addr_ipv6_v1 {
14721 + struct in6_addr ip;
14722 + struct in6_addr mask;
14725 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
14726 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
14728 +struct vcmd_match_ipv4_v0 {
14733 + struct in_addr ip;
14734 + struct in_addr ip2;
14735 + struct in_addr mask;
14738 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
14739 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
14741 +struct vcmd_match_ipv6_v0 {
14746 + struct in6_addr ip;
14747 + struct in6_addr ip2;
14748 + struct in6_addr mask;
14753 +extern int vc_net_create(uint32_t, void __user *);
14754 +extern int vc_net_migrate(struct nx_info *, void __user *);
14756 +extern int vc_net_add(struct nx_info *, void __user *);
14757 +extern int vc_net_remove(struct nx_info *, void __user *);
14759 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
14760 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
14762 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
14763 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
14765 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
14766 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
14768 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
14769 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
14771 +#endif /* __KERNEL__ */
14774 +/* flag commands */
14776 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
14777 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
14779 +struct vcmd_net_flags_v0 {
14780 + uint64_t flagword;
14785 +extern int vc_get_nflags(struct nx_info *, void __user *);
14786 +extern int vc_set_nflags(struct nx_info *, void __user *);
14788 +#endif /* __KERNEL__ */
14791 +/* network caps commands */
14793 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
14794 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
14796 +struct vcmd_net_caps_v0 {
14802 +extern int vc_get_ncaps(struct nx_info *, void __user *);
14803 +extern int vc_set_ncaps(struct nx_info *, void __user *);
14805 +#endif /* __KERNEL__ */
14806 +#endif /* _VX_CONTEXT_CMD_H */
14807 diff -Nurp linux-2.6.22.18/include/linux/vserver/network.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/network.h
14808 --- linux-2.6.22.18/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
14809 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/network.h 2008-02-11 12:35:36.000000000 +0100
14811 +#ifndef _VX_NETWORK_H
14812 +#define _VX_NETWORK_H
14814 +#include <linux/types.h>
14817 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
14820 +/* network flags */
14822 +#define NXF_INFO_PRIVATE 0x00000008
14824 +#define NXF_SINGLE_IP 0x00000100
14825 +#define NXF_LBACK_REMAP 0x00000200
14827 +#define NXF_HIDE_NETIF 0x02000000
14828 +#define NXF_HIDE_LBACK 0x04000000
14830 +#define NXF_STATE_SETUP (1ULL << 32)
14831 +#define NXF_STATE_ADMIN (1ULL << 34)
14833 +#define NXF_SC_HELPER (1ULL << 36)
14834 +#define NXF_PERSISTENT (1ULL << 38)
14836 +#define NXF_ONE_TIME (0x0005ULL << 32)
14839 +#define NXF_INIT_SET (__nxf_init_set())
14841 +static inline uint64_t __nxf_init_set(void) {
14842 + return NXF_STATE_ADMIN
14843 +#ifdef CONFIG_VSERVER_AUTO_LBACK
14844 + | NXF_LBACK_REMAP
14847 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
14850 + | NXF_HIDE_NETIF;
14854 +/* network caps */
14856 +#define NXC_RAW_ICMP 0x00000100
14859 +/* address types */
14861 +#define NXA_TYPE_IPV4 0x0001
14862 +#define NXA_TYPE_IPV6 0x0002
14864 +#define NXA_TYPE_NONE 0x0000
14865 +#define NXA_TYPE_ANY 0x00FF
14867 +#define NXA_TYPE_ADDR 0x0010
14868 +#define NXA_TYPE_MASK 0x0020
14869 +#define NXA_TYPE_RANGE 0x0040
14871 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
14873 +#define NXA_MOD_BCAST 0x0100
14874 +#define NXA_MOD_LBACK 0x0200
14876 +#define NXA_LOOPBACK 0x1000
14878 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
14879 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
14883 +#include <linux/list.h>
14884 +#include <linux/spinlock.h>
14885 +#include <linux/rcupdate.h>
14886 +#include <linux/in.h>
14887 +#include <linux/in6.h>
14888 +#include <asm/atomic.h>
14890 +struct nx_addr_v4 {
14891 + struct nx_addr_v4 *next;
14892 + struct in_addr ip[2];
14893 + struct in_addr mask;
14898 +struct nx_addr_v6 {
14899 + struct nx_addr_v6 *next;
14900 + struct in6_addr ip;
14901 + struct in6_addr mask;
14908 + struct hlist_node nx_hlist; /* linked list of nxinfos */
14909 + nid_t nx_id; /* vnet id */
14910 + atomic_t nx_usecnt; /* usage count */
14911 + atomic_t nx_tasks; /* tasks count */
14912 + int nx_state; /* context state */
14914 + uint64_t nx_flags; /* network flag word */
14915 + uint64_t nx_ncaps; /* network capabilities */
14917 + struct in_addr v4_lback; /* Loopback address */
14918 + struct in_addr v4_bcast; /* Broadcast address */
14919 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
14920 +#ifdef CONFIG_IPV6
14921 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
14923 + char nx_name[65]; /* network context name */
14927 +/* status flags */
14929 +#define NXS_HASHED 0x0001
14930 +#define NXS_SHUTDOWN 0x0100
14931 +#define NXS_RELEASED 0x8000
14933 +extern struct nx_info *lookup_nx_info(int);
14935 +extern int get_nid_list(int, unsigned int *, int);
14936 +extern int nid_is_hashed(nid_t);
14938 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
14940 +extern long vs_net_change(struct nx_info *, unsigned int);
14945 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
14946 +#ifdef CONFIG_IPV6
14947 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
14949 +#define NX_IPV6(n) (0)
14952 +#endif /* __KERNEL__ */
14953 +#endif /* _VX_NETWORK_H */
14954 diff -Nurp linux-2.6.22.18/include/linux/vserver/percpu.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/percpu.h
14955 --- linux-2.6.22.18/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
14956 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/percpu.h 2008-02-11 12:35:36.000000000 +0100
14958 +#ifndef _VX_PERCPU_H
14959 +#define _VX_PERCPU_H
14961 +#include "cvirt_def.h"
14962 +#include "sched_def.h"
14964 +struct _vx_percpu {
14965 + struct _vx_cvirt_pc cvirt;
14966 + struct _vx_sched_pc sched;
14969 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
14971 +#endif /* _VX_PERCPU_H */
14972 diff -Nurp linux-2.6.22.18/include/linux/vserver/sched_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/sched_cmd.h
14973 --- linux-2.6.22.18/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
14974 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/sched_cmd.h 2008-02-11 12:35:36.000000000 +0100
14976 +#ifndef _VX_SCHED_CMD_H
14977 +#define _VX_SCHED_CMD_H
14980 +/* sched vserver commands */
14982 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
14983 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
14984 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
14986 +struct vcmd_set_sched_v2 {
14987 + int32_t fill_rate;
14988 + int32_t interval;
14990 + int32_t tokens_min;
14991 + int32_t tokens_max;
14992 + uint64_t cpu_mask;
14995 +struct vcmd_set_sched_v3 {
14996 + uint32_t set_mask;
14997 + int32_t fill_rate;
14998 + int32_t interval;
15000 + int32_t tokens_min;
15001 + int32_t tokens_max;
15002 + int32_t priority_bias;
15005 +struct vcmd_set_sched_v4 {
15006 + uint32_t set_mask;
15007 + int32_t fill_rate;
15008 + int32_t interval;
15010 + int32_t tokens_min;
15011 + int32_t tokens_max;
15012 + int32_t prio_bias;
15014 + int32_t bucket_id;
15017 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
15018 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
15020 +struct vcmd_sched_v5 {
15023 + int32_t bucket_id;
15024 + int32_t fill_rate[2];
15025 + int32_t interval[2];
15027 + int32_t tokens_min;
15028 + int32_t tokens_max;
15029 + int32_t prio_bias;
15032 +#define VXSM_FILL_RATE 0x0001
15033 +#define VXSM_INTERVAL 0x0002
15034 +#define VXSM_FILL_RATE2 0x0004
15035 +#define VXSM_INTERVAL2 0x0008
15036 +#define VXSM_TOKENS 0x0010
15037 +#define VXSM_TOKENS_MIN 0x0020
15038 +#define VXSM_TOKENS_MAX 0x0040
15039 +#define VXSM_PRIO_BIAS 0x0100
15041 +#define VXSM_IDLE_TIME 0x0200
15042 +#define VXSM_FORCE 0x0400
15044 +#define VXSM_V3_MASK 0x0173
15045 +#define VXSM_SET_MASK 0x01FF
15047 +#define VXSM_CPU_ID 0x1000
15048 +#define VXSM_BUCKET_ID 0x2000
15050 +#define VXSM_MSEC 0x4000
15052 +#define SCHED_KEEP (-2) /* only for v2 */
15056 +#include <linux/compiler.h>
15058 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
15059 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
15060 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
15061 +extern int vc_set_sched(struct vx_info *, void __user *);
15062 +extern int vc_get_sched(struct vx_info *, void __user *);
15064 +#endif /* __KERNEL__ */
15066 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
15068 +struct vcmd_sched_info {
15070 + int32_t bucket_id;
15071 + uint64_t user_msec;
15072 + uint64_t sys_msec;
15073 + uint64_t hold_msec;
15074 + uint32_t token_usec;
15075 + int32_t vavavoom;
15080 +extern int vc_sched_info(struct vx_info *, void __user *);
15082 +#endif /* __KERNEL__ */
15083 +#endif /* _VX_SCHED_CMD_H */
15084 diff -Nurp linux-2.6.22.18/include/linux/vserver/sched_def.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/sched_def.h
15085 --- linux-2.6.22.18/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
15086 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/sched_def.h 2008-02-11 12:35:36.000000000 +0100
15088 +#ifndef _VX_SCHED_DEF_H
15089 +#define _VX_SCHED_DEF_H
15091 +#include <linux/spinlock.h>
15092 +#include <linux/jiffies.h>
15093 +#include <linux/cpumask.h>
15094 +#include <asm/atomic.h>
15095 +#include <asm/param.h>
15098 +/* context sub struct */
15100 +struct _vx_sched {
15101 + spinlock_t tokens_lock; /* lock for token bucket */
15103 + int tokens; /* number of CPU tokens */
15104 + int fill_rate[2]; /* Fill rate: add X tokens... */
15105 + int interval[2]; /* Divisor: per Y jiffies */
15106 + int tokens_min; /* Limit: minimum for unhold */
15107 + int tokens_max; /* Limit: no more than N tokens */
15109 + int prio_bias; /* bias offset for priority */
15111 + unsigned update_mask; /* which features should be updated */
15112 + cpumask_t update; /* CPUs which should update */
15115 +struct _vx_sched_pc {
15116 + int tokens; /* number of CPU tokens */
15117 + int flags; /* bucket flags */
15119 + int fill_rate[2]; /* Fill rate: add X tokens... */
15120 + int interval[2]; /* Divisor: per Y jiffies */
15121 + int tokens_min; /* Limit: minimum for unhold */
15122 + int tokens_max; /* Limit: no more than N tokens */
15124 + int prio_bias; /* bias offset for priority */
15125 + int vavavoom; /* last calculated vavavoom */
15127 + unsigned long norm_time; /* last time accounted */
15128 + unsigned long idle_time; /* non linear time for fair sched */
15129 + unsigned long token_time; /* token time for accounting */
15130 + unsigned long onhold; /* jiffies when put on hold */
15132 + uint64_t user_ticks; /* token tick events */
15133 + uint64_t sys_ticks; /* token tick events */
15134 + uint64_t hold_ticks; /* token ticks paused */
15138 +#define VXSF_ONHOLD 0x0001
15139 +#define VXSF_IDLE_TIME 0x0100
15141 +#ifdef CONFIG_VSERVER_DEBUG
15143 +static inline void __dump_vx_sched(struct _vx_sched *sched)
15145 + printk("\t_vx_sched:\n");
15146 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
15147 + sched->fill_rate[0], sched->interval[0],
15148 + sched->fill_rate[1], sched->interval[1],
15149 + sched->tokens_min, sched->tokens_max);
15150 + printk("\t priority = %4d\n", sched->prio_bias);
15155 +#endif /* _VX_SCHED_DEF_H */
15156 diff -Nurp linux-2.6.22.18/include/linux/vserver/sched.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/sched.h
15157 --- linux-2.6.22.18/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
15158 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/sched.h 2008-02-11 12:35:36.000000000 +0100
15160 +#ifndef _VX_SCHED_H
15161 +#define _VX_SCHED_H
15168 +void vx_vsi_uptime(struct timespec *, struct timespec *);
15173 +void vx_update_load(struct vx_info *);
15176 +int vx_tokens_recalc(struct _vx_sched_pc *,
15177 + unsigned long *, unsigned long *, int [2]);
15179 +void vx_update_sched_param(struct _vx_sched *sched,
15180 + struct _vx_sched_pc *sched_pc);
15182 +#endif /* __KERNEL__ */
15183 +#else /* _VX_SCHED_H */
15184 +#warning duplicate inclusion
15185 +#endif /* _VX_SCHED_H */
15186 diff -Nurp linux-2.6.22.18/include/linux/vserver/signal_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/signal_cmd.h
15187 --- linux-2.6.22.18/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
15188 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/signal_cmd.h 2008-02-11 12:35:36.000000000 +0100
15190 +#ifndef _VX_SIGNAL_CMD_H
15191 +#define _VX_SIGNAL_CMD_H
15194 +/* signalling vserver commands */
15196 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
15197 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
15199 +struct vcmd_ctx_kill_v0 {
15204 +struct vcmd_wait_exit_v0 {
15205 + int32_t reboot_cmd;
15206 + int32_t exit_code;
15211 +extern int vc_ctx_kill(struct vx_info *, void __user *);
15212 +extern int vc_wait_exit(struct vx_info *, void __user *);
15214 +#endif /* __KERNEL__ */
15216 +/* process alteration commands */
15218 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
15219 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
15221 +struct vcmd_pflags_v0 {
15222 + uint32_t flagword;
15228 +extern int vc_get_pflags(uint32_t pid, void __user *);
15229 +extern int vc_set_pflags(uint32_t pid, void __user *);
15231 +#endif /* __KERNEL__ */
15232 +#endif /* _VX_SIGNAL_CMD_H */
15233 diff -Nurp linux-2.6.22.18/include/linux/vserver/signal.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/signal.h
15234 --- linux-2.6.22.18/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
15235 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/signal.h 2008-02-11 12:35:36.000000000 +0100
15237 +#ifndef _VX_SIGNAL_H
15238 +#define _VX_SIGNAL_H
15245 +int vx_info_kill(struct vx_info *, int, int);
15247 +#endif /* __KERNEL__ */
15248 +#else /* _VX_SIGNAL_H */
15249 +#warning duplicate inclusion
15250 +#endif /* _VX_SIGNAL_H */
15251 diff -Nurp linux-2.6.22.18/include/linux/vserver/space_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/space_cmd.h
15252 --- linux-2.6.22.18/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
15253 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/space_cmd.h 2008-02-11 12:35:36.000000000 +0100
15255 +#ifndef _VX_SPACE_CMD_H
15256 +#define _VX_SPACE_CMD_H
15259 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
15260 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 1)
15262 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
15263 +#define VCMD_set_space VC_CMD(PROCALT, 3, 1)
15265 +#define VCMD_get_space_mask VC_CMD(PROCALT, 4, 0)
15268 +struct vcmd_space_mask {
15275 +extern int vc_enter_space(struct vx_info *, void __user *);
15276 +extern int vc_set_space(struct vx_info *, void __user *);
15277 +extern int vc_get_space_mask(struct vx_info *, void __user *);
15279 +#endif /* __KERNEL__ */
15280 +#endif /* _VX_SPACE_CMD_H */
15281 diff -Nurp linux-2.6.22.18/include/linux/vserver/space.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/space.h
15282 --- linux-2.6.22.18/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
15283 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/space.h 2008-02-11 12:35:36.000000000 +0100
15285 +#ifndef _VX_SPACE_H
15286 +#define _VX_SPACE_H
15289 +#include <linux/types.h>
15293 +int vx_set_space(struct vx_info *vxi, unsigned long mask);
15295 +#else /* _VX_SPACE_H */
15296 +#warning duplicate inclusion
15297 +#endif /* _VX_SPACE_H */
15298 diff -Nurp linux-2.6.22.18/include/linux/vserver/switch.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/switch.h
15299 --- linux-2.6.22.18/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
15300 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/switch.h 2008-02-11 12:35:36.000000000 +0100
15302 +#ifndef _VX_SWITCH_H
15303 +#define _VX_SWITCH_H
15305 +#include <linux/types.h>
15308 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
15309 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
15310 +#define VC_VERSION(c) ((c) & 0xFFF)
15312 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
15313 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
15317 + Syscall Matrix V2.8
15319 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
15320 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
15321 + |INFO |SETUP | |MOVE | | | | | |
15322 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15323 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
15324 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
15325 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15326 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
15327 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
15328 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15329 + MEMORY | | | | |MEMCTRL| | |SWAP | |
15330 + | 16| 17| 18| 19| 20| 21| | 22| 23|
15331 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15332 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
15333 + | 24| 25| 26| 27| 28| 29| | 30| 31|
15334 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15335 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
15336 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
15337 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15338 + OTHER |VSTAT | | | | | | |VINFO | |
15339 + | 40| 41| 42| 43| 44| 45| | 46| 47|
15340 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
15341 + SPECIAL|EVENT | | | |FLAGS | | | | |
15342 + | 48| 49| 50| 51| 52| 53| | 54| 55|
15343 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15344 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
15345 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
15346 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15350 +#define VC_CAT_VERSION 0
15352 +#define VC_CAT_VSETUP 1
15353 +#define VC_CAT_VHOST 2
15355 +#define VC_CAT_DEVICE 6
15357 +#define VC_CAT_VPROC 9
15358 +#define VC_CAT_PROCALT 10
15359 +#define VC_CAT_PROCMIG 11
15360 +#define VC_CAT_PROCTRL 12
15362 +#define VC_CAT_SCHED 14
15363 +#define VC_CAT_MEMCTRL 20
15365 +#define VC_CAT_VNET 25
15366 +#define VC_CAT_NETALT 26
15367 +#define VC_CAT_NETMIG 27
15368 +#define VC_CAT_NETCTRL 28
15370 +#define VC_CAT_TAGMIG 35
15371 +#define VC_CAT_DLIMIT 36
15372 +#define VC_CAT_INODE 38
15374 +#define VC_CAT_VSTAT 40
15375 +#define VC_CAT_VINFO 46
15376 +#define VC_CAT_EVENT 48
15378 +#define VC_CAT_FLAGS 52
15379 +#define VC_CAT_DEBUG 56
15380 +#define VC_CAT_RLIMIT 60
15382 +#define VC_CAT_SYSTEST 61
15383 +#define VC_CAT_COMPAT 63
15385 +/* query version */
15387 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
15388 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
15393 +#include <linux/errno.h>
15396 +#else /* __KERNEL__ */
15398 +#endif /* __KERNEL__ */
15400 +#endif /* _VX_SWITCH_H */
15401 diff -Nurp linux-2.6.22.18/include/linux/vserver/tag_cmd.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/tag_cmd.h
15402 --- linux-2.6.22.18/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
15403 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/tag_cmd.h 2008-02-11 12:35:36.000000000 +0100
15405 +#ifndef _VX_TAG_CMD_H
15406 +#define _VX_TAG_CMD_H
15409 +/* vinfo commands */
15411 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
15414 +extern int vc_task_tag(uint32_t);
15416 +#endif /* __KERNEL__ */
15418 +/* context commands */
15420 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
15423 +extern int vc_tag_migrate(uint32_t);
15425 +#endif /* __KERNEL__ */
15426 +#endif /* _VX_TAG_CMD_H */
15427 diff -Nurp linux-2.6.22.18/include/linux/vserver/tag.h linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/tag.h
15428 --- linux-2.6.22.18/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
15429 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vserver/tag.h 2008-02-11 12:35:36.000000000 +0100
15434 +#include <linux/types.h>
15437 +#define DX_TAG(in) (IS_TAGGED(in))
15440 +#ifdef CONFIG_DX_TAG_NFSD
15441 +#define DX_TAG_NFSD 1
15443 +#define DX_TAG_NFSD 0
15447 +#ifdef CONFIG_TAGGING_NONE
15449 +#define MAX_UID 0xFFFFFFFF
15450 +#define MAX_GID 0xFFFFFFFF
15452 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
15454 +#define TAGINO_UID(cond, uid, tag) (uid)
15455 +#define TAGINO_GID(cond, gid, tag) (gid)
15460 +#ifdef CONFIG_TAGGING_GID16
15462 +#define MAX_UID 0xFFFFFFFF
15463 +#define MAX_GID 0x0000FFFF
15465 +#define INOTAG_TAG(cond, uid, gid, tag) \
15466 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
15468 +#define TAGINO_UID(cond, uid, tag) (uid)
15469 +#define TAGINO_GID(cond, gid, tag) \
15470 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
15475 +#ifdef CONFIG_TAGGING_ID24
15477 +#define MAX_UID 0x00FFFFFF
15478 +#define MAX_GID 0x00FFFFFF
15480 +#define INOTAG_TAG(cond, uid, gid, tag) \
15481 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
15483 +#define TAGINO_UID(cond, uid, tag) \
15484 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
15485 +#define TAGINO_GID(cond, gid, tag) \
15486 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
15491 +#ifdef CONFIG_TAGGING_UID16
15493 +#define MAX_UID 0x0000FFFF
15494 +#define MAX_GID 0xFFFFFFFF
15496 +#define INOTAG_TAG(cond, uid, gid, tag) \
15497 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
15499 +#define TAGINO_UID(cond, uid, tag) \
15500 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
15501 +#define TAGINO_GID(cond, gid, tag) (gid)
15506 +#ifdef CONFIG_TAGGING_INTERN
15508 +#define MAX_UID 0xFFFFFFFF
15509 +#define MAX_GID 0xFFFFFFFF
15511 +#define INOTAG_TAG(cond, uid, gid, tag) \
15512 + ((cond) ? (tag) : 0)
15514 +#define TAGINO_UID(cond, uid, tag) (uid)
15515 +#define TAGINO_GID(cond, gid, tag) (gid)
15520 +#ifndef CONFIG_TAGGING_NONE
15521 +#define dx_current_fstag(sb) \
15522 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
15524 +#define dx_current_fstag(sb) (0)
15527 +#ifndef CONFIG_TAGGING_INTERN
15528 +#define TAGINO_TAG(cond, tag) (0)
15530 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
15533 +#define INOTAG_UID(cond, uid, gid) \
15534 + ((cond) ? ((uid) & MAX_UID) : (uid))
15535 +#define INOTAG_GID(cond, uid, gid) \
15536 + ((cond) ? ((gid) & MAX_GID) : (gid))
15539 +static inline uid_t dx_map_uid(uid_t uid)
15541 + if ((uid > MAX_UID) && (uid != -1))
15543 + return (uid & MAX_UID);
15546 +static inline gid_t dx_map_gid(gid_t gid)
15548 + if ((gid > MAX_GID) && (gid != -1))
15550 + return (gid & MAX_GID);
15558 +#define dx_notagcheck(nd) \
15559 + ((nd) && (nd)->mnt && ((nd)->mnt->mnt_flags & MNT_NOTAGCHECK))
15561 +int dx_parse_tag(char *string, tag_t *tag, int remove);
15563 +#ifdef CONFIG_PROPAGATE
15565 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
15567 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
15570 +#define dx_propagate_tag(n, i) do { } while (0)
15573 +#endif /* _DX_TAG_H */
15574 diff -Nurp linux-2.6.22.18/include/linux/vs_inet6.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_inet6.h
15575 --- linux-2.6.22.18/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
15576 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_inet6.h 2008-02-11 12:35:36.000000000 +0100
15578 +#ifndef _VS_INET6_H
15579 +#define _VS_INET6_H
15581 +#include <net/ipv6.h>
15582 +#include "vserver/base.h"
15583 +#include "vserver/network.h"
15584 +#include "vserver/debug.h"
15586 +#define NXAV6(a) NIP6((a)->ip), NIP6((a)->mask), (a)->prefix, (a)->type
15587 +#define NXAV6_FMT "[" NIP6_FMT "/" NIP6_FMT "/%d:%04x]"
15590 +#ifdef CONFIG_IPV6
15593 +int v6_addr_match(struct nx_addr_v6 *nxa,
15594 + const struct in6_addr *addr, uint16_t mask)
15596 + switch (nxa->type & mask) {
15597 + case NXA_TYPE_MASK:
15598 + return ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
15599 + case NXA_TYPE_ADDR:
15600 + return ipv6_addr_equal(&nxa->ip, addr);
15601 + case NXA_TYPE_ANY:
15609 +int v6_addr_in_nx_info(struct nx_info *nxi,
15610 + const struct in6_addr *addr, uint16_t mask)
15612 + struct nx_addr_v6 *nxa;
15616 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
15617 + if (v6_addr_match(nxa, addr, mask))
15623 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
15625 + /* FIXME: needs full range checks */
15626 + return v6_addr_match(nxa, &addr->ip, mask);
15630 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
15632 + struct nx_addr_v6 *ptr;
15634 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
15635 + if (v6_nx_addr_match(ptr, nxa, mask))
15642 + * Check if a given address matches for a socket
15644 + * nxi: the socket's nx_info if any
15645 + * addr: to be verified address
15648 +int v6_sock_addr_match (
15649 + struct nx_info *nxi,
15650 + struct inet_sock *inet,
15651 + struct in6_addr *addr)
15653 + struct sock *sk = &inet->sk;
15654 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
15656 + if (!ipv6_addr_any(addr) &&
15657 + ipv6_addr_equal(saddr, addr))
15659 + if (ipv6_addr_any(saddr))
15660 + return v6_addr_in_nx_info(nxi, addr, -1);
15665 + * check if address is covered by socket
15667 + * sk: the socket to check against
15668 + * addr: the address in question (must be != 0)
15672 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
15674 + struct nx_info *nxi = sk->sk_nx_info;
15675 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
15677 + vxdprintk(VXD_CBIT(net, 5),
15678 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:" NIP6_FMT " %p;%lx",
15679 + sk, NXAV6(nxa), nxi, NIP6(*saddr), sk->sk_socket,
15680 + (sk->sk_socket?sk->sk_socket->flags:0));
15682 + if (!ipv6_addr_any(saddr)) { /* direct address match */
15683 + return v6_addr_match(nxa, saddr, -1);
15684 + } else if (nxi) { /* match against nx_info */
15685 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
15686 + } else { /* unrestricted any socket */
15692 +/* inet related checks and helpers */
15696 +struct net_device;
15700 +#include <linux/netdevice.h>
15701 +#include <linux/inetdevice.h>
15702 +#include <net/inet_timewait_sock.h>
15705 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15706 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
15707 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
15712 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
15718 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
15722 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
15724 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15726 + if (v6_ifa_in_nx_info(ifa, nxi))
15732 +struct nx_v6_sock_addr {
15733 + struct in6_addr saddr; /* Address used for validation */
15734 + struct in6_addr baddr; /* Address used for socket bind */
15738 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
15739 + struct nx_v6_sock_addr *nsa)
15741 + // struct sock *sk = &inet->sk;
15742 + // struct nx_info *nxi = sk->sk_nx_info;
15743 + struct in6_addr saddr = addr->sin6_addr;
15744 + struct in6_addr baddr = saddr;
15746 + nsa->saddr = saddr;
15747 + nsa->baddr = baddr;
15752 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
15754 + // struct sock *sk = &inet->sk;
15755 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
15757 + // *saddr = nsa->baddr;
15758 + // inet->saddr = nsa->baddr;
15762 +int nx_info_has_v6(struct nx_info *nxi)
15766 + if (NX_IPV6(nxi))
15771 +#else /* CONFIG_IPV6 */
15774 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
15781 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
15787 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
15793 +int nx_info_has_v6(struct nx_info *nxi)
15798 +#endif /* CONFIG_IPV6 */
15800 +#define current_nx_info_has_v6() \
15801 + nx_info_has_v6(current_nx_info())
15804 +#warning duplicate inclusion
15806 diff -Nurp linux-2.6.22.18/include/linux/vs_inet.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_inet.h
15807 --- linux-2.6.22.18/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
15808 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_inet.h 2008-02-11 12:35:36.000000000 +0100
15810 +#ifndef _VS_INET_H
15811 +#define _VS_INET_H
15813 +#include "vserver/base.h"
15814 +#include "vserver/network.h"
15815 +#include "vserver/debug.h"
15817 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
15819 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
15820 + NIPQUAD((a)->mask), (a)->type
15821 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
15825 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
15827 + __be32 ip = nxa->ip[0].s_addr;
15828 + __be32 mask = nxa->mask.s_addr;
15829 + __be32 bcast = ip | ~mask;
15832 + switch (nxa->type & tmask) {
15833 + case NXA_TYPE_MASK:
15834 + ret = (ip == (addr & mask));
15836 + case NXA_TYPE_ADDR:
15840 + /* fall through to broadcast */
15841 + case NXA_MOD_BCAST:
15842 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
15844 + case NXA_TYPE_RANGE:
15845 + ret = ((nxa->ip[0].s_addr <= addr) &&
15846 + (nxa->ip[1].s_addr > addr));
15848 + case NXA_TYPE_ANY:
15853 + vxdprintk(VXD_CBIT(net, 0),
15854 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
15855 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
15860 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
15862 + struct nx_addr_v4 *nxa;
15869 + /* allow 127.0.0.1 when remapping lback */
15870 + if ((tmask & NXA_LOOPBACK) &&
15871 + (addr == IPI_LOOPBACK) &&
15872 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15875 + /* check for lback address */
15876 + if ((tmask & NXA_MOD_LBACK) &&
15877 + (nxi->v4_lback.s_addr == addr))
15880 + /* check for broadcast address */
15881 + if ((tmask & NXA_MOD_BCAST) &&
15882 + (nxi->v4_bcast.s_addr == addr))
15885 + /* check for v4 addresses */
15886 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
15887 + if (v4_addr_match(nxa, addr, tmask))
15891 + vxdprintk(VXD_CBIT(net, 0),
15892 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
15893 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
15898 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
15900 + /* FIXME: needs full range checks */
15901 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
15905 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
15907 + struct nx_addr_v4 *ptr;
15909 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
15910 + if (v4_nx_addr_match(ptr, nxa, mask))
15915 +#include <net/inet_sock.h>
15918 + * Check if a given address matches for a socket
15920 + * nxi: the socket's nx_info if any
15921 + * addr: to be verified address
15924 +int v4_sock_addr_match (
15925 + struct nx_info *nxi,
15926 + struct inet_sock *inet,
15929 + __be32 saddr = inet->rcv_saddr;
15930 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
15932 + if (addr && (saddr == addr || bcast == addr))
15935 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
15940 +/* inet related checks and helpers */
15944 +struct net_device;
15947 +#ifdef CONFIG_INET
15949 +#include <linux/netdevice.h>
15950 +#include <linux/inetdevice.h>
15951 +#include <net/inet_timewait_sock.h>
15954 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15955 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
15956 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
15960 + * check if address is covered by socket
15962 + * sk: the socket to check against
15963 + * addr: the address in question (must be != 0)
15967 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
15969 + struct nx_info *nxi = sk->sk_nx_info;
15970 + __be32 saddr = inet_rcv_saddr(sk);
15972 + vxdprintk(VXD_CBIT(net, 5),
15973 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
15974 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
15975 + (sk->sk_socket?sk->sk_socket->flags:0));
15977 + if (saddr) { /* direct address match */
15978 + return v4_addr_match(nxa, saddr, -1);
15979 + } else if (nxi) { /* match against nx_info */
15980 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
15981 + } else { /* unrestricted any socket */
15989 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
15991 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
15992 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
15993 + nxi ? dev_in_nx_info(dev, nxi) : 0);
15995 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15997 + if (dev_in_nx_info(dev, nxi))
16004 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
16010 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
16014 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
16016 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
16017 + nxi, nxi ? nxi->nx_id : 0, ifa,
16018 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
16020 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
16022 + if (v4_ifa_in_nx_info(ifa, nxi))
16028 +struct nx_v4_sock_addr {
16029 + __be32 saddr; /* Address used for validation */
16030 + __be32 baddr; /* Address used for socket bind */
16034 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
16035 + struct nx_v4_sock_addr *nsa)
16037 + struct sock *sk = &inet->sk;
16038 + struct nx_info *nxi = sk->sk_nx_info;
16039 + __be32 saddr = addr->sin_addr.s_addr;
16040 + __be32 baddr = saddr;
16042 + vxdprintk(VXD_CBIT(net, 3),
16043 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
16044 + sk, sk->sk_nx_info, sk->sk_socket,
16045 + (sk->sk_socket ? sk->sk_socket->flags : 0),
16049 + if (saddr == INADDR_ANY) {
16050 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
16051 + baddr = nxi->v4.ip[0].s_addr;
16052 + } else if (saddr == IPI_LOOPBACK) {
16053 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
16054 + baddr = nxi->v4_lback.s_addr;
16055 + } else { /* normal address bind */
16056 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
16057 + return -EADDRNOTAVAIL;
16061 + vxdprintk(VXD_CBIT(net, 3),
16062 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
16063 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
16065 + nsa->saddr = saddr;
16066 + nsa->baddr = baddr;
16071 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
16073 + inet->saddr = nsa->baddr;
16074 + inet->rcv_saddr = nsa->baddr;
16079 + * helper to simplify inet_lookup_listener
16081 + * nxi: the socket's nx_info if any
16082 + * addr: to be verified address
16083 + * saddr: socket address
16085 +static inline int v4_inet_addr_match (
16086 + struct nx_info *nxi,
16090 + if (addr && (saddr == addr))
16093 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
16097 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
16099 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
16100 + (addr == nxi->v4_lback.s_addr))
16101 + return IPI_LOOPBACK;
16106 +int nx_info_has_v4(struct nx_info *nxi)
16110 + if (NX_IPV4(nxi))
16112 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
16117 +#else /* CONFIG_INET */
16120 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
16126 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
16132 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
16138 +int nx_info_has_v4(struct nx_info *nxi)
16143 +#endif /* CONFIG_INET */
16145 +#define current_nx_info_has_v4() \
16146 + nx_info_has_v4(current_nx_info())
16149 +#warning duplicate inclusion
16151 diff -Nurp linux-2.6.22.18/include/linux/vs_limit.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_limit.h
16152 --- linux-2.6.22.18/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
16153 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_limit.h 2008-02-11 12:35:36.000000000 +0100
16155 +#ifndef _VS_LIMIT_H
16156 +#define _VS_LIMIT_H
16158 +#include "vserver/limit.h"
16159 +#include "vserver/base.h"
16160 +#include "vserver/context.h"
16161 +#include "vserver/debug.h"
16162 +#include "vserver/context.h"
16163 +#include "vserver/limit_int.h"
16166 +#define vx_acc_cres(v, d, p, r) \
16167 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
16169 +#define vx_acc_cres_cond(x, d, p, r) \
16170 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
16171 + r, d, p, __FILE__, __LINE__)
16174 +#define vx_add_cres(v, a, p, r) \
16175 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
16176 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
16178 +#define vx_add_cres_cond(x, a, p, r) \
16179 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
16180 + r, a, p, __FILE__, __LINE__)
16181 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
16184 +/* process and file limits */
16186 +#define vx_nproc_inc(p) \
16187 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
16189 +#define vx_nproc_dec(p) \
16190 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
16192 +#define vx_files_inc(f) \
16193 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
16195 +#define vx_files_dec(f) \
16196 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
16198 +#define vx_locks_inc(l) \
16199 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
16201 +#define vx_locks_dec(l) \
16202 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
16204 +#define vx_openfd_inc(f) \
16205 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
16207 +#define vx_openfd_dec(f) \
16208 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
16211 +#define vx_cres_avail(v, n, r) \
16212 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
16215 +#define vx_nproc_avail(n) \
16216 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
16218 +#define vx_files_avail(n) \
16219 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
16221 +#define vx_locks_avail(n) \
16222 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
16224 +#define vx_openfd_avail(n) \
16225 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
16228 +/* dentry limits */
16230 +#define vx_dentry_inc(d) do { \
16231 + if (atomic_read(&d->d_count) == 1) \
16232 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
16235 +#define vx_dentry_dec(d) do { \
16236 + if (atomic_read(&d->d_count) == 0) \
16237 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
16240 +#define vx_dentry_avail(n) \
16241 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
16244 +/* socket limits */
16246 +#define vx_sock_inc(s) \
16247 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
16249 +#define vx_sock_dec(s) \
16250 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
16252 +#define vx_sock_avail(n) \
16253 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
16256 +/* ipc resource limits */
16258 +#define vx_ipcmsg_add(v, u, a) \
16259 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
16261 +#define vx_ipcmsg_sub(v, u, a) \
16262 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
16264 +#define vx_ipcmsg_avail(v, a) \
16265 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
16268 +#define vx_ipcshm_add(v, k, a) \
16269 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
16271 +#define vx_ipcshm_sub(v, k, a) \
16272 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
16274 +#define vx_ipcshm_avail(v, a) \
16275 + vx_cres_avail(v, a, VLIMIT_SHMEM)
16278 +#define vx_semary_inc(a) \
16279 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
16281 +#define vx_semary_dec(a) \
16282 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
16285 +#define vx_nsems_add(a,n) \
16286 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
16288 +#define vx_nsems_sub(a,n) \
16289 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
16293 +#warning duplicate inclusion
16295 diff -Nurp linux-2.6.22.18/include/linux/vs_memory.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_memory.h
16296 --- linux-2.6.22.18/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
16297 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_memory.h 2008-02-11 12:35:36.000000000 +0100
16299 +#ifndef _VS_MEMORY_H
16300 +#define _VS_MEMORY_H
16302 +#include "vserver/limit.h"
16303 +#include "vserver/base.h"
16304 +#include "vserver/context.h"
16305 +#include "vserver/debug.h"
16306 +#include "vserver/context.h"
16307 +#include "vserver/limit_int.h"
16310 +#define __acc_add_long(a, v) (*(v) += (a))
16311 +#define __acc_inc_long(v) (++*(v))
16312 +#define __acc_dec_long(v) (--*(v))
16314 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
16315 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
16316 +#define __acc_inc_atomic(v) atomic_long_inc(v)
16317 +#define __acc_dec_atomic(v) atomic_long_dec(v)
16318 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
16319 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
16320 +#define __acc_inc_atomic(v) __acc_inc_long(v)
16321 +#define __acc_dec_atomic(v) __acc_dec_long(v)
16322 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
16325 +#define vx_acc_page(m, d, v, r) do { \
16327 + __acc_inc_long(&(m)->v); \
16329 + __acc_dec_long(&(m)->v); \
16330 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
16333 +#define vx_acc_page_atomic(m, d, v, r) do { \
16335 + __acc_inc_atomic(&(m)->v); \
16337 + __acc_dec_atomic(&(m)->v); \
16338 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
16342 +#define vx_acc_pages(m, p, v, r) do { \
16343 + unsigned long __p = (p); \
16344 + __acc_add_long(__p, &(m)->v); \
16345 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
16348 +#define vx_acc_pages_atomic(m, p, v, r) do { \
16349 + unsigned long __p = (p); \
16350 + __acc_add_atomic(__p, &(m)->v); \
16351 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
16356 +#define vx_acc_vmpage(m, d) \
16357 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
16358 +#define vx_acc_vmlpage(m, d) \
16359 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
16360 +#define vx_acc_file_rsspage(m, d) \
16361 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
16362 +#define vx_acc_anon_rsspage(m, d) \
16363 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
16365 +#define vx_acc_vmpages(m, p) \
16366 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
16367 +#define vx_acc_vmlpages(m, p) \
16368 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
16369 +#define vx_acc_file_rsspages(m, p) \
16370 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
16371 +#define vx_acc_anon_rsspages(m, p) \
16372 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
16374 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
16375 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
16377 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
16378 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
16379 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
16380 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
16382 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
16383 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
16384 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
16385 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
16387 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
16388 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
16389 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
16390 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
16392 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
16393 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
16394 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
16395 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
16398 +#define vx_pages_avail(m, p, r) \
16399 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
16401 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
16402 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
16403 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
16404 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
16406 +#define vx_rss_avail(m, p) \
16407 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
16411 + VXPT_UNKNOWN = 0,
16420 +#define vx_page_fault(mm, vma, type, ret)
16424 +void __vx_page_fault(struct mm_struct *mm,
16425 + struct vm_area_struct *vma, int type, int ret)
16427 + struct vx_info *vxi = mm->mm_vx_info;
16430 + static char *page_type[6] =
16431 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
16432 + static char *page_what[4] =
16433 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
16439 + what = (ret & 0x3);
16441 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
16442 + type, what, ret, page_type[type], page_what[what]);
16444 + if (ret & VM_FAULT_WRITE)
16446 + atomic_inc(&vxi->cacct.page[type][what]);
16449 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
16453 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
16456 +#warning duplicate inclusion
16458 diff -Nurp linux-2.6.22.18/include/linux/vs_network.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_network.h
16459 --- linux-2.6.22.18/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
16460 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_network.h 2008-02-11 12:35:36.000000000 +0100
16462 +#ifndef _NX_VS_NETWORK_H
16463 +#define _NX_VS_NETWORK_H
16465 +#include "vserver/context.h"
16466 +#include "vserver/network.h"
16467 +#include "vserver/base.h"
16468 +#include "vserver/debug.h"
16471 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
16473 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
16474 + const char *_file, int _line)
16479 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
16480 + nxi, nxi ? nxi->nx_id : 0,
16481 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16484 + atomic_inc(&nxi->nx_usecnt);
16489 +extern void free_nx_info(struct nx_info *);
16491 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
16493 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
16498 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
16499 + nxi, nxi ? nxi->nx_id : 0,
16500 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16503 + if (atomic_dec_and_test(&nxi->nx_usecnt))
16504 + free_nx_info(nxi);
16508 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
16510 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
16511 + const char *_file, int _line)
16514 + vxlprintk(VXD_CBIT(nid, 3),
16515 + "init_nx_info(%p[#%d.%d])",
16516 + nxi, nxi ? nxi->nx_id : 0,
16517 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16520 + atomic_inc(&nxi->nx_usecnt);
16526 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
16528 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
16529 + const char *_file, int _line)
16531 + struct nx_info *nxo;
16536 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
16537 + nxi, nxi ? nxi->nx_id : 0,
16538 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16541 + atomic_inc(&nxi->nx_usecnt);
16542 + nxo = xchg(nxp, nxi);
16546 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
16548 +static inline void __clr_nx_info(struct nx_info **nxp,
16549 + const char *_file, int _line)
16551 + struct nx_info *nxo;
16553 + nxo = xchg(nxp, NULL);
16557 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
16558 + nxo, nxo ? nxo->nx_id : 0,
16559 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
16562 + if (atomic_dec_and_test(&nxo->nx_usecnt))
16563 + free_nx_info(nxo);
16567 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
16569 +static inline void __claim_nx_info(struct nx_info *nxi,
16570 + struct task_struct *task, const char *_file, int _line)
16572 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
16573 + nxi, nxi ? nxi->nx_id : 0,
16574 + nxi?atomic_read(&nxi->nx_usecnt):0,
16575 + nxi?atomic_read(&nxi->nx_tasks):0,
16576 + task, _file, _line);
16578 + atomic_inc(&nxi->nx_tasks);
16582 +extern void unhash_nx_info(struct nx_info *);
16584 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
16586 +static inline void __release_nx_info(struct nx_info *nxi,
16587 + struct task_struct *task, const char *_file, int _line)
16589 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
16590 + nxi, nxi ? nxi->nx_id : 0,
16591 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16592 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
16593 + task, _file, _line);
16597 + if (atomic_dec_and_test(&nxi->nx_tasks))
16598 + unhash_nx_info(nxi);
16602 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
16604 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
16605 + const char *_file, int _line)
16607 + struct nx_info *nxi;
16610 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
16611 + p, _file, _line);
16612 + nxi = __get_nx_info(p->nx_info, _file, _line);
16618 +static inline void exit_nx_info(struct task_struct *p)
16621 + release_nx_info(p->nx_info, p);
16626 +#warning duplicate inclusion
16628 diff -Nurp linux-2.6.22.18/include/linux/vs_pid.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_pid.h
16629 --- linux-2.6.22.18/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
16630 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_pid.h 2008-02-11 12:35:36.000000000 +0100
16635 +#include "vserver/base.h"
16636 +#include "vserver/context.h"
16637 +#include "vserver/debug.h"
16638 +#include <linux/pid_namespace.h>
16641 +/* pid faking stuff */
16644 +#define vx_info_map_pid(v, p) \
16645 + __vx_info_map_pid((v), (p), __FUNC__, __FILE__, __LINE__)
16646 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
16647 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
16648 +#define vx_map_tgid(p) vx_map_pid(p)
16650 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
16651 + const char *func, const char *file, int line)
16653 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
16654 + vxfprintk(VXD_CBIT(cvirt, 2),
16655 + "vx_map_tgid: %p/%llx: %d -> %d",
16656 + vxi, (long long)vxi->vx_flags, pid,
16657 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
16658 + func, file, line);
16661 + if (pid == vxi->vx_initpid)
16667 +#define vx_info_rmap_pid(v, p) \
16668 + __vx_info_rmap_pid((v), (p), __FUNC__, __FILE__, __LINE__)
16669 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
16670 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
16672 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
16673 + const char *func, const char *file, int line)
16675 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
16676 + vxfprintk(VXD_CBIT(cvirt, 2),
16677 + "vx_rmap_tgid: %p/%llx: %d -> %d",
16678 + vxi, (long long)vxi->vx_flags, pid,
16679 + (pid == 1) ? vxi->vx_initpid : pid,
16680 + func, file, line);
16681 + if ((pid == 1) && vxi->vx_initpid)
16682 + return vxi->vx_initpid;
16683 + if (pid == vxi->vx_initpid)
16690 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
16693 +int vx_proc_task_visible(struct task_struct *task)
16695 + if ((task->pid == 1) &&
16696 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
16697 + /* show a blend through init */
16699 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
16707 +struct task_struct *vx_find_proc_task_by_pid(int pid)
16709 + struct task_struct *task = find_task_by_pid(pid);
16711 + if (task && !vx_proc_task_visible(task)) {
16712 + vxdprintk(VXD_CBIT(misc, 6),
16713 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
16714 + task, task->xid, task->pid,
16715 + current, current->xid, current->pid);
16722 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
16724 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
16726 + if (task && !vx_proc_task_visible(task)) {
16727 + vxdprintk(VXD_CBIT(misc, 6),
16728 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
16729 + task, task->xid, task->pid,
16730 + current, current->xid, current->pid);
16731 + put_task_struct(task);
16739 +struct task_struct *vx_child_reaper(struct task_struct *p)
16741 + struct vx_info *vxi = p->vx_info;
16742 + struct task_struct *reaper = child_reaper(p);
16747 + BUG_ON(!p->vx_info->vx_reaper);
16749 + /* child reaper for the guest reaper */
16750 + if (vxi->vx_reaper == p)
16753 + reaper = vxi->vx_reaper;
16755 + vxdprintk(VXD_CBIT(xid, 7),
16756 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
16757 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
16763 +#warning duplicate inclusion
16765 diff -Nurp linux-2.6.22.18/include/linux/vs_sched.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_sched.h
16766 --- linux-2.6.22.18/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
16767 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_sched.h 2008-02-11 12:35:36.000000000 +0100
16769 +#ifndef _VS_SCHED_H
16770 +#define _VS_SCHED_H
16772 +#include "vserver/base.h"
16773 +#include "vserver/context.h"
16774 +#include "vserver/sched.h"
16777 +#define VAVAVOOM_RATIO 50
16779 +#define MAX_PRIO_BIAS 20
16780 +#define MIN_PRIO_BIAS -20
16783 +#ifdef CONFIG_VSERVER_HARDCPU
16786 + * effective_prio - return the priority that is based on the static
16787 + * priority but is modified by bonuses/penalties.
16789 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
16790 + * into a -4 ... 0 ... +4 bonus/penalty range.
16792 + * Additionally, we scale another amount based on the number of
16793 + * CPU tokens currently held by the context, if the process is
16794 + * part of a context (and the appropriate SCHED flag is set).
16795 + * This ranges from -5 ... 0 ... +15, quadratically.
16797 + * So, the total bonus is -9 .. 0 .. +19
16798 + * We use ~50% of the full 0...39 priority range so that:
16800 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
16801 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
16802 + * unless that context is far exceeding its CPU allocation.
16804 + * Both properties are important to certain workloads.
16807 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
16809 + int vavavoom, max;
16811 + /* lots of tokens = lots of vavavoom
16812 + * no tokens = no vavavoom */
16813 + if ((vavavoom = sched_pc->tokens) >= 0) {
16814 + max = sched_pc->tokens_max;
16815 + vavavoom = max - vavavoom;
16817 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
16818 + * (vavavoom*vavavoom - (max >> 2)) / max;
16826 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
16828 + struct vx_info *vxi = p->vx_info;
16829 + struct _vx_sched_pc *sched_pc;
16834 + sched_pc = &vx_cpu(vxi, sched_pc);
16835 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
16836 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
16838 + sched_pc->vavavoom = vavavoom;
16839 + prio += vavavoom;
16841 + prio += sched_pc->prio_bias;
16845 +#else /* !CONFIG_VSERVER_HARDCPU */
16848 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
16850 + struct vx_info *vxi = p->vx_info;
16853 + prio += vx_cpu(vxi, sched_pc).prio_bias;
16857 +#endif /* CONFIG_VSERVER_HARDCPU */
16860 +static inline void vx_account_user(struct vx_info *vxi,
16861 + cputime_t cputime, int nice)
16865 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
16868 +static inline void vx_account_system(struct vx_info *vxi,
16869 + cputime_t cputime, int idle)
16873 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
16877 +#warning duplicate inclusion
16879 diff -Nurp linux-2.6.22.18/include/linux/vs_socket.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_socket.h
16880 --- linux-2.6.22.18/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
16881 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_socket.h 2008-02-11 12:35:36.000000000 +0100
16883 +#ifndef _VS_SOCKET_H
16884 +#define _VS_SOCKET_H
16886 +#include "vserver/debug.h"
16887 +#include "vserver/base.h"
16888 +#include "vserver/cacct.h"
16889 +#include "vserver/context.h"
16890 +#include "vserver/tag.h"
16893 +/* socket accounting */
16895 +#include <linux/socket.h>
16897 +static inline int vx_sock_type(int family)
16899 + switch (family) {
16901 + return VXA_SOCK_UNSPEC;
16903 + return VXA_SOCK_UNIX;
16905 + return VXA_SOCK_INET;
16907 + return VXA_SOCK_INET6;
16909 + return VXA_SOCK_PACKET;
16911 + return VXA_SOCK_OTHER;
16915 +#define vx_acc_sock(v, f, p, s) \
16916 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
16918 +static inline void __vx_acc_sock(struct vx_info *vxi,
16919 + int family, int pos, int size, char *file, int line)
16922 + int type = vx_sock_type(family);
16924 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
16925 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
16929 +#define vx_sock_recv(sk, s) \
16930 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
16931 +#define vx_sock_send(sk, s) \
16932 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
16933 +#define vx_sock_fail(sk, s) \
16934 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
16937 +#define sock_vx_init(s) do { \
16938 + (s)->sk_xid = 0; \
16939 + (s)->sk_vx_info = NULL; \
16942 +#define sock_nx_init(s) do { \
16943 + (s)->sk_nid = 0; \
16944 + (s)->sk_nx_info = NULL; \
16948 +int vx_socket_peer_tag(struct socket *sock, int level,
16949 + char __user *optval, int __user *optlen, int len)
16951 + struct peer_tag tag;
16953 + tag.xid = sock->sk->sk_xid;
16954 + tag.nid = sock->sk->sk_nid;
16955 + if (copy_to_user(optval, &tag, sizeof(tag)))
16961 +#warning duplicate inclusion
16963 diff -Nurp linux-2.6.22.18/include/linux/vs_tag.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_tag.h
16964 --- linux-2.6.22.18/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
16965 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_tag.h 2008-02-11 12:35:36.000000000 +0100
16970 +#include <linux/vserver/tag.h>
16972 +/* check conditions */
16974 +#define DX_ADMIN 0x0001
16975 +#define DX_WATCH 0x0002
16976 +#define DX_HOSTID 0x0008
16978 +#define DX_IDENT 0x0010
16980 +#define DX_ARG_MASK 0x0010
16983 +#define dx_task_tag(t) ((t)->tag)
16985 +#define dx_current_tag() dx_task_tag(current)
16987 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
16989 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
16993 + * check current context for ADMIN/WATCH and
16994 + * optionally against supplied argument
16996 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
16998 + if (mode & DX_ARG_MASK) {
16999 + if ((mode & DX_IDENT) && (id == cid))
17002 + return (((mode & DX_ADMIN) && (cid == 0)) ||
17003 + ((mode & DX_WATCH) && (cid == 1)) ||
17004 + ((mode & DX_HOSTID) && (id == 0)));
17008 +#warning duplicate inclusion
17010 diff -Nurp linux-2.6.22.18/include/linux/vs_time.h linux-2.6.22.18-vs2.3.0.32/include/linux/vs_time.h
17011 --- linux-2.6.22.18/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
17012 +++ linux-2.6.22.18-vs2.3.0.32/include/linux/vs_time.h 2008-02-11 12:35:36.000000000 +0100
17014 +#ifndef _VS_TIME_H
17015 +#define _VS_TIME_H
17018 +/* time faking stuff */
17020 +#ifdef CONFIG_VSERVER_VTIME
17022 +extern void vx_gettimeofday(struct timeval *tv);
17023 +extern int vx_settimeofday(struct timespec *ts);
17026 +#define vx_gettimeofday(t) do_gettimeofday(t)
17027 +#define vx_settimeofday(t) do_settimeofday(t)
17031 +#warning duplicate inclusion
17033 diff -Nurp linux-2.6.22.18/include/net/addrconf.h linux-2.6.22.18-vs2.3.0.32/include/net/addrconf.h
17034 --- linux-2.6.22.18/include/net/addrconf.h 2007-07-22 00:00:24.000000000 +0200
17035 +++ linux-2.6.22.18-vs2.3.0.32/include/net/addrconf.h 2008-02-11 12:35:36.000000000 +0100
17036 @@ -69,10 +69,12 @@ extern struct inet6_ifaddr * ipv6_get_if
17038 extern int ipv6_get_saddr(struct dst_entry *dst,
17039 struct in6_addr *daddr,
17040 - struct in6_addr *saddr);
17041 + struct in6_addr *saddr,
17042 + struct nx_info *nxi);
17043 extern int ipv6_dev_get_saddr(struct net_device *dev,
17044 struct in6_addr *daddr,
17045 - struct in6_addr *saddr);
17046 + struct in6_addr *saddr,
17047 + struct nx_info *nxi);
17048 extern int ipv6_get_lladdr(struct net_device *dev,
17049 struct in6_addr *addr,
17050 unsigned char banned_flags);
17051 diff -Nurp linux-2.6.22.18/include/net/af_unix.h linux-2.6.22.18-vs2.3.0.32/include/net/af_unix.h
17052 --- linux-2.6.22.18/include/net/af_unix.h 2007-07-22 00:00:24.000000000 +0200
17053 +++ linux-2.6.22.18-vs2.3.0.32/include/net/af_unix.h 2008-02-11 12:35:36.000000000 +0100
17055 #include <linux/socket.h>
17056 #include <linux/un.h>
17057 #include <linux/mutex.h>
17058 +#include <linux/vs_base.h>
17059 #include <net/sock.h>
17061 extern void unix_inflight(struct file *fp);
17062 @@ -17,9 +18,9 @@ extern spinlock_t unix_table_lock;
17064 extern atomic_t unix_tot_inflight;
17066 -static inline struct sock *first_unix_socket(int *i)
17067 +static inline struct sock *next_unix_socket_table(int *i)
17069 - for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
17070 + for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
17071 if (!hlist_empty(&unix_socket_table[*i]))
17072 return __sk_head(&unix_socket_table[*i]);
17074 @@ -28,16 +29,19 @@ static inline struct sock *first_unix_so
17076 static inline struct sock *next_unix_socket(int *i, struct sock *s)
17078 - struct sock *next = sk_next(s);
17079 - /* More in this chain? */
17082 - /* Look for next non-empty chain. */
17083 - for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
17084 - if (!hlist_empty(&unix_socket_table[*i]))
17085 - return __sk_head(&unix_socket_table[*i]);
17092 + s = next_unix_socket_table(i);
17093 + } while (s && !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT));
17097 +static inline struct sock *first_unix_socket(int *i)
17100 + return next_unix_socket(i, NULL);
17103 #define forall_unix_sockets(i, s) \
17104 diff -Nurp linux-2.6.22.18/include/net/inet_timewait_sock.h linux-2.6.22.18-vs2.3.0.32/include/net/inet_timewait_sock.h
17105 --- linux-2.6.22.18/include/net/inet_timewait_sock.h 2007-07-21 23:58:53.000000000 +0200
17106 +++ linux-2.6.22.18-vs2.3.0.32/include/net/inet_timewait_sock.h 2008-02-11 12:35:36.000000000 +0100
17107 @@ -115,6 +115,10 @@ struct inet_timewait_sock {
17108 #define tw_refcnt __tw_common.skc_refcnt
17109 #define tw_hash __tw_common.skc_hash
17110 #define tw_prot __tw_common.skc_prot
17111 +#define tw_xid __tw_common.skc_xid
17112 +#define tw_vx_info __tw_common.skc_vx_info
17113 +#define tw_nid __tw_common.skc_nid
17114 +#define tw_nx_info __tw_common.skc_nx_info
17115 volatile unsigned char tw_substate;
17116 /* 3 bits hole, try to pack */
17117 unsigned char tw_rcv_wscale;
17118 diff -Nurp linux-2.6.22.18/include/net/route.h linux-2.6.22.18-vs2.3.0.32/include/net/route.h
17119 --- linux-2.6.22.18/include/net/route.h 2007-07-21 23:58:53.000000000 +0200
17120 +++ linux-2.6.22.18-vs2.3.0.32/include/net/route.h 2008-02-11 12:35:36.000000000 +0100
17121 @@ -27,12 +27,16 @@
17122 #include <net/dst.h>
17123 #include <net/inetpeer.h>
17124 #include <net/flow.h>
17125 +#include <net/inet_sock.h>
17126 #include <linux/in_route.h>
17127 #include <linux/rtnetlink.h>
17128 #include <linux/route.h>
17129 #include <linux/ip.h>
17130 #include <linux/cache.h>
17131 #include <linux/security.h>
17132 +#include <linux/vs_base.h>
17133 +#include <linux/vs_inet.h>
17134 +#include <linux/in.h>
17137 #warning This file is not supposed to be used outside of kernel.
17138 @@ -143,6 +147,8 @@ static inline char rt_tos2priority(u8 to
17139 return ip_tos2prio[IPTOS_TOS(tos)>>1];
17142 +extern int ip_v4_find_src(struct nx_info *, struct rtable **, struct flowi *);
17144 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
17145 __be32 src, u32 tos, int oif, u8 protocol,
17146 __be16 sport, __be16 dport, struct sock *sk,
17147 @@ -158,7 +164,21 @@ static inline int ip_route_connect(struc
17148 .dport = dport } } };
17151 - if (!dst || !src) {
17152 + struct nx_info *nx_info = current->nx_info;
17155 + nx_info = sk->sk_nx_info;
17157 + vxdprintk(VXD_CBIT(net, 4),
17158 + "ip_route_connect(%p) %p,%p;%lx",
17159 + sk, nx_info, sk->sk_socket,
17160 + (sk->sk_socket?sk->sk_socket->flags:0));
17162 + err = ip_v4_find_src(nx_info, rp, &fl);
17166 + if (!fl.fl4_dst || !fl.fl4_src) {
17167 err = __ip_route_output_key(rp, &fl);
17170 diff -Nurp linux-2.6.22.18/include/net/sock.h linux-2.6.22.18-vs2.3.0.32/include/net/sock.h
17171 --- linux-2.6.22.18/include/net/sock.h 2007-07-22 00:00:24.000000000 +0200
17172 +++ linux-2.6.22.18-vs2.3.0.32/include/net/sock.h 2008-02-11 12:35:36.000000000 +0100
17173 @@ -119,6 +119,10 @@ struct sock_common {
17174 atomic_t skc_refcnt;
17175 unsigned int skc_hash;
17176 struct proto *skc_prot;
17178 + struct vx_info *skc_vx_info;
17180 + struct nx_info *skc_nx_info;
17184 @@ -195,6 +199,10 @@ struct sock {
17185 #define sk_refcnt __sk_common.skc_refcnt
17186 #define sk_hash __sk_common.skc_hash
17187 #define sk_prot __sk_common.skc_prot
17188 +#define sk_xid __sk_common.skc_xid
17189 +#define sk_vx_info __sk_common.skc_vx_info
17190 +#define sk_nid __sk_common.skc_nid
17191 +#define sk_nx_info __sk_common.skc_nx_info
17192 unsigned char sk_shutdown : 2,
17195 diff -Nurp linux-2.6.22.18/init/main.c linux-2.6.22.18-vs2.3.0.32/init/main.c
17196 --- linux-2.6.22.18/init/main.c 2007-07-22 00:00:24.000000000 +0200
17197 +++ linux-2.6.22.18-vs2.3.0.32/init/main.c 2008-02-11 12:35:36.000000000 +0100
17199 #include <linux/pid_namespace.h>
17200 #include <linux/device.h>
17201 #include <linux/kthread.h>
17202 +#include <linux/vserver/percpu.h>
17204 #include <asm/io.h>
17205 #include <asm/bugs.h>
17206 @@ -364,12 +365,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
17208 static void __init setup_per_cpu_areas(void)
17210 - unsigned long size, i;
17211 + unsigned long size, vspc, i;
17213 unsigned long nr_possible_cpus = num_possible_cpus();
17215 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
17217 /* Copy section for each CPU (we discard the original) */
17218 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
17219 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
17220 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
17222 for_each_possible_cpu(i) {
17223 diff -Nurp linux-2.6.22.18/ipc/mqueue.c linux-2.6.22.18-vs2.3.0.32/ipc/mqueue.c
17224 --- linux-2.6.22.18/ipc/mqueue.c 2007-12-09 12:43:53.000000000 +0100
17225 +++ linux-2.6.22.18-vs2.3.0.32/ipc/mqueue.c 2008-02-11 12:35:36.000000000 +0100
17227 #include <linux/audit.h>
17228 #include <linux/signal.h>
17229 #include <linux/mutex.h>
17230 +#include <linux/vs_context.h>
17231 +#include <linux/vs_limit.h>
17233 #include <net/sock.h>
17235 @@ -151,17 +153,20 @@ static struct inode *mqueue_get_inode(st
17236 spin_lock(&mq_lock);
17237 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
17238 u->mq_bytes + mq_bytes >
17239 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
17240 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
17241 + !vx_ipcmsg_avail(p->vx_info, mq_bytes)) {
17242 spin_unlock(&mq_lock);
17245 u->mq_bytes += mq_bytes;
17246 + vx_ipcmsg_add(p->vx_info, u, mq_bytes);
17247 spin_unlock(&mq_lock);
17249 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
17250 if (!info->messages) {
17251 spin_lock(&mq_lock);
17252 u->mq_bytes -= mq_bytes;
17253 + vx_ipcmsg_sub(p->vx_info, u, mq_bytes);
17254 spin_unlock(&mq_lock);
17257 @@ -257,10 +262,14 @@ static void mqueue_delete_inode(struct i
17258 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
17261 + struct vx_info *vxi = lookup_vx_info(user->xid);
17263 spin_lock(&mq_lock);
17264 user->mq_bytes -= mq_bytes;
17265 + vx_ipcmsg_sub(vxi, user, mq_bytes);
17267 spin_unlock(&mq_lock);
17268 + put_vx_info(vxi);
17272 @@ -748,7 +757,7 @@ asmlinkage long sys_mq_unlink(const char
17274 atomic_inc(&inode->i_count);
17276 - err = vfs_unlink(dentry->d_parent->d_inode, dentry);
17277 + err = vfs_unlink(dentry->d_parent->d_inode, dentry, NULL);
17281 diff -Nurp linux-2.6.22.18/ipc/msg.c linux-2.6.22.18-vs2.3.0.32/ipc/msg.c
17282 --- linux-2.6.22.18/ipc/msg.c 2007-05-04 15:58:24.000000000 +0200
17283 +++ linux-2.6.22.18-vs2.3.0.32/ipc/msg.c 2008-02-11 12:35:36.000000000 +0100
17285 #include <linux/seq_file.h>
17286 #include <linux/mutex.h>
17287 #include <linux/nsproxy.h>
17288 +#include <linux/vs_base.h>
17290 #include <asm/current.h>
17291 #include <asm/uaccess.h>
17292 @@ -149,6 +150,7 @@ static int newque (struct ipc_namespace
17294 msq->q_perm.mode = msgflg & S_IRWXUGO;
17295 msq->q_perm.key = key;
17296 + msq->q_perm.xid = vx_current_xid();
17298 msq->q_perm.security = NULL;
17299 retval = security_msg_queue_alloc(msq);
17300 diff -Nurp linux-2.6.22.18/ipc/sem.c linux-2.6.22.18-vs2.3.0.32/ipc/sem.c
17301 --- linux-2.6.22.18/ipc/sem.c 2007-07-22 00:00:24.000000000 +0200
17302 +++ linux-2.6.22.18-vs2.3.0.32/ipc/sem.c 2008-02-11 12:35:36.000000000 +0100
17304 #include <linux/seq_file.h>
17305 #include <linux/mutex.h>
17306 #include <linux/nsproxy.h>
17307 +#include <linux/vs_base.h>
17308 +#include <linux/vs_limit.h>
17310 #include <asm/uaccess.h>
17312 @@ -229,6 +231,7 @@ static int newary (struct ipc_namespace
17314 sma->sem_perm.mode = (semflg & S_IRWXUGO);
17315 sma->sem_perm.key = key;
17316 + sma->sem_perm.xid = vx_current_xid();
17318 sma->sem_perm.security = NULL;
17319 retval = security_sem_alloc(sma);
17320 @@ -244,6 +247,9 @@ static int newary (struct ipc_namespace
17323 ns->used_sems += nsems;
17324 + /* FIXME: obsoleted? */
17325 + vx_semary_inc(sma);
17326 + vx_nsems_add(sma, nsems);
17328 sma->sem_id = sem_buildid(ns, id, sma->sem_perm.seq);
17329 sma->sem_base = (struct sem *) &sma[1];
17330 @@ -525,6 +531,9 @@ static void freeary (struct ipc_namespac
17333 ns->used_sems -= sma->sem_nsems;
17334 + /* FIXME: obsoleted? */
17335 + vx_nsems_sub(sma, sma->sem_nsems);
17336 + vx_semary_dec(sma);
17337 size = sizeof (*sma) + sma->sem_nsems * sizeof (struct sem);
17338 security_sem_free(sma);
17339 ipc_rcu_putref(sma);
17340 diff -Nurp linux-2.6.22.18/ipc/shm.c linux-2.6.22.18-vs2.3.0.32/ipc/shm.c
17341 --- linux-2.6.22.18/ipc/shm.c 2007-08-12 03:54:37.000000000 +0200
17342 +++ linux-2.6.22.18-vs2.3.0.32/ipc/shm.c 2008-02-11 12:35:36.000000000 +0100
17344 #include <linux/mutex.h>
17345 #include <linux/nsproxy.h>
17346 #include <linux/mount.h>
17347 +#include <linux/vs_context.h>
17348 +#include <linux/vs_limit.h>
17350 #include <asm/uaccess.h>
17352 @@ -185,7 +187,12 @@ static void shm_open(struct vm_area_stru
17354 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
17356 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
17357 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
17358 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
17360 + vx_ipcshm_sub(vxi, shp, numpages);
17361 + ns->shm_tot -= numpages;
17363 shm_rmid(ns, shp->id);
17365 if (!is_file_hugepages(shp->shm_file))
17366 @@ -195,6 +202,7 @@ static void shm_destroy(struct ipc_names
17368 fput (shp->shm_file);
17369 security_shm_free(shp);
17370 + put_vx_info(vxi);
17371 ipc_rcu_putref(shp);
17374 @@ -351,11 +359,15 @@ static int newseg (struct ipc_namespace
17375 if (ns->shm_tot + numpages > ns->shm_ctlall)
17378 + if (!vx_ipcshm_avail(current->vx_info, numpages))
17381 shp = ipc_rcu_alloc(sizeof(*shp));
17385 shp->shm_perm.key = key;
17386 + shp->shm_perm.xid = vx_current_xid();
17387 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
17388 shp->mlock_user = NULL;
17390 @@ -406,6 +418,7 @@ static int newseg (struct ipc_namespace
17391 file->f_dentry->d_inode->i_ino = shp->id;
17393 ns->shm_tot += numpages;
17394 + vx_ipcshm_add(current->vx_info, key, numpages);
17398 diff -Nurp linux-2.6.22.18/ipc/util.c linux-2.6.22.18-vs2.3.0.32/ipc/util.c
17399 --- linux-2.6.22.18/ipc/util.c 2007-07-22 00:00:24.000000000 +0200
17400 +++ linux-2.6.22.18-vs2.3.0.32/ipc/util.c 2008-02-11 12:35:36.000000000 +0100
17402 #include <linux/proc_fs.h>
17403 #include <linux/audit.h>
17404 #include <linux/nsproxy.h>
17405 +#include <linux/vs_base.h>
17406 +#include <linux/vserver/global.h>
17408 #include <asm/unistd.h>
17410 @@ -72,6 +74,7 @@ static struct ipc_namespace *clone_ipc_n
17413 kref_init(&ns->kref);
17414 + atomic_inc(&vs_global_ipc_ns);
17418 @@ -108,6 +111,7 @@ void free_ipc_ns(struct kref *kref)
17422 + atomic_dec(&vs_global_ipc_ns);
17426 diff -Nurp linux-2.6.22.18/kernel/capability.c linux-2.6.22.18-vs2.3.0.32/kernel/capability.c
17427 --- linux-2.6.22.18/kernel/capability.c 2007-07-21 23:58:53.000000000 +0200
17428 +++ linux-2.6.22.18-vs2.3.0.32/kernel/capability.c 2008-02-11 12:35:36.000000000 +0100
17430 #include <linux/module.h>
17431 #include <linux/security.h>
17432 #include <linux/syscalls.h>
17433 +#include <linux/vs_context.h>
17434 #include <asm/uaccess.h>
17436 unsigned securebits = SECUREBITS_DEFAULT; /* systemwide security settings */
17437 @@ -103,6 +104,8 @@ static inline int cap_set_pg(int pgrp_nr
17439 pgrp = find_pid(pgrp_nr);
17440 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
17441 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
17444 while_each_thread(g, target) {
17445 if (!security_capset_check(target, effective,
17446 @@ -246,8 +249,12 @@ int __capable(struct task_struct *t, int
17448 EXPORT_SYMBOL(__capable);
17450 +#include <linux/vserver/base.h>
17451 int capable(int cap)
17453 + /* here for now so we don't require task locking */
17454 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
17456 return __capable(current, cap);
17458 EXPORT_SYMBOL(capable);
17459 diff -Nurp linux-2.6.22.18/kernel/compat.c linux-2.6.22.18-vs2.3.0.32/kernel/compat.c
17460 --- linux-2.6.22.18/kernel/compat.c 2007-07-22 00:00:24.000000000 +0200
17461 +++ linux-2.6.22.18-vs2.3.0.32/kernel/compat.c 2008-02-11 12:35:36.000000000 +0100
17462 @@ -846,7 +846,7 @@ asmlinkage long compat_sys_time(compat_t
17466 - do_gettimeofday(&tv);
17467 + vx_gettimeofday(&tv);
17471 @@ -870,7 +870,7 @@ asmlinkage long compat_sys_stime(compat_
17475 - do_settimeofday(&tv);
17476 + vx_settimeofday(&tv);
17480 diff -Nurp linux-2.6.22.18/kernel/exit.c linux-2.6.22.18-vs2.3.0.32/kernel/exit.c
17481 --- linux-2.6.22.18/kernel/exit.c 2008-01-15 16:00:35.000000000 +0100
17482 +++ linux-2.6.22.18-vs2.3.0.32/kernel/exit.c 2008-02-11 12:35:36.000000000 +0100
17484 #include <linux/resource.h>
17485 #include <linux/blkdev.h>
17486 #include <linux/task_io_accounting_ops.h>
17487 +#include <linux/vs_limit.h>
17488 +#include <linux/vs_context.h>
17489 +#include <linux/vs_network.h>
17490 +#include <linux/vs_pid.h>
17491 +#include <linux/vserver/global.h>
17493 #include <asm/uaccess.h>
17494 #include <asm/unistd.h>
17495 @@ -443,9 +448,11 @@ static void close_files(struct files_str
17496 filp_close(file, files);
17499 + vx_openfd_dec(i);
17507 @@ -525,6 +532,7 @@ static inline void __put_fs_struct(struc
17509 mntput(fs->altrootmnt);
17511 + atomic_dec(&vs_global_fs);
17512 kmem_cache_free(fs_cachep, fs);
17515 @@ -596,6 +604,14 @@ static void exit_mm(struct task_struct *
17517 choose_new_parent(struct task_struct *p, struct task_struct *reaper)
17519 + /* check for reaper context */
17520 + vxwprintk((p->xid != reaper->xid) && (reaper != child_reaper(p)),
17521 + "rogue reaper: %p[%d,#%u] <> %p[%d,#%u]",
17522 + p, p->pid, p->xid, reaper, reaper->pid, reaper->xid);
17525 + reaper = vx_child_reaper(p);
17528 * Make sure we're not reparenting to ourselves and that
17529 * the parent is not a zombie.
17530 @@ -687,7 +703,7 @@ forget_original_parent(struct task_struc
17532 reaper = next_thread(reaper);
17533 if (reaper == father) {
17534 - reaper = child_reaper(father);
17535 + reaper = vx_child_reaper(father);
17538 } while (reaper->exit_state);
17539 @@ -964,6 +980,8 @@ fastcall NORET_TYPE void do_exit(long co
17540 tsk->exit_code = code;
17541 proc_exit_connector(tsk);
17542 exit_task_namespaces(tsk);
17543 + /* needs to stay before exit_notify() */
17544 + exit_vx_info_early(tsk, code);
17547 mpol_free(tsk->mempolicy);
17548 @@ -994,6 +1012,10 @@ fastcall NORET_TYPE void do_exit(long co
17549 if (tsk->splice_pipe)
17550 __free_pipe_info(tsk->splice_pipe);
17552 + /* needs to stay after exit_notify() */
17553 + exit_vx_info(tsk, code);
17554 + exit_nx_info(tsk);
17557 /* causes final put_task_struct in finish_task_switch(). */
17558 tsk->state = TASK_DEAD;
17559 diff -Nurp linux-2.6.22.18/kernel/fork.c linux-2.6.22.18-vs2.3.0.32/kernel/fork.c
17560 --- linux-2.6.22.18/kernel/fork.c 2007-07-22 00:00:24.000000000 +0200
17561 +++ linux-2.6.22.18-vs2.3.0.32/kernel/fork.c 2008-02-11 12:35:36.000000000 +0100
17563 #include <linux/delayacct.h>
17564 #include <linux/taskstats_kern.h>
17565 #include <linux/random.h>
17566 +#include <linux/vs_context.h>
17567 +#include <linux/vs_network.h>
17568 +#include <linux/vs_limit.h>
17569 +#include <linux/vs_memory.h>
17570 +#include <linux/vserver/global.h>
17572 #include <asm/pgtable.h>
17573 #include <asm/pgalloc.h>
17574 @@ -108,6 +113,8 @@ void free_task(struct task_struct *tsk)
17576 free_thread_info(tsk->stack);
17577 rt_mutex_debug_task_free(tsk);
17578 + clr_vx_info(&tsk->vx_info);
17579 + clr_nx_info(&tsk->nx_info);
17580 free_task_struct(tsk);
17582 EXPORT_SYMBOL(free_task);
17583 @@ -215,6 +222,8 @@ static inline int dup_mmap(struct mm_str
17584 mm->free_area_cache = oldmm->mmap_base;
17585 mm->cached_hole_size = ~0UL;
17587 + __set_mm_counter(mm, file_rss, 0);
17588 + __set_mm_counter(mm, anon_rss, 0);
17589 cpus_clear(mm->cpu_vm_mask);
17590 mm->mm_rb = RB_ROOT;
17591 rb_link = &mm->mm_rb.rb_node;
17592 @@ -226,7 +235,7 @@ static inline int dup_mmap(struct mm_str
17594 if (mpnt->vm_flags & VM_DONTCOPY) {
17595 long pages = vma_pages(mpnt);
17596 - mm->total_vm -= pages;
17597 + vx_vmpages_sub(mm, pages);
17598 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
17601 @@ -327,7 +336,7 @@ static inline void mm_free_pgd(struct mm
17603 #include <linux/init_task.h>
17605 -static struct mm_struct * mm_init(struct mm_struct * mm)
17606 +static struct mm_struct * mm_init(struct mm_struct * mm, struct vx_info *vxi)
17608 atomic_set(&mm->mm_users, 1);
17609 atomic_set(&mm->mm_count, 1);
17610 @@ -335,8 +344,8 @@ static struct mm_struct * mm_init(struct
17611 INIT_LIST_HEAD(&mm->mmlist);
17612 mm->core_waiters = 0;
17614 - set_mm_counter(mm, file_rss, 0);
17615 - set_mm_counter(mm, anon_rss, 0);
17616 + __set_mm_counter(mm, file_rss, 0);
17617 + __set_mm_counter(mm, anon_rss, 0);
17618 spin_lock_init(&mm->page_table_lock);
17619 rwlock_init(&mm->ioctx_list_lock);
17620 mm->ioctx_list = NULL;
17621 @@ -345,6 +354,7 @@ static struct mm_struct * mm_init(struct
17623 if (likely(!mm_alloc_pgd(mm))) {
17625 + set_vx_info(&mm->mm_vx_info, vxi);
17629 @@ -361,7 +371,7 @@ struct mm_struct * mm_alloc(void)
17630 mm = allocate_mm();
17632 memset(mm, 0, sizeof(*mm));
17633 - mm = mm_init(mm);
17634 + mm = mm_init(mm, current->vx_info);
17638 @@ -376,6 +386,7 @@ void fastcall __mmdrop(struct mm_struct
17639 BUG_ON(mm == &init_mm);
17641 destroy_context(mm);
17642 + clr_vx_info(&mm->mm_vx_info);
17646 @@ -490,12 +501,13 @@ static struct mm_struct *dup_mm(struct t
17649 memcpy(mm, oldmm, sizeof(*mm));
17650 + mm->mm_vx_info = NULL;
17652 /* Initializing for Swap token stuff */
17653 mm->token_priority = 0;
17654 mm->last_interval = 0;
17656 - if (!mm_init(mm))
17657 + if (!mm_init(mm, oldmm->mm_vx_info))
17660 if (init_new_context(tsk, mm))
17661 @@ -521,6 +533,7 @@ fail_nocontext:
17662 * If init_new_context() failed, we cannot use mmput() to free the mm
17663 * because it calls destroy_context()
17665 + clr_vx_info(&mm->mm_vx_info);
17669 @@ -591,6 +604,7 @@ static inline struct fs_struct *__copy_f
17670 fs->altroot = NULL;
17672 read_unlock(&old->lock);
17673 + atomic_inc(&vs_global_fs);
17677 @@ -709,6 +723,8 @@ static struct files_struct *dup_fd(struc
17678 struct file *f = *old_fds++;
17681 + /* TODO: sum it first for check and performance */
17682 + vx_openfd_inc(open_files - i);
17685 * The fd may be claimed in the fd bitmap but not yet
17686 @@ -961,6 +977,8 @@ static struct task_struct *copy_process(
17689 struct task_struct *p = NULL;
17690 + struct vx_info *vxi;
17691 + struct nx_info *nxi;
17693 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
17694 return ERR_PTR(-EINVAL);
17695 @@ -995,12 +1013,30 @@ static struct task_struct *copy_process(
17696 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
17697 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
17699 + init_vx_info(&p->vx_info, current->vx_info);
17700 + init_nx_info(&p->nx_info, current->nx_info);
17702 + /* check vserver memory */
17703 + if (p->mm && !(clone_flags & CLONE_VM)) {
17704 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
17705 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17707 + goto bad_fork_free;
17709 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
17710 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
17711 + goto bad_fork_cleanup_vm;
17715 + if (!vx_nproc_avail(1))
17716 + goto bad_fork_cleanup_vm;
17718 if (atomic_read(&p->user->processes) >=
17719 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
17720 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
17721 p->user != &root_user)
17722 - goto bad_fork_free;
17723 + goto bad_fork_cleanup_vm;
17726 atomic_inc(&p->user->__count);
17727 @@ -1265,6 +1301,18 @@ static struct task_struct *copy_process(
17730 spin_unlock(¤t->sighand->siglock);
17732 + /* p is copy of current */
17733 + vxi = p->vx_info;
17735 + claim_vx_info(vxi, p);
17736 + atomic_inc(&vxi->cvirt.nr_threads);
17737 + atomic_inc(&vxi->cvirt.total_forks);
17740 + nxi = p->nx_info;
17742 + claim_nx_info(nxi, p);
17743 write_unlock_irq(&tasklist_lock);
17744 proc_fork_connector(p);
17746 @@ -1306,6 +1354,9 @@ bad_fork_cleanup_count:
17747 put_group_info(p->group_info);
17748 atomic_dec(&p->user->processes);
17750 +bad_fork_cleanup_vm:
17751 + if (p->mm && !(clone_flags & CLONE_VM))
17752 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17756 @@ -1367,6 +1418,15 @@ long do_fork(unsigned long clone_flags,
17761 + /* kernel threads are host only */
17762 + if ((clone_flags & CLONE_KTHREAD) &&
17763 + !vx_capable(CAP_SYS_ADMIN, VXC_KTHREAD)) {
17764 + vxwprintk_task(1, "tried to spawn a kernel thread.");
17770 if (unlikely(current->ptrace)) {
17771 trace = fork_traceflag (clone_flags);
17772 diff -Nurp linux-2.6.22.18/kernel/kthread.c linux-2.6.22.18-vs2.3.0.32/kernel/kthread.c
17773 --- linux-2.6.22.18/kernel/kthread.c 2007-07-22 00:00:24.000000000 +0200
17774 +++ linux-2.6.22.18-vs2.3.0.32/kernel/kthread.c 2008-02-11 12:35:36.000000000 +0100
17775 @@ -96,7 +96,7 @@ static void create_kthread(struct kthrea
17777 wait_for_completion(&create->started);
17778 read_lock(&tasklist_lock);
17779 - create->result = find_task_by_pid(pid);
17780 + create->result = find_task_by_real_pid(pid);
17781 read_unlock(&tasklist_lock);
17783 complete(&create->done);
17784 diff -Nurp linux-2.6.22.18/kernel/Makefile linux-2.6.22.18-vs2.3.0.32/kernel/Makefile
17785 --- linux-2.6.22.18/kernel/Makefile 2007-07-22 00:00:24.000000000 +0200
17786 +++ linux-2.6.22.18-vs2.3.0.32/kernel/Makefile 2008-02-11 12:35:36.000000000 +0100
17787 @@ -10,6 +10,8 @@ obj-y = sched.o fork.o exec_domain.o
17788 kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
17789 hrtimer.o rwsem.o latency.o nsproxy.o srcu.o die_notifier.o
17793 obj-$(CONFIG_STACKTRACE) += stacktrace.o
17795 obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
17796 diff -Nurp linux-2.6.22.18/kernel/nsproxy.c linux-2.6.22.18-vs2.3.0.32/kernel/nsproxy.c
17797 --- linux-2.6.22.18/kernel/nsproxy.c 2007-07-22 00:00:25.000000000 +0200
17798 +++ linux-2.6.22.18-vs2.3.0.32/kernel/nsproxy.c 2008-02-11 12:35:36.000000000 +0100
17799 @@ -20,14 +20,11 @@
17800 #include <linux/mnt_namespace.h>
17801 #include <linux/utsname.h>
17802 #include <linux/pid_namespace.h>
17803 +#include <linux/vserver/global.h>
17804 +#include <linux/vserver/debug.h>
17806 struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
17808 -static inline void get_nsproxy(struct nsproxy *ns)
17810 - atomic_inc(&ns->count);
17813 void get_task_namespaces(struct task_struct *tsk)
17815 struct nsproxy *ns = tsk->nsproxy;
17816 @@ -46,6 +43,9 @@ static inline struct nsproxy *clone_nspr
17817 ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL);
17819 atomic_set(&ns->count, 1);
17820 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
17821 + orig, atomic_read(&orig->count), ns);
17822 + atomic_inc(&vs_global_nsproxy);
17826 @@ -54,28 +54,32 @@ static inline struct nsproxy *clone_nspr
17827 * Return the newly created nsproxy. Do not attach this to the task,
17828 * leave it to the caller to do proper locking and attach it to task.
17830 -static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17831 +static struct nsproxy *unshare_namespaces(int flags, struct nsproxy *orig,
17832 struct fs_struct *new_fs)
17834 struct nsproxy *new_nsp;
17836 - new_nsp = clone_nsproxy(tsk->nsproxy);
17837 + vxdprintk(VXD_CBIT(space, 4),
17838 + "unshare_namespaces(0x%08x,%p,%p)",
17839 + flags, orig, new_fs);
17841 + new_nsp = clone_nsproxy(orig);
17843 return ERR_PTR(-ENOMEM);
17845 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
17846 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
17847 if (IS_ERR(new_nsp->mnt_ns))
17850 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
17851 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
17852 if (IS_ERR(new_nsp->uts_ns))
17855 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
17856 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
17857 if (IS_ERR(new_nsp->ipc_ns))
17860 - new_nsp->pid_ns = copy_pid_ns(flags, tsk->nsproxy->pid_ns);
17861 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
17862 if (IS_ERR(new_nsp->pid_ns))
17865 @@ -95,6 +99,33 @@ out_ns:
17866 return ERR_PTR(-ENOMEM);
17869 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17870 + struct fs_struct *new_fs)
17872 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
17876 + * copies the nsproxy, setting refcount to 1, and grabbing a
17877 + * reference to all contained namespaces.
17879 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
17881 + struct nsproxy *ns = clone_nsproxy(orig);
17885 + get_mnt_ns(ns->mnt_ns);
17887 + get_uts_ns(ns->uts_ns);
17889 + get_ipc_ns(ns->ipc_ns);
17891 + get_pid_ns(ns->pid_ns);
17897 * called from clone. This now handles copy for nsproxy and all
17898 * namespaces therein.
17899 @@ -102,9 +133,12 @@ out_ns:
17900 int copy_namespaces(int flags, struct task_struct *tsk)
17902 struct nsproxy *old_ns = tsk->nsproxy;
17903 - struct nsproxy *new_ns;
17904 + struct nsproxy *new_ns = NULL;
17907 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08x,%p[%p])",
17908 + flags, tsk, old_ns);
17913 @@ -127,6 +161,9 @@ int copy_namespaces(int flags, struct ta
17914 tsk->nsproxy = new_ns;
17916 put_nsproxy(old_ns);
17917 + vxdprintk(VXD_CBIT(space, 3),
17918 + "copy_namespaces(0x%08x,%p[%p]) = %d [%p]",
17919 + flags, tsk, old_ns, err, new_ns);
17923 @@ -140,6 +177,7 @@ void free_nsproxy(struct nsproxy *ns)
17924 put_ipc_ns(ns->ipc_ns);
17926 put_pid_ns(ns->pid_ns);
17927 + atomic_dec(&vs_global_nsproxy);
17931 @@ -152,6 +190,10 @@ int unshare_nsproxy_namespaces(unsigned
17935 + vxdprintk(VXD_CBIT(space, 4),
17936 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
17937 + unshare_flags, current->nsproxy);
17939 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC)))
17942 diff -Nurp linux-2.6.22.18/kernel/pid.c linux-2.6.22.18-vs2.3.0.32/kernel/pid.c
17943 --- linux-2.6.22.18/kernel/pid.c 2007-07-22 00:00:25.000000000 +0200
17944 +++ linux-2.6.22.18-vs2.3.0.32/kernel/pid.c 2008-02-11 12:35:36.000000000 +0100
17946 #include <linux/hash.h>
17947 #include <linux/pid_namespace.h>
17948 #include <linux/init_task.h>
17949 +#include <linux/vs_pid.h>
17951 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
17952 static struct hlist_head *pid_hash;
17953 @@ -295,6 +296,9 @@ void fastcall transfer_pid(struct task_s
17954 struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
17956 struct task_struct *result = NULL;
17958 + if (type == PIDTYPE_REALPID)
17959 + type = PIDTYPE_PID;
17961 struct hlist_node *first;
17962 first = rcu_dereference(pid->tasks[type].first);
17963 @@ -309,7 +313,17 @@ struct task_struct * fastcall pid_task(s
17965 struct task_struct *find_task_by_pid_type(int type, int nr)
17967 - return pid_task(find_pid(nr), type);
17968 + struct task_struct *task;
17970 + if (type == PIDTYPE_PID)
17971 + nr = vx_rmap_pid(nr);
17973 + task = pid_task(find_pid(nr), type);
17974 + if (task && (type != PIDTYPE_REALPID) &&
17975 + /* maybe VS_WATCH_P in the future? */
17976 + !vx_check(task->xid, VS_WATCH|VS_IDENT))
17981 EXPORT_SYMBOL(find_task_by_pid_type);
17982 diff -Nurp linux-2.6.22.18/kernel/posix-timers.c linux-2.6.22.18-vs2.3.0.32/kernel/posix-timers.c
17983 --- linux-2.6.22.18/kernel/posix-timers.c 2007-07-22 00:00:25.000000000 +0200
17984 +++ linux-2.6.22.18-vs2.3.0.32/kernel/posix-timers.c 2008-02-11 12:35:36.000000000 +0100
17986 #include <linux/wait.h>
17987 #include <linux/workqueue.h>
17988 #include <linux/module.h>
17989 +#include <linux/vs_context.h>
17992 * Management arrays for POSIX timers. Timers are kept in slab memory
17993 @@ -297,6 +298,12 @@ void do_schedule_next_timer(struct sigin
17995 int posix_timer_event(struct k_itimer *timr,int si_private)
17997 + struct vx_info_save vxis;
17998 + struct vx_info *vxi;
18001 + vxi = task_get_vx_info(timr->it_process);
18002 + enter_vx_info(vxi, &vxis);
18003 memset(&timr->sigq->info, 0, sizeof(siginfo_t));
18004 timr->sigq->info.si_sys_private = si_private;
18005 /* Send signal to the process that owns this timer.*/
18006 @@ -309,11 +316,11 @@ int posix_timer_event(struct k_itimer *t
18008 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
18009 struct task_struct *leader;
18010 - int ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
18011 - timr->it_process);
18013 + ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
18014 + timr->it_process);
18015 if (likely(ret >= 0))
18019 timr->it_sigev_notify = SIGEV_SIGNAL;
18020 leader = timr->it_process->group_leader;
18021 @@ -321,8 +328,12 @@ int posix_timer_event(struct k_itimer *t
18022 timr->it_process = leader;
18025 - return send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
18026 + ret = send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
18029 + leave_vx_info(&vxis);
18030 + put_vx_info(vxi);
18033 EXPORT_SYMBOL_GPL(posix_timer_event);
18035 @@ -402,7 +413,7 @@ static struct task_struct * good_sigeven
18036 struct task_struct *rtn = current->group_leader;
18038 if ((event->sigev_notify & SIGEV_THREAD_ID ) &&
18039 - (!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) ||
18040 + (!(rtn = find_task_by_real_pid(event->sigev_notify_thread_id)) ||
18041 rtn->tgid != current->tgid ||
18042 (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))
18044 diff -Nurp linux-2.6.22.18/kernel/printk.c linux-2.6.22.18-vs2.3.0.32/kernel/printk.c
18045 --- linux-2.6.22.18/kernel/printk.c 2007-07-22 00:00:25.000000000 +0200
18046 +++ linux-2.6.22.18-vs2.3.0.32/kernel/printk.c 2008-02-11 12:35:36.000000000 +0100
18048 #include <linux/bootmem.h>
18049 #include <linux/syscalls.h>
18050 #include <linux/jiffies.h>
18051 +#include <linux/vs_cvirt.h>
18053 #include <asm/uaccess.h>
18055 @@ -182,18 +183,13 @@ int do_syslog(int type, char __user *buf
18056 unsigned long i, j, limit, count;
18062 error = security_syslog(type);
18067 - case 0: /* Close log */
18069 - case 1: /* Open log */
18071 - case 2: /* Read from log */
18072 + if ((type >= 2) && (type <= 4)) {
18074 if (!buf || len < 0)
18076 @@ -204,6 +200,16 @@ int do_syslog(int type, char __user *buf
18081 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
18082 + return vx_do_syslog(type, buf, len);
18085 + case 0: /* Close log */
18087 + case 1: /* Open log */
18089 + case 2: /* Read from log */
18090 error = wait_event_interruptible(log_wait,
18091 (log_start - log_end));
18093 @@ -228,16 +234,6 @@ int do_syslog(int type, char __user *buf
18096 case 3: /* Read last kernel messages */
18098 - if (!buf || len < 0)
18103 - if (!access_ok(VERIFY_WRITE, buf, len)) {
18108 if (count > log_buf_len)
18109 count = log_buf_len;
18110 diff -Nurp linux-2.6.22.18/kernel/ptrace.c linux-2.6.22.18-vs2.3.0.32/kernel/ptrace.c
18111 --- linux-2.6.22.18/kernel/ptrace.c 2007-07-22 00:00:25.000000000 +0200
18112 +++ linux-2.6.22.18-vs2.3.0.32/kernel/ptrace.c 2008-02-11 12:35:36.000000000 +0100
18114 #include <linux/security.h>
18115 #include <linux/signal.h>
18116 #include <linux/audit.h>
18117 +#include <linux/vs_context.h>
18119 #include <asm/pgtable.h>
18120 #include <asm/uaccess.h>
18121 @@ -145,6 +146,11 @@ static int may_attach(struct task_struct
18122 dumpable = task->mm->dumpable;
18123 if (!dumpable && !capable(CAP_SYS_PTRACE))
18125 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
18127 + if (!vx_check(task->xid, VS_IDENT) &&
18128 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
18131 return security_ptrace(current, task);
18133 @@ -471,6 +477,10 @@ asmlinkage long sys_ptrace(long request,
18138 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
18139 + goto out_put_task_struct;
18141 if (request == PTRACE_ATTACH) {
18142 ret = ptrace_attach(child);
18143 goto out_put_task_struct;
18144 diff -Nurp linux-2.6.22.18/kernel/sched.c linux-2.6.22.18-vs2.3.0.32/kernel/sched.c
18145 --- linux-2.6.22.18/kernel/sched.c 2007-07-22 00:00:25.000000000 +0200
18146 +++ linux-2.6.22.18-vs2.3.0.32/kernel/sched.c 2008-02-11 12:35:36.000000000 +0100
18149 #include <asm/tlb.h>
18150 #include <asm/unistd.h>
18151 +#include <linux/vs_sched.h>
18152 +#include <linux/vs_cvirt.h>
18155 * Scheduler clock - returns current time in nanosec units.
18156 @@ -281,6 +283,16 @@ struct rq {
18157 struct task_struct *migration_thread;
18158 struct list_head migration_queue;
18160 + unsigned long norm_time;
18161 + unsigned long idle_time;
18162 +#ifdef CONFIG_VSERVER_IDLETIME
18165 +#ifdef CONFIG_VSERVER_HARDCPU
18166 + struct list_head hold_queue;
18167 + unsigned long nr_onhold;
18171 #ifdef CONFIG_SCHEDSTATS
18172 /* latency stats */
18173 @@ -714,6 +726,7 @@ sched_info_switch(struct task_struct *pr
18175 static void dequeue_task(struct task_struct *p, struct prio_array *array)
18177 + BUG_ON(p->state & TASK_ONHOLD);
18178 array->nr_active--;
18179 list_del(&p->run_list);
18180 if (list_empty(array->queue + p->prio))
18181 @@ -722,6 +735,7 @@ static void dequeue_task(struct task_str
18183 static void enqueue_task(struct task_struct *p, struct prio_array *array)
18185 + BUG_ON(p->state & TASK_ONHOLD);
18186 sched_info_queued(p);
18187 list_add_tail(&p->run_list, array->queue + p->prio);
18188 __set_bit(p->prio, array->bitmap);
18189 @@ -735,12 +749,14 @@ static void enqueue_task(struct task_str
18191 static void requeue_task(struct task_struct *p, struct prio_array *array)
18193 + BUG_ON(p->state & TASK_ONHOLD);
18194 list_move_tail(&p->run_list, array->queue + p->prio);
18198 enqueue_task_head(struct task_struct *p, struct prio_array *array)
18200 + BUG_ON(p->state & TASK_ONHOLD);
18201 list_add(&p->run_list, array->queue + p->prio);
18202 __set_bit(p->prio, array->bitmap);
18203 array->nr_active++;
18204 @@ -769,6 +785,10 @@ static inline int __normal_prio(struct t
18205 bonus = CURRENT_BONUS(p) - MAX_BONUS / 2;
18207 prio = p->static_prio - bonus;
18209 + /* adjust effective priority */
18210 + prio = vx_adjust_prio(p, prio, MAX_USER_PRIO);
18212 if (prio < MAX_RT_PRIO)
18213 prio = MAX_RT_PRIO;
18214 if (prio > MAX_PRIO-1)
18215 @@ -878,6 +898,9 @@ static int effective_prio(struct task_st
18219 +#include "sched_mon.h"
18223 * __activate_task - move a task to the runqueue.
18225 @@ -887,6 +910,7 @@ static void __activate_task(struct task_
18228 target = rq->expired;
18229 + vxm_activate_task(p, rq);
18230 enqueue_task(p, target);
18231 inc_nr_running(p, rq);
18233 @@ -896,6 +920,7 @@ static void __activate_task(struct task_
18235 static inline void __activate_idle_task(struct task_struct *p, struct rq *rq)
18237 + vxm_activate_idle(p, rq);
18238 enqueue_task_head(p, rq->active);
18239 inc_nr_running(p, rq);
18241 @@ -1030,19 +1055,30 @@ static void activate_task(struct task_st
18243 p->timestamp = now;
18245 + vx_activate_task(p);
18246 __activate_task(p, rq);
18250 - * deactivate_task - remove a task from the runqueue.
18251 + * __deactivate_task - remove a task from the runqueue.
18253 -static void deactivate_task(struct task_struct *p, struct rq *rq)
18254 +static void __deactivate_task(struct task_struct *p, struct rq *rq)
18256 dec_nr_running(p, rq);
18257 dequeue_task(p, p->array);
18258 + vxm_deactivate_task(p, rq);
18263 +void deactivate_task(struct task_struct *p, struct rq *rq)
18265 + vx_deactivate_task(p);
18266 + __deactivate_task(p, rq);
18269 +#include "sched_hard.h"
18272 * resched_task - mark a task 'to be rescheduled now'.
18274 @@ -1129,6 +1165,7 @@ migrate_task(struct task_struct *p, int
18276 struct rq *rq = task_rq(p);
18278 + vxm_migrate_task(p, rq, dest_cpu);
18280 * If the task is not on a runqueue (and not running), then
18281 * it is sufficient to simply update the task's cpu field.
18282 @@ -1518,6 +1555,12 @@ static int try_to_wake_up(struct task_st
18284 rq = task_rq_lock(p, &flags);
18285 old_state = p->state;
18287 + /* we need to unhold suspended tasks */
18288 + if (old_state & TASK_ONHOLD) {
18289 + vx_unhold_task(p, rq);
18290 + old_state = p->state;
18292 if (!(old_state & state))
18295 @@ -1625,6 +1668,7 @@ out_activate:
18296 #endif /* CONFIG_SMP */
18297 if (old_state == TASK_UNINTERRUPTIBLE) {
18298 rq->nr_uninterruptible--;
18299 + vx_uninterruptible_dec(p);
18301 * Tasks on involuntary sleep don't earn
18302 * sleep_avg beyond just interactive state.
18303 @@ -1676,7 +1720,7 @@ int fastcall wake_up_state(struct task_s
18304 return try_to_wake_up(p, state, 0);
18307 -static void task_running_tick(struct rq *rq, struct task_struct *p);
18308 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu);
18310 * Perform scheduler related setup for a newly forked process p.
18311 * p is forked by current.
18312 @@ -1737,7 +1781,7 @@ void fastcall sched_fork(struct task_str
18313 * runqueue lock is not a problem.
18315 current->time_slice = 1;
18316 - task_running_tick(cpu_rq(cpu), current);
18317 + task_running_tick(cpu_rq(cpu), current, cpu);
18319 local_irq_enable();
18321 @@ -1772,6 +1816,7 @@ void fastcall wake_up_new_task(struct ta
18323 p->prio = effective_prio(p);
18325 + vx_activate_task(p);
18326 if (likely(cpu == this_cpu)) {
18327 if (!(clone_flags & CLONE_VM)) {
18329 @@ -1783,6 +1828,7 @@ void fastcall wake_up_new_task(struct ta
18330 __activate_task(p, rq);
18332 p->prio = current->prio;
18333 + BUG_ON(p->state & TASK_ONHOLD);
18334 p->normal_prio = current->normal_prio;
18335 list_add_tail(&p->run_list, ¤t->run_list);
18336 p->array = current->array;
18337 @@ -3351,13 +3397,16 @@ static inline int expired_starving(struc
18338 void account_user_time(struct task_struct *p, cputime_t cputime)
18340 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
18341 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
18343 + int nice = (TASK_NICE(p) > 0);
18345 p->utime = cputime_add(p->utime, cputime);
18346 + vx_account_user(vxi, cputime, nice);
18348 /* Add user time to cpustat. */
18349 tmp = cputime_to_cputime64(cputime);
18350 - if (TASK_NICE(p) > 0)
18352 cpustat->nice = cputime64_add(cpustat->nice, tmp);
18354 cpustat->user = cputime64_add(cpustat->user, tmp);
18355 @@ -3373,10 +3422,12 @@ void account_system_time(struct task_str
18358 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
18359 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
18360 struct rq *rq = this_rq();
18363 p->stime = cputime_add(p->stime, cputime);
18364 + vx_account_system(vxi, cputime, (p == rq->idle));
18366 /* Add system time to cpustat. */
18367 tmp = cputime_to_cputime64(cputime);
18368 @@ -3415,7 +3466,7 @@ void account_steal_time(struct task_stru
18369 cpustat->steal = cputime64_add(cpustat->steal, tmp);
18372 -static void task_running_tick(struct rq *rq, struct task_struct *p)
18373 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu)
18375 if (p->array != rq->active) {
18376 /* Task has expired but was not scheduled yet */
18377 @@ -3445,7 +3496,7 @@ static void task_running_tick(struct rq
18381 - if (!--p->time_slice) {
18382 + if (vx_need_resched(p, --p->time_slice, cpu)) {
18383 dequeue_task(p, rq->active);
18384 set_tsk_need_resched(p);
18385 p->prio = effective_prio(p);
18386 @@ -3506,9 +3557,12 @@ void scheduler_tick(void)
18387 struct rq *rq = cpu_rq(cpu);
18389 update_cpu_clock(p, rq, now);
18390 + vxm_sync(now, cpu);
18392 - if (!idle_at_tick)
18393 - task_running_tick(rq, p);
18394 + if (idle_at_tick)
18395 + vx_idle_resched(rq);
18397 + task_running_tick(rq, p, cpu);
18400 rq->idle_at_tick = idle_at_tick;
18401 @@ -3630,14 +3684,25 @@ need_resched_nonpreemptible:
18402 unlikely(signal_pending(prev))))
18403 prev->state = TASK_RUNNING;
18405 - if (prev->state == TASK_UNINTERRUPTIBLE)
18406 + if (prev->state == TASK_UNINTERRUPTIBLE) {
18407 rq->nr_uninterruptible++;
18408 + vx_uninterruptible_inc(prev);
18410 deactivate_task(prev, rq);
18414 cpu = smp_processor_id();
18415 + vx_set_rq_time(rq, jiffies);
18417 + vx_try_unhold(rq, cpu);
18420 if (unlikely(!rq->nr_running)) {
18421 + /* can we skip idle time? */
18422 + if (vx_try_skip(rq, cpu))
18425 idle_balance(cpu, rq);
18426 if (!rq->nr_running) {
18428 @@ -3663,6 +3728,10 @@ need_resched_nonpreemptible:
18429 queue = array->queue + idx;
18430 next = list_entry(queue->next, struct task_struct, run_list);
18432 + /* check before we schedule this context */
18433 + if (!vx_schedule(next, rq, cpu))
18436 if (!rt_task(next) && interactive_sleep(next->sleep_type)) {
18437 unsigned long long delta = now - next->timestamp;
18438 if (unlikely((long long)(now - next->timestamp) < 0))
18439 @@ -4263,7 +4332,7 @@ asmlinkage long sys_nice(int increment)
18442 if (increment < 0 && !can_nice(current, nice))
18444 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
18446 retval = security_task_setnice(current, nice);
18448 @@ -4435,6 +4504,7 @@ recheck:
18450 __setscheduler(p, policy, param->sched_priority);
18452 + vx_activate_task(p);
18453 __activate_task(p, rq);
18455 * Reschedule if we are currently running on this runqueue and
18456 @@ -5188,6 +5258,7 @@ static int __migrate_task(struct task_st
18457 p->timestamp = p->timestamp - rq_src->most_recent_timestamp
18458 + rq_dest->most_recent_timestamp;
18459 deactivate_task(p, rq_src);
18460 + vx_activate_task(p);
18461 __activate_task(p, rq_dest);
18462 if (TASK_PREEMPTS_CURR(p, rq_dest))
18463 resched_task(rq_dest->curr);
18464 @@ -7058,7 +7129,10 @@ void __init sched_init(void)
18465 INIT_LIST_HEAD(&rq->migration_queue);
18467 atomic_set(&rq->nr_iowait, 0);
18469 +#ifdef CONFIG_VSERVER_HARDCPU
18470 + INIT_LIST_HEAD(&rq->hold_queue);
18471 + rq->nr_onhold = 0;
18473 for (j = 0; j < 2; j++) {
18474 array = rq->arrays + j;
18475 for (k = 0; k < MAX_PRIO; k++) {
18476 @@ -7144,6 +7218,7 @@ void normalize_rt_tasks(void)
18477 deactivate_task(p, task_rq(p));
18478 __setscheduler(p, SCHED_NORMAL, 0);
18480 + vx_activate_task(p);
18481 __activate_task(p, task_rq(p));
18482 resched_task(rq->curr);
18484 diff -Nurp linux-2.6.22.18/kernel/sched_hard.h linux-2.6.22.18-vs2.3.0.32/kernel/sched_hard.h
18485 --- linux-2.6.22.18/kernel/sched_hard.h 1970-01-01 01:00:00.000000000 +0100
18486 +++ linux-2.6.22.18-vs2.3.0.32/kernel/sched_hard.h 2008-02-11 12:35:36.000000000 +0100
18489 +#ifdef CONFIG_VSERVER_IDLELIMIT
18492 + * vx_idle_resched - reschedule after maxidle
18495 +void vx_idle_resched(struct rq *rq)
18497 + /* maybe have a better criterion for paused */
18498 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
18499 + set_need_resched();
18502 +#else /* !CONFIG_VSERVER_IDLELIMIT */
18504 +#define vx_idle_resched(rq)
18506 +#endif /* CONFIG_VSERVER_IDLELIMIT */
18510 +#ifdef CONFIG_VSERVER_IDLETIME
18512 +#define vx_set_rq_min_skip(rq, min) \
18513 + (rq)->idle_skip = (min)
18515 +#define vx_save_min_skip(ret, min, val) \
18516 + __vx_save_min_skip(ret, min, val)
18519 +void __vx_save_min_skip(int ret, int *min, int val)
18523 + if ((*min > val) || !*min)
18528 +int vx_try_skip(struct rq *rq, int cpu)
18530 + /* artificially advance time */
18531 + if (rq->idle_skip > 0) {
18532 + vxdprintk(list_empty(&rq->hold_queue),
18533 + "hold queue empty on cpu %d", cpu);
18534 + rq->idle_time += rq->idle_skip;
18535 + vxm_idle_skip(rq, cpu);
18541 +#else /* !CONFIG_VSERVER_IDLETIME */
18543 +#define vx_set_rq_min_skip(rq, min) \
18544 + ({ int dummy = (min); dummy; })
18546 +#define vx_save_min_skip(ret, min, val)
18549 +int vx_try_skip(struct rq *rq, int cpu)
18554 +#endif /* CONFIG_VSERVER_IDLETIME */
18558 +#ifdef CONFIG_VSERVER_HARDCPU
18560 +#define vx_set_rq_max_idle(rq, max) \
18561 + (rq)->idle_tokens = (max)
18563 +#define vx_save_max_idle(ret, min, val) \
18564 + __vx_save_max_idle(ret, min, val)
18567 +void __vx_save_max_idle(int ret, int *min, int val)
18575 + * vx_hold_task - put a task on the hold queue
18578 +void vx_hold_task(struct task_struct *p, struct rq *rq)
18580 + __deactivate_task(p, rq);
18581 + p->state |= TASK_ONHOLD;
18582 + /* a new one on hold */
18584 + vxm_hold_task(p, rq);
18585 + list_add_tail(&p->run_list, &rq->hold_queue);
18589 + * vx_unhold_task - put a task back to the runqueue
18592 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
18594 + list_del(&p->run_list);
18595 + /* one less waiting */
18597 + p->state &= ~TASK_ONHOLD;
18598 + enqueue_task(p, rq->expired);
18599 + inc_nr_running(p, rq);
18600 + vxm_unhold_task(p, rq);
18602 + if (p->static_prio < rq->best_expired_prio)
18603 + rq->best_expired_prio = p->static_prio;
18606 +unsigned long nr_onhold(void)
18608 + unsigned long i, sum = 0;
18610 + for_each_online_cpu(i)
18611 + sum += cpu_rq(i)->nr_onhold;
18619 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
18621 + return sched_pc->tokens;
18625 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
18627 + sched_pc->tokens--;
18631 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
18633 + struct vx_info *vxi = p->vx_info;
18635 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
18636 + struct _vx_sched_pc *sched_pc =
18637 + &vx_per_cpu(vxi, sched_pc, cpu);
18640 + /* maybe we can simplify that to decrement
18641 + the token counter unconditional? */
18643 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
18644 + __vx_consume_token(sched_pc);
18646 + /* for tokens > 0, one token was consumed */
18650 + vxm_need_resched(p, slice, cpu);
18651 + return (slice == 0);
18655 +#define vx_set_rq_time(rq, time) do { \
18656 + rq->norm_time = time; \
18661 +void vx_try_unhold(struct rq *rq, int cpu)
18663 + struct vx_info *vxi = NULL;
18664 + struct list_head *l, *n;
18665 + int maxidle = HZ;
18668 + /* nothing to do? what about pause? */
18669 + if (list_empty(&rq->hold_queue))
18672 + list_for_each_safe(l, n, &rq->hold_queue) {
18673 + int ret, delta_min[2];
18674 + struct _vx_sched_pc *sched_pc;
18675 + struct task_struct *p;
18677 + p = list_entry(l, struct task_struct, run_list);
18678 + /* don't bother with same context */
18679 + if (vxi == p->vx_info)
18682 + vxi = p->vx_info;
18683 + /* ignore paused contexts */
18684 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
18687 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18689 + /* recalc tokens */
18690 + vxm_sched_info(sched_pc, vxi, cpu);
18691 + ret = vx_tokens_recalc(sched_pc,
18692 + &rq->norm_time, &rq->idle_time, delta_min);
18693 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18696 + /* we found a runable context */
18697 + vx_unhold_task(p, rq);
18700 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
18701 + vx_save_min_skip(ret, &minskip, delta_min[1]);
18703 + vx_set_rq_max_idle(rq, maxidle);
18704 + vx_set_rq_min_skip(rq, minskip);
18705 + vxm_rq_max_min(rq, cpu);
18710 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
18712 + struct vx_info *vxi = next->vx_info;
18713 + struct _vx_sched_pc *sched_pc;
18714 + int delta_min[2];
18720 + flags = vxi->vx_flags;
18722 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
18723 + goto put_on_hold;
18724 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
18727 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18729 + /* update scheduler params */
18730 + if (cpu_isset(cpu, vxi->sched.update)) {
18731 + vx_update_sched_param(&vxi->sched, sched_pc);
18732 + vxm_update_sched(sched_pc, vxi, cpu);
18733 + cpu_clear(cpu, vxi->sched.update);
18736 + vxm_sched_info(sched_pc, vxi, cpu);
18737 + ret = vx_tokens_recalc(sched_pc,
18738 + &rq->norm_time, &rq->idle_time, delta_min);
18739 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18741 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
18744 + if (unlikely(ret < 0)) {
18745 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
18746 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
18747 + vxm_rq_max_min(rq, cpu);
18749 + vx_hold_task(next, rq);
18756 +#else /* CONFIG_VSERVER_HARDCPU */
18759 +void vx_hold_task(struct task_struct *p, struct rq *rq)
18765 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
18770 +unsigned long nr_onhold(void)
18777 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
18779 + return (slice == 0);
18783 +#define vx_set_rq_time(rq, time)
18786 +void vx_try_unhold(struct rq *rq, int cpu)
18792 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
18794 + struct vx_info *vxi = next->vx_info;
18795 + struct _vx_sched_pc *sched_pc;
18796 + int delta_min[2];
18799 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
18802 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18803 + vxm_sched_info(sched_pc, vxi, cpu);
18804 + ret = vx_tokens_recalc(sched_pc,
18805 + &rq->norm_time, &rq->idle_time, delta_min);
18806 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18810 +#endif /* CONFIG_VSERVER_HARDCPU */
18812 diff -Nurp linux-2.6.22.18/kernel/sched_mon.h linux-2.6.22.18-vs2.3.0.32/kernel/sched_mon.h
18813 --- linux-2.6.22.18/kernel/sched_mon.h 1970-01-01 01:00:00.000000000 +0100
18814 +++ linux-2.6.22.18-vs2.3.0.32/kernel/sched_mon.h 2008-02-11 12:35:36.000000000 +0100
18817 +#include <linux/vserver/monitor.h>
18819 +#ifdef CONFIG_VSERVER_MONITOR
18821 +#ifdef CONFIG_VSERVER_HARDCPU
18822 +#define HARDCPU(x) (x)
18824 +#define HARDCPU(x) (0)
18827 +#ifdef CONFIG_VSERVER_IDLETIME
18828 +#define IDLETIME(x) (x)
18830 +#define IDLETIME(x) (0)
18833 +struct _vx_mon_entry *vxm_advance(int cpu);
18837 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
18839 + entry->type = type;
18840 + entry->xid = xid;
18844 +void __vxm_sync(int cpu)
18846 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18848 + __vxm_basic(entry, 0, VXM_SYNC);
18849 + entry->ev.sec = xtime.tv_sec;
18850 + entry->ev.nsec = xtime.tv_nsec;
18854 +void __vxm_task(struct task_struct *p, int type)
18856 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
18858 + __vxm_basic(entry, p->xid, type);
18859 + entry->ev.tsk.pid = p->pid;
18860 + entry->ev.tsk.state = p->state;
18864 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18866 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18868 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
18869 + entry->sd.tokens = s->tokens;
18870 + entry->sd.norm_time = s->norm_time;
18871 + entry->sd.idle_time = s->idle_time;
18875 +void __vxm_rqinfo1(struct rq *q, int cpu)
18877 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18879 + entry->type = VXM_RQINFO_1;
18880 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
18881 + entry->q1.running = q->nr_running;
18882 + entry->q1.onhold = HARDCPU(q->nr_onhold);
18883 + entry->q1.iowait = atomic_read(&q->nr_iowait);
18884 + entry->q1.uintr = q->nr_uninterruptible;
18885 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
18889 +void __vxm_rqinfo2(struct rq *q, int cpu)
18891 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18893 + entry->type = VXM_RQINFO_2;
18894 + entry->xid = (unsigned long)q & 0xffff;
18895 + entry->q2.norm_time = q->norm_time;
18896 + entry->q2.idle_time = q->idle_time;
18897 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
18901 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18903 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18905 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
18906 + entry->ev.tokens = s->tokens;
18910 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18912 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18914 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
18915 + entry->u1.tokens_max = s->tokens_max;
18916 + entry->u1.fill_rate = s->fill_rate[0];
18917 + entry->u1.interval = s->interval[0];
18921 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18923 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18925 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
18926 + entry->u2.tokens_min = s->tokens_min;
18927 + entry->u2.fill_rate = s->fill_rate[1];
18928 + entry->u2.interval = s->interval[1];
18932 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
18933 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
18934 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
18935 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
18936 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
18939 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
18941 + __vxm_task(p, VXM_MIGRATE);
18942 + __vxm_rqinfo1(rq, task_cpu(p));
18943 + __vxm_rqinfo2(rq, task_cpu(p));
18947 +void vxm_idle_skip(struct rq *rq, int cpu)
18949 + __vxm_rqinfo1(rq, cpu);
18950 + __vxm_rqinfo2(rq, cpu);
18954 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
18959 + __vxm_task(p, VXM_RESCHED);
18963 +void vxm_sync(unsigned long now, int cpu)
18965 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
18966 + (now % CONFIG_VSERVER_MONITOR_SYNC))
18972 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
18975 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
18976 + struct vx_info *vxi, int cpu)
18978 + __vxm_sched(s, vxi, cpu);
18979 + __vxm_rqinfo2(rq, cpu);
18983 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18985 + __vxm_sched(s, vxi, cpu);
18986 + __vxm_update(s, vxi, cpu);
18987 + __vxm_update1(s, vxi, cpu);
18988 + __vxm_update2(s, vxi, cpu);
18992 +void vxm_rq_max_min(struct rq *rq, int cpu)
18994 + __vxm_rqinfo1(rq, cpu);
18995 + __vxm_rqinfo2(rq, cpu);
18998 +#else /* CONFIG_VSERVER_MONITOR */
19000 +#define vxm_activate_task(t,q) do { } while (0)
19001 +#define vxm_activate_idle(t,q) do { } while (0)
19002 +#define vxm_deactivate_task(t,q) do { } while (0)
19003 +#define vxm_hold_task(t,q) do { } while (0)
19004 +#define vxm_unhold_task(t,q) do { } while (0)
19005 +#define vxm_migrate_task(t,q,d) do { } while (0)
19006 +#define vxm_idle_skip(q,c) do { } while (0)
19007 +#define vxm_need_resched(t,s,c) do { } while (0)
19008 +#define vxm_sync(s,c) do { } while (0)
19009 +#define vxm_sched_info(s,v,c) do { } while (0)
19010 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
19011 +#define vxm_update_sched(s,v,c) do { } while (0)
19012 +#define vxm_rq_max_min(q,c) do { } while (0)
19014 +#endif /* CONFIG_VSERVER_MONITOR */
19016 diff -Nurp linux-2.6.22.18/kernel/signal.c linux-2.6.22.18-vs2.3.0.32/kernel/signal.c
19017 --- linux-2.6.22.18/kernel/signal.c 2007-09-29 14:11:49.000000000 +0200
19018 +++ linux-2.6.22.18-vs2.3.0.32/kernel/signal.c 2008-02-11 12:35:36.000000000 +0100
19020 #include <linux/freezer.h>
19021 #include <linux/pid_namespace.h>
19022 #include <linux/nsproxy.h>
19023 +#include <linux/vs_context.h>
19024 +#include <linux/vs_pid.h>
19026 #include <asm/param.h>
19027 #include <asm/uaccess.h>
19028 @@ -523,19 +525,34 @@ static int check_kill_permission(int sig
19029 if (!valid_signal(sig))
19032 + if ((info != SEND_SIG_NOINFO) &&
19033 + (is_si_special(info) || !SI_FROMUSER(info)))
19036 + vxdprintk(VXD_CBIT(misc, 7),
19037 + "check_kill_permission(%d,%p,%p[#%u,%u])",
19038 + sig, info, t, vx_task_xid(t), t->pid);
19040 error = audit_signal_info(sig, t); /* Let audit system see the signal */
19045 - if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
19046 - && ((sig != SIGCONT) ||
19047 + if (((sig != SIGCONT) ||
19048 (process_session(current) != process_session(t)))
19049 && (current->euid ^ t->suid) && (current->euid ^ t->uid)
19050 && (current->uid ^ t->suid) && (current->uid ^ t->uid)
19051 && !capable(CAP_KILL))
19055 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
19056 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
19057 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
19058 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
19062 return security_task_kill(t, info, sig, 0);
19065 @@ -1043,7 +1060,7 @@ int kill_pid_info(int sig, struct siginf
19067 p = pid_task(pid, PIDTYPE_PID);
19070 + if (p && vx_check(vx_task_xid(p), VS_IDENT))
19071 error = group_send_sig_info(sig, info, p);
19073 if (unlikely(sig_needs_tasklist(sig)))
19074 @@ -1057,7 +1074,7 @@ kill_proc_info(int sig, struct siginfo *
19078 - error = kill_pid_info(sig, info, find_pid(pid));
19079 + error = kill_pid_info(sig, info, find_pid(vx_rmap_pid(pid)));
19083 @@ -1118,7 +1135,9 @@ static int kill_something_info(int sig,
19085 read_lock(&tasklist_lock);
19086 for_each_process(p) {
19087 - if (p->pid > 1 && p->tgid != current->tgid) {
19088 + if (vx_check(vx_task_xid(p), VS_ADMIN_P|VS_IDENT) &&
19089 + p->pid > 1 && p->tgid != current->tgid &&
19090 + !vx_current_initpid(p->pid)) {
19091 int err = group_send_sig_info(sig, info, p);
19094 @@ -1128,9 +1147,9 @@ static int kill_something_info(int sig,
19095 read_unlock(&tasklist_lock);
19096 ret = count ? retval : -ESRCH;
19097 } else if (pid < 0) {
19098 - ret = kill_pgrp_info(sig, info, find_pid(-pid));
19099 + ret = kill_pgrp_info(sig, info, find_pid(vx_rmap_pid(-pid)));
19101 - ret = kill_pid_info(sig, info, find_pid(pid));
19102 + ret = kill_pid_info(sig, info, find_pid(vx_rmap_pid(pid)));
19106 @@ -1814,6 +1833,11 @@ relock:
19107 if (current == child_reaper(current))
19110 + /* virtual init is protected against user signals */
19111 + if ((info->si_code == SI_USER) &&
19112 + vx_current_initpid(current->pid))
19115 if (sig_kernel_stop(signr)) {
19117 * The default action is to stop all threads in
19118 diff -Nurp linux-2.6.22.18/kernel/softirq.c linux-2.6.22.18-vs2.3.0.32/kernel/softirq.c
19119 --- linux-2.6.22.18/kernel/softirq.c 2007-07-22 00:00:25.000000000 +0200
19120 +++ linux-2.6.22.18-vs2.3.0.32/kernel/softirq.c 2008-02-11 12:35:36.000000000 +0100
19122 #include <linux/rcupdate.h>
19123 #include <linux/smp.h>
19124 #include <linux/tick.h>
19125 +#include <linux/vs_context.h>
19127 #include <asm/irq.h>
19129 diff -Nurp linux-2.6.22.18/kernel/sys.c linux-2.6.22.18-vs2.3.0.32/kernel/sys.c
19130 --- linux-2.6.22.18/kernel/sys.c 2008-01-15 16:00:35.000000000 +0100
19131 +++ linux-2.6.22.18-vs2.3.0.32/kernel/sys.c 2008-02-11 12:35:37.000000000 +0100
19133 #include <linux/compat.h>
19134 #include <linux/syscalls.h>
19135 #include <linux/kprobes.h>
19136 +#include <linux/vs_pid.h>
19138 #include <asm/uaccess.h>
19139 #include <asm/io.h>
19140 @@ -638,7 +639,10 @@ static int set_one_prio(struct task_stru
19143 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
19145 + if (vx_flags(VXF_IGNEG_NICE, 0))
19151 no_nice = security_task_setnice(p, niceval);
19152 @@ -686,6 +690,8 @@ asmlinkage long sys_setpriority(int whic
19154 pgrp = task_pgrp(current);
19155 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
19156 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
19158 error = set_one_prio(p, niceval, error);
19159 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
19161 @@ -694,7 +700,8 @@ asmlinkage long sys_setpriority(int whic
19163 who = current->uid;
19165 - if ((who != current->uid) && !(user = find_user(who)))
19166 + if ((who != current->uid) &&
19167 + !(user = find_user(vx_current_xid(), who)))
19168 goto out_unlock; /* No processes for this user */
19170 do_each_thread(g, p)
19171 @@ -746,6 +753,8 @@ asmlinkage long sys_getpriority(int whic
19173 pgrp = task_pgrp(current);
19174 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
19175 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
19177 niceval = 20 - task_nice(p);
19178 if (niceval > retval)
19180 @@ -756,7 +765,8 @@ asmlinkage long sys_getpriority(int whic
19182 who = current->uid;
19184 - if ((who != current->uid) && !(user = find_user(who)))
19185 + if ((who != current->uid) &&
19186 + !(user = find_user(vx_current_xid(), who)))
19187 goto out_unlock; /* No processes for this user */
19189 do_each_thread(g, p)
19190 @@ -869,6 +879,9 @@ void kernel_power_off(void)
19191 machine_power_off();
19193 EXPORT_SYMBOL_GPL(kernel_power_off);
19195 +long vs_reboot(unsigned int, void __user *);
19198 * Reboot system call: for obvious reasons only root may call it,
19199 * and even root needs to set up some magic numbers in the registers
19200 @@ -899,6 +912,9 @@ asmlinkage long sys_reboot(int magic1, i
19201 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
19202 cmd = LINUX_REBOOT_CMD_HALT;
19204 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
19205 + return vs_reboot(cmd, arg);
19209 case LINUX_REBOOT_CMD_RESTART:
19210 @@ -1078,7 +1094,7 @@ static int set_user(uid_t new_ruid, int
19212 struct user_struct *new_user;
19214 - new_user = alloc_uid(new_ruid);
19215 + new_user = alloc_uid(vx_current_xid(), new_ruid);
19219 @@ -1432,15 +1448,18 @@ asmlinkage long sys_setpgid(pid_t pid, p
19221 struct task_struct *p;
19222 struct task_struct *group_leader = current->group_leader;
19227 - pid = group_leader->pid;
19228 + pid = vx_map_pid(group_leader->pid);
19234 + rpgid = vx_rmap_pid(pgid);
19236 /* From this point forward we keep holding onto the tasklist lock
19237 * so that our parent does not change from under us. -DaveM
19239 @@ -1474,20 +1493,20 @@ asmlinkage long sys_setpgid(pid_t pid, p
19242 struct task_struct *g =
19243 - find_task_by_pid_type(PIDTYPE_PGID, pgid);
19244 + find_task_by_pid_type(PIDTYPE_PGID, rpgid);
19246 if (!g || task_session(g) != task_session(group_leader))
19250 - err = security_task_setpgid(p, pgid);
19251 + err = security_task_setpgid(p, rpgid);
19255 - if (process_group(p) != pgid) {
19256 + if (process_group(p) != rpgid) {
19257 detach_pid(p, PIDTYPE_PGID);
19258 - p->signal->pgrp = pgid;
19259 - attach_pid(p, PIDTYPE_PGID, find_pid(pgid));
19260 + p->signal->pgrp = rpgid;
19261 + attach_pid(p, PIDTYPE_PGID, find_pid(rpgid));
19265 @@ -1500,7 +1519,7 @@ out:
19266 asmlinkage long sys_getpgid(pid_t pid)
19269 - return process_group(current);
19270 + return vx_rmap_pid(process_group(current));
19273 struct task_struct *p;
19274 @@ -1512,7 +1531,7 @@ asmlinkage long sys_getpgid(pid_t pid)
19276 retval = security_task_getpgid(p);
19278 - retval = process_group(p);
19279 + retval = vx_rmap_pid(process_group(p));
19281 read_unlock(&tasklist_lock);
19283 @@ -1863,7 +1882,7 @@ asmlinkage long sys_sethostname(char __u
19285 char tmp[__NEW_UTS_LEN];
19287 - if (!capable(CAP_SYS_ADMIN))
19288 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
19290 if (len < 0 || len > __NEW_UTS_LEN)
19292 @@ -1908,7 +1927,7 @@ asmlinkage long sys_setdomainname(char _
19294 char tmp[__NEW_UTS_LEN];
19296 - if (!capable(CAP_SYS_ADMIN))
19297 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
19299 if (len < 0 || len > __NEW_UTS_LEN)
19301 @@ -1975,7 +1994,7 @@ asmlinkage long sys_setrlimit(unsigned i
19303 old_rlim = current->signal->rlim + resource;
19304 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
19305 - !capable(CAP_SYS_RESOURCE))
19306 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
19308 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
19310 diff -Nurp linux-2.6.22.18/kernel/sysctl.c linux-2.6.22.18-vs2.3.0.32/kernel/sysctl.c
19311 --- linux-2.6.22.18/kernel/sysctl.c 2007-07-22 00:00:25.000000000 +0200
19312 +++ linux-2.6.22.18-vs2.3.0.32/kernel/sysctl.c 2008-02-11 12:35:38.000000000 +0100
19313 @@ -89,6 +89,7 @@ static int ngroups_max = NGROUPS_MAX;
19315 extern char modprobe_path[];
19317 +extern char vshelper_path[];
19318 #ifdef CONFIG_CHR_DEV_SG
19319 extern int sg_big_buff;
19321 @@ -343,6 +344,15 @@ static ctl_table kern_table[] = {
19322 .strategy = &sysctl_string,
19326 + .ctl_name = KERN_VSHELPER,
19327 + .procname = "vshelper",
19328 + .data = &vshelper_path,
19331 + .proc_handler = &proc_dostring,
19332 + .strategy = &sysctl_string,
19334 #ifdef CONFIG_CHR_DEV_SG
19336 .ctl_name = KERN_SG_BIG_BUFF,
19337 diff -Nurp linux-2.6.22.18/kernel/time.c linux-2.6.22.18-vs2.3.0.32/kernel/time.c
19338 --- linux-2.6.22.18/kernel/time.c 2007-07-22 00:00:25.000000000 +0200
19339 +++ linux-2.6.22.18-vs2.3.0.32/kernel/time.c 2008-02-11 12:35:38.000000000 +0100
19340 @@ -60,7 +60,7 @@ asmlinkage long sys_time(time_t __user *
19344 - do_gettimeofday(&tv);
19345 + vx_gettimeofday(&tv);
19349 @@ -91,7 +91,7 @@ asmlinkage long sys_stime(time_t __user
19353 - do_settimeofday(&tv);
19354 + vx_settimeofday(&tv);
19358 @@ -101,7 +101,7 @@ asmlinkage long sys_gettimeofday(struct
19360 if (likely(tv != NULL)) {
19361 struct timeval ktv;
19362 - do_gettimeofday(&ktv);
19363 + vx_gettimeofday(&ktv);
19364 if (copy_to_user(tv, &ktv, sizeof(ktv)))
19367 @@ -175,7 +175,7 @@ int do_sys_settimeofday(struct timespec
19368 /* SMP safe, again the code in arch/foo/time.c should
19369 * globally block out interrupts when it runs.
19371 - return do_settimeofday(tv);
19372 + return vx_settimeofday(tv);
19376 @@ -388,7 +388,7 @@ void getnstimeofday(struct timespec *tv)
19380 - do_gettimeofday(&x);
19381 + vx_gettimeofday(&x);
19382 tv->tv_sec = x.tv_sec;
19383 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
19385 diff -Nurp linux-2.6.22.18/kernel/timer.c linux-2.6.22.18-vs2.3.0.32/kernel/timer.c
19386 --- linux-2.6.22.18/kernel/timer.c 2007-07-22 00:00:25.000000000 +0200
19387 +++ linux-2.6.22.18-vs2.3.0.32/kernel/timer.c 2008-02-11 12:35:38.000000000 +0100
19389 #include <linux/delay.h>
19390 #include <linux/tick.h>
19391 #include <linux/kallsyms.h>
19392 +#include <linux/vs_base.h>
19393 +#include <linux/vs_cvirt.h>
19394 +#include <linux/vs_pid.h>
19395 +#include <linux/vserver/sched.h>
19397 #include <asm/uaccess.h>
19398 #include <asm/unistd.h>
19399 @@ -921,12 +925,6 @@ asmlinkage unsigned long sys_alarm(unsig
19406 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
19407 - * should be moved into arch/i386 instead?
19411 * sys_getpid - return the thread group id of the current process
19412 @@ -939,7 +937,7 @@ asmlinkage unsigned long sys_alarm(unsig
19414 asmlinkage long sys_getpid(void)
19416 - return current->tgid;
19417 + return vx_map_tgid(current->tgid);
19421 @@ -955,10 +953,23 @@ asmlinkage long sys_getppid(void)
19423 pid = rcu_dereference(current->real_parent)->tgid;
19425 + return vx_map_pid(pid);
19432 + * The Alpha uses getxpid, getxuid, and getxgid instead.
19435 +asmlinkage long do_getxpid(long *ppid)
19437 + *ppid = sys_getppid();
19438 + return sys_getpid();
19441 +#else /* _alpha_ */
19443 asmlinkage long sys_getuid(void)
19445 /* Only we change this so SMP safe */
19446 @@ -1118,6 +1129,8 @@ int do_sysinfo(struct sysinfo *info)
19447 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
19450 + if (vx_flags(VXF_VIRT_UPTIME, 0))
19451 + vx_vsi_uptime(&tp, NULL);
19452 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
19454 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
19455 diff -Nurp linux-2.6.22.18/kernel/user.c linux-2.6.22.18-vs2.3.0.32/kernel/user.c
19456 --- linux-2.6.22.18/kernel/user.c 2007-05-04 15:58:24.000000000 +0200
19457 +++ linux-2.6.22.18-vs2.3.0.32/kernel/user.c 2008-02-11 12:35:38.000000000 +0100
19459 #define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8)
19460 #define UIDHASH_SZ (1 << UIDHASH_BITS)
19461 #define UIDHASH_MASK (UIDHASH_SZ - 1)
19462 -#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
19463 -#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid)))
19464 +#define __uidhashfn(xid,uid) ((((uid) >> UIDHASH_BITS) + ((uid)^(xid))) & UIDHASH_MASK)
19465 +#define uidhashentry(xid,uid) (uidhash_table + __uidhashfn((xid),(uid)))
19467 static struct kmem_cache *uid_cachep;
19468 static struct list_head uidhash_table[UIDHASH_SZ];
19469 @@ -66,7 +66,7 @@ static inline void uid_hash_remove(struc
19470 list_del(&up->uidhash_list);
19473 -static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
19474 +static inline struct user_struct *uid_hash_find(xid_t xid, uid_t uid, struct list_head *hashent)
19476 struct list_head *up;
19478 @@ -75,7 +75,7 @@ static inline struct user_struct *uid_ha
19480 user = list_entry(up, struct user_struct, uidhash_list);
19482 - if(user->uid == uid) {
19483 + if(user->uid == uid && user->xid == xid) {
19484 atomic_inc(&user->__count);
19487 @@ -90,13 +90,13 @@ static inline struct user_struct *uid_ha
19489 * If the user_struct could not be found, return NULL.
19491 -struct user_struct *find_user(uid_t uid)
19492 +struct user_struct *find_user(xid_t xid, uid_t uid)
19494 struct user_struct *ret;
19495 unsigned long flags;
19497 spin_lock_irqsave(&uidhash_lock, flags);
19498 - ret = uid_hash_find(uid, uidhashentry(uid));
19499 + ret = uid_hash_find(xid, uid, uidhashentry(xid, uid));
19500 spin_unlock_irqrestore(&uidhash_lock, flags);
19503 @@ -120,13 +120,13 @@ void free_uid(struct user_struct *up)
19507 -struct user_struct * alloc_uid(uid_t uid)
19508 +struct user_struct * alloc_uid(xid_t xid, uid_t uid)
19510 - struct list_head *hashent = uidhashentry(uid);
19511 + struct list_head *hashent = uidhashentry(xid, uid);
19512 struct user_struct *up;
19514 spin_lock_irq(&uidhash_lock);
19515 - up = uid_hash_find(uid, hashent);
19516 + up = uid_hash_find(xid, uid, hashent);
19517 spin_unlock_irq(&uidhash_lock);
19520 @@ -136,6 +136,7 @@ struct user_struct * alloc_uid(uid_t uid
19525 atomic_set(&new->__count, 1);
19526 atomic_set(&new->processes, 0);
19527 atomic_set(&new->files, 0);
19528 @@ -158,7 +159,7 @@ struct user_struct * alloc_uid(uid_t uid
19529 * on adding the same user already..
19531 spin_lock_irq(&uidhash_lock);
19532 - up = uid_hash_find(uid, hashent);
19533 + up = uid_hash_find(xid, uid, hashent);
19535 key_put(new->uid_keyring);
19536 key_put(new->session_keyring);
19537 @@ -215,7 +216,7 @@ static int __init uid_cache_init(void)
19539 /* Insert the root user immediately (init already runs as root) */
19540 spin_lock_irq(&uidhash_lock);
19541 - uid_hash_insert(&root_user, uidhashentry(0));
19542 + uid_hash_insert(&root_user, uidhashentry(0,0));
19543 spin_unlock_irq(&uidhash_lock);
19546 diff -Nurp linux-2.6.22.18/kernel/utsname.c linux-2.6.22.18-vs2.3.0.32/kernel/utsname.c
19547 --- linux-2.6.22.18/kernel/utsname.c 2007-07-22 00:00:25.000000000 +0200
19548 +++ linux-2.6.22.18-vs2.3.0.32/kernel/utsname.c 2008-02-11 12:35:38.000000000 +0100
19550 #include <linux/uts.h>
19551 #include <linux/utsname.h>
19552 #include <linux/version.h>
19553 +#include <linux/vserver/global.h>
19556 * Clone a new ns copying an original utsname, setting refcount to 1
19557 @@ -27,6 +28,7 @@ static struct uts_namespace *clone_uts_n
19559 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
19560 kref_init(&ns->kref);
19561 + atomic_inc(&vs_global_uts_ns);
19565 @@ -58,5 +60,6 @@ void free_uts_ns(struct kref *kref)
19566 struct uts_namespace *ns;
19568 ns = container_of(kref, struct uts_namespace, kref);
19569 + atomic_dec(&vs_global_uts_ns);
19572 diff -Nurp linux-2.6.22.18/kernel/vserver/cacct.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cacct.c
19573 --- linux-2.6.22.18/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
19574 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cacct.c 2008-02-11 12:35:38.000000000 +0100
19577 + * linux/kernel/vserver/cacct.c
19579 + * Virtual Server: Context Accounting
19581 + * Copyright (C) 2006-2007 Herbert Pötzl
19583 + * V0.01 added accounting stats
19587 +#include <linux/types.h>
19588 +#include <linux/vs_context.h>
19589 +#include <linux/vserver/cacct_cmd.h>
19590 +#include <linux/vserver/cacct_int.h>
19592 +#include <asm/errno.h>
19593 +#include <asm/uaccess.h>
19596 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
19598 + struct vcmd_sock_stat_v0 vc_data;
19601 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19604 + field = vc_data.field;
19605 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
19608 + for (j = 0; j < 3; j++) {
19609 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
19610 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
19613 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19618 diff -Nurp linux-2.6.22.18/kernel/vserver/cacct_init.h linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cacct_init.h
19619 --- linux-2.6.22.18/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
19620 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cacct_init.h 2008-02-11 12:35:38.000000000 +0100
19624 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
19629 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
19630 + for (j = 0; j < 3; j++) {
19631 + atomic_set(&cacct->sock[i][j].count, 0);
19632 + atomic_set(&cacct->sock[i][j].total, 0);
19635 + for (i = 0; i < 8; i++)
19636 + atomic_set(&cacct->slab[i], 0);
19637 + for (i = 0; i < 5; i++)
19638 + for (j = 0; j < 4; j++)
19639 + atomic_set(&cacct->page[i][j], 0);
19642 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
19647 diff -Nurp linux-2.6.22.18/kernel/vserver/cacct_proc.h linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cacct_proc.h
19648 --- linux-2.6.22.18/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
19649 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cacct_proc.h 2008-02-11 12:35:38.000000000 +0100
19651 +#ifndef _VX_CACCT_PROC_H
19652 +#define _VX_CACCT_PROC_H
19654 +#include <linux/vserver/cacct_int.h>
19657 +#define VX_SOCKA_TOP \
19658 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
19660 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
19662 + int i, j, length = 0;
19663 + static char *type[VXA_SOCK_SIZE] = {
19664 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
19667 + length += sprintf(buffer + length, VX_SOCKA_TOP);
19668 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
19669 + length += sprintf(buffer + length, "%s:", type[i]);
19670 + for (j = 0; j < 3; j++) {
19671 + length += sprintf(buffer + length,
19672 + "\t%10lu/%-10lu",
19673 + vx_sock_count(cacct, i, j),
19674 + vx_sock_total(cacct, i, j));
19676 + buffer[length++] = '\n';
19679 + length += sprintf(buffer + length, "\n");
19680 + length += sprintf(buffer + length,
19681 + "slab:\t %8u %8u %8u %8u\n",
19682 + atomic_read(&cacct->slab[1]),
19683 + atomic_read(&cacct->slab[4]),
19684 + atomic_read(&cacct->slab[0]),
19685 + atomic_read(&cacct->slab[2]));
19687 + length += sprintf(buffer + length, "\n");
19688 + for (i = 0; i < 5; i++) {
19689 + length += sprintf(buffer + length,
19690 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
19691 + atomic_read(&cacct->page[i][0]),
19692 + atomic_read(&cacct->page[i][1]),
19693 + atomic_read(&cacct->page[i][2]),
19694 + atomic_read(&cacct->page[i][3]),
19695 + atomic_read(&cacct->page[i][4]),
19696 + atomic_read(&cacct->page[i][5]),
19697 + atomic_read(&cacct->page[i][6]),
19698 + atomic_read(&cacct->page[i][7]));
19703 +#endif /* _VX_CACCT_PROC_H */
19704 diff -Nurp linux-2.6.22.18/kernel/vserver/context.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/context.c
19705 --- linux-2.6.22.18/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
19706 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/context.c 2008-02-11 12:35:38.000000000 +0100
19709 + * linux/kernel/vserver/context.c
19711 + * Virtual Server: Context Support
19713 + * Copyright (C) 2003-2007 Herbert Pötzl
19715 + * V0.01 context helper
19716 + * V0.02 vx_ctx_kill syscall command
19717 + * V0.03 replaced context_info calls
19718 + * V0.04 redesign of struct (de)alloc
19719 + * V0.05 rlimit basic implementation
19720 + * V0.06 task_xid and info commands
19721 + * V0.07 context flags and caps
19722 + * V0.08 switch to RCU based hash
19723 + * V0.09 revert to non RCU for now
19724 + * V0.10 and back to working RCU hash
19725 + * V0.11 and back to locking again
19726 + * V0.12 referenced context store
19727 + * V0.13 separate per cpu data
19728 + * V0.14 changed vcmds to vxi arg
19729 + * V0.15 added context stat
19730 + * V0.16 have __create claim() the vxi
19731 + * V0.17 removed older and legacy stuff
19735 +#include <linux/slab.h>
19736 +#include <linux/types.h>
19737 +#include <linux/pid_namespace.h>
19739 +#include <linux/vserver/context.h>
19740 +#include <linux/vserver/network.h>
19741 +#include <linux/vserver/debug.h>
19742 +#include <linux/vserver/limit.h>
19743 +#include <linux/vserver/limit_int.h>
19744 +#include <linux/vserver/space.h>
19746 +#include <linux/vs_context.h>
19747 +#include <linux/vs_limit.h>
19748 +#include <linux/vserver/context_cmd.h>
19750 +#include "cvirt_init.h"
19751 +#include "cacct_init.h"
19752 +#include "limit_init.h"
19753 +#include "sched_init.h"
19756 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
19757 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
19760 +/* now inactive context structures */
19762 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
19764 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
19767 +/* __alloc_vx_info()
19769 + * allocate an initialized vx_info struct
19770 + * doesn't make it visible (hash) */
19772 +static struct vx_info *__alloc_vx_info(xid_t xid)
19774 + struct vx_info *new = NULL;
19777 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
19779 + /* would this benefit from a slab cache? */
19780 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
19784 + memset(new, 0, sizeof(struct vx_info));
19786 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
19787 + if (!new->ptr_pc)
19790 + new->vx_id = xid;
19791 + INIT_HLIST_NODE(&new->vx_hlist);
19792 + atomic_set(&new->vx_usecnt, 0);
19793 + atomic_set(&new->vx_tasks, 0);
19794 + new->vx_parent = NULL;
19795 + new->vx_state = 0;
19796 + init_waitqueue_head(&new->vx_wait);
19798 + /* prepare reaper */
19799 + get_task_struct(init_pid_ns.child_reaper);
19800 + new->vx_reaper = init_pid_ns.child_reaper;
19801 + new->vx_badness_bias = 0;
19803 + /* rest of init goes here */
19804 + vx_info_init_limit(&new->limit);
19805 + vx_info_init_sched(&new->sched);
19806 + vx_info_init_cvirt(&new->cvirt);
19807 + vx_info_init_cacct(&new->cacct);
19809 + /* per cpu data structures */
19810 + for_each_possible_cpu(cpu) {
19811 + vx_info_init_sched_pc(
19812 + &vx_per_cpu(new, sched_pc, cpu), cpu);
19813 + vx_info_init_cvirt_pc(
19814 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
19817 + new->vx_flags = VXF_INIT_SET;
19818 + new->vx_bcaps = CAP_INIT_EFF_SET;
19819 + new->vx_ccaps = 0;
19820 + new->vx_cap_bset = cap_bset;
19822 + new->reboot_cmd = 0;
19823 + new->exit_code = 0;
19825 + vxdprintk(VXD_CBIT(xid, 0),
19826 + "alloc_vx_info(%d) = %p", xid, new);
19827 + vxh_alloc_vx_info(new);
19828 + atomic_inc(&vx_global_ctotal);
19837 +/* __dealloc_vx_info()
19839 + * final disposal of vx_info */
19841 +static void __dealloc_vx_info(struct vx_info *vxi)
19845 + vxdprintk(VXD_CBIT(xid, 0),
19846 + "dealloc_vx_info(%p)", vxi);
19847 + vxh_dealloc_vx_info(vxi);
19851 + vx_info_exit_limit(&vxi->limit);
19852 + vx_info_exit_sched(&vxi->sched);
19853 + vx_info_exit_cvirt(&vxi->cvirt);
19854 + vx_info_exit_cacct(&vxi->cacct);
19856 + for_each_possible_cpu(cpu) {
19857 + vx_info_exit_sched_pc(
19858 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
19859 + vx_info_exit_cvirt_pc(
19860 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
19863 + vxi->vx_state |= VXS_RELEASED;
19866 + free_percpu(vxi->ptr_pc);
19869 + atomic_dec(&vx_global_ctotal);
19872 +static void __shutdown_vx_info(struct vx_info *vxi)
19874 + struct nsproxy *nsproxy;
19875 + struct fs_struct *fs;
19879 + vxi->vx_state |= VXS_SHUTDOWN;
19880 + vs_state_change(vxi, VSC_SHUTDOWN);
19882 + nsproxy = xchg(&vxi->vx_nsproxy, NULL);
19883 + fs = xchg(&vxi->vx_fs, NULL);
19886 + put_nsproxy(nsproxy);
19888 + put_fs_struct(fs);
19891 +/* exported stuff */
19893 +void free_vx_info(struct vx_info *vxi)
19895 + unsigned long flags;
19897 + /* check for reference counts first */
19898 + BUG_ON(atomic_read(&vxi->vx_usecnt));
19899 + BUG_ON(atomic_read(&vxi->vx_tasks));
19901 + /* context must not be hashed */
19902 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
19904 + /* context shutdown is mandatory */
19905 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
19907 + BUG_ON(vxi->vx_nsproxy);
19908 + BUG_ON(vxi->vx_fs);
19910 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
19911 + hlist_del(&vxi->vx_hlist);
19912 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
19914 + __dealloc_vx_info(vxi);
19918 +/* hash table for vx_info hash */
19920 +#define VX_HASH_SIZE 13
19922 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
19923 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
19925 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
19928 +static inline unsigned int __hashval(xid_t xid)
19930 + return (xid % VX_HASH_SIZE);
19935 +/* __hash_vx_info()
19937 + * add the vxi to the global hash table
19938 + * requires the hash_lock to be held */
19940 +static inline void __hash_vx_info(struct vx_info *vxi)
19942 + struct hlist_head *head;
19944 + vxd_assert_lock(&vx_info_hash_lock);
19945 + vxdprintk(VXD_CBIT(xid, 4),
19946 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
19947 + vxh_hash_vx_info(vxi);
19949 + /* context must not be hashed */
19950 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
19952 + vxi->vx_state |= VXS_HASHED;
19953 + head = &vx_info_hash[__hashval(vxi->vx_id)];
19954 + hlist_add_head(&vxi->vx_hlist, head);
19955 + atomic_inc(&vx_global_cactive);
19958 +/* __unhash_vx_info()
19960 + * remove the vxi from the global hash table
19961 + * requires the hash_lock to be held */
19963 +static inline void __unhash_vx_info(struct vx_info *vxi)
19965 + unsigned long flags;
19967 + vxd_assert_lock(&vx_info_hash_lock);
19968 + vxdprintk(VXD_CBIT(xid, 4),
19969 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
19970 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
19971 + vxh_unhash_vx_info(vxi);
19973 + /* context must be hashed */
19974 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
19975 + /* but without tasks */
19976 + BUG_ON(atomic_read(&vxi->vx_tasks));
19978 + vxi->vx_state &= ~VXS_HASHED;
19979 + hlist_del_init(&vxi->vx_hlist);
19980 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
19981 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
19982 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
19983 + atomic_dec(&vx_global_cactive);
19987 +/* __lookup_vx_info()
19989 + * requires the hash_lock to be held
19990 + * doesn't increment the vx_refcnt */
19992 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
19994 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
19995 + struct hlist_node *pos;
19996 + struct vx_info *vxi;
19998 + vxd_assert_lock(&vx_info_hash_lock);
19999 + hlist_for_each(pos, head) {
20000 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
20002 + if (vxi->vx_id == xid)
20007 + vxdprintk(VXD_CBIT(xid, 0),
20008 + "__lookup_vx_info(#%u): %p[#%u]",
20009 + xid, vxi, vxi ? vxi->vx_id : 0);
20010 + vxh_lookup_vx_info(vxi, xid);
20015 +/* __create_vx_info()
20017 + * create the requested context
20018 + * get(), claim() and hash it */
20020 +static struct vx_info *__create_vx_info(int id)
20022 + struct vx_info *new, *vxi = NULL;
20024 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
20026 + if (!(new = __alloc_vx_info(id)))
20027 + return ERR_PTR(-ENOMEM);
20029 + /* required to make dynamic xids unique */
20030 + spin_lock(&vx_info_hash_lock);
20032 + /* static context requested */
20033 + if ((vxi = __lookup_vx_info(id))) {
20034 + vxdprintk(VXD_CBIT(xid, 0),
20035 + "create_vx_info(%d) = %p (already there)", id, vxi);
20036 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
20037 + vxi = ERR_PTR(-EBUSY);
20039 + vxi = ERR_PTR(-EEXIST);
20042 + /* new context */
20043 + vxdprintk(VXD_CBIT(xid, 0),
20044 + "create_vx_info(%d) = %p (new)", id, new);
20045 + claim_vx_info(new, NULL);
20046 + __hash_vx_info(get_vx_info(new));
20047 + vxi = new, new = NULL;
20050 + spin_unlock(&vx_info_hash_lock);
20051 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
20053 + __dealloc_vx_info(new);
20058 +/* exported stuff */
20061 +void unhash_vx_info(struct vx_info *vxi)
20063 + __shutdown_vx_info(vxi);
20064 + spin_lock(&vx_info_hash_lock);
20065 + __unhash_vx_info(vxi);
20066 + spin_unlock(&vx_info_hash_lock);
20067 + __wakeup_vx_info(vxi);
20071 +/* lookup_vx_info()
20073 + * search for a vx_info and get() it
20074 + * negative id means current */
20076 +struct vx_info *lookup_vx_info(int id)
20078 + struct vx_info *vxi = NULL;
20081 + vxi = get_vx_info(current->vx_info);
20082 + } else if (id > 1) {
20083 + spin_lock(&vx_info_hash_lock);
20084 + vxi = get_vx_info(__lookup_vx_info(id));
20085 + spin_unlock(&vx_info_hash_lock);
20090 +/* xid_is_hashed()
20092 + * verify that xid is still hashed */
20094 +int xid_is_hashed(xid_t xid)
20098 + spin_lock(&vx_info_hash_lock);
20099 + hashed = (__lookup_vx_info(xid) != NULL);
20100 + spin_unlock(&vx_info_hash_lock);
20104 +#ifdef CONFIG_PROC_FS
20108 + * get a subset of hashed xids for proc
20109 + * assumes size is at least one */
20111 +int get_xid_list(int index, unsigned int *xids, int size)
20113 + int hindex, nr_xids = 0;
20115 + /* only show current and children */
20116 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
20119 + xids[nr_xids] = vx_current_xid();
20123 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
20124 + struct hlist_head *head = &vx_info_hash[hindex];
20125 + struct hlist_node *pos;
20127 + spin_lock(&vx_info_hash_lock);
20128 + hlist_for_each(pos, head) {
20129 + struct vx_info *vxi;
20134 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
20135 + xids[nr_xids] = vxi->vx_id;
20136 + if (++nr_xids >= size) {
20137 + spin_unlock(&vx_info_hash_lock);
20141 + /* keep the lock time short */
20142 + spin_unlock(&vx_info_hash_lock);
20149 +#ifdef CONFIG_VSERVER_DEBUG
20151 +void dump_vx_info_inactive(int level)
20153 + struct hlist_node *entry, *next;
20155 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
20156 + struct vx_info *vxi =
20157 + list_entry(entry, struct vx_info, vx_hlist);
20159 + dump_vx_info(vxi, level);
20165 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
20167 + struct user_struct *new_user, *old_user;
20172 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
20175 + new_user = alloc_uid(vxi->vx_id, p->uid);
20179 + old_user = p->user;
20180 + if (new_user != old_user) {
20181 + atomic_inc(&new_user->processes);
20182 + atomic_dec(&old_user->processes);
20183 + p->user = new_user;
20185 + free_uid(old_user);
20189 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
20191 + p->cap_effective &= vxi->vx_cap_bset;
20192 + p->cap_inheritable &= vxi->vx_cap_bset;
20193 + p->cap_permitted &= vxi->vx_cap_bset;
20197 +#include <linux/file.h>
20199 +static int vx_openfd_task(struct task_struct *tsk)
20201 + struct files_struct *files = tsk->files;
20202 + struct fdtable *fdt;
20203 + const unsigned long *bptr;
20204 + int count, total;
20206 + /* no rcu_read_lock() because of spin_lock() */
20207 + spin_lock(&files->file_lock);
20208 + fdt = files_fdtable(files);
20209 + bptr = fdt->open_fds->fds_bits;
20210 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
20211 + for (total = 0; count > 0; count--) {
20213 + total += hweight_long(*bptr);
20216 + spin_unlock(&files->file_lock);
20221 +/* for *space compatibility */
20223 +asmlinkage long sys_unshare(unsigned long);
20226 + * migrate task to new context
20227 + * gets vxi, puts old_vxi on change
20228 + * optionally unshares namespaces (hack)
20231 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
20233 + struct vx_info *old_vxi;
20239 + vxdprintk(VXD_CBIT(xid, 5),
20240 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
20241 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
20243 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
20244 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
20247 + if (vx_info_state(vxi, VXS_SHUTDOWN))
20250 + old_vxi = task_get_vx_info(p);
20251 + if (old_vxi == vxi)
20254 + if (!(ret = vx_migrate_user(p, vxi))) {
20258 + openfd = vx_openfd_task(p);
20261 + atomic_dec(&old_vxi->cvirt.nr_threads);
20262 + atomic_dec(&old_vxi->cvirt.nr_running);
20263 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
20264 + /* FIXME: what about the struct files here? */
20265 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
20266 + /* account for the executable */
20267 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
20269 + atomic_inc(&vxi->cvirt.nr_threads);
20270 + atomic_inc(&vxi->cvirt.nr_running);
20271 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
20272 + /* FIXME: what about the struct files here? */
20273 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
20274 + /* account for the executable */
20275 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
20278 + release_vx_info(old_vxi, p);
20279 + clr_vx_info(&p->vx_info);
20281 + claim_vx_info(vxi, p);
20282 + set_vx_info(&p->vx_info, vxi);
20283 + p->xid = vxi->vx_id;
20285 + vxdprintk(VXD_CBIT(xid, 5),
20286 + "moved task %p into vxi:%p[#%d]",
20287 + p, vxi, vxi->vx_id);
20289 + vx_mask_cap_bset(vxi, p);
20292 + /* hack for *spaces to provide compatibility */
20294 + struct nsproxy *old_nsp, *new_nsp;
20296 + ret = unshare_nsproxy_namespaces(
20297 + CLONE_NEWUTS | CLONE_NEWIPC,
20302 + old_nsp = xchg(&p->nsproxy, new_nsp);
20303 + vx_set_space(vxi, CLONE_NEWUTS | CLONE_NEWIPC);
20304 + put_nsproxy(old_nsp);
20308 + put_vx_info(old_vxi);
20312 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
20314 + struct task_struct *old_reaper;
20319 + vxdprintk(VXD_CBIT(xid, 6),
20320 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
20321 + vxi, vxi->vx_id, p, p->xid, p->pid);
20323 + old_reaper = vxi->vx_reaper;
20324 + if (old_reaper == p)
20327 + /* set new child reaper */
20328 + get_task_struct(p);
20329 + vxi->vx_reaper = p;
20330 + put_task_struct(old_reaper);
20334 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
20339 + vxdprintk(VXD_CBIT(xid, 6),
20340 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
20341 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
20343 + vxi->vx_flags &= ~VXF_STATE_INIT;
20344 + vxi->vx_initpid = p->tgid;
20348 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
20350 + vxdprintk(VXD_CBIT(xid, 6),
20351 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
20352 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
20354 + vxi->exit_code = code;
20355 + vxi->vx_initpid = 0;
20359 +void vx_set_persistent(struct vx_info *vxi)
20361 + vxdprintk(VXD_CBIT(xid, 6),
20362 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
20364 + get_vx_info(vxi);
20365 + claim_vx_info(vxi, NULL);
20368 +void vx_clear_persistent(struct vx_info *vxi)
20370 + vxdprintk(VXD_CBIT(xid, 6),
20371 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
20373 + release_vx_info(vxi, NULL);
20374 + put_vx_info(vxi);
20377 +void vx_update_persistent(struct vx_info *vxi)
20379 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
20380 + vx_set_persistent(vxi);
20382 + vx_clear_persistent(vxi);
20386 +/* task must be current or locked */
20388 +void exit_vx_info(struct task_struct *p, int code)
20390 + struct vx_info *vxi = p->vx_info;
20393 + atomic_dec(&vxi->cvirt.nr_threads);
20396 + vxi->exit_code = code;
20397 + release_vx_info(vxi, p);
20401 +void exit_vx_info_early(struct task_struct *p, int code)
20403 + struct vx_info *vxi = p->vx_info;
20406 + if (vxi->vx_initpid == p->tgid)
20407 + vx_exit_init(vxi, p, code);
20408 + if (vxi->vx_reaper == p)
20409 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
20414 +/* vserver syscall commands below here */
20416 +/* taks xid and vx_info functions */
20418 +#include <asm/uaccess.h>
20421 +int vc_task_xid(uint32_t id)
20426 + struct task_struct *tsk;
20428 + read_lock(&tasklist_lock);
20429 + tsk = find_task_by_real_pid(id);
20430 + xid = (tsk) ? tsk->xid : -ESRCH;
20431 + read_unlock(&tasklist_lock);
20433 + xid = vx_current_xid();
20438 +int vc_vx_info(struct vx_info *vxi, void __user *data)
20440 + struct vcmd_vx_info_v0 vc_data;
20442 + vc_data.xid = vxi->vx_id;
20443 + vc_data.initpid = vxi->vx_initpid;
20445 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20451 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
20453 + struct vcmd_ctx_stat_v0 vc_data;
20455 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
20456 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
20458 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20464 +/* context functions */
20466 +int vc_ctx_create(uint32_t xid, void __user *data)
20468 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
20469 + struct vx_info *new_vxi;
20472 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20475 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
20478 + new_vxi = __create_vx_info(xid);
20479 + if (IS_ERR(new_vxi))
20480 + return PTR_ERR(new_vxi);
20482 + /* initial flags */
20483 + new_vxi->vx_flags = vc_data.flagword;
20486 + if (vs_state_change(new_vxi, VSC_STARTUP))
20489 + ret = vx_migrate_task(current, new_vxi, (!data));
20493 + /* return context id on success */
20494 + ret = new_vxi->vx_id;
20496 + /* get a reference for persistent contexts */
20497 + if ((vc_data.flagword & VXF_PERSISTENT))
20498 + vx_set_persistent(new_vxi);
20500 + release_vx_info(new_vxi, NULL);
20501 + put_vx_info(new_vxi);
20506 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
20508 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
20511 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20514 + ret = vx_migrate_task(current, vxi, 0);
20517 + if (vc_data.flagword & VXM_SET_INIT)
20518 + ret = vx_set_init(vxi, current);
20521 + if (vc_data.flagword & VXM_SET_REAPER)
20522 + ret = vx_set_reaper(vxi, current);
20527 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
20529 + struct vcmd_ctx_flags_v0 vc_data;
20531 + vc_data.flagword = vxi->vx_flags;
20533 + /* special STATE flag handling */
20534 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
20536 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20541 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
20543 + struct vcmd_ctx_flags_v0 vc_data;
20544 + uint64_t mask, trigger;
20546 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20549 + /* special STATE flag handling */
20550 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
20551 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
20553 + if (vxi == current->vx_info) {
20554 + if (trigger & VXF_STATE_SETUP)
20555 + vx_mask_cap_bset(vxi, current);
20556 + if (trigger & VXF_STATE_INIT) {
20559 + ret = vx_set_init(vxi, current);
20562 + ret = vx_set_reaper(vxi, current);
20568 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
20569 + vc_data.flagword, mask);
20570 + if (trigger & VXF_PERSISTENT)
20571 + vx_update_persistent(vxi);
20576 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
20579 + *bcaps = vxi->vx_bcaps;
20581 + *ccaps = vxi->vx_ccaps;
20586 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
20588 + struct vcmd_ctx_caps_v1 vc_data;
20591 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
20594 + vc_data.cmask = ~0ULL;
20596 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20601 +static int do_set_caps(struct vx_info *vxi,
20602 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
20604 + vxi->vx_bcaps = vs_mask_flags(vxi->vx_bcaps, bcaps, bmask);
20605 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
20610 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
20612 + struct vcmd_ctx_caps_v1 vc_data;
20614 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20617 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
20620 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
20622 + struct vcmd_bcaps vc_data;
20625 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
20628 + vc_data.bmask = ~0ULL;
20630 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20635 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
20637 + struct vcmd_bcaps vc_data;
20639 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20642 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
20646 +int vc_get_badness(struct vx_info *vxi, void __user *data)
20648 + struct vcmd_badness_v0 vc_data;
20650 + vc_data.bias = vxi->vx_badness_bias;
20652 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20657 +int vc_set_badness(struct vx_info *vxi, void __user *data)
20659 + struct vcmd_badness_v0 vc_data;
20661 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20664 + vxi->vx_badness_bias = vc_data.bias;
20668 +#include <linux/module.h>
20670 +EXPORT_SYMBOL_GPL(free_vx_info);
20672 diff -Nurp linux-2.6.22.18/kernel/vserver/cvirt.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cvirt.c
20673 --- linux-2.6.22.18/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
20674 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cvirt.c 2008-02-11 12:35:38.000000000 +0100
20677 + * linux/kernel/vserver/cvirt.c
20679 + * Virtual Server: Context Virtualization
20681 + * Copyright (C) 2004-2007 Herbert Pötzl
20683 + * V0.01 broken out from limit.c
20684 + * V0.02 added utsname stuff
20685 + * V0.03 changed vcmds to vxi arg
20689 +#include <linux/types.h>
20690 +#include <linux/vs_cvirt.h>
20691 +#include <linux/vserver/switch.h>
20692 +#include <linux/vserver/cvirt_cmd.h>
20694 +#include <asm/uaccess.h>
20697 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
20699 + struct vx_info *vxi = current->vx_info;
20701 + set_normalized_timespec(uptime,
20702 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
20703 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
20706 + set_normalized_timespec(idle,
20707 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
20708 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
20712 +uint64_t vx_idle_jiffies(void)
20714 + return init_task.utime + init_task.stime;
20719 +static inline uint32_t __update_loadavg(uint32_t load,
20720 + int wsize, int delta, int n)
20722 + unsigned long long calc, prev;
20724 + /* just set it to n */
20725 + if (unlikely(delta >= wsize))
20726 + return (n << FSHIFT);
20728 + calc = delta * n;
20730 + prev = (wsize - delta);
20733 + do_div(calc, wsize);
20738 +void vx_update_load(struct vx_info *vxi)
20740 + uint32_t now, last, delta;
20741 + unsigned int nr_running, nr_uninterruptible;
20742 + unsigned int total;
20743 + unsigned long flags;
20745 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
20748 + last = vxi->cvirt.load_last;
20749 + delta = now - last;
20751 + if (delta < 5*HZ)
20754 + nr_running = atomic_read(&vxi->cvirt.nr_running);
20755 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
20756 + total = nr_running + nr_uninterruptible;
20758 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
20759 + 60*HZ, delta, total);
20760 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
20761 + 5*60*HZ, delta, total);
20762 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
20763 + 15*60*HZ, delta, total);
20765 + vxi->cvirt.load_last = now;
20767 + atomic_inc(&vxi->cvirt.load_updates);
20768 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
20773 + * Commands to do_syslog:
20775 + * 0 -- Close the log. Currently a NOP.
20776 + * 1 -- Open the log. Currently a NOP.
20777 + * 2 -- Read from the log.
20778 + * 3 -- Read all messages remaining in the ring buffer.
20779 + * 4 -- Read and clear all messages remaining in the ring buffer
20780 + * 5 -- Clear ring buffer.
20781 + * 6 -- Disable printk's to console
20782 + * 7 -- Enable printk's to console
20783 + * 8 -- Set level of messages printed to console
20784 + * 9 -- Return number of unread characters in the log buffer
20785 + * 10 -- Return size of the log buffer
20787 +int vx_do_syslog(int type, char __user *buf, int len)
20790 + int do_clear = 0;
20791 + struct vx_info *vxi = current->vx_info;
20792 + struct _vx_syslog *log;
20796 + log = &vxi->cvirt.syslog;
20799 + case 0: /* Close log */
20800 + case 1: /* Open log */
20802 + case 2: /* Read from log */
20803 + error = wait_event_interruptible(log->log_wait,
20804 + (log->log_start - log->log_end));
20807 + spin_lock_irq(&log->logbuf_lock);
20808 + spin_unlock_irq(&log->logbuf_lock);
20810 + case 4: /* Read/clear last kernel messages */
20812 + /* fall through */
20813 + case 3: /* Read last kernel messages */
20816 + case 5: /* Clear ring buffer */
20819 + case 6: /* Disable logging to console */
20820 + case 7: /* Enable logging to console */
20821 + case 8: /* Set level of messages printed to console */
20824 + case 9: /* Number of chars in the log buffer */
20826 + case 10: /* Size of the log buffer */
20836 +/* virtual host info names */
20838 +static char *vx_vhi_name(struct vx_info *vxi, int id)
20840 + struct nsproxy *nsproxy;
20841 + struct uts_namespace *uts;
20844 + if (id == VHIN_CONTEXT)
20845 + return vxi->vx_name;
20847 + nsproxy = vxi->vx_nsproxy;
20851 + uts = nsproxy->uts_ns;
20856 + case VHIN_SYSNAME:
20857 + return uts->name.sysname;
20858 + case VHIN_NODENAME:
20859 + return uts->name.nodename;
20860 + case VHIN_RELEASE:
20861 + return uts->name.release;
20862 + case VHIN_VERSION:
20863 + return uts->name.version;
20864 + case VHIN_MACHINE:
20865 + return uts->name.machine;
20866 + case VHIN_DOMAINNAME:
20867 + return uts->name.domainname;
20874 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
20876 + struct vcmd_vhi_name_v0 vc_data;
20879 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20882 + name = vx_vhi_name(vxi, vc_data.field);
20886 + memcpy(name, vc_data.name, 65);
20890 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
20892 + struct vcmd_vhi_name_v0 vc_data;
20895 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20898 + name = vx_vhi_name(vxi, vc_data.field);
20902 + memcpy(vc_data.name, name, 65);
20903 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20909 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
20911 + struct vcmd_virt_stat_v0 vc_data;
20912 + struct _vx_cvirt *cvirt = &vxi->cvirt;
20913 + struct timespec uptime;
20915 + do_posix_clock_monotonic_gettime(&uptime);
20916 + set_normalized_timespec(&uptime,
20917 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
20918 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
20920 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
20921 + vc_data.uptime = timespec_to_ns(&uptime);
20922 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
20923 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
20924 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
20925 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
20926 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
20927 + vc_data.load[0] = cvirt->load[0];
20928 + vc_data.load[1] = cvirt->load[1];
20929 + vc_data.load[2] = cvirt->load[2];
20931 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20937 +#ifdef CONFIG_VSERVER_VTIME
20939 +/* virtualized time base */
20941 +void vx_gettimeofday(struct timeval *tv)
20943 + do_gettimeofday(tv);
20944 + if (!vx_flags(VXF_VIRT_TIME, 0))
20947 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
20948 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
20950 + if (tv->tv_usec >= USEC_PER_SEC) {
20952 + tv->tv_usec -= USEC_PER_SEC;
20953 + } else if (tv->tv_usec < 0) {
20955 + tv->tv_usec += USEC_PER_SEC;
20959 +int vx_settimeofday(struct timespec *ts)
20961 + struct timeval tv;
20963 + if (!vx_flags(VXF_VIRT_TIME, 0))
20964 + return do_settimeofday(ts);
20966 + do_gettimeofday(&tv);
20967 + current->vx_info->cvirt.bias_tv.tv_sec =
20968 + ts->tv_sec - tv.tv_sec;
20969 + current->vx_info->cvirt.bias_tv.tv_usec =
20970 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
20976 diff -Nurp linux-2.6.22.18/kernel/vserver/cvirt_init.h linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cvirt_init.h
20977 --- linux-2.6.22.18/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
20978 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cvirt_init.h 2008-02-11 12:35:38.000000000 +0100
20982 +extern uint64_t vx_idle_jiffies(void);
20984 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
20986 + uint64_t idle_jiffies = vx_idle_jiffies();
20987 + uint64_t nsuptime;
20989 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
20990 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
20991 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
20992 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
20993 + cvirt->bias_tv.tv_sec = 0;
20994 + cvirt->bias_tv.tv_usec = 0;
20996 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
20997 + atomic_set(&cvirt->nr_threads, 0);
20998 + atomic_set(&cvirt->nr_running, 0);
20999 + atomic_set(&cvirt->nr_uninterruptible, 0);
21000 + atomic_set(&cvirt->nr_onhold, 0);
21002 + spin_lock_init(&cvirt->load_lock);
21003 + cvirt->load_last = jiffies;
21004 + atomic_set(&cvirt->load_updates, 0);
21005 + cvirt->load[0] = 0;
21006 + cvirt->load[1] = 0;
21007 + cvirt->load[2] = 0;
21008 + atomic_set(&cvirt->total_forks, 0);
21010 + spin_lock_init(&cvirt->syslog.logbuf_lock);
21011 + init_waitqueue_head(&cvirt->syslog.log_wait);
21012 + cvirt->syslog.log_start = 0;
21013 + cvirt->syslog.log_end = 0;
21014 + cvirt->syslog.con_start = 0;
21015 + cvirt->syslog.logged_chars = 0;
21019 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
21021 + // cvirt_pc->cpustat = { 0 };
21024 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
21028 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
21029 + "!!! cvirt: %p[nr_threads] = %d on exit.",
21031 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
21032 + "!!! cvirt: %p[nr_running] = %d on exit.",
21034 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
21035 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
21037 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
21038 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
21044 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
21049 diff -Nurp linux-2.6.22.18/kernel/vserver/cvirt_proc.h linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cvirt_proc.h
21050 --- linux-2.6.22.18/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
21051 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/cvirt_proc.h 2008-02-11 12:35:38.000000000 +0100
21053 +#ifndef _VX_CVIRT_PROC_H
21054 +#define _VX_CVIRT_PROC_H
21056 +#include <linux/nsproxy.h>
21057 +#include <linux/mnt_namespace.h>
21058 +#include <linux/utsname.h>
21059 +#include <linux/ipc.h>
21063 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
21065 + struct mnt_namespace *ns;
21066 + struct uts_namespace *uts;
21067 + struct ipc_namespace *ipc;
21068 + struct vfsmount *mnt;
21069 + char *path, *root;
21075 + length += sprintf(buffer + length,
21076 + "NSProxy:\t%p [%p,%p,%p]\n",
21077 + nsproxy, nsproxy->mnt_ns,
21078 + nsproxy->uts_ns, nsproxy->ipc_ns);
21080 + ns = nsproxy->mnt_ns;
21084 + path = kmalloc(PATH_MAX, GFP_KERNEL);
21089 + root = d_path(mnt->mnt_root, mnt->mnt_parent, path, PATH_MAX - 2);
21090 + length += sprintf(buffer + length,
21091 + "Namespace:\t%p [#%u]\n"
21092 + "RootPath:\t%s\n",
21093 + ns, atomic_read(&ns->count),
21098 + uts = nsproxy->uts_ns;
21102 + length += sprintf(buffer + length,
21103 + "SysName:\t%.*s\n"
21104 + "NodeName:\t%.*s\n"
21105 + "Release:\t%.*s\n"
21106 + "Version:\t%.*s\n"
21107 + "Machine:\t%.*s\n"
21108 + "DomainName:\t%.*s\n",
21109 + __NEW_UTS_LEN, uts->name.sysname,
21110 + __NEW_UTS_LEN, uts->name.nodename,
21111 + __NEW_UTS_LEN, uts->name.release,
21112 + __NEW_UTS_LEN, uts->name.version,
21113 + __NEW_UTS_LEN, uts->name.machine,
21114 + __NEW_UTS_LEN, uts->name.domainname);
21117 + ipc = nsproxy->ipc_ns;
21121 + length += sprintf(buffer + length,
21122 + "SEMS:\t\t%d %d %d %d %d\n"
21123 + "MSG:\t\t%d %d %d\n"
21124 + "SHM:\t\t%lu %lu %d %d\n",
21125 + ipc->sem_ctls[0], ipc->sem_ctls[1],
21126 + ipc->sem_ctls[2], ipc->sem_ctls[3],
21128 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
21129 + (unsigned long)ipc->shm_ctlmax,
21130 + (unsigned long)ipc->shm_ctlall,
21131 + ipc->shm_ctlmni, ipc->shm_tot);
21138 +#include <linux/sched.h>
21140 +#define LOAD_INT(x) ((x) >> FSHIFT)
21141 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
21144 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
21149 + length += sprintf(buffer + length,
21150 + "BiasUptime:\t%lu.%02lu\n",
21151 + (unsigned long)cvirt->bias_uptime.tv_sec,
21152 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
21154 + a = cvirt->load[0] + (FIXED_1 / 200);
21155 + b = cvirt->load[1] + (FIXED_1 / 200);
21156 + c = cvirt->load[2] + (FIXED_1 / 200);
21157 + length += sprintf(buffer + length,
21158 + "nr_threads:\t%d\n"
21159 + "nr_running:\t%d\n"
21160 + "nr_unintr:\t%d\n"
21161 + "nr_onhold:\t%d\n"
21162 + "load_updates:\t%d\n"
21163 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
21164 + "total_forks:\t%d\n",
21165 + atomic_read(&cvirt->nr_threads),
21166 + atomic_read(&cvirt->nr_running),
21167 + atomic_read(&cvirt->nr_uninterruptible),
21168 + atomic_read(&cvirt->nr_onhold),
21169 + atomic_read(&cvirt->load_updates),
21170 + LOAD_INT(a), LOAD_FRAC(a),
21171 + LOAD_INT(b), LOAD_FRAC(b),
21172 + LOAD_INT(c), LOAD_FRAC(c),
21173 + atomic_read(&cvirt->total_forks));
21178 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
21179 + char *buffer, int cpu)
21185 +#endif /* _VX_CVIRT_PROC_H */
21186 diff -Nurp linux-2.6.22.18/kernel/vserver/debug.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/debug.c
21187 --- linux-2.6.22.18/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
21188 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/debug.c 2008-02-11 12:35:38.000000000 +0100
21191 + * kernel/vserver/debug.c
21193 + * Copyright (C) 2005-2007 Herbert Pötzl
21195 + * V0.01 vx_info dump support
21199 +#include <linux/module.h>
21201 +#include <linux/vserver/context.h>
21204 +void dump_vx_info(struct vx_info *vxi, int level)
21206 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
21207 + atomic_read(&vxi->vx_usecnt),
21208 + atomic_read(&vxi->vx_tasks),
21211 + __dump_vx_limit(&vxi->limit);
21212 + __dump_vx_sched(&vxi->sched);
21213 + __dump_vx_cvirt(&vxi->cvirt);
21214 + __dump_vx_cacct(&vxi->cacct);
21220 +EXPORT_SYMBOL_GPL(dump_vx_info);
21222 diff -Nurp linux-2.6.22.18/kernel/vserver/device.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/device.c
21223 --- linux-2.6.22.18/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
21224 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/device.c 2008-02-11 12:35:38.000000000 +0100
21227 + * linux/kernel/vserver/device.c
21229 + * Linux-VServer: Device Support
21231 + * Copyright (C) 2006 Herbert Pötzl
21232 + * Copyright (C) 2007 Daniel Hokka Zakrisson
21234 + * V0.01 device mapping basics
21235 + * V0.02 added defaults
21239 +#include <linux/slab.h>
21240 +#include <linux/rcupdate.h>
21241 +#include <linux/fs.h>
21242 +#include <linux/namei.h>
21243 +#include <linux/hash.h>
21245 +#include <asm/errno.h>
21246 +#include <asm/uaccess.h>
21247 +#include <linux/vserver/base.h>
21248 +#include <linux/vserver/debug.h>
21249 +#include <linux/vserver/context.h>
21250 +#include <linux/vserver/device.h>
21251 +#include <linux/vserver/device_cmd.h>
21254 +#define DMAP_HASH_BITS 4
21257 +struct vs_mapping {
21259 + struct hlist_node hlist;
21260 + struct list_head list;
21262 +#define dm_hlist u.hlist
21263 +#define dm_list u.list
21266 + struct vx_dmap_target target;
21270 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
21272 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
21274 +static struct vx_dmap_target dmap_defaults[2] = {
21275 + { .flags = DATTR_OPEN },
21276 + { .flags = DATTR_OPEN },
21280 +struct kmem_cache *dmap_cachep __read_mostly;
21282 +int __init dmap_cache_init(void)
21284 + dmap_cachep = kmem_cache_create("dmap_cache",
21285 + sizeof(struct vs_mapping), 0,
21286 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
21290 +__initcall(dmap_cache_init);
21293 +static inline unsigned int __hashval(dev_t dev, int bits)
21295 + return hash_long((unsigned long)dev, bits);
21299 +/* __hash_mapping()
21300 + * add the mapping to the hash table
21302 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
21304 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21305 + struct hlist_head *head, *hash = dmap_main_hash;
21306 + int device = vdm->device;
21308 + spin_lock(hash_lock);
21309 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
21310 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
21312 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
21313 + hlist_add_head(&vdm->dm_hlist, head);
21314 + spin_unlock(hash_lock);
21318 +static inline int __mode_to_default(umode_t mode)
21331 +/* __set_default()
21334 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
21335 + struct vx_dmap_target *vdmt)
21337 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21338 + spin_lock(hash_lock);
21341 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
21343 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
21346 + spin_unlock(hash_lock);
21348 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
21349 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
21353 +/* __remove_default()
21354 + * remove a default
21356 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
21358 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21359 + spin_lock(hash_lock);
21362 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
21363 + else /* remove == reset */
21364 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
21366 + spin_unlock(hash_lock);
21371 +/* __find_mapping()
21372 + * find a mapping in the hash table
21374 + * caller must hold hash_lock
21376 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
21377 + struct vs_mapping **local, struct vs_mapping **global)
21379 + struct hlist_head *hash = dmap_main_hash;
21380 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
21381 + struct hlist_node *pos;
21382 + struct vs_mapping *vdm;
21388 + hlist_for_each(pos, head) {
21389 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
21391 + if ((vdm->device == device) &&
21392 + !((vdm->target.flags ^ mode) & S_IFMT)) {
21393 + if (vdm->xid == xid) {
21396 + } else if (global && vdm->xid == 0)
21401 + if (global && *global)
21408 +/* __lookup_mapping()
21409 + * find a mapping and store the result in target and flags
21411 +static inline int __lookup_mapping(struct vx_info *vxi,
21412 + dev_t device, dev_t *target, int *flags, umode_t mode)
21414 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21415 + struct vs_mapping *vdm, *global;
21416 + struct vx_dmap_target *vdmt;
21418 + xid_t xid = vxi->vx_id;
21421 + spin_lock(hash_lock);
21422 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
21424 + vdmt = &vdm->target;
21428 + index = __mode_to_default(mode);
21429 + if (vxi && vxi->dmap.targets[index].flags) {
21431 + vdmt = &vxi->dmap.targets[index];
21432 + } else if (global) {
21434 + vdmt = &global->target;
21438 + vdmt = &dmap_defaults[index];
21442 + if (target && (vdmt->flags & DATTR_REMAP))
21443 + *target = vdmt->target;
21445 + *target = device;
21447 + *flags = vdmt->flags;
21449 + spin_unlock(hash_lock);
21455 +/* __remove_mapping()
21456 + * remove a mapping from the hash table
21458 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
21461 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21462 + struct vs_mapping *vdm = NULL;
21465 + spin_lock(hash_lock);
21467 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
21469 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
21470 + vxi, vxi ? vxi->vx_id : 0, device, mode);
21473 + hlist_del(&vdm->dm_hlist);
21476 + spin_unlock(hash_lock);
21478 + kmem_cache_free(dmap_cachep, vdm);
21484 +int vs_map_device(struct vx_info *vxi,
21485 + dev_t device, dev_t *target, umode_t mode)
21487 + int ret, flags = DATTR_MASK;
21491 + *target = device;
21494 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
21495 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
21496 + device, target ? *target : 0, flags, mode, ret);
21498 + return (flags & DATTR_MASK);
21503 +static int do_set_mapping(struct vx_info *vxi,
21504 + dev_t device, dev_t target, int flags, umode_t mode)
21507 + struct vs_mapping *new;
21509 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
21513 + INIT_HLIST_NODE(&new->dm_hlist);
21514 + new->device = device;
21515 + new->target.target = target;
21516 + new->target.flags = flags | mode;
21517 + new->xid = (vxi ? vxi->vx_id : 0);
21519 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
21520 + __hash_mapping(vxi, new);
21522 + struct vx_dmap_target new = {
21523 + .target = target,
21524 + .flags = flags | mode,
21526 + __set_default(vxi, mode, &new);
21532 +static int do_unset_mapping(struct vx_info *vxi,
21533 + dev_t device, dev_t target, int flags, umode_t mode)
21535 + int ret = -EINVAL;
21538 + ret = __remove_mapping(vxi, device, mode);
21542 + ret = __remove_default(vxi, mode);
21552 +static inline int __user_device(const char __user *name, dev_t *dev,
21555 + struct nameidata nd;
21562 + ret = user_path_walk_link(name, &nd);
21565 + if (nd.dentry->d_inode) {
21566 + *dev = nd.dentry->d_inode->i_rdev;
21567 + *mode = nd.dentry->d_inode->i_mode;
21569 + path_release(&nd);
21573 +static inline int __mapping_mode(dev_t device, dev_t target,
21574 + umode_t device_mode, umode_t target_mode, umode_t *mode)
21577 + *mode = device_mode & S_IFMT;
21579 + *mode = target_mode & S_IFMT;
21583 + /* if both given, device and target mode have to match */
21584 + if (device && target &&
21585 + ((device_mode ^ target_mode) & S_IFMT))
21591 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
21592 + const char __user *target_path, int flags, int set)
21594 + dev_t device = ~0, target = ~0;
21595 + umode_t device_mode = 0, target_mode = 0, mode;
21598 + ret = __user_device(device_path, &device, &device_mode);
21601 + ret = __user_device(target_path, &target, &target_mode);
21605 + ret = __mapping_mode(device, target,
21606 + device_mode, target_mode, &mode);
21611 + return do_set_mapping(vxi, device, target,
21614 + return do_unset_mapping(vxi, device, target,
21619 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
21621 + struct vcmd_set_mapping_v0 vc_data;
21623 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21626 + return do_mapping(vxi, vc_data.device, vc_data.target,
21627 + vc_data.flags, 1);
21630 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
21632 + struct vcmd_set_mapping_v0 vc_data;
21634 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21637 + return do_mapping(vxi, vc_data.device, vc_data.target,
21638 + vc_data.flags, 0);
21642 +#ifdef CONFIG_COMPAT
21644 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
21646 + struct vcmd_set_mapping_v0_x32 vc_data;
21648 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21651 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
21652 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
21655 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
21657 + struct vcmd_set_mapping_v0_x32 vc_data;
21659 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21662 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
21663 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
21666 +#endif /* CONFIG_COMPAT */
21669 diff -Nurp linux-2.6.22.18/kernel/vserver/dlimit.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/dlimit.c
21670 --- linux-2.6.22.18/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
21671 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/dlimit.c 2008-02-11 12:35:38.000000000 +0100
21674 + * linux/kernel/vserver/dlimit.c
21676 + * Virtual Server: Context Disk Limits
21678 + * Copyright (C) 2004-2007 Herbert Pötzl
21680 + * V0.01 initial version
21681 + * V0.02 compat32 splitup
21685 +#include <linux/statfs.h>
21686 +#include <linux/vs_tag.h>
21687 +#include <linux/vs_dlimit.h>
21688 +#include <linux/vserver/dlimit_cmd.h>
21690 +#include <asm/uaccess.h>
21692 +/* __alloc_dl_info()
21694 + * allocate an initialized dl_info struct
21695 + * doesn't make it visible (hash) */
21697 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
21699 + struct dl_info *new = NULL;
21701 + vxdprintk(VXD_CBIT(dlim, 5),
21702 + "alloc_dl_info(%p,%d)*", sb, tag);
21704 + /* would this benefit from a slab cache? */
21705 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
21709 + memset(new, 0, sizeof(struct dl_info));
21710 + new->dl_tag = tag;
21712 + INIT_RCU_HEAD(&new->dl_rcu);
21713 + INIT_HLIST_NODE(&new->dl_hlist);
21714 + spin_lock_init(&new->dl_lock);
21715 + atomic_set(&new->dl_refcnt, 0);
21716 + atomic_set(&new->dl_usecnt, 0);
21718 + /* rest of init goes here */
21720 + vxdprintk(VXD_CBIT(dlim, 4),
21721 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
21725 +/* __dealloc_dl_info()
21727 + * final disposal of dl_info */
21729 +static void __dealloc_dl_info(struct dl_info *dli)
21731 + vxdprintk(VXD_CBIT(dlim, 4),
21732 + "dealloc_dl_info(%p)", dli);
21734 + dli->dl_hlist.next = LIST_POISON1;
21735 + dli->dl_tag = -1;
21738 + BUG_ON(atomic_read(&dli->dl_usecnt));
21739 + BUG_ON(atomic_read(&dli->dl_refcnt));
21745 +/* hash table for dl_info hash */
21747 +#define DL_HASH_SIZE 13
21749 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
21751 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
21754 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
21756 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
21761 +/* __hash_dl_info()
21763 + * add the dli to the global hash table
21764 + * requires the hash_lock to be held */
21766 +static inline void __hash_dl_info(struct dl_info *dli)
21768 + struct hlist_head *head;
21770 + vxdprintk(VXD_CBIT(dlim, 6),
21771 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
21772 + get_dl_info(dli);
21773 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
21774 + hlist_add_head_rcu(&dli->dl_hlist, head);
21777 +/* __unhash_dl_info()
21779 + * remove the dli from the global hash table
21780 + * requires the hash_lock to be held */
21782 +static inline void __unhash_dl_info(struct dl_info *dli)
21784 + vxdprintk(VXD_CBIT(dlim, 6),
21785 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
21786 + hlist_del_rcu(&dli->dl_hlist);
21787 + put_dl_info(dli);
21791 +/* __lookup_dl_info()
21793 + * requires the rcu_read_lock()
21794 + * doesn't increment the dl_refcnt */
21796 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
21798 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
21799 + struct hlist_node *pos;
21800 + struct dl_info *dli;
21802 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
21804 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
21812 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
21814 + struct dl_info *dli;
21817 + dli = get_dl_info(__lookup_dl_info(sb, tag));
21818 + vxdprintk(VXD_CBIT(dlim, 7),
21819 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
21820 + rcu_read_unlock();
21824 +void rcu_free_dl_info(struct rcu_head *head)
21826 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
21827 + int usecnt, refcnt;
21829 + BUG_ON(!dli || !head);
21831 + usecnt = atomic_read(&dli->dl_usecnt);
21832 + BUG_ON(usecnt < 0);
21834 + refcnt = atomic_read(&dli->dl_refcnt);
21835 + BUG_ON(refcnt < 0);
21837 + vxdprintk(VXD_CBIT(dlim, 3),
21838 + "rcu_free_dl_info(%p)", dli);
21840 + __dealloc_dl_info(dli);
21842 + printk("!!! rcu didn't free\n");
21848 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
21849 + uint32_t flags, int add)
21851 + struct nameidata nd;
21854 + ret = user_path_walk_link(name, &nd);
21856 + struct super_block *sb;
21857 + struct dl_info *dli;
21860 + if (!nd.dentry->d_inode)
21861 + goto out_release;
21862 + if (!(sb = nd.dentry->d_inode->i_sb))
21863 + goto out_release;
21866 + dli = __alloc_dl_info(sb, id);
21867 + spin_lock(&dl_info_hash_lock);
21870 + if (__lookup_dl_info(sb, id))
21872 + __hash_dl_info(dli);
21875 + spin_lock(&dl_info_hash_lock);
21876 + dli = __lookup_dl_info(sb, id);
21881 + __unhash_dl_info(dli);
21885 + spin_unlock(&dl_info_hash_lock);
21887 + __dealloc_dl_info(dli);
21889 + path_release(&nd);
21894 +int vc_add_dlimit(uint32_t id, void __user *data)
21896 + struct vcmd_ctx_dlimit_base_v0 vc_data;
21898 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21901 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
21904 +int vc_rem_dlimit(uint32_t id, void __user *data)
21906 + struct vcmd_ctx_dlimit_base_v0 vc_data;
21908 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21911 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
21914 +#ifdef CONFIG_COMPAT
21916 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
21918 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
21920 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21923 + return do_addrem_dlimit(id,
21924 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
21927 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
21929 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
21931 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21934 + return do_addrem_dlimit(id,
21935 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
21938 +#endif /* CONFIG_COMPAT */
21942 +int do_set_dlimit(uint32_t id, const char __user *name,
21943 + uint32_t space_used, uint32_t space_total,
21944 + uint32_t inodes_used, uint32_t inodes_total,
21945 + uint32_t reserved, uint32_t flags)
21947 + struct nameidata nd;
21950 + ret = user_path_walk_link(name, &nd);
21952 + struct super_block *sb;
21953 + struct dl_info *dli;
21956 + if (!nd.dentry->d_inode)
21957 + goto out_release;
21958 + if (!(sb = nd.dentry->d_inode->i_sb))
21959 + goto out_release;
21960 + if ((reserved != CDLIM_KEEP &&
21961 + reserved > 100) ||
21962 + (inodes_used != CDLIM_KEEP &&
21963 + inodes_used > inodes_total) ||
21964 + (space_used != CDLIM_KEEP &&
21965 + space_used > space_total))
21966 + goto out_release;
21969 + dli = locate_dl_info(sb, id);
21971 + goto out_release;
21973 + spin_lock(&dli->dl_lock);
21975 + if (inodes_used != CDLIM_KEEP)
21976 + dli->dl_inodes_used = inodes_used;
21977 + if (inodes_total != CDLIM_KEEP)
21978 + dli->dl_inodes_total = inodes_total;
21979 + if (space_used != CDLIM_KEEP) {
21980 + dli->dl_space_used = space_used;
21981 + dli->dl_space_used <<= 10;
21983 + if (space_total == CDLIM_INFINITY)
21984 + dli->dl_space_total = DLIM_INFINITY;
21985 + else if (space_total != CDLIM_KEEP) {
21986 + dli->dl_space_total = space_total;
21987 + dli->dl_space_total <<= 10;
21989 + if (reserved != CDLIM_KEEP)
21990 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
21992 + spin_unlock(&dli->dl_lock);
21994 + put_dl_info(dli);
21998 + path_release(&nd);
22003 +int vc_set_dlimit(uint32_t id, void __user *data)
22005 + struct vcmd_ctx_dlimit_v0 vc_data;
22007 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22010 + return do_set_dlimit(id, vc_data.name,
22011 + vc_data.space_used, vc_data.space_total,
22012 + vc_data.inodes_used, vc_data.inodes_total,
22013 + vc_data.reserved, vc_data.flags);
22016 +#ifdef CONFIG_COMPAT
22018 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
22020 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
22022 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22025 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
22026 + vc_data.space_used, vc_data.space_total,
22027 + vc_data.inodes_used, vc_data.inodes_total,
22028 + vc_data.reserved, vc_data.flags);
22031 +#endif /* CONFIG_COMPAT */
22035 +int do_get_dlimit(uint32_t id, const char __user *name,
22036 + uint32_t *space_used, uint32_t *space_total,
22037 + uint32_t *inodes_used, uint32_t *inodes_total,
22038 + uint32_t *reserved, uint32_t *flags)
22040 + struct nameidata nd;
22043 + ret = user_path_walk_link(name, &nd);
22045 + struct super_block *sb;
22046 + struct dl_info *dli;
22049 + if (!nd.dentry->d_inode)
22050 + goto out_release;
22051 + if (!(sb = nd.dentry->d_inode->i_sb))
22052 + goto out_release;
22055 + dli = locate_dl_info(sb, id);
22057 + goto out_release;
22059 + spin_lock(&dli->dl_lock);
22060 + *inodes_used = dli->dl_inodes_used;
22061 + *inodes_total = dli->dl_inodes_total;
22062 + *space_used = dli->dl_space_used >> 10;
22063 + if (dli->dl_space_total == DLIM_INFINITY)
22064 + *space_total = CDLIM_INFINITY;
22066 + *space_total = dli->dl_space_total >> 10;
22068 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
22069 + spin_unlock(&dli->dl_lock);
22071 + put_dl_info(dli);
22076 + path_release(&nd);
22082 +int vc_get_dlimit(uint32_t id, void __user *data)
22084 + struct vcmd_ctx_dlimit_v0 vc_data;
22087 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22090 + ret = do_get_dlimit(id, vc_data.name,
22091 + &vc_data.space_used, &vc_data.space_total,
22092 + &vc_data.inodes_used, &vc_data.inodes_total,
22093 + &vc_data.reserved, &vc_data.flags);
22097 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22102 +#ifdef CONFIG_COMPAT
22104 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
22106 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
22109 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22112 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
22113 + &vc_data.space_used, &vc_data.space_total,
22114 + &vc_data.inodes_used, &vc_data.inodes_total,
22115 + &vc_data.reserved, &vc_data.flags);
22119 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22124 +#endif /* CONFIG_COMPAT */
22127 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
22129 + struct dl_info *dli;
22130 + __u64 blimit, bfree, bavail;
22133 + dli = locate_dl_info(sb, dx_current_tag());
22137 + spin_lock(&dli->dl_lock);
22138 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
22141 + /* reduce max inodes available to limit */
22142 + if (buf->f_files > dli->dl_inodes_total)
22143 + buf->f_files = dli->dl_inodes_total;
22145 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
22146 + /* reduce free inodes to min */
22147 + if (ifree < buf->f_ffree)
22148 + buf->f_ffree = ifree;
22151 + if (dli->dl_space_total == DLIM_INFINITY)
22154 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
22156 + if (dli->dl_space_total < dli->dl_space_used)
22159 + bfree = (dli->dl_space_total - dli->dl_space_used)
22160 + >> sb->s_blocksize_bits;
22162 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
22163 + if (bavail < dli->dl_space_used)
22166 + bavail = (bavail - dli->dl_space_used)
22167 + >> sb->s_blocksize_bits;
22169 + /* reduce max space available to limit */
22170 + if (buf->f_blocks > blimit)
22171 + buf->f_blocks = blimit;
22173 + /* reduce free space to min */
22174 + if (bfree < buf->f_bfree)
22175 + buf->f_bfree = bfree;
22177 + /* reduce avail space to min */
22178 + if (bavail < buf->f_bavail)
22179 + buf->f_bavail = bavail;
22182 + spin_unlock(&dli->dl_lock);
22183 + put_dl_info(dli);
22188 +#include <linux/module.h>
22190 +EXPORT_SYMBOL_GPL(locate_dl_info);
22191 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
22193 diff -Nurp linux-2.6.22.18/kernel/vserver/helper.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/helper.c
22194 --- linux-2.6.22.18/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
22195 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/helper.c 2008-02-11 12:35:38.000000000 +0100
22198 + * linux/kernel/vserver/helper.c
22200 + * Virtual Context Support
22202 + * Copyright (C) 2004-2007 Herbert Pötzl
22204 + * V0.01 basic helper
22208 +#include <linux/kmod.h>
22209 +#include <linux/reboot.h>
22210 +#include <linux/vs_context.h>
22211 +#include <linux/vs_network.h>
22212 +#include <linux/vserver/signal.h>
22215 +char vshelper_path[255] = "/sbin/vshelper";
22218 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
22222 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
22223 + printk( KERN_WARNING
22224 + "%s: (%s %s) returned %s with %d\n",
22225 + name, argv[1], argv[2],
22226 + sync ? "sync" : "async", ret);
22228 + vxdprintk(VXD_CBIT(switch, 4),
22229 + "%s: (%s %s) returned %s with %d",
22230 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
22235 + * vshelper path is set via /proc/sys
22236 + * invoked by vserver sys_reboot(), with
22237 + * the following arguments
22239 + * argv [0] = vshelper_path;
22240 + * argv [1] = action: "restart", "halt", "poweroff", ...
22241 + * argv [2] = context identifier
22243 + * envp [*] = type-specific parameters
22246 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
22248 + char id_buf[8], cmd_buf[16];
22249 + char uid_buf[16], pid_buf[16];
22252 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22253 + char *envp[] = {"HOME=/", "TERM=linux",
22254 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
22255 + uid_buf, pid_buf, cmd_buf, 0};
22257 + if (vx_info_state(vxi, VXS_HELPER))
22259 + vxi->vx_state |= VXS_HELPER;
22261 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
22263 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22264 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
22265 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
22268 + case LINUX_REBOOT_CMD_RESTART:
22269 + argv[1] = "restart";
22272 + case LINUX_REBOOT_CMD_HALT:
22273 + argv[1] = "halt";
22276 + case LINUX_REBOOT_CMD_POWER_OFF:
22277 + argv[1] = "poweroff";
22280 + case LINUX_REBOOT_CMD_SW_SUSPEND:
22281 + argv[1] = "swsusp";
22285 + vxi->vx_state &= ~VXS_HELPER;
22289 + ret = do_vshelper(vshelper_path, argv, envp, 0);
22290 + vxi->vx_state &= ~VXS_HELPER;
22291 + __wakeup_vx_info(vxi);
22292 + return (ret) ? -EPERM : 0;
22296 +long vs_reboot(unsigned int cmd, void __user *arg)
22298 + struct vx_info *vxi = current->vx_info;
22301 + vxdprintk(VXD_CBIT(misc, 5),
22302 + "vs_reboot(%p[#%d],%d)",
22303 + vxi, vxi ? vxi->vx_id : 0, cmd);
22305 + ret = vs_reboot_helper(vxi, cmd, arg);
22309 + vxi->reboot_cmd = cmd;
22310 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
22312 + case LINUX_REBOOT_CMD_RESTART:
22313 + case LINUX_REBOOT_CMD_HALT:
22314 + case LINUX_REBOOT_CMD_POWER_OFF:
22315 + vx_info_kill(vxi, 0, SIGKILL);
22316 + vx_info_kill(vxi, 1, SIGKILL);
22326 + * argv [0] = vshelper_path;
22327 + * argv [1] = action: "startup", "shutdown"
22328 + * argv [2] = context identifier
22330 + * envp [*] = type-specific parameters
22333 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
22335 + char id_buf[8], cmd_buf[16];
22336 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22337 + char *envp[] = {"HOME=/", "TERM=linux",
22338 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
22340 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
22343 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
22344 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22347 + case VSC_STARTUP:
22348 + argv[1] = "startup";
22350 + case VSC_SHUTDOWN:
22351 + argv[1] = "shutdown";
22357 + return do_vshelper(vshelper_path, argv, envp, 1);
22362 + * argv [0] = vshelper_path;
22363 + * argv [1] = action: "netup", "netdown"
22364 + * argv [2] = context identifier
22366 + * envp [*] = type-specific parameters
22369 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
22371 + char id_buf[8], cmd_buf[16];
22372 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22373 + char *envp[] = {"HOME=/", "TERM=linux",
22374 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
22376 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
22379 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
22380 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22384 + argv[1] = "netup";
22386 + case VSC_NETDOWN:
22387 + argv[1] = "netdown";
22393 + return do_vshelper(vshelper_path, argv, envp, 1);
22396 diff -Nurp linux-2.6.22.18/kernel/vserver/history.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/history.c
22397 --- linux-2.6.22.18/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
22398 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/history.c 2008-02-11 12:35:38.000000000 +0100
22401 + * kernel/vserver/history.c
22403 + * Virtual Context History Backtrace
22405 + * Copyright (C) 2004-2007 Herbert Pötzl
22407 + * V0.01 basic structure
22408 + * V0.02 hash/unhash and trace
22409 + * V0.03 preemption fixes
22413 +#include <linux/module.h>
22414 +#include <asm/uaccess.h>
22416 +#include <linux/vserver/context.h>
22417 +#include <linux/vserver/debug.h>
22418 +#include <linux/vserver/debug_cmd.h>
22419 +#include <linux/vserver/history.h>
22422 +#ifdef CONFIG_VSERVER_HISTORY
22423 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
22425 +#define VXH_SIZE 64
22428 +struct _vx_history {
22429 + unsigned int counter;
22431 + struct _vx_hist_entry entry[VXH_SIZE + 1];
22435 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
22437 +unsigned volatile int vxh_active = 1;
22439 +static atomic_t sequence = ATOMIC_INIT(0);
22444 + * requires disabled preemption */
22446 +struct _vx_hist_entry *vxh_advance(void *loc)
22448 + unsigned int cpu = smp_processor_id();
22449 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
22450 + struct _vx_hist_entry *entry;
22451 + unsigned int index;
22453 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
22454 + entry = &hist->entry[index];
22456 + entry->seq = atomic_inc_return(&sequence);
22457 + entry->loc = loc;
22461 +EXPORT_SYMBOL_GPL(vxh_advance);
22464 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
22466 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
22469 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
22471 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
22472 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
22473 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
22474 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
22476 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
22478 + switch (e->type) {
22479 + case VXH_THROW_OOPS:
22480 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
22483 + case VXH_GET_VX_INFO:
22484 + case VXH_PUT_VX_INFO:
22485 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
22487 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
22488 + VXH_VXI_ARGS(e));
22491 + case VXH_INIT_VX_INFO:
22492 + case VXH_SET_VX_INFO:
22493 + case VXH_CLR_VX_INFO:
22494 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
22496 + (e->type == VXH_INIT_VX_INFO) ? "init" :
22497 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
22498 + VXH_VXI_ARGS(e), e->sc.data);
22501 + case VXH_CLAIM_VX_INFO:
22502 + case VXH_RELEASE_VX_INFO:
22503 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
22505 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
22506 + VXH_VXI_ARGS(e), e->sc.data);
22509 + case VXH_ALLOC_VX_INFO:
22510 + case VXH_DEALLOC_VX_INFO:
22511 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
22513 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
22514 + VXH_VXI_ARGS(e));
22517 + case VXH_HASH_VX_INFO:
22518 + case VXH_UNHASH_VX_INFO:
22519 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
22521 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
22522 + VXH_VXI_ARGS(e));
22525 + case VXH_LOC_VX_INFO:
22526 + case VXH_LOOKUP_VX_INFO:
22527 + case VXH_CREATE_VX_INFO:
22528 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
22530 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
22531 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
22532 + e->ll.arg, VXH_VXI_ARGS(e));
22537 +static void __vxh_dump_history(void)
22539 + unsigned int i, cpu;
22541 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
22542 + atomic_read(&sequence), NR_CPUS);
22544 + for (i = 0; i < VXH_SIZE; i++) {
22545 + for_each_online_cpu(cpu) {
22546 + struct _vx_history *hist =
22547 + &per_cpu(vx_history_buffer, cpu);
22548 + unsigned int index = (hist->counter - i) % VXH_SIZE;
22549 + struct _vx_hist_entry *entry = &hist->entry[index];
22551 + vxh_dump_entry(entry, cpu);
22556 +void vxh_dump_history(void)
22560 + local_irq_enable();
22562 + local_irq_disable();
22564 + __vxh_dump_history();
22568 +/* vserver syscall commands below here */
22571 +int vc_dump_history(uint32_t id)
22574 + __vxh_dump_history();
22581 +int do_read_history(struct __user _vx_hist_entry *data,
22582 + int cpu, uint32_t *index, uint32_t *count)
22584 + int pos, ret = 0;
22585 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
22586 + int end = hist->counter;
22587 + int start = end - VXH_SIZE + 2;
22588 + int idx = *index;
22590 + /* special case: get current pos */
22596 + /* have we lost some data? */
22600 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22601 + struct _vx_hist_entry *entry =
22602 + &hist->entry[idx % VXH_SIZE];
22604 + /* send entry to userspace */
22605 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22609 + /* save new index and count */
22612 + return ret ? ret : (*index < end);
22615 +int vc_read_history(uint32_t id, void __user *data)
22617 + struct vcmd_read_history_v0 vc_data;
22620 + if (id >= NR_CPUS)
22623 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22626 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
22627 + id, &vc_data.index, &vc_data.count);
22629 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22634 +#ifdef CONFIG_COMPAT
22636 +int vc_read_history_x32(uint32_t id, void __user *data)
22638 + struct vcmd_read_history_v0_x32 vc_data;
22641 + if (id >= NR_CPUS)
22644 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22647 + ret = do_read_history((struct __user _vx_hist_entry *)
22648 + compat_ptr(vc_data.data_ptr),
22649 + id, &vc_data.index, &vc_data.count);
22651 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22656 +#endif /* CONFIG_COMPAT */
22658 diff -Nurp linux-2.6.22.18/kernel/vserver/inet.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/inet.c
22659 --- linux-2.6.22.18/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
22660 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/inet.c 2008-02-11 12:35:38.000000000 +0100
22663 +#include <linux/in.h>
22664 +#include <linux/inetdevice.h>
22665 +#include <linux/vs_inet6.h>
22666 +#include <linux/vserver/debug.h>
22667 +#include <net/route.h>
22668 +#include <net/addrconf.h>
22671 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
22675 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
22678 + struct nx_addr_v4 *ptr;
22680 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
22681 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
22688 + vxdprintk(VXD_CBIT(net, 2),
22689 + "nx_v4_addr_conflict(%p,%p): %d",
22690 + nxi1, nxi2, ret);
22696 +#ifdef CONFIG_IPV6
22698 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
22702 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
22705 + struct nx_addr_v6 *ptr;
22707 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
22708 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
22715 + vxdprintk(VXD_CBIT(net, 2),
22716 + "nx_v6_addr_conflict(%p,%p): %d",
22717 + nxi1, nxi2, ret);
22724 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22726 + struct in_device *in_dev;
22727 + struct in_ifaddr **ifap;
22728 + struct in_ifaddr *ifa;
22733 + in_dev = in_dev_get(dev);
22737 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
22738 + ifap = &ifa->ifa_next) {
22739 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
22744 + in_dev_put(in_dev);
22750 +#ifdef CONFIG_IPV6
22752 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22754 + struct inet6_dev *in_dev;
22755 + struct inet6_ifaddr **ifap;
22756 + struct inet6_ifaddr *ifa;
22761 + in_dev = in6_dev_get(dev);
22765 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
22766 + ifap = &ifa->if_next) {
22767 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
22772 + in6_dev_put(in_dev);
22779 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22785 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
22787 +#ifdef CONFIG_IPV6
22789 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
22794 + vxdprintk(VXD_CBIT(net, 3),
22795 + "dev_in_nx_info(%p,%p[#%d]) = %d",
22796 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
22800 +int ip_v4_find_src(struct nx_info *nxi, struct rtable **rp, struct flowi *fl)
22805 + /* FIXME: handle lback only case */
22806 + if (!NX_IPV4(nxi))
22809 + vxdprintk(VXD_CBIT(net, 4),
22810 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
22811 + nxi, nxi ? nxi->nx_id : 0,
22812 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
22814 + /* single IP is unconditional */
22815 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
22816 + (fl->fl4_src == INADDR_ANY))
22817 + fl->fl4_src = nxi->v4.ip[0].s_addr;
22819 + if (fl->fl4_src == INADDR_ANY) {
22820 + struct nx_addr_v4 *ptr;
22824 + err = __ip_route_output_key(rp, fl);
22826 + found = (*rp)->rt_src;
22828 + vxdprintk(VXD_CBIT(net, 4),
22829 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
22830 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
22831 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
22835 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
22836 + __be32 primary = ptr->ip[0].s_addr;
22837 + __be32 mask = ptr->mask.s_addr;
22838 + __be32 net = primary & mask;
22840 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
22841 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
22842 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
22843 + NIPQUAD(mask), NIPQUAD(net));
22844 + if ((found & mask) != net)
22847 + fl->fl4_src = primary;
22848 + err = __ip_route_output_key(rp, fl);
22849 + vxdprintk(VXD_CBIT(net, 4),
22850 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
22851 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
22853 + found = (*rp)->rt_src;
22855 + if (found == primary)
22859 + /* still no source ip? */
22860 + found = LOOPBACK(fl->fl4_dst)
22861 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
22863 + /* assign src ip to flow */
22864 + fl->fl4_src = found;
22867 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
22871 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
22872 + if (LOOPBACK(fl->fl4_dst))
22873 + fl->fl4_dst = nxi->v4_lback.s_addr;
22874 + if (LOOPBACK(fl->fl4_src))
22875 + fl->fl4_src = nxi->v4_lback.s_addr;
22876 + } else if (LOOPBACK(fl->fl4_dst))
22882 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
22884 diff -Nurp linux-2.6.22.18/kernel/vserver/init.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/init.c
22885 --- linux-2.6.22.18/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
22886 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/init.c 2008-02-11 12:35:38.000000000 +0100
22889 + * linux/kernel/init.c
22891 + * Virtual Server Init
22893 + * Copyright (C) 2004-2007 Herbert Pötzl
22895 + * V0.01 basic structure
22899 +#include <linux/init.h>
22901 +int vserver_register_sysctl(void);
22902 +void vserver_unregister_sysctl(void);
22905 +static int __init init_vserver(void)
22909 +#ifdef CONFIG_VSERVER_DEBUG
22910 + vserver_register_sysctl();
22916 +static void __exit exit_vserver(void)
22919 +#ifdef CONFIG_VSERVER_DEBUG
22920 + vserver_unregister_sysctl();
22925 +/* FIXME: GFP_ZONETYPES gone
22926 +long vx_slab[GFP_ZONETYPES]; */
22930 +module_init(init_vserver);
22931 +module_exit(exit_vserver);
22933 diff -Nurp linux-2.6.22.18/kernel/vserver/inode.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/inode.c
22934 --- linux-2.6.22.18/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
22935 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/inode.c 2008-02-11 12:35:38.000000000 +0100
22938 + * linux/kernel/vserver/inode.c
22940 + * Virtual Server: File System Support
22942 + * Copyright (C) 2004-2007 Herbert Pötzl
22944 + * V0.01 separated from vcontext V0.05
22945 + * V0.02 moved to tag (instead of xid)
22949 +#include <linux/tty.h>
22950 +#include <linux/proc_fs.h>
22951 +#include <linux/devpts_fs.h>
22952 +#include <linux/fs.h>
22953 +#include <linux/file.h>
22954 +#include <linux/mount.h>
22955 +#include <linux/parser.h>
22956 +#include <linux/vserver/inode.h>
22957 +#include <linux/vserver/inode_cmd.h>
22958 +#include <linux/vs_base.h>
22959 +#include <linux/vs_tag.h>
22961 +#include <asm/uaccess.h>
22964 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
22966 + struct proc_dir_entry *entry;
22968 + if (!in || !in->i_sb)
22971 + *flags = IATTR_TAG
22972 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
22973 + | (IS_IUNLINK(in) ? IATTR_IUNLINK : 0)
22974 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
22975 + *mask = IATTR_IUNLINK | IATTR_IMMUTABLE;
22977 + if (S_ISDIR(in->i_mode))
22978 + *mask |= IATTR_BARRIER;
22980 + if (IS_TAGGED(in)) {
22981 + *tag = in->i_tag;
22982 + *mask |= IATTR_TAG;
22985 + switch (in->i_sb->s_magic) {
22986 + case PROC_SUPER_MAGIC:
22987 + entry = PROC_I(in)->pde;
22989 + /* check for specific inodes? */
22991 + *mask |= IATTR_FLAGS;
22993 + *flags |= (entry->vx_flags & IATTR_FLAGS);
22995 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
22998 + case DEVPTS_SUPER_MAGIC:
22999 + *tag = in->i_tag;
23000 + *mask |= IATTR_TAG;
23009 +int vc_get_iattr(void __user *data)
23011 + struct nameidata nd;
23012 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
23015 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23018 + ret = user_path_walk_link(vc_data.name, &nd);
23020 + ret = __vc_get_iattr(nd.dentry->d_inode,
23021 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23022 + path_release(&nd);
23027 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23032 +#ifdef CONFIG_COMPAT
23034 +int vc_get_iattr_x32(void __user *data)
23036 + struct nameidata nd;
23037 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
23040 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23043 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
23045 + ret = __vc_get_iattr(nd.dentry->d_inode,
23046 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23047 + path_release(&nd);
23052 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23057 +#endif /* CONFIG_COMPAT */
23060 +int vc_fget_iattr(uint32_t fd, void __user *data)
23062 + struct file *filp;
23063 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
23066 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23070 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
23073 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
23074 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23078 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23084 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
23086 + struct inode *in = de->d_inode;
23087 + int error = 0, is_proc = 0, has_tag = 0;
23088 + struct iattr attr = { 0 };
23090 + if (!in || !in->i_sb)
23093 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
23094 + if ((*mask & IATTR_FLAGS) && !is_proc)
23097 + has_tag = IS_TAGGED(in) ||
23098 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
23099 + if ((*mask & IATTR_TAG) && !has_tag)
23102 + mutex_lock(&in->i_mutex);
23103 + if (*mask & IATTR_TAG) {
23104 + attr.ia_tag = *tag;
23105 + attr.ia_valid |= ATTR_TAG;
23108 + if (*mask & IATTR_FLAGS) {
23109 + struct proc_dir_entry *entry = PROC_I(in)->pde;
23110 + unsigned int iflags = PROC_I(in)->vx_flags;
23112 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
23113 + | (*flags & IATTR_FLAGS);
23114 + PROC_I(in)->vx_flags = iflags;
23116 + entry->vx_flags = iflags;
23119 + if (*mask & (IATTR_BARRIER | IATTR_IUNLINK | IATTR_IMMUTABLE)) {
23120 + if (*mask & IATTR_IMMUTABLE) {
23121 + if (*flags & IATTR_IMMUTABLE)
23122 + in->i_flags |= S_IMMUTABLE;
23124 + in->i_flags &= ~S_IMMUTABLE;
23126 + if (*mask & IATTR_IUNLINK) {
23127 + if (*flags & IATTR_IUNLINK)
23128 + in->i_flags |= S_IUNLINK;
23130 + in->i_flags &= ~S_IUNLINK;
23132 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
23133 + if (*flags & IATTR_BARRIER)
23134 + in->i_flags |= S_BARRIER;
23136 + in->i_flags &= ~S_BARRIER;
23138 + if (in->i_op && in->i_op->sync_flags) {
23139 + error = in->i_op->sync_flags(in);
23145 + if (attr.ia_valid) {
23146 + if (in->i_op && in->i_op->setattr)
23147 + error = in->i_op->setattr(de, &attr);
23149 + error = inode_change_ok(in, &attr);
23151 + error = inode_setattr(in, &attr);
23156 + mutex_unlock(&in->i_mutex);
23160 +int vc_set_iattr(void __user *data)
23162 + struct nameidata nd;
23163 + struct vcmd_ctx_iattr_v1 vc_data;
23166 + if (!capable(CAP_LINUX_IMMUTABLE))
23168 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23171 + ret = user_path_walk_link(vc_data.name, &nd);
23173 + ret = __vc_set_iattr(nd.dentry,
23174 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23175 + path_release(&nd);
23178 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23183 +#ifdef CONFIG_COMPAT
23185 +int vc_set_iattr_x32(void __user *data)
23187 + struct nameidata nd;
23188 + struct vcmd_ctx_iattr_v1_x32 vc_data;
23191 + if (!capable(CAP_LINUX_IMMUTABLE))
23193 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23196 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
23198 + ret = __vc_set_iattr(nd.dentry,
23199 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23200 + path_release(&nd);
23203 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23208 +#endif /* CONFIG_COMPAT */
23210 +int vc_fset_iattr(uint32_t fd, void __user *data)
23212 + struct file *filp;
23213 + struct vcmd_ctx_fiattr_v0 vc_data;
23216 + if (!capable(CAP_LINUX_IMMUTABLE))
23218 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23222 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
23225 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
23226 + &vc_data.flags, &vc_data.mask);
23230 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23236 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
23238 +static match_table_t tokens = {
23239 + {Opt_notagcheck, "notagcheck"},
23240 +#ifdef CONFIG_PROPAGATE
23241 + {Opt_notag, "notag"},
23242 + {Opt_tag, "tag"},
23243 + {Opt_tagid, "tagid=%u"},
23249 +static void __dx_parse_remove(char *string, char *opt)
23251 + char *p = strstr(string, opt);
23255 + while (*q != '\0' && *q != ',')
23265 +int __dx_parse_tag(char *string, tag_t *tag, int remove)
23267 + substring_t args[MAX_OPT_ARGS];
23268 + int token, option = 0;
23273 + token = match_token(string, tokens, args);
23275 + vxdprintk(VXD_CBIT(tag, 7),
23276 + "dx_parse_tag(»%s«): %d:#%d",
23277 + string, token, option);
23284 + __dx_parse_remove(string, "tag");
23285 + return MNT_TAGID;
23288 + __dx_parse_remove(string, "notag");
23289 + return MNT_NOTAG;
23290 + case Opt_notagcheck:
23292 + __dx_parse_remove(string, "notagcheck");
23293 + return MNT_NOTAGCHECK;
23295 + if (tag && !match_int(args, &option))
23298 + __dx_parse_remove(string, "tagid");
23299 + return MNT_TAGID;
23304 +int dx_parse_tag(char *string, tag_t *tag, int remove)
23306 + int retval, flags = 0;
23308 + while ((retval = __dx_parse_tag(string, tag, remove)))
23313 +#ifdef CONFIG_PROPAGATE
23315 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
23317 + tag_t new_tag = 0;
23318 + struct vfsmount *mnt;
23327 + propagate = (mnt->mnt_flags & MNT_TAGID);
23329 + new_tag = mnt->mnt_tag;
23331 + vxdprintk(VXD_CBIT(tag, 7),
23332 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
23333 + inode, inode->i_ino, inode->i_tag,
23334 + new_tag, (propagate) ? 1 : 0);
23337 + inode->i_tag = new_tag;
23340 +#include <linux/module.h>
23342 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
23344 +#endif /* CONFIG_PROPAGATE */
23346 diff -Nurp linux-2.6.22.18/kernel/vserver/Kconfig linux-2.6.22.18-vs2.3.0.32/kernel/vserver/Kconfig
23347 --- linux-2.6.22.18/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
23348 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/Kconfig 2008-02-11 12:35:38.000000000 +0100
23351 +# Linux VServer configuration
23354 +menu "Linux VServer"
23356 +config VSERVER_AUTO_LBACK
23357 + bool "Automatically Assign Loopback IP"
23360 + Automatically assign a guest specific loopback
23361 + IP and add it to the kernel network stack on
23364 +config VSERVER_AUTO_SINGLE
23365 + bool "Automatic Single IP Special Casing"
23366 + depends on EXPERIMENTAL
23369 + This allows network contexts with a single IP to
23370 + automatically remap 0.0.0.0 bindings to that IP,
23371 + avoiding further network checks and improving
23374 + (note: such guests do not allow to change the ip
23375 + on the fly and do not show loopback addresses)
23377 +config VSERVER_COWBL
23378 + bool "Enable COW Immutable Link Breaking"
23381 + This enables the COW (Copy-On-Write) link break code.
23382 + It allows you to treat unified files like normal files
23383 + when writing to them (which will implicitely break the
23384 + link and create a copy of the unified file)
23386 +config VSERVER_VTIME
23387 + bool "Enable Virtualized Guest Time"
23388 + depends on EXPERIMENTAL
23391 + This enables per guest time offsets to allow for
23392 + adjusting the system clock individually per guest.
23393 + this adds some overhead to the time functions and
23394 + therefore should not be enabled without good reason.
23396 +config VSERVER_DEVICE
23397 + bool "Enable Guest Device Mapping"
23398 + depends on EXPERIMENTAL
23401 + This enables generic device remapping.
23403 +config VSERVER_PROC_SECURE
23404 + bool "Enable Proc Security"
23405 + depends on PROC_FS
23408 + This configures ProcFS security to initially hide
23409 + non-process entries for all contexts except the main and
23410 + spectator context (i.e. for all guests), which is a secure
23413 + (note: on 1.2x the entries were visible by default)
23415 +config VSERVER_HARDCPU
23416 + bool "Enable Hard CPU Limits"
23419 + Activate the Hard CPU Limits
23421 + This will compile in code that allows the Token Bucket
23422 + Scheduler to put processes on hold when a context's
23423 + tokens are depleted (provided that its per-context
23424 + sched_hard flag is set).
23426 + Processes belonging to that context will not be able
23427 + to consume CPU resources again until a per-context
23428 + configured minimum of tokens has been reached.
23430 +config VSERVER_IDLETIME
23431 + bool "Avoid idle CPUs by skipping Time"
23432 + depends on VSERVER_HARDCPU
23435 + This option allows the scheduler to artificially
23436 + advance time (per cpu) when otherwise the idle
23437 + task would be scheduled, thus keeping the cpu
23438 + busy and sharing the available resources among
23439 + certain contexts.
23441 +config VSERVER_IDLELIMIT
23442 + bool "Limit the IDLE task"
23443 + depends on VSERVER_HARDCPU
23446 + Limit the idle slices, so the the next context
23447 + will be scheduled as soon as possible.
23449 + This might improve interactivity and latency, but
23450 + will also marginally increase scheduling overhead.
23453 + prompt "Persistent Inode Tagging"
23454 + default TAGGING_ID24
23456 + This adds persistent context information to filesystems
23457 + mounted with the tagxid option. Tagging is a requirement
23458 + for per-context disk limits and per-context quota.
23461 +config TAGGING_NONE
23464 + do not store per-context information in inodes.
23466 +config TAGGING_UID16
23467 + bool "UID16/GID32"
23469 + reduces UID to 16 bit, but leaves GID at 32 bit.
23471 +config TAGGING_GID16
23472 + bool "UID32/GID16"
23474 + reduces GID to 16 bit, but leaves UID at 32 bit.
23476 +config TAGGING_ID24
23477 + bool "UID24/GID24"
23479 + uses the upper 8bit from UID and GID for XID tagging
23480 + which leaves 24bit for UID/GID each, which should be
23481 + more than sufficient for normal use.
23483 +config TAGGING_INTERN
23484 + bool "UID32/GID32"
23486 + this uses otherwise reserved inode fields in the on
23487 + disk representation, which limits the use to a few
23488 + filesystems (currently ext2 and ext3)
23493 + bool "Tag NFSD User Auth and Files"
23496 + Enable this if you do want the in-kernel NFS
23497 + Server to use the tagging specified above.
23498 + (will require patched clients too)
23500 +config VSERVER_PRIVACY
23501 + bool "Honor Privacy Aspects of Guests"
23504 + When enabled, most context checks will disallow
23505 + access to structures assigned to a specific context,
23506 + like ptys or loop devices.
23508 +config VSERVER_CONTEXTS
23509 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
23511 + default "768" if 64BIT
23514 + This setting will optimize certain data structures
23515 + and memory allocations according to the expected
23518 + note: this is not a strict upper limit.
23520 +config VSERVER_WARN
23521 + bool "VServer Warnings"
23524 + This enables various runtime warnings, which will
23525 + notify about potential manipulation attempts or
23526 + resource shortage. It is generally considered to
23527 + be a good idea to have that enabled.
23529 +config VSERVER_DEBUG
23530 + bool "VServer Debugging Code"
23533 + Set this to yes if you want to be able to activate
23534 + debugging output at runtime. It adds a very small
23535 + overhead to all vserver related functions and
23536 + increases the kernel size by about 20k.
23538 +config VSERVER_HISTORY
23539 + bool "VServer History Tracing"
23540 + depends on VSERVER_DEBUG
23543 + Set this to yes if you want to record the history of
23544 + linux-vserver activities, so they can be replayed in
23545 + the event of a kernel panic or oops.
23547 +config VSERVER_HISTORY_SIZE
23548 + int "Per-CPU History Size (32-65536)"
23549 + depends on VSERVER_HISTORY
23553 + This allows you to specify the number of entries in
23554 + the per-CPU history buffer.
23556 +config VSERVER_MONITOR
23557 + bool "VServer Scheduling Monitor"
23558 + depends on VSERVER_DEBUG
23561 + Set this to yes if you want to record the scheduling
23562 + decisions, so that they can be relayed to userspace
23563 + for detailed analysis.
23565 +config VSERVER_MONITOR_SIZE
23566 + int "Per-CPU Monitor Queue Size (32-65536)"
23567 + depends on VSERVER_MONITOR
23571 + This allows you to specify the number of entries in
23572 + the per-CPU scheduling monitor buffer.
23574 +config VSERVER_MONITOR_SYNC
23575 + int "Per-CPU Monitor Sync Interval (0-65536)"
23576 + depends on VSERVER_MONITOR
23580 + This allows you to specify the interval in ticks
23581 + when a time sync entry is inserted.
23593 +config VSERVER_SECURITY
23595 + depends on SECURITY
23597 + select SECURITY_CAPABILITIES
23599 diff -Nurp linux-2.6.22.18/kernel/vserver/limit.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/limit.c
23600 --- linux-2.6.22.18/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
23601 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/limit.c 2008-02-11 12:35:38.000000000 +0100
23604 + * linux/kernel/vserver/limit.c
23606 + * Virtual Server: Context Limits
23608 + * Copyright (C) 2004-2007 Herbert Pötzl
23610 + * V0.01 broken out from vcontext V0.05
23611 + * V0.02 changed vcmds to vxi arg
23615 +#include <linux/module.h>
23616 +#include <linux/vs_limit.h>
23617 +#include <linux/vserver/limit.h>
23618 +#include <linux/vserver/limit_cmd.h>
23620 +#include <asm/uaccess.h>
23623 +const char *vlimit_name[NUM_LIMITS] = {
23624 + [RLIMIT_CPU] = "CPU",
23625 + [RLIMIT_RSS] = "RSS",
23626 + [RLIMIT_NPROC] = "NPROC",
23627 + [RLIMIT_NOFILE] = "NOFILE",
23628 + [RLIMIT_MEMLOCK] = "VML",
23629 + [RLIMIT_AS] = "VM",
23630 + [RLIMIT_LOCKS] = "LOCKS",
23631 + [RLIMIT_SIGPENDING] = "SIGP",
23632 + [RLIMIT_MSGQUEUE] = "MSGQ",
23634 + [VLIMIT_NSOCK] = "NSOCK",
23635 + [VLIMIT_OPENFD] = "OPENFD",
23636 + [VLIMIT_ANON] = "ANON",
23637 + [VLIMIT_SHMEM] = "SHMEM",
23638 + [VLIMIT_DENTRY] = "DENTRY",
23641 +EXPORT_SYMBOL_GPL(vlimit_name);
23643 +#define MASK_ENTRY(x) (1 << (x))
23645 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
23648 + , /* softlimit */
23649 + MASK_ENTRY( RLIMIT_RSS ) |
23650 + MASK_ENTRY( VLIMIT_ANON ) |
23653 + MASK_ENTRY( RLIMIT_RSS ) |
23654 + MASK_ENTRY( RLIMIT_NPROC ) |
23655 + MASK_ENTRY( RLIMIT_NOFILE ) |
23656 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
23657 + MASK_ENTRY( RLIMIT_AS ) |
23658 + MASK_ENTRY( RLIMIT_LOCKS ) |
23659 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
23661 + MASK_ENTRY( VLIMIT_NSOCK ) |
23662 + MASK_ENTRY( VLIMIT_OPENFD ) |
23663 + MASK_ENTRY( VLIMIT_ANON ) |
23664 + MASK_ENTRY( VLIMIT_SHMEM ) |
23665 + MASK_ENTRY( VLIMIT_DENTRY ) |
23668 + /* accounting only */
23669 +uint32_t account_mask =
23670 + MASK_ENTRY( VLIMIT_SEMARY ) |
23671 + MASK_ENTRY( VLIMIT_NSEMS ) |
23672 + MASK_ENTRY( VLIMIT_MAPPED ) |
23676 +static int is_valid_vlimit(int id)
23678 + uint32_t mask = vlimit_mask.minimum |
23679 + vlimit_mask.softlimit | vlimit_mask.maximum;
23680 + return mask & (1 << id);
23683 +static int is_accounted_vlimit(int id)
23685 + if (is_valid_vlimit(id))
23687 + return account_mask & (1 << id);
23691 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
23693 + rlim_t limit = __rlim_soft(&vxi->limit, id);
23694 + return VX_VLIM(limit);
23697 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
23699 + rlim_t limit = __rlim_hard(&vxi->limit, id);
23700 + return VX_VLIM(limit);
23703 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
23704 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
23706 + if (!is_valid_vlimit(id))
23710 + *minimum = CRLIM_UNSET;
23712 + *softlimit = vc_get_soft(vxi, id);
23714 + *maximum = vc_get_hard(vxi, id);
23718 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
23720 + struct vcmd_ctx_rlimit_v0 vc_data;
23723 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23726 + ret = do_get_rlimit(vxi, vc_data.id,
23727 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
23731 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23736 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
23737 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
23739 + if (!is_valid_vlimit(id))
23742 + if (maximum != CRLIM_KEEP)
23743 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
23744 + if (softlimit != CRLIM_KEEP)
23745 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
23747 + /* clamp soft limit */
23748 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
23749 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
23754 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
23756 + struct vcmd_ctx_rlimit_v0 vc_data;
23758 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23761 + return do_set_rlimit(vxi, vc_data.id,
23762 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
23765 +#ifdef CONFIG_IA32_EMULATION
23767 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
23769 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
23771 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23774 + return do_set_rlimit(vxi, vc_data.id,
23775 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
23778 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
23780 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
23783 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23786 + ret = do_get_rlimit(vxi, vc_data.id,
23787 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
23791 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23796 +#endif /* CONFIG_IA32_EMULATION */
23799 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
23801 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
23807 +static inline void vx_reset_minmax(struct _vx_limit *limit)
23812 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23813 + value = __rlim_get(limit, lim);
23814 + __rlim_rmax(limit, lim) = value;
23815 + __rlim_rmin(limit, lim) = value;
23820 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
23822 + vx_reset_minmax(&vxi->limit);
23827 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
23829 + struct vcmd_rlimit_stat_v0 vc_data;
23830 + struct _vx_limit *limit = &vxi->limit;
23833 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23837 + if (!is_accounted_vlimit(id))
23840 + vx_limit_fixup(limit, id);
23841 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
23842 + vc_data.value = __rlim_get(limit, id);
23843 + vc_data.minimum = __rlim_rmin(limit, id);
23844 + vc_data.maximum = __rlim_rmax(limit, id);
23846 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23852 +void vx_vsi_meminfo(struct sysinfo *val)
23854 + struct vx_info *vxi = current->vx_info;
23855 + unsigned long totalram, freeram;
23858 + /* we blindly accept the max */
23859 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23860 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
23862 + /* total minus used equals free */
23863 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23864 + freeram = (v < totalram) ? totalram - v : 0;
23866 + val->totalram = totalram;
23867 + val->freeram = freeram;
23868 + val->bufferram = 0;
23869 + val->totalhigh = 0;
23870 + val->freehigh = 0;
23874 +void vx_vsi_swapinfo(struct sysinfo *val)
23876 + struct vx_info *vxi = current->vx_info;
23877 + unsigned long totalswap, freeswap;
23880 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23881 + if (v == RLIM_INFINITY) {
23882 + val->freeswap = val->totalswap;
23886 + /* we blindly accept the max */
23887 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
23888 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
23890 + /* currently 'used' swap */
23891 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23892 + w -= (w > v) ? v : w;
23894 + /* total minus used equals free */
23895 + freeswap = (w < totalswap) ? totalswap - w : 0;
23897 + val->totalswap = totalswap;
23898 + val->freeswap = freeswap;
23903 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
23905 + struct vx_info *vxi = mm->mm_vx_info;
23906 + unsigned long points;
23912 + points = vxi->vx_badness_bias;
23914 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23915 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23916 + points += (v > w) ? (v - w) : 0;
23921 diff -Nurp linux-2.6.22.18/kernel/vserver/limit_init.h linux-2.6.22.18-vs2.3.0.32/kernel/vserver/limit_init.h
23922 --- linux-2.6.22.18/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
23923 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/limit_init.h 2008-02-11 12:35:38.000000000 +0100
23927 +static inline void vx_info_init_limit(struct _vx_limit *limit)
23931 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23932 + __rlim_soft(limit, lim) = RLIM_INFINITY;
23933 + __rlim_hard(limit, lim) = RLIM_INFINITY;
23934 + __rlim_set(limit, lim, 0);
23935 + atomic_set(&__rlim_lhit(limit, lim), 0);
23936 + __rlim_rmin(limit, lim) = 0;
23937 + __rlim_rmax(limit, lim) = 0;
23941 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
23943 +#ifdef CONFIG_VSERVER_WARN
23947 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23948 + if ((1 << lim) & VLIM_NOCHECK)
23950 + value = __rlim_get(limit, lim);
23951 + vxwprintk_xid(value,
23952 + "!!! limit: %p[%s,%d] = %ld on exit.",
23953 + limit, vlimit_name[lim], lim, (long)value);
23958 diff -Nurp linux-2.6.22.18/kernel/vserver/limit_proc.h linux-2.6.22.18-vs2.3.0.32/kernel/vserver/limit_proc.h
23959 --- linux-2.6.22.18/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
23960 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/limit_proc.h 2008-02-11 12:35:38.000000000 +0100
23962 +#ifndef _VX_LIMIT_PROC_H
23963 +#define _VX_LIMIT_PROC_H
23965 +#include <linux/vserver/limit_int.h>
23968 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
23969 +#define VX_LIMIT_TOP \
23970 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
23972 +#define VX_LIMIT_ARG(r) \
23973 + (unsigned long)__rlim_get(limit, r), \
23974 + (unsigned long)__rlim_rmin(limit, r), \
23975 + (unsigned long)__rlim_rmax(limit, r), \
23976 + VX_VLIM(__rlim_soft(limit, r)), \
23977 + VX_VLIM(__rlim_hard(limit, r)), \
23978 + atomic_read(&__rlim_lhit(limit, r))
23980 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
23982 + vx_limit_fixup(limit, -1);
23983 + return sprintf(buffer, VX_LIMIT_TOP
23984 + "PROC" VX_LIMIT_FMT
23985 + "VM" VX_LIMIT_FMT
23986 + "VML" VX_LIMIT_FMT
23987 + "RSS" VX_LIMIT_FMT
23988 + "ANON" VX_LIMIT_FMT
23989 + "RMAP" VX_LIMIT_FMT
23990 + "FILES" VX_LIMIT_FMT
23991 + "OFD" VX_LIMIT_FMT
23992 + "LOCKS" VX_LIMIT_FMT
23993 + "SOCK" VX_LIMIT_FMT
23994 + "MSGQ" VX_LIMIT_FMT
23995 + "SHM" VX_LIMIT_FMT
23996 + "SEMA" VX_LIMIT_FMT
23997 + "SEMS" VX_LIMIT_FMT
23998 + "DENT" VX_LIMIT_FMT,
23999 + VX_LIMIT_ARG(RLIMIT_NPROC),
24000 + VX_LIMIT_ARG(RLIMIT_AS),
24001 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
24002 + VX_LIMIT_ARG(RLIMIT_RSS),
24003 + VX_LIMIT_ARG(VLIMIT_ANON),
24004 + VX_LIMIT_ARG(VLIMIT_MAPPED),
24005 + VX_LIMIT_ARG(RLIMIT_NOFILE),
24006 + VX_LIMIT_ARG(VLIMIT_OPENFD),
24007 + VX_LIMIT_ARG(RLIMIT_LOCKS),
24008 + VX_LIMIT_ARG(VLIMIT_NSOCK),
24009 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
24010 + VX_LIMIT_ARG(VLIMIT_SHMEM),
24011 + VX_LIMIT_ARG(VLIMIT_SEMARY),
24012 + VX_LIMIT_ARG(VLIMIT_NSEMS),
24013 + VX_LIMIT_ARG(VLIMIT_DENTRY));
24016 +#endif /* _VX_LIMIT_PROC_H */
24019 diff -Nurp linux-2.6.22.18/kernel/vserver/Makefile linux-2.6.22.18-vs2.3.0.32/kernel/vserver/Makefile
24020 --- linux-2.6.22.18/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
24021 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/Makefile 2008-02-11 12:35:38.000000000 +0100
24024 +# Makefile for the Linux vserver routines.
24028 +obj-y += vserver.o
24030 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
24031 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
24034 +vserver-$(CONFIG_INET) += inet.o
24035 +vserver-$(CONFIG_PROC_FS) += proc.o
24036 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
24037 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
24038 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
24039 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
24041 diff -Nurp linux-2.6.22.18/kernel/vserver/monitor.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/monitor.c
24042 --- linux-2.6.22.18/kernel/vserver/monitor.c 1970-01-01 01:00:00.000000000 +0100
24043 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/monitor.c 2008-02-11 12:35:38.000000000 +0100
24046 + * kernel/vserver/monitor.c
24048 + * Virtual Context Scheduler Monitor
24050 + * Copyright (C) 2006-2007 Herbert Pötzl
24052 + * V0.01 basic design
24056 +#include <linux/module.h>
24057 +#include <linux/jiffies.h>
24058 +#include <asm/uaccess.h>
24059 +#include <asm/atomic.h>
24061 +#include <linux/vserver/monitor.h>
24062 +#include <linux/vserver/debug_cmd.h>
24065 +#ifdef CONFIG_VSERVER_MONITOR
24066 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
24068 +#define VXM_SIZE 64
24071 +struct _vx_monitor {
24072 + unsigned int counter;
24074 + struct _vx_mon_entry entry[VXM_SIZE+1];
24078 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
24080 +unsigned volatile int vxm_active = 1;
24082 +static atomic_t sequence = ATOMIC_INIT(0);
24087 + * requires disabled preemption */
24089 +struct _vx_mon_entry *vxm_advance(int cpu)
24091 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
24092 + struct _vx_mon_entry *entry;
24093 + unsigned int index;
24095 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
24096 + entry = &mon->entry[index];
24098 + entry->ev.seq = atomic_inc_return(&sequence);
24099 + entry->ev.jif = jiffies;
24103 +EXPORT_SYMBOL_GPL(vxm_advance);
24106 +int do_read_monitor(struct __user _vx_mon_entry *data,
24107 + int cpu, uint32_t *index, uint32_t *count)
24109 + int pos, ret = 0;
24110 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
24111 + int end = mon->counter;
24112 + int start = end - VXM_SIZE + 2;
24113 + int idx = *index;
24115 + /* special case: get current pos */
24121 + /* have we lost some data? */
24125 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
24126 + struct _vx_mon_entry *entry =
24127 + &mon->entry[idx % VXM_SIZE];
24129 + /* send entry to userspace */
24130 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
24134 + /* save new index and count */
24137 + return ret ? ret : (*index < end);
24140 +int vc_read_monitor(uint32_t id, void __user *data)
24142 + struct vcmd_read_monitor_v0 vc_data;
24145 + if (id >= NR_CPUS)
24148 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24151 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
24152 + id, &vc_data.index, &vc_data.count);
24154 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24159 +#ifdef CONFIG_COMPAT
24161 +int vc_read_monitor_x32(uint32_t id, void __user *data)
24163 + struct vcmd_read_monitor_v0_x32 vc_data;
24166 + if (id >= NR_CPUS)
24169 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24172 + ret = do_read_monitor((struct __user _vx_mon_entry *)
24173 + compat_ptr(vc_data.data_ptr),
24174 + id, &vc_data.index, &vc_data.count);
24176 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24181 +#endif /* CONFIG_COMPAT */
24183 diff -Nurp linux-2.6.22.18/kernel/vserver/network.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/network.c
24184 --- linux-2.6.22.18/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
24185 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/network.c 2008-02-11 12:35:38.000000000 +0100
24188 + * linux/kernel/vserver/network.c
24190 + * Virtual Server: Network Support
24192 + * Copyright (C) 2003-2007 Herbert Pötzl
24194 + * V0.01 broken out from vcontext V0.05
24195 + * V0.02 cleaned up implementation
24196 + * V0.03 added equiv nx commands
24197 + * V0.04 switch to RCU based hash
24198 + * V0.05 and back to locking again
24199 + * V0.06 changed vcmds to nxi arg
24200 + * V0.07 have __create claim() the nxi
24204 +#include <linux/err.h>
24205 +#include <linux/slab.h>
24206 +#include <linux/rcupdate.h>
24208 +#include <linux/vs_network.h>
24209 +#include <linux/vserver/network_cmd.h>
24212 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
24213 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
24215 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
24216 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
24219 +static int __init init_network(void)
24221 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
24222 + sizeof(struct nx_addr_v4), 0, SLAB_PANIC, NULL, NULL);
24223 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
24224 + sizeof(struct nx_addr_v6), 0, SLAB_PANIC, NULL, NULL);
24229 +/* __alloc_nx_addr_v4() */
24231 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
24233 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
24234 + nx_addr_v4_cachep, GFP_KERNEL);
24236 + if (!IS_ERR(nxa))
24237 + memset(nxa, 0, sizeof(*nxa));
24241 +/* __dealloc_nx_addr_v4() */
24243 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
24245 + kmem_cache_free(nx_addr_v4_cachep, nxa);
24248 +/* __dealloc_nx_addr_v4_all() */
24250 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
24253 + struct nx_addr_v4 *next = nxa->next;
24255 + __dealloc_nx_addr_v4(nxa);
24261 +#ifdef CONFIG_IPV6
24263 +/* __alloc_nx_addr_v6() */
24265 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
24267 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
24268 + nx_addr_v6_cachep, GFP_KERNEL);
24270 + if (!IS_ERR(nxa))
24271 + memset(nxa, 0, sizeof(*nxa));
24275 +/* __dealloc_nx_addr_v6() */
24277 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
24279 + kmem_cache_free(nx_addr_v6_cachep, nxa);
24282 +/* __dealloc_nx_addr_v6_all() */
24284 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
24287 + struct nx_addr_v6 *next = nxa->next;
24289 + __dealloc_nx_addr_v6(nxa);
24294 +#endif /* CONFIG_IPV6 */
24297 +/* __alloc_nx_info()
24299 + * allocate an initialized nx_info struct
24300 + * doesn't make it visible (hash) */
24302 +static struct nx_info *__alloc_nx_info(nid_t nid)
24304 + struct nx_info *new = NULL;
24306 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
24308 + /* would this benefit from a slab cache? */
24309 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
24313 + memset(new, 0, sizeof(struct nx_info));
24314 + new->nx_id = nid;
24315 + INIT_HLIST_NODE(&new->nx_hlist);
24316 + atomic_set(&new->nx_usecnt, 0);
24317 + atomic_set(&new->nx_tasks, 0);
24318 + new->nx_state = 0;
24320 + new->nx_flags = NXF_INIT_SET;
24322 + /* rest of init goes here */
24324 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
24325 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
24327 + vxdprintk(VXD_CBIT(nid, 0),
24328 + "alloc_nx_info(%d) = %p", nid, new);
24329 + atomic_inc(&nx_global_ctotal);
24333 +/* __dealloc_nx_info()
24335 + * final disposal of nx_info */
24337 +static void __dealloc_nx_info(struct nx_info *nxi)
24339 + vxdprintk(VXD_CBIT(nid, 0),
24340 + "dealloc_nx_info(%p)", nxi);
24342 + nxi->nx_hlist.next = LIST_POISON1;
24345 + BUG_ON(atomic_read(&nxi->nx_usecnt));
24346 + BUG_ON(atomic_read(&nxi->nx_tasks));
24348 + __dealloc_nx_addr_v4_all(nxi->v4.next);
24350 + nxi->nx_state |= NXS_RELEASED;
24352 + atomic_dec(&nx_global_ctotal);
24355 +static void __shutdown_nx_info(struct nx_info *nxi)
24357 + nxi->nx_state |= NXS_SHUTDOWN;
24358 + vs_net_change(nxi, VSC_NETDOWN);
24361 +/* exported stuff */
24363 +void free_nx_info(struct nx_info *nxi)
24365 + /* context shutdown is mandatory */
24366 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
24368 + /* context must not be hashed */
24369 + BUG_ON(nxi->nx_state & NXS_HASHED);
24371 + BUG_ON(atomic_read(&nxi->nx_usecnt));
24372 + BUG_ON(atomic_read(&nxi->nx_tasks));
24374 + __dealloc_nx_info(nxi);
24378 +void __nx_set_lback(struct nx_info *nxi)
24380 + int nid = nxi->nx_id;
24381 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
24383 + nxi->v4_lback.s_addr = lback;
24386 +extern int __nx_inet_add_lback(__be32 addr);
24387 +extern int __nx_inet_del_lback(__be32 addr);
24390 +/* hash table for nx_info hash */
24392 +#define NX_HASH_SIZE 13
24394 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
24396 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
24399 +static inline unsigned int __hashval(nid_t nid)
24401 + return (nid % NX_HASH_SIZE);
24406 +/* __hash_nx_info()
24408 + * add the nxi to the global hash table
24409 + * requires the hash_lock to be held */
24411 +static inline void __hash_nx_info(struct nx_info *nxi)
24413 + struct hlist_head *head;
24415 + vxd_assert_lock(&nx_info_hash_lock);
24416 + vxdprintk(VXD_CBIT(nid, 4),
24417 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
24419 + /* context must not be hashed */
24420 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
24422 + nxi->nx_state |= NXS_HASHED;
24423 + head = &nx_info_hash[__hashval(nxi->nx_id)];
24424 + hlist_add_head(&nxi->nx_hlist, head);
24425 + atomic_inc(&nx_global_cactive);
24428 +/* __unhash_nx_info()
24430 + * remove the nxi from the global hash table
24431 + * requires the hash_lock to be held */
24433 +static inline void __unhash_nx_info(struct nx_info *nxi)
24435 + vxd_assert_lock(&nx_info_hash_lock);
24436 + vxdprintk(VXD_CBIT(nid, 4),
24437 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
24438 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
24440 + /* context must be hashed */
24441 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
24442 + /* but without tasks */
24443 + BUG_ON(atomic_read(&nxi->nx_tasks));
24445 + nxi->nx_state &= ~NXS_HASHED;
24446 + hlist_del(&nxi->nx_hlist);
24447 + atomic_dec(&nx_global_cactive);
24451 +/* __lookup_nx_info()
24453 + * requires the hash_lock to be held
24454 + * doesn't increment the nx_refcnt */
24456 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
24458 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
24459 + struct hlist_node *pos;
24460 + struct nx_info *nxi;
24462 + vxd_assert_lock(&nx_info_hash_lock);
24463 + hlist_for_each(pos, head) {
24464 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
24466 + if (nxi->nx_id == nid)
24471 + vxdprintk(VXD_CBIT(nid, 0),
24472 + "__lookup_nx_info(#%u): %p[#%u]",
24473 + nid, nxi, nxi ? nxi->nx_id : 0);
24478 +/* __create_nx_info()
24480 + * create the requested context
24481 + * get(), claim() and hash it */
24483 +static struct nx_info *__create_nx_info(int id)
24485 + struct nx_info *new, *nxi = NULL;
24487 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
24489 + if (!(new = __alloc_nx_info(id)))
24490 + return ERR_PTR(-ENOMEM);
24492 + /* required to make dynamic xids unique */
24493 + spin_lock(&nx_info_hash_lock);
24495 + /* static context requested */
24496 + if ((nxi = __lookup_nx_info(id))) {
24497 + vxdprintk(VXD_CBIT(nid, 0),
24498 + "create_nx_info(%d) = %p (already there)", id, nxi);
24499 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
24500 + nxi = ERR_PTR(-EBUSY);
24502 + nxi = ERR_PTR(-EEXIST);
24505 + /* new context */
24506 + vxdprintk(VXD_CBIT(nid, 0),
24507 + "create_nx_info(%d) = %p (new)", id, new);
24508 + claim_nx_info(new, NULL);
24509 + __nx_set_lback(new);
24510 + __hash_nx_info(get_nx_info(new));
24511 + nxi = new, new = NULL;
24514 + spin_unlock(&nx_info_hash_lock);
24516 + __dealloc_nx_info(new);
24522 +/* exported stuff */
24525 +void unhash_nx_info(struct nx_info *nxi)
24527 + __shutdown_nx_info(nxi);
24528 + spin_lock(&nx_info_hash_lock);
24529 + __unhash_nx_info(nxi);
24530 + spin_unlock(&nx_info_hash_lock);
24533 +/* lookup_nx_info()
24535 + * search for a nx_info and get() it
24536 + * negative id means current */
24538 +struct nx_info *lookup_nx_info(int id)
24540 + struct nx_info *nxi = NULL;
24543 + nxi = get_nx_info(current->nx_info);
24544 + } else if (id > 1) {
24545 + spin_lock(&nx_info_hash_lock);
24546 + nxi = get_nx_info(__lookup_nx_info(id));
24547 + spin_unlock(&nx_info_hash_lock);
24552 +/* nid_is_hashed()
24554 + * verify that nid is still hashed */
24556 +int nid_is_hashed(nid_t nid)
24560 + spin_lock(&nx_info_hash_lock);
24561 + hashed = (__lookup_nx_info(nid) != NULL);
24562 + spin_unlock(&nx_info_hash_lock);
24567 +#ifdef CONFIG_PROC_FS
24571 + * get a subset of hashed nids for proc
24572 + * assumes size is at least one */
24574 +int get_nid_list(int index, unsigned int *nids, int size)
24576 + int hindex, nr_nids = 0;
24578 + /* only show current and children */
24579 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
24582 + nids[nr_nids] = nx_current_nid();
24586 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
24587 + struct hlist_head *head = &nx_info_hash[hindex];
24588 + struct hlist_node *pos;
24590 + spin_lock(&nx_info_hash_lock);
24591 + hlist_for_each(pos, head) {
24592 + struct nx_info *nxi;
24597 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
24598 + nids[nr_nids] = nxi->nx_id;
24599 + if (++nr_nids >= size) {
24600 + spin_unlock(&nx_info_hash_lock);
24604 + /* keep the lock time short */
24605 + spin_unlock(&nx_info_hash_lock);
24614 + * migrate task to new network
24615 + * gets nxi, puts old_nxi on change
24618 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
24620 + struct nx_info *old_nxi;
24626 + vxdprintk(VXD_CBIT(nid, 5),
24627 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
24628 + p, nxi, nxi->nx_id,
24629 + atomic_read(&nxi->nx_usecnt),
24630 + atomic_read(&nxi->nx_tasks));
24632 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
24633 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
24636 + if (nx_info_state(nxi, NXS_SHUTDOWN))
24639 + /* maybe disallow this completely? */
24640 + old_nxi = task_get_nx_info(p);
24641 + if (old_nxi == nxi)
24646 + clr_nx_info(&p->nx_info);
24647 + claim_nx_info(nxi, p);
24648 + set_nx_info(&p->nx_info, nxi);
24649 + p->nid = nxi->nx_id;
24652 + vxdprintk(VXD_CBIT(nid, 5),
24653 + "moved task %p into nxi:%p[#%d]",
24654 + p, nxi, nxi->nx_id);
24657 + release_nx_info(old_nxi, p);
24660 + put_nx_info(old_nxi);
24665 +void nx_set_persistent(struct nx_info *nxi)
24667 + vxdprintk(VXD_CBIT(nid, 6),
24668 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
24670 + get_nx_info(nxi);
24671 + claim_nx_info(nxi, NULL);
24674 +void nx_clear_persistent(struct nx_info *nxi)
24676 + vxdprintk(VXD_CBIT(nid, 6),
24677 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
24679 + release_nx_info(nxi, NULL);
24680 + put_nx_info(nxi);
24683 +void nx_update_persistent(struct nx_info *nxi)
24685 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
24686 + nx_set_persistent(nxi);
24688 + nx_clear_persistent(nxi);
24691 +/* vserver syscall commands below here */
24693 +/* taks nid and nx_info functions */
24695 +#include <asm/uaccess.h>
24698 +int vc_task_nid(uint32_t id)
24703 + struct task_struct *tsk;
24705 + read_lock(&tasklist_lock);
24706 + tsk = find_task_by_real_pid(id);
24707 + nid = (tsk) ? tsk->nid : -ESRCH;
24708 + read_unlock(&tasklist_lock);
24710 + nid = nx_current_nid();
24715 +int vc_nx_info(struct nx_info *nxi, void __user *data)
24717 + struct vcmd_nx_info_v0 vc_data;
24719 + vc_data.nid = nxi->nx_id;
24721 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24727 +/* network functions */
24729 +int vc_net_create(uint32_t nid, void __user *data)
24731 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
24732 + struct nx_info *new_nxi;
24735 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24738 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
24741 + new_nxi = __create_nx_info(nid);
24742 + if (IS_ERR(new_nxi))
24743 + return PTR_ERR(new_nxi);
24745 + /* initial flags */
24746 + new_nxi->nx_flags = vc_data.flagword;
24749 + if (vs_net_change(new_nxi, VSC_NETUP))
24752 + ret = nx_migrate_task(current, new_nxi);
24756 + /* return context id on success */
24757 + ret = new_nxi->nx_id;
24759 + /* get a reference for persistent contexts */
24760 + if ((vc_data.flagword & NXF_PERSISTENT))
24761 + nx_set_persistent(new_nxi);
24763 + release_nx_info(new_nxi, NULL);
24764 + put_nx_info(new_nxi);
24769 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
24771 + return nx_migrate_task(current, nxi);
24776 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
24777 + uint16_t type, uint16_t flags)
24779 + struct nx_addr_v4 *nxa = &nxi->v4;
24781 + if (NX_IPV4(nxi)) {
24782 + /* locate last entry */
24783 + for (; nxa->next; nxa = nxa->next);
24784 + nxa->next = __alloc_nx_addr_v4();
24788 + return PTR_ERR(nxa);
24791 + if (nxi->v4.next)
24792 + /* remove single ip for ip list */
24793 + nxi->nx_flags &= ~NXF_SINGLE_IP;
24795 + nxa->ip[0].s_addr = ip;
24796 + nxa->ip[1].s_addr = ip2;
24797 + nxa->mask.s_addr = mask;
24798 + nxa->type = type;
24799 + nxa->flags = flags;
24804 +int vc_net_add(struct nx_info *nxi, void __user *data)
24806 + struct vcmd_net_addr_v0 vc_data;
24807 + int index, ret = 0;
24809 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24812 + switch (vc_data.type) {
24813 + case NXA_TYPE_IPV4:
24814 + if ((vc_data.count < 1) || (vc_data.count > 4))
24818 + while (index < vc_data.count) {
24819 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
24820 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
24828 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
24829 + nxi->v4_bcast = vc_data.ip[0];
24833 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
24834 + nxi->v4_lback = vc_data.ip[0];
24845 +int vc_net_remove(struct nx_info *nxi, void __user *data)
24847 + struct vcmd_net_addr_v0 vc_data;
24849 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24852 + switch (vc_data.type) {
24853 + case NXA_TYPE_ANY:
24854 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24855 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24865 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
24867 + struct vcmd_net_addr_ipv4_v1 vc_data;
24869 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24872 + switch (vc_data.type) {
24873 + case NXA_TYPE_ADDR:
24874 + case NXA_TYPE_RANGE:
24875 + case NXA_TYPE_MASK:
24876 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
24877 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
24879 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
24880 + nxi->v4_bcast = vc_data.ip;
24883 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
24884 + nxi->v4_lback = vc_data.ip;
24893 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
24895 + struct vcmd_net_addr_ipv4_v1 vc_data;
24897 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24900 + switch (vc_data.type) {
24901 +/* case NXA_TYPE_ADDR:
24904 + case NXA_TYPE_ANY:
24905 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24906 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24916 +#ifdef CONFIG_IPV6
24918 +int do_add_v6_addr(struct nx_info *nxi,
24919 + struct in6_addr *ip, struct in6_addr *mask,
24920 + uint32_t prefix, uint16_t type, uint16_t flags)
24922 + struct nx_addr_v6 *nxa = &nxi->v6;
24924 + if (NX_IPV6(nxi)) {
24925 + /* locate last entry */
24926 + for (; nxa->next; nxa = nxa->next);
24927 + nxa->next = __alloc_nx_addr_v6();
24931 + return PTR_ERR(nxa);
24935 + nxa->mask = *mask;
24936 + nxa->prefix = prefix;
24937 + nxa->type = type;
24938 + nxa->flags = flags;
24943 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
24945 + struct vcmd_net_addr_ipv6_v1 vc_data;
24947 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24950 + switch (vc_data.type) {
24951 + case NXA_TYPE_ADDR:
24952 + case NXA_TYPE_MASK:
24953 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
24954 + vc_data.prefix, vc_data.type, vc_data.flags);
24961 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
24963 + struct vcmd_net_addr_ipv6_v1 vc_data;
24965 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24968 + switch (vc_data.type) {
24969 + case NXA_TYPE_ANY:
24970 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
24971 + memset(&nxi->v6, 0, sizeof(nxi->v6));
24980 +#endif /* CONFIG_IPV6 */
24983 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
24985 + struct vcmd_net_flags_v0 vc_data;
24987 + vc_data.flagword = nxi->nx_flags;
24989 + /* special STATE flag handling */
24990 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
24992 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24997 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
24999 + struct vcmd_net_flags_v0 vc_data;
25000 + uint64_t mask, trigger;
25002 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25005 + /* special STATE flag handling */
25006 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
25007 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
25009 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
25010 + vc_data.flagword, mask);
25011 + if (trigger & NXF_PERSISTENT)
25012 + nx_update_persistent(nxi);
25017 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
25019 + struct vcmd_net_caps_v0 vc_data;
25021 + vc_data.ncaps = nxi->nx_ncaps;
25022 + vc_data.cmask = ~0ULL;
25024 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25029 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
25031 + struct vcmd_net_caps_v0 vc_data;
25033 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25036 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
25037 + vc_data.ncaps, vc_data.cmask);
25042 +#include <linux/module.h>
25044 +module_init(init_network);
25046 +EXPORT_SYMBOL_GPL(free_nx_info);
25047 +EXPORT_SYMBOL_GPL(unhash_nx_info);
25049 diff -Nurp linux-2.6.22.18/kernel/vserver/proc.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/proc.c
25050 --- linux-2.6.22.18/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
25051 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/proc.c 2008-02-11 12:35:38.000000000 +0100
25054 + * linux/kernel/vserver/proc.c
25056 + * Virtual Context Support
25058 + * Copyright (C) 2003-2007 Herbert Pötzl
25060 + * V0.01 basic structure
25061 + * V0.02 adaptation vs1.3.0
25062 + * V0.03 proc permissions
25063 + * V0.04 locking/generic
25064 + * V0.05 next generation procfs
25065 + * V0.06 inode validation
25066 + * V0.07 generic rewrite vid
25067 + * V0.08 remove inode type
25071 +#include <linux/proc_fs.h>
25072 +#include <asm/unistd.h>
25074 +#include <linux/vs_context.h>
25075 +#include <linux/vs_network.h>
25076 +#include <linux/vs_cvirt.h>
25077 +#include <linux/vs_inet.h>
25078 +#include <linux/vs_inet6.h>
25080 +#include <linux/vserver/global.h>
25082 +#include "cvirt_proc.h"
25083 +#include "cacct_proc.h"
25084 +#include "limit_proc.h"
25085 +#include "sched_proc.h"
25086 +#include "vci_config.h"
25088 +static struct proc_dir_entry *proc_virtual;
25090 +static struct proc_dir_entry *proc_virtnet;
25093 +/* first the actual feeds */
25096 +static int proc_vci(char *buffer)
25098 + return sprintf(buffer,
25099 + "VCIVersion:\t%04x:%04x\n"
25100 + "VCISyscall:\t%d\n"
25101 + "VCIKernel:\t%08x\n",
25102 + VCI_VERSION >> 16,
25103 + VCI_VERSION & 0xFFFF,
25105 + vci_kernel_config());
25108 +static int proc_virtual_info(char *buffer)
25110 + return proc_vci(buffer);
25113 +static int proc_virtual_status(char *buffer)
25115 + return sprintf(buffer,
25117 + "#CActive:\t%d\n"
25118 + "#NSProxy:\t%d\t%d %d %d %d\n",
25119 + atomic_read(&vx_global_ctotal),
25120 + atomic_read(&vx_global_cactive),
25121 + atomic_read(&vs_global_nsproxy),
25122 + atomic_read(&vs_global_fs),
25123 + atomic_read(&vs_global_mnt_ns),
25124 + atomic_read(&vs_global_uts_ns),
25125 + atomic_read(&vs_global_ipc_ns));
25129 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
25133 + length = sprintf(buffer,
25141 + vxi->vx_badness_bias);
25145 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
25149 + length = sprintf(buffer,
25152 + "Flags:\t%016llx\n"
25153 + "BCaps:\t%016llx\n"
25154 + "CCaps:\t%016llx\n"
25155 + "Spaces:\t%08lx\n",
25156 + atomic_read(&vxi->vx_usecnt),
25157 + atomic_read(&vxi->vx_tasks),
25158 + (unsigned long long)vxi->vx_flags,
25159 + (unsigned long long)vxi->vx_bcaps,
25160 + (unsigned long long)vxi->vx_ccaps,
25165 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
25167 + return vx_info_proc_limit(&vxi->limit, buffer);
25170 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
25174 + length = vx_info_proc_sched(&vxi->sched, buffer);
25175 + for_each_online_cpu(cpu) {
25176 + length += vx_info_proc_sched_pc(
25177 + &vx_per_cpu(vxi, sched_pc, cpu),
25178 + buffer + length, cpu);
25183 +int proc_vxi_nsproxy(struct vx_info *vxi, char *buffer)
25185 + return vx_info_proc_nsproxy(vxi->vx_nsproxy, buffer);
25188 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
25192 + vx_update_load(vxi);
25193 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
25194 + for_each_online_cpu(cpu) {
25195 + length += vx_info_proc_cvirt_pc(
25196 + &vx_per_cpu(vxi, cvirt_pc, cpu),
25197 + buffer + length, cpu);
25202 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
25204 + return vx_info_proc_cacct(&vxi->cacct, buffer);
25208 +static int proc_virtnet_info(char *buffer)
25210 + return proc_vci(buffer);
25213 +static int proc_virtnet_status(char *buffer)
25215 + return sprintf(buffer,
25217 + "#CActive:\t%d\n",
25218 + atomic_read(&nx_global_ctotal),
25219 + atomic_read(&nx_global_cactive));
25222 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
25224 + struct nx_addr_v4 *v4a;
25225 +#ifdef CONFIG_IPV6
25226 + struct nx_addr_v6 *v6a;
25230 + length = sprintf(buffer,
25233 + "Bcast:\t" NIPQUAD_FMT "\n"
25234 + "Lback:\t" NIPQUAD_FMT "\n",
25237 + NIPQUAD(nxi->v4_bcast.s_addr),
25238 + NIPQUAD(nxi->v4_lback.s_addr));
25240 + if (!NX_IPV4(nxi))
25242 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
25243 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
25246 +#ifdef CONFIG_IPV6
25247 + if (!NX_IPV6(nxi))
25249 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
25250 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
25257 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
25261 + length = sprintf(buffer,
25264 + "Flags:\t%016llx\n"
25265 + "NCaps:\t%016llx\n",
25266 + atomic_read(&nxi->nx_usecnt),
25267 + atomic_read(&nxi->nx_tasks),
25268 + (unsigned long long)nxi->nx_flags,
25269 + (unsigned long long)nxi->nx_ncaps);
25275 +/* here the inode helpers */
25281 + struct inode_operations *iop;
25282 + struct file_operations *fop;
25283 + union proc_op op;
25286 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
25288 + struct inode *inode = new_inode(sb);
25293 + inode->i_mode = p->mode;
25295 + inode->i_op = p->iop;
25297 + inode->i_fop = p->fop;
25299 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
25300 + inode->i_flags |= S_IMMUTABLE;
25302 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
25304 + inode->i_uid = 0;
25305 + inode->i_gid = 0;
25306 + inode->i_tag = 0;
25311 +static struct dentry *vs_proc_instantiate(struct inode *dir,
25312 + struct dentry *dentry, int id, void *ptr)
25314 + struct vs_entry *p = ptr;
25315 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
25316 + struct dentry *error = ERR_PTR(-EINVAL);
25321 + PROC_I(inode)->op = p->op;
25322 + PROC_I(inode)->fd = id;
25323 + d_add(dentry, inode);
25331 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
25334 + * Fill a directory entry.
25336 + * If possible create the dcache entry and derive our inode number and
25337 + * file type from dcache entry.
25339 + * Since all of the proc inode numbers are dynamically generated, the inode
25340 + * numbers do not exist until the inode is cache. This means creating the
25341 + * the dcache entry in readdir is necessary to keep the inode numbers
25342 + * reported by readdir in sync with the inode numbers reported
25345 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
25346 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
25348 + struct dentry *child, *dir = filp->f_dentry;
25349 + struct inode *inode;
25350 + struct qstr qname;
25352 + unsigned type = DT_UNKNOWN;
25354 + qname.name = name;
25356 + qname.hash = full_name_hash(name, len);
25358 + child = d_lookup(dir, &qname);
25360 + struct dentry *new;
25361 + new = d_alloc(dir, &qname);
25363 + child = instantiate(dir->d_inode, new, id, ptr);
25370 + if (!child || IS_ERR(child) || !child->d_inode)
25371 + goto end_instantiate;
25372 + inode = child->d_inode;
25374 + ino = inode->i_ino;
25375 + type = inode->i_mode >> 12;
25380 + ino = find_inode_number(dir, &qname);
25383 + return filldir(dirent, name, len, filp->f_pos, ino, type);
25388 +/* get and revalidate vx_info/xid */
25391 +struct vx_info *get_proc_vx_info(struct inode *inode)
25393 + return lookup_vx_info(PROC_I(inode)->fd);
25396 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
25398 + struct inode *inode = dentry->d_inode;
25399 + xid_t xid = PROC_I(inode)->fd;
25401 + if (!xid || xid_is_hashed(xid))
25408 +/* get and revalidate nx_info/nid */
25410 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
25412 + struct inode *inode = dentry->d_inode;
25413 + nid_t nid = PROC_I(inode)->fd;
25415 + if (!nid || nid_is_hashed(nid))
25423 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
25425 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
25426 + size_t count, loff_t *ppos)
25428 + struct inode *inode = file->f_dentry->d_inode;
25429 + unsigned long page;
25430 + ssize_t length = 0;
25432 + if (count > PROC_BLOCK_SIZE)
25433 + count = PROC_BLOCK_SIZE;
25435 + /* fade that out as soon as stable */
25436 + WARN_ON(PROC_I(inode)->fd);
25438 + if (!(page = __get_free_page(GFP_KERNEL)))
25441 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
25442 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
25445 + length = simple_read_from_buffer(buf, count, ppos,
25446 + (char *)page, length);
25452 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
25453 + size_t count, loff_t *ppos)
25455 + struct inode *inode = file->f_dentry->d_inode;
25456 + struct vx_info *vxi = NULL;
25457 + xid_t xid = PROC_I(inode)->fd;
25458 + unsigned long page;
25459 + ssize_t length = 0;
25461 + if (count > PROC_BLOCK_SIZE)
25462 + count = PROC_BLOCK_SIZE;
25464 + /* fade that out as soon as stable */
25466 + vxi = lookup_vx_info(xid);
25470 + length = -ENOMEM;
25471 + if (!(page = __get_free_page(GFP_KERNEL)))
25474 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
25475 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
25478 + length = simple_read_from_buffer(buf, count, ppos,
25479 + (char *)page, length);
25483 + put_vx_info(vxi);
25488 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
25489 + size_t count, loff_t *ppos)
25491 + struct inode *inode = file->f_dentry->d_inode;
25492 + struct nx_info *nxi = NULL;
25493 + nid_t nid = PROC_I(inode)->fd;
25494 + unsigned long page;
25495 + ssize_t length = 0;
25497 + if (count > PROC_BLOCK_SIZE)
25498 + count = PROC_BLOCK_SIZE;
25500 + /* fade that out as soon as stable */
25502 + nxi = lookup_nx_info(nid);
25506 + length = -ENOMEM;
25507 + if (!(page = __get_free_page(GFP_KERNEL)))
25510 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
25511 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
25514 + length = simple_read_from_buffer(buf, count, ppos,
25515 + (char *)page, length);
25519 + put_nx_info(nxi);
25526 +/* here comes the lower level */
25529 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
25530 + .len = sizeof(NAME) - 1, \
25531 + .name = (NAME), \
25539 +#define DIR(NAME, MODE, OTYPE) \
25540 + NOD(NAME, (S_IFDIR | (MODE)), \
25541 + &proc_ ## OTYPE ## _inode_operations, \
25542 + &proc_ ## OTYPE ## _file_operations, { } )
25544 +#define INF(NAME, MODE, OTYPE) \
25545 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25546 + &proc_vs_info_file_operations, \
25547 + { .proc_vs_read = &proc_##OTYPE } )
25549 +#define VINF(NAME, MODE, OTYPE) \
25550 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25551 + &proc_vx_info_file_operations, \
25552 + { .proc_vxi_read = &proc_##OTYPE } )
25554 +#define NINF(NAME, MODE, OTYPE) \
25555 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25556 + &proc_nx_info_file_operations, \
25557 + { .proc_nxi_read = &proc_##OTYPE } )
25560 +static struct file_operations proc_vs_info_file_operations = {
25561 + .read = proc_vs_info_read,
25564 +static struct file_operations proc_vx_info_file_operations = {
25565 + .read = proc_vx_info_read,
25568 +static struct dentry_operations proc_xid_dentry_operations = {
25569 + .d_revalidate = proc_xid_revalidate,
25572 +static struct vs_entry vx_base_stuff[] = {
25573 + VINF("info", S_IRUGO, vxi_info),
25574 + VINF("status", S_IRUGO, vxi_status),
25575 + VINF("limit", S_IRUGO, vxi_limit),
25576 + VINF("sched", S_IRUGO, vxi_sched),
25577 + VINF("nsproxy", S_IRUGO, vxi_nsproxy),
25578 + VINF("cvirt", S_IRUGO, vxi_cvirt),
25579 + VINF("cacct", S_IRUGO, vxi_cacct),
25586 +static struct dentry *proc_xid_instantiate(struct inode *dir,
25587 + struct dentry *dentry, int id, void *ptr)
25589 + dentry->d_op = &proc_xid_dentry_operations;
25590 + return vs_proc_instantiate(dir, dentry, id, ptr);
25593 +static struct dentry *proc_xid_lookup(struct inode *dir,
25594 + struct dentry *dentry, struct nameidata *nd)
25596 + struct vs_entry *p = vx_base_stuff;
25597 + struct dentry *error = ERR_PTR(-ENOENT);
25599 + for (; p->name; p++) {
25600 + if (p->len != dentry->d_name.len)
25602 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25608 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
25613 +static int proc_xid_readdir(struct file *filp,
25614 + void *dirent, filldir_t filldir)
25616 + struct dentry *dentry = filp->f_dentry;
25617 + struct inode *inode = dentry->d_inode;
25618 + struct vs_entry *p = vx_base_stuff;
25619 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
25623 + pos = filp->f_pos;
25626 + ino = inode->i_ino;
25627 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25630 + /* fall through */
25632 + ino = parent_ino(dentry);
25633 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25636 + /* fall through */
25639 + if (index >= size)
25641 + for (p += index; p->name; p++) {
25642 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25643 + vs_proc_instantiate, PROC_I(inode)->fd, p))
25649 + filp->f_pos = pos;
25655 +static struct file_operations proc_nx_info_file_operations = {
25656 + .read = proc_nx_info_read,
25659 +static struct dentry_operations proc_nid_dentry_operations = {
25660 + .d_revalidate = proc_nid_revalidate,
25663 +static struct vs_entry nx_base_stuff[] = {
25664 + NINF("info", S_IRUGO, nxi_info),
25665 + NINF("status", S_IRUGO, nxi_status),
25670 +static struct dentry *proc_nid_instantiate(struct inode *dir,
25671 + struct dentry *dentry, int id, void *ptr)
25673 + dentry->d_op = &proc_nid_dentry_operations;
25674 + return vs_proc_instantiate(dir, dentry, id, ptr);
25677 +static struct dentry *proc_nid_lookup(struct inode *dir,
25678 + struct dentry *dentry, struct nameidata *nd)
25680 + struct vs_entry *p = nx_base_stuff;
25681 + struct dentry *error = ERR_PTR(-ENOENT);
25683 + for (; p->name; p++) {
25684 + if (p->len != dentry->d_name.len)
25686 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25692 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
25697 +static int proc_nid_readdir(struct file *filp,
25698 + void *dirent, filldir_t filldir)
25700 + struct dentry *dentry = filp->f_dentry;
25701 + struct inode *inode = dentry->d_inode;
25702 + struct vs_entry *p = nx_base_stuff;
25703 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
25707 + pos = filp->f_pos;
25710 + ino = inode->i_ino;
25711 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25714 + /* fall through */
25716 + ino = parent_ino(dentry);
25717 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25720 + /* fall through */
25723 + if (index >= size)
25725 + for (p += index; p->name; p++) {
25726 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25727 + vs_proc_instantiate, PROC_I(inode)->fd, p))
25733 + filp->f_pos = pos;
25738 +#define MAX_MULBY10 ((~0U - 9) / 10)
25740 +static inline int atovid(const char *str, int len)
25745 + while (len-- > 0) {
25750 + if (vid >= MAX_MULBY10)
25760 +/* now the upper level (virtual) */
25763 +static struct file_operations proc_xid_file_operations = {
25764 + .read = generic_read_dir,
25765 + .readdir = proc_xid_readdir,
25768 +static struct inode_operations proc_xid_inode_operations = {
25769 + .lookup = proc_xid_lookup,
25772 +static struct vs_entry vx_virtual_stuff[] = {
25773 + INF("info", S_IRUGO, virtual_info),
25774 + INF("status", S_IRUGO, virtual_status),
25775 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
25779 +static struct dentry *proc_virtual_lookup(struct inode *dir,
25780 + struct dentry *dentry, struct nameidata *nd)
25782 + struct vs_entry *p = vx_virtual_stuff;
25783 + struct dentry *error = ERR_PTR(-ENOENT);
25786 + for (; p->name; p++) {
25787 + if (p->len != dentry->d_name.len)
25789 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25793 + goto instantiate;
25795 + id = atovid(dentry->d_name.name, dentry->d_name.len);
25796 + if ((id < 0) || !xid_is_hashed(id))
25800 + error = proc_xid_instantiate(dir, dentry, id, p);
25805 +static struct file_operations proc_nid_file_operations = {
25806 + .read = generic_read_dir,
25807 + .readdir = proc_nid_readdir,
25810 +static struct inode_operations proc_nid_inode_operations = {
25811 + .lookup = proc_nid_lookup,
25814 +static struct vs_entry nx_virtnet_stuff[] = {
25815 + INF("info", S_IRUGO, virtnet_info),
25816 + INF("status", S_IRUGO, virtnet_status),
25817 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
25821 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
25822 + struct dentry *dentry, struct nameidata *nd)
25824 + struct vs_entry *p = nx_virtnet_stuff;
25825 + struct dentry *error = ERR_PTR(-ENOENT);
25828 + for (; p->name; p++) {
25829 + if (p->len != dentry->d_name.len)
25831 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25835 + goto instantiate;
25837 + id = atovid(dentry->d_name.name, dentry->d_name.len);
25838 + if ((id < 0) || !nid_is_hashed(id))
25842 + error = proc_nid_instantiate(dir, dentry, id, p);
25849 +#define PROC_NUMBUF 10
25850 +#define PROC_MAXVIDS 32
25852 +int proc_virtual_readdir(struct file *filp,
25853 + void *dirent, filldir_t filldir)
25855 + struct dentry *dentry = filp->f_dentry;
25856 + struct inode *inode = dentry->d_inode;
25857 + struct vs_entry *p = vx_virtual_stuff;
25858 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
25860 + unsigned int xid_array[PROC_MAXVIDS];
25861 + char buf[PROC_NUMBUF];
25862 + unsigned int nr_xids, i;
25865 + pos = filp->f_pos;
25868 + ino = inode->i_ino;
25869 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25872 + /* fall through */
25874 + ino = parent_ino(dentry);
25875 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25878 + /* fall through */
25881 + if (index >= size)
25883 + for (p += index; p->name; p++) {
25884 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25885 + vs_proc_instantiate, 0, p))
25890 + index = pos - size;
25891 + p = &vx_virtual_stuff[size - 1];
25892 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
25893 + for (i = 0; i < nr_xids; i++) {
25894 + int n, xid = xid_array[i];
25895 + unsigned int j = PROC_NUMBUF;
25899 + buf[--j] = '0' + (n % 10);
25902 + if (proc_fill_cache(filp, dirent, filldir,
25903 + buf + j, PROC_NUMBUF - j,
25904 + vs_proc_instantiate, xid, p))
25910 + filp->f_pos = pos;
25914 +static int proc_virtual_getattr(struct vfsmount *mnt,
25915 + struct dentry *dentry, struct kstat *stat)
25917 + struct inode *inode = dentry->d_inode;
25919 + generic_fillattr(inode, stat);
25920 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
25924 +static struct file_operations proc_virtual_dir_operations = {
25925 + .read = generic_read_dir,
25926 + .readdir = proc_virtual_readdir,
25929 +static struct inode_operations proc_virtual_dir_inode_operations = {
25930 + .getattr = proc_virtual_getattr,
25931 + .lookup = proc_virtual_lookup,
25938 +int proc_virtnet_readdir(struct file *filp,
25939 + void *dirent, filldir_t filldir)
25941 + struct dentry *dentry = filp->f_dentry;
25942 + struct inode *inode = dentry->d_inode;
25943 + struct vs_entry *p = nx_virtnet_stuff;
25944 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
25946 + unsigned int nid_array[PROC_MAXVIDS];
25947 + char buf[PROC_NUMBUF];
25948 + unsigned int nr_nids, i;
25951 + pos = filp->f_pos;
25954 + ino = inode->i_ino;
25955 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25958 + /* fall through */
25960 + ino = parent_ino(dentry);
25961 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25964 + /* fall through */
25967 + if (index >= size)
25969 + for (p += index; p->name; p++) {
25970 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25971 + vs_proc_instantiate, 0, p))
25976 + index = pos - size;
25977 + p = &nx_virtnet_stuff[size - 1];
25978 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
25979 + for (i = 0; i < nr_nids; i++) {
25980 + int n, nid = nid_array[i];
25981 + unsigned int j = PROC_NUMBUF;
25985 + buf[--j] = '0' + (n % 10);
25988 + if (proc_fill_cache(filp, dirent, filldir,
25989 + buf + j, PROC_NUMBUF - j,
25990 + vs_proc_instantiate, nid, p))
25996 + filp->f_pos = pos;
26000 +static int proc_virtnet_getattr(struct vfsmount *mnt,
26001 + struct dentry *dentry, struct kstat *stat)
26003 + struct inode *inode = dentry->d_inode;
26005 + generic_fillattr(inode, stat);
26006 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
26010 +static struct file_operations proc_virtnet_dir_operations = {
26011 + .read = generic_read_dir,
26012 + .readdir = proc_virtnet_readdir,
26015 +static struct inode_operations proc_virtnet_dir_inode_operations = {
26016 + .getattr = proc_virtnet_getattr,
26017 + .lookup = proc_virtnet_lookup,
26022 +void proc_vx_init(void)
26024 + struct proc_dir_entry *ent;
26026 + ent = proc_mkdir("virtual", 0);
26028 + ent->proc_fops = &proc_virtual_dir_operations;
26029 + ent->proc_iops = &proc_virtual_dir_inode_operations;
26031 + proc_virtual = ent;
26033 + ent = proc_mkdir("virtnet", 0);
26035 + ent->proc_fops = &proc_virtnet_dir_operations;
26036 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
26038 + proc_virtnet = ent;
26044 +/* per pid info */
26047 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
26049 + struct vx_info *vxi;
26050 + char *orig = buffer;
26052 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
26054 + vxi = task_get_vx_info(p);
26058 + buffer += sprintf(buffer, "BCaps:\t%016llx\n",
26059 + (unsigned long long)vxi->vx_bcaps);
26060 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
26061 + (unsigned long long)vxi->vx_ccaps);
26062 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
26063 + (unsigned long long)vxi->vx_flags);
26064 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
26066 + put_vx_info(vxi);
26068 + return buffer - orig;
26072 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
26074 + struct nx_info *nxi;
26075 + struct nx_addr_v4 *v4a;
26076 +#ifdef CONFIG_IPV6
26077 + struct nx_addr_v6 *v6a;
26079 + char *orig = buffer;
26082 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
26084 + nxi = task_get_nx_info(p);
26088 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
26089 + (unsigned long long)nxi->nx_ncaps);
26090 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
26091 + (unsigned long long)nxi->nx_flags);
26093 + buffer += sprintf(buffer,
26094 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
26095 + NIPQUAD(nxi->v4_bcast.s_addr));
26096 + buffer += sprintf (buffer,
26097 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
26098 + NIPQUAD(nxi->v4_lback.s_addr));
26099 + if (!NX_IPV4(nxi))
26101 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
26102 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
26105 +#ifdef CONFIG_IPV6
26106 + if (!NX_IPV6(nxi))
26108 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
26109 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
26113 + put_nx_info(nxi);
26115 + return buffer - orig;
26118 diff -Nurp linux-2.6.22.18/kernel/vserver/sched.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/sched.c
26119 --- linux-2.6.22.18/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
26120 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/sched.c 2008-02-11 12:35:38.000000000 +0100
26123 + * linux/kernel/vserver/sched.c
26125 + * Virtual Server: Scheduler Support
26127 + * Copyright (C) 2004-2007 Herbert Pötzl
26129 + * V0.01 adapted Sam Vilains version to 2.6.3
26130 + * V0.02 removed legacy interface
26131 + * V0.03 changed vcmds to vxi arg
26132 + * V0.04 removed older and legacy interfaces
26136 +#include <linux/vs_context.h>
26137 +#include <linux/vs_sched.h>
26138 +#include <linux/vserver/sched_cmd.h>
26140 +#include <asm/uaccess.h>
26143 +#define vxd_check_range(val, min, max) do { \
26144 + vxlprintk((val < min) || (val > max), \
26145 + "check_range(%ld,%ld,%ld)", \
26146 + (long)val, (long)min, (long)max, \
26147 + __FILE__, __LINE__); \
26151 +void vx_update_sched_param(struct _vx_sched *sched,
26152 + struct _vx_sched_pc *sched_pc)
26154 + unsigned int set_mask = sched->update_mask;
26156 + if (set_mask & VXSM_FILL_RATE)
26157 + sched_pc->fill_rate[0] = sched->fill_rate[0];
26158 + if (set_mask & VXSM_INTERVAL)
26159 + sched_pc->interval[0] = sched->interval[0];
26160 + if (set_mask & VXSM_FILL_RATE2)
26161 + sched_pc->fill_rate[1] = sched->fill_rate[1];
26162 + if (set_mask & VXSM_INTERVAL2)
26163 + sched_pc->interval[1] = sched->interval[1];
26164 + if (set_mask & VXSM_TOKENS)
26165 + sched_pc->tokens = sched->tokens;
26166 + if (set_mask & VXSM_TOKENS_MIN)
26167 + sched_pc->tokens_min = sched->tokens_min;
26168 + if (set_mask & VXSM_TOKENS_MAX)
26169 + sched_pc->tokens_max = sched->tokens_max;
26170 + if (set_mask & VXSM_PRIO_BIAS)
26171 + sched_pc->prio_bias = sched->prio_bias;
26173 + if (set_mask & VXSM_IDLE_TIME)
26174 + sched_pc->flags |= VXSF_IDLE_TIME;
26176 + sched_pc->flags &= ~VXSF_IDLE_TIME;
26179 + sched_pc->norm_time = jiffies;
26184 + * recalculate the context's scheduling tokens
26186 + * ret > 0 : number of tokens available
26187 + * ret < 0 : on hold, check delta_min[]
26188 + * -1 only jiffies
26189 + * -2 also idle time
26192 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
26193 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
26197 + int flags = sched_pc->flags;
26199 + /* how much time did pass? */
26200 + delta = *norm_time - sched_pc->norm_time;
26201 + vxd_check_range(delta, 0, INT_MAX);
26203 + if (delta >= sched_pc->interval[0]) {
26204 + long tokens, integral;
26206 + /* calc integral token part */
26207 + tokens = delta / sched_pc->interval[0];
26208 + integral = tokens * sched_pc->interval[0];
26209 + tokens *= sched_pc->fill_rate[0];
26210 +#ifdef CONFIG_VSERVER_HARDCPU
26211 + delta_min[0] = delta - integral;
26212 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
26214 + /* advance time */
26215 + sched_pc->norm_time += delta;
26218 + sched_pc->tokens += tokens;
26219 + sched_pc->token_time += tokens;
26221 + delta_min[0] = delta;
26223 +#ifdef CONFIG_VSERVER_IDLETIME
26224 + if (!(flags & VXSF_IDLE_TIME))
26227 + /* how much was the idle skip? */
26228 + delta = *idle_time - sched_pc->idle_time;
26229 + vxd_check_range(delta, 0, INT_MAX);
26231 + if (delta >= sched_pc->interval[1]) {
26232 + long tokens, integral;
26234 + /* calc fair share token part */
26235 + tokens = delta / sched_pc->interval[1];
26236 + integral = tokens * sched_pc->interval[1];
26237 + tokens *= sched_pc->fill_rate[1];
26238 + delta_min[1] = delta - integral;
26239 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
26241 + /* advance idle time */
26242 + sched_pc->idle_time += integral;
26245 + sched_pc->tokens += tokens;
26246 + sched_pc->token_time += tokens;
26248 + delta_min[1] = delta;
26252 + /* clip at maximum */
26253 + if (sched_pc->tokens > sched_pc->tokens_max)
26254 + sched_pc->tokens = sched_pc->tokens_max;
26255 + tokens = sched_pc->tokens;
26257 + if ((flags & VXSF_ONHOLD)) {
26258 + /* can we unhold? */
26259 + if (tokens >= sched_pc->tokens_min) {
26260 + flags &= ~VXSF_ONHOLD;
26261 + sched_pc->hold_ticks +=
26262 + *norm_time - sched_pc->onhold;
26266 + /* put on hold? */
26267 + if (tokens <= 0) {
26268 + flags |= VXSF_ONHOLD;
26269 + sched_pc->onhold = *norm_time;
26273 + sched_pc->flags = flags;
26277 + tokens = sched_pc->tokens_min - tokens;
26278 + sched_pc->flags = flags;
26279 + BUG_ON(tokens < 0);
26281 +#ifdef CONFIG_VSERVER_HARDCPU
26282 + /* next interval? */
26283 + if (!sched_pc->fill_rate[0])
26284 + delta_min[0] = HZ;
26285 + else if (tokens > sched_pc->fill_rate[0])
26286 + delta_min[0] += sched_pc->interval[0] *
26287 + tokens / sched_pc->fill_rate[0];
26289 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
26290 + vxd_check_range(delta_min[0], 0, INT_MAX);
26292 +#ifdef CONFIG_VSERVER_IDLETIME
26293 + if (!(flags & VXSF_IDLE_TIME))
26296 + /* next interval? */
26297 + if (!sched_pc->fill_rate[1])
26298 + delta_min[1] = HZ;
26299 + else if (tokens > sched_pc->fill_rate[1])
26300 + delta_min[1] += sched_pc->interval[1] *
26301 + tokens / sched_pc->fill_rate[1];
26303 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
26304 + vxd_check_range(delta_min[1], 0, INT_MAX);
26309 +#endif /* CONFIG_VSERVER_IDLETIME */
26312 +#endif /* CONFIG_VSERVER_HARDCPU */
26315 +static inline unsigned long msec_to_ticks(unsigned long msec)
26317 + return msecs_to_jiffies(msec);
26320 +static inline unsigned long ticks_to_msec(unsigned long ticks)
26322 + return jiffies_to_msecs(ticks);
26325 +static inline unsigned long ticks_to_usec(unsigned long ticks)
26327 + return jiffies_to_usecs(ticks);
26331 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
26333 + unsigned int set_mask = data->mask;
26334 + unsigned int update_mask;
26337 + /* Sanity check data values */
26338 + if (data->tokens_max <= 0)
26339 + data->tokens_max = HZ;
26340 + if (data->tokens_min < 0)
26341 + data->tokens_min = HZ / 3;
26342 + if (data->tokens_min >= data->tokens_max)
26343 + data->tokens_min = data->tokens_max;
26345 + if (data->prio_bias > MAX_PRIO_BIAS)
26346 + data->prio_bias = MAX_PRIO_BIAS;
26347 + if (data->prio_bias < MIN_PRIO_BIAS)
26348 + data->prio_bias = MIN_PRIO_BIAS;
26350 + spin_lock(&vxi->sched.tokens_lock);
26352 + /* sync up on delayed updates */
26353 + for_each_cpu_mask(cpu, vxi->sched.update)
26354 + vx_update_sched_param(&vxi->sched,
26355 + &vx_per_cpu(vxi, sched_pc, cpu));
26357 + if (set_mask & VXSM_FILL_RATE)
26358 + vxi->sched.fill_rate[0] = data->fill_rate[0];
26359 + if (set_mask & VXSM_FILL_RATE2)
26360 + vxi->sched.fill_rate[1] = data->fill_rate[1];
26361 + if (set_mask & VXSM_INTERVAL)
26362 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
26363 + msec_to_ticks(data->interval[0]) : data->interval[0];
26364 + if (set_mask & VXSM_INTERVAL2)
26365 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
26366 + msec_to_ticks(data->interval[1]) : data->interval[1];
26367 + if (set_mask & VXSM_TOKENS)
26368 + vxi->sched.tokens = data->tokens;
26369 + if (set_mask & VXSM_TOKENS_MIN)
26370 + vxi->sched.tokens_min = data->tokens_min;
26371 + if (set_mask & VXSM_TOKENS_MAX)
26372 + vxi->sched.tokens_max = data->tokens_max;
26373 + if (set_mask & VXSM_PRIO_BIAS)
26374 + vxi->sched.prio_bias = data->prio_bias;
26376 + /* Sanity check rate/interval */
26377 + for (i = 0; i < 2; i++) {
26378 + if (data->fill_rate[i] < 0)
26379 + data->fill_rate[i] = 0;
26380 + if (data->interval[i] <= 0)
26381 + data->interval[i] = HZ;
26384 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
26385 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
26386 + vxi->sched.update_mask = update_mask;
26390 + if (set_mask & VXSM_CPU_ID) {
26391 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
26392 + cpus_and(vxi->sched.update, cpu_online_map,
26393 + vxi->sched.update);
26395 + vxi->sched.update = cpu_online_map;
26397 + /* forced reload? */
26398 + if (set_mask & VXSM_FORCE) {
26399 + for_each_cpu_mask(cpu, vxi->sched.update)
26400 + vx_update_sched_param(&vxi->sched,
26401 + &vx_per_cpu(vxi, sched_pc, cpu));
26402 + vxi->sched.update = CPU_MASK_NONE;
26405 + /* on UP we update immediately */
26406 + vx_update_sched_param(&vxi->sched,
26407 + &vx_per_cpu(vxi, sched_pc, 0));
26410 + spin_unlock(&vxi->sched.tokens_lock);
26415 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
26416 +#define COPY_PRI(C) C(prio_bias)
26417 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
26418 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
26419 + C(fill_rate[1]); C(interval[1]);
26421 +#define COPY_VALUE(name) vc_data.name = data->name
26423 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
26425 + struct vcmd_sched_v5 vc_data;
26427 + vc_data.mask = data->set_mask;
26428 + COPY_IDS(COPY_VALUE);
26429 + COPY_PRI(COPY_VALUE);
26430 + COPY_TOK(COPY_VALUE);
26431 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
26432 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
26433 + return do_set_sched(vxi, &vc_data);
26436 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
26438 + struct vcmd_set_sched_v4 vc_data;
26440 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26443 + return do_set_sched_v4(vxi, &vc_data);
26446 + /* latest interface is v5 */
26448 +int vc_set_sched(struct vx_info *vxi, void __user *data)
26450 + struct vcmd_sched_v5 vc_data;
26452 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26455 + return do_set_sched(vxi, &vc_data);
26459 +#define COPY_PRI(C) C(prio_bias)
26460 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
26461 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
26462 + C(fill_rate[1]); C(interval[1]);
26464 +#define COPY_VALUE(name) vc_data.name = data->name
26467 +int vc_get_sched(struct vx_info *vxi, void __user *data)
26469 + struct vcmd_sched_v5 vc_data;
26471 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26474 + if (vc_data.mask & VXSM_CPU_ID) {
26475 + int cpu = vc_data.cpu_id;
26476 + struct _vx_sched_pc *data;
26478 + if (!cpu_possible(cpu))
26481 + data = &vx_per_cpu(vxi, sched_pc, cpu);
26482 + COPY_TOK(COPY_VALUE);
26483 + COPY_PRI(COPY_VALUE);
26484 + COPY_FRI(COPY_VALUE);
26486 + if (data->flags & VXSF_IDLE_TIME)
26487 + vc_data.mask |= VXSM_IDLE_TIME;
26489 + struct _vx_sched *data = &vxi->sched;
26491 + COPY_TOK(COPY_VALUE);
26492 + COPY_PRI(COPY_VALUE);
26493 + COPY_FRI(COPY_VALUE);
26496 + if (vc_data.mask & VXSM_MSEC) {
26497 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
26498 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
26501 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26507 +int vc_sched_info(struct vx_info *vxi, void __user *data)
26509 + struct vcmd_sched_info vc_data;
26512 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26515 + cpu = vc_data.cpu_id;
26516 + if (!cpu_possible(cpu))
26520 + struct _vx_sched_pc *sched_pc =
26521 + &vx_per_cpu(vxi, sched_pc, cpu);
26523 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
26524 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
26525 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
26526 + vc_data.vavavoom = sched_pc->vavavoom;
26528 + vc_data.token_usec = ticks_to_usec(1);
26530 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26535 diff -Nurp linux-2.6.22.18/kernel/vserver/sched_init.h linux-2.6.22.18-vs2.3.0.32/kernel/vserver/sched_init.h
26536 --- linux-2.6.22.18/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
26537 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/sched_init.h 2008-02-11 12:35:38.000000000 +0100
26540 +static inline void vx_info_init_sched(struct _vx_sched *sched)
26542 + static struct lock_class_key tokens_lock_key;
26544 + /* scheduling; hard code starting values as constants */
26545 + sched->fill_rate[0] = 1;
26546 + sched->interval[0] = 4;
26547 + sched->fill_rate[1] = 1;
26548 + sched->interval[1] = 8;
26549 + sched->tokens = HZ >> 2;
26550 + sched->tokens_min = HZ >> 4;
26551 + sched->tokens_max = HZ >> 1;
26552 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
26553 + sched->prio_bias = 0;
26555 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
26559 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
26561 + sched_pc->fill_rate[0] = 1;
26562 + sched_pc->interval[0] = 4;
26563 + sched_pc->fill_rate[1] = 1;
26564 + sched_pc->interval[1] = 8;
26565 + sched_pc->tokens = HZ >> 2;
26566 + sched_pc->tokens_min = HZ >> 4;
26567 + sched_pc->tokens_max = HZ >> 1;
26568 + sched_pc->prio_bias = 0;
26569 + sched_pc->vavavoom = 0;
26570 + sched_pc->token_time = 0;
26571 + sched_pc->idle_time = 0;
26572 + sched_pc->norm_time = jiffies;
26574 + sched_pc->user_ticks = 0;
26575 + sched_pc->sys_ticks = 0;
26576 + sched_pc->hold_ticks = 0;
26579 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
26585 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
26589 diff -Nurp linux-2.6.22.18/kernel/vserver/sched_proc.h linux-2.6.22.18-vs2.3.0.32/kernel/vserver/sched_proc.h
26590 --- linux-2.6.22.18/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
26591 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/sched_proc.h 2008-02-11 12:35:38.000000000 +0100
26593 +#ifndef _VX_SCHED_PROC_H
26594 +#define _VX_SCHED_PROC_H
26598 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
26602 + length += sprintf(buffer,
26603 + "FillRate:\t%8d,%d\n"
26604 + "Interval:\t%8d,%d\n"
26605 + "TokensMin:\t%8d\n"
26606 + "TokensMax:\t%8d\n"
26607 + "PrioBias:\t%8d\n",
26608 + sched->fill_rate[0],
26609 + sched->fill_rate[1],
26610 + sched->interval[0],
26611 + sched->interval[1],
26612 + sched->tokens_min,
26613 + sched->tokens_max,
26614 + sched->prio_bias);
26619 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
26620 + char *buffer, int cpu)
26624 + length += sprintf(buffer + length,
26625 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
26626 + (unsigned long long)sched_pc->user_ticks,
26627 + (unsigned long long)sched_pc->sys_ticks,
26628 + (unsigned long long)sched_pc->hold_ticks,
26629 + sched_pc->token_time,
26630 + sched_pc->idle_time);
26631 + length += sprintf(buffer + length,
26632 + " %c%c %d %d %d %d/%d %d/%d",
26633 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
26634 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
26635 + sched_pc->tokens,
26636 + sched_pc->tokens_min,
26637 + sched_pc->tokens_max,
26638 + sched_pc->fill_rate[0],
26639 + sched_pc->interval[0],
26640 + sched_pc->fill_rate[1],
26641 + sched_pc->interval[1]);
26642 + length += sprintf(buffer + length,
26644 + sched_pc->prio_bias,
26645 + sched_pc->vavavoom);
26649 +#endif /* _VX_SCHED_PROC_H */
26650 diff -Nurp linux-2.6.22.18/kernel/vserver/signal.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/signal.c
26651 --- linux-2.6.22.18/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
26652 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/signal.c 2008-02-11 12:35:38.000000000 +0100
26655 + * linux/kernel/vserver/signal.c
26657 + * Virtual Server: Signal Support
26659 + * Copyright (C) 2003-2007 Herbert Pötzl
26661 + * V0.01 broken out from vcontext V0.05
26662 + * V0.02 changed vcmds to vxi arg
26663 + * V0.03 adjusted siginfo for kill
26667 +#include <asm/uaccess.h>
26669 +#include <linux/vs_context.h>
26670 +#include <linux/vserver/signal_cmd.h>
26673 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
26675 + int retval, count = 0;
26676 + struct task_struct *p;
26677 + struct siginfo *sip = SEND_SIG_PRIV;
26680 + vxdprintk(VXD_CBIT(misc, 4),
26681 + "vx_info_kill(%p[#%d],%d,%d)*",
26682 + vxi, vxi->vx_id, pid, sig);
26683 + read_lock(&tasklist_lock);
26687 + for_each_process(p) {
26690 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
26691 + (pid && vxi->vx_initpid == p->pid))
26694 + err = group_send_sig_info(sig, sip, p);
26696 + if (err != -EPERM)
26702 + if (vxi->vx_initpid) {
26703 + pid = vxi->vx_initpid;
26704 + /* for now, only SIGINT to private init ... */
26705 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
26706 + /* ... as long as there are tasks left */
26707 + (atomic_read(&vxi->vx_tasks) > 1))
26710 + /* fallthrough */
26712 + p = find_task_by_real_pid(pid);
26714 + if (vx_task_xid(p) == vxi->vx_id)
26715 + retval = group_send_sig_info(sig, sip, p);
26719 + read_unlock(&tasklist_lock);
26720 + vxdprintk(VXD_CBIT(misc, 4),
26721 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
26722 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
26726 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
26728 + struct vcmd_ctx_kill_v0 vc_data;
26730 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26733 + /* special check to allow guest shutdown */
26734 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
26735 + /* forbid killall pid=0 when init is present */
26736 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
26737 + (vc_data.pid > 1)))
26740 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
26744 +static int __wait_exit(struct vx_info *vxi)
26746 + DECLARE_WAITQUEUE(wait, current);
26749 + add_wait_queue(&vxi->vx_wait, &wait);
26750 + set_current_state(TASK_INTERRUPTIBLE);
26753 + if (vx_info_state(vxi,
26754 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
26756 + if (signal_pending(current)) {
26757 + ret = -ERESTARTSYS;
26764 + set_current_state(TASK_RUNNING);
26765 + remove_wait_queue(&vxi->vx_wait, &wait);
26771 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
26773 + struct vcmd_wait_exit_v0 vc_data;
26776 + ret = __wait_exit(vxi);
26777 + vc_data.reboot_cmd = vxi->reboot_cmd;
26778 + vc_data.exit_code = vxi->exit_code;
26780 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26785 diff -Nurp linux-2.6.22.18/kernel/vserver/space.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/space.c
26786 --- linux-2.6.22.18/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
26787 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/space.c 2008-02-11 12:35:38.000000000 +0100
26790 + * linux/kernel/vserver/space.c
26792 + * Virtual Server: Context Space Support
26794 + * Copyright (C) 2003-2007 Herbert Pötzl
26796 + * V0.01 broken out from context.c 0.07
26797 + * V0.02 added task locking for namespace
26798 + * V0.03 broken out vx_enter_namespace
26799 + * V0.04 added *space support and commands
26803 +#include <linux/utsname.h>
26804 +#include <linux/nsproxy.h>
26805 +#include <linux/err.h>
26806 +#include <asm/uaccess.h>
26808 +#include <linux/vs_context.h>
26809 +#include <linux/vserver/space.h>
26810 +#include <linux/vserver/space_cmd.h>
26813 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
26814 +atomic_t vs_global_fs = ATOMIC_INIT(0);
26815 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
26816 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
26817 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
26820 +/* namespace functions */
26822 +#include <linux/mnt_namespace.h>
26824 +const struct vcmd_space_mask space_mask = {
26825 + .mask = CLONE_NEWNS |
26833 + * build a new nsproxy mix
26834 + * assumes that both proxies are 'const'
26835 + * does not touch nsproxy refcounts
26836 + * will hold a reference on the result.
26839 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
26840 + struct nsproxy *new_nsproxy, unsigned long mask)
26842 + struct mnt_namespace *old_ns;
26843 + struct uts_namespace *old_uts;
26844 + struct ipc_namespace *old_ipc;
26845 + struct nsproxy *nsproxy;
26847 + nsproxy = copy_nsproxy(old_nsproxy);
26851 + if (mask & CLONE_NEWNS) {
26852 + old_ns = nsproxy->mnt_ns;
26853 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
26854 + if (nsproxy->mnt_ns)
26855 + get_mnt_ns(nsproxy->mnt_ns);
26859 + if (mask & CLONE_NEWUTS) {
26860 + old_uts = nsproxy->uts_ns;
26861 + nsproxy->uts_ns = new_nsproxy->uts_ns;
26862 + if (nsproxy->uts_ns)
26863 + get_uts_ns(nsproxy->uts_ns);
26867 + if (mask & CLONE_NEWIPC) {
26868 + old_ipc = nsproxy->ipc_ns;
26869 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
26870 + if (nsproxy->ipc_ns)
26871 + get_ipc_ns(nsproxy->ipc_ns);
26876 + put_mnt_ns(old_ns);
26878 + put_uts_ns(old_uts);
26880 + put_ipc_ns(old_ipc);
26887 + * merge two nsproxy structs into a new one.
26888 + * will hold a reference on the result.
26892 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
26893 + struct nsproxy *proxy, unsigned long mask)
26895 + struct nsproxy null_proxy = { .mnt_ns = NULL };
26901 + /* vs_mix_nsproxy returns with reference */
26902 + return vs_mix_nsproxy(old ? old : &null_proxy,
26905 + get_nsproxy(proxy);
26910 + * merge two fs structs into a new one.
26911 + * will take a reference on the result.
26915 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
26916 + struct fs_struct *fs, unsigned long mask)
26918 + if (!(mask & CLONE_FS)) {
26920 + atomic_inc(&old->count);
26927 + return copy_fs_struct(fs);
26931 +int vx_enter_space(struct vx_info *vxi, unsigned long mask)
26933 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
26934 + struct fs_struct *fs, *fs_cur, *fs_new;
26937 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
26941 + mask = vxi->vx_nsmask;
26943 + if ((mask & vxi->vx_nsmask) != mask)
26946 + proxy = vxi->vx_nsproxy;
26949 + task_lock(current);
26950 + fs_cur = current->fs;
26951 + atomic_inc(&fs_cur->count);
26952 + proxy_cur = current->nsproxy;
26953 + get_nsproxy(proxy_cur);
26954 + task_unlock(current);
26956 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
26957 + if (IS_ERR(fs_new)) {
26958 + ret = PTR_ERR(fs_new);
26962 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
26963 + if (IS_ERR(proxy_new)) {
26964 + ret = PTR_ERR(proxy_new);
26968 + fs_new = xchg(¤t->fs, fs_new);
26969 + proxy_new = xchg(¤t->nsproxy, proxy_new);
26973 + put_nsproxy(proxy_new);
26976 + put_fs_struct(fs_new);
26979 + put_nsproxy(proxy_cur);
26981 + put_fs_struct(fs_cur);
26986 +int vx_set_space(struct vx_info *vxi, unsigned long mask)
26988 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
26989 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
26993 + mask = space_mask.mask;
26995 + if ((mask & space_mask.mask) != mask)
26998 + proxy_vxi = vxi->vx_nsproxy;
26999 + fs_vxi = vxi->vx_fs;
27001 + task_lock(current);
27002 + fs_cur = current->fs;
27003 + atomic_inc(&fs_cur->count);
27004 + proxy_cur = current->nsproxy;
27005 + get_nsproxy(proxy_cur);
27006 + task_unlock(current);
27008 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
27009 + if (IS_ERR(fs_new)) {
27010 + ret = PTR_ERR(fs_new);
27014 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
27015 + if (IS_ERR(proxy_new)) {
27016 + ret = PTR_ERR(proxy_new);
27020 + fs_new = xchg(&vxi->vx_fs, fs_new);
27021 + proxy_new = xchg(&vxi->vx_nsproxy, proxy_new);
27022 + vxi->vx_nsmask |= mask;
27026 + put_nsproxy(proxy_new);
27029 + put_fs_struct(fs_new);
27032 + put_nsproxy(proxy_cur);
27034 + put_fs_struct(fs_cur);
27039 +int vc_enter_space(struct vx_info *vxi, void __user *data)
27041 + struct vcmd_space_mask vc_data = { .mask = 0 };
27043 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
27046 + return vx_enter_space(vxi, vc_data.mask);
27049 +int vc_set_space(struct vx_info *vxi, void __user *data)
27051 + struct vcmd_space_mask vc_data = { .mask = 0 };
27053 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
27056 + return vx_set_space(vxi, vc_data.mask);
27059 +int vc_get_space_mask(struct vx_info *vxi, void __user *data)
27061 + if (copy_to_user(data, &space_mask, sizeof(space_mask)))
27066 diff -Nurp linux-2.6.22.18/kernel/vserver/switch.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/switch.c
27067 --- linux-2.6.22.18/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
27068 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/switch.c 2008-02-11 12:35:38.000000000 +0100
27071 + * linux/kernel/vserver/switch.c
27073 + * Virtual Server: Syscall Switch
27075 + * Copyright (C) 2003-2007 Herbert Pötzl
27077 + * V0.01 syscall switch
27078 + * V0.02 added signal to context
27079 + * V0.03 added rlimit functions
27080 + * V0.04 added iattr, task/xid functions
27081 + * V0.05 added debug/history stuff
27082 + * V0.06 added compat32 layer
27083 + * V0.07 vcmd args and perms
27084 + * V0.08 added status commands
27085 + * V0.09 added tag commands
27086 + * V0.10 added oom bias
27087 + * V0.11 added device commands
27091 +#include <linux/vs_context.h>
27092 +#include <linux/vs_network.h>
27093 +#include <linux/vserver/switch.h>
27095 +#include "vci_config.h"
27099 +int vc_get_version(uint32_t id)
27101 + return VCI_VERSION;
27105 +int vc_get_vci(uint32_t id)
27107 + return vci_kernel_config();
27110 +#include <linux/vserver/context_cmd.h>
27111 +#include <linux/vserver/cvirt_cmd.h>
27112 +#include <linux/vserver/cacct_cmd.h>
27113 +#include <linux/vserver/limit_cmd.h>
27114 +#include <linux/vserver/network_cmd.h>
27115 +#include <linux/vserver/sched_cmd.h>
27116 +#include <linux/vserver/debug_cmd.h>
27117 +#include <linux/vserver/inode_cmd.h>
27118 +#include <linux/vserver/dlimit_cmd.h>
27119 +#include <linux/vserver/signal_cmd.h>
27120 +#include <linux/vserver/space_cmd.h>
27121 +#include <linux/vserver/tag_cmd.h>
27122 +#include <linux/vserver/device_cmd.h>
27124 +#include <linux/vserver/inode.h>
27125 +#include <linux/vserver/dlimit.h>
27128 +#ifdef CONFIG_COMPAT
27129 +#define __COMPAT(name, id, data, compat) \
27130 + (compat) ? name ## _x32(id, data) : name(id, data)
27131 +#define __COMPAT_NO_ID(name, data, compat) \
27132 + (compat) ? name ## _x32(data) : name(data)
27134 +#define __COMPAT(name, id, data, compat) \
27136 +#define __COMPAT_NO_ID(name, data, compat) \
27142 +long do_vcmd(uint32_t cmd, uint32_t id,
27143 + struct vx_info *vxi, struct nx_info *nxi,
27144 + void __user *data, int compat)
27148 + case VCMD_get_version:
27149 + return vc_get_version(id);
27150 + case VCMD_get_vci:
27151 + return vc_get_vci(id);
27153 + case VCMD_task_xid:
27154 + return vc_task_xid(id);
27155 + case VCMD_vx_info:
27156 + return vc_vx_info(vxi, data);
27158 + case VCMD_task_nid:
27159 + return vc_task_nid(id);
27160 + case VCMD_nx_info:
27161 + return vc_nx_info(nxi, data);
27163 + case VCMD_task_tag:
27164 + return vc_task_tag(id);
27166 + /* this is version 1 */
27167 + case VCMD_set_space:
27168 + return vc_set_space(vxi, data);
27170 + case VCMD_get_space_mask:
27171 + return vc_get_space_mask(vxi, data);
27173 +#ifdef CONFIG_IA32_EMULATION
27174 + case VCMD_get_rlimit:
27175 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
27176 + case VCMD_set_rlimit:
27177 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
27179 + case VCMD_get_rlimit:
27180 + return vc_get_rlimit(vxi, data);
27181 + case VCMD_set_rlimit:
27182 + return vc_set_rlimit(vxi, data);
27184 + case VCMD_get_rlimit_mask:
27185 + return vc_get_rlimit_mask(id, data);
27186 + case VCMD_reset_minmax:
27187 + return vc_reset_minmax(vxi, data);
27189 + case VCMD_get_vhi_name:
27190 + return vc_get_vhi_name(vxi, data);
27191 + case VCMD_set_vhi_name:
27192 + return vc_set_vhi_name(vxi, data);
27194 + case VCMD_ctx_stat:
27195 + return vc_ctx_stat(vxi, data);
27196 + case VCMD_virt_stat:
27197 + return vc_virt_stat(vxi, data);
27198 + case VCMD_sock_stat:
27199 + return vc_sock_stat(vxi, data);
27200 + case VCMD_rlimit_stat:
27201 + return vc_rlimit_stat(vxi, data);
27203 + case VCMD_set_cflags:
27204 + return vc_set_cflags(vxi, data);
27205 + case VCMD_get_cflags:
27206 + return vc_get_cflags(vxi, data);
27208 + /* this is version 1 */
27209 + case VCMD_set_ccaps:
27210 + return vc_set_ccaps(vxi, data);
27211 + /* this is version 1 */
27212 + case VCMD_get_ccaps:
27213 + return vc_get_ccaps(vxi, data);
27214 + case VCMD_set_bcaps:
27215 + return vc_set_bcaps(vxi, data);
27216 + case VCMD_get_bcaps:
27217 + return vc_get_bcaps(vxi, data);
27219 + case VCMD_set_badness:
27220 + return vc_set_badness(vxi, data);
27221 + case VCMD_get_badness:
27222 + return vc_get_badness(vxi, data);
27224 + case VCMD_set_nflags:
27225 + return vc_set_nflags(nxi, data);
27226 + case VCMD_get_nflags:
27227 + return vc_get_nflags(nxi, data);
27229 + case VCMD_set_ncaps:
27230 + return vc_set_ncaps(nxi, data);
27231 + case VCMD_get_ncaps:
27232 + return vc_get_ncaps(nxi, data);
27234 + case VCMD_set_sched_v4:
27235 + return vc_set_sched_v4(vxi, data);
27236 + /* this is version 5 */
27237 + case VCMD_set_sched:
27238 + return vc_set_sched(vxi, data);
27239 + case VCMD_get_sched:
27240 + return vc_get_sched(vxi, data);
27241 + case VCMD_sched_info:
27242 + return vc_sched_info(vxi, data);
27244 + case VCMD_add_dlimit:
27245 + return __COMPAT(vc_add_dlimit, id, data, compat);
27246 + case VCMD_rem_dlimit:
27247 + return __COMPAT(vc_rem_dlimit, id, data, compat);
27248 + case VCMD_set_dlimit:
27249 + return __COMPAT(vc_set_dlimit, id, data, compat);
27250 + case VCMD_get_dlimit:
27251 + return __COMPAT(vc_get_dlimit, id, data, compat);
27253 + case VCMD_ctx_kill:
27254 + return vc_ctx_kill(vxi, data);
27256 + case VCMD_wait_exit:
27257 + return vc_wait_exit(vxi, data);
27259 + case VCMD_get_iattr:
27260 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
27261 + case VCMD_set_iattr:
27262 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
27264 + case VCMD_fget_iattr:
27265 + return vc_fget_iattr(id, data);
27266 + case VCMD_fset_iattr:
27267 + return vc_fset_iattr(id, data);
27269 + case VCMD_enter_space_v0:
27270 + return vc_enter_space(vxi, NULL);
27271 + /* this is version 1 */
27272 + case VCMD_enter_space:
27273 + return vc_enter_space(vxi, data);
27275 + case VCMD_ctx_create_v0:
27276 + return vc_ctx_create(id, NULL);
27277 + case VCMD_ctx_create:
27278 + return vc_ctx_create(id, data);
27279 + case VCMD_ctx_migrate_v0:
27280 + return vc_ctx_migrate(vxi, NULL);
27281 + case VCMD_ctx_migrate:
27282 + return vc_ctx_migrate(vxi, data);
27284 + case VCMD_net_create_v0:
27285 + return vc_net_create(id, NULL);
27286 + case VCMD_net_create:
27287 + return vc_net_create(id, data);
27288 + case VCMD_net_migrate:
27289 + return vc_net_migrate(nxi, data);
27291 + case VCMD_tag_migrate:
27292 + return vc_tag_migrate(id);
27294 + case VCMD_net_add:
27295 + return vc_net_add(nxi, data);
27296 + case VCMD_net_remove:
27297 + return vc_net_remove(nxi, data);
27299 + case VCMD_net_add_ipv4:
27300 + return vc_net_add_ipv4(nxi, data);
27301 + case VCMD_net_remove_ipv4:
27302 + return vc_net_remove_ipv4(nxi, data);
27303 +#ifdef CONFIG_IPV6
27304 + case VCMD_net_add_ipv6:
27305 + return vc_net_add_ipv6(nxi, data);
27306 + case VCMD_net_remove_ipv6:
27307 + return vc_net_remove_ipv6(nxi, data);
27309 +/* case VCMD_add_match_ipv4:
27310 + return vc_add_match_ipv4(nxi, data);
27311 + case VCMD_get_match_ipv4:
27312 + return vc_get_match_ipv4(nxi, data);
27313 +#ifdef CONFIG_IPV6
27314 + case VCMD_add_match_ipv6:
27315 + return vc_add_match_ipv6(nxi, data);
27316 + case VCMD_get_match_ipv6:
27317 + return vc_get_match_ipv6(nxi, data);
27320 +#ifdef CONFIG_VSERVER_DEVICE
27321 + case VCMD_set_mapping:
27322 + return __COMPAT(vc_set_mapping, vxi, data, compat);
27323 + case VCMD_unset_mapping:
27324 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
27326 +#ifdef CONFIG_VSERVER_HISTORY
27327 + case VCMD_dump_history:
27328 + return vc_dump_history(id);
27329 + case VCMD_read_history:
27330 + return __COMPAT(vc_read_history, id, data, compat);
27332 +#ifdef CONFIG_VSERVER_MONITOR
27333 + case VCMD_read_monitor:
27334 + return __COMPAT(vc_read_monitor, id, data, compat);
27337 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
27338 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
27344 +#define __VCMD(vcmd, _perm, _args, _flags) \
27345 + case VCMD_ ## vcmd: perm = _perm; \
27346 + args = _args; flags = _flags; break
27349 +#define VCA_NONE 0x00
27350 +#define VCA_VXI 0x01
27351 +#define VCA_NXI 0x02
27353 +#define VCF_NONE 0x00
27354 +#define VCF_INFO 0x01
27355 +#define VCF_ADMIN 0x02
27356 +#define VCF_ARES 0x06 /* includes admin */
27357 +#define VCF_SETUP 0x08
27359 +#define VCF_ZIDOK 0x10 /* zero id okay */
27363 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
27366 + int permit = -1, state = 0;
27367 + int perm = -1, args = 0, flags = 0;
27368 + struct vx_info *vxi = NULL;
27369 + struct nx_info *nxi = NULL;
27372 + /* unpriviledged commands */
27373 + __VCMD(get_version, 0, VCA_NONE, 0);
27374 + __VCMD(get_vci, 0, VCA_NONE, 0);
27375 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
27376 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
27378 + /* info commands */
27379 + __VCMD(task_xid, 2, VCA_NONE, 0);
27380 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
27381 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
27382 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
27383 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
27384 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
27385 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
27386 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
27387 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
27389 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
27390 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
27391 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
27392 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
27394 + __VCMD(task_nid, 2, VCA_NONE, 0);
27395 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
27396 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
27397 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
27399 + __VCMD(task_tag, 2, VCA_NONE, 0);
27401 + __VCMD(get_iattr, 2, VCA_NONE, 0);
27402 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
27403 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
27404 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
27405 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
27407 + /* lower admin commands */
27408 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
27409 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
27410 + __VCMD(ctx_create, 5, VCA_NONE, 0);
27411 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
27412 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
27413 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
27414 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
27416 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
27417 + __VCMD(net_create, 5, VCA_NONE, 0);
27418 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
27420 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
27422 + /* higher admin commands */
27423 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
27424 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27426 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27427 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27428 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27429 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27431 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27432 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27433 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27434 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27436 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
27437 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
27438 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27439 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27440 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27441 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27442 +#ifdef CONFIG_IPV6
27443 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27444 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27446 + __VCMD(set_iattr, 7, VCA_NONE, 0);
27447 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
27448 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
27449 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
27450 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
27452 +#ifdef CONFIG_VSERVER_DEVICE
27453 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
27454 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
27456 + /* debug level admin commands */
27457 +#ifdef CONFIG_VSERVER_HISTORY
27458 + __VCMD(dump_history, 9, VCA_NONE, 0);
27459 + __VCMD(read_history, 9, VCA_NONE, 0);
27461 +#ifdef CONFIG_VSERVER_MONITOR
27462 + __VCMD(read_monitor, 9, VCA_NONE, 0);
27469 + vxdprintk(VXD_CBIT(switch, 0),
27470 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
27471 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
27472 + VC_VERSION(cmd), id, data, compat,
27473 + perm, args, flags);
27480 + if (!capable(CAP_CONTEXT))
27484 + /* moved here from the individual commands */
27486 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
27490 + /* vcmd involves resource management */
27492 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
27496 + /* various legacy exceptions */
27498 + /* will go away when spectator is a cap */
27499 + case VCMD_ctx_migrate_v0:
27500 + case VCMD_ctx_migrate:
27502 + current->xid = 1;
27508 + /* will go away when spectator is a cap */
27509 + case VCMD_net_migrate:
27511 + current->nid = 1;
27518 + /* vcmds are fine by default */
27521 + /* admin type vcmds require admin ... */
27522 + if (flags & VCF_ADMIN)
27523 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
27525 + /* ... but setup type vcmds override that */
27526 + if (!permit && (flags & VCF_SETUP))
27527 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
27535 + if (!id && (flags & VCF_ZIDOK))
27539 + if (args & VCA_VXI) {
27540 + vxi = lookup_vx_info(id);
27544 + if ((flags & VCF_ADMIN) &&
27545 + /* special case kill for shutdown */
27546 + (cmd != VCMD_ctx_kill) &&
27547 + /* can context be administrated? */
27548 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
27554 + if (args & VCA_NXI) {
27555 + nxi = lookup_nx_info(id);
27559 + if ((flags & VCF_ADMIN) &&
27560 + /* can context be administrated? */
27561 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
27568 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
27571 + if ((args & VCA_NXI) && nxi)
27572 + put_nx_info(nxi);
27574 + if ((args & VCA_VXI) && vxi)
27575 + put_vx_info(vxi);
27577 + vxdprintk(VXD_CBIT(switch, 1),
27578 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
27579 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
27580 + VC_VERSION(cmd), ret, ret, state, permit);
27585 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
27587 + return do_vserver(cmd, id, data, 0);
27590 +#ifdef CONFIG_COMPAT
27593 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
27595 + return do_vserver(cmd, id, data, 1);
27598 +#endif /* CONFIG_COMPAT */
27599 diff -Nurp linux-2.6.22.18/kernel/vserver/sysctl.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/sysctl.c
27600 --- linux-2.6.22.18/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
27601 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/sysctl.c 2008-02-11 12:35:38.000000000 +0100
27604 + * kernel/vserver/sysctl.c
27606 + * Virtual Context Support
27608 + * Copyright (C) 2004-2007 Herbert Pötzl
27610 + * V0.01 basic structure
27614 +#include <linux/module.h>
27615 +#include <linux/ctype.h>
27616 +#include <linux/sysctl.h>
27617 +#include <linux/parser.h>
27618 +#include <asm/uaccess.h>
27621 +#define CTL_VSERVER 4242 /* unused? */
27624 + CTL_DEBUG_ERROR = 0,
27625 + CTL_DEBUG_SWITCH = 1,
27640 +unsigned int vx_debug_switch = 0;
27641 +unsigned int vx_debug_xid = 0;
27642 +unsigned int vx_debug_nid = 0;
27643 +unsigned int vx_debug_tag = 0;
27644 +unsigned int vx_debug_net = 0;
27645 +unsigned int vx_debug_limit = 0;
27646 +unsigned int vx_debug_cres = 0;
27647 +unsigned int vx_debug_dlim = 0;
27648 +unsigned int vx_debug_quota = 0;
27649 +unsigned int vx_debug_cvirt = 0;
27650 +unsigned int vx_debug_space = 0;
27651 +unsigned int vx_debug_misc = 0;
27654 +static struct ctl_table_header *vserver_table_header;
27655 +static ctl_table vserver_table[];
27658 +void vserver_register_sysctl(void)
27660 + if (!vserver_table_header) {
27661 + vserver_table_header = register_sysctl_table(vserver_table);
27666 +void vserver_unregister_sysctl(void)
27668 + if (vserver_table_header) {
27669 + unregister_sysctl_table(vserver_table_header);
27670 + vserver_table_header = NULL;
27675 +static int proc_dodebug(ctl_table *table, int write,
27676 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
27678 + char tmpbuf[20], *p, c;
27679 + unsigned int value;
27680 + size_t left, len;
27682 + if ((*ppos && !write) || !*lenp) {
27690 + if (!access_ok(VERIFY_READ, buffer, left))
27692 + p = (char *)buffer;
27693 + while (left && __get_user(c, p) >= 0 && isspace(c))
27698 + if (left > sizeof(tmpbuf) - 1)
27700 + if (copy_from_user(tmpbuf, p, left))
27702 + tmpbuf[left] = '\0';
27704 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
27705 + value = 10 * value + (*p - '0');
27706 + if (*p && !isspace(*p))
27708 + while (left && isspace(*p))
27710 + *(unsigned int *)table->data = value;
27712 + if (!access_ok(VERIFY_WRITE, buffer, left))
27714 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
27717 + if (__copy_to_user(buffer, tmpbuf, len))
27719 + if ((left -= len) > 0) {
27720 + if (put_user('\n', (char *)buffer + len))
27733 +#define CTL_ENTRY(ctl, name) \
27735 + .ctl_name = ctl, \
27736 + .procname = #name, \
27737 + .data = &vx_ ## name, \
27738 + .maxlen = sizeof(int), \
27740 + .proc_handler = &proc_dodebug \
27743 +static ctl_table debug_table[] = {
27744 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
27745 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
27746 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
27747 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
27748 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
27749 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
27750 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
27751 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
27752 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
27753 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
27754 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
27755 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
27756 + { .ctl_name = 0 }
27759 +static ctl_table vserver_table[] = {
27761 + .ctl_name = CTL_VSERVER,
27762 + .procname = "vserver",
27764 + .child = debug_table
27766 + { .ctl_name = 0 }
27770 +static match_table_t tokens = {
27771 + { CTL_DEBUG_SWITCH, "switch=%x" },
27772 + { CTL_DEBUG_XID, "xid=%x" },
27773 + { CTL_DEBUG_NID, "nid=%x" },
27774 + { CTL_DEBUG_TAG, "tag=%x" },
27775 + { CTL_DEBUG_NET, "net=%x" },
27776 + { CTL_DEBUG_LIMIT, "limit=%x" },
27777 + { CTL_DEBUG_CRES, "cres=%x" },
27778 + { CTL_DEBUG_DLIM, "dlim=%x" },
27779 + { CTL_DEBUG_QUOTA, "quota=%x" },
27780 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
27781 + { CTL_DEBUG_SPACE, "space=%x" },
27782 + { CTL_DEBUG_MISC, "misc=%x" },
27783 + { CTL_DEBUG_ERROR, NULL }
27786 +#define HANDLE_CASE(id, name, val) \
27787 + case CTL_DEBUG_ ## id: \
27788 + vx_debug_ ## name = val; \
27789 + printk("vs_debug_" #name "=0x%x\n", val); \
27793 +static int __init vs_debug_setup(char *str)
27798 + printk("vs_debug_setup(%s)\n", str);
27799 + while ((p = strsep(&str, ",")) != NULL) {
27800 + substring_t args[MAX_OPT_ARGS];
27801 + unsigned int value;
27806 + token = match_token(p, tokens, args);
27807 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
27810 + HANDLE_CASE(SWITCH, switch, value);
27811 + HANDLE_CASE(XID, xid, value);
27812 + HANDLE_CASE(NID, nid, value);
27813 + HANDLE_CASE(TAG, tag, value);
27814 + HANDLE_CASE(NET, net, value);
27815 + HANDLE_CASE(LIMIT, limit, value);
27816 + HANDLE_CASE(CRES, cres, value);
27817 + HANDLE_CASE(DLIM, dlim, value);
27818 + HANDLE_CASE(QUOTA, quota, value);
27819 + HANDLE_CASE(CVIRT, cvirt, value);
27820 + HANDLE_CASE(SPACE, space, value);
27821 + HANDLE_CASE(MISC, misc, value);
27830 +__setup("vsdebug=", vs_debug_setup);
27834 +EXPORT_SYMBOL_GPL(vx_debug_switch);
27835 +EXPORT_SYMBOL_GPL(vx_debug_xid);
27836 +EXPORT_SYMBOL_GPL(vx_debug_nid);
27837 +EXPORT_SYMBOL_GPL(vx_debug_net);
27838 +EXPORT_SYMBOL_GPL(vx_debug_limit);
27839 +EXPORT_SYMBOL_GPL(vx_debug_cres);
27840 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
27841 +EXPORT_SYMBOL_GPL(vx_debug_quota);
27842 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
27843 +EXPORT_SYMBOL_GPL(vx_debug_space);
27844 +EXPORT_SYMBOL_GPL(vx_debug_misc);
27846 diff -Nurp linux-2.6.22.18/kernel/vserver/tag.c linux-2.6.22.18-vs2.3.0.32/kernel/vserver/tag.c
27847 --- linux-2.6.22.18/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
27848 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/tag.c 2008-02-11 12:35:38.000000000 +0100
27851 + * linux/kernel/vserver/tag.c
27853 + * Virtual Server: Shallow Tag Space
27855 + * Copyright (C) 2007 Herbert Pötzl
27857 + * V0.01 basic implementation
27861 +#include <linux/sched.h>
27862 +#include <linux/vserver/debug.h>
27863 +#include <linux/vs_tag.h>
27865 +#include <linux/vserver/tag_cmd.h>
27868 +int dx_migrate_task(struct task_struct *p, tag_t tag)
27873 + vxdprintk(VXD_CBIT(tag, 5),
27874 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
27880 + vxdprintk(VXD_CBIT(tag, 5),
27881 + "moved task %p into [#%d]", p, tag);
27885 +/* vserver syscall commands below here */
27887 +/* taks xid and vx_info functions */
27890 +int vc_task_tag(uint32_t id)
27895 + struct task_struct *tsk;
27896 + read_lock(&tasklist_lock);
27897 + tsk = find_task_by_real_pid(id);
27898 + tag = (tsk) ? tsk->tag : -ESRCH;
27899 + read_unlock(&tasklist_lock);
27901 + tag = dx_current_tag();
27906 +int vc_tag_migrate(uint32_t tag)
27908 + return dx_migrate_task(current, tag & 0xFFFF);
27912 diff -Nurp linux-2.6.22.18/kernel/vserver/vci_config.h linux-2.6.22.18-vs2.3.0.32/kernel/vserver/vci_config.h
27913 --- linux-2.6.22.18/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
27914 +++ linux-2.6.22.18-vs2.3.0.32/kernel/vserver/vci_config.h 2008-02-11 12:35:38.000000000 +0100
27917 +/* interface version */
27919 +#define VCI_VERSION 0x00020302
27923 + VCI_KCBIT_NO_DYNAMIC = 0,
27925 + VCI_KCBIT_PROC_SECURE = 4,
27926 + VCI_KCBIT_HARDCPU = 5,
27927 + VCI_KCBIT_IDLELIMIT = 6,
27928 + VCI_KCBIT_IDLETIME = 7,
27930 + VCI_KCBIT_COWBL = 8,
27931 + VCI_KCBIT_FULLCOWBL = 9,
27932 + VCI_KCBIT_SPACES = 10,
27933 + VCI_KCBIT_NETV2 = 11,
27935 + VCI_KCBIT_DEBUG = 16,
27936 + VCI_KCBIT_HISTORY = 20,
27937 + VCI_KCBIT_TAGGED = 24,
27938 + VCI_KCBIT_PPTAG = 28,
27940 + VCI_KCBIT_MORE = 31,
27944 +static inline uint32_t vci_kernel_config(void)
27947 + (1 << VCI_KCBIT_NO_DYNAMIC) |
27949 + /* configured features */
27950 +#ifdef CONFIG_VSERVER_PROC_SECURE
27951 + (1 << VCI_KCBIT_PROC_SECURE) |
27953 +#ifdef CONFIG_VSERVER_HARDCPU
27954 + (1 << VCI_KCBIT_HARDCPU) |
27956 +#ifdef CONFIG_VSERVER_IDLELIMIT
27957 + (1 << VCI_KCBIT_IDLELIMIT) |
27959 +#ifdef CONFIG_VSERVER_IDLETIME
27960 + (1 << VCI_KCBIT_IDLETIME) |
27962 +#ifdef CONFIG_VSERVER_COWBL
27963 + (1 << VCI_KCBIT_COWBL) |
27964 + (1 << VCI_KCBIT_FULLCOWBL) |
27966 + (1 << VCI_KCBIT_SPACES) |
27967 + (1 << VCI_KCBIT_NETV2) |
27969 + /* debug options */
27970 +#ifdef CONFIG_VSERVER_DEBUG
27971 + (1 << VCI_KCBIT_DEBUG) |
27973 +#ifdef CONFIG_VSERVER_HISTORY
27974 + (1 << VCI_KCBIT_HISTORY) |
27977 + /* inode context tagging */
27978 +#if defined(CONFIG_TAGGING_NONE)
27979 + (0 << VCI_KCBIT_TAGGED) |
27980 +#elif defined(CONFIG_TAGGING_UID16)
27981 + (1 << VCI_KCBIT_TAGGED) |
27982 +#elif defined(CONFIG_TAGGING_GID16)
27983 + (2 << VCI_KCBIT_TAGGED) |
27984 +#elif defined(CONFIG_TAGGING_ID24)
27985 + (3 << VCI_KCBIT_TAGGED) |
27986 +#elif defined(CONFIG_TAGGING_INTERN)
27987 + (4 << VCI_KCBIT_TAGGED) |
27988 +#elif defined(CONFIG_TAGGING_RUNTIME)
27989 + (5 << VCI_KCBIT_TAGGED) |
27991 + (7 << VCI_KCBIT_TAGGED) |
27993 + (1 << VCI_KCBIT_PPTAG) |
27997 diff -Nurp linux-2.6.22.18/Makefile linux-2.6.22.18-vs2.3.0.32/Makefile
27998 --- linux-2.6.22.18/Makefile 2008-02-11 12:34:27.000000000 +0100
27999 +++ linux-2.6.22.18-vs2.3.0.32/Makefile 2008-02-11 12:35:55.000000000 +0100
28004 -EXTRAVERSION = .18
28005 +EXTRAVERSION = .18-vs2.3.0.32
28006 NAME = Holy Dancing Manatees, Batman!
28009 diff -Nurp linux-2.6.22.18/mm/filemap_xip.c linux-2.6.22.18-vs2.3.0.32/mm/filemap_xip.c
28010 --- linux-2.6.22.18/mm/filemap_xip.c 2007-07-22 00:00:25.000000000 +0200
28011 +++ linux-2.6.22.18-vs2.3.0.32/mm/filemap_xip.c 2008-02-11 12:35:38.000000000 +0100
28013 #include <linux/uio.h>
28014 #include <linux/rmap.h>
28015 #include <linux/sched.h>
28016 +#include <linux/vs_memory.h>
28017 #include <asm/tlbflush.h>
28018 #include "filemap.h"
28020 diff -Nurp linux-2.6.22.18/mm/fremap.c linux-2.6.22.18-vs2.3.0.32/mm/fremap.c
28021 --- linux-2.6.22.18/mm/fremap.c 2007-05-04 15:58:24.000000000 +0200
28022 +++ linux-2.6.22.18-vs2.3.0.32/mm/fremap.c 2008-02-11 12:35:38.000000000 +0100
28024 #include <linux/rmap.h>
28025 #include <linux/module.h>
28026 #include <linux/syscalls.h>
28027 +#include <linux/vs_memory.h>
28029 #include <asm/mmu_context.h>
28030 #include <asm/cacheflush.h>
28031 @@ -74,6 +75,8 @@ int install_page(struct mm_struct *mm, s
28033 if (page_mapcount(page) > INT_MAX/2)
28035 + if (!vx_rss_avail(mm, 1))
28038 if (pte_none(*pte) || !zap_pte(mm, vma, addr, pte))
28039 inc_mm_counter(mm, file_rss);
28040 diff -Nurp linux-2.6.22.18/mm/hugetlb.c linux-2.6.22.18-vs2.3.0.32/mm/hugetlb.c
28041 --- linux-2.6.22.18/mm/hugetlb.c 2007-08-12 03:54:37.000000000 +0200
28042 +++ linux-2.6.22.18-vs2.3.0.32/mm/hugetlb.c 2008-02-11 12:35:38.000000000 +0100
28044 #include <asm/pgtable.h>
28046 #include <linux/hugetlb.h>
28047 +#include <linux/vs_memory.h>
28048 #include "internal.h"
28050 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
28051 diff -Nurp linux-2.6.22.18/mm/memory.c linux-2.6.22.18-vs2.3.0.32/mm/memory.c
28052 --- linux-2.6.22.18/mm/memory.c 2007-07-22 00:00:25.000000000 +0200
28053 +++ linux-2.6.22.18-vs2.3.0.32/mm/memory.c 2008-02-11 12:35:38.000000000 +0100
28054 @@ -498,6 +498,9 @@ static int copy_pte_range(struct mm_stru
28058 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
28062 rss[1] = rss[0] = 0;
28063 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
28064 @@ -2157,6 +2160,11 @@ static int do_swap_page(struct mm_struct
28065 count_vm_event(PGMAJFAULT);
28068 + if (!vx_rss_avail(mm, 1)) {
28069 + ret = VM_FAULT_OOM;
28073 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
28074 mark_page_accessed(page);
28076 @@ -2229,6 +2237,8 @@ static int do_anonymous_page(struct mm_s
28077 /* Allocate our own private page. */
28078 pte_unmap(page_table);
28080 + if (!vx_rss_avail(mm, 1))
28082 if (unlikely(anon_vma_prepare(vma)))
28084 page = alloc_zeroed_user_highpage(vma, address);
28085 @@ -2302,6 +2312,9 @@ static int do_no_page(struct mm_struct *
28086 pte_unmap(page_table);
28087 BUG_ON(vma->vm_flags & VM_PFNMAP);
28089 + if (!vx_rss_avail(mm, 1))
28090 + return VM_FAULT_OOM;
28092 if (vma->vm_file) {
28093 mapping = vma->vm_file->f_mapping;
28094 sequence = mapping->truncate_count;
28095 @@ -2527,6 +2540,7 @@ static inline int handle_pte_fault(struc
28099 + int ret, type = VXPT_UNKNOWN;
28102 if (!pte_present(entry)) {
28103 @@ -2555,9 +2569,12 @@ static inline int handle_pte_fault(struc
28104 if (unlikely(!pte_same(*pte, entry)))
28106 if (write_access) {
28107 - if (!pte_write(entry))
28108 - return do_wp_page(mm, vma, address,
28109 + if (!pte_write(entry)) {
28110 + ret = do_wp_page(mm, vma, address,
28111 pte, pmd, ptl, entry);
28112 + type = VXPT_WRITE;
28115 entry = pte_mkdirty(entry);
28117 entry = pte_mkyoung(entry);
28118 @@ -2576,7 +2593,10 @@ static inline int handle_pte_fault(struc
28121 pte_unmap_unlock(pte, ptl);
28122 - return VM_FAULT_MINOR;
28123 + ret = VM_FAULT_MINOR;
28125 + vx_page_fault(mm, vma, type, ret);
28130 diff -Nurp linux-2.6.22.18/mm/mlock.c linux-2.6.22.18-vs2.3.0.32/mm/mlock.c
28131 --- linux-2.6.22.18/mm/mlock.c 2007-08-12 03:54:37.000000000 +0200
28132 +++ linux-2.6.22.18-vs2.3.0.32/mm/mlock.c 2008-02-11 12:35:38.000000000 +0100
28134 #include <linux/syscalls.h>
28135 #include <linux/sched.h>
28136 #include <linux/module.h>
28137 +#include <linux/vs_memory.h>
28139 int can_do_mlock(void)
28141 @@ -76,7 +77,7 @@ success:
28142 ret = make_pages_present(start, end);
28145 - mm->locked_vm -= pages;
28146 + vx_vmlocked_sub(mm, pages);
28148 if (ret == -ENOMEM)
28150 @@ -134,7 +135,7 @@ static int do_mlock(unsigned long start,
28152 asmlinkage long sys_mlock(unsigned long start, size_t len)
28154 - unsigned long locked;
28155 + unsigned long locked, grow;
28156 unsigned long lock_limit;
28157 int error = -ENOMEM;
28159 @@ -145,8 +146,10 @@ asmlinkage long sys_mlock(unsigned long
28160 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
28161 start &= PAGE_MASK;
28163 - locked = len >> PAGE_SHIFT;
28164 - locked += current->mm->locked_vm;
28165 + grow = len >> PAGE_SHIFT;
28166 + if (!vx_vmlocked_avail(current->mm, grow))
28168 + locked = current->mm->locked_vm + grow;
28170 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
28171 lock_limit >>= PAGE_SHIFT;
28172 @@ -154,6 +157,7 @@ asmlinkage long sys_mlock(unsigned long
28173 /* check against resource limits */
28174 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
28175 error = do_mlock(start, len, 1);
28177 up_write(¤t->mm->mmap_sem);
28180 @@ -213,6 +217,8 @@ asmlinkage long sys_mlockall(int flags)
28181 lock_limit >>= PAGE_SHIFT;
28184 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
28186 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
28187 capable(CAP_IPC_LOCK))
28188 ret = do_mlockall(flags);
28189 diff -Nurp linux-2.6.22.18/mm/mmap.c linux-2.6.22.18-vs2.3.0.32/mm/mmap.c
28190 --- linux-2.6.22.18/mm/mmap.c 2008-02-11 12:34:20.000000000 +0100
28191 +++ linux-2.6.22.18-vs2.3.0.32/mm/mmap.c 2008-02-11 12:35:38.000000000 +0100
28192 @@ -1144,10 +1144,10 @@ munmap_back:
28193 kmem_cache_free(vm_area_cachep, vma);
28196 - mm->total_vm += len >> PAGE_SHIFT;
28197 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28198 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
28199 if (vm_flags & VM_LOCKED) {
28200 - mm->locked_vm += len >> PAGE_SHIFT;
28201 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
28202 make_pages_present(addr, addr + len);
28204 if (flags & MAP_POPULATE) {
28205 @@ -1502,9 +1502,9 @@ static int acct_stack_growth(struct vm_a
28208 /* Ok, everything looks good - let it rip */
28209 - mm->total_vm += grow;
28210 + vx_vmpages_add(mm, grow);
28211 if (vma->vm_flags & VM_LOCKED)
28212 - mm->locked_vm += grow;
28213 + vx_vmlocked_add(mm, grow);
28214 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
28217 @@ -1662,9 +1662,9 @@ static void remove_vma_list(struct mm_st
28219 long nrpages = vma_pages(vma);
28221 - mm->total_vm -= nrpages;
28222 + vx_vmpages_sub(mm, nrpages);
28223 if (vma->vm_flags & VM_LOCKED)
28224 - mm->locked_vm -= nrpages;
28225 + vx_vmlocked_sub(mm, nrpages);
28226 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
28227 vma = remove_vma(vma);
28229 @@ -1903,6 +1903,8 @@ unsigned long do_brk(unsigned long addr,
28230 lock_limit >>= PAGE_SHIFT;
28231 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
28233 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
28238 @@ -1929,7 +1931,8 @@ unsigned long do_brk(unsigned long addr,
28239 if (mm->map_count > sysctl_max_map_count)
28242 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
28243 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
28244 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
28247 /* Can we just expand an old private anonymous mapping? */
28248 @@ -1955,9 +1958,9 @@ unsigned long do_brk(unsigned long addr,
28249 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)];
28250 vma_link(mm, vma, prev, rb_link, rb_parent);
28252 - mm->total_vm += len >> PAGE_SHIFT;
28253 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28254 if (flags & VM_LOCKED) {
28255 - mm->locked_vm += len >> PAGE_SHIFT;
28256 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
28257 make_pages_present(addr, addr + len);
28260 @@ -1986,6 +1989,11 @@ void exit_mmap(struct mm_struct *mm)
28261 free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, 0);
28262 tlb_finish_mmu(tlb, 0, end);
28264 + set_mm_counter(mm, file_rss, 0);
28265 + set_mm_counter(mm, anon_rss, 0);
28266 + vx_vmpages_sub(mm, mm->total_vm);
28267 + vx_vmlocked_sub(mm, mm->locked_vm);
28270 * Walk the list again, actually closing and freeing it,
28271 * with preemption enabled, without holding any MM locks.
28272 @@ -2025,7 +2033,8 @@ int insert_vm_struct(struct mm_struct *
28273 if (__vma && __vma->vm_start < vma->vm_end)
28275 if ((vma->vm_flags & VM_ACCOUNT) &&
28276 - security_vm_enough_memory(vma_pages(vma)))
28277 + (security_vm_enough_memory(vma_pages(vma)) ||
28278 + !vx_vmpages_avail(mm, vma_pages(vma))))
28280 vma_link(mm, vma, prev, rb_link, rb_parent);
28282 @@ -2098,6 +2107,8 @@ int may_expand_vm(struct mm_struct *mm,
28284 if (cur + npages > lim)
28286 + if (!vx_vmpages_avail(mm, npages))
28291 @@ -2168,7 +2179,6 @@ int install_special_mapping(struct mm_st
28295 - mm->total_vm += len >> PAGE_SHIFT;
28297 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28300 diff -Nurp linux-2.6.22.18/mm/mremap.c linux-2.6.22.18-vs2.3.0.32/mm/mremap.c
28301 --- linux-2.6.22.18/mm/mremap.c 2007-05-04 15:58:24.000000000 +0200
28302 +++ linux-2.6.22.18-vs2.3.0.32/mm/mremap.c 2008-02-11 12:35:38.000000000 +0100
28304 #include <linux/highmem.h>
28305 #include <linux/security.h>
28306 #include <linux/syscalls.h>
28307 +#include <linux/vs_memory.h>
28309 #include <asm/uaccess.h>
28310 #include <asm/cacheflush.h>
28311 @@ -212,7 +213,7 @@ static unsigned long move_vma(struct vm_
28312 * If this were a serious issue, we'd add a flag to do_munmap().
28314 hiwater_vm = mm->hiwater_vm;
28315 - mm->total_vm += new_len >> PAGE_SHIFT;
28316 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
28317 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
28319 if (do_munmap(mm, old_addr, old_len) < 0) {
28320 @@ -230,7 +231,7 @@ static unsigned long move_vma(struct vm_
28323 if (vm_flags & VM_LOCKED) {
28324 - mm->locked_vm += new_len >> PAGE_SHIFT;
28325 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
28326 if (new_len > old_len)
28327 make_pages_present(new_addr + old_len,
28328 new_addr + new_len);
28329 @@ -337,6 +338,9 @@ unsigned long do_mremap(unsigned long ad
28331 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
28333 + if (!vx_vmlocked_avail(current->mm,
28334 + (new_len - old_len) >> PAGE_SHIFT))
28337 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
28339 @@ -365,10 +369,10 @@ unsigned long do_mremap(unsigned long ad
28340 vma_adjust(vma, vma->vm_start,
28341 addr + new_len, vma->vm_pgoff, NULL);
28343 - mm->total_vm += pages;
28344 + vx_vmpages_add(mm, pages);
28345 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
28346 if (vma->vm_flags & VM_LOCKED) {
28347 - mm->locked_vm += pages;
28348 + vx_vmlocked_add(mm, pages);
28349 make_pages_present(addr + old_len,
28352 diff -Nurp linux-2.6.22.18/mm/nommu.c linux-2.6.22.18-vs2.3.0.32/mm/nommu.c
28353 --- linux-2.6.22.18/mm/nommu.c 2007-07-22 00:00:25.000000000 +0200
28354 +++ linux-2.6.22.18-vs2.3.0.32/mm/nommu.c 2008-02-11 12:35:39.000000000 +0100
28355 @@ -936,7 +936,7 @@ unsigned long do_mmap_pgoff(struct file
28356 realalloc += kobjsize(vma);
28357 askedalloc += sizeof(*vma);
28359 - current->mm->total_vm += len >> PAGE_SHIFT;
28360 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
28362 add_nommu_vma(vma);
28364 @@ -1061,7 +1061,7 @@ int do_munmap(struct mm_struct *mm, unsi
28367 update_hiwater_vm(mm);
28368 - mm->total_vm -= len >> PAGE_SHIFT;
28369 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
28372 show_process_blocks();
28373 @@ -1093,7 +1093,7 @@ void exit_mmap(struct mm_struct * mm)
28374 printk("Exit_mmap:\n");
28377 - mm->total_vm = 0;
28378 + vx_vmpages_sub(mm, mm->total_vm);
28380 while ((tmp = mm->context.vmlist)) {
28381 mm->context.vmlist = tmp->next;
28382 diff -Nurp linux-2.6.22.18/mm/oom_kill.c linux-2.6.22.18-vs2.3.0.32/mm/oom_kill.c
28383 --- linux-2.6.22.18/mm/oom_kill.c 2007-07-22 00:00:25.000000000 +0200
28384 +++ linux-2.6.22.18-vs2.3.0.32/mm/oom_kill.c 2008-02-11 12:35:39.000000000 +0100
28386 #include <linux/cpuset.h>
28387 #include <linux/module.h>
28388 #include <linux/notifier.h>
28389 +#include <linux/vs_memory.h>
28391 int sysctl_panic_on_oom;
28392 /* #define DEBUG */
28393 @@ -66,6 +67,12 @@ unsigned long badness(struct task_struct
28394 points = mm->total_vm;
28397 + * add points for context badness
28400 + points += vx_badness(p, mm);
28403 * After this unlock we can no longer dereference local variable `mm'
28406 @@ -156,8 +163,8 @@ unsigned long badness(struct task_struct
28410 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %d points\n",
28411 - p->pid, p->comm, points);
28412 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
28413 + p->pid, p->xid, p->comm, points);
28417 @@ -288,7 +295,8 @@ static void __oom_kill_task(struct task_
28421 - printk(KERN_ERR "Killed process %d (%s)\n", p->pid, p->comm);
28422 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
28423 + p->pid, p->xid, p->comm);
28426 * We give our sacrificial lamb high priority and access to
28427 @@ -358,8 +366,8 @@ static int oom_kill_process(struct task_
28431 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
28432 - message, p->pid, p->comm, points);
28433 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
28434 + message, p->pid, p->xid, p->comm, points);
28436 /* Try to kill a child first */
28437 list_for_each(tsk, &p->children) {
28438 diff -Nurp linux-2.6.22.18/mm/page_alloc.c linux-2.6.22.18-vs2.3.0.32/mm/page_alloc.c
28439 --- linux-2.6.22.18/mm/page_alloc.c 2007-07-22 00:00:25.000000000 +0200
28440 +++ linux-2.6.22.18-vs2.3.0.32/mm/page_alloc.c 2008-02-11 12:35:39.000000000 +0100
28442 #include <linux/pfn.h>
28443 #include <linux/backing-dev.h>
28444 #include <linux/fault-inject.h>
28445 +#include <linux/vs_base.h>
28446 +#include <linux/vs_limit.h>
28448 #include <asm/tlbflush.h>
28449 #include <asm/div64.h>
28450 @@ -1488,6 +1490,9 @@ void si_meminfo(struct sysinfo *val)
28451 val->totalhigh = totalhigh_pages;
28452 val->freehigh = nr_free_highpages();
28453 val->mem_unit = PAGE_SIZE;
28455 + if (vx_flags(VXF_VIRT_MEM, 0))
28456 + vx_vsi_meminfo(val);
28459 EXPORT_SYMBOL(si_meminfo);
28460 @@ -1508,6 +1513,9 @@ void si_meminfo_node(struct sysinfo *val
28463 val->mem_unit = PAGE_SIZE;
28465 + if (vx_flags(VXF_VIRT_MEM, 0))
28466 + vx_vsi_meminfo(val);
28470 diff -Nurp linux-2.6.22.18/mm/rmap.c linux-2.6.22.18-vs2.3.0.32/mm/rmap.c
28471 --- linux-2.6.22.18/mm/rmap.c 2007-07-22 00:00:25.000000000 +0200
28472 +++ linux-2.6.22.18-vs2.3.0.32/mm/rmap.c 2008-02-11 12:35:39.000000000 +0100
28474 #include <linux/rcupdate.h>
28475 #include <linux/module.h>
28476 #include <linux/kallsyms.h>
28477 +#include <linux/vs_memory.h>
28479 #include <asm/tlbflush.h>
28481 diff -Nurp linux-2.6.22.18/mm/shmem.c linux-2.6.22.18-vs2.3.0.32/mm/shmem.c
28482 --- linux-2.6.22.18/mm/shmem.c 2008-01-15 16:00:35.000000000 +0100
28483 +++ linux-2.6.22.18-vs2.3.0.32/mm/shmem.c 2008-02-11 12:35:39.000000000 +0100
28485 #include <asm/pgtable.h>
28487 /* This magic number is used in glibc for posix shared memory */
28488 -#define TMPFS_MAGIC 0x01021994
28490 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
28491 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
28492 @@ -1750,7 +1749,7 @@ static int shmem_statfs(struct dentry *d
28494 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
28496 - buf->f_type = TMPFS_MAGIC;
28497 + buf->f_type = TMPFS_SUPER_MAGIC;
28498 buf->f_bsize = PAGE_CACHE_SIZE;
28499 buf->f_namelen = NAME_MAX;
28500 spin_lock(&sbinfo->stat_lock);
28501 @@ -2324,7 +2323,7 @@ static int shmem_fill_super(struct super
28502 sb->s_maxbytes = SHMEM_MAX_BYTES;
28503 sb->s_blocksize = PAGE_CACHE_SIZE;
28504 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
28505 - sb->s_magic = TMPFS_MAGIC;
28506 + sb->s_magic = TMPFS_SUPER_MAGIC;
28507 sb->s_op = &shmem_ops;
28508 sb->s_time_gran = 1;
28509 #ifdef CONFIG_TMPFS_POSIX_ACL
28510 diff -Nurp linux-2.6.22.18/mm/slab.c linux-2.6.22.18-vs2.3.0.32/mm/slab.c
28511 --- linux-2.6.22.18/mm/slab.c 2007-07-22 00:00:25.000000000 +0200
28512 +++ linux-2.6.22.18-vs2.3.0.32/mm/slab.c 2008-02-11 12:35:40.000000000 +0100
28513 @@ -510,6 +510,8 @@ struct kmem_cache {
28514 #define STATS_INC_FREEMISS(x) do { } while (0)
28517 +#include "slab_vs.h"
28522 @@ -3314,6 +3316,7 @@ retry:
28524 obj = slab_get_obj(cachep, slabp, nodeid);
28525 check_slabp(cachep, slabp);
28526 + vx_slab_alloc(cachep, flags);
28527 l3->free_objects--;
28528 /* move slabp to correct slabp list: */
28529 list_del(&slabp->list);
28530 @@ -3386,6 +3389,7 @@ __cache_alloc_node(struct kmem_cache *ca
28531 /* ___cache_alloc_node can fall back to other nodes */
28532 ptr = ____cache_alloc_node(cachep, flags, nodeid);
28534 + vx_slab_alloc(cachep, flags);
28535 local_irq_restore(save_flags);
28536 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
28538 @@ -3551,6 +3555,7 @@ static inline void __cache_free(struct k
28541 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
28542 + vx_slab_free(cachep);
28544 if (cache_free_alien(cachep, objp))
28546 diff -Nurp linux-2.6.22.18/mm/slab_vs.h linux-2.6.22.18-vs2.3.0.32/mm/slab_vs.h
28547 --- linux-2.6.22.18/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
28548 +++ linux-2.6.22.18-vs2.3.0.32/mm/slab_vs.h 2008-02-11 12:35:40.000000000 +0100
28551 +#include <linux/vserver/context.h>
28553 +#include <linux/vs_context.h>
28556 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
28558 + int what = gfp_zone(cachep->gfpflags);
28560 + if (!current->vx_info)
28563 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
28567 +void vx_slab_free(struct kmem_cache *cachep)
28569 + int what = gfp_zone(cachep->gfpflags);
28571 + if (!current->vx_info)
28574 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
28577 diff -Nurp linux-2.6.22.18/mm/swapfile.c linux-2.6.22.18-vs2.3.0.32/mm/swapfile.c
28578 --- linux-2.6.22.18/mm/swapfile.c 2007-07-22 00:00:25.000000000 +0200
28579 +++ linux-2.6.22.18-vs2.3.0.32/mm/swapfile.c 2008-02-11 12:35:40.000000000 +0100
28581 #include <asm/pgtable.h>
28582 #include <asm/tlbflush.h>
28583 #include <linux/swapops.h>
28584 +#include <linux/vs_base.h>
28585 +#include <linux/vs_memory.h>
28587 DEFINE_SPINLOCK(swap_lock);
28588 unsigned int nr_swapfiles;
28589 @@ -1712,6 +1714,8 @@ void si_swapinfo(struct sysinfo *val)
28590 val->freeswap = nr_swap_pages + nr_to_be_unused;
28591 val->totalswap = total_swap_pages + nr_to_be_unused;
28592 spin_unlock(&swap_lock);
28593 + if (vx_flags(VXF_VIRT_MEM, 0))
28594 + vx_vsi_swapinfo(val);
28598 diff -Nurp linux-2.6.22.18/net/core/dev.c linux-2.6.22.18-vs2.3.0.32/net/core/dev.c
28599 --- linux-2.6.22.18/net/core/dev.c 2007-09-05 07:07:59.000000000 +0200
28600 +++ linux-2.6.22.18-vs2.3.0.32/net/core/dev.c 2008-02-11 12:35:40.000000000 +0100
28601 @@ -117,6 +117,7 @@
28602 #include <linux/err.h>
28603 #include <linux/ctype.h>
28604 #include <linux/if_arp.h>
28605 +#include <linux/vs_inet.h>
28608 * The list of packet types we will receive (as opposed to discard)
28609 @@ -2120,6 +2121,8 @@ static int dev_ifconf(char __user *arg)
28612 for_each_netdev(dev) {
28613 + if (!nx_dev_visible(current->nx_info, dev))
28615 for (i = 0; i < NPROTO; i++) {
28616 if (gifconf_list[i]) {
28618 @@ -2184,6 +2187,9 @@ static void dev_seq_printf_stats(struct
28620 struct net_device_stats *stats = dev->get_stats(dev);
28622 + if (!nx_dev_visible(current->nx_info, dev))
28625 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
28626 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
28627 dev->name, stats->rx_bytes, stats->rx_packets,
28628 diff -Nurp linux-2.6.22.18/net/core/rtnetlink.c linux-2.6.22.18-vs2.3.0.32/net/core/rtnetlink.c
28629 --- linux-2.6.22.18/net/core/rtnetlink.c 2007-07-22 00:00:25.000000000 +0200
28630 +++ linux-2.6.22.18-vs2.3.0.32/net/core/rtnetlink.c 2008-02-11 12:35:40.000000000 +0100
28631 @@ -537,6 +537,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
28634 for_each_netdev(dev) {
28635 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
28639 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
28640 @@ -797,6 +799,9 @@ void rtmsg_ifinfo(int type, struct net_d
28641 struct sk_buff *skb;
28642 int err = -ENOBUFS;
28644 + if (!nx_dev_visible(current->nx_info, dev))
28647 skb = nlmsg_new(if_nlmsg_size(), GFP_KERNEL);
28650 diff -Nurp linux-2.6.22.18/net/core/sock.c linux-2.6.22.18-vs2.3.0.32/net/core/sock.c
28651 --- linux-2.6.22.18/net/core/sock.c 2007-07-22 00:00:25.000000000 +0200
28652 +++ linux-2.6.22.18-vs2.3.0.32/net/core/sock.c 2008-02-11 12:35:40.000000000 +0100
28653 @@ -125,6 +125,10 @@
28654 #include <linux/ipsec.h>
28656 #include <linux/filter.h>
28657 +#include <linux/vs_socket.h>
28658 +#include <linux/vs_limit.h>
28659 +#include <linux/vs_context.h>
28660 +#include <linux/vs_network.h>
28663 #include <net/tcp.h>
28664 @@ -812,6 +816,9 @@ int sock_getsockopt(struct socket *sock,
28666 return security_socket_getpeersec_stream(sock, optval, optlen, len);
28669 + return vx_socket_peer_tag(sock, level, optval, optlen, len);
28672 return -ENOPROTOOPT;
28674 @@ -869,6 +876,8 @@ struct sock *sk_alloc(int family, gfp_t
28675 sk->sk_prot = sk->sk_prot_creator = prot;
28676 sock_lock_init(sk);
28678 + sock_vx_init(sk);
28679 + sock_nx_init(sk);
28681 if (security_sk_alloc(sk, family, priority))
28683 @@ -907,6 +916,11 @@ void sk_free(struct sock *sk)
28684 __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
28686 security_sk_free(sk);
28688 + clr_vx_info(&sk->sk_vx_info);
28690 + clr_nx_info(&sk->sk_nx_info);
28692 if (sk->sk_prot_creator->slab != NULL)
28693 kmem_cache_free(sk->sk_prot_creator->slab, sk);
28695 @@ -924,6 +938,8 @@ struct sock *sk_clone(const struct sock
28696 sock_copy(newsk, sk);
28699 + sock_vx_init(newsk);
28700 + sock_nx_init(newsk);
28701 sk_node_init(&newsk->sk_node);
28702 sock_lock_init(newsk);
28703 bh_lock_sock(newsk);
28704 @@ -969,6 +985,12 @@ struct sock *sk_clone(const struct sock
28705 newsk->sk_priority = 0;
28706 atomic_set(&newsk->sk_refcnt, 2);
28708 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
28709 + newsk->sk_xid = sk->sk_xid;
28710 + vx_sock_inc(newsk);
28711 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
28712 + newsk->sk_nid = sk->sk_nid;
28715 * Increment the counter in the same struct proto as the master
28716 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
28717 @@ -1551,6 +1573,11 @@ void sock_init_data(struct socket *sock,
28719 sk->sk_stamp = ktime_set(-1L, -1L);
28721 + set_vx_info(&sk->sk_vx_info, current->vx_info);
28722 + sk->sk_xid = vx_current_xid();
28724 + set_nx_info(&sk->sk_nx_info, current->nx_info);
28725 + sk->sk_nid = nx_current_nid();
28726 atomic_set(&sk->sk_refcnt, 1);
28729 diff -Nurp linux-2.6.22.18/net/ipv4/af_inet.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/af_inet.c
28730 --- linux-2.6.22.18/net/ipv4/af_inet.c 2007-09-05 07:07:59.000000000 +0200
28731 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/af_inet.c 2008-02-11 12:35:40.000000000 +0100
28732 @@ -115,6 +115,7 @@
28733 #ifdef CONFIG_IP_MROUTE
28734 #include <linux/mroute.h>
28736 +#include <linux/vs_limit.h>
28738 DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly;
28740 @@ -308,9 +309,12 @@ lookup_protocol:
28744 + if ((protocol == IPPROTO_ICMP) &&
28745 + nx_capable(answer->capability, NXC_RAW_ICMP))
28747 if (answer->capability > 0 && !capable(answer->capability))
28748 goto out_rcu_unlock;
28751 sock->ops = answer->ops;
28752 answer_prot = answer->prot;
28753 answer_no_check = answer->no_check;
28754 @@ -424,6 +428,7 @@ int inet_bind(struct socket *sock, struc
28755 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
28756 struct sock *sk = sock->sk;
28757 struct inet_sock *inet = inet_sk(sk);
28758 + struct nx_v4_sock_addr nsa;
28759 unsigned short snum;
28762 @@ -437,7 +442,11 @@ int inet_bind(struct socket *sock, struc
28763 if (addr_len < sizeof(struct sockaddr_in))
28766 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
28767 + err = v4_map_sock_addr(inet, addr, &nsa);
28771 + chk_addr_ret = inet_addr_type(nsa.saddr);
28773 /* Not specified by any standard per-se, however it breaks too
28774 * many applications when removed. It is unfortunate since
28775 @@ -449,7 +458,7 @@ int inet_bind(struct socket *sock, struc
28776 err = -EADDRNOTAVAIL;
28777 if (!sysctl_ip_nonlocal_bind &&
28779 - addr->sin_addr.s_addr != INADDR_ANY &&
28780 + nsa.saddr != INADDR_ANY &&
28781 chk_addr_ret != RTN_LOCAL &&
28782 chk_addr_ret != RTN_MULTICAST &&
28783 chk_addr_ret != RTN_BROADCAST)
28784 @@ -474,7 +483,7 @@ int inet_bind(struct socket *sock, struc
28785 if (sk->sk_state != TCP_CLOSE || inet->num)
28786 goto out_release_sock;
28788 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
28789 + v4_set_sock_addr(inet, &nsa);
28790 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
28791 inet->saddr = 0; /* Use device */
28793 @@ -667,11 +676,13 @@ int inet_getname(struct socket *sock, st
28796 sin->sin_port = inet->dport;
28797 - sin->sin_addr.s_addr = inet->daddr;
28798 + sin->sin_addr.s_addr =
28799 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
28801 __be32 addr = inet->rcv_saddr;
28803 addr = inet->saddr;
28804 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
28805 sin->sin_port = inet->sport;
28806 sin->sin_addr.s_addr = addr;
28808 diff -Nurp linux-2.6.22.18/net/ipv4/devinet.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/devinet.c
28809 --- linux-2.6.22.18/net/ipv4/devinet.c 2008-02-11 12:34:20.000000000 +0100
28810 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/devinet.c 2008-02-11 12:35:40.000000000 +0100
28811 @@ -427,6 +427,7 @@ struct in_device *inetdev_by_index(int i
28816 /* Called only from RTNL semaphored context. No locks. */
28818 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
28819 @@ -676,6 +677,8 @@ int devinet_ioctl(unsigned int cmd, void
28822 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
28823 + struct nx_info *nxi = current->nx_info;
28825 if (tryaddrmatch) {
28826 /* Matthias Andree */
28827 /* compare label and address (4.4BSD style) */
28828 @@ -684,6 +687,8 @@ int devinet_ioctl(unsigned int cmd, void
28829 This is checked above. */
28830 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
28831 ifap = &ifa->ifa_next) {
28832 + if (!nx_v4_ifa_visible(nxi, ifa))
28834 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
28835 sin_orig.sin_addr.s_addr ==
28836 ifa->ifa_address) {
28837 @@ -696,9 +701,12 @@ int devinet_ioctl(unsigned int cmd, void
28838 comparing just the label */
28840 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
28841 - ifap = &ifa->ifa_next)
28842 + ifap = &ifa->ifa_next) {
28843 + if (!nx_v4_ifa_visible(nxi, ifa))
28845 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
28851 @@ -849,6 +857,8 @@ static int inet_gifconf(struct net_devic
28854 for (; ifa; ifa = ifa->ifa_next) {
28855 + if (!nx_v4_ifa_visible(current->nx_info, ifa))
28858 done += sizeof(ifr);
28860 @@ -1179,6 +1189,7 @@ static int inet_dump_ifaddr(struct sk_bu
28861 struct net_device *dev;
28862 struct in_device *in_dev;
28863 struct in_ifaddr *ifa;
28864 + struct sock *sk = skb->sk;
28865 int s_ip_idx, s_idx = cb->args[0];
28867 s_ip_idx = ip_idx = cb->args[1];
28868 @@ -1193,6 +1204,8 @@ static int inet_dump_ifaddr(struct sk_bu
28870 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
28871 ifa = ifa->ifa_next, ip_idx++) {
28872 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
28874 if (ip_idx < s_ip_idx)
28876 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
28877 diff -Nurp linux-2.6.22.18/net/ipv4/fib_hash.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/fib_hash.c
28878 --- linux-2.6.22.18/net/ipv4/fib_hash.c 2007-07-22 00:00:25.000000000 +0200
28879 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/fib_hash.c 2008-02-11 12:35:41.000000000 +0100
28880 @@ -1012,7 +1012,7 @@ static int fib_seq_show(struct seq_file
28881 prefix = f->fn_key;
28882 mask = FZ_MASK(iter->zone);
28883 flags = fib_flag_trans(fa->fa_type, mask, fi);
28885 + if (fi && nx_dev_visible(current->nx_info, fi->fib_dev))
28886 snprintf(bf, sizeof(bf),
28887 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
28888 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
28889 diff -Nurp linux-2.6.22.18/net/ipv4/inet_connection_sock.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/inet_connection_sock.c
28890 --- linux-2.6.22.18/net/ipv4/inet_connection_sock.c 2007-07-22 00:00:25.000000000 +0200
28891 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/inet_connection_sock.c 2008-02-11 12:35:41.000000000 +0100
28892 @@ -34,10 +34,40 @@ EXPORT_SYMBOL(inet_csk_timer_bug_msg);
28894 int sysctl_local_port_range[2] = { 32768, 61000 };
28896 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
28898 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
28899 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
28901 + if (inet_v6_ipv6only(sk2))
28904 + if (sk1_rcv_saddr &&
28906 + sk1_rcv_saddr == sk2_rcv_saddr)
28909 + if (sk1_rcv_saddr &&
28910 + !sk2_rcv_saddr &&
28911 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
28914 + if (sk2_rcv_saddr &&
28915 + !sk1_rcv_saddr &&
28916 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
28919 + if (!sk1_rcv_saddr &&
28920 + !sk2_rcv_saddr &&
28921 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
28927 int inet_csk_bind_conflict(const struct sock *sk,
28928 const struct inet_bind_bucket *tb)
28930 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
28932 struct hlist_node *node;
28933 int reuse = sk->sk_reuse;
28934 @@ -50,9 +80,7 @@ int inet_csk_bind_conflict(const struct
28935 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
28936 if (!reuse || !sk2->sk_reuse ||
28937 sk2->sk_state == TCP_LISTEN) {
28938 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28939 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
28940 - sk2_rcv_saddr == sk_rcv_saddr)
28941 + if (ipv4_rcv_saddr_equal(sk, sk2))
28945 diff -Nurp linux-2.6.22.18/net/ipv4/inet_diag.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/inet_diag.c
28946 --- linux-2.6.22.18/net/ipv4/inet_diag.c 2007-09-29 14:11:49.000000000 +0200
28947 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/inet_diag.c 2008-02-11 12:35:41.000000000 +0100
28948 @@ -98,8 +98,8 @@ static int inet_csk_diag_fill(struct soc
28950 r->id.idiag_sport = inet->sport;
28951 r->id.idiag_dport = inet->dport;
28952 - r->id.idiag_src[0] = inet->rcv_saddr;
28953 - r->id.idiag_dst[0] = inet->daddr;
28954 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
28955 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
28957 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
28958 if (r->idiag_family == AF_INET6) {
28959 @@ -186,8 +186,8 @@ static int inet_twsk_diag_fill(struct in
28960 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
28961 r->id.idiag_sport = tw->tw_sport;
28962 r->id.idiag_dport = tw->tw_dport;
28963 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
28964 - r->id.idiag_dst[0] = tw->tw_daddr;
28965 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
28966 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
28967 r->idiag_state = tw->tw_substate;
28968 r->idiag_timer = 3;
28969 r->idiag_expires = (tmo * 1000 + HZ - 1) / HZ;
28970 @@ -239,6 +239,7 @@ static int inet_diag_get_exact(struct sk
28971 hashinfo = handler->idiag_hashinfo;
28973 if (req->idiag_family == AF_INET) {
28974 + /* TODO: lback */
28975 sk = inet_lookup(hashinfo, req->id.idiag_dst[0],
28976 req->id.idiag_dport, req->id.idiag_src[0],
28977 req->id.idiag_sport, req->id.idiag_if);
28978 @@ -478,6 +479,7 @@ static int inet_csk_diag_dump(struct soc
28982 + /* TODO: lback */
28983 entry.saddr = &inet->rcv_saddr;
28984 entry.daddr = &inet->daddr;
28986 @@ -514,6 +516,7 @@ static int inet_twsk_diag_dump(struct in
28990 + /* TODO: lback */
28991 entry.saddr = &tw->tw_rcv_saddr;
28992 entry.daddr = &tw->tw_daddr;
28994 @@ -560,8 +563,8 @@ static int inet_diag_fill_req(struct sk_
28996 r->id.idiag_sport = inet->sport;
28997 r->id.idiag_dport = ireq->rmt_port;
28998 - r->id.idiag_src[0] = ireq->loc_addr;
28999 - r->id.idiag_dst[0] = ireq->rmt_addr;
29000 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
29001 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
29002 r->idiag_expires = jiffies_to_msecs(tmo);
29003 r->idiag_rqueue = 0;
29004 r->idiag_wqueue = 0;
29005 @@ -631,6 +634,7 @@ static int inet_diag_dump_reqs(struct sk
29009 + /* TODO: lback */
29011 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
29012 (entry.family == AF_INET6) ?
29013 @@ -697,6 +701,8 @@ static int inet_diag_dump(struct sk_buff
29014 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
29015 struct inet_sock *inet = inet_sk(sk);
29017 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29022 @@ -757,6 +763,8 @@ skip_listen_ht:
29023 sk_for_each(sk, node, &head->chain) {
29024 struct inet_sock *inet = inet_sk(sk);
29026 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29030 if (!(r->idiag_states & (1 << sk->sk_state)))
29031 @@ -781,6 +789,8 @@ next_normal:
29032 inet_twsk_for_each(tw, node,
29035 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
29039 if (r->id.idiag_sport != tw->tw_sport &&
29040 diff -Nurp linux-2.6.22.18/net/ipv4/inet_hashtables.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/inet_hashtables.c
29041 --- linux-2.6.22.18/net/ipv4/inet_hashtables.c 2007-07-21 23:58:55.000000000 +0200
29042 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/inet_hashtables.c 2008-02-11 12:35:41.000000000 +0100
29043 @@ -140,11 +140,10 @@ static struct sock *inet_lookup_listener
29044 const __be32 rcv_saddr = inet->rcv_saddr;
29045 int score = sk->sk_family == PF_INET ? 1 : 0;
29048 - if (rcv_saddr != daddr)
29050 + if (v4_inet_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
29055 if (sk->sk_bound_dev_if) {
29056 if (sk->sk_bound_dev_if != dif)
29058 @@ -175,7 +174,7 @@ struct sock *__inet_lookup_listener(stru
29059 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
29061 if (inet->num == hnum && !sk->sk_node.next &&
29062 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
29063 + v4_inet_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
29064 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
29065 !sk->sk_bound_dev_if)
29067 diff -Nurp linux-2.6.22.18/net/ipv4/raw.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/raw.c
29068 --- linux-2.6.22.18/net/ipv4/raw.c 2007-07-22 00:00:27.000000000 +0200
29069 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/raw.c 2008-02-11 12:35:41.000000000 +0100
29070 @@ -112,7 +112,7 @@ struct sock *__raw_v4_lookup(struct sock
29072 if (inet->num == num &&
29073 !(inet->daddr && inet->daddr != raddr) &&
29074 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
29075 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
29076 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
29077 goto found; /* gotcha */
29079 @@ -314,6 +314,12 @@ static int raw_send_hdrinc(struct sock *
29080 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
29084 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
29085 + sk->sk_nx_info &&
29086 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
29089 err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
29092 @@ -325,6 +331,7 @@ out:
29099 IP_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
29100 @@ -491,6 +498,12 @@ static int raw_sendmsg(struct kiocb *ioc
29103 security_sk_classify_flow(sk, &fl);
29104 + if (sk->sk_nx_info) {
29105 + err = ip_v4_find_src(sk->sk_nx_info, &rt, &fl);
29110 err = ip_route_output_flow(&rt, &fl, sk, 1);
29113 @@ -553,17 +566,19 @@ static int raw_bind(struct sock *sk, str
29115 struct inet_sock *inet = inet_sk(sk);
29116 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
29117 + struct nx_v4_sock_addr nsa = { 0 };
29121 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
29123 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
29124 + v4_map_sock_addr(inet, addr, &nsa);
29125 + chk_addr_ret = inet_addr_type(nsa.saddr);
29126 ret = -EADDRNOTAVAIL;
29127 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
29128 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
29129 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
29131 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
29132 + v4_set_sock_addr(inet, &nsa);
29133 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
29134 inet->saddr = 0; /* Use device */
29136 @@ -615,7 +630,8 @@ static int raw_recvmsg(struct kiocb *ioc
29137 /* Copy the address. */
29139 sin->sin_family = AF_INET;
29140 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
29141 + sin->sin_addr.s_addr =
29142 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
29144 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
29146 @@ -795,7 +811,8 @@ static struct sock *raw_get_first(struct
29147 struct hlist_node *node;
29149 sk_for_each(sk, node, &raw_v4_htable[state->bucket])
29150 - if (sk->sk_family == PF_INET)
29151 + if (sk->sk_family == PF_INET &&
29152 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29156 @@ -811,7 +828,8 @@ static struct sock *raw_get_next(struct
29160 - } while (sk && sk->sk_family != PF_INET);
29161 + } while (sk && (sk->sk_family != PF_INET ||
29162 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
29164 if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
29165 sk = sk_head(&raw_v4_htable[state->bucket]);
29166 @@ -863,7 +881,10 @@ static __inline__ char *get_raw_sock(str
29168 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29169 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
29170 - i, src, srcp, dest, destp, sp->sk_state,
29172 + nx_map_sock_lback(current_nx_info(), src), srcp,
29173 + nx_map_sock_lback(current_nx_info(), dest), destp,
29175 atomic_read(&sp->sk_wmem_alloc),
29176 atomic_read(&sp->sk_rmem_alloc),
29177 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
29178 diff -Nurp linux-2.6.22.18/net/ipv4/tcp.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/tcp.c
29179 --- linux-2.6.22.18/net/ipv4/tcp.c 2007-09-05 07:07:59.000000000 +0200
29180 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/tcp.c 2008-02-11 12:35:41.000000000 +0100
29181 @@ -258,6 +258,7 @@
29182 #include <linux/cache.h>
29183 #include <linux/err.h>
29184 #include <linux/crypto.h>
29185 +#include <linux/in.h>
29187 #include <net/icmp.h>
29188 #include <net/tcp.h>
29189 diff -Nurp linux-2.6.22.18/net/ipv4/tcp_ipv4.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/tcp_ipv4.c
29190 --- linux-2.6.22.18/net/ipv4/tcp_ipv4.c 2007-12-09 12:43:41.000000000 +0100
29191 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/tcp_ipv4.c 2008-02-11 12:35:42.000000000 +0100
29192 @@ -1974,6 +1974,12 @@ static void *listening_get_next(struct s
29193 req = req->dl_next;
29196 + vxdprintk(VXD_CBIT(net, 6),
29197 + "sk,req: %p [#%d] (from %d)", req->sk,
29198 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
29200 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
29202 if (req->rsk_ops->family == st->family) {
29205 @@ -1998,6 +2004,10 @@ get_req:
29208 sk_for_each_from(sk, node) {
29209 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
29210 + sk, sk->sk_nid, nx_current_nid());
29211 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29213 if (sk->sk_family == st->family) {
29216 @@ -2049,18 +2059,26 @@ static void *established_get_first(struc
29218 read_lock(&tcp_hashinfo.ehash[st->bucket].lock);
29219 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
29220 - if (sk->sk_family != st->family) {
29221 + vxdprintk(VXD_CBIT(net, 6),
29222 + "sk,egf: %p [#%d] (from %d)",
29223 + sk, sk->sk_nid, nx_current_nid());
29224 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29226 + if (sk->sk_family != st->family)
29232 st->state = TCP_SEQ_STATE_TIME_WAIT;
29233 inet_twsk_for_each(tw, node,
29234 &tcp_hashinfo.ehash[st->bucket].twchain) {
29235 - if (tw->tw_family != st->family) {
29236 + vxdprintk(VXD_CBIT(net, 6),
29237 + "tw: %p [#%d] (from %d)",
29238 + tw, tw->tw_nid, nx_current_nid());
29239 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
29241 + if (tw->tw_family != st->family)
29247 @@ -2084,7 +2102,8 @@ static void *established_get_next(struct
29251 - while (tw && tw->tw_family != st->family) {
29252 + while (tw && (tw->tw_family != st->family ||
29253 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
29257 @@ -2108,6 +2127,11 @@ get_tw:
29260 sk_for_each_from(sk, node) {
29261 + vxdprintk(VXD_CBIT(net, 6),
29262 + "sk,egn: %p [#%d] (from %d)",
29263 + sk, sk->sk_nid, nx_current_nid());
29264 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29266 if (sk->sk_family == st->family)
29269 @@ -2283,9 +2307,9 @@ static void get_openreq4(struct sock *sk
29270 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29271 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p",
29274 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
29275 ntohs(inet_sk(sk)->sport),
29277 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
29278 ntohs(ireq->rmt_port),
29280 0, 0, /* could print option size, but that is af dependent. */
29281 @@ -2327,7 +2351,10 @@ static void get_tcp4_sock(struct sock *s
29283 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
29284 "%08X %5d %8d %lu %d %p %u %u %u %u %d",
29285 - i, src, srcp, dest, destp, sk->sk_state,
29287 + nx_map_sock_lback(current_nx_info(), src), srcp,
29288 + nx_map_sock_lback(current_nx_info(), dest), destp,
29290 tp->write_seq - tp->snd_una,
29291 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
29292 (tp->rcv_nxt - tp->copied_seq),
29293 @@ -2362,7 +2389,10 @@ static void get_timewait4_sock(struct in
29295 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29296 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p",
29297 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
29299 + nx_map_sock_lback(current_nx_info(), src), srcp,
29300 + nx_map_sock_lback(current_nx_info(), dest), destp,
29301 + tw->tw_substate, 0, 0,
29302 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
29303 atomic_read(&tw->tw_refcnt), tw);
29305 diff -Nurp linux-2.6.22.18/net/ipv4/tcp_minisocks.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/tcp_minisocks.c
29306 --- linux-2.6.22.18/net/ipv4/tcp_minisocks.c 2007-07-22 00:00:27.000000000 +0200
29307 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/tcp_minisocks.c 2008-02-11 12:35:42.000000000 +0100
29309 #include <net/inet_common.h>
29310 #include <net/xfrm.h>
29312 +#include <linux/vs_limit.h>
29313 +#include <linux/vs_socket.h>
29314 +#include <linux/vs_context.h>
29316 #ifdef CONFIG_SYSCTL
29317 #define SYNC_INIT 0 /* let the user enable it */
29319 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
29320 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
29321 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
29323 + tw->tw_xid = sk->sk_xid;
29324 + tw->tw_vx_info = NULL;
29325 + tw->tw_nid = sk->sk_nid;
29326 + tw->tw_nx_info = NULL;
29328 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
29329 if (tw->tw_family == PF_INET6) {
29330 struct ipv6_pinfo *np = inet6_sk(sk);
29331 diff -Nurp linux-2.6.22.18/net/ipv4/udp.c linux-2.6.22.18-vs2.3.0.32/net/ipv4/udp.c
29332 --- linux-2.6.22.18/net/ipv4/udp.c 2007-07-22 00:00:27.000000000 +0200
29333 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv4/udp.c 2008-02-11 12:35:42.000000000 +0100
29334 @@ -219,14 +219,7 @@ int udp_get_port(struct sock *sk, unsign
29335 return __udp_lib_get_port(sk, snum, udp_hash, &udp_port_rover, scmp);
29338 -int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
29340 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
29342 - return ( !ipv6_only_sock(sk2) &&
29343 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
29344 - inet1->rcv_saddr == inet2->rcv_saddr ));
29346 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
29348 static inline int udp_v4_get_port(struct sock *sk, unsigned short snum)
29350 @@ -246,15 +239,22 @@ static struct sock *__udp4_lib_lookup(__
29353 read_lock(&udp_hash_lock);
29355 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
29356 struct inet_sock *inet = inet_sk(sk);
29358 if (sk->sk_hash == hnum && !ipv6_only_sock(sk)) {
29359 int score = (sk->sk_family == PF_INET ? 1 : 0);
29361 if (inet->rcv_saddr) {
29362 if (inet->rcv_saddr != daddr)
29366 + /* block non nx_info ips */
29367 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
29368 + daddr, NXA_MASK_BIND))
29372 if (inet->daddr != saddr)
29373 @@ -280,6 +280,7 @@ static struct sock *__udp4_lib_lookup(__
29380 read_unlock(&udp_hash_lock);
29381 @@ -301,7 +302,7 @@ static inline struct sock *udp_v4_mcast_
29382 if (s->sk_hash != hnum ||
29383 (inet->daddr && inet->daddr != rmt_addr) ||
29384 (inet->dport != rmt_port && inet->dport) ||
29385 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
29386 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
29387 ipv6_only_sock(s) ||
29388 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
29390 @@ -631,7 +632,14 @@ int udp_sendmsg(struct kiocb *iocb, stru
29391 .uli_u = { .ports =
29392 { .sport = inet->sport,
29393 .dport = dport } } };
29394 + struct nx_info *nxi = sk->sk_nx_info;
29396 security_sk_classify_flow(sk, &fl);
29398 + err = ip_v4_find_src(nxi, &rt, &fl);
29402 err = ip_route_output_flow(&rt, &fl, sk, 1);
29404 if (err == -ENETUNREACH)
29405 @@ -871,7 +879,8 @@ try_again:
29407 sin->sin_family = AF_INET;
29408 sin->sin_port = udp_hdr(skb)->source;
29409 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
29410 + sin->sin_addr.s_addr = nx_map_sock_lback(
29411 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
29412 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
29414 if (inet->cmsg_flags)
29415 @@ -1551,7 +1560,8 @@ static struct sock *udp_get_first(struct
29416 for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
29417 struct hlist_node *node;
29418 sk_for_each(sk, node, state->hashtable + state->bucket) {
29419 - if (sk->sk_family == state->family)
29420 + if (sk->sk_family == state->family &&
29421 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29425 @@ -1568,7 +1578,8 @@ static struct sock *udp_get_next(struct
29429 - } while (sk && sk->sk_family != state->family);
29430 + } while (sk && (sk->sk_family != state->family ||
29431 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
29433 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
29434 sk = sk_head(state->hashtable + state->bucket);
29435 @@ -1681,7 +1692,10 @@ static void udp4_format_sock(struct sock
29437 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29438 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
29439 - bucket, src, srcp, dest, destp, sp->sk_state,
29441 + nx_map_sock_lback(current_nx_info(), src), srcp,
29442 + nx_map_sock_lback(current_nx_info(), dest), destp,
29444 atomic_read(&sp->sk_wmem_alloc),
29445 atomic_read(&sp->sk_rmem_alloc),
29446 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
29447 diff -Nurp linux-2.6.22.18/net/ipv6/addrconf.c linux-2.6.22.18-vs2.3.0.32/net/ipv6/addrconf.c
29448 --- linux-2.6.22.18/net/ipv6/addrconf.c 2008-01-15 16:00:36.000000000 +0100
29449 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/addrconf.c 2008-02-11 12:35:42.000000000 +0100
29452 #include <linux/proc_fs.h>
29453 #include <linux/seq_file.h>
29454 +#include <linux/vs_inet6.h>
29456 /* Set to 3 to get tracing... */
29457 #define ACONF_DEBUG 2
29458 @@ -904,7 +905,8 @@ static inline int ipv6_saddr_label(const
29461 int ipv6_dev_get_saddr(struct net_device *daddr_dev,
29462 - struct in6_addr *daddr, struct in6_addr *saddr)
29463 + struct in6_addr *daddr, struct in6_addr *saddr,
29464 + struct nx_info *nxi)
29466 struct ipv6_saddr_score hiscore;
29467 struct inet6_ifaddr *ifa_result = NULL;
29468 @@ -949,6 +951,10 @@ int ipv6_dev_get_saddr(struct net_device
29470 score.addr_type = __ipv6_addr_type(&ifa->addr);
29472 + /* Use only addresses assigned to the context */
29473 + if (!v6_ifa_in_nx_info(ifa, nxi))
29477 * - Tentative Address (RFC2462 section 5.4)
29478 * - A tentative address is not considered
29479 @@ -1162,9 +1168,10 @@ record_it:
29482 int ipv6_get_saddr(struct dst_entry *dst,
29483 - struct in6_addr *daddr, struct in6_addr *saddr)
29484 + struct in6_addr *daddr, struct in6_addr *saddr,
29485 + struct nx_info *nxi)
29487 - return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr);
29488 + return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr, nxi);
29491 EXPORT_SYMBOL(ipv6_get_saddr);
29492 @@ -1260,35 +1267,46 @@ struct inet6_ifaddr * ipv6_get_ifaddr(st
29496 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
29498 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
29500 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
29501 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
29502 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
29503 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
29504 int sk_ipv6only = ipv6_only_sock(sk);
29505 int sk2_ipv6only = inet_v6_ipv6only(sk2);
29506 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
29507 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
29509 - if (!sk2_rcv_saddr && !sk_ipv6only)
29510 + /* FIXME: needs handling for v4 ANY */
29511 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
29514 if (addr_type2 == IPV6_ADDR_ANY &&
29515 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
29516 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
29517 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
29520 if (addr_type == IPV6_ADDR_ANY &&
29521 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
29522 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
29523 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
29526 + if (addr_type == IPV6_ADDR_ANY &&
29527 + addr_type2 == IPV6_ADDR_ANY &&
29528 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
29531 if (sk2_rcv_saddr6 &&
29532 + addr_type != IPV6_ADDR_ANY &&
29533 + addr_type != IPV6_ADDR_ANY &&
29534 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
29537 if (addr_type == IPV6_ADDR_MAPPED &&
29539 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
29540 + ipv4_rcv_saddr_equal(sk, sk2))
29544 @@ -2788,7 +2806,10 @@ static void if6_seq_stop(struct seq_file
29545 static int if6_seq_show(struct seq_file *seq, void *v)
29547 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
29550 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
29551 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
29553 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
29555 ifp->idev->dev->ifindex,
29556 @@ -3270,6 +3291,11 @@ static int inet6_dump_addr(struct sk_buf
29557 struct inet6_ifaddr *ifa;
29558 struct ifmcaddr6 *ifmca;
29559 struct ifacaddr6 *ifaca;
29560 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29562 + /* disable ipv6 on non v6 guests */
29563 + if (nxi && !nx_info_has_v6(nxi))
29566 s_idx = cb->args[0];
29567 s_ip_idx = ip_idx = cb->args[1];
29568 @@ -3291,6 +3317,8 @@ static int inet6_dump_addr(struct sk_buf
29569 ifa = ifa->if_next, ip_idx++) {
29570 if (ip_idx < s_ip_idx)
29572 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
29574 if ((err = inet6_fill_ifaddr(skb, ifa,
29575 NETLINK_CB(cb->skb).pid,
29576 cb->nlh->nlmsg_seq, RTM_NEWADDR,
29577 @@ -3304,6 +3332,8 @@ static int inet6_dump_addr(struct sk_buf
29578 ifmca = ifmca->next, ip_idx++) {
29579 if (ip_idx < s_ip_idx)
29581 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
29583 if ((err = inet6_fill_ifmcaddr(skb, ifmca,
29584 NETLINK_CB(cb->skb).pid,
29585 cb->nlh->nlmsg_seq, RTM_GETMULTICAST,
29586 @@ -3317,6 +3347,8 @@ static int inet6_dump_addr(struct sk_buf
29587 ifaca = ifaca->aca_next, ip_idx++) {
29588 if (ip_idx < s_ip_idx)
29590 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
29592 if ((err = inet6_fill_ifacaddr(skb, ifaca,
29593 NETLINK_CB(cb->skb).pid,
29594 cb->nlh->nlmsg_seq, RTM_GETANYCAST,
29595 @@ -3593,12 +3625,19 @@ static int inet6_dump_ifinfo(struct sk_b
29596 int s_idx = cb->args[0];
29597 struct net_device *dev;
29598 struct inet6_dev *idev;
29599 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29601 + /* FIXME: maybe disable ipv6 on non v6 guests?
29602 + if (skb->sk && skb->sk->sk_vx_info)
29603 + return skb->len; */
29605 read_lock(&dev_base_lock);
29607 for_each_netdev(dev) {
29610 + if (!v6_dev_in_nx_info(dev, nxi))
29612 if ((idev = in6_dev_get(dev)) == NULL)
29614 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
29615 diff -Nurp linux-2.6.22.18/net/ipv6/af_inet6.c linux-2.6.22.18-vs2.3.0.32/net/ipv6/af_inet6.c
29616 --- linux-2.6.22.18/net/ipv6/af_inet6.c 2007-09-05 07:08:00.000000000 +0200
29617 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/af_inet6.c 2008-02-11 12:35:42.000000000 +0100
29619 #include <linux/netdevice.h>
29620 #include <linux/icmpv6.h>
29621 #include <linux/netfilter_ipv6.h>
29622 +#include <linux/vs_inet6.h>
29624 #include <net/ip.h>
29625 #include <net/ipv6.h>
29626 @@ -150,9 +151,12 @@ lookup_protocol:
29630 + if ((protocol == IPPROTO_ICMPV6) &&
29631 + nx_capable(answer->capability, NXC_RAW_ICMP))
29633 if (answer->capability > 0 && !capable(answer->capability))
29634 goto out_rcu_unlock;
29637 sock->ops = answer->ops;
29638 answer_prot = answer->prot;
29639 answer_no_check = answer->no_check;
29640 @@ -250,6 +254,7 @@ int inet6_bind(struct socket *sock, stru
29641 struct sock *sk = sock->sk;
29642 struct inet_sock *inet = inet_sk(sk);
29643 struct ipv6_pinfo *np = inet6_sk(sk);
29644 + struct nx_v6_sock_addr nsa;
29646 unsigned short snum;
29648 @@ -261,6 +266,11 @@ int inet6_bind(struct socket *sock, stru
29650 if (addr_len < SIN6_LEN_RFC2133)
29653 + err = v6_map_sock_addr(inet, addr, &nsa);
29657 addr_type = ipv6_addr_type(&addr->sin6_addr);
29658 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
29660 @@ -284,6 +294,10 @@ int inet6_bind(struct socket *sock, stru
29661 err = -EADDRNOTAVAIL;
29664 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
29665 + err = -EADDRNOTAVAIL;
29669 if (addr_type != IPV6_ADDR_ANY) {
29670 struct net_device *dev = NULL;
29671 @@ -309,6 +323,11 @@ int inet6_bind(struct socket *sock, stru
29675 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
29676 + err = -EADDRNOTAVAIL;
29680 /* ipv4 addr of the socket is invalid. Only the
29681 * unspecified and mapped address have a v4 equivalent.
29683 @@ -326,6 +345,8 @@ int inet6_bind(struct socket *sock, stru
29687 + v6_set_sock_addr(inet, &nsa);
29689 inet->rcv_saddr = v4addr;
29690 inet->saddr = v4addr;
29692 @@ -420,9 +441,11 @@ int inet6_getname(struct socket *sock, s
29694 sin->sin6_port = inet->dport;
29695 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
29696 + /* FIXME: remap lback? */
29698 sin->sin6_flowinfo = np->flow_label;
29700 + /* FIXME: remap lback? */
29701 if (ipv6_addr_any(&np->rcv_saddr))
29702 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
29704 diff -Nurp linux-2.6.22.18/net/ipv6/fib6_rules.c linux-2.6.22.18-vs2.3.0.32/net/ipv6/fib6_rules.c
29705 --- linux-2.6.22.18/net/ipv6/fib6_rules.c 2007-07-22 00:00:27.000000000 +0200
29706 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/fib6_rules.c 2008-02-11 12:35:42.000000000 +0100
29707 @@ -107,7 +107,7 @@ static int fib6_rule_action(struct fib_r
29708 r->src.plen && !(flags & RT6_LOOKUP_F_HAS_SADDR)) {
29709 struct in6_addr saddr;
29710 if (ipv6_get_saddr(&rt->u.dst, &flp->fl6_dst,
29714 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
29716 diff -Nurp linux-2.6.22.18/net/ipv6/inet6_hashtables.c linux-2.6.22.18-vs2.3.0.32/net/ipv6/inet6_hashtables.c
29717 --- linux-2.6.22.18/net/ipv6/inet6_hashtables.c 2007-07-21 23:58:56.000000000 +0200
29718 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/inet6_hashtables.c 2008-02-11 12:35:42.000000000 +0100
29721 #include <linux/module.h>
29722 #include <linux/random.h>
29723 +#include <linux/vs_inet6.h>
29725 #include <net/inet_connection_sock.h>
29726 #include <net/inet_hashtables.h>
29727 @@ -121,6 +122,9 @@ struct sock *inet6_lookup_listener(struc
29728 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29732 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29735 if (sk->sk_bound_dev_if) {
29736 if (sk->sk_bound_dev_if != dif)
29737 diff -Nurp linux-2.6.22.18/net/ipv6/ip6_output.c linux-2.6.22.18-vs2.3.0.32/net/ipv6/ip6_output.c
29738 --- linux-2.6.22.18/net/ipv6/ip6_output.c 2007-09-29 14:11:49.000000000 +0200
29739 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/ip6_output.c 2008-02-11 12:35:42.000000000 +0100
29740 @@ -884,7 +884,7 @@ static int ip6_dst_lookup_tail(struct so
29741 goto out_err_release;
29743 if (ipv6_addr_any(&fl->fl6_src)) {
29744 - err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src);
29745 + err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src, sk->sk_nx_info);
29747 goto out_err_release;
29749 diff -Nurp linux-2.6.22.18/net/ipv6/Kconfig linux-2.6.22.18-vs2.3.0.32/net/ipv6/Kconfig
29750 --- linux-2.6.22.18/net/ipv6/Kconfig 2007-07-22 00:00:27.000000000 +0200
29751 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/Kconfig 2008-02-11 12:35:42.000000000 +0100
29754 # IPv6 as module will cause a CRASH if you try to unload it
29756 - tristate "The IPv6 protocol"
29758 + bool "The IPv6 protocol"
29761 This is complemental support for the IP version 6.
29762 You will still be able to do traditional IPv4 networking as well.
29763 diff -Nurp linux-2.6.22.18/net/ipv6/ndisc.c linux-2.6.22.18-vs2.3.0.32/net/ipv6/ndisc.c
29764 --- linux-2.6.22.18/net/ipv6/ndisc.c 2007-12-09 12:43:41.000000000 +0100
29765 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/ndisc.c 2008-02-11 12:35:42.000000000 +0100
29766 @@ -531,7 +531,7 @@ static void ndisc_send_na(struct net_dev
29770 - if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr))
29771 + if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr, NULL))
29773 src_addr = &tmpaddr;
29775 diff -Nurp linux-2.6.22.18/net/ipv6/route.c linux-2.6.22.18-vs2.3.0.32/net/ipv6/route.c
29776 --- linux-2.6.22.18/net/ipv6/route.c 2007-07-22 00:00:27.000000000 +0200
29777 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/route.c 2008-02-11 12:35:42.000000000 +0100
29778 @@ -2182,7 +2182,7 @@ static int rt6_fill_node(struct sk_buff
29779 NLA_PUT_U32(skb, RTA_IIF, iif);
29781 struct in6_addr saddr_buf;
29782 - if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf) == 0)
29783 + if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf, (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
29784 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
29787 diff -Nurp linux-2.6.22.18/net/ipv6/tcp_ipv6.c linux-2.6.22.18-vs2.3.0.32/net/ipv6/tcp_ipv6.c
29788 --- linux-2.6.22.18/net/ipv6/tcp_ipv6.c 2007-12-09 12:43:41.000000000 +0100
29789 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/tcp_ipv6.c 2008-02-11 12:35:42.000000000 +0100
29792 #include <linux/crypto.h>
29793 #include <linux/scatterlist.h>
29794 +#include <linux/vs_inet6.h>
29796 /* Socket used for sending RSTs and ACKs */
29797 static struct socket *tcp6_socket;
29798 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
29799 * connect() to INADDR_ANY means loopback (BSD'ism).
29802 - if(ipv6_addr_any(&usin->sin6_addr))
29803 - usin->sin6_addr.s6_addr[15] = 0x1;
29804 + if(ipv6_addr_any(&usin->sin6_addr)) {
29805 + struct nx_info *nxi = sk->sk_nx_info;
29807 + if (nxi && nx_info_has_v6(nxi))
29808 + /* FIXME: remap lback? */
29809 + usin->sin6_addr = nxi->v6.ip;
29811 + usin->sin6_addr.s6_addr[15] = 0x1;
29814 addr_type = ipv6_addr_type(&usin->sin6_addr);
29816 diff -Nurp linux-2.6.22.18/net/ipv6/udp.c linux-2.6.22.18-vs2.3.0.32/net/ipv6/udp.c
29817 --- linux-2.6.22.18/net/ipv6/udp.c 2007-07-22 00:00:27.000000000 +0200
29818 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/udp.c 2008-02-11 12:35:42.000000000 +0100
29821 #include <linux/proc_fs.h>
29822 #include <linux/seq_file.h>
29823 +#include <linux/vs_inet6.h>
29824 #include "udp_impl.h"
29826 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
29827 @@ -82,6 +83,10 @@ static struct sock *__udp6_lib_lookup(st
29828 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29832 + /* block non nx_info ips */
29833 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29836 if (!ipv6_addr_any(&np->daddr)) {
29837 if (!ipv6_addr_equal(&np->daddr, saddr))
29838 diff -Nurp linux-2.6.22.18/net/ipv6/xfrm6_policy.c linux-2.6.22.18-vs2.3.0.32/net/ipv6/xfrm6_policy.c
29839 --- linux-2.6.22.18/net/ipv6/xfrm6_policy.c 2007-07-22 00:00:27.000000000 +0200
29840 +++ linux-2.6.22.18-vs2.3.0.32/net/ipv6/xfrm6_policy.c 2008-02-11 12:35:42.000000000 +0100
29841 @@ -49,7 +49,7 @@ static int xfrm6_get_saddr(xfrm_address_
29843 if (!xfrm6_dst_lookup((struct xfrm_dst **)&rt, &fl_tunnel)) {
29844 ipv6_get_saddr(&rt->u.dst, (struct in6_addr *)&daddr->a6,
29845 - (struct in6_addr *)&saddr->a6);
29846 + (struct in6_addr *)&saddr->a6, NULL);
29847 dst_release(&rt->u.dst);
29850 diff -Nurp linux-2.6.22.18/net/netlink/af_netlink.c linux-2.6.22.18-vs2.3.0.32/net/netlink/af_netlink.c
29851 --- linux-2.6.22.18/net/netlink/af_netlink.c 2007-12-09 12:43:53.000000000 +0100
29852 +++ linux-2.6.22.18-vs2.3.0.32/net/netlink/af_netlink.c 2008-02-11 12:35:42.000000000 +0100
29854 #include <linux/audit.h>
29855 #include <linux/selinux.h>
29856 #include <linux/mutex.h>
29857 +#include <linux/vs_context.h>
29858 +#include <linux/vs_network.h>
29859 +#include <linux/vs_limit.h>
29861 #include <net/sock.h>
29862 #include <net/scm.h>
29863 @@ -885,6 +888,10 @@ static inline int do_one_broadcast(struc
29864 !test_bit(p->group - 1, nlk->groups))
29867 + if (sk->sk_nx_info &&
29868 + (p->group == RTNLGRP_IPV4_IFADDR || p->group == RTNLGRP_IPV6_IFADDR))
29872 netlink_overrun(sk);
29874 diff -Nurp linux-2.6.22.18/net/rxrpc/Kconfig linux-2.6.22.18-vs2.3.0.32/net/rxrpc/Kconfig
29875 --- linux-2.6.22.18/net/rxrpc/Kconfig 2008-01-15 16:00:36.000000000 +0100
29876 +++ linux-2.6.22.18-vs2.3.0.32/net/rxrpc/Kconfig 2008-02-11 12:35:42.000000000 +0100
29880 tristate "RxRPC session sockets"
29881 - depends on INET && EXPERIMENTAL
29882 + depends on INET && EXPERIMENTAL && !VSERVER_SECURITY
29886 diff -Nurp linux-2.6.22.18/net/sctp/ipv6.c linux-2.6.22.18-vs2.3.0.32/net/sctp/ipv6.c
29887 --- linux-2.6.22.18/net/sctp/ipv6.c 2007-08-12 03:54:37.000000000 +0200
29888 +++ linux-2.6.22.18-vs2.3.0.32/net/sctp/ipv6.c 2008-02-11 12:35:43.000000000 +0100
29889 @@ -303,7 +303,7 @@ static void sctp_v6_get_saddr(struct sct
29890 __FUNCTION__, asoc, dst, NIP6(daddr->v6.sin6_addr));
29893 - ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr);
29894 + ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr, asoc->base.sk->sk_nx_info);
29895 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n",
29896 NIP6(saddr->v6.sin6_addr));
29898 diff -Nurp linux-2.6.22.18/net/socket.c linux-2.6.22.18-vs2.3.0.32/net/socket.c
29899 --- linux-2.6.22.18/net/socket.c 2007-12-09 12:43:53.000000000 +0100
29900 +++ linux-2.6.22.18-vs2.3.0.32/net/socket.c 2008-02-11 12:35:43.000000000 +0100
29903 #include <net/sock.h>
29904 #include <linux/netfilter.h>
29905 +#include <linux/vs_base.h>
29906 +#include <linux/vs_socket.h>
29907 +#include <linux/vs_inet.h>
29908 +#include <linux/vs_inet6.h>
29910 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
29911 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
29912 @@ -543,7 +547,7 @@ static inline int __sock_sendmsg(struct
29913 struct msghdr *msg, size_t size)
29915 struct sock_iocb *si = kiocb_to_siocb(iocb);
29921 @@ -554,7 +558,22 @@ static inline int __sock_sendmsg(struct
29925 - return sock->ops->sendmsg(iocb, sock, msg, size);
29926 + len = sock->ops->sendmsg(iocb, sock, msg, size);
29929 + vx_sock_send(sock->sk, size);
29931 + vx_sock_fail(sock->sk, size);
29933 + vxdprintk(VXD_CBIT(net, 7),
29934 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29936 + (sock->sk)?sock->sk->sk_nx_info:0,
29937 + (sock->sk)?sock->sk->sk_vx_info:0,
29938 + (sock->sk)?sock->sk->sk_xid:0,
29939 + (sock->sk)?sock->sk->sk_nid:0,
29940 + (unsigned int)size, len);
29944 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
29945 @@ -623,7 +642,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
29946 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
29947 struct msghdr *msg, size_t size, int flags)
29951 struct sock_iocb *si = kiocb_to_siocb(iocb);
29954 @@ -636,7 +655,18 @@ static inline int __sock_recvmsg(struct
29958 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
29959 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
29960 + if ((len >= 0) && sock->sk)
29961 + vx_sock_recv(sock->sk, len);
29962 + vxdprintk(VXD_CBIT(net, 7),
29963 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29965 + (sock->sk)?sock->sk->sk_nx_info:0,
29966 + (sock->sk)?sock->sk->sk_vx_info:0,
29967 + (sock->sk)?sock->sk->sk_xid:0,
29968 + (sock->sk)?sock->sk->sk_nid:0,
29969 + (unsigned int)size, len);
29973 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
29974 @@ -1087,6 +1117,13 @@ static int __sock_create(int family, int
29975 if (type < 0 || type >= SOCK_MAX)
29978 + if (!nx_check(0, VS_ADMIN)) {
29979 + if (family == PF_INET && !current_nx_info_has_v4())
29980 + return -EAFNOSUPPORT;
29981 + if (family == PF_INET6 && !current_nx_info_has_v6())
29982 + return -EAFNOSUPPORT;
29987 This uglymoron is moved from INET layer to here to avoid
29988 @@ -1204,6 +1241,7 @@ asmlinkage long sys_socket(int family, i
29992 + set_bit(SOCK_USER_SOCKET, &sock->flags);
29993 retval = sock_map_fd(sock);
29996 @@ -1236,10 +1274,12 @@ asmlinkage long sys_socketpair(int famil
29997 err = sock_create(family, type, protocol, &sock1);
30000 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
30002 err = sock_create(family, type, protocol, &sock2);
30004 goto out_release_1;
30005 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
30007 err = sock1->ops->socketpair(sock1, sock2);
30009 diff -Nurp linux-2.6.22.18/net/sunrpc/auth.c linux-2.6.22.18-vs2.3.0.32/net/sunrpc/auth.c
30010 --- linux-2.6.22.18/net/sunrpc/auth.c 2007-07-21 23:59:04.000000000 +0200
30011 +++ linux-2.6.22.18-vs2.3.0.32/net/sunrpc/auth.c 2008-02-11 12:35:43.000000000 +0100
30013 #include <linux/errno.h>
30014 #include <linux/sunrpc/clnt.h>
30015 #include <linux/spinlock.h>
30016 +#include <linux/vs_tag.h>
30019 # define RPCDBG_FACILITY RPCDBG_AUTH
30020 @@ -263,6 +264,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
30021 struct auth_cred acred = {
30022 .uid = current->fsuid,
30023 .gid = current->fsgid,
30024 + .tag = dx_current_tag(),
30025 .group_info = current->group_info,
30027 struct rpc_cred *ret;
30028 @@ -282,6 +284,7 @@ rpcauth_bindcred(struct rpc_task *task)
30029 struct auth_cred acred = {
30030 .uid = current->fsuid,
30031 .gid = current->fsgid,
30032 + .tag = dx_current_tag(),
30033 .group_info = current->group_info,
30035 struct rpc_cred *ret;
30036 diff -Nurp linux-2.6.22.18/net/sunrpc/auth_unix.c linux-2.6.22.18-vs2.3.0.32/net/sunrpc/auth_unix.c
30037 --- linux-2.6.22.18/net/sunrpc/auth_unix.c 2007-07-21 23:59:04.000000000 +0200
30038 +++ linux-2.6.22.18-vs2.3.0.32/net/sunrpc/auth_unix.c 2008-02-11 12:35:43.000000000 +0100
30039 @@ -11,12 +11,14 @@
30040 #include <linux/module.h>
30041 #include <linux/sunrpc/clnt.h>
30042 #include <linux/sunrpc/auth.h>
30043 +#include <linux/vs_tag.h>
30045 #define NFS_NGROUPS 16
30048 struct rpc_cred uc_base;
30051 gid_t uc_gids[NFS_NGROUPS];
30053 #define uc_uid uc_base.cr_uid
30054 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
30055 if (flags & RPCAUTH_LOOKUP_ROOTCREDS) {
30058 + cred->uc_tag = dx_current_tag();
30059 cred->uc_gids[0] = NOGROUP;
30061 int groups = acred->group_info->ngroups;
30062 @@ -87,6 +90,7 @@ unx_create_cred(struct rpc_auth *auth, s
30064 cred->uc_uid = acred->uid;
30065 cred->uc_gid = acred->gid;
30066 + cred->uc_tag = acred->tag;
30067 for (i = 0; i < groups; i++)
30068 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
30069 if (i < NFS_NGROUPS)
30070 @@ -118,7 +122,8 @@ unx_match(struct auth_cred *acred, struc
30073 if (cred->uc_uid != acred->uid
30074 - || cred->uc_gid != acred->gid)
30075 + || cred->uc_gid != acred->gid
30076 + || cred->uc_tag != acred->tag)
30079 groups = acred->group_info->ngroups;
30080 @@ -144,7 +149,7 @@ unx_marshal(struct rpc_task *task, __be3
30081 struct rpc_clnt *clnt = task->tk_client;
30082 struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred;
30083 __be32 *base, *hold;
30087 *p++ = htonl(RPC_AUTH_UNIX);
30089 @@ -154,9 +159,12 @@ unx_marshal(struct rpc_task *task, __be3
30090 * Copy the UTS nodename captured when the client was created.
30092 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
30093 + tag = task->tk_client->cl_tag;
30095 - *p++ = htonl((u32) cred->uc_uid);
30096 - *p++ = htonl((u32) cred->uc_gid);
30097 + *p++ = htonl((u32) TAGINO_UID(tag,
30098 + cred->uc_uid, cred->uc_tag));
30099 + *p++ = htonl((u32) TAGINO_GID(tag,
30100 + cred->uc_gid, cred->uc_tag));
30102 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
30103 *p++ = htonl((u32) cred->uc_gids[i]);
30104 diff -Nurp linux-2.6.22.18/net/sunrpc/clnt.c linux-2.6.22.18-vs2.3.0.32/net/sunrpc/clnt.c
30105 --- linux-2.6.22.18/net/sunrpc/clnt.c 2007-07-22 00:00:28.000000000 +0200
30106 +++ linux-2.6.22.18-vs2.3.0.32/net/sunrpc/clnt.c 2008-02-11 12:35:43.000000000 +0100
30108 #include <linux/smp_lock.h>
30109 #include <linux/utsname.h>
30110 #include <linux/workqueue.h>
30111 +#include <linux/vs_cvirt.h>
30113 #include <linux/sunrpc/clnt.h>
30114 #include <linux/sunrpc/rpc_pipe_fs.h>
30115 @@ -249,7 +250,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
30116 clnt->cl_oneshot = 1;
30117 if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
30118 clnt->cl_discrtry = 1;
30120 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
30121 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
30122 + clnt->cl_tag = 1; */
30125 EXPORT_SYMBOL_GPL(rpc_create);
30126 diff -Nurp linux-2.6.22.18/net/unix/af_unix.c linux-2.6.22.18-vs2.3.0.32/net/unix/af_unix.c
30127 --- linux-2.6.22.18/net/unix/af_unix.c 2008-01-15 16:00:36.000000000 +0100
30128 +++ linux-2.6.22.18-vs2.3.0.32/net/unix/af_unix.c 2008-02-11 12:35:43.000000000 +0100
30129 @@ -115,6 +115,8 @@
30130 #include <linux/mount.h>
30131 #include <net/checksum.h>
30132 #include <linux/security.h>
30133 +#include <linux/vs_context.h>
30134 +#include <linux/vs_limit.h>
30136 int sysctl_unix_max_dgram_qlen __read_mostly = 10;
30138 @@ -252,6 +254,8 @@ static struct sock *__unix_find_socket_b
30139 sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
30140 struct unix_sock *u = unix_sk(s);
30142 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
30144 if (u->addr->len == len &&
30145 !memcmp(u->addr->name, sunname, len))
30147 @@ -807,7 +811,7 @@ static int unix_bind(struct socket *sock
30150 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
30151 - err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
30152 + err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0, NULL);
30154 goto out_mknod_dput;
30155 mutex_unlock(&nd.dentry->d_inode->i_mutex);
30156 diff -Nurp linux-2.6.22.18/net/x25/af_x25.c linux-2.6.22.18-vs2.3.0.32/net/x25/af_x25.c
30157 --- linux-2.6.22.18/net/x25/af_x25.c 2007-07-22 00:00:28.000000000 +0200
30158 +++ linux-2.6.22.18-vs2.3.0.32/net/x25/af_x25.c 2008-02-11 12:35:43.000000000 +0100
30159 @@ -500,7 +500,10 @@ static int x25_create(struct socket *soc
30163 - sock_init_data(sock, sk);
30164 + sk->sk_socket = sock;
30165 + sk->sk_type = sock->type;
30166 + sk->sk_sleep = &sock->wait;
30169 x25_init_timers(sk);
30171 diff -Nurp linux-2.6.22.18/security/commoncap.c linux-2.6.22.18-vs2.3.0.32/security/commoncap.c
30172 --- linux-2.6.22.18/security/commoncap.c 2007-07-22 00:00:28.000000000 +0200
30173 +++ linux-2.6.22.18-vs2.3.0.32/security/commoncap.c 2008-02-11 12:35:43.000000000 +0100
30174 @@ -22,10 +22,11 @@
30175 #include <linux/ptrace.h>
30176 #include <linux/xattr.h>
30177 #include <linux/hugetlb.h>
30178 +#include <linux/vs_context.h>
30180 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
30182 - NETLINK_CB(skb).eff_cap = current->cap_effective;
30183 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
30187 @@ -43,7 +44,7 @@ EXPORT_SYMBOL(cap_netlink_recv);
30188 int cap_capable (struct task_struct *tsk, int cap)
30190 /* Derived from include/linux/sched.h:capable. */
30191 - if (cap_raised(tsk->cap_effective, cap))
30192 + if (vx_cap_raised(tsk->vx_info, tsk->cap_effective, cap))
30196 @@ -141,7 +142,8 @@ void cap_bprm_apply_creds (struct linux_
30197 /* Derived from fs/exec.c:compute_creds. */
30198 kernel_cap_t new_permitted, working;
30200 - new_permitted = cap_intersect (bprm->cap_permitted, cap_bset);
30201 + new_permitted = cap_intersect (bprm->cap_permitted,
30202 + vx_current_cap_bset());
30203 working = cap_intersect (bprm->cap_inheritable,
30204 current->cap_inheritable);
30205 new_permitted = cap_combine (new_permitted, working);
30206 @@ -310,7 +312,8 @@ void cap_task_reparent_to_init (struct t
30208 int cap_syslog (int type)
30210 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
30211 + if ((type != 3 && type != 10) &&
30212 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
30216 diff -Nurp linux-2.6.22.18/security/dummy.c linux-2.6.22.18-vs2.3.0.32/security/dummy.c
30217 --- linux-2.6.22.18/security/dummy.c 2007-07-21 23:59:05.000000000 +0200
30218 +++ linux-2.6.22.18-vs2.3.0.32/security/dummy.c 2008-02-11 12:35:43.000000000 +0100
30220 #include <linux/hugetlb.h>
30221 #include <linux/ptrace.h>
30222 #include <linux/file.h>
30223 +#include <linux/vs_context.h>
30225 static int dummy_ptrace (struct task_struct *parent, struct task_struct *child)
30227 @@ -678,7 +679,7 @@ static int dummy_sem_semop (struct sem_a
30229 static int dummy_netlink_send (struct sock *sk, struct sk_buff *skb)
30231 - NETLINK_CB(skb).eff_cap = current->cap_effective;
30232 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
30236 diff -Nurp linux-2.6.22.18/security/Kconfig linux-2.6.22.18-vs2.3.0.32/security/Kconfig
30237 --- linux-2.6.22.18/security/Kconfig 2007-05-04 15:57:46.000000000 +0200
30238 +++ linux-2.6.22.18-vs2.3.0.32/security/Kconfig 2008-02-11 12:35:43.000000000 +0100
30239 @@ -6,6 +6,7 @@ menu "Security options"
30242 bool "Enable access key retention support"
30243 + depends on !VSERVER_SECURITY
30245 This option provides support for retaining authentication tokens and
30246 access keys in the kernel.
30247 diff -Nurp linux-2.6.22.18/security/selinux/hooks.c linux-2.6.22.18-vs2.3.0.32/security/selinux/hooks.c
30248 --- linux-2.6.22.18/security/selinux/hooks.c 2007-10-30 02:18:04.000000000 +0100
30249 +++ linux-2.6.22.18-vs2.3.0.32/security/selinux/hooks.c 2008-02-11 12:35:43.000000000 +0100
30251 #include <linux/dccp.h>
30252 #include <linux/quota.h>
30253 #include <linux/un.h> /* for Unix socket types */
30254 -#include <net/af_unix.h> /* for Unix socket types */
30255 #include <linux/parser.h>
30256 #include <linux/nfs_mount.h>
30257 #include <net/ipv6.h>