1 diff -Nurp linux-2.6.22.15/arch/alpha/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/Kconfig
2 --- linux-2.6.22.15/arch/alpha/Kconfig 2007-07-21 17:59:44.000000000 -0400
3 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/Kconfig 2007-12-09 06:44:17.000000000 -0500
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.15/arch/alpha/kernel/asm-offsets.c linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/asm-offsets.c
14 --- linux-2.6.22.15/arch/alpha/kernel/asm-offsets.c 2006-06-17 21:49:35.000000000 -0400
15 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/asm-offsets.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/alpha/kernel/entry.S linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/entry.S
25 --- linux-2.6.22.15/arch/alpha/kernel/entry.S 2007-07-21 17:59:44.000000000 -0400
26 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/entry.S 2007-12-09 06:44:17.000000000 -0500
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.15/arch/alpha/kernel/osf_sys.c linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/osf_sys.c
69 --- linux-2.6.22.15/arch/alpha/kernel/osf_sys.c 2007-07-21 17:59:44.000000000 -0400
70 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/osf_sys.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/alpha/kernel/ptrace.c linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/ptrace.c
81 --- linux-2.6.22.15/arch/alpha/kernel/ptrace.c 2006-06-17 21:49:35.000000000 -0400
82 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/ptrace.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/alpha/kernel/semaphore.c linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/semaphore.c
104 --- linux-2.6.22.15/arch/alpha/kernel/semaphore.c 2006-06-17 21:49:35.000000000 -0400
105 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/semaphore.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/alpha/kernel/systbls.S linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/systbls.S
140 --- linux-2.6.22.15/arch/alpha/kernel/systbls.S 2007-07-21 17:59:44.000000000 -0400
141 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/systbls.S 2007-12-09 06:44:17.000000000 -0500
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.15/arch/alpha/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/traps.c
152 --- linux-2.6.22.15/arch/alpha/kernel/traps.c 2007-05-04 09:55:03.000000000 -0400
153 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/kernel/traps.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/alpha/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/mm/fault.c
165 --- linux-2.6.22.15/arch/alpha/mm/fault.c 2007-07-21 17:59:44.000000000 -0400
166 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/alpha/mm/fault.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/arm/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/arm/Kconfig
179 --- linux-2.6.22.15/arch/arm/Kconfig 2007-07-21 17:59:44.000000000 -0400
180 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/arm/Kconfig 2007-12-09 06:44:17.000000000 -0500
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.15/arch/arm/kernel/calls.S linux-2.6.22.15-vs2.3.0.29.1/arch/arm/kernel/calls.S
191 --- linux-2.6.22.15/arch/arm/kernel/calls.S 2007-07-21 17:59:44.000000000 -0400
192 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/arm/kernel/calls.S 2007-12-09 06:44:17.000000000 -0500
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.15/arch/arm/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/arm/kernel/process.c
203 --- linux-2.6.22.15/arch/arm/kernel/process.c 2007-07-21 17:59:44.000000000 -0400
204 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/arm/kernel/process.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/arm/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/arm/kernel/traps.c
226 --- linux-2.6.22.15/arch/arm/kernel/traps.c 2007-07-21 17:59:44.000000000 -0400
227 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/arm/kernel/traps.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/arm/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/arm/mm/fault.c
240 --- linux-2.6.22.15/arch/arm/mm/fault.c 2007-07-21 17:59:44.000000000 -0400
241 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/arm/mm/fault.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/arm26/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/arm26/Kconfig
253 --- linux-2.6.22.15/arch/arm26/Kconfig 2007-07-21 17:59:44.000000000 -0400
254 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/arm26/Kconfig 2007-12-09 06:44:17.000000000 -0500
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.15/arch/arm26/kernel/calls.S linux-2.6.22.15-vs2.3.0.29.1/arch/arm26/kernel/calls.S
265 --- linux-2.6.22.15/arch/arm26/kernel/calls.S 2006-06-17 21:49:35.000000000 -0400
266 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/arm26/kernel/calls.S 2007-12-09 06:44:17.000000000 -0500
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.15/arch/arm26/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/arm26/kernel/process.c
280 --- linux-2.6.22.15/arch/arm26/kernel/process.c 2007-05-04 09:55:07.000000000 -0400
281 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/arm26/kernel/process.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/arm26/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/arm26/kernel/traps.c
293 --- linux-2.6.22.15/arch/arm26/kernel/traps.c 2007-05-04 09:55:07.000000000 -0400
294 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/arm26/kernel/traps.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/cris/arch-v10/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/cris/arch-v10/kernel/process.c
308 --- linux-2.6.22.15/arch/cris/arch-v10/kernel/process.c 2007-05-04 09:55:07.000000000 -0400
309 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/cris/arch-v10/kernel/process.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/cris/arch-v32/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/cris/arch-v32/kernel/process.c
321 --- linux-2.6.22.15/arch/cris/arch-v32/kernel/process.c 2007-05-04 09:55:07.000000000 -0400
322 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/cris/arch-v32/kernel/process.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/cris/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/cris/Kconfig
334 --- linux-2.6.22.15/arch/cris/Kconfig 2007-07-21 17:58:14.000000000 -0400
335 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/cris/Kconfig 2007-12-09 06:44:17.000000000 -0500
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.15/arch/frv/kernel/kernel_thread.S linux-2.6.22.15-vs2.3.0.29.1/arch/frv/kernel/kernel_thread.S
346 --- linux-2.6.22.15/arch/frv/kernel/kernel_thread.S 2006-06-17 21:49:35.000000000 -0400
347 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/frv/kernel/kernel_thread.S 2007-12-09 06:44:17.000000000 -0500
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.15/arch/h8300/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/h8300/Kconfig
367 --- linux-2.6.22.15/arch/h8300/Kconfig 2007-07-21 17:59:44.000000000 -0400
368 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/h8300/Kconfig 2007-12-09 06:44:17.000000000 -0500
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.15/arch/h8300/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/h8300/kernel/process.c
379 --- linux-2.6.22.15/arch/h8300/kernel/process.c 2007-05-04 09:55:07.000000000 -0400
380 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/h8300/kernel/process.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/i386/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/i386/Kconfig
391 --- linux-2.6.22.15/arch/i386/Kconfig 2007-07-21 17:59:44.000000000 -0400
392 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/i386/Kconfig 2007-12-09 06:44:17.000000000 -0500
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.15/arch/i386/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/i386/kernel/process.c
403 --- linux-2.6.22.15/arch/i386/kernel/process.c 2007-07-21 17:59:45.000000000 -0400
404 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/i386/kernel/process.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/i386/kernel/syscall_table.S linux-2.6.22.15-vs2.3.0.29.1/arch/i386/kernel/syscall_table.S
429 --- linux-2.6.22.15/arch/i386/kernel/syscall_table.S 2007-07-21 17:59:45.000000000 -0400
430 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/i386/kernel/syscall_table.S 2007-12-09 06:44:17.000000000 -0500
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.15/arch/i386/kernel/sysenter.c linux-2.6.22.15-vs2.3.0.29.1/arch/i386/kernel/sysenter.c
441 --- linux-2.6.22.15/arch/i386/kernel/sysenter.c 2007-08-25 21:38:36.000000000 -0400
442 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/i386/kernel/sysenter.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/i386/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/i386/kernel/traps.c
452 --- linux-2.6.22.15/arch/i386/kernel/traps.c 2007-07-21 17:59:45.000000000 -0400
453 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/i386/kernel/traps.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/i386/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/i386/mm/fault.c
496 --- linux-2.6.22.15/arch/i386/mm/fault.c 2007-09-05 01:07:59.000000000 -0400
497 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/i386/mm/fault.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/ia64/ia32/binfmt_elf32.c linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/ia32/binfmt_elf32.c
509 --- linux-2.6.22.15/arch/ia64/ia32/binfmt_elf32.c 2007-07-21 17:58:15.000000000 -0400
510 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/ia32/binfmt_elf32.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/ia64/ia32/ia32_entry.S linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/ia32/ia32_entry.S
522 --- linux-2.6.22.15/arch/ia64/ia32/ia32_entry.S 2007-07-21 17:59:45.000000000 -0400
523 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/ia32/ia32_entry.S 2007-12-09 06:44:17.000000000 -0500
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.15/arch/ia64/ia32/sys_ia32.c linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/ia32/sys_ia32.c
534 --- linux-2.6.22.15/arch/ia64/ia32/sys_ia32.c 2007-07-21 17:58:15.000000000 -0400
535 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/ia32/sys_ia32.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/ia64/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/Kconfig
546 --- linux-2.6.22.15/arch/ia64/Kconfig 2007-07-21 17:59:45.000000000 -0400
547 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/Kconfig 2007-12-09 06:44:17.000000000 -0500
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.15/arch/ia64/kernel/asm-offsets.c linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/asm-offsets.c
558 --- linux-2.6.22.15/arch/ia64/kernel/asm-offsets.c 2007-07-21 17:58:15.000000000 -0400
559 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/asm-offsets.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/ia64/kernel/entry.S linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/entry.S
569 --- linux-2.6.22.15/arch/ia64/kernel/entry.S 2007-07-21 17:59:45.000000000 -0400
570 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/entry.S 2007-12-09 06:44:17.000000000 -0500
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.15/arch/ia64/kernel/perfmon.c linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/perfmon.c
581 --- linux-2.6.22.15/arch/ia64/kernel/perfmon.c 2007-07-21 17:59:45.000000000 -0400
582 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/perfmon.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/ia64/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/process.c
601 --- linux-2.6.22.15/arch/ia64/kernel/process.c 2007-07-21 17:59:45.000000000 -0400
602 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/process.c 2007-12-09 06:44:17.000000000 -0500
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.15/arch/ia64/kernel/ptrace.c linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/ptrace.c
624 --- linux-2.6.22.15/arch/ia64/kernel/ptrace.c 2007-07-21 17:58:15.000000000 -0400
625 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/ptrace.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/ia64/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/traps.c
645 --- linux-2.6.22.15/arch/ia64/kernel/traps.c 2007-07-21 17:59:45.000000000 -0400
646 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/kernel/traps.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/ia64/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/mm/fault.c
672 --- linux-2.6.22.15/arch/ia64/mm/fault.c 2007-07-21 17:59:45.000000000 -0400
673 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ia64/mm/fault.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/m32r/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/m32r/kernel/process.c
683 --- linux-2.6.22.15/arch/m32r/kernel/process.c 2007-07-21 17:58:15.000000000 -0400
684 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/m32r/kernel/process.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/m32r/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/m32r/kernel/traps.c
697 --- linux-2.6.22.15/arch/m32r/kernel/traps.c 2007-05-04 09:57:13.000000000 -0400
698 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/m32r/kernel/traps.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/m68k/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/m68k/Kconfig
712 --- linux-2.6.22.15/arch/m68k/Kconfig 2007-07-21 17:59:45.000000000 -0400
713 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/m68k/Kconfig 2007-12-09 06:44:18.000000000 -0500
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.15/arch/m68k/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/m68k/kernel/process.c
724 --- linux-2.6.22.15/arch/m68k/kernel/process.c 2007-05-04 09:57:14.000000000 -0400
725 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/m68k/kernel/process.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/m68k/kernel/ptrace.c linux-2.6.22.15-vs2.3.0.29.1/arch/m68k/kernel/ptrace.c
737 --- linux-2.6.22.15/arch/m68k/kernel/ptrace.c 2007-07-21 17:59:45.000000000 -0400
738 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/m68k/kernel/ptrace.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/m68k/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/m68k/kernel/traps.c
757 --- linux-2.6.22.15/arch/m68k/kernel/traps.c 2007-07-21 17:58:15.000000000 -0400
758 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/m68k/kernel/traps.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/m68knommu/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/m68knommu/Kconfig
771 --- linux-2.6.22.15/arch/m68knommu/Kconfig 2007-07-21 17:59:45.000000000 -0400
772 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/m68knommu/Kconfig 2007-12-09 06:44:18.000000000 -0500
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.15/arch/m68knommu/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/m68knommu/kernel/process.c
783 --- linux-2.6.22.15/arch/m68knommu/kernel/process.c 2007-05-04 09:58:04.000000000 -0400
784 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/m68knommu/kernel/process.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/m68knommu/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/m68knommu/kernel/traps.c
795 --- linux-2.6.22.15/arch/m68knommu/kernel/traps.c 2007-07-21 17:58:15.000000000 -0400
796 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/m68knommu/kernel/traps.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/mips/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/mips/Kconfig
810 --- linux-2.6.22.15/arch/mips/Kconfig 2007-07-21 17:59:45.000000000 -0400
811 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/mips/Kconfig 2007-12-09 06:44:18.000000000 -0500
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.15/arch/mips/kernel/linux32.c linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/linux32.c
822 --- linux-2.6.22.15/arch/mips/kernel/linux32.c 2007-07-21 17:59:45.000000000 -0400
823 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/linux32.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/mips/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/process.c
834 --- linux-2.6.22.15/arch/mips/kernel/process.c 2007-07-21 17:58:16.000000000 -0400
835 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/process.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/mips/kernel/ptrace.c linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/ptrace.c
847 --- linux-2.6.22.15/arch/mips/kernel/ptrace.c 2007-07-21 17:59:45.000000000 -0400
848 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/ptrace.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/mips/kernel/scall32-o32.S linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/scall32-o32.S
868 --- linux-2.6.22.15/arch/mips/kernel/scall32-o32.S 2007-07-21 17:59:45.000000000 -0400
869 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/scall32-o32.S 2007-12-09 06:44:18.000000000 -0500
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.15/arch/mips/kernel/scall64-64.S linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/scall64-64.S
880 --- linux-2.6.22.15/arch/mips/kernel/scall64-64.S 2007-07-21 17:59:45.000000000 -0400
881 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/scall64-64.S 2007-12-09 06:44:18.000000000 -0500
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.15/arch/mips/kernel/scall64-n32.S linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/scall64-n32.S
892 --- linux-2.6.22.15/arch/mips/kernel/scall64-n32.S 2007-07-21 17:59:45.000000000 -0400
893 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/scall64-n32.S 2007-12-09 06:44:18.000000000 -0500
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.15/arch/mips/kernel/scall64-o32.S linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/scall64-o32.S
904 --- linux-2.6.22.15/arch/mips/kernel/scall64-o32.S 2007-07-21 17:59:45.000000000 -0400
905 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/scall64-o32.S 2007-12-09 06:44:18.000000000 -0500
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.15/arch/mips/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/traps.c
916 --- linux-2.6.22.15/arch/mips/kernel/traps.c 2007-07-21 17:59:48.000000000 -0400
917 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/mips/kernel/traps.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/mips/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/mips/mm/fault.c
931 --- linux-2.6.22.15/arch/mips/mm/fault.c 2007-07-21 17:59:48.000000000 -0400
932 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/mips/mm/fault.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/parisc/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/Kconfig
944 --- linux-2.6.22.15/arch/parisc/Kconfig 2007-07-21 17:58:18.000000000 -0400
945 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/Kconfig 2007-12-09 06:44:18.000000000 -0500
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.15/arch/parisc/kernel/entry.S linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/kernel/entry.S
956 --- linux-2.6.22.15/arch/parisc/kernel/entry.S 2007-07-21 17:59:48.000000000 -0400
957 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/kernel/entry.S 2007-12-09 06:44:18.000000000 -0500
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.15/arch/parisc/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/kernel/process.c
967 --- linux-2.6.22.15/arch/parisc/kernel/process.c 2007-07-21 17:59:48.000000000 -0400
968 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/kernel/process.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/parisc/kernel/syscall_table.S linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/kernel/syscall_table.S
979 --- linux-2.6.22.15/arch/parisc/kernel/syscall_table.S 2007-07-21 17:59:48.000000000 -0400
980 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/kernel/syscall_table.S 2007-12-09 06:44:18.000000000 -0500
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.15/arch/parisc/kernel/sys_parisc32.c linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/kernel/sys_parisc32.c
991 --- linux-2.6.22.15/arch/parisc/kernel/sys_parisc32.c 2007-07-21 17:59:48.000000000 -0400
992 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/kernel/sys_parisc32.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/parisc/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/kernel/traps.c
1008 --- linux-2.6.22.15/arch/parisc/kernel/traps.c 2007-07-21 17:59:48.000000000 -0400
1009 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/kernel/traps.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/parisc/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/mm/fault.c
1034 --- linux-2.6.22.15/arch/parisc/mm/fault.c 2007-07-21 17:58:18.000000000 -0400
1035 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/parisc/mm/fault.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/powerpc/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/Kconfig
1059 --- linux-2.6.22.15/arch/powerpc/Kconfig 2007-07-21 17:59:48.000000000 -0400
1060 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/Kconfig 2007-12-09 06:44:18.000000000 -0500
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.15/arch/powerpc/kernel/asm-offsets.c linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/asm-offsets.c
1071 --- linux-2.6.22.15/arch/powerpc/kernel/asm-offsets.c 2007-07-21 17:59:48.000000000 -0400
1072 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/asm-offsets.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/powerpc/kernel/irq.c linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/irq.c
1082 --- linux-2.6.22.15/arch/powerpc/kernel/irq.c 2007-07-21 17:59:48.000000000 -0400
1083 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/irq.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/powerpc/kernel/misc_32.S linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/misc_32.S
1093 --- linux-2.6.22.15/arch/powerpc/kernel/misc_32.S 2007-07-21 17:59:48.000000000 -0400
1094 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/misc_32.S 2007-12-09 06:44:18.000000000 -0500
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.15/arch/powerpc/kernel/misc_64.S linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/misc_64.S
1105 --- linux-2.6.22.15/arch/powerpc/kernel/misc_64.S 2007-07-21 17:58:18.000000000 -0400
1106 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/misc_64.S 2007-12-09 06:44:18.000000000 -0500
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.15/arch/powerpc/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/process.c
1117 --- linux-2.6.22.15/arch/powerpc/kernel/process.c 2007-09-29 08:11:48.000000000 -0400
1118 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/process.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/powerpc/kernel/sys_ppc32.c linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/sys_ppc32.c
1132 --- linux-2.6.22.15/arch/powerpc/kernel/sys_ppc32.c 2007-07-21 17:59:48.000000000 -0400
1133 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/sys_ppc32.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/powerpc/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/traps.c
1144 --- linux-2.6.22.15/arch/powerpc/kernel/traps.c 2007-07-21 17:59:48.000000000 -0400
1145 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/traps.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/powerpc/kernel/vdso.c linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/vdso.c
1159 --- linux-2.6.22.15/arch/powerpc/kernel/vdso.c 2007-07-21 17:59:48.000000000 -0400
1160 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/kernel/vdso.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/powerpc/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/mm/fault.c
1170 --- linux-2.6.22.15/arch/powerpc/mm/fault.c 2007-07-21 17:59:48.000000000 -0400
1171 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/powerpc/mm/fault.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/ppc/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/ppc/Kconfig
1183 --- linux-2.6.22.15/arch/ppc/Kconfig 2007-07-21 17:58:19.000000000 -0400
1184 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ppc/Kconfig 2007-12-09 06:44:18.000000000 -0500
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.15/arch/ppc/kernel/asm-offsets.c linux-2.6.22.15-vs2.3.0.29.1/arch/ppc/kernel/asm-offsets.c
1195 --- linux-2.6.22.15/arch/ppc/kernel/asm-offsets.c 2007-07-21 17:59:49.000000000 -0400
1196 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ppc/kernel/asm-offsets.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/ppc/kernel/misc.S linux-2.6.22.15-vs2.3.0.29.1/arch/ppc/kernel/misc.S
1206 --- linux-2.6.22.15/arch/ppc/kernel/misc.S 2007-05-04 09:57:15.000000000 -0400
1207 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ppc/kernel/misc.S 2007-12-09 06:44:18.000000000 -0500
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.15/arch/ppc/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/ppc/kernel/traps.c
1218 --- linux-2.6.22.15/arch/ppc/kernel/traps.c 2007-07-21 17:59:49.000000000 -0400
1219 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ppc/kernel/traps.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/ppc/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/ppc/mm/fault.c
1233 --- linux-2.6.22.15/arch/ppc/mm/fault.c 2007-05-04 09:57:15.000000000 -0400
1234 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/ppc/mm/fault.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/s390/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/s390/Kconfig
1246 --- linux-2.6.22.15/arch/s390/Kconfig 2007-07-21 17:59:49.000000000 -0400
1247 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/s390/Kconfig 2007-12-09 06:44:18.000000000 -0500
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.15/arch/s390/kernel/compat_linux.c linux-2.6.22.15-vs2.3.0.29.1/arch/s390/kernel/compat_linux.c
1258 --- linux-2.6.22.15/arch/s390/kernel/compat_linux.c 2007-07-21 17:59:49.000000000 -0400
1259 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/s390/kernel/compat_linux.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/s390/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/s390/kernel/process.c
1270 --- linux-2.6.22.15/arch/s390/kernel/process.c 2007-07-21 17:59:49.000000000 -0400
1271 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/s390/kernel/process.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/s390/kernel/ptrace.c linux-2.6.22.15-vs2.3.0.29.1/arch/s390/kernel/ptrace.c
1295 --- linux-2.6.22.15/arch/s390/kernel/ptrace.c 2007-07-21 17:58:19.000000000 -0400
1296 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/s390/kernel/ptrace.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/s390/kernel/syscalls.S linux-2.6.22.15-vs2.3.0.29.1/arch/s390/kernel/syscalls.S
1320 --- linux-2.6.22.15/arch/s390/kernel/syscalls.S 2007-07-21 17:59:49.000000000 -0400
1321 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/s390/kernel/syscalls.S 2007-12-09 06:44:18.000000000 -0500
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.15/arch/s390/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/s390/mm/fault.c
1332 --- linux-2.6.22.15/arch/s390/mm/fault.c 2007-07-21 17:59:49.000000000 -0400
1333 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/s390/mm/fault.c 2007-12-09 06:44:18.000000000 -0500
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.15/arch/sh/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/sh/Kconfig
1345 --- linux-2.6.22.15/arch/sh/Kconfig 2007-07-21 17:59:49.000000000 -0400
1346 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sh/Kconfig 2007-12-09 06:44:18.000000000 -0500
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.15/arch/sh/kernel/irq.c linux-2.6.22.15-vs2.3.0.29.1/arch/sh/kernel/irq.c
1357 --- linux-2.6.22.15/arch/sh/kernel/irq.c 2007-07-21 17:59:49.000000000 -0400
1358 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sh/kernel/irq.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sh/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/sh/kernel/process.c
1368 --- linux-2.6.22.15/arch/sh/kernel/process.c 2007-07-21 17:59:49.000000000 -0400
1369 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sh/kernel/process.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.22.15-vs2.3.0.29.1/arch/sh/kernel/vsyscall/vsyscall.c
1390 --- linux-2.6.22.15/arch/sh/kernel/vsyscall/vsyscall.c 2007-07-21 17:59:49.000000000 -0400
1391 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sh/kernel/vsyscall/vsyscall.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sh/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/sh/mm/fault.c
1401 --- linux-2.6.22.15/arch/sh/mm/fault.c 2007-07-21 17:59:49.000000000 -0400
1402 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sh/mm/fault.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sh64/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/sh64/kernel/process.c
1414 --- linux-2.6.22.15/arch/sh64/kernel/process.c 2007-07-21 17:59:49.000000000 -0400
1415 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sh64/kernel/process.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sh64/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/sh64/mm/fault.c
1428 --- linux-2.6.22.15/arch/sh64/mm/fault.c 2007-07-21 17:59:49.000000000 -0400
1429 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sh64/mm/fault.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/Kconfig
1450 --- linux-2.6.22.15/arch/sparc/Kconfig 2007-07-21 17:59:49.000000000 -0400
1451 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/Kconfig 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/kernel/process.c
1462 --- linux-2.6.22.15/arch/sparc/kernel/process.c 2007-07-21 17:59:49.000000000 -0400
1463 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/kernel/process.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc/kernel/ptrace.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/kernel/ptrace.c
1475 --- linux-2.6.22.15/arch/sparc/kernel/ptrace.c 2007-05-04 09:58:05.000000000 -0400
1476 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/kernel/ptrace.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc/kernel/systbls.S linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/kernel/systbls.S
1497 --- linux-2.6.22.15/arch/sparc/kernel/systbls.S 2007-07-21 17:59:49.000000000 -0400
1498 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/kernel/systbls.S 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/kernel/traps.c
1509 --- linux-2.6.22.15/arch/sparc/kernel/traps.c 2007-07-21 17:59:49.000000000 -0400
1510 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/kernel/traps.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/mm/fault.c
1522 --- linux-2.6.22.15/arch/sparc/mm/fault.c 2007-07-21 17:59:49.000000000 -0400
1523 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc/mm/fault.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc64/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/Kconfig
1535 --- linux-2.6.22.15/arch/sparc64/Kconfig 2007-07-21 17:59:49.000000000 -0400
1536 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/Kconfig 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc64/kernel/binfmt_aout32.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/binfmt_aout32.c
1547 --- linux-2.6.22.15/arch/sparc64/kernel/binfmt_aout32.c 2007-05-04 09:58:05.000000000 -0400
1548 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/binfmt_aout32.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc64/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/process.c
1558 --- linux-2.6.22.15/arch/sparc64/kernel/process.c 2007-07-21 17:59:49.000000000 -0400
1559 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/process.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc64/kernel/ptrace.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/ptrace.c
1571 --- linux-2.6.22.15/arch/sparc64/kernel/ptrace.c 2007-05-04 09:58:05.000000000 -0400
1572 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/ptrace.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc64/kernel/sys_sparc32.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/sys_sparc32.c
1593 --- linux-2.6.22.15/arch/sparc64/kernel/sys_sparc32.c 2007-07-21 17:59:49.000000000 -0400
1594 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/sys_sparc32.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc64/kernel/systbls.S linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/systbls.S
1605 --- linux-2.6.22.15/arch/sparc64/kernel/systbls.S 2007-07-21 17:59:49.000000000 -0400
1606 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/systbls.S 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc64/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/traps.c
1626 --- linux-2.6.22.15/arch/sparc64/kernel/traps.c 2007-09-05 01:07:59.000000000 -0400
1627 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/kernel/traps.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc64/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/mm/fault.c
1639 --- linux-2.6.22.15/arch/sparc64/mm/fault.c 2007-09-05 01:07:59.000000000 -0400
1640 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/mm/fault.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/sparc64/solaris/fs.c linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/solaris/fs.c
1652 --- linux-2.6.22.15/arch/sparc64/solaris/fs.c 2007-05-04 09:58:05.000000000 -0400
1653 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/sparc64/solaris/fs.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/um/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/um/Kconfig
1673 --- linux-2.6.22.15/arch/um/Kconfig 2007-07-21 17:59:49.000000000 -0400
1674 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/um/Kconfig 2007-12-09 06:44:19.000000000 -0500
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.15/arch/um/kernel/trap.c linux-2.6.22.15-vs2.3.0.29.1/arch/um/kernel/trap.c
1685 --- linux-2.6.22.15/arch/um/kernel/trap.c 2007-07-21 17:59:50.000000000 -0400
1686 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/um/kernel/trap.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/v850/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/v850/Kconfig
1698 --- linux-2.6.22.15/arch/v850/Kconfig 2007-07-21 17:59:50.000000000 -0400
1699 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/v850/Kconfig 2007-12-09 06:44:19.000000000 -0500
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.15/arch/v850/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/v850/kernel/process.c
1710 --- linux-2.6.22.15/arch/v850/kernel/process.c 2007-07-21 17:59:50.000000000 -0400
1711 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/v850/kernel/process.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/v850/kernel/ptrace.c linux-2.6.22.15-vs2.3.0.29.1/arch/v850/kernel/ptrace.c
1722 --- linux-2.6.22.15/arch/v850/kernel/ptrace.c 2007-07-21 17:59:50.000000000 -0400
1723 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/v850/kernel/ptrace.c 2007-12-09 06:44:19.000000000 -0500
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.15/arch/x86_64/ia32/ia32_aout.c linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/ia32/ia32_aout.c
1743 --- linux-2.6.22.15/arch/x86_64/ia32/ia32_aout.c 2007-05-04 09:58:05.000000000 -0400
1744 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/ia32/ia32_aout.c 2007-12-09 06:44:20.000000000 -0500
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.15/arch/x86_64/ia32/ia32_binfmt.c linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/ia32/ia32_binfmt.c
1754 --- linux-2.6.22.15/arch/x86_64/ia32/ia32_binfmt.c 2007-07-21 17:59:50.000000000 -0400
1755 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/ia32/ia32_binfmt.c 2007-12-09 06:44:20.000000000 -0500
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.15/arch/x86_64/ia32/ia32entry.S linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/ia32/ia32entry.S
1767 --- linux-2.6.22.15/arch/x86_64/ia32/ia32entry.S 2007-09-29 08:11:36.000000000 -0400
1768 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/ia32/ia32entry.S 2007-12-09 06:44:20.000000000 -0500
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.15/arch/x86_64/ia32/syscall32.c linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/ia32/syscall32.c
1779 --- linux-2.6.22.15/arch/x86_64/ia32/syscall32.c 2007-07-21 17:59:50.000000000 -0400
1780 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/ia32/syscall32.c 2007-12-09 06:44:20.000000000 -0500
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.15/arch/x86_64/ia32/sys_ia32.c linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/ia32/sys_ia32.c
1790 --- linux-2.6.22.15/arch/x86_64/ia32/sys_ia32.c 2007-07-21 17:59:50.000000000 -0400
1791 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/ia32/sys_ia32.c 2007-12-09 06:44:20.000000000 -0500
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.15/arch/x86_64/Kconfig linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/Kconfig
1802 --- linux-2.6.22.15/arch/x86_64/Kconfig 2007-07-21 17:59:50.000000000 -0400
1803 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/Kconfig 2007-12-09 06:44:20.000000000 -0500
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.15/arch/x86_64/kernel/process.c linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/kernel/process.c
1814 --- linux-2.6.22.15/arch/x86_64/kernel/process.c 2007-07-21 17:59:50.000000000 -0400
1815 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/kernel/process.c 2007-12-09 06:44:20.000000000 -0500
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.15/arch/x86_64/kernel/traps.c linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/kernel/traps.c
1838 --- linux-2.6.22.15/arch/x86_64/kernel/traps.c 2007-07-21 17:59:50.000000000 -0400
1839 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/kernel/traps.c 2007-12-09 06:44:20.000000000 -0500
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.15/arch/x86_64/mm/fault.c linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/mm/fault.c
1915 --- linux-2.6.22.15/arch/x86_64/mm/fault.c 2007-07-21 17:59:50.000000000 -0400
1916 +++ linux-2.6.22.15-vs2.3.0.29.1/arch/x86_64/mm/fault.c 2007-12-09 06:44:20.000000000 -0500
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.15/Documentation/vserver/debug.txt linux-2.6.22.15-vs2.3.0.29.1/Documentation/vserver/debug.txt
1942 --- linux-2.6.22.15/Documentation/vserver/debug.txt 1969-12-31 19:00:00.000000000 -0500
1943 +++ linux-2.6.22.15-vs2.3.0.29.1/Documentation/vserver/debug.txt 2007-12-09 06:44:17.000000000 -0500
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.15/drivers/block/Kconfig linux-2.6.22.15-vs2.3.0.29.1/drivers/block/Kconfig
2100 --- linux-2.6.22.15/drivers/block/Kconfig 2007-07-21 17:59:50.000000000 -0400
2101 +++ linux-2.6.22.15-vs2.3.0.29.1/drivers/block/Kconfig 2007-12-09 06:44:20.000000000 -0500
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.15/drivers/block/loop.c linux-2.6.22.15-vs2.3.0.29.1/drivers/block/loop.c
2117 --- linux-2.6.22.15/drivers/block/loop.c 2007-07-21 17:59:50.000000000 -0400
2118 +++ linux-2.6.22.15-vs2.3.0.29.1/drivers/block/loop.c 2007-12-09 06:44:20.000000000 -0500
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.15/drivers/block/Makefile linux-2.6.22.15-vs2.3.0.29.1/drivers/block/Makefile
2173 --- linux-2.6.22.15/drivers/block/Makefile 2007-05-04 09:58:05.000000000 -0400
2174 +++ linux-2.6.22.15-vs2.3.0.29.1/drivers/block/Makefile 2007-12-09 06:44:20.000000000 -0500
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.15/drivers/block/vroot.c linux-2.6.22.15-vs2.3.0.29.1/drivers/block/vroot.c
2182 --- linux-2.6.22.15/drivers/block/vroot.c 1969-12-31 19:00:00.000000000 -0500
2183 +++ linux-2.6.22.15-vs2.3.0.29.1/drivers/block/vroot.c 2007-12-09 06:44:20.000000000 -0500
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.15/drivers/char/sysrq.c linux-2.6.22.15-vs2.3.0.29.1/drivers/char/sysrq.c
2467 --- linux-2.6.22.15/drivers/char/sysrq.c 2007-07-21 17:59:53.000000000 -0400
2468 +++ linux-2.6.22.15-vs2.3.0.29.1/drivers/char/sysrq.c 2007-12-09 06:44:20.000000000 -0500
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.15/drivers/char/tty_io.c linux-2.6.22.15-vs2.3.0.29.1/drivers/char/tty_io.c
2522 --- linux-2.6.22.15/drivers/char/tty_io.c 2007-07-21 17:59:53.000000000 -0400
2523 +++ linux-2.6.22.15-vs2.3.0.29.1/drivers/char/tty_io.c 2007-12-09 06:44:20.000000000 -0500
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.15/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.22.15-vs2.3.0.29.1/drivers/infiniband/hw/ipath/ipath_user_pages.c
2558 --- linux-2.6.22.15/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-05-04 09:58:07.000000000 -0400
2559 +++ linux-2.6.22.15-vs2.3.0.29.1/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-12-09 06:44:20.000000000 -0500
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.15/drivers/md/dm.c linux-2.6.22.15-vs2.3.0.29.1/drivers/md/dm.c
2606 --- linux-2.6.22.15/drivers/md/dm.c 2007-08-11 21:54:36.000000000 -0400
2607 +++ linux-2.6.22.15-vs2.3.0.29.1/drivers/md/dm.c 2007-12-09 06:44:20.000000000 -0500
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.15/drivers/md/dm.h linux-2.6.22.15-vs2.3.0.29.1/drivers/md/dm.h
2682 --- linux-2.6.22.15/drivers/md/dm.h 2007-05-04 09:58:08.000000000 -0400
2683 +++ linux-2.6.22.15-vs2.3.0.29.1/drivers/md/dm.h 2007-12-09 06:44:20.000000000 -0500
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.15/drivers/md/dm-ioctl.c linux-2.6.22.15-vs2.3.0.29.1/drivers/md/dm-ioctl.c
2694 --- linux-2.6.22.15/drivers/md/dm-ioctl.c 2007-07-21 17:58:29.000000000 -0400
2695 +++ linux-2.6.22.15-vs2.3.0.29.1/drivers/md/dm-ioctl.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/attr.c linux-2.6.22.15-vs2.3.0.29.1/fs/attr.c
2778 --- linux-2.6.22.15/fs/attr.c 2007-07-21 18:00:15.000000000 -0400
2779 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/attr.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/binfmt_aout.c linux-2.6.22.15-vs2.3.0.29.1/fs/binfmt_aout.c
2838 --- linux-2.6.22.15/fs/binfmt_aout.c 2007-05-04 09:58:21.000000000 -0400
2839 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/binfmt_aout.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/binfmt_elf.c linux-2.6.22.15-vs2.3.0.29.1/fs/binfmt_elf.c
2849 --- linux-2.6.22.15/fs/binfmt_elf.c 2007-07-21 18:00:15.000000000 -0400
2850 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/binfmt_elf.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/binfmt_flat.c linux-2.6.22.15-vs2.3.0.29.1/fs/binfmt_flat.c
2860 --- linux-2.6.22.15/fs/binfmt_flat.c 2007-07-21 18:00:15.000000000 -0400
2861 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/binfmt_flat.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/binfmt_som.c linux-2.6.22.15-vs2.3.0.29.1/fs/binfmt_som.c
2871 --- linux-2.6.22.15/fs/binfmt_som.c 2007-05-04 09:57:29.000000000 -0400
2872 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/binfmt_som.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/block_dev.c linux-2.6.22.15-vs2.3.0.29.1/fs/block_dev.c
2882 --- linux-2.6.22.15/fs/block_dev.c 2007-07-21 18:00:15.000000000 -0400
2883 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/block_dev.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/char_dev.c linux-2.6.22.15-vs2.3.0.29.1/fs/char_dev.c
2922 --- linux-2.6.22.15/fs/char_dev.c 2007-07-21 17:58:44.000000000 -0400
2923 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/char_dev.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/dcache.c linux-2.6.22.15-vs2.3.0.29.1/fs/dcache.c
2956 --- linux-2.6.22.15/fs/dcache.c 2007-07-21 18:00:15.000000000 -0400
2957 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/dcache.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/devpts/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/devpts/inode.c
3018 --- linux-2.6.22.15/fs/devpts/inode.c 2007-07-21 18:00:15.000000000 -0400
3019 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/devpts/inode.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ecryptfs/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/ecryptfs/inode.c
3097 --- linux-2.6.22.15/fs/ecryptfs/inode.c 2007-08-11 21:54:36.000000000 -0400
3098 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ecryptfs/inode.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/exec.c linux-2.6.22.15-vs2.3.0.29.1/fs/exec.c
3154 --- linux-2.6.22.15/fs/exec.c 2007-09-05 01:07:59.000000000 -0400
3155 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/exec.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext2/balloc.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/balloc.c
3184 --- linux-2.6.22.15/fs/ext2/balloc.c 2007-07-21 17:58:45.000000000 -0400
3185 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/balloc.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext2/ext2.h linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/ext2.h
3240 --- linux-2.6.22.15/fs/ext2/ext2.h 2007-07-21 18:00:15.000000000 -0400
3241 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/ext2.h 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext2/file.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/file.c
3251 --- linux-2.6.22.15/fs/ext2/file.c 2007-07-21 17:58:45.000000000 -0400
3252 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/file.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext2/ialloc.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/ialloc.c
3260 --- linux-2.6.22.15/fs/ext2/ialloc.c 2007-05-04 09:57:35.000000000 -0400
3261 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/ialloc.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext2/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/inode.c
3318 --- linux-2.6.22.15/fs/ext2/inode.c 2007-07-21 18:00:15.000000000 -0400
3319 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/inode.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext2/ioctl.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/ioctl.c
3453 --- linux-2.6.22.15/fs/ext2/ioctl.c 2007-07-21 18:00:15.000000000 -0400
3454 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/ioctl.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext2/namei.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/namei.c
3495 --- linux-2.6.22.15/fs/ext2/namei.c 2007-07-21 17:58:45.000000000 -0400
3496 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/namei.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext2/super.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/super.c
3528 --- linux-2.6.22.15/fs/ext2/super.c 2007-07-21 18:00:15.000000000 -0400
3529 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/super.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext2/symlink.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/symlink.c
3594 --- linux-2.6.22.15/fs/ext2/symlink.c 2007-07-21 17:58:45.000000000 -0400
3595 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/symlink.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext2/xattr.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/xattr.c
3611 --- linux-2.6.22.15/fs/ext2/xattr.c 2007-05-04 09:58:21.000000000 -0400
3612 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext2/xattr.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext3/balloc.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/balloc.c
3651 --- linux-2.6.22.15/fs/ext3/balloc.c 2007-07-21 17:58:45.000000000 -0400
3652 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/balloc.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext3/file.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/file.c
3760 --- linux-2.6.22.15/fs/ext3/file.c 2007-07-21 17:58:45.000000000 -0400
3761 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/file.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext3/ialloc.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/ialloc.c
3770 --- linux-2.6.22.15/fs/ext3/ialloc.c 2007-05-04 09:57:35.000000000 -0400
3771 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/ialloc.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext3/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/inode.c
3830 --- linux-2.6.22.15/fs/ext3/inode.c 2007-07-21 18:00:15.000000000 -0400
3831 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/inode.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext3/ioctl.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/ioctl.c
4018 --- linux-2.6.22.15/fs/ext3/ioctl.c 2007-07-21 18:00:15.000000000 -0400
4019 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/ioctl.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext3/namei.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/namei.c
4098 --- linux-2.6.22.15/fs/ext3/namei.c 2007-09-29 08:11:49.000000000 -0400
4099 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/namei.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext3/super.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/super.c
4131 --- linux-2.6.22.15/fs/ext3/super.c 2007-07-21 18:00:15.000000000 -0400
4132 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/super.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext3/symlink.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/symlink.c
4197 --- linux-2.6.22.15/fs/ext3/symlink.c 2007-07-21 17:58:45.000000000 -0400
4198 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/symlink.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext3/xattr.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/xattr.c
4214 --- linux-2.6.22.15/fs/ext3/xattr.c 2007-07-21 17:58:45.000000000 -0400
4215 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext3/xattr.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext4/balloc.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/balloc.c
4258 --- linux-2.6.22.15/fs/ext4/balloc.c 2007-07-21 18:00:15.000000000 -0400
4259 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/balloc.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext4/file.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/file.c
4366 --- linux-2.6.22.15/fs/ext4/file.c 2007-07-21 17:58:45.000000000 -0400
4367 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/file.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext4/ialloc.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/ialloc.c
4376 --- linux-2.6.22.15/fs/ext4/ialloc.c 2007-05-04 09:57:35.000000000 -0400
4377 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/ialloc.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext4/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/inode.c
4436 --- linux-2.6.22.15/fs/ext4/inode.c 2007-07-21 18:00:15.000000000 -0400
4437 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/inode.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext4/ioctl.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/ioctl.c
4623 --- linux-2.6.22.15/fs/ext4/ioctl.c 2007-05-04 09:58:21.000000000 -0400
4624 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/ioctl.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext4/namei.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/namei.c
4703 --- linux-2.6.22.15/fs/ext4/namei.c 2007-09-29 08:11:49.000000000 -0400
4704 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/namei.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext4/super.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/super.c
4736 --- linux-2.6.22.15/fs/ext4/super.c 2007-07-21 18:00:15.000000000 -0400
4737 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/super.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext4/symlink.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/symlink.c
4802 --- linux-2.6.22.15/fs/ext4/symlink.c 2007-07-21 17:58:45.000000000 -0400
4803 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/symlink.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ext4/xattr.c linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/xattr.c
4819 --- linux-2.6.22.15/fs/ext4/xattr.c 2007-07-21 17:58:45.000000000 -0400
4820 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ext4/xattr.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/fcntl.c linux-2.6.22.15-vs2.3.0.29.1/fs/fcntl.c
4863 --- linux-2.6.22.15/fs/fcntl.c 2007-05-04 09:58:21.000000000 -0400
4864 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/fcntl.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/file_table.c linux-2.6.22.15-vs2.3.0.29.1/fs/file_table.c
4901 --- linux-2.6.22.15/fs/file_table.c 2007-07-21 18:00:15.000000000 -0400
4902 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/file_table.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/hfsplus/ioctl.c linux-2.6.22.15-vs2.3.0.29.1/fs/hfsplus/ioctl.c
4940 --- linux-2.6.22.15/fs/hfsplus/ioctl.c 2007-05-04 09:57:35.000000000 -0400
4941 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/hfsplus/ioctl.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/inode.c
4961 --- linux-2.6.22.15/fs/inode.c 2007-07-21 18:00:16.000000000 -0400
4962 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/inode.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ioctl.c linux-2.6.22.15-vs2.3.0.29.1/fs/ioctl.c
5003 --- linux-2.6.22.15/fs/ioctl.c 2007-07-21 18:00:16.000000000 -0400
5004 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ioctl.c 2007-12-09 06:44:20.000000000 -0500
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.15/fs/ioprio.c linux-2.6.22.15-vs2.3.0.29.1/fs/ioprio.c
5016 --- linux-2.6.22.15/fs/ioprio.c 2007-07-21 17:58:45.000000000 -0400
5017 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ioprio.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/dir.c linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/dir.c
5063 --- linux-2.6.22.15/fs/jffs2/dir.c 2007-07-21 18:00:17.000000000 -0400
5064 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/dir.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/file.c linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/file.c
5085 --- linux-2.6.22.15/fs/jffs2/file.c 2007-07-21 18:00:17.000000000 -0400
5086 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/file.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/fs.c linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/fs.c
5151 --- linux-2.6.22.15/fs/jffs2/fs.c 2007-09-29 08:11:49.000000000 -0400
5152 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/fs.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/gc.c linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/gc.c
5309 --- linux-2.6.22.15/fs/jffs2/gc.c 2007-07-21 18:00:17.000000000 -0400
5310 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/gc.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/ioctl.c linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/ioctl.c
5336 --- linux-2.6.22.15/fs/jffs2/ioctl.c 2007-07-21 18:00:17.000000000 -0400
5337 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/ioctl.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/jffs2_fs_sb.h linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/jffs2_fs_sb.h
5410 --- linux-2.6.22.15/fs/jffs2/jffs2_fs_sb.h 2007-07-21 18:00:17.000000000 -0400
5411 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/jffs2_fs_sb.h 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/nodelist.h linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/nodelist.h
5421 --- linux-2.6.22.15/fs/jffs2/nodelist.h 2007-07-21 18:00:17.000000000 -0400
5422 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/nodelist.h 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/os-linux.h linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/os-linux.h
5454 --- linux-2.6.22.15/fs/jffs2/os-linux.h 2007-07-21 18:00:17.000000000 -0400
5455 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/os-linux.h 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/readinode.c linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/readinode.c
5475 --- linux-2.6.22.15/fs/jffs2/readinode.c 2007-07-21 18:00:17.000000000 -0400
5476 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/readinode.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/super.c linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/super.c
5487 --- linux-2.6.22.15/fs/jffs2/super.c 2007-07-21 18:00:17.000000000 -0400
5488 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/super.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jffs2/write.c linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/write.c
5561 --- linux-2.6.22.15/fs/jffs2/write.c 2007-08-25 21:38:36.000000000 -0400
5562 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jffs2/write.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/acl.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/acl.c
5572 --- linux-2.6.22.15/fs/jfs/acl.c 2007-05-04 09:57:35.000000000 -0400
5573 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/acl.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/file.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/file.c
5585 --- linux-2.6.22.15/fs/jfs/file.c 2007-07-21 17:58:46.000000000 -0400
5586 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/file.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/inode.c
5596 --- linux-2.6.22.15/fs/jfs/inode.c 2007-07-21 18:00:17.000000000 -0400
5597 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/inode.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/ioctl.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/ioctl.c
5615 --- linux-2.6.22.15/fs/jfs/ioctl.c 2007-07-21 18:00:17.000000000 -0400
5616 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/ioctl.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/jfs_dinode.h linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_dinode.h
5647 --- linux-2.6.22.15/fs/jfs/jfs_dinode.h 2007-05-04 09:57:35.000000000 -0400
5648 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_dinode.h 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/jfs_dtree.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_dtree.c
5665 --- linux-2.6.22.15/fs/jfs/jfs_dtree.c 2007-05-04 09:58:21.000000000 -0400
5666 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_dtree.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/jfs_extent.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_extent.c
5779 --- linux-2.6.22.15/fs/jfs/jfs_extent.c 2007-05-04 09:57:36.000000000 -0400
5780 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_extent.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/jfs_filsys.h linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_filsys.h
5843 --- linux-2.6.22.15/fs/jfs/jfs_filsys.h 2007-05-04 09:58:21.000000000 -0400
5844 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_filsys.h 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/jfs_imap.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_imap.c
5854 --- linux-2.6.22.15/fs/jfs/jfs_imap.c 2007-07-21 18:00:17.000000000 -0400
5855 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_imap.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/jfs_inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_inode.c
5916 --- linux-2.6.22.15/fs/jfs/jfs_inode.c 2007-07-21 18:00:17.000000000 -0400
5917 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_inode.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/jfs_inode.h linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_inode.h
5998 --- linux-2.6.22.15/fs/jfs/jfs_inode.h 2007-07-21 18:00:17.000000000 -0400
5999 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_inode.h 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/jfs_xtree.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_xtree.c
6009 --- linux-2.6.22.15/fs/jfs/jfs_xtree.c 2007-07-21 17:58:46.000000000 -0400
6010 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/jfs_xtree.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/namei.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/namei.c
6095 --- linux-2.6.22.15/fs/jfs/namei.c 2007-07-21 17:58:46.000000000 -0400
6096 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/namei.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/super.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/super.c
6122 --- linux-2.6.22.15/fs/jfs/super.c 2007-07-21 18:00:17.000000000 -0400
6123 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/super.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/jfs/xattr.c linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/xattr.c
6191 --- linux-2.6.22.15/fs/jfs/xattr.c 2007-05-04 09:57:36.000000000 -0400
6192 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/jfs/xattr.c 2007-12-09 06:44:21.000000000 -0500
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.15/fs/libfs.c linux-2.6.22.15-vs2.3.0.29.1/fs/libfs.c
6271 --- linux-2.6.22.15/fs/libfs.c 2007-07-21 18:00:17.000000000 -0400
6272 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/libfs.c 2007-12-09 06:44:21.000000000 -0500
6273 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
6274 * both impossible due to the lock on directory.
6277 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6278 +static inline int do_dcache_readdir_filter(struct file *filp,
6279 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6281 struct dentry *dentry = filp->f_path.dentry;
6282 struct dentry *cursor = filp->private_data;
6283 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
6284 next = list_entry(p, struct dentry, d_u.d_child);
6285 if (d_unhashed(next) || !next->d_inode)
6287 + if (filter && !filter(next))
6290 spin_unlock(&dcache_lock);
6291 if (filldir(dirent, next->d_name.name,
6292 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
6296 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6298 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6301 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6302 + int (*filter)(struct dentry *))
6304 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6308 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6311 @@ -640,6 +655,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6312 EXPORT_SYMBOL(dcache_dir_lseek);
6313 EXPORT_SYMBOL(dcache_dir_open);
6314 EXPORT_SYMBOL(dcache_readdir);
6315 +EXPORT_SYMBOL(dcache_readdir_filter);
6316 EXPORT_SYMBOL(generic_read_dir);
6317 EXPORT_SYMBOL(get_sb_pseudo);
6318 EXPORT_SYMBOL(simple_commit_write);
6319 diff -Nurp linux-2.6.22.15/fs/locks.c linux-2.6.22.15-vs2.3.0.29.1/fs/locks.c
6320 --- linux-2.6.22.15/fs/locks.c 2007-09-29 08:11:49.000000000 -0400
6321 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/locks.c 2007-12-09 06:44:21.000000000 -0500
6323 #include <linux/syscalls.h>
6324 #include <linux/time.h>
6325 #include <linux/rcupdate.h>
6326 +#include <linux/vs_base.h>
6327 +#include <linux/vs_limit.h>
6329 #include <asm/semaphore.h>
6330 #include <asm/uaccess.h>
6331 @@ -147,6 +149,8 @@ static struct kmem_cache *filelock_cache
6332 /* Allocate an empty lock structure. */
6333 static struct file_lock *locks_alloc_lock(void)
6335 + if (!vx_locks_avail(1))
6337 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6340 @@ -172,6 +176,7 @@ static void locks_free_lock(struct file_
6341 BUG_ON(!list_empty(&fl->fl_block));
6342 BUG_ON(!list_empty(&fl->fl_link));
6345 locks_release_private(fl);
6346 kmem_cache_free(filelock_cache, fl);
6348 @@ -191,6 +196,7 @@ void locks_init_lock(struct file_lock *f
6349 fl->fl_start = fl->fl_end = 0;
6351 fl->fl_lmops = NULL;
6355 EXPORT_SYMBOL(locks_init_lock);
6356 @@ -244,6 +250,7 @@ void locks_copy_lock(struct file_lock *n
6357 new->fl_file = fl->fl_file;
6358 new->fl_ops = fl->fl_ops;
6359 new->fl_lmops = fl->fl_lmops;
6360 + new->fl_xid = fl->fl_xid;
6362 locks_copy_private(new, fl);
6364 @@ -282,6 +289,11 @@ static int flock_make_lock(struct file *
6365 fl->fl_flags = FL_FLOCK;
6367 fl->fl_end = OFFSET_MAX;
6369 + vxd_assert(filp->f_xid == vx_current_xid(),
6370 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6371 + fl->fl_xid = filp->f_xid;
6376 @@ -447,6 +459,7 @@ static int lease_init(struct file *filp,
6378 fl->fl_owner = current->files;
6379 fl->fl_pid = current->tgid;
6380 + fl->fl_xid = vx_current_xid();
6383 fl->fl_flags = FL_LEASE;
6384 @@ -466,6 +479,11 @@ static int lease_alloc(struct file *filp
6388 + fl->fl_xid = vx_current_xid();
6390 + vxd_assert(filp->f_xid == fl->fl_xid,
6391 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6393 error = lease_init(filp, type, fl);
6395 locks_free_lock(fl);
6396 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
6400 + new_fl->fl_xid = -1;
6402 for_each_lock(inode, before) {
6403 struct file_lock *fl = *before;
6404 @@ -787,6 +806,7 @@ find_conflict:
6406 locks_copy_lock(new_fl, request);
6407 locks_insert_lock(before, new_fl);
6408 + vx_locks_inc(new_fl);
6412 @@ -797,7 +817,8 @@ out:
6416 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6417 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6418 + struct file_lock *conflock, xid_t xid)
6420 struct file_lock *fl;
6421 struct file_lock *new_fl = NULL;
6422 @@ -807,6 +828,8 @@ static int __posix_lock_file(struct inod
6423 struct file_lock **before;
6424 int error, added = 0;
6426 + vxd_assert(xid == vx_current_xid(),
6427 + "xid(%d) == current(%d)", xid, vx_current_xid());
6429 * We may need two file_lock structures for this operation,
6430 * so we get them in advance to avoid races.
6431 @@ -817,7 +840,11 @@ static int __posix_lock_file(struct inod
6432 (request->fl_type != F_UNLCK ||
6433 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6434 new_fl = locks_alloc_lock();
6435 + new_fl->fl_xid = xid;
6436 + vx_locks_inc(new_fl);
6437 new_fl2 = locks_alloc_lock();
6438 + new_fl2->fl_xid = xid;
6439 + vx_locks_inc(new_fl2);
6443 @@ -1016,7 +1043,8 @@ static int __posix_lock_file(struct inod
6444 int posix_lock_file(struct file *filp, struct file_lock *fl,
6445 struct file_lock *conflock)
6447 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6448 + return __posix_lock_file(filp->f_path.dentry->d_inode,
6449 + fl, conflock, filp->f_xid);
6451 EXPORT_SYMBOL(posix_lock_file);
6453 @@ -1106,7 +1134,7 @@ int locks_mandatory_area(int read_write,
6454 fl.fl_end = offset + count - 1;
6457 - error = __posix_lock_file(inode, &fl, NULL);
6458 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6459 if (error != -EAGAIN)
6461 if (!(fl.fl_flags & FL_SLEEP))
6462 @@ -1410,8 +1438,8 @@ static int __setlease(struct file *filp,
6465 locks_copy_lock(fl, lease);
6467 locks_insert_lock(before, fl);
6472 @@ -1738,6 +1766,11 @@ int fcntl_setlk(unsigned int fd, struct
6473 if (file_lock == NULL)
6476 + vxd_assert(filp->f_xid == vx_current_xid(),
6477 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6478 + file_lock->fl_xid = filp->f_xid;
6479 + vx_locks_inc(file_lock);
6482 * This might block, so we do it before checking the inode.
6484 @@ -1864,6 +1897,11 @@ int fcntl_setlk64(unsigned int fd, struc
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 @@ -2168,6 +2206,10 @@ int get_locks_status(char *buffer, char
6497 list_for_each(tmp, &file_lock_list) {
6498 struct list_head *btmp;
6499 struct file_lock *fl = list_entry(tmp, struct file_lock, fl_link);
6501 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6504 lock_get_status(q, fl, ++i, "");
6505 move_lock_status(&q, &pos, offset);
6507 diff -Nurp linux-2.6.22.15/fs/namei.c linux-2.6.22.15-vs2.3.0.29.1/fs/namei.c
6508 --- linux-2.6.22.15/fs/namei.c 2007-07-21 18:00:17.000000000 -0400
6509 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/namei.c 2007-12-09 06:44:21.000000000 -0500
6511 #include <linux/file.h>
6512 #include <linux/fcntl.h>
6513 #include <linux/namei.h>
6514 +#include <linux/proc_fs.h>
6515 +#include <linux/vserver/inode.h>
6516 +#include <linux/vs_base.h>
6517 +#include <linux/vs_tag.h>
6518 +#include <linux/vs_cowbl.h>
6519 +#include <linux/vs_device.h>
6520 +#include <linux/vs_context.h>
6521 #include <asm/namei.h>
6522 #include <asm/uaccess.h>
6524 @@ -224,6 +231,28 @@ int generic_permission(struct inode *ino
6528 +static inline int dx_barrier(struct inode *inode)
6530 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN)) {
6531 + vxwprintk_task(1, "did hit the barrier.");
6537 +static inline int dx_permission(struct inode *inode, int mask, struct nameidata *nd)
6539 + if (dx_barrier(inode))
6541 + if (dx_notagcheck(nd) ||
6542 + dx_check(inode->i_tag, DX_HOSTID|DX_ADMIN|DX_WATCH|DX_IDENT))
6545 + vxwprintk_task(1, "denied access to %p[#%d,%lu] »%s«.",
6546 + inode, inode->i_tag, inode->i_ino, vxd_cond_path(nd));
6550 int permission(struct inode *inode, int mask, struct nameidata *nd)
6552 umode_t mode = inode->i_mode;
6553 @@ -234,14 +263,14 @@ int permission(struct inode *inode, int
6555 * Nobody gets write access to a read-only fs.
6557 - if (IS_RDONLY(inode) &&
6558 + if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
6559 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
6563 * Nobody gets write access to an immutable file.
6565 - if (IS_IMMUTABLE(inode))
6566 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6570 @@ -257,6 +286,12 @@ int permission(struct inode *inode, int
6572 /* Ordinary permission routines do not understand MAY_APPEND. */
6573 submask = mask & ~MAY_APPEND;
6575 + if ((inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC) &&
6576 + (inode->i_sb->s_magic != PROC_SUPER_MAGIC) &&
6577 + (retval = dx_permission(inode, mask, nd)))
6580 if (inode->i_op && inode->i_op->permission)
6581 retval = inode->i_op->permission(inode, submask, nd);
6583 @@ -432,6 +467,8 @@ static int exec_permission_lite(struct i
6585 umode_t mode = inode->i_mode;
6587 + if (dx_barrier(inode))
6589 if (inode->i_op && inode->i_op->permission)
6592 @@ -732,7 +769,8 @@ static __always_inline void follow_dotdo
6593 if (nd->dentry == fs->root &&
6594 nd->mnt == fs->rootmnt) {
6595 read_unlock(&fs->lock);
6597 + /* for sane '/' avoid follow_mount() */
6600 read_unlock(&fs->lock);
6601 spin_lock(&dcache_lock);
6602 @@ -769,16 +807,39 @@ static int do_lookup(struct nameidata *n
6604 struct vfsmount *mnt = nd->mnt;
6605 struct dentry *dentry = __d_lookup(nd->dentry, name);
6606 + struct inode *inode;
6610 if (dentry->d_op && dentry->d_op->d_revalidate)
6611 goto need_revalidate;
6612 + inode = dentry->d_inode;
6616 + if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6617 + struct proc_dir_entry *de = PDE(inode);
6619 + if (de && !vx_hide_check(0, de->vx_flags))
6621 + } else if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6622 + if (!vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
6625 + if (!dx_notagcheck(nd) && !dx_check(inode->i_tag,
6626 + DX_WATCH | DX_ADMIN | DX_HOSTID | DX_IDENT))
6631 path->dentry = dentry;
6632 __follow_mount(path);
6635 + vxwprintk_task(1, "did lookup hidden %p[#%d,%lu] »%s«.",
6636 + inode, inode->i_tag, inode->i_ino, vxd_path(dentry, mnt));
6641 dentry = real_lookup(nd->dentry, name, nd);
6642 @@ -1399,7 +1460,8 @@ static inline int check_sticky(struct in
6643 * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
6644 * nfs_async_unlink().
6646 -static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
6647 +static int may_delete(struct inode *dir, struct dentry *victim,
6648 + int isdir, struct nameidata *nd)
6652 @@ -1409,13 +1471,13 @@ static int may_delete(struct inode *dir,
6653 BUG_ON(victim->d_parent->d_inode != dir);
6654 audit_inode_child(victim->d_name.name, victim->d_inode, dir);
6656 - error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
6657 + error = permission(dir,MAY_WRITE | MAY_EXEC, nd);
6662 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6663 - IS_IMMUTABLE(victim->d_inode))
6664 + IS_IXORUNLINK(victim->d_inode))
6667 if (!S_ISDIR(victim->d_inode->i_mode))
6668 @@ -1546,6 +1608,14 @@ int may_open(struct nameidata *nd, int a
6669 if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE))
6672 +#ifdef CONFIG_VSERVER_COWBL
6673 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
6674 + if (IS_COW_LINK(inode))
6676 + inode->i_flags &= ~(S_IUNLINK|S_IMMUTABLE);
6677 + mark_inode_dirty(inode);
6680 error = vfs_permission(nd, acc_mode);
6683 @@ -1562,7 +1632,8 @@ int may_open(struct nameidata *nd, int a
6687 - } else if (IS_RDONLY(inode) && (acc_mode & MAY_WRITE))
6688 + } else if ((IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
6689 + && (acc_mode & MAY_WRITE))
6692 * An append-only file must be opened in append mode for writing.
6693 @@ -1650,6 +1721,11 @@ int open_namei(int dfd, const char *path
6697 +#ifdef CONFIG_VSERVER_COWBL
6702 acc_mode = ACC_MODE(flag);
6704 /* O_TRUNC implies we need access checks for write permissions */
6705 @@ -1743,6 +1819,22 @@ do_last:
6708 error = may_open(nd, acc_mode, flag);
6709 +#ifdef CONFIG_VSERVER_COWBL
6710 + if (error == -EMLINK) {
6711 + struct dentry *dentry;
6712 + dentry = cow_break_link(pathname);
6713 + if (IS_ERR(dentry)) {
6714 + error = PTR_ERR(dentry);
6718 + release_open_intent(nd);
6728 @@ -1854,16 +1946,25 @@ fail:
6730 EXPORT_SYMBOL_GPL(lookup_create);
6732 -int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
6733 +int vfs_mknod(struct inode *dir, struct dentry *dentry,
6734 + int mode, dev_t dev, struct nameidata *nd)
6736 - int error = may_create(dir, dentry, NULL);
6737 + int error = may_create(dir, dentry, nd);
6742 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
6743 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
6746 + if (!capable(CAP_MKNOD))
6749 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
6751 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
6754 if (!dir->i_op || !dir->i_op->mknod)
6757 @@ -1906,11 +2007,12 @@ asmlinkage long sys_mknodat(int dfd, con
6758 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
6760 case S_IFCHR: case S_IFBLK:
6761 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
6762 - new_decode_dev(dev));
6763 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6764 + new_decode_dev(dev), &nd);
6766 case S_IFIFO: case S_IFSOCK:
6767 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
6768 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6773 @@ -1933,9 +2035,10 @@ asmlinkage long sys_mknod(const char __u
6774 return sys_mknodat(AT_FDCWD, filename, mode, dev);
6777 -int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
6778 +int vfs_mkdir(struct inode *dir, struct dentry *dentry,
6779 + int mode, struct nameidata *nd)
6781 - int error = may_create(dir, dentry, NULL);
6782 + int error = may_create(dir, dentry, nd);
6786 @@ -1977,7 +2080,7 @@ asmlinkage long sys_mkdirat(int dfd, con
6788 if (!IS_POSIXACL(nd.dentry->d_inode))
6789 mode &= ~current->fs->umask;
6790 - error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
6791 + error = vfs_mkdir(nd.dentry->d_inode, dentry, mode, &nd);
6794 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6795 @@ -2020,9 +2123,10 @@ void dentry_unhash(struct dentry *dentry
6796 spin_unlock(&dcache_lock);
6799 -int vfs_rmdir(struct inode *dir, struct dentry *dentry)
6800 +int vfs_rmdir(struct inode *dir, struct dentry *dentry,
6801 + struct nameidata *nd)
6803 - int error = may_delete(dir, dentry, 1);
6804 + int error = may_delete(dir, dentry, 1, nd);
6808 @@ -2084,7 +2188,7 @@ static long do_rmdir(int dfd, const char
6809 error = PTR_ERR(dentry);
6812 - error = vfs_rmdir(nd.dentry->d_inode, dentry);
6813 + error = vfs_rmdir(nd.dentry->d_inode, dentry, &nd);
6816 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6817 @@ -2100,9 +2204,10 @@ asmlinkage long sys_rmdir(const char __u
6818 return do_rmdir(AT_FDCWD, pathname);
6821 -int vfs_unlink(struct inode *dir, struct dentry *dentry)
6822 +int vfs_unlink(struct inode *dir, struct dentry *dentry,
6823 + struct nameidata *nd)
6825 - int error = may_delete(dir, dentry, 0);
6826 + int error = may_delete(dir, dentry, 0, nd);
6830 @@ -2164,7 +2269,7 @@ static long do_unlinkat(int dfd, const c
6831 inode = dentry->d_inode;
6833 atomic_inc(&inode->i_count);
6834 - error = vfs_unlink(nd.dentry->d_inode, dentry);
6835 + error = vfs_unlink(nd.dentry->d_inode, dentry, &nd);
6839 @@ -2199,9 +2304,10 @@ asmlinkage long sys_unlink(const char __
6840 return do_unlinkat(AT_FDCWD, pathname);
6843 -int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode)
6844 +int vfs_symlink(struct inode *dir, struct dentry *dentry,
6845 + const char *oldname, int mode, struct nameidata *nd)
6847 - int error = may_create(dir, dentry, NULL);
6848 + int error = may_create(dir, dentry, nd);
6852 @@ -2245,7 +2351,7 @@ asmlinkage long sys_symlinkat(const char
6856 - error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
6857 + error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO, &nd);
6860 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6861 @@ -2262,7 +2368,8 @@ asmlinkage long sys_symlink(const char _
6862 return sys_symlinkat(oldname, AT_FDCWD, newname);
6865 -int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
6866 +int vfs_link(struct dentry *old_dentry, struct inode *dir,
6867 + struct dentry *new_dentry, struct nameidata *nd)
6869 struct inode *inode = old_dentry->d_inode;
6871 @@ -2270,7 +2377,7 @@ int vfs_link(struct dentry *old_dentry,
6875 - error = may_create(dir, new_dentry, NULL);
6876 + error = may_create(dir, new_dentry, nd);
6880 @@ -2280,7 +2387,7 @@ int vfs_link(struct dentry *old_dentry,
6882 * A link to an append-only or immutable file cannot be created.
6884 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6885 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6887 if (!dir->i_op || !dir->i_op->link)
6889 @@ -2340,7 +2447,7 @@ asmlinkage long sys_linkat(int olddfd, c
6890 error = PTR_ERR(new_dentry);
6891 if (IS_ERR(new_dentry))
6893 - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
6894 + error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry, &nd);
6897 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6898 @@ -2472,14 +2579,14 @@ int vfs_rename(struct inode *old_dir, st
6899 if (old_dentry->d_inode == new_dentry->d_inode)
6902 - error = may_delete(old_dir, old_dentry, is_dir);
6903 + error = may_delete(old_dir, old_dentry, is_dir, NULL);
6907 if (!new_dentry->d_inode)
6908 error = may_create(new_dir, new_dentry, NULL);
6910 - error = may_delete(new_dir, new_dentry, is_dir);
6911 + error = may_delete(new_dir, new_dentry, is_dir, NULL);
6915 @@ -2557,6 +2664,9 @@ static int do_rename(int olddfd, const c
6917 if (old_dentry == trap)
6920 + if (MNT_IS_RDONLY(newnd.mnt))
6922 new_dentry = lookup_hash(&newnd);
6923 error = PTR_ERR(new_dentry);
6924 if (IS_ERR(new_dentry))
6925 @@ -2650,6 +2760,216 @@ int vfs_follow_link(struct nameidata *nd
6926 return __vfs_follow_link(nd, link);
6930 +#ifdef CONFIG_VSERVER_COWBL
6932 +#include <linux/file.h>
6935 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6939 + return do_splice_direct(in, &ppos, out, len, 0);
6942 +struct dentry *cow_break_link(const char *pathname)
6944 + int ret, mode, pathlen, redo = 0;
6945 + struct nameidata old_nd, dir_nd;
6946 + struct dentry *old_dentry, *new_dentry;
6947 + struct dentry *dir, *res = NULL;
6948 + struct vfsmount *old_mnt, *new_mnt;
6949 + struct file *old_file;
6950 + struct file *new_file;
6951 + char *to, *path, pad='\251';
6954 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6955 + path = kmalloc(PATH_MAX, GFP_KERNEL);
6960 + /* old_nd will have refs to dentry and mnt */
6961 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6962 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6964 + goto out_free_path;
6966 + old_dentry = old_nd.dentry;
6967 + old_mnt = old_nd.mnt;
6968 + mode = old_dentry->d_inode->i_mode;
6970 + to = d_path(old_dentry, old_mnt, path, PATH_MAX-2);
6971 + pathlen = strlen(to);
6972 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
6973 + old_dentry->d_name.len, old_dentry->d_name.name,
6974 + old_dentry->d_name.len);
6976 + to[pathlen + 1] = 0;
6978 + to[pathlen] = pad--;
6980 + if (pad <= '\240')
6983 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
6984 + /* dir_nd will have refs to dentry and mnt */
6985 + ret = path_lookup(to,
6986 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6987 + vxdprintk(VXD_CBIT(misc, 2),
6988 + "path_lookup(new): %d", ret);
6992 + /* this puppy downs the inode mutex */
6993 + new_dentry = lookup_create(&dir_nd, 0);
6994 + vxdprintk(VXD_CBIT(misc, 2),
6995 + "lookup_create(new): %p [»%.*s«:%d]", new_dentry,
6996 + new_dentry->d_name.len, new_dentry->d_name.name,
6997 + new_dentry->d_name.len);
6998 + if (!new_dentry || IS_ERR(new_dentry)) {
6999 + path_release(&dir_nd);
7002 + dir = dir_nd.dentry;
7004 + ret = vfs_create(dir_nd.dentry->d_inode, new_dentry, mode, &dir_nd);
7005 + vxdprintk(VXD_CBIT(misc, 2),
7006 + "vfs_create(new): %d", ret);
7007 + if (ret == -EEXIST) {
7008 + mutex_unlock(&dir->d_inode->i_mutex);
7010 + path_release(&dir_nd);
7014 + goto out_unlock_new;
7016 + /* drop out early, ret passes ENOENT */
7018 + if ((redo = d_unhashed(old_dentry)))
7019 + goto out_unlock_new;
7021 + new_mnt = dir_nd.mnt;
7024 + /* this one cleans up the dentry/mnt in case of failure */
7025 + old_file = dentry_open(old_dentry, old_mnt, O_RDONLY);
7026 + vxdprintk(VXD_CBIT(misc, 2),
7027 + "dentry_open(old): %p", old_file);
7028 + if (!old_file || IS_ERR(old_file)) {
7029 + res = IS_ERR(old_file) ? (void *) old_file : res;
7030 + goto out_unlock_new;
7035 + /* this one cleans up the dentry/mnt in case of failure */
7036 + new_file = dentry_open(new_dentry, new_mnt, O_WRONLY);
7037 + vxdprintk(VXD_CBIT(misc, 2),
7038 + "dentry_open(new): %p", new_file);
7040 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
7041 + if (!new_file || IS_ERR(new_file))
7042 + goto out_fput_old;
7044 + size = i_size_read(old_file->f_dentry->d_inode);
7045 + ret = do_cow_splice(old_file, new_file, size);
7046 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
7048 + goto out_fput_both;
7049 + } else if (ret < size) {
7051 + goto out_fput_both;
7053 + struct inode *old_inode = old_dentry->d_inode;
7054 + struct inode *new_inode = new_dentry->d_inode;
7055 + struct iattr attr = {
7056 + .ia_uid = old_inode->i_uid,
7057 + .ia_gid = old_inode->i_gid,
7058 + .ia_valid = ATTR_UID | ATTR_GID
7061 + ret = inode_setattr(new_inode, &attr);
7063 + goto out_fput_both;
7066 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
7068 + /* drop out late */
7070 + if ((redo = d_unhashed(old_dentry)))
7073 + vxdprintk(VXD_CBIT(misc, 2),
7074 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
7075 + new_dentry->d_name.len, new_dentry->d_name.name,
7076 + new_dentry->d_name.len,
7077 + old_dentry->d_name.len, old_dentry->d_name.name,
7078 + old_dentry->d_name.len);
7079 + ret = vfs_rename(dir_nd.dentry->d_inode, new_dentry,
7080 + old_nd.dentry->d_parent->d_inode, old_dentry);
7081 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
7085 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
7088 + vxdprintk(VXD_CBIT(misc, 3),
7089 + "fput(new_file=%p[#%d])", new_file,
7090 + atomic_read(&new_file->f_count));
7094 + vxdprintk(VXD_CBIT(misc, 3),
7095 + "fput(old_file=%p[#%d])", old_file,
7096 + atomic_read(&old_file->f_count));
7100 + mutex_unlock(&dir->d_inode->i_mutex);
7104 + /* error path cleanup */
7105 + vfs_unlink(dir->d_inode, new_dentry, &dir_nd);
7110 + goto out_rel_both;
7111 + /* lookup dentry once again */
7112 + path_release(&old_nd);
7113 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
7115 + goto out_rel_both;
7117 + new_dentry = old_nd.dentry;
7118 + vxdprintk(VXD_CBIT(misc, 2),
7119 + "path_lookup(redo): %p [»%.*s«:%d]", new_dentry,
7120 + new_dentry->d_name.len, new_dentry->d_name.name,
7121 + new_dentry->d_name.len);
7126 + path_release(&dir_nd);
7128 + path_release(&old_nd);
7133 + res = ERR_PTR(ret);
7139 /* get the link contents into pagecache */
7140 static char *page_getlink(struct dentry * dentry, struct page **ppage)
7142 diff -Nurp linux-2.6.22.15/fs/namespace.c linux-2.6.22.15-vs2.3.0.29.1/fs/namespace.c
7143 --- linux-2.6.22.15/fs/namespace.c 2007-07-21 18:00:17.000000000 -0400
7144 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/namespace.c 2007-12-09 06:44:21.000000000 -0500
7146 #include <linux/security.h>
7147 #include <linux/mount.h>
7148 #include <linux/ramfs.h>
7149 +#include <linux/vs_base.h>
7150 +#include <linux/vs_context.h>
7151 +#include <linux/vs_tag.h>
7152 +#include <linux/vserver/space.h>
7153 +#include <linux/vserver/global.h>
7154 #include <asm/uaccess.h>
7155 #include <asm/unistd.h>
7157 @@ -240,6 +245,7 @@ static struct vfsmount *clone_mnt(struct
7158 mnt->mnt_root = dget(root);
7159 mnt->mnt_mountpoint = mnt->mnt_root;
7160 mnt->mnt_parent = mnt;
7161 + mnt->mnt_tag = old->mnt_tag;
7163 if (flag & CL_SLAVE) {
7164 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
7165 @@ -348,48 +354,91 @@ static inline void mangle(struct seq_fil
7166 seq_escape(m, s, " \t\n\\");
7169 +static int mnt_is_reachable(struct vfsmount *mnt)
7171 + struct vfsmount *root_mnt;
7172 + struct dentry *root, *point;
7175 + if (mnt == mnt->mnt_ns->root)
7178 + spin_lock(&vfsmount_lock);
7179 + root_mnt = current->fs->rootmnt;
7180 + root = current->fs->root;
7183 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
7184 + point = mnt->mnt_mountpoint;
7185 + mnt = mnt->mnt_parent;
7188 + ret = (mnt == root_mnt) && is_subdir(point, root);
7190 + spin_unlock(&vfsmount_lock);
7195 static int show_vfsmnt(struct seq_file *m, void *v)
7197 struct vfsmount *mnt = v;
7199 static struct proc_fs_info {
7207 - { MS_SYNCHRONOUS, ",sync" },
7208 - { MS_DIRSYNC, ",dirsync" },
7209 - { MS_MANDLOCK, ",mand" },
7212 - static struct proc_fs_info mnt_info[] = {
7213 - { MNT_NOSUID, ",nosuid" },
7214 - { MNT_NODEV, ",nodev" },
7215 - { MNT_NOEXEC, ",noexec" },
7216 - { MNT_NOATIME, ",noatime" },
7217 - { MNT_NODIRATIME, ",nodiratime" },
7218 - { MNT_RELATIME, ",relatime" },
7220 + { MS_RDONLY, MNT_RDONLY, "ro", "rw" },
7221 + { MS_SYNCHRONOUS, 0, ",sync", NULL },
7222 + { MS_DIRSYNC, 0, ",dirsync", NULL },
7223 + { MS_MANDLOCK, 0, ",mand", NULL },
7224 + { MS_TAGGED, 0, ",tag", NULL },
7225 + { MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
7226 + { MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
7227 + { MS_RELATIME, MNT_RELATIME, ",relatime", NULL },
7228 + { 0, MNT_NOSUID, ",nosuid", NULL },
7229 + { 0, MNT_NODEV, ",nodev", NULL },
7230 + { 0, MNT_NOEXEC, ",noexec", NULL },
7231 + { 0, 0, NULL, NULL }
7233 - struct proc_fs_info *fs_infop;
7234 + struct proc_fs_info *p;
7235 + unsigned long s_flags = mnt->mnt_sb->s_flags;
7236 + int mnt_flags = mnt->mnt_flags;
7238 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7240 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7242 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7244 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7247 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7248 + mnt == current->fs->rootmnt) {
7249 + seq_puts(m, "/dev/root / ");
7251 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7253 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7256 + if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
7258 + mangle(m, mnt->mnt_sb->s_subtype);
7261 mangle(m, mnt->mnt_sb->s_type->name);
7262 - if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
7264 - mangle(m, mnt->mnt_sb->s_subtype);
7266 - seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
7267 - for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
7268 - if (mnt->mnt_sb->s_flags & fs_infop->flag)
7269 - seq_puts(m, fs_infop->str);
7271 - for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
7272 - if (mnt->mnt_flags & fs_infop->flag)
7273 - seq_puts(m, fs_infop->str);
7275 + for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
7276 + if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
7278 + seq_puts(m, p->set_str);
7281 + seq_puts(m, p->unset_str);
7284 + if (mnt->mnt_flags & MNT_TAGID)
7285 + seq_printf(m, ",tag=%d", mnt->mnt_tag);
7286 if (mnt->mnt_sb->s_op->show_options)
7287 err = mnt->mnt_sb->s_op->show_options(m, mnt);
7288 seq_puts(m, " 0 0\n");
7289 @@ -408,17 +457,27 @@ static int show_vfsstat(struct seq_file
7290 struct vfsmount *mnt = v;
7294 - if (mnt->mnt_devname) {
7295 - seq_puts(m, "device ");
7296 - mangle(m, mnt->mnt_devname);
7298 - seq_puts(m, "no device");
7301 - seq_puts(m, " mounted on ");
7302 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7304 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7306 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7309 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7310 + mnt == current->fs->rootmnt) {
7311 + seq_puts(m, "device /dev/root mounted on / ");
7314 + if (mnt->mnt_devname) {
7315 + seq_puts(m, "device ");
7316 + mangle(m, mnt->mnt_devname);
7318 + seq_puts(m, "no device");
7321 + seq_puts(m, " mounted on ");
7322 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7326 /* file system type */
7327 seq_puts(m, "with fstype ");
7328 @@ -648,7 +707,7 @@ asmlinkage long sys_umount(char __user *
7332 - if (!capable(CAP_SYS_ADMIN))
7333 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7336 retval = do_umount(nd.mnt, flags);
7337 @@ -672,7 +731,7 @@ asmlinkage long sys_oldumount(char __use
7339 static int mount_is_safe(struct nameidata *nd)
7341 - if (capable(CAP_SYS_ADMIN))
7342 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7346 @@ -904,11 +963,13 @@ static int do_change_type(struct nameida
7348 * do loopback mount.
7350 -static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
7351 +static int do_loopback(struct nameidata *nd, char *old_name, tag_t tag,
7352 + unsigned long flags, int mnt_flags)
7354 struct nameidata old_nd;
7355 struct vfsmount *mnt = NULL;
7356 int err = mount_is_safe(nd);
7357 + int recurse = flags & MS_REC;
7360 if (!old_name || !*old_name)
7361 @@ -934,6 +995,12 @@ static int do_loopback(struct nameidata
7365 + mnt->mnt_flags = mnt_flags;
7366 + if (flags & MS_TAGID) {
7367 + mnt->mnt_tag = tag;
7368 + mnt->mnt_flags |= MNT_TAGID;
7371 err = graft_tree(mnt, nd);
7373 LIST_HEAD(umount_list);
7374 @@ -942,6 +1009,7 @@ static int do_loopback(struct nameidata
7375 spin_unlock(&vfsmount_lock);
7376 release_mounts(&umount_list);
7378 + mnt->mnt_flags = mnt_flags;
7381 up_write(&namespace_sem);
7382 @@ -955,12 +1023,12 @@ out:
7383 * on it - tough luck.
7385 static int do_remount(struct nameidata *nd, int flags, int mnt_flags,
7387 + void *data, xid_t xid)
7390 struct super_block *sb = nd->mnt->mnt_sb;
7392 - if (!capable(CAP_SYS_ADMIN))
7393 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7396 if (!check_mnt(nd->mnt))
7397 @@ -994,7 +1062,7 @@ static int do_move_mount(struct nameidat
7398 struct nameidata old_nd, parent_nd;
7401 - if (!capable(CAP_SYS_ADMIN))
7402 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7404 if (!old_name || !*old_name)
7406 @@ -1074,7 +1142,7 @@ static int do_new_mount(struct nameidata
7409 /* we need capabilities... */
7410 - if (!capable(CAP_SYS_ADMIN))
7411 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7414 mnt = do_kern_mount(type, flags, name, data);
7415 @@ -1386,6 +1454,7 @@ long do_mount(char *dev_name, char *dir_
7416 struct nameidata nd;
7422 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7423 @@ -1401,7 +1470,17 @@ long do_mount(char *dev_name, char *dir_
7425 ((char *)data_page)[PAGE_SIZE - 1] = 0;
7427 + retval = dx_parse_tag(data_page, &tag, 1);
7429 + mnt_flags |= retval;
7430 + /* FIXME: bind and re-mounts get the tag flag? */
7431 + if (flags & (MS_BIND|MS_REMOUNT))
7432 + flags |= MS_TAGID;
7435 /* Separate the per-mountpoint flags */
7436 + if (flags & MS_RDONLY)
7437 + mnt_flags |= MNT_RDONLY;
7438 if (flags & MS_NOSUID)
7439 mnt_flags |= MNT_NOSUID;
7440 if (flags & MS_NODEV)
7441 @@ -1415,6 +1494,8 @@ long do_mount(char *dev_name, char *dir_
7442 if (flags & MS_RELATIME)
7443 mnt_flags |= MNT_RELATIME;
7445 + if (!capable(CAP_SYS_ADMIN))
7446 + mnt_flags |= MNT_NODEV;
7447 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
7448 MS_NOATIME | MS_NODIRATIME | MS_RELATIME);
7450 @@ -1429,9 +1510,9 @@ long do_mount(char *dev_name, char *dir_
7452 if (flags & MS_REMOUNT)
7453 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
7456 else if (flags & MS_BIND)
7457 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
7458 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
7459 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7460 retval = do_change_type(&nd, flags);
7461 else if (flags & MS_MOVE)
7462 @@ -1504,6 +1585,7 @@ static struct mnt_namespace *dup_mnt_ns(
7463 q = next_mnt(q, new_ns->root);
7465 up_write(&namespace_sem);
7466 + atomic_inc(&vs_global_mnt_ns);
7470 @@ -1866,5 +1948,6 @@ void __put_mnt_ns(struct mnt_namespace *
7471 spin_unlock(&vfsmount_lock);
7472 up_write(&namespace_sem);
7473 release_mounts(&umount_list);
7474 + atomic_dec(&vs_global_mnt_ns);
7477 diff -Nurp linux-2.6.22.15/fs/nfs/client.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/client.c
7478 --- linux-2.6.22.15/fs/nfs/client.c 2007-07-21 18:00:17.000000000 -0400
7479 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/client.c 2007-12-09 06:44:21.000000000 -0500
7480 @@ -521,6 +521,9 @@ static int nfs_init_server_rpcclient(str
7481 if (server->flags & NFS4_MOUNT_INTR)
7482 server->client->cl_intr = 1;
7484 + server->client->cl_tag = 0;
7485 + if (server->flags & NFS_MOUNT_TAGGED)
7486 + server->client->cl_tag = 1;
7490 @@ -678,6 +681,10 @@ static void nfs_server_set_fsinfo(struct
7491 server->acdirmin = server->acdirmax = 0;
7494 + /* FIXME: needs fsinfo
7495 + if (server->flags & NFS_MOUNT_TAGGED)
7496 + sb->s_flags |= MS_TAGGED; */
7498 server->maxfilesize = fsinfo->maxfilesize;
7500 /* We're airborne Set socket buffersize */
7501 diff -Nurp linux-2.6.22.15/fs/nfs/dir.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/dir.c
7502 --- linux-2.6.22.15/fs/nfs/dir.c 2007-07-21 18:00:17.000000000 -0400
7503 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/dir.c 2007-12-09 06:44:21.000000000 -0500
7505 #include <linux/namei.h>
7506 #include <linux/mount.h>
7507 #include <linux/sched.h>
7508 +#include <linux/vs_tag.h>
7510 #include "nfs4_fs.h"
7511 #include "delegation.h"
7512 @@ -956,6 +957,7 @@ static struct dentry *nfs_lookup(struct
7516 + dx_propagate_tag(nd, inode);
7518 res = d_materialise_unique(dentry, inode);
7520 @@ -998,7 +1000,8 @@ static int is_atomic_open(struct inode *
7521 if (nd->flags & LOOKUP_DIRECTORY)
7523 /* Are we trying to write to a read only partition? */
7524 - if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7525 + if ((IS_RDONLY(dir) || MNT_IS_RDONLY(nd->mnt)) &&
7526 + (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7530 diff -Nurp linux-2.6.22.15/fs/nfs/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/inode.c
7531 --- linux-2.6.22.15/fs/nfs/inode.c 2007-07-21 18:00:17.000000000 -0400
7532 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/inode.c 2007-12-09 06:44:21.000000000 -0500
7534 #include <linux/vfs.h>
7535 #include <linux/inet.h>
7536 #include <linux/nfs_xdr.h>
7537 +#include <linux/vs_tag.h>
7539 #include <asm/system.h>
7540 #include <asm/uaccess.h>
7541 @@ -285,8 +286,10 @@ nfs_fhget(struct super_block *sb, struct
7542 nfsi->change_attr = fattr->change_attr;
7543 inode->i_size = nfs_size_to_loff_t(fattr->size);
7544 inode->i_nlink = fattr->nlink;
7545 - inode->i_uid = fattr->uid;
7546 - inode->i_gid = fattr->gid;
7547 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7548 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7549 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7550 + /* maybe fattr->xid someday */
7551 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7553 * report the blocks in 512byte units
7554 @@ -377,6 +380,8 @@ void nfs_setattr_update_inode(struct ino
7555 inode->i_uid = attr->ia_uid;
7556 if ((attr->ia_valid & ATTR_GID) != 0)
7557 inode->i_gid = attr->ia_gid;
7558 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7559 + inode->i_tag = attr->ia_tag;
7560 spin_lock(&inode->i_lock);
7561 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7562 spin_unlock(&inode->i_lock);
7563 @@ -825,6 +830,9 @@ static int nfs_check_inode_attributes(st
7564 struct nfs_inode *nfsi = NFS_I(inode);
7565 loff_t cur_size, new_isize;
7572 /* Has the inode gone and changed behind our back? */
7573 @@ -852,10 +860,15 @@ static int nfs_check_inode_attributes(st
7574 if (cur_size != new_isize && nfsi->npages == 0)
7575 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7577 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7578 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7579 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7581 /* Have any file permissions changed? */
7582 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
7583 - || inode->i_uid != fattr->uid
7584 - || inode->i_gid != fattr->gid)
7585 + || inode->i_uid != uid
7586 + || inode->i_gid != gid
7587 + || inode->i_tag != tag)
7588 nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7590 /* Has the link count changed? */
7591 @@ -946,6 +959,9 @@ static int nfs_update_inode(struct inode
7592 unsigned int invalid = 0;
7593 unsigned long now = jiffies;
7599 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7600 __FUNCTION__, inode->i_sb->s_id, inode->i_ino,
7601 @@ -1022,15 +1038,21 @@ static int nfs_update_inode(struct inode
7603 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7605 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7606 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7607 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7609 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
7610 - inode->i_uid != fattr->uid ||
7611 - inode->i_gid != fattr->gid)
7612 + inode->i_uid != uid ||
7613 + inode->i_gid != gid ||
7614 + inode->i_tag != tag)
7615 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7617 inode->i_mode = fattr->mode;
7618 inode->i_nlink = fattr->nlink;
7619 - inode->i_uid = fattr->uid;
7620 - inode->i_gid = fattr->gid;
7621 + inode->i_uid = uid;
7622 + inode->i_gid = gid;
7623 + inode->i_tag = tag;
7625 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7627 diff -Nurp linux-2.6.22.15/fs/nfs/nfs3xdr.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/nfs3xdr.c
7628 --- linux-2.6.22.15/fs/nfs/nfs3xdr.c 2007-07-21 18:00:17.000000000 -0400
7629 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/nfs3xdr.c 2007-12-09 06:44:21.000000000 -0500
7631 #include <linux/nfs3.h>
7632 #include <linux/nfs_fs.h>
7633 #include <linux/nfsacl.h>
7634 +#include <linux/vs_tag.h>
7635 #include "internal.h"
7637 #define NFSDBG_FACILITY NFSDBG_XDR
7638 @@ -178,7 +179,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7641 static inline __be32 *
7642 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7643 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7645 if (attr->ia_valid & ATTR_MODE) {
7647 @@ -186,15 +187,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7651 - if (attr->ia_valid & ATTR_UID) {
7652 + if (attr->ia_valid & ATTR_UID ||
7653 + (tag && (attr->ia_valid & ATTR_TAG))) {
7655 - *p++ = htonl(attr->ia_uid);
7656 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7660 - if (attr->ia_valid & ATTR_GID) {
7661 + if (attr->ia_valid & ATTR_GID ||
7662 + (tag && (attr->ia_valid & ATTR_TAG))) {
7664 - *p++ = htonl(attr->ia_gid);
7665 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7669 @@ -279,7 +282,8 @@ static int
7670 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7672 p = xdr_encode_fhandle(p, args->fh);
7673 - p = xdr_encode_sattr(p, args->sattr);
7674 + p = xdr_encode_sattr(p, args->sattr,
7675 + req->rq_task->tk_client->cl_tag);
7676 *p++ = htonl(args->guard);
7678 p = xdr_encode_time3(p, &args->guardtime);
7679 @@ -370,7 +374,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7680 *p++ = args->verifier[0];
7681 *p++ = args->verifier[1];
7683 - p = xdr_encode_sattr(p, args->sattr);
7684 + p = xdr_encode_sattr(p, args->sattr,
7685 + req->rq_task->tk_client->cl_tag);
7687 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7689 @@ -384,7 +389,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7691 p = xdr_encode_fhandle(p, args->fh);
7692 p = xdr_encode_array(p, args->name, args->len);
7693 - p = xdr_encode_sattr(p, args->sattr);
7694 + p = xdr_encode_sattr(p, args->sattr,
7695 + req->rq_task->tk_client->cl_tag);
7696 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7699 @@ -397,7 +403,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7701 p = xdr_encode_fhandle(p, args->fromfh);
7702 p = xdr_encode_array(p, args->fromname, args->fromlen);
7703 - p = xdr_encode_sattr(p, args->sattr);
7704 + p = xdr_encode_sattr(p, args->sattr,
7705 + req->rq_task->tk_client->cl_tag);
7706 *p++ = htonl(args->pathlen);
7707 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7709 @@ -415,7 +422,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7710 p = xdr_encode_fhandle(p, args->fh);
7711 p = xdr_encode_array(p, args->name, args->len);
7712 *p++ = htonl(args->type);
7713 - p = xdr_encode_sattr(p, args->sattr);
7714 + p = xdr_encode_sattr(p, args->sattr,
7715 + req->rq_task->tk_client->cl_tag);
7716 if (args->type == NF3CHR || args->type == NF3BLK) {
7717 *p++ = htonl(MAJOR(args->rdev));
7718 *p++ = htonl(MINOR(args->rdev));
7719 diff -Nurp linux-2.6.22.15/fs/nfs/nfsroot.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/nfsroot.c
7720 --- linux-2.6.22.15/fs/nfs/nfsroot.c 2007-07-21 18:00:17.000000000 -0400
7721 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/nfsroot.c 2007-12-09 06:44:21.000000000 -0500
7722 @@ -118,12 +118,12 @@ static int mount_port __initdata = 0; /
7724 /* Options that take integer arguments */
7725 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7726 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7727 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7728 /* Options that take no arguments */
7729 Opt_soft, Opt_hard, Opt_intr,
7730 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
7731 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7732 - Opt_acl, Opt_noacl,
7733 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7737 @@ -160,6 +160,9 @@ static match_table_t __initdata tokens =
7740 {Opt_noacl, "noacl"},
7742 + {Opt_notag, "notag"},
7743 + {Opt_tagid, "tagid=%u"},
7747 @@ -274,6 +277,20 @@ static int __init root_nfs_parse(char *n
7749 nfs_data.flags |= NFS_MOUNT_NOACL;
7751 +#ifndef CONFIG_TAGGING_NONE
7753 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7756 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7759 +#ifdef CONFIG_PROPAGATE
7762 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7766 printk(KERN_WARNING "Root-NFS: unknown "
7768 diff -Nurp linux-2.6.22.15/fs/nfs/super.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/super.c
7769 --- linux-2.6.22.15/fs/nfs/super.c 2007-09-29 08:11:49.000000000 -0400
7770 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfs/super.c 2007-12-09 06:44:21.000000000 -0500
7772 #include <linux/nfs_xdr.h>
7773 #include <linux/magic.h>
7774 #include <linux/parser.h>
7775 +#include <linux/vs_tag.h>
7777 #include <asm/system.h>
7778 #include <asm/uaccess.h>
7779 @@ -291,6 +292,7 @@ static void nfs_show_mount_options(struc
7780 { NFS_MOUNT_NOACL, ",noacl", "" },
7781 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7782 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
7783 + { NFS_MOUNT_TAGGED, ",tag", "" },
7786 const struct proc_nfs_info *nfs_infop;
7787 diff -Nurp linux-2.6.22.15/fs/nfsd/auth.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/auth.c
7788 --- linux-2.6.22.15/fs/nfsd/auth.c 2006-06-17 21:49:35.000000000 -0400
7789 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/auth.c 2007-12-09 06:44:21.000000000 -0500
7791 #include <linux/sunrpc/svc.h>
7792 #include <linux/sunrpc/svcauth.h>
7793 #include <linux/nfsd/nfsd.h>
7794 +#include <linux/vs_tag.h>
7796 #define CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
7798 @@ -41,19 +42,22 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7799 get_group_info(cred.cr_group_info);
7801 if (cred.cr_uid != (uid_t) -1)
7802 - current->fsuid = cred.cr_uid;
7803 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7805 current->fsuid = exp->ex_anon_uid;
7806 if (cred.cr_gid != (gid_t) -1)
7807 - current->fsgid = cred.cr_gid;
7808 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7810 current->fsgid = exp->ex_anon_gid;
7812 + /* this desperately needs a tag :) */
7813 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7815 if (!cred.cr_group_info)
7817 ret = set_current_groups(cred.cr_group_info);
7818 put_group_info(cred.cr_group_info);
7819 - if ((cred.cr_uid)) {
7820 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
7821 cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
7823 cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
7824 diff -Nurp linux-2.6.22.15/fs/nfsd/nfs3xdr.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/nfs3xdr.c
7825 --- linux-2.6.22.15/fs/nfsd/nfs3xdr.c 2007-07-21 18:00:17.000000000 -0400
7826 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/nfs3xdr.c 2007-12-09 06:44:21.000000000 -0500
7828 #include <linux/sunrpc/svc.h>
7829 #include <linux/nfsd/nfsd.h>
7830 #include <linux/nfsd/xdr3.h>
7831 +#include <linux/vs_tag.h>
7833 #define NFSDDBG_FACILITY NFSDDBG_XDR
7835 @@ -107,6 +108,8 @@ static __be32 *
7836 decode_sattr3(__be32 *p, struct iattr *iap)
7844 @@ -116,12 +119,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7847 iap->ia_valid |= ATTR_UID;
7848 - iap->ia_uid = ntohl(*p++);
7849 + uid = ntohl(*p++);
7852 iap->ia_valid |= ATTR_GID;
7853 - iap->ia_gid = ntohl(*p++);
7854 + gid = ntohl(*p++);
7856 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7857 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7858 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7862 @@ -180,8 +186,10 @@ encode_fattr3(struct svc_rqst *rqstp, __
7863 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7864 *p++ = htonl((u32) stat->mode);
7865 *p++ = htonl((u32) stat->nlink);
7866 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7867 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7868 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7869 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7870 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7871 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7872 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7873 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7875 diff -Nurp linux-2.6.22.15/fs/nfsd/nfs4recover.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/nfs4recover.c
7876 --- linux-2.6.22.15/fs/nfsd/nfs4recover.c 2007-07-21 18:00:17.000000000 -0400
7877 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/nfs4recover.c 2007-12-09 06:44:21.000000000 -0500
7878 @@ -156,7 +156,7 @@ nfsd4_create_clid_dir(struct nfs4_client
7879 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n");
7882 - status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU);
7883 + status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU, NULL);
7887 @@ -260,7 +260,7 @@ nfsd4_remove_clid_file(struct dentry *di
7890 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7891 - status = vfs_unlink(dir->d_inode, dentry);
7892 + status = vfs_unlink(dir->d_inode, dentry, NULL);
7893 mutex_unlock(&dir->d_inode->i_mutex);
7896 @@ -275,7 +275,7 @@ nfsd4_clear_clid_dir(struct dentry *dir,
7897 * a kernel from the future.... */
7898 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
7899 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7900 - status = vfs_rmdir(dir->d_inode, dentry);
7901 + status = vfs_rmdir(dir->d_inode, dentry, NULL);
7902 mutex_unlock(&dir->d_inode->i_mutex);
7905 diff -Nurp linux-2.6.22.15/fs/nfsd/nfs4xdr.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/nfs4xdr.c
7906 --- linux-2.6.22.15/fs/nfsd/nfs4xdr.c 2007-07-21 18:00:17.000000000 -0400
7907 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/nfs4xdr.c 2007-12-09 06:44:21.000000000 -0500
7909 #include <linux/nfs4_acl.h>
7910 #include <linux/sunrpc/gss_api.h>
7911 #include <linux/sunrpc/svcauth_gss.h>
7912 +#include <linux/vs_tag.h>
7914 #define NFSDDBG_FACILITY NFSDDBG_XDR
7916 @@ -1727,14 +1728,18 @@ out_acl:
7917 WRITE32(stat.nlink);
7919 if (bmval1 & FATTR4_WORD1_OWNER) {
7920 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7921 + status = nfsd4_encode_user(rqstp,
7922 + TAGINO_UID(DX_TAG(dentry->d_inode),
7923 + stat.uid, stat.tag), &p, &buflen);
7924 if (status == nfserr_resource)
7929 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7930 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7931 + status = nfsd4_encode_group(rqstp,
7932 + TAGINO_GID(DX_TAG(dentry->d_inode),
7933 + stat.gid, stat.tag), &p, &buflen);
7934 if (status == nfserr_resource)
7937 diff -Nurp linux-2.6.22.15/fs/nfsd/nfsxdr.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/nfsxdr.c
7938 --- linux-2.6.22.15/fs/nfsd/nfsxdr.c 2007-07-21 18:00:17.000000000 -0400
7939 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/nfsxdr.c 2007-12-09 06:44:21.000000000 -0500
7941 #include <linux/nfsd/nfsd.h>
7942 #include <linux/nfsd/xdr.h>
7943 #include <linux/mm.h>
7944 +#include <linux/vs_tag.h>
7946 #define NFSDDBG_FACILITY NFSDDBG_XDR
7948 @@ -97,6 +98,8 @@ static __be32 *
7949 decode_sattr(__be32 *p, struct iattr *iap)
7957 @@ -110,12 +113,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7959 if ((tmp = ntohl(*p++)) != (u32)-1) {
7960 iap->ia_valid |= ATTR_UID;
7961 - iap->ia_uid = tmp;
7964 if ((tmp = ntohl(*p++)) != (u32)-1) {
7965 iap->ia_valid |= ATTR_GID;
7966 - iap->ia_gid = tmp;
7969 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7970 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7971 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7972 if ((tmp = ntohl(*p++)) != (u32)-1) {
7973 iap->ia_valid |= ATTR_SIZE;
7975 @@ -160,8 +166,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7976 *p++ = htonl(nfs_ftypes[type >> 12]);
7977 *p++ = htonl((u32) stat->mode);
7978 *p++ = htonl((u32) stat->nlink);
7979 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7980 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7981 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7982 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7983 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7984 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7986 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7987 *p++ = htonl(NFS_MAXPATHLEN);
7988 diff -Nurp linux-2.6.22.15/fs/nfsd/vfs.c linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/vfs.c
7989 --- linux-2.6.22.15/fs/nfsd/vfs.c 2007-08-11 21:54:36.000000000 -0400
7990 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/nfsd/vfs.c 2007-12-09 06:44:21.000000000 -0500
7991 @@ -1186,13 +1186,13 @@ nfsd_create(struct svc_rqst *rqstp, stru
7992 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
7995 - host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
7996 + host_err = vfs_mkdir(dirp, dchild, iap->ia_mode, NULL);
8002 - host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
8003 + host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev, NULL);
8006 printk("nfsd: bad file type %o in nfsd_create\n", type);
8007 @@ -1466,11 +1466,13 @@ nfsd_symlink(struct svc_rqst *rqstp, str
8009 strncpy(path_alloced, path, plen);
8010 path_alloced[plen] = 0;
8011 - host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
8012 + host_err = vfs_symlink(dentry->d_inode, dnew,
8013 + path_alloced, mode, NULL);
8014 kfree(path_alloced);
8017 - host_err = vfs_symlink(dentry->d_inode, dnew, path, mode);
8018 + host_err = vfs_symlink(dentry->d_inode, dnew,
8019 + path, mode, NULL);
8022 if (EX_ISSYNC(fhp->fh_export))
8023 @@ -1529,7 +1531,7 @@ nfsd_link(struct svc_rqst *rqstp, struct
8024 dold = tfhp->fh_dentry;
8025 dest = dold->d_inode;
8027 - host_err = vfs_link(dold, dirp, dnew);
8028 + host_err = vfs_link(dold, dirp, dnew, NULL);
8030 if (EX_ISSYNC(ffhp->fh_export)) {
8031 err = nfserrno(nfsd_sync_dir(ddir));
8032 @@ -1694,9 +1696,9 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
8036 - host_err = vfs_unlink(dirp, rdentry);
8037 + host_err = vfs_unlink(dirp, rdentry, NULL);
8038 } else { /* It's RMDIR */
8039 - host_err = vfs_rmdir(dirp, rdentry);
8040 + host_err = vfs_rmdir(dirp, rdentry, NULL);
8044 @@ -1807,7 +1809,8 @@ nfsd_permission(struct svc_export *exp,
8046 if (!(acc & MAY_LOCAL_ACCESS))
8047 if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
8048 - if (EX_RDONLY(exp, rqstp) || IS_RDONLY(inode))
8049 + if (EX_RDONLY(exp, rqstp) || IS_RDONLY(inode)
8050 + || MNT_IS_RDONLY(exp->ex_mnt))
8052 if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
8054 diff -Nurp linux-2.6.22.15/fs/ocfs2/dlm/dlmfs.c linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/dlm/dlmfs.c
8055 --- linux-2.6.22.15/fs/ocfs2/dlm/dlmfs.c 2007-07-21 18:00:17.000000000 -0400
8056 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/dlm/dlmfs.c 2007-12-09 06:44:21.000000000 -0500
8058 #include <linux/init.h>
8059 #include <linux/string.h>
8060 #include <linux/backing-dev.h>
8061 +#include <linux/vs_tag.h>
8063 #include <asm/uaccess.h>
8065 @@ -331,6 +332,7 @@ static struct inode *dlmfs_get_root_inod
8066 inode->i_mode = mode;
8067 inode->i_uid = current->fsuid;
8068 inode->i_gid = current->fsgid;
8069 + inode->i_tag = dx_current_fstag(sb);
8070 inode->i_blocks = 0;
8071 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
8072 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
8073 @@ -357,6 +359,7 @@ static struct inode *dlmfs_get_inode(str
8074 inode->i_mode = mode;
8075 inode->i_uid = current->fsuid;
8076 inode->i_gid = current->fsgid;
8077 + inode->i_tag = dx_current_fstag(sb);
8078 inode->i_blocks = 0;
8079 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
8080 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
8081 diff -Nurp linux-2.6.22.15/fs/ocfs2/dlmglue.c linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/dlmglue.c
8082 --- linux-2.6.22.15/fs/ocfs2/dlmglue.c 2007-07-21 18:00:18.000000000 -0400
8083 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/dlmglue.c 2007-12-09 06:44:21.000000000 -0500
8084 @@ -1475,6 +1475,7 @@ static void __ocfs2_stuff_meta_lvb(struc
8085 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
8086 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
8087 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
8088 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
8089 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
8090 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
8091 lvb->lvb_iatime_packed =
8092 @@ -1527,6 +1528,7 @@ static void ocfs2_refresh_inode_from_lvb
8094 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
8095 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
8096 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
8097 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
8098 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
8099 ocfs2_unpack_timespec(&inode->i_atime,
8100 diff -Nurp linux-2.6.22.15/fs/ocfs2/dlmglue.h linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/dlmglue.h
8101 --- linux-2.6.22.15/fs/ocfs2/dlmglue.h 2007-07-21 18:00:18.000000000 -0400
8102 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/dlmglue.h 2007-12-09 06:44:21.000000000 -0500
8104 struct ocfs2_meta_lvb {
8107 - __be16 lvb_reserved1;
8109 __be32 lvb_iclusters;
8112 diff -Nurp linux-2.6.22.15/fs/ocfs2/file.c linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/file.c
8113 --- linux-2.6.22.15/fs/ocfs2/file.c 2007-09-05 01:07:59.000000000 -0400
8114 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/file.c 2007-12-09 06:44:21.000000000 -0500
8115 @@ -943,13 +943,15 @@ int ocfs2_setattr(struct dentry *dentry,
8116 mlog(0, "uid change: %d\n", attr->ia_uid);
8117 if (attr->ia_valid & ATTR_GID)
8118 mlog(0, "gid change: %d\n", attr->ia_gid);
8119 + if (attr->ia_valid & ATTR_TAG)
8120 + mlog(0, "tag change: %d\n", attr->ia_tag);
8121 if (attr->ia_valid & ATTR_SIZE)
8122 mlog(0, "size change...\n");
8123 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
8124 mlog(0, "time change...\n");
8126 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
8127 - | ATTR_GID | ATTR_UID | ATTR_MODE)
8128 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
8129 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
8130 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
8132 @@ -1805,6 +1807,7 @@ bail:
8133 const struct inode_operations ocfs2_file_iops = {
8134 .setattr = ocfs2_setattr,
8135 .getattr = ocfs2_getattr,
8136 + .sync_flags = ocfs2_sync_flags,
8137 .permission = ocfs2_permission,
8140 diff -Nurp linux-2.6.22.15/fs/ocfs2/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/inode.c
8141 --- linux-2.6.22.15/fs/ocfs2/inode.c 2007-07-21 18:00:18.000000000 -0400
8142 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/inode.c 2007-12-09 06:44:21.000000000 -0500
8144 #include <linux/slab.h>
8145 #include <linux/highmem.h>
8146 #include <linux/pagemap.h>
8147 +#include <linux/vs_tag.h>
8149 #include <asm/byteorder.h>
8153 #include "heartbeat.h"
8156 #include "journal.h"
8158 #include "suballoc.h"
8159 @@ -77,6 +79,10 @@ void ocfs2_set_inode_flags(struct inode
8161 if (flags & OCFS2_IMMUTABLE_FL)
8162 inode->i_flags |= S_IMMUTABLE;
8163 + if (flags & OCFS2_IUNLINK_FL)
8164 + inode->i_flags |= S_IUNLINK;
8165 + if (flags & OCFS2_BARRIER_FL)
8166 + inode->i_flags |= S_BARRIER;
8168 if (flags & OCFS2_SYNC_FL)
8169 inode->i_flags |= S_SYNC;
8170 @@ -107,6 +113,27 @@ void ocfs2_get_inode_flags(struct ocfs2_
8171 oi->ip_attr |= OCFS2_DIRSYNC_FL;
8174 +int ocfs2_sync_flags(struct inode *inode)
8176 + unsigned int oldflags, newflags;
8178 + oldflags = OCFS2_I(inode)->ip_flags;
8179 + newflags = oldflags & ~(OCFS2_IMMUTABLE_FL |
8180 + OCFS2_IUNLINK_FL | OCFS2_BARRIER_FL);
8182 + if (IS_IMMUTABLE(inode))
8183 + newflags |= OCFS2_IMMUTABLE_FL;
8184 + if (IS_IUNLINK(inode))
8185 + newflags |= OCFS2_IUNLINK_FL;
8186 + if (IS_BARRIER(inode))
8187 + newflags |= OCFS2_BARRIER_FL;
8189 + if (oldflags ^ newflags)
8190 + return ocfs2_set_inode_attr(inode,
8191 + newflags, OCFS2_FL_MASK);
8195 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags)
8197 struct inode *inode = NULL;
8198 @@ -212,6 +239,8 @@ int ocfs2_populate_inode(struct inode *i
8199 struct super_block *sb;
8200 struct ocfs2_super *osb;
8201 int status = -EINVAL;
8205 mlog_entry("(0x%p, size:%llu)\n", inode,
8206 (unsigned long long)le64_to_cpu(fe->i_size));
8207 @@ -246,8 +275,12 @@ int ocfs2_populate_inode(struct inode *i
8208 inode->i_generation = le32_to_cpu(fe->i_generation);
8209 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
8210 inode->i_mode = le16_to_cpu(fe->i_mode);
8211 - inode->i_uid = le32_to_cpu(fe->i_uid);
8212 - inode->i_gid = le32_to_cpu(fe->i_gid);
8213 + uid = le32_to_cpu(fe->i_uid);
8214 + gid = le32_to_cpu(fe->i_gid);
8215 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8216 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8217 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8218 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8220 /* Fast symlinks will have i_size but no allocated clusters. */
8221 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
8222 @@ -1224,8 +1257,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
8224 fe->i_size = cpu_to_le64(i_size_read(inode));
8225 fe->i_links_count = cpu_to_le16(inode->i_nlink);
8226 - fe->i_uid = cpu_to_le32(inode->i_uid);
8227 - fe->i_gid = cpu_to_le32(inode->i_gid);
8228 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
8229 + inode->i_uid, inode->i_tag));
8230 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
8231 + inode->i_gid, inode->i_tag));
8232 + /* i_tag = = cpu_to_le16(inode->i_tag); */
8233 fe->i_mode = cpu_to_le16(inode->i_mode);
8234 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
8235 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
8236 @@ -1253,15 +1289,24 @@ leave:
8237 void ocfs2_refresh_inode(struct inode *inode,
8238 struct ocfs2_dinode *fe)
8243 spin_lock(&OCFS2_I(inode)->ip_lock);
8245 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
8246 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
8247 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
8248 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
8249 ocfs2_set_inode_flags(inode);
8250 i_size_write(inode, le64_to_cpu(fe->i_size));
8251 inode->i_nlink = le16_to_cpu(fe->i_links_count);
8252 - inode->i_uid = le32_to_cpu(fe->i_uid);
8253 - inode->i_gid = le32_to_cpu(fe->i_gid);
8254 + uid = le32_to_cpu(fe->i_uid);
8255 + gid = le32_to_cpu(fe->i_gid);
8256 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8257 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8258 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8259 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8260 inode->i_mode = le16_to_cpu(fe->i_mode);
8261 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
8262 inode->i_blocks = 0;
8263 diff -Nurp linux-2.6.22.15/fs/ocfs2/inode.h linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/inode.h
8264 --- linux-2.6.22.15/fs/ocfs2/inode.h 2007-07-21 18:00:18.000000000 -0400
8265 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/inode.h 2007-12-09 06:44:21.000000000 -0500
8266 @@ -142,6 +142,7 @@ int ocfs2_aio_write(struct file *file, s
8268 void ocfs2_set_inode_flags(struct inode *inode);
8269 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
8270 +int ocfs2_sync_flags(struct inode *inode);
8272 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
8274 diff -Nurp linux-2.6.22.15/fs/ocfs2/ioctl.c linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/ioctl.c
8275 --- linux-2.6.22.15/fs/ocfs2/ioctl.c 2007-07-21 18:00:18.000000000 -0400
8276 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/ioctl.c 2007-12-09 06:44:21.000000000 -0500
8277 @@ -39,7 +39,7 @@ static int ocfs2_get_inode_attr(struct i
8281 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8282 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8285 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
8286 diff -Nurp linux-2.6.22.15/fs/ocfs2/ioctl.h linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/ioctl.h
8287 --- linux-2.6.22.15/fs/ocfs2/ioctl.h 2007-07-21 18:00:18.000000000 -0400
8288 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/ioctl.h 2007-12-09 06:44:21.000000000 -0500
8290 #ifndef OCFS2_IOCTL_H
8291 #define OCFS2_IOCTL_H
8293 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8296 int ocfs2_ioctl(struct inode * inode, struct file * filp,
8297 unsigned int cmd, unsigned long arg);
8298 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
8299 diff -Nurp linux-2.6.22.15/fs/ocfs2/namei.c linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/namei.c
8300 --- linux-2.6.22.15/fs/ocfs2/namei.c 2007-07-21 18:00:18.000000000 -0400
8301 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/namei.c 2007-12-09 06:44:21.000000000 -0500
8303 #include <linux/types.h>
8304 #include <linux/slab.h>
8305 #include <linux/highmem.h>
8306 +#include <linux/vs_tag.h>
8308 #define MLOG_MASK_PREFIX ML_NAMEI
8309 #include <cluster/masklog.h>
8310 @@ -483,6 +484,9 @@ static int ocfs2_mknod_locked(struct ocf
8313 struct inode *inode = NULL;
8318 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
8319 (unsigned long)dev, dentry->d_name.len,
8320 @@ -542,13 +546,19 @@ static int ocfs2_mknod_locked(struct ocf
8321 fe->i_blkno = cpu_to_le64(fe_blkno);
8322 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
8323 fe->i_suballoc_slot = cpu_to_le16(osb->slot_num);
8324 - fe->i_uid = cpu_to_le32(current->fsuid);
8326 + tag = dx_current_fstag(osb->sb);
8327 + uid = current->fsuid;
8328 if (dir->i_mode & S_ISGID) {
8329 - fe->i_gid = cpu_to_le32(dir->i_gid);
8334 - fe->i_gid = cpu_to_le32(current->fsgid);
8335 + gid = current->fsgid;
8337 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
8338 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
8339 + inode->i_tag = tag;
8340 fe->i_mode = cpu_to_le16(mode);
8341 if (S_ISCHR(mode) || S_ISBLK(mode))
8342 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
8343 @@ -2316,5 +2326,6 @@ const struct inode_operations ocfs2_dir_
8344 .rename = ocfs2_rename,
8345 .setattr = ocfs2_setattr,
8346 .getattr = ocfs2_getattr,
8347 + .sync_flags = ocfs2_sync_flags,
8348 .permission = ocfs2_permission,
8350 diff -Nurp linux-2.6.22.15/fs/ocfs2/ocfs2_fs.h linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/ocfs2_fs.h
8351 --- linux-2.6.22.15/fs/ocfs2/ocfs2_fs.h 2007-07-21 18:00:18.000000000 -0400
8352 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/ocfs2_fs.h 2007-12-09 06:44:21.000000000 -0500
8353 @@ -152,8 +152,12 @@
8354 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
8355 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
8357 +#define OCFS2_BARRIER_FL (0x04000000) /* Barrier for chroot() */
8358 +#define OCFS2_IUNLINK_FL (0x08000000) /* Immutable unlink */
8360 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
8361 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
8362 +#define OCFS2_FL_MASK (0x0F0100FF)
8365 * Extent record flags (e_node.leaf.flags)
8366 diff -Nurp linux-2.6.22.15/fs/ocfs2/ocfs2.h linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/ocfs2.h
8367 --- linux-2.6.22.15/fs/ocfs2/ocfs2.h 2007-07-21 18:00:18.000000000 -0400
8368 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/ocfs2.h 2007-12-09 06:44:21.000000000 -0500
8369 @@ -170,6 +170,7 @@ enum ocfs2_mount_options
8370 OCFS2_MOUNT_NOINTR = 1 << 2, /* Don't catch signals */
8371 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
8372 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
8373 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
8376 #define OCFS2_OSB_SOFT_RO 0x0001
8377 diff -Nurp linux-2.6.22.15/fs/ocfs2/super.c linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/super.c
8378 --- linux-2.6.22.15/fs/ocfs2/super.c 2007-07-21 18:00:18.000000000 -0400
8379 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/ocfs2/super.c 2007-12-09 06:44:21.000000000 -0500
8380 @@ -140,6 +140,7 @@ enum {
8384 + Opt_tag, Opt_notag, Opt_tagid,
8388 @@ -154,6 +155,9 @@ static match_table_t tokens = {
8389 {Opt_data_ordered, "data=ordered"},
8390 {Opt_data_writeback, "data=writeback"},
8391 {Opt_atime_quantum, "atime_quantum=%u"},
8393 + {Opt_notag, "notag"},
8394 + {Opt_tagid, "tagid=%u"},
8398 @@ -362,6 +366,13 @@ static int ocfs2_remount(struct super_bl
8402 + if ((parsed_options & OCFS2_MOUNT_TAGGED) &&
8403 + !(sb->s_flags & MS_TAGGED)) {
8405 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
8409 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
8410 (parsed_options & OCFS2_MOUNT_HB_LOCAL)) {
8412 @@ -654,6 +665,9 @@ static int ocfs2_fill_super(struct super
8414 ocfs2_complete_mount_recovery(osb);
8416 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
8417 + sb->s_flags |= MS_TAGGED;
8419 if (ocfs2_mount_local(osb))
8420 snprintf(nodestr, sizeof(nodestr), "local");
8422 @@ -782,6 +796,20 @@ static int ocfs2_parse_options(struct su
8424 osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
8426 +#ifndef CONFIG_TAGGING_NONE
8428 + *mount_opt |= OCFS2_MOUNT_TAGGED;
8431 + *mount_opt &= ~OCFS2_MOUNT_TAGGED;
8434 +#ifdef CONFIG_PROPAGATE
8437 + *mount_opt |= OCFS2_MOUNT_TAGGED;
8442 "Unrecognized mount option \"%s\" "
8443 diff -Nurp linux-2.6.22.15/fs/open.c linux-2.6.22.15-vs2.3.0.29.1/fs/open.c
8444 --- linux-2.6.22.15/fs/open.c 2007-07-21 18:00:18.000000000 -0400
8445 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/open.c 2007-12-09 06:44:21.000000000 -0500
8447 #include <linux/syscalls.h>
8448 #include <linux/rcupdate.h>
8449 #include <linux/audit.h>
8450 +#include <linux/vs_base.h>
8451 +#include <linux/vs_limit.h>
8452 +#include <linux/vs_dlimit.h>
8453 +#include <linux/vs_tag.h>
8454 +#include <linux/vs_cowbl.h>
8456 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
8458 int retval = -ENODEV;
8461 + struct super_block *sb = dentry->d_sb;
8464 - if (dentry->d_sb->s_op->statfs) {
8465 + if (sb->s_op->statfs) {
8466 memset(buf, 0, sizeof(*buf));
8467 retval = security_sb_statfs(dentry);
8470 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
8471 + retval = sb->s_op->statfs(dentry, buf);
8472 if (retval == 0 && buf->f_frsize == 0)
8473 buf->f_frsize = buf->f_bsize;
8475 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
8476 + vx_vsi_statfs(sb, buf);
8480 @@ -248,7 +257,7 @@ static long do_sys_truncate(const char _
8484 - if (IS_RDONLY(inode))
8485 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
8489 @@ -397,7 +406,7 @@ asmlinkage long sys_faccessat(int dfd, c
8490 special_file(nd.dentry->d_inode->i_mode))
8491 goto out_path_release;
8493 - if(IS_RDONLY(nd.dentry->d_inode))
8494 + if(IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
8498 @@ -511,7 +520,7 @@ asmlinkage long sys_fchmod(unsigned int
8499 audit_inode(NULL, inode);
8502 - if (IS_RDONLY(inode))
8503 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
8506 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8507 @@ -541,11 +550,11 @@ asmlinkage long sys_fchmodat(int dfd, co
8508 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
8511 - inode = nd.dentry->d_inode;
8514 - if (IS_RDONLY(inode))
8515 + error = cow_check_and_break(&nd);
8518 + inode = nd.dentry->d_inode;
8521 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8522 @@ -570,7 +579,8 @@ asmlinkage long sys_chmod(const char __u
8523 return sys_fchmodat(AT_FDCWD, filename, mode);
8526 -static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
8527 +static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
8528 + uid_t user, gid_t group)
8530 struct inode * inode;
8532 @@ -582,7 +592,7 @@ static int chown_common(struct dentry *
8536 - if (IS_RDONLY(inode))
8537 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
8540 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8541 @@ -590,11 +600,11 @@ static int chown_common(struct dentry *
8542 newattrs.ia_valid = ATTR_CTIME;
8543 if (user != (uid_t) -1) {
8544 newattrs.ia_valid |= ATTR_UID;
8545 - newattrs.ia_uid = user;
8546 + newattrs.ia_uid = dx_map_uid(user);
8548 if (group != (gid_t) -1) {
8549 newattrs.ia_valid |= ATTR_GID;
8550 - newattrs.ia_gid = group;
8551 + newattrs.ia_gid = dx_map_gid(group);
8553 if (!S_ISDIR(inode->i_mode))
8554 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
8555 @@ -613,7 +623,11 @@ asmlinkage long sys_chown(const char __u
8556 error = user_path_walk(filename, &nd);
8559 - error = chown_common(nd.dentry, user, group);
8560 +#ifdef CONFIG_VSERVER_COWBL
8561 + error = cow_check_and_break(&nd);
8564 + error = chown_common(nd.dentry, nd.mnt, user, group);
8568 @@ -633,7 +647,11 @@ asmlinkage long sys_fchownat(int dfd, co
8569 error = __user_walk_fd(dfd, filename, follow, &nd);
8572 - error = chown_common(nd.dentry, user, group);
8573 +#ifdef CONFIG_VSERVER_COWBL
8574 + error = cow_check_and_break(&nd);
8577 + error = chown_common(nd.dentry, nd.mnt, user, group);
8581 @@ -647,7 +665,11 @@ asmlinkage long sys_lchown(const char __
8582 error = user_path_walk_link(filename, &nd);
8585 - error = chown_common(nd.dentry, user, group);
8586 +#ifdef CONFIG_VSERVER_COWBL
8587 + error = cow_check_and_break(&nd);
8590 + error = chown_common(nd.dentry, nd.mnt, user, group);
8594 @@ -666,7 +688,7 @@ asmlinkage long sys_fchown(unsigned int
8596 dentry = file->f_path.dentry;
8597 audit_inode(NULL, dentry->d_inode);
8598 - error = chown_common(dentry, user, group);
8599 + error = chown_common(dentry, file->f_vfsmnt, user, group);
8603 @@ -893,6 +915,7 @@ repeat:
8604 FD_SET(fd, fdt->open_fds);
8605 FD_CLR(fd, fdt->close_on_exec);
8606 files->next_fd = fd + 1;
8607 + vx_openfd_inc(fd);
8610 if (fdt->fd[fd] != NULL) {
8611 @@ -915,6 +938,7 @@ static void __put_unused_fd(struct files
8612 __FD_CLR(fd, fdt->open_fds);
8613 if (fd < files->next_fd)
8614 files->next_fd = fd;
8615 + vx_openfd_dec(fd);
8618 void fastcall put_unused_fd(unsigned int fd)
8619 diff -Nurp linux-2.6.22.15/fs/proc/array.c linux-2.6.22.15-vs2.3.0.29.1/fs/proc/array.c
8620 --- linux-2.6.22.15/fs/proc/array.c 2007-07-21 18:00:18.000000000 -0400
8621 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/proc/array.c 2007-12-09 06:44:21.000000000 -0500
8623 #include <linux/cpuset.h>
8624 #include <linux/rcupdate.h>
8625 #include <linux/delayacct.h>
8626 +#include <linux/vs_context.h>
8627 +#include <linux/vs_network.h>
8629 #include <asm/uaccess.h>
8630 #include <asm/pgtable.h>
8631 @@ -134,8 +136,9 @@ static const char *task_state_array[] =
8632 "D (disk sleep)", /* 2 */
8633 "T (stopped)", /* 4 */
8634 "T (tracing stop)", /* 8 */
8635 - "Z (zombie)", /* 16 */
8636 - "X (dead)" /* 32 */
8637 + "H (on hold)", /* 16 */
8638 + "Z (zombie)", /* 32 */
8639 + "X (dead)", /* 64 */
8642 static inline const char * get_task_state(struct task_struct *tsk)
8643 @@ -144,7 +147,8 @@ static inline const char * get_task_stat
8644 TASK_INTERRUPTIBLE |
8645 TASK_UNINTERRUPTIBLE |
8650 (tsk->exit_state & (EXIT_ZOMBIE |
8652 const char **p = &task_state_array[0];
8653 @@ -161,8 +165,16 @@ static inline char * task_state(struct t
8654 struct group_info *group_info;
8656 struct fdtable *fdt = NULL;
8657 + pid_t pid, ptgid, tppid, tgid;
8660 + tgid = vx_map_tgid(p->tgid);
8661 + pid = vx_map_pid(p->pid);
8662 + ptgid = vx_map_pid(pid_alive(p) ?
8663 + rcu_dereference(p->real_parent)->tgid : 0);
8664 + tppid = vx_map_pid(pid_alive(p) && p->ptrace ?
8665 + rcu_dereference(p->parent)->pid : 0);
8667 buffer += sprintf(buffer,
8669 "SleepAVG:\t%lu%%\n"
8670 @@ -174,9 +186,7 @@ static inline char * task_state(struct t
8671 "Gid:\t%d\t%d\t%d\t%d\n",
8673 (p->sleep_avg/1024)*100/(1020000000/1024),
8675 - pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0,
8676 - pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0,
8677 + tgid, pid, (pid > 1) ? ptgid : 0, tppid,
8678 p->uid, p->euid, p->suid, p->fsuid,
8679 p->gid, p->egid, p->sgid, p->fsgid);
8681 @@ -283,12 +293,15 @@ static inline char * task_sig(struct tas
8683 static inline char *task_cap(struct task_struct *p, char *buffer)
8685 - return buffer + sprintf(buffer, "CapInh:\t%016x\n"
8686 - "CapPrm:\t%016x\n"
8687 - "CapEff:\t%016x\n",
8688 - cap_t(p->cap_inheritable),
8689 - cap_t(p->cap_permitted),
8690 - cap_t(p->cap_effective));
8691 + struct vx_info *vxi = p->vx_info;
8693 + return buffer + sprintf(buffer,
8694 + "CapInh:\t%016x\n"
8695 + "CapPrm:\t%016x\n"
8696 + "CapEff:\t%016x\n",
8697 + (unsigned)vx_info_mbcap(vxi, p->cap_inheritable),
8698 + (unsigned)vx_info_mbcap(vxi, p->cap_permitted),
8699 + (unsigned)vx_info_mbcap(vxi, p->cap_effective));
8702 int proc_pid_status(struct task_struct *task, char * buffer)
8703 @@ -306,6 +319,12 @@ int proc_pid_status(struct task_struct *
8704 buffer = task_sig(task, buffer);
8705 buffer = task_cap(task, buffer);
8706 buffer = cpuset_task_status_allowed(task, buffer);
8708 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8710 + buffer += sprintf (buffer,"VxID: %d\n", vx_task_xid(task));
8711 + buffer += sprintf (buffer,"NxID: %d\n", nx_task_nid(task));
8713 #if defined(CONFIG_S390)
8714 buffer = task_show_regs(task, buffer);
8716 @@ -320,7 +339,7 @@ static int do_task_stat(struct task_stru
8717 sigset_t sigign, sigcatch;
8720 - pid_t ppid = 0, pgid = -1, sid = -1;
8721 + pid_t pid = 0, ppid = 0, pgid = -1, sid = -1;
8722 int num_threads = 0;
8723 struct mm_struct *mm;
8724 unsigned long long start_time;
8725 @@ -382,8 +401,10 @@ static int do_task_stat(struct task_stru
8728 sid = signal_session(sig);
8729 - pgid = process_group(task);
8730 - ppid = rcu_dereference(task->real_parent)->tgid;
8731 + pid = vx_info_map_pid(task->vx_info, task->pid);
8732 + pgid = vx_info_map_pid(task->vx_info, process_group(task));
8733 + ppid = (pid > 1) ? vx_info_map_tgid(task->vx_info,
8734 + rcu_dereference(task->real_parent)->tgid) : 0;
8736 unlock_task_sighand(task, &flags);
8738 @@ -410,10 +431,21 @@ static int do_task_stat(struct task_stru
8739 /* convert nsec -> ticks */
8740 start_time = nsec_to_clock_t(start_time);
8742 + /* fixup start time for virt uptime */
8743 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8744 + unsigned long long bias =
8745 + current->vx_info->cvirt.bias_clock;
8747 + if (start_time > bias)
8748 + start_time -= bias;
8753 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %u %lu \
8754 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8755 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n",
8761 diff -Nurp linux-2.6.22.15/fs/proc/base.c linux-2.6.22.15-vs2.3.0.29.1/fs/proc/base.c
8762 --- linux-2.6.22.15/fs/proc/base.c 2007-07-21 18:00:18.000000000 -0400
8763 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/proc/base.c 2007-12-09 06:44:21.000000000 -0500
8765 #include <linux/poll.h>
8766 #include <linux/nsproxy.h>
8767 #include <linux/oom.h>
8768 +#include <linux/vs_context.h>
8769 +#include <linux/vs_network.h>
8771 #include "internal.h"
8774 @@ -1049,6 +1052,8 @@ static struct inode *proc_pid_make_inode
8775 inode->i_uid = task->euid;
8776 inode->i_gid = task->egid;
8778 + /* procfs is xid tagged */
8779 + inode->i_tag = (tag_t)vx_task_xid(task);
8780 security_task_to_inode(task, inode);
8783 @@ -1082,6 +1087,8 @@ static int pid_getattr(struct vfsmount *
8787 +static unsigned name_to_int(struct dentry *dentry);
8790 * Exceptional case: normally we are not allowed to unhash a busy
8791 * directory. In this case, however, we can do it - no aliasing problems
8792 @@ -1102,6 +1109,12 @@ static int pid_revalidate(struct dentry
8793 struct inode *inode = dentry->d_inode;
8794 struct task_struct *task = get_proc_task(inode);
8796 + unsigned pid = name_to_int(dentry);
8797 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
8798 + put_task_struct(task);
8802 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
8803 task_dumpable(task)) {
8804 inode->i_uid = task->euid;
8805 @@ -1115,6 +1128,7 @@ static int pid_revalidate(struct dentry
8806 put_task_struct(task);
8813 @@ -1595,6 +1609,13 @@ static struct dentry *proc_pident_lookup
8817 + /* TODO: maybe we can come up with a generic approach? */
8818 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8819 + (dentry->d_name.len == 5) &&
8820 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8821 + !memcmp(dentry->d_name.name, "ninfo", 5)))
8825 * Yes, it does not scale. And it should not. Don't add
8826 * new entries into /proc/<tgid>/ without very good reasons.
8827 @@ -1790,14 +1811,14 @@ static int proc_self_readlink(struct den
8830 char tmp[PROC_NUMBUF];
8831 - sprintf(tmp, "%d", current->tgid);
8832 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8833 return vfs_readlink(dentry,buffer,buflen,tmp);
8836 static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
8838 char tmp[PROC_NUMBUF];
8839 - sprintf(tmp, "%d", current->tgid);
8840 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8841 return ERR_PTR(vfs_follow_link(nd,tmp));
8844 @@ -1891,7 +1912,7 @@ out_iput:
8845 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8847 struct dentry *error;
8848 - struct task_struct *task = get_proc_task(dir);
8849 + struct task_struct *task = get_proc_task_real(dir);
8850 const struct pid_entry *p, *last;
8852 error = ERR_PTR(-ENOENT);
8853 @@ -1956,6 +1977,9 @@ static int proc_pid_io_accounting(struct
8854 static const struct file_operations proc_task_operations;
8855 static const struct inode_operations proc_task_inode_operations;
8857 +extern int proc_pid_vx_info(struct task_struct *, char *);
8858 +extern int proc_pid_nx_info(struct task_struct *, char *);
8860 static const struct pid_entry tgid_base_stuff[] = {
8861 DIR("task", S_IRUGO|S_IXUGO, task),
8862 DIR("fd", S_IRUSR|S_IXUSR, fd),
8863 @@ -1995,6 +2019,8 @@ static const struct pid_entry tgid_base_
8864 #ifdef CONFIG_CPUSETS
8865 REG("cpuset", S_IRUGO, cpuset),
8867 + INF("vinfo", S_IRUGO, pid_vx_info),
8868 + INF("ninfo", S_IRUGO, pid_nx_info),
8869 INF("oom_score", S_IRUGO, oom_score),
8870 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
8871 #ifdef CONFIG_AUDITSYSCALL
8872 @@ -2141,9 +2167,11 @@ struct dentry *proc_pid_lookup(struct in
8873 tgid = name_to_int(dentry);
8876 + if (vx_current_initpid(tgid))
8880 - task = find_task_by_pid(tgid);
8881 + task = vx_find_proc_task_by_pid(tgid);
8883 get_task_struct(task);
8885 @@ -2198,7 +2226,7 @@ static int proc_pid_fill_cache(struct fi
8886 struct task_struct *task, int tgid)
8888 char name[PROC_NUMBUF];
8889 - int len = snprintf(name, sizeof(name), "%d", tgid);
8890 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(tgid));
8891 return proc_fill_cache(filp, dirent, filldir, name, len,
8892 proc_pid_instantiate, task, NULL);
8894 @@ -2207,7 +2235,7 @@ static int proc_pid_fill_cache(struct fi
8895 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8897 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8898 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8899 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8900 struct task_struct *task;
8903 @@ -2226,6 +2254,8 @@ int proc_pid_readdir(struct file * filp,
8904 put_task_struct(task), task = next_tgid(tgid + 1)) {
8906 filp->f_pos = tgid + TGID_OFFSET;
8907 + if (!vx_proc_task_visible(task))
8909 if (proc_pid_fill_cache(filp, dirent, filldir, task, tgid) < 0) {
8910 put_task_struct(task);
8912 @@ -2352,9 +2382,11 @@ static struct dentry *proc_task_lookup(s
8913 tid = name_to_int(dentry);
8916 + if (vx_current_initpid(tid))
8920 - task = find_task_by_pid(tid);
8921 + task = vx_find_proc_task_by_pid(tid);
8923 get_task_struct(task);
8925 @@ -2499,7 +2531,7 @@ static int proc_task_readdir(struct file
8926 for (task = first_tid(leader, tid, pos - 2);
8928 task = next_tid(task), pos++) {
8930 + tid = vx_map_pid(task->pid);
8931 if (proc_task_fill_cache(filp, dirent, filldir, task, tid) < 0) {
8932 /* returning this tgid failed, save it as the first
8933 * pid for the next readir call */
8934 diff -Nurp linux-2.6.22.15/fs/proc/generic.c linux-2.6.22.15-vs2.3.0.29.1/fs/proc/generic.c
8935 --- linux-2.6.22.15/fs/proc/generic.c 2007-07-21 18:00:18.000000000 -0400
8936 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/proc/generic.c 2007-12-09 06:44:21.000000000 -0500
8938 #include <linux/namei.h>
8939 #include <linux/bitops.h>
8940 #include <linux/spinlock.h>
8941 +#include <linux/vserver/inode.h>
8942 #include <asm/uaccess.h>
8944 #include "internal.h"
8945 @@ -395,6 +396,8 @@ struct dentry *proc_lookup(struct inode
8946 for (de = de->subdir; de ; de = de->next) {
8947 if (de->namelen != dentry->d_name.len)
8949 + if (!vx_hide_check(0, de->vx_flags))
8951 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8952 unsigned int ino = de->low_ino;
8954 @@ -402,6 +405,8 @@ struct dentry *proc_lookup(struct inode
8955 spin_unlock(&proc_subdir_lock);
8957 inode = proc_get_inode(dir->i_sb, ino, de);
8958 + /* generic proc entries belong to the host */
8960 spin_lock(&proc_subdir_lock);
8963 @@ -482,6 +487,8 @@ int proc_readdir(struct file * filp,
8965 /* filldir passes info to user space */
8967 + if (!vx_hide_check(0, de->vx_flags))
8969 spin_unlock(&proc_subdir_lock);
8970 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8971 de->low_ino, de->mode >> 12) < 0) {
8972 @@ -489,6 +496,7 @@ int proc_readdir(struct file * filp,
8975 spin_lock(&proc_subdir_lock);
8980 @@ -613,6 +621,7 @@ static struct proc_dir_entry *proc_creat
8984 + ent->vx_flags = IATTR_PROC_DEFAULT;
8988 @@ -633,7 +642,8 @@ struct proc_dir_entry *proc_symlink(cons
8994 + ent->vx_flags = IATTR_PROC_SYMLINK;
8998 diff -Nurp linux-2.6.22.15/fs/proc/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/proc/inode.c
8999 --- linux-2.6.22.15/fs/proc/inode.c 2007-07-21 18:00:18.000000000 -0400
9000 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/proc/inode.c 2007-12-09 06:44:21.000000000 -0500
9001 @@ -160,6 +160,8 @@ struct inode *proc_get_inode(struct supe
9002 inode->i_uid = de->uid;
9003 inode->i_gid = de->gid;
9006 + PROC_I(inode)->vx_flags = de->vx_flags;
9008 inode->i_size = de->size;
9010 diff -Nurp linux-2.6.22.15/fs/proc/internal.h linux-2.6.22.15-vs2.3.0.29.1/fs/proc/internal.h
9011 --- linux-2.6.22.15/fs/proc/internal.h 2007-07-21 18:00:18.000000000 -0400
9012 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/proc/internal.h 2007-12-09 06:44:21.000000000 -0500
9016 #include <linux/proc_fs.h>
9017 +#include <linux/vs_pid.h>
9019 #ifdef CONFIG_PROC_SYSCTL
9020 extern int proc_sys_init(void);
9021 @@ -64,11 +65,16 @@ static inline struct pid *proc_pid(struc
9022 return PROC_I(inode)->pid;
9025 -static inline struct task_struct *get_proc_task(struct inode *inode)
9026 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
9028 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
9031 +static inline struct task_struct *get_proc_task(struct inode *inode)
9033 + return vx_get_proc_task(inode, proc_pid(inode));
9036 static inline int proc_fd(struct inode *inode)
9038 return PROC_I(inode)->fd;
9039 diff -Nurp linux-2.6.22.15/fs/proc/proc_misc.c linux-2.6.22.15-vs2.3.0.29.1/fs/proc/proc_misc.c
9040 --- linux-2.6.22.15/fs/proc/proc_misc.c 2007-07-21 18:00:18.000000000 -0400
9041 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/proc/proc_misc.c 2007-12-09 06:44:21.000000000 -0500
9043 #include <asm/div64.h>
9044 #include "internal.h"
9046 +#include <linux/vs_cvirt.h>
9048 #define LOAD_INT(x) ((x) >> FSHIFT)
9049 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
9051 @@ -82,17 +84,32 @@ static int proc_calc_metrics(char *page,
9052 static int loadavg_read_proc(char *page, char **start, off_t off,
9053 int count, int *eof, void *data)
9055 + unsigned int running, threads;
9059 - a = avenrun[0] + (FIXED_1/200);
9060 - b = avenrun[1] + (FIXED_1/200);
9061 - c = avenrun[2] + (FIXED_1/200);
9062 - len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
9063 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
9064 + struct vx_info *vxi = current->vx_info;
9066 + a = vxi->cvirt.load[0] + (FIXED_1/200);
9067 + b = vxi->cvirt.load[1] + (FIXED_1/200);
9068 + c = vxi->cvirt.load[2] + (FIXED_1/200);
9070 + running = atomic_read(&vxi->cvirt.nr_running);
9071 + threads = atomic_read(&vxi->cvirt.nr_threads);
9073 + a = avenrun[0] + (FIXED_1/200);
9074 + b = avenrun[1] + (FIXED_1/200);
9075 + c = avenrun[2] + (FIXED_1/200);
9077 + running = nr_running();
9078 + threads = nr_threads;
9080 + len = sprintf(page,"%d.%02d %d.%02d %d.%02d %d/%d %d\n",
9081 LOAD_INT(a), LOAD_FRAC(a),
9082 LOAD_INT(b), LOAD_FRAC(b),
9083 LOAD_INT(c), LOAD_FRAC(c),
9084 - nr_running(), nr_threads, current->nsproxy->pid_ns->last_pid);
9085 + running, threads, current->nsproxy->pid_ns->last_pid);
9086 return proc_calc_metrics(page, start, off, count, eof, len);
9089 @@ -106,6 +123,9 @@ static int uptime_read_proc(char *page,
9091 do_posix_clock_monotonic_gettime(&uptime);
9092 cputime_to_timespec(idletime, &idle);
9093 + if (vx_flags(VXF_VIRT_UPTIME, 0))
9094 + vx_vsi_uptime(&uptime, &idle);
9096 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
9097 (unsigned long) uptime.tv_sec,
9098 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
9099 @@ -137,7 +157,7 @@ static int meminfo_read_proc(char *page,
9101 cached = global_page_state(NR_FILE_PAGES) -
9102 total_swapcache_pages - i.bufferram;
9104 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
9107 get_vmalloc_info(&vmi);
9108 diff -Nurp linux-2.6.22.15/fs/proc/root.c linux-2.6.22.15-vs2.3.0.29.1/fs/proc/root.c
9109 --- linux-2.6.22.15/fs/proc/root.c 2007-07-21 17:58:48.000000000 -0400
9110 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/proc/root.c 2007-12-09 06:44:21.000000000 -0500
9112 #include "internal.h"
9114 struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
9115 +struct proc_dir_entry *proc_virtual;
9117 +extern void proc_vx_init(void);
9119 static int proc_get_sb(struct file_system_type *fs_type,
9120 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
9121 @@ -79,6 +82,7 @@ void __init proc_root_init(void)
9122 proc_device_tree_init();
9124 proc_bus = proc_mkdir("bus", NULL);
9129 diff -Nurp linux-2.6.22.15/fs/quota.c linux-2.6.22.15-vs2.3.0.29.1/fs/quota.c
9130 --- linux-2.6.22.15/fs/quota.c 2007-07-21 18:00:18.000000000 -0400
9131 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/quota.c 2007-12-09 06:44:21.000000000 -0500
9133 #include <linux/buffer_head.h>
9134 #include <linux/capability.h>
9135 #include <linux/quotaops.h>
9136 +#include <linux/vs_context.h>
9138 /* Check validity of generic quotactl commands */
9139 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
9140 @@ -80,11 +81,11 @@ static int generic_quotactl_valid(struct
9141 if (cmd == Q_GETQUOTA) {
9142 if (((type == USRQUOTA && current->euid != id) ||
9143 (type == GRPQUOTA && !in_egroup_p(id))) &&
9144 - !capable(CAP_SYS_ADMIN))
9145 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9148 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
9149 - if (!capable(CAP_SYS_ADMIN))
9150 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9154 @@ -131,10 +132,10 @@ static int xqm_quotactl_valid(struct sup
9155 if (cmd == Q_XGETQUOTA) {
9156 if (((type == XQM_USRQUOTA && current->euid != id) ||
9157 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
9158 - !capable(CAP_SYS_ADMIN))
9159 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9161 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
9162 - if (!capable(CAP_SYS_ADMIN))
9163 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9167 @@ -327,6 +328,46 @@ static int do_quotactl(struct super_bloc
9171 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
9173 +#include <linux/vroot.h>
9174 +#include <linux/major.h>
9175 +#include <linux/module.h>
9176 +#include <linux/kallsyms.h>
9177 +#include <linux/vserver/debug.h>
9179 +static vroot_grb_func *vroot_get_real_bdev = NULL;
9181 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
9183 +int register_vroot_grb(vroot_grb_func *func) {
9186 + spin_lock(&vroot_grb_lock);
9187 + if (!vroot_get_real_bdev) {
9188 + vroot_get_real_bdev = func;
9191 + spin_unlock(&vroot_grb_lock);
9194 +EXPORT_SYMBOL(register_vroot_grb);
9196 +int unregister_vroot_grb(vroot_grb_func *func) {
9197 + int ret = -EINVAL;
9199 + spin_lock(&vroot_grb_lock);
9200 + if (vroot_get_real_bdev) {
9201 + vroot_get_real_bdev = NULL;
9204 + spin_unlock(&vroot_grb_lock);
9207 +EXPORT_SYMBOL(unregister_vroot_grb);
9212 * look up a superblock on which quota ops will be performed
9213 * - use the name of a block device to find the superblock thereon
9214 @@ -344,6 +385,22 @@ static inline struct super_block *quotac
9217 return ERR_PTR(PTR_ERR(bdev));
9218 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
9219 + if (bdev && bdev->bd_inode &&
9220 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
9221 + struct block_device *bdnew = (void *)-EINVAL;
9223 + if (vroot_get_real_bdev)
9224 + bdnew = vroot_get_real_bdev(bdev);
9226 + vxdprintk(VXD_CBIT(misc, 0),
9227 + "vroot_get_real_bdev not set");
9229 + if (IS_ERR(bdnew))
9230 + return ERR_PTR(PTR_ERR(bdnew));
9234 sb = get_super(bdev);
9237 diff -Nurp linux-2.6.22.15/fs/reiserfs/bitmap.c linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/bitmap.c
9238 --- linux-2.6.22.15/fs/reiserfs/bitmap.c 2007-05-04 09:58:22.000000000 -0400
9239 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/bitmap.c 2007-12-09 06:44:21.000000000 -0500
9241 #include <linux/reiserfs_fs_sb.h>
9242 #include <linux/reiserfs_fs_i.h>
9243 #include <linux/quotaops.h>
9244 +#include <linux/vs_dlimit.h>
9246 #define PREALLOCATION_SIZE 9
9248 @@ -425,8 +426,10 @@ static void _reiserfs_free_block(struct
9249 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
9251 journal_mark_dirty(th, s, sbh);
9252 - if (for_unformatted)
9253 + if (for_unformatted) {
9254 + DLIMIT_FREE_BLOCK(inode, 1);
9255 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
9259 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
9260 @@ -1034,6 +1037,7 @@ static inline int blocknrs_and_prealloc_
9261 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
9263 int nr_allocated = 0;
9266 determine_prealloc_size(hint);
9267 if (!hint->formatted_node) {
9268 @@ -1043,19 +1047,30 @@ static inline int blocknrs_and_prealloc_
9269 "reiserquota: allocating %d blocks id=%u",
9270 amount_needed, hint->inode->i_uid);
9273 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
9274 - if (quota_ret) /* Quota exceeded? */
9275 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
9278 return QUOTA_EXCEEDED;
9279 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
9280 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
9282 + return NO_DISK_SPACE;
9285 if (hint->preallocate && hint->prealloc_size) {
9286 #ifdef REISERQUOTA_DEBUG
9287 reiserfs_debug(s, REISERFS_DEBUG_CODE,
9288 "reiserquota: allocating (prealloc) %d blocks id=%u",
9289 hint->prealloc_size, hint->inode->i_uid);
9292 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
9293 - hint->prealloc_size);
9294 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
9295 + hint->prealloc_size);
9297 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
9298 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
9299 + hint->prealloc_size);
9303 hint->preallocate = hint->prealloc_size = 0;
9305 @@ -1087,7 +1102,10 @@ static inline int blocknrs_and_prealloc_
9307 hint->inode->i_uid);
9309 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
9310 + /* Free not allocated blocks */
9311 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
9312 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
9313 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
9315 while (nr_allocated--)
9316 reiserfs_free_block(hint->th, hint->inode,
9317 @@ -1118,10 +1136,10 @@ static inline int blocknrs_and_prealloc_
9318 REISERFS_I(hint->inode)->i_prealloc_count,
9319 hint->inode->i_uid);
9321 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
9322 - hint->prealloc_size - nr_allocated -
9323 - REISERFS_I(hint->inode)->
9324 - i_prealloc_count);
9325 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
9326 + REISERFS_I(hint->inode)->i_prealloc_count;
9327 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
9328 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
9332 diff -Nurp linux-2.6.22.15/fs/reiserfs/file.c linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/file.c
9333 --- linux-2.6.22.15/fs/reiserfs/file.c 2007-07-21 18:00:18.000000000 -0400
9334 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/file.c 2007-12-09 06:44:21.000000000 -0500
9335 @@ -1546,4 +1546,5 @@ const struct inode_operations reiserfs_f
9336 .listxattr = reiserfs_listxattr,
9337 .removexattr = reiserfs_removexattr,
9338 .permission = reiserfs_permission,
9339 + .sync_flags = reiserfs_sync_flags,
9341 diff -Nurp linux-2.6.22.15/fs/reiserfs/inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/inode.c
9342 --- linux-2.6.22.15/fs/reiserfs/inode.c 2007-07-21 18:00:18.000000000 -0400
9343 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/inode.c 2007-12-09 06:44:21.000000000 -0500
9345 #include <linux/mpage.h>
9346 #include <linux/writeback.h>
9347 #include <linux/quotaops.h>
9348 +#include <linux/vs_dlimit.h>
9349 +#include <linux/vs_tag.h>
9351 static int reiserfs_commit_write(struct file *f, struct page *page,
9352 unsigned from, unsigned to);
9353 @@ -50,6 +52,7 @@ void reiserfs_delete_inode(struct inode
9354 * stat data deletion */
9356 DQUOT_FREE_INODE(inode);
9357 + DLIMIT_FREE_INODE(inode);
9359 if (journal_end(&th, inode->i_sb, jbegin_count))
9361 @@ -1112,6 +1115,8 @@ static void init_inode(struct inode *ino
9362 struct buffer_head *bh;
9363 struct item_head *ih;
9367 //int version = ITEM_VERSION_1;
9369 bh = PATH_PLAST_BUFFER(path);
9370 @@ -1135,12 +1140,13 @@ static void init_inode(struct inode *ino
9371 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
9372 unsigned long blocks;
9374 + uid = sd_v1_uid(sd);
9375 + gid = sd_v1_gid(sd);
9377 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
9378 set_inode_sd_version(inode, STAT_DATA_V1);
9379 inode->i_mode = sd_v1_mode(sd);
9380 inode->i_nlink = sd_v1_nlink(sd);
9381 - inode->i_uid = sd_v1_uid(sd);
9382 - inode->i_gid = sd_v1_gid(sd);
9383 inode->i_size = sd_v1_size(sd);
9384 inode->i_atime.tv_sec = sd_v1_atime(sd);
9385 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
9386 @@ -1182,11 +1188,12 @@ static void init_inode(struct inode *ino
9387 // (directories and symlinks)
9388 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
9390 + uid = sd_v2_uid(sd);
9391 + gid = sd_v2_gid(sd);
9393 inode->i_mode = sd_v2_mode(sd);
9394 inode->i_nlink = sd_v2_nlink(sd);
9395 - inode->i_uid = sd_v2_uid(sd);
9396 inode->i_size = sd_v2_size(sd);
9397 - inode->i_gid = sd_v2_gid(sd);
9398 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
9399 inode->i_atime.tv_sec = sd_v2_atime(sd);
9400 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
9401 @@ -1216,6 +1223,10 @@ static void init_inode(struct inode *ino
9402 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
9405 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
9406 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
9407 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
9410 if (S_ISREG(inode->i_mode)) {
9411 inode->i_op = &reiserfs_file_inode_operations;
9412 @@ -1238,13 +1249,15 @@ static void init_inode(struct inode *ino
9413 static void inode2sd(void *sd, struct inode *inode, loff_t size)
9415 struct stat_data *sd_v2 = (struct stat_data *)sd;
9416 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
9417 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
9420 + set_sd_v2_uid(sd_v2, uid);
9421 + set_sd_v2_gid(sd_v2, gid);
9422 set_sd_v2_mode(sd_v2, inode->i_mode);
9423 set_sd_v2_nlink(sd_v2, inode->i_nlink);
9424 - set_sd_v2_uid(sd_v2, inode->i_uid);
9425 set_sd_v2_size(sd_v2, size);
9426 - set_sd_v2_gid(sd_v2, inode->i_gid);
9427 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
9428 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
9429 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
9430 @@ -1775,6 +1788,10 @@ int reiserfs_new_inode(struct reiserfs_t
9432 BUG_ON(!th->t_trans_id);
9434 + if (DLIMIT_ALLOC_INODE(inode)) {
9436 + goto out_bad_dlimit;
9438 if (DQUOT_ALLOC_INODE(inode)) {
9441 @@ -1960,6 +1977,9 @@ int reiserfs_new_inode(struct reiserfs_t
9442 DQUOT_FREE_INODE(inode);
9445 + DLIMIT_FREE_INODE(inode);
9448 journal_end(th, th->t_super, th->t_blocks_allocated);
9449 /* Drop can be outside and it needs more credits so it's better to have it outside */
9451 @@ -2690,6 +2710,14 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
9452 inode->i_flags |= S_IMMUTABLE;
9454 inode->i_flags &= ~S_IMMUTABLE;
9455 + if (sd_attrs & REISERFS_IUNLINK_FL)
9456 + inode->i_flags |= S_IUNLINK;
9458 + inode->i_flags &= ~S_IUNLINK;
9459 + if (sd_attrs & REISERFS_BARRIER_FL)
9460 + inode->i_flags |= S_BARRIER;
9462 + inode->i_flags &= ~S_BARRIER;
9463 if (sd_attrs & REISERFS_APPEND_FL)
9464 inode->i_flags |= S_APPEND;
9466 @@ -2712,6 +2740,14 @@ void i_attrs_to_sd_attrs(struct inode *i
9467 *sd_attrs |= REISERFS_IMMUTABLE_FL;
9469 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
9470 + if (inode->i_flags & S_IUNLINK)
9471 + *sd_attrs |= REISERFS_IUNLINK_FL;
9473 + *sd_attrs &= ~REISERFS_IUNLINK_FL;
9474 + if (inode->i_flags & S_BARRIER)
9475 + *sd_attrs |= REISERFS_BARRIER_FL;
9477 + *sd_attrs &= ~REISERFS_BARRIER_FL;
9478 if (inode->i_flags & S_SYNC)
9479 *sd_attrs |= REISERFS_SYNC_FL;
9481 @@ -2891,6 +2927,22 @@ static ssize_t reiserfs_direct_IO(int rw
9482 reiserfs_get_blocks_direct_io, NULL);
9485 +int reiserfs_sync_flags(struct inode *inode)
9487 + u16 oldflags, newflags;
9489 + oldflags = REISERFS_I(inode)->i_attrs;
9490 + newflags = oldflags;
9491 + i_attrs_to_sd_attrs(inode, &newflags);
9493 + if (oldflags ^ newflags) {
9494 + REISERFS_I(inode)->i_attrs = newflags;
9495 + inode->i_ctime = CURRENT_TIME_SEC;
9496 + mark_inode_dirty(inode);
9501 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
9503 struct inode *inode = dentry->d_inode;
9504 @@ -2940,9 +2992,11 @@ int reiserfs_setattr(struct dentry *dent
9507 error = inode_change_ok(inode, attr);
9510 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
9511 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
9512 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
9513 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
9514 error = reiserfs_chown_xattrs(inode, attr);
9517 @@ -2972,6 +3026,9 @@ int reiserfs_setattr(struct dentry *dent
9518 inode->i_uid = attr->ia_uid;
9519 if (attr->ia_valid & ATTR_GID)
9520 inode->i_gid = attr->ia_gid;
9521 + if ((attr->ia_valid & ATTR_TAG) &&
9523 + inode->i_tag = attr->ia_tag;
9524 mark_inode_dirty(inode);
9526 journal_end(&th, inode->i_sb, jbegin_count);
9527 diff -Nurp linux-2.6.22.15/fs/reiserfs/ioctl.c linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/ioctl.c
9528 --- linux-2.6.22.15/fs/reiserfs/ioctl.c 2007-05-04 09:58:22.000000000 -0400
9529 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/ioctl.c 2007-12-09 06:44:21.000000000 -0500
9531 #include <linux/fs.h>
9532 #include <linux/reiserfs_fs.h>
9533 #include <linux/time.h>
9534 +#include <linux/mount.h>
9535 #include <asm/uaccess.h>
9536 #include <linux/pagemap.h>
9537 #include <linux/smp_lock.h>
9538 @@ -24,7 +25,7 @@ static int reiserfs_unpack(struct inode
9539 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
9542 - unsigned int flags;
9543 + unsigned int flags, oldflags;
9546 case REISERFS_IOC_UNPACK:
9547 @@ -43,12 +44,14 @@ int reiserfs_ioctl(struct inode *inode,
9549 flags = REISERFS_I(inode)->i_attrs;
9550 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
9551 + flags &= REISERFS_FL_USER_VISIBLE;
9552 return put_user(flags, (int __user *)arg);
9553 case REISERFS_IOC_SETFLAGS:{
9554 if (!reiserfs_attrs(inode->i_sb))
9557 - if (IS_RDONLY(inode))
9558 + if (IS_RDONLY(inode) ||
9559 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9562 if ((current->fsuid != inode->i_uid)
9563 @@ -58,10 +61,12 @@ int reiserfs_ioctl(struct inode *inode,
9564 if (get_user(flags, (int __user *)arg))
9567 - if (((flags ^ REISERFS_I(inode)->
9568 - i_attrs) & (REISERFS_IMMUTABLE_FL |
9569 - REISERFS_APPEND_FL))
9570 - && !capable(CAP_LINUX_IMMUTABLE))
9571 + oldflags = REISERFS_I(inode) -> i_attrs;
9572 + if (((oldflags & REISERFS_IMMUTABLE_FL) ||
9573 + ((flags ^ oldflags) &
9574 + (REISERFS_IMMUTABLE_FL | REISERFS_IUNLINK_FL |
9575 + REISERFS_APPEND_FL))) &&
9576 + !capable(CAP_LINUX_IMMUTABLE))
9579 if ((flags & REISERFS_NOTAIL_FL) &&
9580 @@ -72,6 +77,9 @@ int reiserfs_ioctl(struct inode *inode,
9585 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
9586 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
9587 sd_attrs_to_i_attrs(flags, inode);
9588 REISERFS_I(inode)->i_attrs = flags;
9589 inode->i_ctime = CURRENT_TIME_SEC;
9590 @@ -83,7 +91,8 @@ int reiserfs_ioctl(struct inode *inode,
9591 case REISERFS_IOC_SETVERSION:
9592 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
9594 - if (IS_RDONLY(inode))
9595 + if (IS_RDONLY(inode) ||
9596 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9598 if (get_user(inode->i_generation, (int __user *)arg))
9600 diff -Nurp linux-2.6.22.15/fs/reiserfs/namei.c linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/namei.c
9601 --- linux-2.6.22.15/fs/reiserfs/namei.c 2007-07-21 18:00:18.000000000 -0400
9602 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/namei.c 2007-12-09 06:44:21.000000000 -0500
9604 #include <linux/reiserfs_acl.h>
9605 #include <linux/reiserfs_xattr.h>
9606 #include <linux/quotaops.h>
9607 +#include <linux/vs_tag.h>
9609 #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; }
9610 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
9611 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
9612 reiserfs_write_unlock(dir->i_sb);
9613 return ERR_PTR(-EACCES);
9615 + dx_propagate_tag(nd, inode);
9617 /* Propogate the priv_object flag so we know we're in the priv tree */
9618 if (is_reiserfs_priv_object(dir))
9619 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
9621 inode->i_gid = current->fsgid;
9623 + inode->i_tag = dx_current_fstag(inode->i_sb);
9627 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
9628 .listxattr = reiserfs_listxattr,
9629 .removexattr = reiserfs_removexattr,
9630 .permission = reiserfs_permission,
9631 + .sync_flags = reiserfs_sync_flags,
9635 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
9636 .listxattr = reiserfs_listxattr,
9637 .removexattr = reiserfs_removexattr,
9638 .permission = reiserfs_permission,
9639 + .sync_flags = reiserfs_sync_flags,
9643 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
9644 .listxattr = reiserfs_listxattr,
9645 .removexattr = reiserfs_removexattr,
9646 .permission = reiserfs_permission,
9647 + .sync_flags = reiserfs_sync_flags,
9650 diff -Nurp linux-2.6.22.15/fs/reiserfs/stree.c linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/stree.c
9651 --- linux-2.6.22.15/fs/reiserfs/stree.c 2007-07-21 18:00:18.000000000 -0400
9652 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/stree.c 2007-12-09 06:44:21.000000000 -0500
9654 #include <linux/reiserfs_fs.h>
9655 #include <linux/buffer_head.h>
9656 #include <linux/quotaops.h>
9657 +#include <linux/vs_dlimit.h>
9659 /* Does the buffer contain a disk block which is in the tree. */
9660 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
9661 @@ -1296,6 +1297,7 @@ int reiserfs_delete_item(struct reiserfs
9662 "reiserquota delete_item(): freeing %u, id=%u type=%c",
9663 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
9665 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9666 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9668 /* Return deleted body length */
9669 @@ -1384,6 +1386,7 @@ void reiserfs_delete_solid_item(struct r
9671 DQUOT_FREE_SPACE_NODIRTY(inode,
9673 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
9677 @@ -1737,6 +1740,7 @@ int reiserfs_cut_from_item(struct reiser
9678 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
9679 quota_cut_bytes, p_s_inode->i_uid, '?');
9681 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9682 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9685 @@ -1978,6 +1982,11 @@ int reiserfs_paste_into_item(struct reis
9686 pathrelse(p_s_search_path);
9689 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
9690 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9691 + pathrelse(p_s_search_path);
9694 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
9696 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
9697 @@ -2030,6 +2039,7 @@ int reiserfs_paste_into_item(struct reis
9698 n_pasted_size, inode->i_uid,
9699 key2type(&(p_s_key->on_disk_key)));
9701 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
9702 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9705 @@ -2067,6 +2077,11 @@ int reiserfs_insert_item(struct reiserfs
9706 pathrelse(p_s_path);
9709 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
9710 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9711 + pathrelse(p_s_path);
9715 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
9716 IH_SIZE + ih_item_len(p_s_ih));
9717 @@ -2114,7 +2129,9 @@ int reiserfs_insert_item(struct reiserfs
9718 "reiserquota insert_item(): freeing %u id=%u type=%c",
9719 quota_bytes, inode->i_uid, head2type(p_s_ih));
9723 + DLIMIT_FREE_SPACE(inode, quota_bytes);
9724 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9728 diff -Nurp linux-2.6.22.15/fs/reiserfs/super.c linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/super.c
9729 --- linux-2.6.22.15/fs/reiserfs/super.c 2007-07-21 18:00:18.000000000 -0400
9730 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/super.c 2007-12-09 06:44:21.000000000 -0500
9731 @@ -882,6 +882,14 @@ static int reiserfs_parse_options(struct
9732 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9733 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9735 +#ifndef CONFIG_TAGGING_NONE
9736 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9737 + {"tag",.setmask = 1 << REISERFS_TAGGED},
9738 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
9740 +#ifdef CONFIG_PROPAGATE
9741 + {"tag",.arg_required = 'T',.values = NULL},
9743 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9744 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9745 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9746 @@ -1143,6 +1151,12 @@ static int reiserfs_remount(struct super
9750 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
9751 + !(s->s_flags & MS_TAGGED)) {
9752 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
9758 /* Add options that are safe here */
9759 @@ -1591,6 +1605,10 @@ static int reiserfs_fill_super(struct su
9763 + /* map mount option tagxid */
9764 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9765 + s->s_flags |= MS_TAGGED;
9767 rs = SB_DISK_SUPER_BLOCK(s);
9768 /* Let's do basic sanity check to verify that underlying device is not
9769 smaller than the filesystem. If the check fails then abort and scream,
9770 diff -Nurp linux-2.6.22.15/fs/reiserfs/xattr.c linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/xattr.c
9771 --- linux-2.6.22.15/fs/reiserfs/xattr.c 2007-07-21 18:00:18.000000000 -0400
9772 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/reiserfs/xattr.c 2007-12-09 06:44:21.000000000 -0500
9774 #include <linux/namei.h>
9775 #include <linux/errno.h>
9776 #include <linux/fs.h>
9777 +#include <linux/mount.h>
9778 #include <linux/file.h>
9779 #include <linux/pagemap.h>
9780 #include <linux/xattr.h>
9781 @@ -775,7 +776,7 @@ int reiserfs_delete_xattrs(struct inode
9782 if (dir->d_inode->i_nlink <= 2) {
9783 root = get_xa_root(inode->i_sb, XATTR_REPLACE);
9784 reiserfs_write_lock_xattrs(inode->i_sb);
9785 - err = vfs_rmdir(root->d_inode, dir);
9786 + err = vfs_rmdir(root->d_inode, dir, NULL);
9787 reiserfs_write_unlock_xattrs(inode->i_sb);
9790 diff -Nurp linux-2.6.22.15/fs/stat.c linux-2.6.22.15-vs2.3.0.29.1/fs/stat.c
9791 --- linux-2.6.22.15/fs/stat.c 2007-07-21 18:00:18.000000000 -0400
9792 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/stat.c 2007-12-09 06:44:21.000000000 -0500
9793 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9794 stat->nlink = inode->i_nlink;
9795 stat->uid = inode->i_uid;
9796 stat->gid = inode->i_gid;
9797 + stat->tag = inode->i_tag;
9798 stat->rdev = inode->i_rdev;
9799 stat->atime = inode->i_atime;
9800 stat->mtime = inode->i_mtime;
9801 diff -Nurp linux-2.6.22.15/fs/super.c linux-2.6.22.15-vs2.3.0.29.1/fs/super.c
9802 --- linux-2.6.22.15/fs/super.c 2007-07-21 18:00:18.000000000 -0400
9803 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/super.c 2007-12-09 06:44:21.000000000 -0500
9805 #include <linux/idr.h>
9806 #include <linux/kobject.h>
9807 #include <linux/mutex.h>
9808 +#include <linux/devpts_fs.h>
9809 +#include <linux/proc_fs.h>
9810 +#include <linux/vs_context.h>
9811 #include <asm/uaccess.h>
9814 @@ -860,12 +863,18 @@ struct vfsmount *
9815 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9817 struct vfsmount *mnt;
9818 + struct super_block *sb;
9819 char *secdata = NULL;
9823 return ERR_PTR(-ENODEV);
9826 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9827 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9831 mnt = alloc_vfsmnt(name);
9833 @@ -885,7 +894,14 @@ vfs_kern_mount(struct file_system_type *
9835 goto out_free_secdata;
9837 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
9840 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9841 + (sb->s_magic != PROC_SUPER_MAGIC) &&
9842 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
9845 + error = security_sb_kern_mount(sb, secdata);
9849 diff -Nurp linux-2.6.22.15/fs/sysfs/mount.c linux-2.6.22.15-vs2.3.0.29.1/fs/sysfs/mount.c
9850 --- linux-2.6.22.15/fs/sysfs/mount.c 2007-07-21 18:00:18.000000000 -0400
9851 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/sysfs/mount.c 2007-12-09 06:44:21.000000000 -0500
9856 -/* Random magic number */
9857 -#define SYSFS_MAGIC 0x62656572
9859 struct vfsmount *sysfs_mount;
9860 struct super_block * sysfs_sb = NULL;
9861 @@ -48,7 +46,7 @@ static int sysfs_fill_super(struct super
9863 sb->s_blocksize = PAGE_CACHE_SIZE;
9864 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9865 - sb->s_magic = SYSFS_MAGIC;
9866 + sb->s_magic = SYSFS_SUPER_MAGIC;
9867 sb->s_op = &sysfs_ops;
9868 sb->s_time_gran = 1;
9870 diff -Nurp linux-2.6.22.15/fs/utimes.c linux-2.6.22.15-vs2.3.0.29.1/fs/utimes.c
9871 --- linux-2.6.22.15/fs/utimes.c 2007-07-21 18:00:18.000000000 -0400
9872 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/utimes.c 2007-12-09 06:44:21.000000000 -0500
9874 #include <linux/sched.h>
9875 #include <linux/stat.h>
9876 #include <linux/utime.h>
9877 +#include <linux/mount.h>
9878 +#include <linux/vs_cowbl.h>
9879 #include <asm/uaccess.h>
9880 #include <asm/unistd.h>
9882 @@ -70,11 +72,13 @@ long do_utimes(int dfd, char __user *fil
9886 + error = cow_check_and_break(&nd);
9888 + goto dput_and_out;
9892 inode = dentry->d_inode;
9895 if (IS_RDONLY(inode))
9897 diff -Nurp linux-2.6.22.15/fs/xattr.c linux-2.6.22.15-vs2.3.0.29.1/fs/xattr.c
9898 --- linux-2.6.22.15/fs/xattr.c 2007-07-21 18:00:18.000000000 -0400
9899 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xattr.c 2007-12-09 06:44:21.000000000 -0500
9901 #include <linux/module.h>
9902 #include <linux/fsnotify.h>
9903 #include <linux/audit.h>
9904 +#include <linux/mount.h>
9905 #include <asm/uaccess.h>
9908 @@ -194,7 +195,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
9911 setxattr(struct dentry *d, char __user *name, void __user *value,
9912 - size_t size, int flags)
9913 + size_t size, int flags, struct vfsmount *mnt)
9916 void *kvalue = NULL;
9917 @@ -221,6 +222,9 @@ setxattr(struct dentry *d, char __user *
9921 + if (MNT_IS_RDONLY(mnt))
9924 error = vfs_setxattr(d, kname, kvalue, size, flags);
9927 @@ -236,7 +240,7 @@ sys_setxattr(char __user *path, char __u
9928 error = user_path_walk(path, &nd);
9931 - error = setxattr(nd.dentry, name, value, size, flags);
9932 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
9936 @@ -251,7 +255,7 @@ sys_lsetxattr(char __user *path, char __
9937 error = user_path_walk_link(path, &nd);
9940 - error = setxattr(nd.dentry, name, value, size, flags);
9941 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
9945 @@ -269,7 +273,7 @@ sys_fsetxattr(int fd, char __user *name,
9947 dentry = f->f_path.dentry;
9948 audit_inode(NULL, dentry->d_inode);
9949 - error = setxattr(dentry, name, value, size, flags);
9950 + error = setxattr(dentry, name, value, size, flags, f->f_vfsmnt);
9954 @@ -433,7 +437,7 @@ sys_flistxattr(int fd, char __user *list
9955 * Extended attribute REMOVE operations
9958 -removexattr(struct dentry *d, char __user *name)
9959 +removexattr(struct dentry *d, char __user *name, struct vfsmount *mnt)
9962 char kname[XATTR_NAME_MAX + 1];
9963 @@ -444,6 +448,9 @@ removexattr(struct dentry *d, char __use
9967 + if (MNT_IS_RDONLY(mnt))
9970 return vfs_removexattr(d, kname);
9973 @@ -456,7 +463,7 @@ sys_removexattr(char __user *path, char
9974 error = user_path_walk(path, &nd);
9977 - error = removexattr(nd.dentry, name);
9978 + error = removexattr(nd.dentry, name, nd.mnt);
9982 @@ -470,7 +477,7 @@ sys_lremovexattr(char __user *path, char
9983 error = user_path_walk_link(path, &nd);
9986 - error = removexattr(nd.dentry, name);
9987 + error = removexattr(nd.dentry, name, nd.mnt);
9991 @@ -487,7 +494,7 @@ sys_fremovexattr(int fd, char __user *na
9993 dentry = f->f_path.dentry;
9994 audit_inode(NULL, dentry->d_inode);
9995 - error = removexattr(dentry, name);
9996 + error = removexattr(dentry, name, f->f_vfsmnt);
10000 diff -Nurp linux-2.6.22.15/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_ioctl.c
10001 --- linux-2.6.22.15/fs/xfs/linux-2.6/xfs_ioctl.c 2007-07-21 17:58:49.000000000 -0400
10002 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_ioctl.c 2007-12-09 06:44:21.000000000 -0500
10003 @@ -1128,6 +1128,10 @@ xfs_di2lxflags(
10005 if (di_flags & XFS_DIFLAG_IMMUTABLE)
10006 flags |= FS_IMMUTABLE_FL;
10007 + if (di_flags & XFS_DIFLAG_IUNLINK)
10008 + flags |= FS_IUNLINK_FL;
10009 + if (di_flags & XFS_DIFLAG_BARRIER)
10010 + flags |= FS_BARRIER_FL;
10011 if (di_flags & XFS_DIFLAG_APPEND)
10012 flags |= FS_APPEND_FL;
10013 if (di_flags & XFS_DIFLAG_SYNC)
10014 diff -Nurp linux-2.6.22.15/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_iops.c
10015 --- linux-2.6.22.15/fs/xfs/linux-2.6/xfs_iops.c 2007-07-21 17:58:49.000000000 -0400
10016 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_iops.c 2007-12-09 06:44:21.000000000 -0500
10018 #include <linux/xattr.h>
10019 #include <linux/namei.h>
10020 #include <linux/security.h>
10021 +#include <linux/vs_tag.h>
10024 * Get a XFS inode from a given vnode.
10025 @@ -400,6 +401,7 @@ xfs_vn_lookup(
10026 d_add(dentry, NULL);
10029 + dx_propagate_tag(nd, vn_to_inode(cvp));
10031 return d_splice_alias(vn_to_inode(cvp), dentry);
10033 @@ -657,6 +659,10 @@ xfs_vn_setattr(
10037 + error = inode_change_ok(inode, attr);
10041 if (ia_valid & ATTR_UID) {
10042 vattr.va_mask |= XFS_AT_UID;
10043 vattr.va_uid = attr->ia_uid;
10044 @@ -665,6 +671,10 @@ xfs_vn_setattr(
10045 vattr.va_mask |= XFS_AT_GID;
10046 vattr.va_gid = attr->ia_gid;
10048 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode)) {
10049 + vattr.va_mask |= XFS_AT_TAG;
10050 + vattr.va_tag = attr->ia_tag;
10052 if (ia_valid & ATTR_SIZE) {
10053 vattr.va_mask |= XFS_AT_SIZE;
10054 vattr.va_size = attr->ia_size;
10055 @@ -710,6 +720,42 @@ xfs_vn_truncate(
10059 +xfs_vn_sync_flags(struct inode *inode)
10061 + unsigned int oldflags, newflags;
10064 + bhv_vattr_t vattr;
10065 + bhv_vnode_t *vp = vn_from_inode(inode);
10067 + memset(&vattr, 0, sizeof vattr);
10069 + vattr.va_mask = XFS_AT_XFLAGS;
10070 + error = bhv_vop_getattr(vp, &vattr, 0, NULL);
10074 + oldflags = vattr.va_xflags;
10075 + newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
10076 + XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
10078 + if (IS_IMMUTABLE(inode))
10079 + newflags |= XFS_XFLAG_IMMUTABLE;
10080 + if (IS_IUNLINK(inode))
10081 + newflags |= XFS_XFLAG_IUNLINK;
10082 + if (IS_BARRIER(inode))
10083 + newflags |= XFS_XFLAG_BARRIER;
10085 + if (oldflags ^ newflags) {
10086 + vattr.va_xflags = newflags;
10087 + vattr.va_mask |= XFS_AT_XFLAGS;
10088 + error = bhv_vop_setattr(vp, &vattr, flags, NULL);
10090 + vn_revalidate(vp);
10096 struct dentry *dentry,
10098 @@ -822,6 +868,7 @@ const struct inode_operations xfs_inode_
10099 .getxattr = xfs_vn_getxattr,
10100 .listxattr = xfs_vn_listxattr,
10101 .removexattr = xfs_vn_removexattr,
10102 + .sync_flags = xfs_vn_sync_flags,
10105 const struct inode_operations xfs_dir_inode_operations = {
10106 @@ -841,6 +888,7 @@ const struct inode_operations xfs_dir_in
10107 .getxattr = xfs_vn_getxattr,
10108 .listxattr = xfs_vn_listxattr,
10109 .removexattr = xfs_vn_removexattr,
10110 + .sync_flags = xfs_vn_sync_flags,
10113 const struct inode_operations xfs_symlink_inode_operations = {
10114 @@ -854,4 +902,5 @@ const struct inode_operations xfs_symlin
10115 .getxattr = xfs_vn_getxattr,
10116 .listxattr = xfs_vn_listxattr,
10117 .removexattr = xfs_vn_removexattr,
10118 + .sync_flags = xfs_vn_sync_flags,
10120 diff -Nurp linux-2.6.22.15/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_linux.h
10121 --- linux-2.6.22.15/fs/xfs/linux-2.6/xfs_linux.h 2007-07-21 17:58:49.000000000 -0400
10122 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_linux.h 2007-12-09 06:44:21.000000000 -0500
10123 @@ -129,6 +129,7 @@
10124 #define current_pid() (current->pid)
10125 #define current_fsuid(cred) (current->fsuid)
10126 #define current_fsgid(cred) (current->fsgid)
10127 +#define current_fstag(cred,vp) (dx_current_fstag(vn_to_inode(vp)->i_sb))
10128 #define current_test_flags(f) (current->flags & (f))
10129 #define current_set_flags_nested(sp, f) \
10130 (*(sp) = current->flags, current->flags |= (f))
10131 diff -Nurp linux-2.6.22.15/fs/xfs/linux-2.6/xfs_super.c linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_super.c
10132 --- linux-2.6.22.15/fs/xfs/linux-2.6/xfs_super.c 2007-07-21 18:00:18.000000000 -0400
10133 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_super.c 2007-12-09 06:44:21.000000000 -0500
10134 @@ -157,6 +157,7 @@ xfs_revalidate_inode(
10135 inode->i_nlink = ip->i_d.di_nlink;
10136 inode->i_uid = ip->i_d.di_uid;
10137 inode->i_gid = ip->i_d.di_gid;
10138 + inode->i_tag = ip->i_d.di_tag;
10140 switch (inode->i_mode & S_IFMT) {
10142 @@ -184,6 +185,14 @@ xfs_revalidate_inode(
10143 inode->i_flags |= S_IMMUTABLE;
10145 inode->i_flags &= ~S_IMMUTABLE;
10146 + if (ip->i_d.di_flags & XFS_DIFLAG_IUNLINK)
10147 + inode->i_flags |= S_IUNLINK;
10149 + inode->i_flags &= ~S_IUNLINK;
10150 + if (ip->i_d.di_flags & XFS_DIFLAG_BARRIER)
10151 + inode->i_flags |= S_BARRIER;
10153 + inode->i_flags &= ~S_BARRIER;
10154 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
10155 inode->i_flags |= S_APPEND;
10157 @@ -712,6 +721,12 @@ xfs_fs_remount(
10160 error = bhv_vfs_parseargs(vfsp, options, args, 1);
10161 + if ((args->flags2 & XFSMNT2_TAGGED) &&
10162 + !(sb->s_flags & MS_TAGGED)) {
10163 + printk("XFS: %s: tagging not permitted on remount.\n",
10168 error = bhv_vfs_mntupdate(vfsp, flags, args);
10169 kmem_free(args, sizeof(*args));
10170 diff -Nurp linux-2.6.22.15/fs/xfs/linux-2.6/xfs_vnode.c linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_vnode.c
10171 --- linux-2.6.22.15/fs/xfs/linux-2.6/xfs_vnode.c 2007-07-21 17:58:49.000000000 -0400
10172 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_vnode.c 2007-12-09 06:44:21.000000000 -0500
10173 @@ -119,6 +119,7 @@ vn_revalidate_core(
10174 inode->i_nlink = vap->va_nlink;
10175 inode->i_uid = vap->va_uid;
10176 inode->i_gid = vap->va_gid;
10177 + inode->i_tag = vap->va_tag;
10178 inode->i_blocks = vap->va_nblocks;
10179 inode->i_mtime = vap->va_mtime;
10180 inode->i_ctime = vap->va_ctime;
10181 @@ -126,6 +127,14 @@ vn_revalidate_core(
10182 inode->i_flags |= S_IMMUTABLE;
10184 inode->i_flags &= ~S_IMMUTABLE;
10185 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10186 + inode->i_flags |= S_IUNLINK;
10188 + inode->i_flags &= ~S_IUNLINK;
10189 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10190 + inode->i_flags |= S_BARRIER;
10192 + inode->i_flags &= ~S_BARRIER;
10193 if (vap->va_xflags & XFS_XFLAG_APPEND)
10194 inode->i_flags |= S_APPEND;
10196 diff -Nurp linux-2.6.22.15/fs/xfs/linux-2.6/xfs_vnode.h linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_vnode.h
10197 --- linux-2.6.22.15/fs/xfs/linux-2.6/xfs_vnode.h 2007-07-21 18:00:18.000000000 -0400
10198 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/linux-2.6/xfs_vnode.h 2007-12-09 06:44:21.000000000 -0500
10199 @@ -350,6 +350,7 @@ typedef struct bhv_vattr {
10200 xfs_nlink_t va_nlink; /* number of references to file */
10201 uid_t va_uid; /* owner user id */
10202 gid_t va_gid; /* owner group id */
10203 + tag_t va_tag; /* owner group id */
10204 xfs_ino_t va_nodeid; /* file id */
10205 xfs_off_t va_size; /* file size in bytes */
10206 u_long va_blocksize; /* blocksize preferred for i/o */
10207 @@ -398,13 +399,15 @@ typedef struct bhv_vattr {
10208 #define XFS_AT_PROJID 0x04000000
10209 #define XFS_AT_SIZE_NOPERM 0x08000000
10210 #define XFS_AT_GENCOUNT 0x10000000
10211 +#define XFS_AT_TAG 0x20000000
10213 #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
10214 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
10215 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
10216 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
10217 XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
10218 - XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
10219 + XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT\
10222 #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
10223 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
10224 diff -Nurp linux-2.6.22.15/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/quota/xfs_qm_syscalls.c
10225 --- linux-2.6.22.15/fs/xfs/quota/xfs_qm_syscalls.c 2007-07-21 18:00:18.000000000 -0400
10226 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/quota/xfs_qm_syscalls.c 2007-12-09 06:44:21.000000000 -0500
10230 #include <linux/capability.h>
10231 +#include <linux/vs_context.h>
10234 #include "xfs_fs.h"
10235 @@ -211,7 +212,7 @@ xfs_qm_scall_quotaoff(
10236 xfs_qoff_logitem_t *qoffstart;
10239 - if (!force && !capable(CAP_SYS_ADMIN))
10240 + if (!force && !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10241 return XFS_ERROR(EPERM);
10243 * No file system can have quotas enabled on disk but not in core.
10244 @@ -380,7 +381,7 @@ xfs_qm_scall_trunc_qfiles(
10248 - if (!capable(CAP_SYS_ADMIN))
10249 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10250 return XFS_ERROR(EPERM);
10252 if (!XFS_SB_VERSION_HASQUOTA(&mp->m_sb) || flags == 0) {
10253 @@ -425,7 +426,7 @@ xfs_qm_scall_quotaon(
10257 - if (!capable(CAP_SYS_ADMIN))
10258 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10259 return XFS_ERROR(EPERM);
10261 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
10262 @@ -594,7 +595,7 @@ xfs_qm_scall_setqlim(
10264 xfs_qcnt_t hard, soft;
10266 - if (!capable(CAP_SYS_ADMIN))
10267 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10268 return XFS_ERROR(EPERM);
10270 if ((newlim->d_fieldmask &
10271 diff -Nurp linux-2.6.22.15/fs/xfs/xfs_clnt.h linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_clnt.h
10272 --- linux-2.6.22.15/fs/xfs/xfs_clnt.h 2006-06-17 21:49:35.000000000 -0400
10273 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_clnt.h 2007-12-09 06:44:21.000000000 -0500
10274 @@ -99,5 +99,7 @@ struct xfs_mount_args {
10276 #define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred
10277 * I/O size in stat(2) */
10278 +#define XFSMNT2_TAGGED 0x80000000 /* context tagging */
10281 #endif /* __XFS_CLNT_H__ */
10282 diff -Nurp linux-2.6.22.15/fs/xfs/xfs_dinode.h linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_dinode.h
10283 --- linux-2.6.22.15/fs/xfs/xfs_dinode.h 2007-05-04 09:55:41.000000000 -0400
10284 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_dinode.h 2007-12-09 06:44:21.000000000 -0500
10285 @@ -53,7 +53,8 @@ typedef struct xfs_dinode_core
10286 __uint32_t di_gid; /* owner's group id */
10287 __uint32_t di_nlink; /* number of links to file */
10288 __uint16_t di_projid; /* owner's project id */
10289 - __uint8_t di_pad[8]; /* unused, zeroed space */
10290 + __uint16_t di_tag; /* context tagging */
10291 + __uint8_t di_pad[6]; /* unused, zeroed space */
10292 __uint16_t di_flushiter; /* incremented on flush */
10293 xfs_timestamp_t di_atime; /* time last accessed */
10294 xfs_timestamp_t di_mtime; /* time last modified */
10295 @@ -257,6 +258,9 @@ typedef enum xfs_dinode_fmt
10296 #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */
10297 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
10298 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
10299 +#define XFS_DIFLAG_BARRIER_BIT 14 /* chroot() barrier */
10300 +#define XFS_DIFLAG_IUNLINK_BIT 15 /* immutable unlink */
10302 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
10303 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
10304 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
10305 @@ -271,12 +275,15 @@ typedef enum xfs_dinode_fmt
10306 #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT)
10307 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
10308 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
10309 +#define XFS_DIFLAG_BARRIER (1 << XFS_DIFLAG_BARRIER_BIT)
10310 +#define XFS_DIFLAG_IUNLINK (1 << XFS_DIFLAG_IUNLINK_BIT)
10312 #define XFS_DIFLAG_ANY \
10313 (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
10314 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
10315 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
10316 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
10317 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG)
10318 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_BARRIER | \
10319 + XFS_DIFLAG_IUNLINK)
10321 #endif /* __XFS_DINODE_H__ */
10322 diff -Nurp linux-2.6.22.15/fs/xfs/xfs_fs.h linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_fs.h
10323 --- linux-2.6.22.15/fs/xfs/xfs_fs.h 2007-05-04 09:57:37.000000000 -0400
10324 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_fs.h 2007-12-09 06:44:21.000000000 -0500
10325 @@ -66,6 +66,8 @@ struct fsxattr {
10326 #define XFS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */
10327 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
10328 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
10329 +#define XFS_XFLAG_BARRIER 0x00004000 /* chroot() barrier */
10330 +#define XFS_XFLAG_IUNLINK 0x00008000 /* immutable unlink */
10331 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
10334 @@ -294,7 +296,8 @@ typedef struct xfs_bstat {
10335 __s32 bs_extents; /* number of extents */
10336 __u32 bs_gen; /* generation count */
10337 __u16 bs_projid; /* project id */
10338 - unsigned char bs_pad[14]; /* pad space, unused */
10339 + __u16 bs_tag; /* context tagging */
10340 + unsigned char bs_pad[12]; /* pad space, unused */
10341 __u32 bs_dmevmask; /* DMIG event mask */
10342 __u16 bs_dmstate; /* DMIG state info */
10343 __u16 bs_aextents; /* attribute number of extents */
10344 diff -Nurp linux-2.6.22.15/fs/xfs/xfs_inode.c linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_inode.c
10345 --- linux-2.6.22.15/fs/xfs/xfs_inode.c 2007-07-21 18:00:18.000000000 -0400
10346 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_inode.c 2007-12-09 06:44:22.000000000 -0500
10348 #include "xfs_quota.h"
10349 #include "xfs_acl.h"
10351 +#include <linux/vs_tag.h>
10353 kmem_zone_t *xfs_ifork_zone;
10354 kmem_zone_t *xfs_inode_zone;
10355 @@ -736,20 +737,35 @@ xfs_xlate_dinode_core(
10356 xfs_dinode_core_t *buf_core = (xfs_dinode_core_t *)buf;
10357 xfs_dinode_core_t *mem_core = (xfs_dinode_core_t *)dip;
10358 xfs_arch_t arch = ARCH_CONVERT;
10359 + uint32_t uid = 0, gid = 0;
10360 + uint16_t tag = 0;
10365 + tag = mem_core->di_tag;
10366 + /* FIXME: supposed to use superblock flag */
10367 + uid = TAGINO_UID(1, mem_core->di_uid, tag);
10368 + gid = TAGINO_GID(1, mem_core->di_gid, tag);
10369 + tag = TAGINO_TAG(1, tag);
10372 INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch);
10373 INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch);
10374 INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch);
10375 INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch);
10376 INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch);
10377 - INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch);
10378 - INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch);
10379 + INT_XLATE(buf_core->di_uid, uid, dir, arch);
10380 + INT_XLATE(buf_core->di_gid, gid, dir, arch);
10381 + INT_XLATE(buf_core->di_tag, tag, dir, arch);
10382 INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch);
10383 INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch);
10386 + /* FIXME: supposed to use superblock flag */
10387 + mem_core->di_uid = INOTAG_UID(1, uid, gid);
10388 + mem_core->di_gid = INOTAG_GID(1, uid, gid);
10389 + mem_core->di_tag = INOTAG_TAG(1, uid, gid, tag);
10390 memcpy(mem_core->di_pad, buf_core->di_pad,
10391 sizeof(buf_core->di_pad));
10393 @@ -797,6 +813,10 @@ _xfs_dic2xflags(
10394 flags |= XFS_XFLAG_PREALLOC;
10395 if (di_flags & XFS_DIFLAG_IMMUTABLE)
10396 flags |= XFS_XFLAG_IMMUTABLE;
10397 + if (di_flags & XFS_DIFLAG_IUNLINK)
10398 + flags |= XFS_XFLAG_IUNLINK;
10399 + if (di_flags & XFS_DIFLAG_BARRIER)
10400 + flags |= XFS_XFLAG_BARRIER;
10401 if (di_flags & XFS_DIFLAG_APPEND)
10402 flags |= XFS_XFLAG_APPEND;
10403 if (di_flags & XFS_DIFLAG_SYNC)
10404 @@ -1129,6 +1149,7 @@ xfs_ialloc(
10405 ASSERT(ip->i_d.di_nlink == nlink);
10406 ip->i_d.di_uid = current_fsuid(cr);
10407 ip->i_d.di_gid = current_fsgid(cr);
10408 + ip->i_d.di_tag = current_fstag(cr, vp);
10409 ip->i_d.di_projid = prid;
10410 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
10412 diff -Nurp linux-2.6.22.15/fs/xfs/xfs_itable.c linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_itable.c
10413 --- linux-2.6.22.15/fs/xfs/xfs_itable.c 2007-07-21 18:00:18.000000000 -0400
10414 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_itable.c 2007-12-09 06:44:22.000000000 -0500
10415 @@ -89,6 +89,7 @@ xfs_bulkstat_one_iget(
10416 buf->bs_mode = dic->di_mode;
10417 buf->bs_uid = dic->di_uid;
10418 buf->bs_gid = dic->di_gid;
10419 + buf->bs_tag = dic->di_tag;
10420 buf->bs_size = dic->di_size;
10421 vn_atime_to_bstime(vp, &buf->bs_atime);
10422 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
10423 @@ -163,6 +164,7 @@ xfs_bulkstat_one_dinode(
10424 buf->bs_mode = INT_GET(dic->di_mode, ARCH_CONVERT);
10425 buf->bs_uid = INT_GET(dic->di_uid, ARCH_CONVERT);
10426 buf->bs_gid = INT_GET(dic->di_gid, ARCH_CONVERT);
10427 + buf->bs_tag = INT_GET(dic->di_tag, ARCH_CONVERT);
10428 buf->bs_size = INT_GET(dic->di_size, ARCH_CONVERT);
10429 buf->bs_atime.tv_sec = INT_GET(dic->di_atime.t_sec, ARCH_CONVERT);
10430 buf->bs_atime.tv_nsec = INT_GET(dic->di_atime.t_nsec, ARCH_CONVERT);
10431 diff -Nurp linux-2.6.22.15/fs/xfs/xfs_mount.h linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_mount.h
10432 --- linux-2.6.22.15/fs/xfs/xfs_mount.h 2007-07-21 17:58:49.000000000 -0400
10433 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_mount.h 2007-12-09 06:44:22.000000000 -0500
10434 @@ -464,6 +464,7 @@ typedef struct xfs_mount {
10435 #define XFS_MOUNT_NO_PERCPU_SB (1ULL << 23) /* don't use per-cpu superblock
10438 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
10441 * Default minimum read and write sizes.
10442 diff -Nurp linux-2.6.22.15/fs/xfs/xfs_vfsops.c linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_vfsops.c
10443 --- linux-2.6.22.15/fs/xfs/xfs_vfsops.c 2007-07-21 18:00:18.000000000 -0400
10444 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_vfsops.c 2007-12-09 06:44:22.000000000 -0500
10445 @@ -300,6 +300,8 @@ xfs_start_flags(
10447 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
10448 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
10449 + if (ap->flags2 & XFSMNT2_TAGGED)
10450 + mp->m_flags |= XFS_MOUNT_TAGGED;
10453 * no recovery flag requires a read-only mount
10454 @@ -394,6 +396,8 @@ xfs_finish_flags(
10455 return XFS_ERROR(EINVAL);
10458 + if (ap->flags2 & XFSMNT2_TAGGED)
10459 + vfs->vfs_super->s_flags |= MS_TAGGED;
10463 @@ -1645,6 +1649,9 @@ xfs_vget(
10465 #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
10466 #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
10467 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
10468 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
10469 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
10471 STATIC unsigned long
10472 suffix_strtoul(char *s, char **endp, unsigned int base)
10473 @@ -1831,6 +1838,19 @@ xfs_parseargs(
10474 args->flags |= XFSMNT_ATTR2;
10475 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
10476 args->flags &= ~XFSMNT_ATTR2;
10477 +#ifndef CONFIG_TAGGING_NONE
10478 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
10479 + args->flags2 |= XFSMNT2_TAGGED;
10480 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
10481 + args->flags2 &= ~XFSMNT2_TAGGED;
10482 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
10483 + args->flags2 |= XFSMNT2_TAGGED;
10485 +#ifdef CONFIG_PROPAGATE
10486 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
10488 + args->flags2 |= XFSMNT2_TAGGED;
10490 } else if (!strcmp(this_char, "osyncisdsync")) {
10491 /* no-op, this is now the default */
10493 diff -Nurp linux-2.6.22.15/fs/xfs/xfs_vnodeops.c linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_vnodeops.c
10494 --- linux-2.6.22.15/fs/xfs/xfs_vnodeops.c 2007-07-21 18:00:18.000000000 -0400
10495 +++ linux-2.6.22.15-vs2.3.0.29.1/fs/xfs/xfs_vnodeops.c 2007-12-09 06:44:22.000000000 -0500
10496 @@ -159,6 +159,7 @@ xfs_getattr(
10497 vap->va_mode = ip->i_d.di_mode;
10498 vap->va_uid = ip->i_d.di_uid;
10499 vap->va_gid = ip->i_d.di_gid;
10500 + vap->va_tag = ip->i_d.di_tag;
10501 vap->va_projid = ip->i_d.di_projid;
10504 @@ -259,6 +260,7 @@ xfs_setattr(
10505 uint commit_flags=0;
10506 uid_t uid=0, iuid=0;
10507 gid_t gid=0, igid=0;
10508 + tag_t tag=0, itag=0;
10511 xfs_prid_t projid=0, iprojid=0;
10512 @@ -315,6 +317,7 @@ xfs_setattr(
10513 (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID))) {
10516 + /* TODO: handle tagging? */
10517 if ((mask & XFS_AT_UID) && XFS_IS_UQUOTA_ON(mp)) {
10519 qflags |= XFS_QMOPT_UQUOTA;
10520 @@ -394,6 +397,8 @@ xfs_setattr(
10522 (XFS_AT_MODE|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_UID|
10523 XFS_AT_GID|XFS_AT_PROJID)) {
10524 + /* TODO: handle tagging? */
10527 * CAP_FOWNER overrides the following restrictions:
10529 @@ -442,7 +447,7 @@ xfs_setattr(
10530 * and can change the group id only to a group of which he
10531 * or she is a member.
10533 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10534 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10536 * These IDs could have changed since we last looked at them.
10537 * But, we're assured that if the ownership did change
10538 @@ -450,10 +455,12 @@ xfs_setattr(
10539 * would have changed also.
10541 iuid = ip->i_d.di_uid;
10542 - iprojid = ip->i_d.di_projid;
10543 igid = ip->i_d.di_gid;
10544 - gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10545 + itag = ip->i_d.di_tag;
10546 + iprojid = ip->i_d.di_projid;
10547 uid = (mask & XFS_AT_UID) ? vap->va_uid : iuid;
10548 + gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10549 + tag = (mask & XFS_AT_TAG) ? vap->va_tag : itag;
10550 projid = (mask & XFS_AT_PROJID) ? (xfs_prid_t)vap->va_projid :
10553 @@ -481,6 +488,7 @@ xfs_setattr(
10554 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
10555 (XFS_IS_PQUOTA_ON(mp) && iprojid != projid) ||
10556 (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
10557 + /* TODO: handle tagging? */
10559 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
10560 capable(CAP_FOWNER) ?
10561 @@ -706,7 +714,7 @@ xfs_setattr(
10562 * and can change the group id only to a group of which he
10563 * or she is a member.
10565 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10566 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10568 * CAP_FSETID overrides the following restrictions:
10570 @@ -722,6 +730,9 @@ xfs_setattr(
10571 * Change the ownerships and register quota modifications
10572 * in the transaction.
10574 + if (itag != tag) {
10575 + ip->i_d.di_tag = tag;
10578 if (XFS_IS_UQUOTA_ON(mp)) {
10579 ASSERT(mask & XFS_AT_UID);
10580 @@ -802,6 +813,10 @@ xfs_setattr(
10581 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
10582 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
10583 di_flags |= XFS_DIFLAG_IMMUTABLE;
10584 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10585 + di_flags |= XFS_DIFLAG_IUNLINK;
10586 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10587 + di_flags |= XFS_DIFLAG_BARRIER;
10588 if (vap->va_xflags & XFS_XFLAG_APPEND)
10589 di_flags |= XFS_DIFLAG_APPEND;
10590 if (vap->va_xflags & XFS_XFLAG_SYNC)
10591 diff -Nurp linux-2.6.22.15/include/asm-alpha/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-alpha/socket.h
10592 --- linux-2.6.22.15/include/asm-alpha/socket.h 2007-07-21 18:00:18.000000000 -0400
10593 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-alpha/socket.h 2007-12-09 06:44:22.000000000 -0500
10595 #define SO_TIMESTAMPNS 35
10596 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10598 +#define SO_PEERTAG 36
10600 /* Security levels - as per NRL IPv6 - don't actually do anything */
10601 #define SO_SECURITY_AUTHENTICATION 19
10602 #define SO_SECURITY_ENCRYPTION_TRANSPORT 20
10603 diff -Nurp linux-2.6.22.15/include/asm-arm/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-arm/socket.h
10604 --- linux-2.6.22.15/include/asm-arm/socket.h 2007-07-21 18:00:19.000000000 -0400
10605 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-arm/socket.h 2007-12-09 06:44:22.000000000 -0500
10607 #define SO_TIMESTAMPNS 35
10608 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10610 +#define SO_PEERTAG 36
10612 #endif /* _ASM_SOCKET_H */
10613 diff -Nurp linux-2.6.22.15/include/asm-arm/tlb.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-arm/tlb.h
10614 --- linux-2.6.22.15/include/asm-arm/tlb.h 2006-06-17 21:49:35.000000000 -0400
10615 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-arm/tlb.h 2007-12-09 06:44:22.000000000 -0500
10617 #else /* !CONFIG_MMU */
10619 #include <asm/pgalloc.h>
10620 +#include <linux/vs_memory.h>
10623 * TLB handling. This allows us to remove pages from the page
10624 diff -Nurp linux-2.6.22.15/include/asm-arm26/tlb.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-arm26/tlb.h
10625 --- linux-2.6.22.15/include/asm-arm26/tlb.h 2006-06-17 21:49:35.000000000 -0400
10626 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-arm26/tlb.h 2007-12-09 06:44:22.000000000 -0500
10629 #include <asm/pgalloc.h>
10630 #include <asm/tlbflush.h>
10631 +#include <linux/vs_memory.h>
10634 * TLB handling. This allows us to remove pages from the page
10635 diff -Nurp linux-2.6.22.15/include/asm-arm26/unistd.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-arm26/unistd.h
10636 --- linux-2.6.22.15/include/asm-arm26/unistd.h 2007-05-04 09:58:22.000000000 -0400
10637 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-arm26/unistd.h 2007-12-09 06:44:22.000000000 -0500
10638 @@ -302,6 +302,8 @@
10639 #define __NR_mq_getsetattr (__NR_SYSCALL_BASE+279)
10640 #define __NR_waitid (__NR_SYSCALL_BASE+280)
10642 +#define __NR_vserver (__NR_SYSCALL_BASE+313)
10645 * The following SWIs are ARM private. FIXME - make appropriate for arm26
10647 diff -Nurp linux-2.6.22.15/include/asm-cris/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-cris/socket.h
10648 --- linux-2.6.22.15/include/asm-cris/socket.h 2007-07-21 18:00:19.000000000 -0400
10649 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-cris/socket.h 2007-12-09 06:44:22.000000000 -0500
10651 #define SO_TIMESTAMPNS 35
10652 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10654 +#define SO_PEERTAG 36
10656 #endif /* _ASM_SOCKET_H */
10659 diff -Nurp linux-2.6.22.15/include/asm-frv/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-frv/socket.h
10660 --- linux-2.6.22.15/include/asm-frv/socket.h 2007-07-21 18:00:19.000000000 -0400
10661 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-frv/socket.h 2007-12-09 06:44:22.000000000 -0500
10663 #define SO_TIMESTAMPNS 35
10664 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10666 +#define SO_PEERTAG 36
10668 #endif /* _ASM_SOCKET_H */
10670 diff -Nurp linux-2.6.22.15/include/asm-generic/tlb.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-generic/tlb.h
10671 --- linux-2.6.22.15/include/asm-generic/tlb.h 2007-05-04 09:57:38.000000000 -0400
10672 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-generic/tlb.h 2007-12-09 06:44:22.000000000 -0500
10674 #define _ASM_GENERIC__TLB_H
10676 #include <linux/swap.h>
10677 +#include <linux/vs_memory.h>
10678 #include <asm/pgalloc.h>
10679 #include <asm/tlbflush.h>
10681 diff -Nurp linux-2.6.22.15/include/asm-h8300/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-h8300/socket.h
10682 --- linux-2.6.22.15/include/asm-h8300/socket.h 2007-07-21 18:00:19.000000000 -0400
10683 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-h8300/socket.h 2007-12-09 06:44:22.000000000 -0500
10685 #define SO_TIMESTAMPNS 35
10686 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10688 +#define SO_PEERTAG 36
10690 #endif /* _ASM_SOCKET_H */
10691 diff -Nurp linux-2.6.22.15/include/asm-i386/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-i386/socket.h
10692 --- linux-2.6.22.15/include/asm-i386/socket.h 2007-07-21 18:00:19.000000000 -0400
10693 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-i386/socket.h 2007-12-09 06:44:22.000000000 -0500
10695 #define SO_TIMESTAMPNS 35
10696 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10698 +#define SO_PEERTAG 36
10700 #endif /* _ASM_SOCKET_H */
10701 diff -Nurp linux-2.6.22.15/include/asm-ia64/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-ia64/socket.h
10702 --- linux-2.6.22.15/include/asm-ia64/socket.h 2007-07-21 18:00:19.000000000 -0400
10703 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-ia64/socket.h 2007-12-09 06:44:22.000000000 -0500
10705 #define SO_TIMESTAMPNS 35
10706 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10708 +#define SO_PEERTAG 36
10710 #endif /* _ASM_IA64_SOCKET_H */
10711 diff -Nurp linux-2.6.22.15/include/asm-ia64/tlb.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-ia64/tlb.h
10712 --- linux-2.6.22.15/include/asm-ia64/tlb.h 2007-05-04 09:55:44.000000000 -0400
10713 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-ia64/tlb.h 2007-12-09 06:44:22.000000000 -0500
10715 #include <linux/mm.h>
10716 #include <linux/pagemap.h>
10717 #include <linux/swap.h>
10718 +#include <linux/vs_memory.h>
10720 #include <asm/pgalloc.h>
10721 #include <asm/processor.h>
10722 diff -Nurp linux-2.6.22.15/include/asm-m32r/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-m32r/socket.h
10723 --- linux-2.6.22.15/include/asm-m32r/socket.h 2007-07-21 18:00:19.000000000 -0400
10724 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-m32r/socket.h 2007-12-09 06:44:22.000000000 -0500
10726 #define SO_TIMESTAMPNS 35
10727 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10729 +#define SO_PEERTAG 36
10731 #endif /* _ASM_M32R_SOCKET_H */
10732 diff -Nurp linux-2.6.22.15/include/asm-mips/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-mips/socket.h
10733 --- linux-2.6.22.15/include/asm-mips/socket.h 2007-07-21 18:00:19.000000000 -0400
10734 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-mips/socket.h 2007-12-09 06:44:22.000000000 -0500
10735 @@ -73,6 +73,8 @@ To add: #define SO_REUSEPORT 0x0200 /* A
10736 #define SO_TIMESTAMPNS 35
10737 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10739 +#define SO_PEERTAG 36
10743 /** sock_type - Socket types
10744 diff -Nurp linux-2.6.22.15/include/asm-parisc/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-parisc/socket.h
10745 --- linux-2.6.22.15/include/asm-parisc/socket.h 2007-07-21 18:00:20.000000000 -0400
10746 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-parisc/socket.h 2007-12-09 06:44:22.000000000 -0500
10749 #define SO_PEERSEC 0x401d
10750 #define SO_PASSSEC 0x401e
10751 +#define SO_PEERTAG 0x401f
10753 #endif /* _ASM_SOCKET_H */
10754 diff -Nurp linux-2.6.22.15/include/asm-powerpc/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-powerpc/socket.h
10755 --- linux-2.6.22.15/include/asm-powerpc/socket.h 2007-07-21 18:00:20.000000000 -0400
10756 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-powerpc/socket.h 2007-12-09 06:44:22.000000000 -0500
10758 #define SO_TIMESTAMPNS 35
10759 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10761 +#define SO_PEERTAG 36
10763 #endif /* _ASM_POWERPC_SOCKET_H */
10764 diff -Nurp linux-2.6.22.15/include/asm-powerpc/systbl.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-powerpc/systbl.h
10765 --- linux-2.6.22.15/include/asm-powerpc/systbl.h 2007-07-21 18:00:20.000000000 -0400
10766 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-powerpc/systbl.h 2007-12-09 06:44:22.000000000 -0500
10767 @@ -260,7 +260,7 @@ COMPAT_SYS_SPU(fstatfs64)
10768 SYSX(sys_ni_syscall, ppc_fadvise64_64, ppc_fadvise64_64)
10770 OLDSYS(debug_setcontext)
10771 -SYSCALL(ni_syscall)
10772 +SYSX(sys_vserver, sys32_vserver, sys_vserver)
10773 COMPAT_SYS(migrate_pages)
10775 COMPAT_SYS(get_mempolicy)
10776 diff -Nurp linux-2.6.22.15/include/asm-powerpc/unistd.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-powerpc/unistd.h
10777 --- linux-2.6.22.15/include/asm-powerpc/unistd.h 2007-07-21 18:00:20.000000000 -0400
10778 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-powerpc/unistd.h 2007-12-09 06:44:22.000000000 -0500
10779 @@ -275,7 +275,7 @@
10781 #define __NR_rtas 255
10782 #define __NR_sys_debug_setcontext 256
10783 -/* Number 257 is reserved for vserver */
10784 +#define __NR_vserver 257
10785 #define __NR_migrate_pages 258
10786 #define __NR_mbind 259
10787 #define __NR_get_mempolicy 260
10788 diff -Nurp linux-2.6.22.15/include/asm-s390/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-s390/socket.h
10789 --- linux-2.6.22.15/include/asm-s390/socket.h 2007-07-21 18:00:20.000000000 -0400
10790 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-s390/socket.h 2007-12-09 06:44:22.000000000 -0500
10792 #define SO_TIMESTAMPNS 35
10793 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10795 +#define SO_PEERTAG 36
10797 #endif /* _ASM_SOCKET_H */
10798 diff -Nurp linux-2.6.22.15/include/asm-s390/unistd.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-s390/unistd.h
10799 --- linux-2.6.22.15/include/asm-s390/unistd.h 2007-07-21 18:00:20.000000000 -0400
10800 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-s390/unistd.h 2007-12-09 06:44:22.000000000 -0500
10801 @@ -202,7 +202,7 @@
10802 #define __NR_clock_gettime (__NR_timer_create+6)
10803 #define __NR_clock_getres (__NR_timer_create+7)
10804 #define __NR_clock_nanosleep (__NR_timer_create+8)
10805 -/* Number 263 is reserved for vserver */
10806 +#define __NR_vserver 263
10807 #define __NR_statfs64 265
10808 #define __NR_fstatfs64 266
10809 #define __NR_remap_file_pages 267
10810 diff -Nurp linux-2.6.22.15/include/asm-sh/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-sh/socket.h
10811 --- linux-2.6.22.15/include/asm-sh/socket.h 2007-07-21 18:00:20.000000000 -0400
10812 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-sh/socket.h 2007-12-09 06:44:22.000000000 -0500
10814 #define SO_TIMESTAMPNS 35
10815 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10817 +#define SO_PEERTAG 36
10819 #endif /* __ASM_SH_SOCKET_H */
10820 diff -Nurp linux-2.6.22.15/include/asm-sparc/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-sparc/socket.h
10821 --- linux-2.6.22.15/include/asm-sparc/socket.h 2007-07-21 18:00:20.000000000 -0400
10822 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-sparc/socket.h 2007-12-09 06:44:22.000000000 -0500
10824 #define SO_TIMESTAMPNS 0x0021
10825 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10827 +#define SO_PEERTAG 36
10829 /* Security levels - as per NRL IPv6 - don't actually do anything */
10830 #define SO_SECURITY_AUTHENTICATION 0x5001
10831 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
10832 diff -Nurp linux-2.6.22.15/include/asm-sparc/unistd.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-sparc/unistd.h
10833 --- linux-2.6.22.15/include/asm-sparc/unistd.h 2007-07-21 18:00:20.000000000 -0400
10834 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-sparc/unistd.h 2007-12-09 06:44:22.000000000 -0500
10835 @@ -283,7 +283,7 @@
10836 #define __NR_timer_getoverrun 264
10837 #define __NR_timer_delete 265
10838 #define __NR_timer_create 266
10839 -/* #define __NR_vserver 267 Reserved for VSERVER */
10840 +#define __NR_vserver 267
10841 #define __NR_io_setup 268
10842 #define __NR_io_destroy 269
10843 #define __NR_io_submit 270
10844 diff -Nurp linux-2.6.22.15/include/asm-sparc64/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-sparc64/socket.h
10845 --- linux-2.6.22.15/include/asm-sparc64/socket.h 2007-07-21 18:00:20.000000000 -0400
10846 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-sparc64/socket.h 2007-12-09 06:44:22.000000000 -0500
10848 #define SO_TIMESTAMPNS 0x0021
10849 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10851 +#define SO_PEERTAG 0x0022
10853 /* Security levels - as per NRL IPv6 - don't actually do anything */
10854 #define SO_SECURITY_AUTHENTICATION 0x5001
10855 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
10856 diff -Nurp linux-2.6.22.15/include/asm-sparc64/tlb.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-sparc64/tlb.h
10857 --- linux-2.6.22.15/include/asm-sparc64/tlb.h 2007-07-21 18:00:20.000000000 -0400
10858 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-sparc64/tlb.h 2007-12-09 06:44:22.000000000 -0500
10861 #include <linux/swap.h>
10862 #include <linux/pagemap.h>
10863 +#include <linux/vs_memory.h>
10864 #include <asm/pgalloc.h>
10865 #include <asm/tlbflush.h>
10866 #include <asm/mmu_context.h>
10867 diff -Nurp linux-2.6.22.15/include/asm-sparc64/unistd.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-sparc64/unistd.h
10868 --- linux-2.6.22.15/include/asm-sparc64/unistd.h 2007-07-21 18:00:20.000000000 -0400
10869 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-sparc64/unistd.h 2007-12-09 06:44:22.000000000 -0500
10870 @@ -285,7 +285,7 @@
10871 #define __NR_timer_getoverrun 264
10872 #define __NR_timer_delete 265
10873 #define __NR_timer_create 266
10874 -/* #define __NR_vserver 267 Reserved for VSERVER */
10875 +#define __NR_vserver 267
10876 #define __NR_io_setup 268
10877 #define __NR_io_destroy 269
10878 #define __NR_io_submit 270
10879 diff -Nurp linux-2.6.22.15/include/asm-v850/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-v850/socket.h
10880 --- linux-2.6.22.15/include/asm-v850/socket.h 2007-07-21 18:00:20.000000000 -0400
10881 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-v850/socket.h 2007-12-09 06:44:22.000000000 -0500
10883 #define SO_TIMESTAMPNS 35
10884 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10886 +#define SO_PEERTAG 36
10888 #endif /* __V850_SOCKET_H__ */
10889 diff -Nurp linux-2.6.22.15/include/asm-x86_64/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-x86_64/socket.h
10890 --- linux-2.6.22.15/include/asm-x86_64/socket.h 2007-07-21 18:00:20.000000000 -0400
10891 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-x86_64/socket.h 2007-12-09 06:44:22.000000000 -0500
10893 #define SO_TIMESTAMPNS 35
10894 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10896 +#define SO_PEERTAG 36
10898 #endif /* _ASM_SOCKET_H */
10899 diff -Nurp linux-2.6.22.15/include/asm-x86_64/unistd.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-x86_64/unistd.h
10900 --- linux-2.6.22.15/include/asm-x86_64/unistd.h 2007-07-21 18:00:20.000000000 -0400
10901 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-x86_64/unistd.h 2007-12-09 06:44:22.000000000 -0500
10902 @@ -532,7 +532,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
10903 #define __NR_utimes 235
10904 __SYSCALL(__NR_utimes, sys_utimes)
10905 #define __NR_vserver 236
10906 -__SYSCALL(__NR_vserver, sys_ni_syscall)
10907 +__SYSCALL(__NR_vserver, sys_vserver)
10908 #define __NR_mbind 237
10909 __SYSCALL(__NR_mbind, sys_mbind)
10910 #define __NR_set_mempolicy 238
10911 diff -Nurp linux-2.6.22.15/include/asm-xtensa/socket.h linux-2.6.22.15-vs2.3.0.29.1/include/asm-xtensa/socket.h
10912 --- linux-2.6.22.15/include/asm-xtensa/socket.h 2007-07-21 18:00:20.000000000 -0400
10913 +++ linux-2.6.22.15-vs2.3.0.29.1/include/asm-xtensa/socket.h 2007-12-09 06:44:22.000000000 -0500
10915 #define SO_TIMESTAMPNS 35
10916 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10918 +#define SO_PEERTAG 36
10920 #endif /* _XTENSA_SOCKET_H */
10921 diff -Nurp linux-2.6.22.15/include/linux/capability.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/capability.h
10922 --- linux-2.6.22.15/include/linux/capability.h 2007-07-21 18:00:20.000000000 -0400
10923 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/capability.h 2007-12-09 06:44:22.000000000 -0500
10924 @@ -237,6 +237,7 @@ typedef __u32 kernel_cap_t;
10925 arbitrary SCSI commands */
10926 /* Allow setting encryption key on loopback filesystem */
10927 /* Allow setting zone reclaim policy */
10928 +/* Allow the selection of a security context */
10930 #define CAP_SYS_ADMIN 21
10932 @@ -290,6 +291,11 @@ typedef __u32 kernel_cap_t;
10934 #define CAP_AUDIT_CONTROL 30
10936 +/* Allow context manipulations */
10937 +/* Allow changing context info on files */
10939 +#define CAP_CONTEXT 31
10944 diff -Nurp linux-2.6.22.15/include/linux/devpts_fs.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/devpts_fs.h
10945 --- linux-2.6.22.15/include/linux/devpts_fs.h 2006-06-17 21:49:35.000000000 -0400
10946 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/devpts_fs.h 2007-12-09 06:44:22.000000000 -0500
10947 @@ -30,5 +30,4 @@ static inline void devpts_pty_kill(int n
10952 #endif /* _LINUX_DEVPTS_FS_H */
10953 diff -Nurp linux-2.6.22.15/include/linux/ext2_fs.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/ext2_fs.h
10954 --- linux-2.6.22.15/include/linux/ext2_fs.h 2007-05-04 09:57:41.000000000 -0400
10955 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/ext2_fs.h 2007-12-09 06:44:22.000000000 -0500
10956 @@ -188,6 +188,8 @@ struct ext2_group_desc
10957 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
10958 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
10959 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
10960 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
10961 +#define EXT2_IUNLINK_FL FS_IUNLINK_FL /* Immutable unlink */
10962 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
10964 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
10965 @@ -244,7 +246,7 @@ struct ext2_inode {
10967 __u8 l_i_frag; /* Fragment number */
10968 __u8 l_i_fsize; /* Fragment size */
10970 + __u16 l_i_tag; /* Context Tag */
10971 __le16 l_i_uid_high; /* these 2 fields */
10972 __le16 l_i_gid_high; /* were reserved2[0] */
10973 __u32 l_i_reserved2;
10974 @@ -276,6 +278,7 @@ struct ext2_inode {
10975 #define i_gid_low i_gid
10976 #define i_uid_high osd2.linux2.l_i_uid_high
10977 #define i_gid_high osd2.linux2.l_i_gid_high
10978 +#define i_raw_tag osd2.linux2.l_i_tag
10979 #define i_reserved2 osd2.linux2.l_i_reserved2
10982 @@ -317,8 +320,9 @@ struct ext2_inode {
10983 #define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */
10984 #define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */
10985 #define EXT2_MOUNT_XIP 0x010000 /* Execute in place */
10986 -#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
10987 -#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
10988 +#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
10989 +#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
10990 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
10993 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
10994 diff -Nurp linux-2.6.22.15/include/linux/ext3_fs.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/ext3_fs.h
10995 --- linux-2.6.22.15/include/linux/ext3_fs.h 2007-07-21 18:00:20.000000000 -0400
10996 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/ext3_fs.h 2007-12-09 06:44:22.000000000 -0500
10997 @@ -177,6 +177,8 @@ struct ext3_group_desc
10998 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
10999 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
11000 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11001 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11002 +#define EXT3_IUNLINK_FL 0x08000000 /* Immutable unlink */
11003 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
11005 #define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
11006 @@ -296,7 +298,7 @@ struct ext3_inode {
11008 __u8 l_i_frag; /* Fragment number */
11009 __u8 l_i_fsize; /* Fragment size */
11011 + __u16 l_i_tag; /* Context Tag */
11012 __le16 l_i_uid_high; /* these 2 fields */
11013 __le16 l_i_gid_high; /* were reserved2[0] */
11014 __u32 l_i_reserved2;
11015 @@ -330,6 +332,7 @@ struct ext3_inode {
11016 #define i_gid_low i_gid
11017 #define i_uid_high osd2.linux2.l_i_uid_high
11018 #define i_gid_high osd2.linux2.l_i_gid_high
11019 +#define i_raw_tag osd2.linux2.l_i_tag
11020 #define i_reserved2 osd2.linux2.l_i_reserved2
11022 #elif defined(__GNU__)
11023 @@ -384,6 +387,7 @@ struct ext3_inode {
11024 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
11025 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
11026 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
11027 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11029 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
11030 #ifndef _LINUX_EXT2_FS_H
11031 @@ -812,6 +816,7 @@ struct buffer_head * ext3_bread (handle_
11032 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
11033 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
11034 int create, int extend_disksize);
11035 +extern int ext3_sync_flags(struct inode *inode);
11037 extern void ext3_read_inode (struct inode *);
11038 extern int ext3_write_inode (struct inode *, int);
11039 diff -Nurp linux-2.6.22.15/include/linux/ext4_fs.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/ext4_fs.h
11040 --- linux-2.6.22.15/include/linux/ext4_fs.h 2007-07-21 18:00:22.000000000 -0400
11041 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/ext4_fs.h 2007-12-09 06:44:22.000000000 -0500
11042 @@ -189,8 +189,10 @@ struct ext4_group_desc
11043 #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
11044 #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
11045 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11046 -#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
11047 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
11048 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11049 +#define EXT4_IUNLINK_FL 0x08000000 /* Immutable unlink */
11050 +#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
11052 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
11053 #define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
11054 @@ -312,7 +314,8 @@ struct ext4_inode {
11055 __le16 l_i_file_acl_high;
11056 __le16 l_i_uid_high; /* these 2 fields */
11057 __le16 l_i_gid_high; /* were reserved2[0] */
11058 - __u32 l_i_reserved2;
11059 + __u16 l_i_tag; /* Context Tag */
11060 + __u16 l_i_reserved2;
11063 __u8 h_i_frag; /* Fragment number */
11064 @@ -344,6 +347,7 @@ struct ext4_inode {
11065 #define i_gid_low i_gid
11066 #define i_uid_high osd2.linux2.l_i_uid_high
11067 #define i_gid_high osd2.linux2.l_i_gid_high
11068 +#define i_raw_tag osd2.linux2.l_i_tag
11069 #define i_reserved2 osd2.linux2.l_i_reserved2
11071 #elif defined(__GNU__)
11072 @@ -400,6 +404,7 @@ struct ext4_inode {
11073 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
11074 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
11075 #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
11076 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11078 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
11079 #ifndef _LINUX_EXT2_FS_H
11080 @@ -850,6 +855,7 @@ struct buffer_head * ext4_bread (handle_
11081 int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
11082 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
11083 int create, int extend_disksize);
11084 +extern int ext4_sync_flags(struct inode *inode);
11086 extern void ext4_read_inode (struct inode *);
11087 extern int ext4_write_inode (struct inode *, int);
11088 diff -Nurp linux-2.6.22.15/include/linux/fs.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/fs.h
11089 --- linux-2.6.22.15/include/linux/fs.h 2007-07-21 18:00:23.000000000 -0400
11090 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/fs.h 2007-12-09 06:44:22.000000000 -0500
11091 @@ -123,6 +123,8 @@ extern int dir_notify_enable;
11092 #define MS_SLAVE (1<<19) /* change to slave */
11093 #define MS_SHARED (1<<20) /* change to shared */
11094 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
11095 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
11096 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
11097 #define MS_ACTIVE (1<<30)
11098 #define MS_NOUSER (1<<31)
11100 @@ -149,6 +151,8 @@ extern int dir_notify_enable;
11101 #define S_NOCMTIME 128 /* Do not update file c/mtime */
11102 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
11103 #define S_PRIVATE 512 /* Inode is fs-internal */
11104 +#define S_BARRIER 1024 /* Barrier for chroot() */
11105 +#define S_IUNLINK 2048 /* Immutable unlink */
11108 * Note that nosuid etc flags are inode-specific: setting some file-system
11109 @@ -165,24 +169,36 @@ extern int dir_notify_enable;
11111 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
11113 -#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
11114 +#define IS_RDONLY(inode) __IS_FLG(inode, MS_RDONLY)
11115 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
11116 ((inode)->i_flags & S_SYNC))
11117 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
11118 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
11119 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
11120 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
11121 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
11122 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
11124 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
11125 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
11126 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
11127 +#define IS_IUNLINK(inode) ((inode)->i_flags & S_IUNLINK)
11128 +#define IS_IXORUNLINK(inode) ((IS_IUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
11129 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
11131 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_flags & S_BARRIER))
11132 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
11133 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
11134 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
11135 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
11137 +#ifdef CONFIG_VSERVER_COWBL
11138 +# define IS_COW(inode) (IS_IUNLINK(inode) && IS_IMMUTABLE(inode))
11139 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
11141 +# define IS_COW(inode) (0)
11142 +# define IS_COW_LINK(inode) (0)
11145 /* the read-only stuff doesn't really belong here, but any other place is
11146 probably as bad and I don't want to create yet another include file. */
11148 @@ -256,12 +272,13 @@ extern int dir_notify_enable;
11149 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11150 #define FS_EXTENT_FL 0x00080000 /* Extents */
11151 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
11152 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11153 +#define FS_IUNLINK_FL 0x08000000 /* Immutable unlink */
11154 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
11156 #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
11157 #define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
11160 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
11161 #define SYNC_FILE_RANGE_WRITE 2
11162 #define SYNC_FILE_RANGE_WAIT_AFTER 4
11163 @@ -327,6 +344,7 @@ typedef void (dio_iodone_t)(struct kiocb
11164 #define ATTR_KILL_SUID 2048
11165 #define ATTR_KILL_SGID 4096
11166 #define ATTR_FILE 8192
11167 +#define ATTR_TAG 16384
11170 * This is the Inode Attributes structure, used for notify_change(). It
11171 @@ -342,6 +360,7 @@ struct iattr {
11177 struct timespec ia_atime;
11178 struct timespec ia_mtime;
11179 @@ -355,6 +374,9 @@ struct iattr {
11180 struct file *ia_file;
11183 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
11184 +#define ATTR_FLAG_IUNLINK 1024 /* Immutable unlink */
11187 * Includes for diskquotas.
11189 @@ -537,7 +559,9 @@ struct inode {
11190 unsigned int i_nlink;
11196 unsigned long i_version;
11198 #ifdef __NEED_I_SIZE_ORDERED
11199 @@ -672,12 +696,12 @@ static inline void i_size_write(struct i
11201 static inline unsigned iminor(const struct inode *inode)
11203 - return MINOR(inode->i_rdev);
11204 + return MINOR(inode->i_mdev);
11207 static inline unsigned imajor(const struct inode *inode)
11209 - return MAJOR(inode->i_rdev);
11210 + return MAJOR(inode->i_mdev);
11213 extern struct block_device *I_BDEV(struct inode *inode);
11214 @@ -728,6 +752,7 @@ struct file {
11216 struct fown_struct f_owner;
11217 unsigned int f_uid, f_gid;
11219 struct file_ra_state f_ra;
11221 unsigned long f_version;
11222 @@ -811,6 +836,7 @@ struct file_lock {
11223 unsigned char fl_type;
11228 struct fasync_struct * fl_fasync; /* for lease break notifications */
11229 unsigned long fl_break_time; /* for nonblocking lease breaks */
11230 @@ -993,12 +1019,12 @@ extern void unlock_super(struct super_bl
11232 extern int vfs_permission(struct nameidata *, int);
11233 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
11234 -extern int vfs_mkdir(struct inode *, struct dentry *, int);
11235 -extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
11236 -extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
11237 -extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
11238 -extern int vfs_rmdir(struct inode *, struct dentry *);
11239 -extern int vfs_unlink(struct inode *, struct dentry *);
11240 +extern int vfs_mkdir(struct inode *, struct dentry *, int, struct nameidata *);
11241 +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t, struct nameidata *);
11242 +extern int vfs_symlink(struct inode *, struct dentry *, const char *, int, struct nameidata *);
11243 +extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct nameidata *);
11244 +extern int vfs_rmdir(struct inode *, struct dentry *, struct nameidata *);
11245 +extern int vfs_unlink(struct inode *, struct dentry *, struct nameidata *);
11246 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
11249 @@ -1138,6 +1164,7 @@ struct inode_operations {
11250 ssize_t (*listxattr) (struct dentry *, char *, size_t);
11251 int (*removexattr) (struct dentry *, const char *);
11252 void (*truncate_range)(struct inode *, loff_t, loff_t);
11253 + int (*sync_flags) (struct inode *);
11257 @@ -1153,6 +1180,7 @@ extern ssize_t vfs_readv(struct file *,
11258 unsigned long, loff_t *);
11259 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
11260 unsigned long, loff_t *);
11261 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
11264 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
11265 @@ -1898,6 +1926,7 @@ extern int dcache_dir_open(struct inode
11266 extern int dcache_dir_close(struct inode *, struct file *);
11267 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
11268 extern int dcache_readdir(struct file *, void *, filldir_t);
11269 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
11270 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
11271 extern int simple_statfs(struct dentry *, struct kstatfs *);
11272 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
11273 diff -Nurp linux-2.6.22.15/include/linux/init_task.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/init_task.h
11274 --- linux-2.6.22.15/include/linux/init_task.h 2007-07-21 18:00:23.000000000 -0400
11275 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/init_task.h 2007-12-09 06:44:22.000000000 -0500
11276 @@ -169,6 +169,10 @@ extern struct group_info init_groups;
11278 INIT_TRACE_IRQFLAGS \
11281 + .vx_info = NULL, \
11283 + .nx_info = NULL, \
11287 diff -Nurp linux-2.6.22.15/include/linux/ipc.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/ipc.h
11288 --- linux-2.6.22.15/include/linux/ipc.h 2007-07-21 18:00:23.000000000 -0400
11289 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/ipc.h 2007-12-09 06:44:22.000000000 -0500
11290 @@ -63,6 +63,7 @@ struct kern_ipc_perm
11298 diff -Nurp linux-2.6.22.15/include/linux/jffs2.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/jffs2.h
11299 --- linux-2.6.22.15/include/linux/jffs2.h 2007-05-04 09:57:43.000000000 -0400
11300 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/jffs2.h 2007-12-09 06:44:22.000000000 -0500
11301 @@ -82,12 +82,36 @@
11302 //#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
11305 -#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
11306 +#define JFFS2_INO_FLAG_PREREAD 0x01 /* Do read_inode() for this one at
11307 mount time, don't wait for it to
11309 -#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
11310 +#define JFFS2_INO_FLAG_USERCOMPR 0x02 /* User has requested a specific
11311 compression type */
11313 +#define JFFS2_INO_FLAG_IMMUTABLE 0x10 /* immutable node */
11314 +#define JFFS2_INO_FLAG_IUNLINK 0x20 /* immutable unlink */
11315 +#define JFFS2_INO_FLAG_BARRIER 0x40 /* barrier */
11317 +#define JFFS2_USER_VISIBLE 0x10
11318 +#define JFFS2_USER_MODIFIABLE 0x10
11323 +#define JFFS2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11325 +#define clear_opt(o, opt) o &= ~JFFS2_MOUNT_##opt
11326 +#define set_opt(o, opt) o |= JFFS2_MOUNT_##opt
11329 + * Maximal mount counts between two filesystem checks
11331 +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
11332 +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
11335 + * Behaviour when detecting errors
11338 /* These can go once we've made sure we've caught all uses without
11340 @@ -97,7 +121,7 @@ typedef struct {
11341 } __attribute__((packed)) jint32_t;
11346 } __attribute__((packed)) jmode_t;
11349 @@ -145,7 +169,8 @@ struct jffs2_raw_inode
11351 jint32_t ino; /* Inode number. */
11352 jint32_t version; /* Version number. */
11353 - jmode_t mode; /* The file's type or mode. */
11354 + jmode_t mode; /* The file's type or mode. */
11355 + jint16_t tag; /* context tagging */
11356 jint16_t uid; /* The file's owner. */
11357 jint16_t gid; /* The file's group. */
11358 jint32_t isize; /* Total resultant size of this inode (used for truncations) */
11359 diff -Nurp linux-2.6.22.15/include/linux/Kbuild linux-2.6.22.15-vs2.3.0.29.1/include/linux/Kbuild
11360 --- linux-2.6.22.15/include/linux/Kbuild 2007-09-29 08:11:49.000000000 -0400
11361 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/Kbuild 2007-12-09 06:44:22.000000000 -0500
11362 @@ -351,3 +351,6 @@ unifdef-y += xattr.h
11363 unifdef-y += xfrm.h
11365 objhdr-y += version.h
11367 +header-y += vserver/
11369 diff -Nurp linux-2.6.22.15/include/linux/loop.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/loop.h
11370 --- linux-2.6.22.15/include/linux/loop.h 2007-07-21 18:00:24.000000000 -0400
11371 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/loop.h 2007-12-09 06:44:22.000000000 -0500
11372 @@ -45,6 +45,7 @@ struct loop_device {
11373 struct loop_func_table *lo_encryption;
11375 uid_t lo_key_owner; /* Who set the key */
11377 int (*ioctl)(struct loop_device *, int cmd,
11378 unsigned long arg);
11380 diff -Nurp linux-2.6.22.15/include/linux/magic.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/magic.h
11381 --- linux-2.6.22.15/include/linux/magic.h 2007-07-21 18:00:24.000000000 -0400
11382 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/magic.h 2007-12-09 06:44:22.000000000 -0500
11385 #define ADFS_SUPER_MAGIC 0xadf5
11386 #define AFFS_SUPER_MAGIC 0xadff
11387 -#define AFS_SUPER_MAGIC 0x5346414F
11388 +#define AFS_SUPER_MAGIC 0x5346414F
11389 #define AUTOFS_SUPER_MAGIC 0x0187
11390 #define CODA_SUPER_MAGIC 0x73757245
11391 #define EFS_SUPER_MAGIC 0x414A53
11393 #define NFS_SUPER_MAGIC 0x6969
11394 #define OPENPROM_SUPER_MAGIC 0x9fa1
11395 #define PROC_SUPER_MAGIC 0x9fa0
11396 +#define DEVPTS_SUPER_MAGIC 0x1cd1
11397 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
11399 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
11400 diff -Nurp linux-2.6.22.15/include/linux/major.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/major.h
11401 --- linux-2.6.22.15/include/linux/major.h 2007-07-21 18:00:24.000000000 -0400
11402 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/major.h 2007-12-09 06:44:22.000000000 -0500
11404 #define HD_MAJOR IDE0_MAJOR
11405 #define PTY_SLAVE_MAJOR 3
11406 #define TTY_MAJOR 4
11407 +#define VROOT_MAJOR 4
11408 #define TTYAUX_MAJOR 5
11410 #define VCS_MAJOR 7
11411 diff -Nurp linux-2.6.22.15/include/linux/mount.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/mount.h
11412 --- linux-2.6.22.15/include/linux/mount.h 2007-07-21 18:00:24.000000000 -0400
11413 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/mount.h 2007-12-09 06:44:22.000000000 -0500
11414 @@ -28,6 +28,9 @@ struct mnt_namespace;
11415 #define MNT_NOATIME 0x08
11416 #define MNT_NODIRATIME 0x10
11417 #define MNT_RELATIME 0x20
11418 +#define MNT_RDONLY 0x40
11420 +#define MNT_IS_RDONLY(m) ((m) && ((m)->mnt_flags & MNT_RDONLY))
11422 #define MNT_SHRINKABLE 0x100
11424 @@ -35,6 +38,10 @@ struct mnt_namespace;
11425 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
11426 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
11428 +#define MNT_TAGID 0x10000
11429 +#define MNT_NOTAG 0x20000
11430 +#define MNT_NOTAGCHECK 0x40000
11433 struct list_head mnt_hash;
11434 struct vfsmount *mnt_parent; /* fs we are mounted on */
11435 @@ -61,6 +68,7 @@ struct vfsmount {
11436 atomic_t mnt_count;
11437 int mnt_expiry_mark; /* true if marked for expiry */
11439 + tag_t mnt_tag; /* tagging used for vfsmount */
11442 static inline struct vfsmount *mntget(struct vfsmount *mnt)
11443 diff -Nurp linux-2.6.22.15/include/linux/net.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/net.h
11444 --- linux-2.6.22.15/include/linux/net.h 2007-07-21 18:00:24.000000000 -0400
11445 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/net.h 2007-12-09 06:44:22.000000000 -0500
11446 @@ -63,6 +63,7 @@ typedef enum {
11447 #define SOCK_NOSPACE 2
11448 #define SOCK_PASSCRED 3
11449 #define SOCK_PASSSEC 4
11450 +#define SOCK_USER_SOCKET 5
11452 #ifndef ARCH_HAS_SOCKET_TYPES
11454 diff -Nurp linux-2.6.22.15/include/linux/nfs_mount.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/nfs_mount.h
11455 --- linux-2.6.22.15/include/linux/nfs_mount.h 2007-07-21 18:00:24.000000000 -0400
11456 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/nfs_mount.h 2007-12-09 06:44:22.000000000 -0500
11458 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
11459 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
11460 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
11461 -#define NFS_MOUNT_FLAGMASK 0xFFFF
11462 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
11463 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
11466 diff -Nurp linux-2.6.22.15/include/linux/nsproxy.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/nsproxy.h
11467 --- linux-2.6.22.15/include/linux/nsproxy.h 2007-07-21 18:00:24.000000000 -0400
11468 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/nsproxy.h 2007-12-09 06:44:22.000000000 -0500
11471 #include <linux/spinlock.h>
11472 #include <linux/sched.h>
11473 +#include <linux/vserver/debug.h>
11475 struct mnt_namespace;
11476 struct uts_namespace;
11477 @@ -32,26 +33,46 @@ struct nsproxy {
11478 extern struct nsproxy init_nsproxy;
11480 int copy_namespaces(int flags, struct task_struct *tsk);
11481 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
11482 void get_task_namespaces(struct task_struct *tsk);
11483 void free_nsproxy(struct nsproxy *ns);
11484 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
11485 struct fs_struct *);
11487 -static inline void put_nsproxy(struct nsproxy *ns)
11488 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
11490 +static inline void __get_nsproxy(struct nsproxy *ns,
11491 + const char *_file, int _line)
11493 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
11494 + ns, atomic_read(&ns->count), _file, _line);
11495 + atomic_inc(&ns->count);
11498 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
11500 +static inline void __put_nsproxy(struct nsproxy *ns,
11501 + const char *_file, int _line)
11503 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
11504 + ns, atomic_read(&ns->count), _file, _line);
11505 if (atomic_dec_and_test(&ns->count)) {
11510 -static inline void exit_task_namespaces(struct task_struct *p)
11511 +#define exit_task_namespaces(p) __exit_task_namespaces(p, __FILE__, __LINE__)
11513 +static inline void __exit_task_namespaces(struct task_struct *p,
11514 + const char *_file, int _line)
11516 struct nsproxy *ns = p->nsproxy;
11522 + __put_nsproxy(ns, _file, _line);
11527 diff -Nurp linux-2.6.22.15/include/linux/pid.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/pid.h
11528 --- linux-2.6.22.15/include/linux/pid.h 2007-07-21 18:00:24.000000000 -0400
11529 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/pid.h 2007-12-09 06:44:22.000000000 -0500
11530 @@ -8,7 +8,8 @@ enum pid_type
11540 diff -Nurp linux-2.6.22.15/include/linux/proc_fs.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/proc_fs.h
11541 --- linux-2.6.22.15/include/linux/proc_fs.h 2007-07-21 18:00:24.000000000 -0400
11542 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/proc_fs.h 2007-12-09 06:44:22.000000000 -0500
11543 @@ -54,6 +54,7 @@ struct proc_dir_entry {
11549 const struct inode_operations *proc_iops;
11550 const struct file_operations *proc_fops;
11551 @@ -246,13 +247,20 @@ static inline void kclist_add(struct kco
11552 extern void kclist_add(struct kcore_list *, void *, size_t);
11559 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
11560 int (*proc_read)(struct task_struct *task, char *page);
11561 + int (*proc_vs_read)(char *page);
11562 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
11563 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
11566 struct proc_inode {
11571 struct proc_dir_entry *pde;
11572 diff -Nurp linux-2.6.22.15/include/linux/reiserfs_fs.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/reiserfs_fs.h
11573 --- linux-2.6.22.15/include/linux/reiserfs_fs.h 2007-07-21 17:58:53.000000000 -0400
11574 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/reiserfs_fs.h 2007-12-09 06:44:22.000000000 -0500
11575 @@ -821,6 +821,10 @@ struct stat_data_v1 {
11576 #define REISERFS_COMPR_FL FS_COMPR_FL
11577 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
11579 +/* unfortunately reiserfs sdattr is only 16 bit */
11580 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
11581 +#define REISERFS_IUNLINK_FL (FS_IUNLINK_FL >> 16)
11583 /* persistent flags that file inherits from the parent directory */
11584 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
11585 REISERFS_SYNC_FL | \
11586 @@ -830,6 +834,9 @@ struct stat_data_v1 {
11587 REISERFS_COMPR_FL | \
11588 REISERFS_NOTAIL_FL )
11590 +#define REISERFS_FL_USER_VISIBLE 0x80FF
11591 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
11593 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
11596 @@ -1901,6 +1908,7 @@ static inline void reiserfs_update_sd(st
11597 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
11598 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
11599 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
11600 +int reiserfs_sync_flags(struct inode *inode);
11603 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
11604 diff -Nurp linux-2.6.22.15/include/linux/reiserfs_fs_sb.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/reiserfs_fs_sb.h
11605 --- linux-2.6.22.15/include/linux/reiserfs_fs_sb.h 2007-07-21 18:00:24.000000000 -0400
11606 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/reiserfs_fs_sb.h 2007-12-09 06:44:22.000000000 -0500
11607 @@ -458,6 +458,7 @@ enum reiserfs_mount_options {
11609 REISERFS_BARRIER_NONE,
11610 REISERFS_BARRIER_FLUSH,
11613 /* Actions on error */
11614 REISERFS_ERROR_PANIC,
11615 diff -Nurp linux-2.6.22.15/include/linux/sched.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/sched.h
11616 --- linux-2.6.22.15/include/linux/sched.h 2007-07-21 18:00:24.000000000 -0400
11617 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/sched.h 2007-12-09 06:44:22.000000000 -0500
11619 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
11620 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
11621 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
11622 +#define CLONE_KTHREAD 0x10000000 /* clone a kernel thread */
11625 * Scheduling policies
11626 @@ -94,7 +95,7 @@ struct bio;
11627 * List of flags we want to share for kernel threads,
11628 * if only because they are not used by them anyway.
11630 -#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
11631 +#define CLONE_KERNEL (CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_KTHREAD)
11634 * These are the constant used to fake the fixed-point load-average
11635 @@ -146,12 +147,13 @@ extern unsigned long weighted_cpuload(co
11636 #define TASK_UNINTERRUPTIBLE 2
11637 #define TASK_STOPPED 4
11638 #define TASK_TRACED 8
11639 +#define TASK_ONHOLD 16
11640 /* in tsk->exit_state */
11641 -#define EXIT_ZOMBIE 16
11642 -#define EXIT_DEAD 32
11643 +#define EXIT_ZOMBIE 32
11644 +#define EXIT_DEAD 64
11645 /* in tsk->state again */
11646 -#define TASK_NONINTERACTIVE 64
11647 -#define TASK_DEAD 128
11648 +#define TASK_NONINTERACTIVE 128
11649 +#define TASK_DEAD 256
11651 #define __set_task_state(tsk, state_value) \
11652 do { (tsk)->state = (state_value); } while (0)
11653 @@ -287,27 +289,30 @@ extern void arch_unmap_area_topdown(stru
11654 * The mm counters are not protected by its page_table_lock,
11655 * so must be incremented atomically.
11657 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
11658 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
11659 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
11660 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
11661 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
11662 typedef atomic_long_t mm_counter_t;
11663 +#define __set_mm_counter(mm, member, value) \
11664 + atomic_long_set(&(mm)->_##member, value)
11665 +#define get_mm_counter(mm, member) \
11666 + ((unsigned long)atomic_long_read(&(mm)->_##member))
11668 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11670 * The mm counters are protected by its page_table_lock,
11671 * so can be incremented directly.
11673 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
11674 -#define get_mm_counter(mm, member) ((mm)->_##member)
11675 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
11676 -#define inc_mm_counter(mm, member) (mm)->_##member++
11677 -#define dec_mm_counter(mm, member) (mm)->_##member--
11678 typedef unsigned long mm_counter_t;
11679 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
11680 +#define get_mm_counter(mm, member) ((mm)->_##member)
11682 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11684 +#define set_mm_counter(mm, member, value) \
11685 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
11686 +#define add_mm_counter(mm, member, value) \
11687 + vx_ ## member ## pages_add((mm), (value))
11688 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
11689 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
11691 #define get_mm_rss(mm) \
11692 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
11693 #define update_hiwater_rss(mm) do { \
11694 @@ -365,6 +370,7 @@ struct mm_struct {
11696 /* Architecture-specific MM context */
11697 mm_context_t context;
11698 + struct vx_info *mm_vx_info;
11700 /* Swap token stuff */
11702 @@ -570,9 +576,10 @@ struct user_struct {
11703 /* Hash table maintenance information */
11704 struct list_head uidhash_list;
11709 -extern struct user_struct *find_user(uid_t);
11710 +extern struct user_struct *find_user(xid_t, uid_t);
11712 extern struct user_struct root_user;
11713 #define INIT_USER (&root_user)
11714 @@ -969,6 +976,15 @@ struct task_struct {
11717 struct audit_context *audit_context;
11719 +/* vserver context data */
11720 + struct vx_info *vx_info;
11721 + struct nx_info *nx_info;
11729 /* Thread group tracking */
11730 @@ -1290,12 +1306,16 @@ extern struct task_struct init_task;
11732 extern struct mm_struct init_mm;
11734 -#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr)
11735 +#define find_task_by_real_pid(nr) \
11736 + find_task_by_pid_type(PIDTYPE_REALPID, nr)
11737 +#define find_task_by_pid(nr) \
11738 + find_task_by_pid_type(PIDTYPE_PID, nr)
11740 extern struct task_struct *find_task_by_pid_type(int type, int pid);
11741 extern void __set_special_pids(pid_t session, pid_t pgrp);
11743 /* per-UID process charging. */
11744 -extern struct user_struct * alloc_uid(uid_t);
11745 +extern struct user_struct * alloc_uid(xid_t, uid_t);
11746 static inline struct user_struct *get_uid(struct user_struct *u)
11748 atomic_inc(&u->__count);
11749 diff -Nurp linux-2.6.22.15/include/linux/shmem_fs.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/shmem_fs.h
11750 --- linux-2.6.22.15/include/linux/shmem_fs.h 2007-05-04 09:57:44.000000000 -0400
11751 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/shmem_fs.h 2007-12-09 06:44:22.000000000 -0500
11754 #define SHMEM_NR_DIRECT 16
11756 +#define TMPFS_SUPER_MAGIC 0x01021994
11759 struct shmem_inode_info {
11761 unsigned long flags;
11762 diff -Nurp linux-2.6.22.15/include/linux/stat.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/stat.h
11763 --- linux-2.6.22.15/include/linux/stat.h 2007-07-21 18:00:24.000000000 -0400
11764 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/stat.h 2007-12-09 06:44:22.000000000 -0500
11765 @@ -66,6 +66,7 @@ struct kstat {
11766 unsigned int nlink;
11772 struct timespec atime;
11773 diff -Nurp linux-2.6.22.15/include/linux/sunrpc/auth.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/sunrpc/auth.h
11774 --- linux-2.6.22.15/include/linux/sunrpc/auth.h 2007-05-04 09:57:44.000000000 -0400
11775 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/sunrpc/auth.h 2007-12-09 06:44:22.000000000 -0500
11781 struct group_info *group_info;
11785 diff -Nurp linux-2.6.22.15/include/linux/sunrpc/clnt.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/sunrpc/clnt.h
11786 --- linux-2.6.22.15/include/linux/sunrpc/clnt.h 2007-07-21 18:00:24.000000000 -0400
11787 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/sunrpc/clnt.h 2007-12-09 06:44:22.000000000 -0500
11788 @@ -43,7 +43,8 @@ struct rpc_clnt {
11789 unsigned int cl_softrtry : 1,/* soft timeouts */
11790 cl_intr : 1,/* interruptible */
11791 cl_discrtry : 1,/* disconnect before retry */
11792 - cl_autobind : 1;/* use getport() */
11793 + cl_autobind : 1,/* use getport() */
11794 + cl_tag : 1;/* context tagging */
11796 struct rpc_rtt * cl_rtt; /* RTO estimator data */
11798 diff -Nurp linux-2.6.22.15/include/linux/syscalls.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/syscalls.h
11799 --- linux-2.6.22.15/include/linux/syscalls.h 2007-07-21 18:00:24.000000000 -0400
11800 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/syscalls.h 2007-12-09 06:44:22.000000000 -0500
11801 @@ -294,6 +294,8 @@ asmlinkage long sys_symlink(const char _
11802 asmlinkage long sys_unlink(const char __user *pathname);
11803 asmlinkage long sys_rename(const char __user *oldname,
11804 const char __user *newname);
11805 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
11807 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
11808 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
11810 diff -Nurp linux-2.6.22.15/include/linux/sysctl.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/sysctl.h
11811 --- linux-2.6.22.15/include/linux/sysctl.h 2007-07-21 18:00:24.000000000 -0400
11812 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/sysctl.h 2007-12-09 06:44:22.000000000 -0500
11813 @@ -106,6 +106,7 @@ enum
11814 KERN_CAP_BSET=14, /* int: capability bounding set */
11815 KERN_PANIC=15, /* int: panic timeout */
11816 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
11817 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
11819 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
11820 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
11821 diff -Nurp linux-2.6.22.15/include/linux/sysfs.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/sysfs.h
11822 --- linux-2.6.22.15/include/linux/sysfs.h 2007-07-21 18:00:24.000000000 -0400
11823 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/sysfs.h 2007-12-09 06:44:22.000000000 -0500
11825 #include <linux/list.h>
11826 #include <asm/atomic.h>
11828 +#define SYSFS_SUPER_MAGIC 0x62656572
11833 diff -Nurp linux-2.6.22.15/include/linux/time.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/time.h
11834 --- linux-2.6.22.15/include/linux/time.h 2007-07-21 18:00:24.000000000 -0400
11835 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/time.h 2007-12-09 06:44:22.000000000 -0500
11836 @@ -176,6 +176,9 @@ static inline void timespec_add_ns(struc
11841 +#include <linux/vs_time.h>
11843 #endif /* __KERNEL__ */
11845 #define NFDBITS __NFDBITS
11846 diff -Nurp linux-2.6.22.15/include/linux/types.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/types.h
11847 --- linux-2.6.22.15/include/linux/types.h 2007-05-04 09:58:24.000000000 -0400
11848 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/types.h 2007-12-09 06:44:22.000000000 -0500
11849 @@ -39,6 +39,9 @@ typedef __kernel_uid32_t uid_t;
11850 typedef __kernel_gid32_t gid_t;
11851 typedef __kernel_uid16_t uid16_t;
11852 typedef __kernel_gid16_t gid16_t;
11853 +typedef unsigned int xid_t;
11854 +typedef unsigned int nid_t;
11855 +typedef unsigned int tag_t;
11857 #ifdef CONFIG_UID16
11858 /* This is defined by include/asm-{arch}/posix_types.h */
11859 diff -Nurp linux-2.6.22.15/include/linux/vroot.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vroot.h
11860 --- linux-2.6.22.15/include/linux/vroot.h 1969-12-31 19:00:00.000000000 -0500
11861 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vroot.h 2007-12-09 06:44:22.000000000 -0500
11865 + * include/linux/vroot.h
11867 + * written by Herbert Pötzl, 9/11/2002
11868 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
11870 + * Copyright (C) 2002-2007 by Herbert Pötzl.
11871 + * Redistribution of this file is permitted under the
11872 + * GNU General Public License.
11875 +#ifndef _LINUX_VROOT_H
11876 +#define _LINUX_VROOT_H
11881 +/* Possible states of device */
11887 +struct vroot_device {
11891 + struct semaphore vr_ctl_mutex;
11892 + struct block_device *vr_device;
11897 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
11899 +extern int register_vroot_grb(vroot_grb_func *);
11900 +extern int unregister_vroot_grb(vroot_grb_func *);
11902 +#endif /* __KERNEL__ */
11904 +#define MAX_VROOT_DEFAULT 8
11907 + * IOCTL commands --- we will commandeer 0x56 ('V')
11910 +#define VROOT_SET_DEV 0x5600
11911 +#define VROOT_CLR_DEV 0x5601
11913 +#endif /* _LINUX_VROOT_H */
11914 diff -Nurp linux-2.6.22.15/include/linux/vs_base.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_base.h
11915 --- linux-2.6.22.15/include/linux/vs_base.h 1969-12-31 19:00:00.000000000 -0500
11916 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_base.h 2007-12-09 06:44:22.000000000 -0500
11918 +#ifndef _VS_BASE_H
11919 +#define _VS_BASE_H
11921 +#include "vserver/base.h"
11922 +#include "vserver/debug.h"
11925 +#warning duplicate inclusion
11927 diff -Nurp linux-2.6.22.15/include/linux/vs_context.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_context.h
11928 --- linux-2.6.22.15/include/linux/vs_context.h 1969-12-31 19:00:00.000000000 -0500
11929 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_context.h 2007-12-09 06:44:22.000000000 -0500
11931 +#ifndef _VS_CONTEXT_H
11932 +#define _VS_CONTEXT_H
11934 +#include "vserver/base.h"
11935 +#include "vserver/context.h"
11936 +#include "vserver/history.h"
11937 +#include "vserver/debug.h"
11940 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
11942 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
11943 + const char *_file, int _line, void *_here)
11948 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
11949 + vxi, vxi ? vxi->vx_id : 0,
11950 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11952 + __vxh_get_vx_info(vxi, _here);
11954 + atomic_inc(&vxi->vx_usecnt);
11959 +extern void free_vx_info(struct vx_info *);
11961 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
11963 +static inline void __put_vx_info(struct vx_info *vxi,
11964 + const char *_file, int _line, void *_here)
11969 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
11970 + vxi, vxi ? vxi->vx_id : 0,
11971 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11973 + __vxh_put_vx_info(vxi, _here);
11975 + if (atomic_dec_and_test(&vxi->vx_usecnt))
11976 + free_vx_info(vxi);
11980 +#define init_vx_info(p, i) \
11981 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11983 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11984 + const char *_file, int _line, void *_here)
11987 + vxlprintk(VXD_CBIT(xid, 3),
11988 + "init_vx_info(%p[#%d.%d])",
11989 + vxi, vxi ? vxi->vx_id : 0,
11990 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11992 + __vxh_init_vx_info(vxi, vxp, _here);
11994 + atomic_inc(&vxi->vx_usecnt);
12000 +#define set_vx_info(p, i) \
12001 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
12003 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
12004 + const char *_file, int _line, void *_here)
12006 + struct vx_info *vxo;
12011 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
12012 + vxi, vxi ? vxi->vx_id : 0,
12013 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12015 + __vxh_set_vx_info(vxi, vxp, _here);
12017 + atomic_inc(&vxi->vx_usecnt);
12018 + vxo = xchg(vxp, vxi);
12023 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
12025 +static inline void __clr_vx_info(struct vx_info **vxp,
12026 + const char *_file, int _line, void *_here)
12028 + struct vx_info *vxo;
12030 + vxo = xchg(vxp, NULL);
12034 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
12035 + vxo, vxo ? vxo->vx_id : 0,
12036 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
12038 + __vxh_clr_vx_info(vxo, vxp, _here);
12040 + if (atomic_dec_and_test(&vxo->vx_usecnt))
12041 + free_vx_info(vxo);
12045 +#define claim_vx_info(v, p) \
12046 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
12048 +static inline void __claim_vx_info(struct vx_info *vxi,
12049 + struct task_struct *task,
12050 + const char *_file, int _line, void *_here)
12052 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
12053 + vxi, vxi ? vxi->vx_id : 0,
12054 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12055 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
12056 + task, _file, _line);
12057 + __vxh_claim_vx_info(vxi, task, _here);
12059 + atomic_inc(&vxi->vx_tasks);
12063 +extern void unhash_vx_info(struct vx_info *);
12065 +#define release_vx_info(v, p) \
12066 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
12068 +static inline void __release_vx_info(struct vx_info *vxi,
12069 + struct task_struct *task,
12070 + const char *_file, int _line, void *_here)
12072 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
12073 + vxi, vxi ? vxi->vx_id : 0,
12074 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12075 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
12076 + task, _file, _line);
12077 + __vxh_release_vx_info(vxi, task, _here);
12081 + if (atomic_dec_and_test(&vxi->vx_tasks))
12082 + unhash_vx_info(vxi);
12086 +#define task_get_vx_info(p) \
12087 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
12089 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
12090 + const char *_file, int _line, void *_here)
12092 + struct vx_info *vxi;
12095 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
12096 + p, _file, _line);
12097 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
12103 +static inline void __wakeup_vx_info(struct vx_info *vxi)
12105 + if (waitqueue_active(&vxi->vx_wait))
12106 + wake_up_interruptible(&vxi->vx_wait);
12110 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
12112 +static inline void __enter_vx_info(struct vx_info *vxi,
12113 + struct vx_info_save *vxis, const char *_file, int _line)
12115 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
12116 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
12117 + current->xid, current->vx_info, _file, _line);
12118 + vxis->vxi = xchg(¤t->vx_info, vxi);
12119 + vxis->xid = current->xid;
12120 + current->xid = vxi ? vxi->vx_id : 0;
12123 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
12125 +static inline void __leave_vx_info(struct vx_info_save *vxis,
12126 + const char *_file, int _line)
12128 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
12129 + vxis, vxis->xid, vxis->vxi, current,
12130 + current->xid, current->vx_info, _file, _line);
12131 + (void)xchg(¤t->vx_info, vxis->vxi);
12132 + current->xid = vxis->xid;
12136 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
12138 + vxis->vxi = xchg(¤t->vx_info, NULL);
12139 + vxis->xid = xchg(¤t->xid, (xid_t)0);
12142 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
12144 + (void)xchg(¤t->xid, vxis->xid);
12145 + (void)xchg(¤t->vx_info, vxis->vxi);
12148 +extern void exit_vx_info(struct task_struct *, int);
12149 +extern void exit_vx_info_early(struct task_struct *, int);
12153 +#warning duplicate inclusion
12155 diff -Nurp linux-2.6.22.15/include/linux/vs_cowbl.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_cowbl.h
12156 --- linux-2.6.22.15/include/linux/vs_cowbl.h 1969-12-31 19:00:00.000000000 -0500
12157 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_cowbl.h 2007-12-09 06:44:22.000000000 -0500
12159 +#ifndef _VS_COWBL_H
12160 +#define _VS_COWBL_H
12162 +#include <linux/fs.h>
12163 +#include <linux/dcache.h>
12164 +#include <linux/namei.h>
12166 +extern struct dentry *cow_break_link(const char *pathname);
12168 +static inline int cow_check_and_break(struct nameidata *nd)
12170 + struct inode *inode = nd->dentry->d_inode;
12172 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
12174 + if (IS_COW(inode)) {
12175 + if (IS_COW_LINK(inode)) {
12176 + struct dentry *new_dentry, *old_dentry = nd->dentry;
12177 + char *path, *buf;
12179 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
12183 + path = d_path(nd->dentry, nd->mnt, buf, PATH_MAX);
12184 + new_dentry = cow_break_link(path);
12186 + if (!IS_ERR(new_dentry)) {
12187 + nd->dentry = new_dentry;
12188 + dput(old_dentry);
12190 + error = PTR_ERR(new_dentry);
12192 + inode->i_flags &= ~(S_IUNLINK | S_IMMUTABLE);
12193 + inode->i_ctime = CURRENT_TIME;
12194 + mark_inode_dirty(inode);
12201 +#warning duplicate inclusion
12203 diff -Nurp linux-2.6.22.15/include/linux/vs_cvirt.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_cvirt.h
12204 --- linux-2.6.22.15/include/linux/vs_cvirt.h 1969-12-31 19:00:00.000000000 -0500
12205 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_cvirt.h 2007-12-09 06:44:22.000000000 -0500
12207 +#ifndef _VS_CVIRT_H
12208 +#define _VS_CVIRT_H
12210 +#include "vserver/cvirt.h"
12211 +#include "vserver/context.h"
12212 +#include "vserver/base.h"
12213 +#include "vserver/debug.h"
12216 +static inline void vx_activate_task(struct task_struct *p)
12218 + struct vx_info *vxi;
12220 + if ((vxi = p->vx_info)) {
12221 + vx_update_load(vxi);
12222 + atomic_inc(&vxi->cvirt.nr_running);
12226 +static inline void vx_deactivate_task(struct task_struct *p)
12228 + struct vx_info *vxi;
12230 + if ((vxi = p->vx_info)) {
12231 + vx_update_load(vxi);
12232 + atomic_dec(&vxi->cvirt.nr_running);
12236 +static inline void vx_uninterruptible_inc(struct task_struct *p)
12238 + struct vx_info *vxi;
12240 + if ((vxi = p->vx_info))
12241 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
12244 +static inline void vx_uninterruptible_dec(struct task_struct *p)
12246 + struct vx_info *vxi;
12248 + if ((vxi = p->vx_info))
12249 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
12254 +#warning duplicate inclusion
12256 diff -Nurp linux-2.6.22.15/include/linux/vs_device.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_device.h
12257 --- linux-2.6.22.15/include/linux/vs_device.h 1969-12-31 19:00:00.000000000 -0500
12258 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_device.h 2007-12-09 06:44:22.000000000 -0500
12260 +#ifndef _VS_DEVICE_H
12261 +#define _VS_DEVICE_H
12263 +#include "vserver/base.h"
12264 +#include "vserver/device.h"
12265 +#include "vserver/debug.h"
12268 +#ifdef CONFIG_VSERVER_DEVICE
12270 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
12272 +#define vs_device_perm(v, d, m, p) \
12273 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
12278 +int vs_map_device(struct vx_info *vxi,
12279 + dev_t device, dev_t *target, umode_t mode)
12282 + *target = device;
12286 +#define vs_device_perm(v, d, m, p) ((p) == (p))
12291 +#define vs_map_chrdev(d, t, p) \
12292 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
12293 +#define vs_map_blkdev(d, t, p) \
12294 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
12296 +#define vs_chrdev_perm(d, p) \
12297 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
12298 +#define vs_blkdev_perm(d, p) \
12299 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
12303 +#warning duplicate inclusion
12305 diff -Nurp linux-2.6.22.15/include/linux/vs_dlimit.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_dlimit.h
12306 --- linux-2.6.22.15/include/linux/vs_dlimit.h 1969-12-31 19:00:00.000000000 -0500
12307 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_dlimit.h 2007-12-09 06:44:22.000000000 -0500
12309 +#ifndef _VS_DLIMIT_H
12310 +#define _VS_DLIMIT_H
12312 +#include <linux/fs.h>
12314 +#include "vserver/dlimit.h"
12315 +#include "vserver/base.h"
12316 +#include "vserver/debug.h"
12319 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
12321 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
12322 + const char *_file, int _line)
12326 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
12327 + dli, dli ? dli->dl_tag : 0,
12328 + dli ? atomic_read(&dli->dl_usecnt) : 0,
12330 + atomic_inc(&dli->dl_usecnt);
12335 +#define free_dl_info(i) \
12336 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
12338 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
12340 +static inline void __put_dl_info(struct dl_info *dli,
12341 + const char *_file, int _line)
12345 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
12346 + dli, dli ? dli->dl_tag : 0,
12347 + dli ? atomic_read(&dli->dl_usecnt) : 0,
12349 + if (atomic_dec_and_test(&dli->dl_usecnt))
12350 + free_dl_info(dli);
12354 +#define __dlimit_char(d) ((d) ? '*' : ' ')
12356 +static inline int __dl_alloc_space(struct super_block *sb,
12357 + tag_t tag, dlsize_t nr, const char *file, int line)
12359 + struct dl_info *dli = NULL;
12364 + dli = locate_dl_info(sb, tag);
12368 + spin_lock(&dli->dl_lock);
12369 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
12371 + dli->dl_space_used += nr;
12372 + spin_unlock(&dli->dl_lock);
12373 + put_dl_info(dli);
12375 + vxlprintk(VXD_CBIT(dlim, 1),
12376 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
12377 + sb, tag, __dlimit_char(dli), (long long)nr,
12378 + ret, file, line);
12382 +static inline void __dl_free_space(struct super_block *sb,
12383 + tag_t tag, dlsize_t nr, const char *_file, int _line)
12385 + struct dl_info *dli = NULL;
12389 + dli = locate_dl_info(sb, tag);
12393 + spin_lock(&dli->dl_lock);
12394 + if (dli->dl_space_used > nr)
12395 + dli->dl_space_used -= nr;
12397 + dli->dl_space_used = 0;
12398 + spin_unlock(&dli->dl_lock);
12399 + put_dl_info(dli);
12401 + vxlprintk(VXD_CBIT(dlim, 1),
12402 + "FREE (%p,#%d)%c %lld bytes",
12403 + sb, tag, __dlimit_char(dli), (long long)nr,
12407 +static inline int __dl_alloc_inode(struct super_block *sb,
12408 + tag_t tag, const char *_file, int _line)
12410 + struct dl_info *dli;
12413 + dli = locate_dl_info(sb, tag);
12417 + spin_lock(&dli->dl_lock);
12418 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
12420 + dli->dl_inodes_used++;
12421 + spin_unlock(&dli->dl_lock);
12422 + put_dl_info(dli);
12424 + vxlprintk(VXD_CBIT(dlim, 0),
12425 + "ALLOC (%p,#%d)%c inode (%d)",
12426 + sb, tag, __dlimit_char(dli), ret, _file, _line);
12430 +static inline void __dl_free_inode(struct super_block *sb,
12431 + tag_t tag, const char *_file, int _line)
12433 + struct dl_info *dli;
12435 + dli = locate_dl_info(sb, tag);
12439 + spin_lock(&dli->dl_lock);
12440 + if (dli->dl_inodes_used > 1)
12441 + dli->dl_inodes_used--;
12443 + dli->dl_inodes_used = 0;
12444 + spin_unlock(&dli->dl_lock);
12445 + put_dl_info(dli);
12447 + vxlprintk(VXD_CBIT(dlim, 0),
12448 + "FREE (%p,#%d)%c inode",
12449 + sb, tag, __dlimit_char(dli), _file, _line);
12452 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
12453 + unsigned long long *free_blocks, unsigned long long *root_blocks,
12454 + const char *_file, int _line)
12456 + struct dl_info *dli;
12457 + uint64_t broot, bfree;
12459 + dli = locate_dl_info(sb, tag);
12463 + spin_lock(&dli->dl_lock);
12464 + broot = (dli->dl_space_total -
12465 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
12466 + >> sb->s_blocksize_bits;
12467 + bfree = (dli->dl_space_total - dli->dl_space_used)
12468 + >> sb->s_blocksize_bits;
12469 + spin_unlock(&dli->dl_lock);
12471 + vxlprintk(VXD_CBIT(dlim, 2),
12472 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
12473 + (long long)bfree, (long long)broot,
12474 + *free_blocks, *root_blocks, dli->dl_nrlmult,
12476 + if (free_blocks) {
12477 + if (*free_blocks > bfree)
12478 + *free_blocks = bfree;
12480 + if (root_blocks) {
12481 + if (*root_blocks > broot)
12482 + *root_blocks = broot;
12484 + put_dl_info(dli);
12487 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
12488 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
12489 + __FILE__, __LINE__ )
12491 +#define DLIMIT_FREE_SPACE(in, bytes) \
12492 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
12493 + __FILE__, __LINE__ )
12495 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
12496 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
12497 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
12498 + __FILE__, __LINE__ )
12500 +#define DLIMIT_FREE_BLOCK(in, nr) \
12501 + __dl_free_space((in)->i_sb, (in)->i_tag, \
12502 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
12503 + __FILE__, __LINE__ )
12506 +#define DLIMIT_ALLOC_INODE(in) \
12507 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
12509 +#define DLIMIT_FREE_INODE(in) \
12510 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
12513 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
12514 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
12518 +#warning duplicate inclusion
12520 diff -Nurp linux-2.6.22.15/include/linux/vserver/base.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/base.h
12521 --- linux-2.6.22.15/include/linux/vserver/base.h 1969-12-31 19:00:00.000000000 -0500
12522 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/base.h 2007-12-09 06:44:22.000000000 -0500
12524 +#ifndef _VX_BASE_H
12525 +#define _VX_BASE_H
12528 +/* context state changes */
12539 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
12541 +/* check conditions */
12543 +#define VS_ADMIN 0x0001
12544 +#define VS_WATCH 0x0002
12545 +#define VS_HIDE 0x0004
12546 +#define VS_HOSTID 0x0008
12548 +#define VS_IDENT 0x0010
12549 +#define VS_EQUIV 0x0020
12550 +#define VS_PARENT 0x0040
12551 +#define VS_CHILD 0x0080
12553 +#define VS_ARG_MASK 0x00F0
12555 +#ifdef CONFIG_VSERVER_PRIVACY
12556 +#define VS_ADMIN_P (0)
12557 +#define VS_WATCH_P (0)
12559 +#define VS_ADMIN_P VS_ADMIN
12560 +#define VS_WATCH_P VS_WATCH
12563 +#define VS_HARDIRQ 0x1000
12564 +#define VS_SOFTIRQ 0x2000
12565 +#define VS_IRQ 0x4000
12567 +#define VS_IRQ_MASK 0xF000
12569 +#include <linux/hardirq.h>
12572 + * check current context for ADMIN/WATCH and
12573 + * optionally against supplied argument
12575 +static inline int __vs_check(int cid, int id, unsigned int mode)
12577 + if (mode & VS_ARG_MASK) {
12578 + if ((mode & VS_IDENT) && (id == cid))
12581 + if (mode & VS_IRQ_MASK) {
12582 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
12584 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
12586 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
12589 + return (((mode & VS_ADMIN) && (cid == 0)) ||
12590 + ((mode & VS_WATCH) && (cid == 1)) ||
12591 + ((mode & VS_HOSTID) && (id == 0)));
12594 +#define vx_task_xid(t) ((t)->xid)
12596 +#define vx_current_xid() vx_task_xid(current)
12598 +#define current_vx_info() (current->vx_info)
12601 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
12603 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
12606 +#define nx_task_nid(t) ((t)->nid)
12608 +#define nx_current_nid() nx_task_nid(current)
12610 +#define current_nx_info() (current->nx_info)
12613 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
12615 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
12619 +/* generic flag merging */
12621 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
12623 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
12625 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
12627 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
12630 +/* context flags */
12632 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
12634 +#define vx_current_flags() __vx_flags(current->vx_info)
12636 +#define vx_info_flags(v, m, f) \
12637 + vs_check_flags(__vx_flags(v), m, f)
12639 +#define task_vx_flags(t, m, f) \
12640 + ((t) && vx_info_flags((t)->vx_info, m, f))
12642 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
12645 +/* context caps */
12647 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
12649 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
12651 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
12653 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
12657 +/* network flags */
12659 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
12661 +#define nx_current_flags() __nx_flags(current->nx_info)
12663 +#define nx_info_flags(n, m, f) \
12664 + vs_check_flags(__nx_flags(n), m, f)
12666 +#define task_nx_flags(t, m, f) \
12667 + ((t) && nx_info_flags((t)->nx_info, m, f))
12669 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
12672 +/* network caps */
12674 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
12676 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
12678 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
12680 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
12683 +/* context mask capabilities */
12685 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
12687 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
12689 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
12692 +/* context bcap mask */
12694 +#define __vx_bcaps(v) ((v) ? (v)->vx_bcaps : ~0 )
12696 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
12698 +#define vx_info_bcaps(v, c) (__vx_bcaps(v) & (c))
12700 +#define vx_bcaps(c) vx_info_bcaps(current->vx_info, c)
12703 +#define vx_info_cap_bset(v) ((v) ? (v)->vx_cap_bset : cap_bset)
12705 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
12708 +#define __vx_info_mbcap(v, b) \
12709 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
12710 + vx_info_bcaps(v, b) : (b))
12712 +#define vx_info_mbcap(v, b) __vx_info_mbcap(v, cap_t(b))
12714 +#define task_vx_mbcap(t, b) \
12715 + vx_info_mbcap((t)->vx_info, (t)->b)
12717 +#define vx_mbcap(b) task_vx_mbcap(current, b)
12719 +#define vx_cap_raised(v, c, f) (vx_info_mbcap(v, c) & CAP_TO_MASK(f))
12721 +#define vx_capable(b, c) (capable(b) || \
12722 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
12724 +#define nx_capable(b, c) (capable(b) || \
12725 + (cap_raised(current->cap_effective, b) && nx_ncaps(c)))
12727 +#define vx_current_initpid(n) \
12728 + (current->vx_info && \
12729 + (current->vx_info->vx_initpid == (n)))
12732 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
12734 +#define vx_info_state(v, m) (__vx_state(v) & (m))
12737 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
12739 +#define nx_info_state(n, m) (__nx_state(n) & (m))
12742 diff -Nurp linux-2.6.22.15/include/linux/vserver/cacct_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cacct_cmd.h
12743 --- linux-2.6.22.15/include/linux/vserver/cacct_cmd.h 1969-12-31 19:00:00.000000000 -0500
12744 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cacct_cmd.h 2007-12-09 06:44:22.000000000 -0500
12746 +#ifndef _VX_CACCT_CMD_H
12747 +#define _VX_CACCT_CMD_H
12750 +/* virtual host info name commands */
12752 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
12754 +struct vcmd_sock_stat_v0 {
12756 + uint32_t count[3];
12757 + uint64_t total[3];
12763 +#include <linux/compiler.h>
12765 +extern int vc_sock_stat(struct vx_info *, void __user *);
12767 +#endif /* __KERNEL__ */
12768 +#endif /* _VX_CACCT_CMD_H */
12769 diff -Nurp linux-2.6.22.15/include/linux/vserver/cacct_def.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cacct_def.h
12770 --- linux-2.6.22.15/include/linux/vserver/cacct_def.h 1969-12-31 19:00:00.000000000 -0500
12771 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cacct_def.h 2007-12-09 06:44:22.000000000 -0500
12773 +#ifndef _VX_CACCT_DEF_H
12774 +#define _VX_CACCT_DEF_H
12776 +#include <asm/atomic.h>
12777 +#include <linux/vserver/cacct.h>
12780 +struct _vx_sock_acc {
12781 + atomic_long_t count;
12782 + atomic_long_t total;
12785 +/* context sub struct */
12787 +struct _vx_cacct {
12788 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
12789 + atomic_t slab[8];
12790 + atomic_t page[6][8];
12793 +#ifdef CONFIG_VSERVER_DEBUG
12795 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
12799 + printk("\t_vx_cacct:");
12800 + for (i = 0; i < 6; i++) {
12801 + struct _vx_sock_acc *ptr = cacct->sock[i];
12803 + printk("\t [%d] =", i);
12804 + for (j = 0; j < 3; j++) {
12805 + printk(" [%d] = %8lu, %8lu", j,
12806 + atomic_long_read(&ptr[j].count),
12807 + atomic_long_read(&ptr[j].total));
12815 +#endif /* _VX_CACCT_DEF_H */
12816 diff -Nurp linux-2.6.22.15/include/linux/vserver/cacct.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cacct.h
12817 --- linux-2.6.22.15/include/linux/vserver/cacct.h 1969-12-31 19:00:00.000000000 -0500
12818 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cacct.h 2007-12-09 06:44:22.000000000 -0500
12820 +#ifndef _VX_CACCT_H
12821 +#define _VX_CACCT_H
12824 +enum sock_acc_field {
12825 + VXA_SOCK_UNSPEC = 0,
12831 + VXA_SOCK_SIZE /* array size */
12834 +#endif /* _VX_CACCT_H */
12835 diff -Nurp linux-2.6.22.15/include/linux/vserver/cacct_int.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cacct_int.h
12836 --- linux-2.6.22.15/include/linux/vserver/cacct_int.h 1969-12-31 19:00:00.000000000 -0500
12837 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cacct_int.h 2007-12-09 06:44:22.000000000 -0500
12839 +#ifndef _VX_CACCT_INT_H
12840 +#define _VX_CACCT_INT_H
12846 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
12848 + return atomic_long_read(&cacct->sock[type][pos].count);
12853 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
12855 + return atomic_long_read(&cacct->sock[type][pos].total);
12858 +#endif /* __KERNEL__ */
12859 +#endif /* _VX_CACCT_INT_H */
12860 diff -Nurp linux-2.6.22.15/include/linux/vserver/context_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/context_cmd.h
12861 --- linux-2.6.22.15/include/linux/vserver/context_cmd.h 1969-12-31 19:00:00.000000000 -0500
12862 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/context_cmd.h 2007-12-09 06:44:22.000000000 -0500
12864 +#ifndef _VX_CONTEXT_CMD_H
12865 +#define _VX_CONTEXT_CMD_H
12868 +/* vinfo commands */
12870 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
12873 +extern int vc_task_xid(uint32_t);
12875 +#endif /* __KERNEL__ */
12877 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
12879 +struct vcmd_vx_info_v0 {
12881 + uint32_t initpid;
12882 + /* more to come */
12886 +extern int vc_vx_info(struct vx_info *, void __user *);
12888 +#endif /* __KERNEL__ */
12890 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
12892 +struct vcmd_ctx_stat_v0 {
12895 + /* more to come */
12899 +extern int vc_ctx_stat(struct vx_info *, void __user *);
12901 +#endif /* __KERNEL__ */
12903 +/* context commands */
12905 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
12906 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
12908 +struct vcmd_ctx_create {
12909 + uint64_t flagword;
12912 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
12913 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
12915 +struct vcmd_ctx_migrate {
12916 + uint64_t flagword;
12920 +extern int vc_ctx_create(uint32_t, void __user *);
12921 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
12923 +#endif /* __KERNEL__ */
12926 +/* flag commands */
12928 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
12929 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
12931 +struct vcmd_ctx_flags_v0 {
12932 + uint64_t flagword;
12937 +extern int vc_get_cflags(struct vx_info *, void __user *);
12938 +extern int vc_set_cflags(struct vx_info *, void __user *);
12940 +#endif /* __KERNEL__ */
12943 +/* context caps commands */
12945 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
12946 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
12948 +struct vcmd_ctx_caps_v1 {
12954 +extern int vc_get_ccaps(struct vx_info *, void __user *);
12955 +extern int vc_set_ccaps(struct vx_info *, void __user *);
12957 +#endif /* __KERNEL__ */
12960 +/* bcaps commands */
12962 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
12963 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
12965 +struct vcmd_bcaps {
12971 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12972 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12974 +#endif /* __KERNEL__ */
12979 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
12980 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
12982 +struct vcmd_badness_v0 {
12987 +extern int vc_get_badness(struct vx_info *, void __user *);
12988 +extern int vc_set_badness(struct vx_info *, void __user *);
12990 +#endif /* __KERNEL__ */
12991 +#endif /* _VX_CONTEXT_CMD_H */
12992 diff -Nurp linux-2.6.22.15/include/linux/vserver/context.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/context.h
12993 --- linux-2.6.22.15/include/linux/vserver/context.h 1969-12-31 19:00:00.000000000 -0500
12994 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/context.h 2007-12-09 06:44:22.000000000 -0500
12996 +#ifndef _VX_CONTEXT_H
12997 +#define _VX_CONTEXT_H
12999 +#include <linux/types.h>
13000 +#include <linux/capability.h>
13003 +/* context flags */
13005 +#define VXF_INFO_SCHED 0x00000002
13006 +#define VXF_INFO_NPROC 0x00000004
13007 +#define VXF_INFO_PRIVATE 0x00000008
13009 +#define VXF_INFO_INIT 0x00000010
13010 +#define VXF_INFO_HIDE 0x00000020
13011 +#define VXF_INFO_ULIMIT 0x00000040
13012 +#define VXF_INFO_NSPACE 0x00000080
13014 +#define VXF_SCHED_HARD 0x00000100
13015 +#define VXF_SCHED_PRIO 0x00000200
13016 +#define VXF_SCHED_PAUSE 0x00000400
13018 +#define VXF_VIRT_MEM 0x00010000
13019 +#define VXF_VIRT_UPTIME 0x00020000
13020 +#define VXF_VIRT_CPU 0x00040000
13021 +#define VXF_VIRT_LOAD 0x00080000
13022 +#define VXF_VIRT_TIME 0x00100000
13024 +#define VXF_HIDE_MOUNT 0x01000000
13025 +/* was VXF_HIDE_NETIF 0x02000000 */
13026 +#define VXF_HIDE_VINFO 0x04000000
13028 +#define VXF_STATE_SETUP (1ULL << 32)
13029 +#define VXF_STATE_INIT (1ULL << 33)
13030 +#define VXF_STATE_ADMIN (1ULL << 34)
13032 +#define VXF_SC_HELPER (1ULL << 36)
13033 +#define VXF_REBOOT_KILL (1ULL << 37)
13034 +#define VXF_PERSISTENT (1ULL << 38)
13036 +#define VXF_FORK_RSS (1ULL << 48)
13037 +#define VXF_PROLIFIC (1ULL << 49)
13039 +#define VXF_IGNEG_NICE (1ULL << 52)
13041 +#define VXF_ONE_TIME (0x0007ULL << 32)
13043 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
13046 +/* context migration */
13048 +#define VXM_SET_INIT 0x00000001
13049 +#define VXM_SET_REAPER 0x00000002
13051 +/* context caps */
13053 +#define VXC_CAP_MASK 0x00000000
13055 +#define VXC_SET_UTSNAME 0x00000001
13056 +#define VXC_SET_RLIMIT 0x00000002
13058 +/* was VXC_RAW_ICMP 0x00000100 */
13059 +#define VXC_SYSLOG 0x00001000
13061 +#define VXC_SECURE_MOUNT 0x00010000
13062 +#define VXC_SECURE_REMOUNT 0x00020000
13063 +#define VXC_BINARY_MOUNT 0x00040000
13065 +#define VXC_QUOTA_CTL 0x00100000
13066 +#define VXC_ADMIN_MAPPER 0x00200000
13067 +#define VXC_ADMIN_CLOOP 0x00400000
13069 +#define VXC_KTHREAD 0x01000000
13074 +#include <linux/list.h>
13075 +#include <linux/spinlock.h>
13076 +#include <linux/rcupdate.h>
13078 +#include "limit_def.h"
13079 +#include "sched_def.h"
13080 +#include "cvirt_def.h"
13081 +#include "cacct_def.h"
13082 +#include "device_def.h"
13084 +struct _vx_info_pc {
13085 + struct _vx_sched_pc sched_pc;
13086 + struct _vx_cvirt_pc cvirt_pc;
13090 + struct hlist_node vx_hlist; /* linked list of contexts */
13091 + xid_t vx_id; /* context id */
13092 + atomic_t vx_usecnt; /* usage count */
13093 + atomic_t vx_tasks; /* tasks count */
13094 + struct vx_info *vx_parent; /* parent context */
13095 + int vx_state; /* context state */
13097 + unsigned long vx_nsmask; /* assignment mask */
13098 + struct nsproxy *vx_nsproxy; /* private namespace */
13099 + struct fs_struct *vx_fs; /* private namespace fs */
13101 + uint64_t vx_flags; /* context flags */
13102 + uint64_t vx_bcaps; /* bounding caps (system) */
13103 + uint64_t vx_ccaps; /* context caps (vserver) */
13104 + kernel_cap_t vx_cap_bset; /* the guest's bset */
13106 + struct task_struct *vx_reaper; /* guest reaper process */
13107 + pid_t vx_initpid; /* PID of guest init */
13108 + int64_t vx_badness_bias; /* OOM points bias */
13110 + struct _vx_limit limit; /* vserver limits */
13111 + struct _vx_sched sched; /* vserver scheduler */
13112 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
13113 + struct _vx_cacct cacct; /* context accounting */
13115 + struct _vx_device dmap; /* default device map targets */
13117 +#ifndef CONFIG_SMP
13118 + struct _vx_info_pc info_pc; /* per cpu data */
13120 + struct _vx_info_pc *ptr_pc; /* per cpu array */
13123 + wait_queue_head_t vx_wait; /* context exit waitqueue */
13124 + int reboot_cmd; /* last sys_reboot() cmd */
13125 + int exit_code; /* last process exit code */
13127 + char vx_name[65]; /* vserver name */
13130 +#ifndef CONFIG_SMP
13131 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
13132 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
13134 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
13135 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
13138 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
13141 +struct vx_info_save {
13142 + struct vx_info *vxi;
13147 +/* status flags */
13149 +#define VXS_HASHED 0x0001
13150 +#define VXS_PAUSED 0x0010
13151 +#define VXS_SHUTDOWN 0x0100
13152 +#define VXS_HELPER 0x1000
13153 +#define VXS_RELEASED 0x8000
13156 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
13157 +extern void release_vx_info(struct vx_info *, struct task_struct *);
13159 +extern struct vx_info *lookup_vx_info(int);
13160 +extern struct vx_info *lookup_or_create_vx_info(int);
13162 +extern int get_xid_list(int, unsigned int *, int);
13163 +extern int xid_is_hashed(xid_t);
13165 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
13167 +extern long vs_state_change(struct vx_info *, unsigned int);
13170 +#endif /* __KERNEL__ */
13171 +#endif /* _VX_CONTEXT_H */
13172 diff -Nurp linux-2.6.22.15/include/linux/vserver/cvirt_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cvirt_cmd.h
13173 --- linux-2.6.22.15/include/linux/vserver/cvirt_cmd.h 1969-12-31 19:00:00.000000000 -0500
13174 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cvirt_cmd.h 2007-12-09 06:44:22.000000000 -0500
13176 +#ifndef _VX_CVIRT_CMD_H
13177 +#define _VX_CVIRT_CMD_H
13180 +/* virtual host info name commands */
13182 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
13183 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
13185 +struct vcmd_vhi_name_v0 {
13191 +enum vhi_name_field {
13192 + VHIN_CONTEXT = 0,
13204 +#include <linux/compiler.h>
13206 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
13207 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
13209 +#endif /* __KERNEL__ */
13211 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
13213 +struct vcmd_virt_stat_v0 {
13216 + uint32_t nr_threads;
13217 + uint32_t nr_running;
13218 + uint32_t nr_uninterruptible;
13219 + uint32_t nr_onhold;
13220 + uint32_t nr_forks;
13221 + uint32_t load[3];
13225 +extern int vc_virt_stat(struct vx_info *, void __user *);
13227 +#endif /* __KERNEL__ */
13228 +#endif /* _VX_CVIRT_CMD_H */
13229 diff -Nurp linux-2.6.22.15/include/linux/vserver/cvirt_def.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cvirt_def.h
13230 --- linux-2.6.22.15/include/linux/vserver/cvirt_def.h 1969-12-31 19:00:00.000000000 -0500
13231 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cvirt_def.h 2007-12-09 06:44:22.000000000 -0500
13233 +#ifndef _VX_CVIRT_DEF_H
13234 +#define _VX_CVIRT_DEF_H
13236 +#include <linux/jiffies.h>
13237 +#include <linux/spinlock.h>
13238 +#include <linux/wait.h>
13239 +#include <linux/time.h>
13240 +#include <linux/utsname.h>
13241 +#include <asm/atomic.h>
13244 +struct _vx_usage_stat {
13248 + uint64_t softirq;
13254 +struct _vx_syslog {
13255 + wait_queue_head_t log_wait;
13256 + spinlock_t logbuf_lock; /* lock for the log buffer */
13258 + unsigned long log_start; /* next char to be read by syslog() */
13259 + unsigned long con_start; /* next char to be sent to consoles */
13260 + unsigned long log_end; /* most-recently-written-char + 1 */
13261 + unsigned long logged_chars; /* #chars since last read+clear operation */
13263 + char log_buf[1024];
13267 +/* context sub struct */
13269 +struct _vx_cvirt {
13270 + atomic_t nr_threads; /* number of current threads */
13271 + atomic_t nr_running; /* number of running threads */
13272 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
13274 + atomic_t nr_onhold; /* processes on hold */
13275 + uint32_t onhold_last; /* jiffies when put on hold */
13277 + struct timeval bias_tv; /* time offset to the host */
13278 + struct timespec bias_idle;
13279 + struct timespec bias_uptime; /* context creation point */
13280 + uint64_t bias_clock; /* offset in clock_t */
13282 + spinlock_t load_lock; /* lock for the load averages */
13283 + atomic_t load_updates; /* nr of load updates done so far */
13284 + uint32_t load_last; /* last time load was calculated */
13285 + uint32_t load[3]; /* load averages 1,5,15 */
13287 + atomic_t total_forks; /* number of forks so far */
13289 + struct _vx_syslog syslog;
13292 +struct _vx_cvirt_pc {
13293 + struct _vx_usage_stat cpustat;
13297 +#ifdef CONFIG_VSERVER_DEBUG
13299 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
13301 + printk("\t_vx_cvirt:\n");
13302 + printk("\t threads: %4d, %4d, %4d, %4d\n",
13303 + atomic_read(&cvirt->nr_threads),
13304 + atomic_read(&cvirt->nr_running),
13305 + atomic_read(&cvirt->nr_uninterruptible),
13306 + atomic_read(&cvirt->nr_onhold));
13307 + /* add rest here */
13308 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
13313 +#endif /* _VX_CVIRT_DEF_H */
13314 diff -Nurp linux-2.6.22.15/include/linux/vserver/cvirt.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cvirt.h
13315 --- linux-2.6.22.15/include/linux/vserver/cvirt.h 1969-12-31 19:00:00.000000000 -0500
13316 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/cvirt.h 2007-12-09 06:44:22.000000000 -0500
13318 +#ifndef _VX_CVIRT_H
13319 +#define _VX_CVIRT_H
13326 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13331 +void vx_update_load(struct vx_info *);
13334 +int vx_do_syslog(int, char __user *, int);
13336 +#endif /* __KERNEL__ */
13337 +#endif /* _VX_CVIRT_H */
13338 diff -Nurp linux-2.6.22.15/include/linux/vserver/debug_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/debug_cmd.h
13339 --- linux-2.6.22.15/include/linux/vserver/debug_cmd.h 1969-12-31 19:00:00.000000000 -0500
13340 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/debug_cmd.h 2007-12-09 06:44:22.000000000 -0500
13342 +#ifndef _VX_DEBUG_CMD_H
13343 +#define _VX_DEBUG_CMD_H
13346 +/* debug commands */
13348 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
13350 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
13351 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
13353 +struct vcmd_read_history_v0 {
13356 + char __user *data;
13359 +struct vcmd_read_monitor_v0 {
13362 + char __user *data;
13368 +#ifdef CONFIG_COMPAT
13370 +#include <asm/compat.h>
13372 +struct vcmd_read_history_v0_x32 {
13375 + compat_uptr_t data_ptr;
13378 +struct vcmd_read_monitor_v0_x32 {
13381 + compat_uptr_t data_ptr;
13384 +#endif /* CONFIG_COMPAT */
13386 +extern int vc_dump_history(uint32_t);
13388 +extern int vc_read_history(uint32_t, void __user *);
13389 +extern int vc_read_monitor(uint32_t, void __user *);
13391 +#ifdef CONFIG_COMPAT
13393 +extern int vc_read_history_x32(uint32_t, void __user *);
13394 +extern int vc_read_monitor_x32(uint32_t, void __user *);
13396 +#endif /* CONFIG_COMPAT */
13398 +#endif /* __KERNEL__ */
13399 +#endif /* _VX_DEBUG_CMD_H */
13400 diff -Nurp linux-2.6.22.15/include/linux/vserver/debug.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/debug.h
13401 --- linux-2.6.22.15/include/linux/vserver/debug.h 1969-12-31 19:00:00.000000000 -0500
13402 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/debug.h 2007-12-09 06:44:22.000000000 -0500
13404 +#ifndef _VX_DEBUG_H
13405 +#define _VX_DEBUG_H
13408 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
13409 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
13410 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
13412 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
13413 + imajor((d)->bd_inode), iminor((d)->bd_inode)
13414 +#define VXF_DEV "%p[%lu,%d:%d]"
13417 +#define __FUNC__ __func__
13420 +#define vxd_path(d, m) \
13421 + ({ static char _buffer[PATH_MAX]; \
13422 + d_path(d, m, _buffer, sizeof(_buffer)); })
13424 +#define vxd_cond_path(n) \
13425 + ((n) ? vxd_path((n)->dentry, (n)->mnt) : "<null>" )
13428 +#ifdef CONFIG_VSERVER_DEBUG
13430 +extern unsigned int vx_debug_switch;
13431 +extern unsigned int vx_debug_xid;
13432 +extern unsigned int vx_debug_nid;
13433 +extern unsigned int vx_debug_tag;
13434 +extern unsigned int vx_debug_net;
13435 +extern unsigned int vx_debug_limit;
13436 +extern unsigned int vx_debug_cres;
13437 +extern unsigned int vx_debug_dlim;
13438 +extern unsigned int vx_debug_quota;
13439 +extern unsigned int vx_debug_cvirt;
13440 +extern unsigned int vx_debug_space;
13441 +extern unsigned int vx_debug_misc;
13444 +#define VX_LOGLEVEL "vxD: "
13445 +#define VX_PROC_FMT "%p: "
13446 +#define VX_PROCESS current
13448 +#define vxdprintk(c, f, x...) \
13451 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
13452 + VX_PROCESS , ##x); \
13455 +#define vxlprintk(c, f, x...) \
13458 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
13461 +#define vxfprintk(c, f, x...) \
13464 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
13470 +void dump_vx_info(struct vx_info *, int);
13471 +void dump_vx_info_inactive(int);
13473 +#else /* CONFIG_VSERVER_DEBUG */
13475 +#define vx_debug_switch 0
13476 +#define vx_debug_xid 0
13477 +#define vx_debug_nid 0
13478 +#define vx_debug_tag 0
13479 +#define vx_debug_net 0
13480 +#define vx_debug_limit 0
13481 +#define vx_debug_cres 0
13482 +#define vx_debug_dlim 0
13483 +#define vx_debug_cvirt 0
13485 +#define vxdprintk(x...) do { } while (0)
13486 +#define vxlprintk(x...) do { } while (0)
13487 +#define vxfprintk(x...) do { } while (0)
13489 +#endif /* CONFIG_VSERVER_DEBUG */
13492 +#ifdef CONFIG_VSERVER_WARN
13494 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
13495 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
13496 +#define VX_WARN_XID "[xid #%u] "
13497 +#define VX_WARN_NID "[nid #%u] "
13498 +#define VX_WARN_TAG "[tag #%u] "
13500 +#define vxwprintk(c, f, x...) \
13503 + printk(VX_WARNLEVEL f "\n", ##x); \
13506 +#else /* CONFIG_VSERVER_WARN */
13508 +#define vxwprintk(x...) do { } while (0)
13510 +#endif /* CONFIG_VSERVER_WARN */
13512 +#define vxwprintk_task(c, f, x...) \
13513 + vxwprintk(c, VX_WARN_TASK f, \
13514 + current->comm, current->pid, \
13515 + current->xid, current->nid, current->tag, ##x)
13516 +#define vxwprintk_xid(c, f, x...) \
13517 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
13518 +#define vxwprintk_nid(c, f, x...) \
13519 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
13520 +#define vxwprintk_tag(c, f, x...) \
13521 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
13523 +#ifdef CONFIG_VSERVER_DEBUG
13524 +#define vxd_assert_lock(l) assert_spin_locked(l)
13525 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
13526 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
13528 +#define vxd_assert_lock(l) do { } while (0)
13529 +#define vxd_assert(c, f, x...) do { } while (0)
13533 +#endif /* _VX_DEBUG_H */
13534 diff -Nurp linux-2.6.22.15/include/linux/vserver/device_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/device_cmd.h
13535 --- linux-2.6.22.15/include/linux/vserver/device_cmd.h 1969-12-31 19:00:00.000000000 -0500
13536 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/device_cmd.h 2007-12-09 06:44:22.000000000 -0500
13538 +#ifndef _VX_DEVICE_CMD_H
13539 +#define _VX_DEVICE_CMD_H
13542 +/* device vserver commands */
13544 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
13545 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
13547 +struct vcmd_set_mapping_v0 {
13548 + const char __user *device;
13549 + const char __user *target;
13556 +#ifdef CONFIG_COMPAT
13558 +#include <asm/compat.h>
13560 +struct vcmd_set_mapping_v0_x32 {
13561 + compat_uptr_t device_ptr;
13562 + compat_uptr_t target_ptr;
13566 +#endif /* CONFIG_COMPAT */
13568 +#include <linux/compiler.h>
13570 +extern int vc_set_mapping(struct vx_info *, void __user *);
13571 +extern int vc_unset_mapping(struct vx_info *, void __user *);
13573 +#ifdef CONFIG_COMPAT
13575 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
13576 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
13578 +#endif /* CONFIG_COMPAT */
13580 +#endif /* __KERNEL__ */
13581 +#endif /* _VX_DEVICE_CMD_H */
13582 diff -Nurp linux-2.6.22.15/include/linux/vserver/device_def.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/device_def.h
13583 --- linux-2.6.22.15/include/linux/vserver/device_def.h 1969-12-31 19:00:00.000000000 -0500
13584 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/device_def.h 2007-12-09 06:44:22.000000000 -0500
13586 +#ifndef _VX_DEVICE_DEF_H
13587 +#define _VX_DEVICE_DEF_H
13589 +#include <linux/types.h>
13591 +struct vx_dmap_target {
13596 +struct _vx_device {
13597 +#ifdef CONFIG_VSERVER_DEVICE
13598 + struct vx_dmap_target targets[2];
13602 +#endif /* _VX_DEVICE_DEF_H */
13603 diff -Nurp linux-2.6.22.15/include/linux/vserver/device.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/device.h
13604 --- linux-2.6.22.15/include/linux/vserver/device.h 1969-12-31 19:00:00.000000000 -0500
13605 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/device.h 2007-12-09 06:44:22.000000000 -0500
13607 +#ifndef _VX_DEVICE_H
13608 +#define _VX_DEVICE_H
13611 +#define DATTR_CREATE 0x00000001
13612 +#define DATTR_OPEN 0x00000002
13614 +#define DATTR_REMAP 0x00000010
13616 +#define DATTR_MASK 0x00000013
13619 +#else /* _VX_DEVICE_H */
13620 +#warning duplicate inclusion
13621 +#endif /* _VX_DEVICE_H */
13622 diff -Nurp linux-2.6.22.15/include/linux/vserver/dlimit_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/dlimit_cmd.h
13623 --- linux-2.6.22.15/include/linux/vserver/dlimit_cmd.h 1969-12-31 19:00:00.000000000 -0500
13624 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/dlimit_cmd.h 2007-12-09 06:44:22.000000000 -0500
13626 +#ifndef _VX_DLIMIT_CMD_H
13627 +#define _VX_DLIMIT_CMD_H
13630 +/* dlimit vserver commands */
13632 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
13633 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
13635 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
13636 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
13638 +struct vcmd_ctx_dlimit_base_v0 {
13639 + const char __user *name;
13643 +struct vcmd_ctx_dlimit_v0 {
13644 + const char __user *name;
13645 + uint32_t space_used; /* used space in kbytes */
13646 + uint32_t space_total; /* maximum space in kbytes */
13647 + uint32_t inodes_used; /* used inodes */
13648 + uint32_t inodes_total; /* maximum inodes */
13649 + uint32_t reserved; /* reserved for root in % */
13653 +#define CDLIM_UNSET ((uint32_t)0UL)
13654 +#define CDLIM_INFINITY ((uint32_t)~0UL)
13655 +#define CDLIM_KEEP ((uint32_t)~1UL)
13659 +#ifdef CONFIG_COMPAT
13661 +#include <asm/compat.h>
13663 +struct vcmd_ctx_dlimit_base_v0_x32 {
13664 + compat_uptr_t name_ptr;
13668 +struct vcmd_ctx_dlimit_v0_x32 {
13669 + compat_uptr_t name_ptr;
13670 + uint32_t space_used; /* used space in kbytes */
13671 + uint32_t space_total; /* maximum space in kbytes */
13672 + uint32_t inodes_used; /* used inodes */
13673 + uint32_t inodes_total; /* maximum inodes */
13674 + uint32_t reserved; /* reserved for root in % */
13678 +#endif /* CONFIG_COMPAT */
13680 +#include <linux/compiler.h>
13682 +extern int vc_add_dlimit(uint32_t, void __user *);
13683 +extern int vc_rem_dlimit(uint32_t, void __user *);
13685 +extern int vc_set_dlimit(uint32_t, void __user *);
13686 +extern int vc_get_dlimit(uint32_t, void __user *);
13688 +#ifdef CONFIG_COMPAT
13690 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
13691 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
13693 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
13694 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
13696 +#endif /* CONFIG_COMPAT */
13698 +#endif /* __KERNEL__ */
13699 +#endif /* _VX_DLIMIT_CMD_H */
13700 diff -Nurp linux-2.6.22.15/include/linux/vserver/dlimit.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/dlimit.h
13701 --- linux-2.6.22.15/include/linux/vserver/dlimit.h 1969-12-31 19:00:00.000000000 -0500
13702 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/dlimit.h 2007-12-09 06:44:22.000000000 -0500
13704 +#ifndef _VX_DLIMIT_H
13705 +#define _VX_DLIMIT_H
13707 +#include "switch.h"
13712 +/* keep in sync with CDLIM_INFINITY */
13714 +#define DLIM_INFINITY (~0ULL)
13716 +#include <linux/spinlock.h>
13717 +#include <linux/rcupdate.h>
13719 +struct super_block;
13722 + struct hlist_node dl_hlist; /* linked list of contexts */
13723 + struct rcu_head dl_rcu; /* the rcu head */
13724 + tag_t dl_tag; /* context tag */
13725 + atomic_t dl_usecnt; /* usage count */
13726 + atomic_t dl_refcnt; /* reference count */
13728 + struct super_block *dl_sb; /* associated superblock */
13730 + spinlock_t dl_lock; /* protect the values */
13732 + unsigned long long dl_space_used; /* used space in bytes */
13733 + unsigned long long dl_space_total; /* maximum space in bytes */
13734 + unsigned long dl_inodes_used; /* used inodes */
13735 + unsigned long dl_inodes_total; /* maximum inodes */
13737 + unsigned int dl_nrlmult; /* non root limit mult */
13742 +extern void rcu_free_dl_info(struct rcu_head *);
13743 +extern void unhash_dl_info(struct dl_info *);
13745 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
13750 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
13752 +typedef uint64_t dlsize_t;
13754 +#endif /* __KERNEL__ */
13755 +#else /* _VX_DLIMIT_H */
13756 +#warning duplicate inclusion
13757 +#endif /* _VX_DLIMIT_H */
13758 diff -Nurp linux-2.6.22.15/include/linux/vserver/global.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/global.h
13759 --- linux-2.6.22.15/include/linux/vserver/global.h 1969-12-31 19:00:00.000000000 -0500
13760 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/global.h 2007-12-09 06:44:22.000000000 -0500
13762 +#ifndef _VX_GLOBAL_H
13763 +#define _VX_GLOBAL_H
13766 +extern atomic_t vx_global_ctotal;
13767 +extern atomic_t vx_global_cactive;
13769 +extern atomic_t nx_global_ctotal;
13770 +extern atomic_t nx_global_cactive;
13772 +extern atomic_t vs_global_nsproxy;
13773 +extern atomic_t vs_global_fs;
13774 +extern atomic_t vs_global_mnt_ns;
13775 +extern atomic_t vs_global_uts_ns;
13776 +extern atomic_t vs_global_ipc_ns;
13779 +#endif /* _VX_GLOBAL_H */
13780 diff -Nurp linux-2.6.22.15/include/linux/vserver/history.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/history.h
13781 --- linux-2.6.22.15/include/linux/vserver/history.h 1969-12-31 19:00:00.000000000 -0500
13782 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/history.h 2007-12-09 06:44:22.000000000 -0500
13784 +#ifndef _VX_HISTORY_H
13785 +#define _VX_HISTORY_H
13790 + VXH_THROW_OOPS = 1,
13794 + VXH_INIT_VX_INFO,
13797 + VXH_CLAIM_VX_INFO,
13798 + VXH_RELEASE_VX_INFO,
13799 + VXH_ALLOC_VX_INFO,
13800 + VXH_DEALLOC_VX_INFO,
13801 + VXH_HASH_VX_INFO,
13802 + VXH_UNHASH_VX_INFO,
13804 + VXH_LOOKUP_VX_INFO,
13805 + VXH_CREATE_VX_INFO,
13808 +struct _vxhe_vxi {
13809 + struct vx_info *ptr;
13815 +struct _vxhe_set_clr {
13819 +struct _vxhe_loc_lookup {
13823 +struct _vx_hist_entry {
13825 + unsigned short seq;
13826 + unsigned short type;
13827 + struct _vxhe_vxi vxi;
13829 + struct _vxhe_set_clr sc;
13830 + struct _vxhe_loc_lookup ll;
13834 +#ifdef CONFIG_VSERVER_HISTORY
13836 +extern unsigned volatile int vxh_active;
13838 +struct _vx_hist_entry *vxh_advance(void *loc);
13842 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
13844 + entry->vxi.ptr = vxi;
13846 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
13847 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
13848 + entry->vxi.xid = vxi->vx_id;
13853 +#define __HERE__ current_text_addr()
13855 +#define __VXH_BODY(__type, __data, __here) \
13856 + struct _vx_hist_entry *entry; \
13858 + preempt_disable(); \
13859 + entry = vxh_advance(__here); \
13861 + entry->type = __type; \
13862 + preempt_enable();
13865 + /* pass vxi only */
13867 +#define __VXH_SMPL \
13868 + __vxh_copy_vxi(entry, vxi)
13871 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
13873 + __VXH_BODY(__type, __VXH_SMPL, __here)
13876 + /* pass vxi and data (void *) */
13878 +#define __VXH_DATA \
13879 + __vxh_copy_vxi(entry, vxi); \
13880 + entry->sc.data = data
13883 +void __vxh_data(struct vx_info *vxi, void *data,
13884 + int __type, void *__here)
13886 + __VXH_BODY(__type, __VXH_DATA, __here)
13889 + /* pass vxi and arg (long) */
13891 +#define __VXH_LONG \
13892 + __vxh_copy_vxi(entry, vxi); \
13893 + entry->ll.arg = arg
13896 +void __vxh_long(struct vx_info *vxi, long arg,
13897 + int __type, void *__here)
13899 + __VXH_BODY(__type, __VXH_LONG, __here)
13904 +void __vxh_throw_oops(void *__here)
13906 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
13907 + /* prevent further acquisition */
13912 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
13914 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
13915 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13917 +#define __vxh_init_vx_info(v, d, h) \
13918 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13919 +#define __vxh_set_vx_info(v, d, h) \
13920 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
13921 +#define __vxh_clr_vx_info(v, d, h) \
13922 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13924 +#define __vxh_claim_vx_info(v, d, h) \
13925 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13926 +#define __vxh_release_vx_info(v, d, h) \
13927 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13929 +#define vxh_alloc_vx_info(v) \
13930 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13931 +#define vxh_dealloc_vx_info(v) \
13932 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13934 +#define vxh_hash_vx_info(v) \
13935 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13936 +#define vxh_unhash_vx_info(v) \
13937 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13939 +#define vxh_loc_vx_info(v, l) \
13940 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13941 +#define vxh_lookup_vx_info(v, l) \
13942 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13943 +#define vxh_create_vx_info(v, l) \
13944 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13946 +extern void vxh_dump_history(void);
13949 +#else /* CONFIG_VSERVER_HISTORY */
13951 +#define __HERE__ 0
13953 +#define vxh_throw_oops() do { } while (0)
13955 +#define __vxh_get_vx_info(v, h) do { } while (0)
13956 +#define __vxh_put_vx_info(v, h) do { } while (0)
13958 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
13959 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
13960 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
13962 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
13963 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13965 +#define vxh_alloc_vx_info(v) do { } while (0)
13966 +#define vxh_dealloc_vx_info(v) do { } while (0)
13968 +#define vxh_hash_vx_info(v) do { } while (0)
13969 +#define vxh_unhash_vx_info(v) do { } while (0)
13971 +#define vxh_loc_vx_info(v, l) do { } while (0)
13972 +#define vxh_lookup_vx_info(v, l) do { } while (0)
13973 +#define vxh_create_vx_info(v, l) do { } while (0)
13975 +#define vxh_dump_history() do { } while (0)
13978 +#endif /* CONFIG_VSERVER_HISTORY */
13980 +#endif /* _VX_HISTORY_H */
13981 diff -Nurp linux-2.6.22.15/include/linux/vserver/inode_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/inode_cmd.h
13982 --- linux-2.6.22.15/include/linux/vserver/inode_cmd.h 1969-12-31 19:00:00.000000000 -0500
13983 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/inode_cmd.h 2007-12-09 06:44:22.000000000 -0500
13985 +#ifndef _VX_INODE_CMD_H
13986 +#define _VX_INODE_CMD_H
13989 +/* inode vserver commands */
13991 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
13992 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
13994 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
13995 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
13997 +struct vcmd_ctx_iattr_v1 {
13998 + const char __user *name;
14004 +struct vcmd_ctx_fiattr_v0 {
14014 +#ifdef CONFIG_COMPAT
14016 +#include <asm/compat.h>
14018 +struct vcmd_ctx_iattr_v1_x32 {
14019 + compat_uptr_t name_ptr;
14025 +#endif /* CONFIG_COMPAT */
14027 +#include <linux/compiler.h>
14029 +extern int vc_get_iattr(void __user *);
14030 +extern int vc_set_iattr(void __user *);
14032 +extern int vc_fget_iattr(uint32_t, void __user *);
14033 +extern int vc_fset_iattr(uint32_t, void __user *);
14035 +#ifdef CONFIG_COMPAT
14037 +extern int vc_get_iattr_x32(void __user *);
14038 +extern int vc_set_iattr_x32(void __user *);
14040 +#endif /* CONFIG_COMPAT */
14042 +#endif /* __KERNEL__ */
14043 +#endif /* _VX_INODE_CMD_H */
14044 diff -Nurp linux-2.6.22.15/include/linux/vserver/inode.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/inode.h
14045 --- linux-2.6.22.15/include/linux/vserver/inode.h 1969-12-31 19:00:00.000000000 -0500
14046 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/inode.h 2007-12-09 06:44:22.000000000 -0500
14048 +#ifndef _VX_INODE_H
14049 +#define _VX_INODE_H
14052 +#define IATTR_TAG 0x01000000
14054 +#define IATTR_ADMIN 0x00000001
14055 +#define IATTR_WATCH 0x00000002
14056 +#define IATTR_HIDE 0x00000004
14057 +#define IATTR_FLAGS 0x00000007
14059 +#define IATTR_BARRIER 0x00010000
14060 +#define IATTR_IUNLINK 0x00020000
14061 +#define IATTR_IMMUTABLE 0x00040000
14066 +#ifdef CONFIG_VSERVER_PROC_SECURE
14067 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
14068 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
14070 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
14071 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
14074 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
14076 +#endif /* __KERNEL__ */
14078 +/* inode ioctls */
14080 +#define FIOC_GETXFLG _IOR('x', 5, long)
14081 +#define FIOC_SETXFLG _IOW('x', 6, long)
14083 +#else /* _VX_INODE_H */
14084 +#warning duplicate inclusion
14085 +#endif /* _VX_INODE_H */
14086 diff -Nurp linux-2.6.22.15/include/linux/vserver/Kbuild linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/Kbuild
14087 --- linux-2.6.22.15/include/linux/vserver/Kbuild 1969-12-31 19:00:00.000000000 -0500
14088 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/Kbuild 2007-12-09 06:44:22.000000000 -0500
14091 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
14092 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
14093 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
14094 + debug_cmd.h device_cmd.h
14096 +unifdef-y += switch.h network.h monitor.h inode.h device.h
14098 diff -Nurp linux-2.6.22.15/include/linux/vserver/limit_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/limit_cmd.h
14099 --- linux-2.6.22.15/include/linux/vserver/limit_cmd.h 1969-12-31 19:00:00.000000000 -0500
14100 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/limit_cmd.h 2007-12-09 06:44:22.000000000 -0500
14102 +#ifndef _VX_LIMIT_CMD_H
14103 +#define _VX_LIMIT_CMD_H
14106 +/* rlimit vserver commands */
14108 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
14109 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
14110 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
14111 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
14113 +struct vcmd_ctx_rlimit_v0 {
14115 + uint64_t minimum;
14116 + uint64_t softlimit;
14117 + uint64_t maximum;
14120 +struct vcmd_ctx_rlimit_mask_v0 {
14121 + uint32_t minimum;
14122 + uint32_t softlimit;
14123 + uint32_t maximum;
14126 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
14128 +struct vcmd_rlimit_stat_v0 {
14132 + uint64_t minimum;
14133 + uint64_t maximum;
14136 +#define CRLIM_UNSET (0ULL)
14137 +#define CRLIM_INFINITY (~0ULL)
14138 +#define CRLIM_KEEP (~1ULL)
14142 +#ifdef CONFIG_IA32_EMULATION
14144 +struct vcmd_ctx_rlimit_v0_x32 {
14146 + uint64_t minimum;
14147 + uint64_t softlimit;
14148 + uint64_t maximum;
14149 +} __attribute__ ((aligned (4)));
14151 +#endif /* CONFIG_IA32_EMULATION */
14153 +#include <linux/compiler.h>
14155 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
14156 +extern int vc_get_rlimit(struct vx_info *, void __user *);
14157 +extern int vc_set_rlimit(struct vx_info *, void __user *);
14158 +extern int vc_reset_minmax(struct vx_info *, void __user *);
14160 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
14162 +#ifdef CONFIG_IA32_EMULATION
14164 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
14165 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
14167 +#endif /* CONFIG_IA32_EMULATION */
14169 +#endif /* __KERNEL__ */
14170 +#endif /* _VX_LIMIT_CMD_H */
14171 diff -Nurp linux-2.6.22.15/include/linux/vserver/limit_def.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/limit_def.h
14172 --- linux-2.6.22.15/include/linux/vserver/limit_def.h 1969-12-31 19:00:00.000000000 -0500
14173 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/limit_def.h 2007-12-09 06:44:22.000000000 -0500
14175 +#ifndef _VX_LIMIT_DEF_H
14176 +#define _VX_LIMIT_DEF_H
14178 +#include <asm/atomic.h>
14179 +#include <asm/resource.h>
14181 +#include "limit.h"
14184 +struct _vx_res_limit {
14185 + rlim_t soft; /* Context soft limit */
14186 + rlim_t hard; /* Context hard limit */
14188 + rlim_atomic_t rcur; /* Current value */
14189 + rlim_t rmin; /* Context minimum */
14190 + rlim_t rmax; /* Context maximum */
14192 + atomic_t lhit; /* Limit hits */
14195 +/* context sub struct */
14197 +struct _vx_limit {
14198 + struct _vx_res_limit res[NUM_LIMITS];
14201 +#ifdef CONFIG_VSERVER_DEBUG
14203 +static inline void __dump_vx_limit(struct _vx_limit *limit)
14207 + printk("\t_vx_limit:");
14208 + for (i = 0; i < NUM_LIMITS; i++) {
14209 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
14210 + i, (unsigned long)__rlim_get(limit, i),
14211 + (unsigned long)__rlim_rmin(limit, i),
14212 + (unsigned long)__rlim_rmax(limit, i),
14213 + (long)__rlim_soft(limit, i),
14214 + (long)__rlim_hard(limit, i),
14215 + atomic_read(&__rlim_lhit(limit, i)));
14221 +#endif /* _VX_LIMIT_DEF_H */
14222 diff -Nurp linux-2.6.22.15/include/linux/vserver/limit.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/limit.h
14223 --- linux-2.6.22.15/include/linux/vserver/limit.h 1969-12-31 19:00:00.000000000 -0500
14224 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/limit.h 2007-12-09 06:44:22.000000000 -0500
14226 +#ifndef _VX_LIMIT_H
14227 +#define _VX_LIMIT_H
14229 +#define VLIMIT_NSOCK 16
14230 +#define VLIMIT_OPENFD 17
14231 +#define VLIMIT_ANON 18
14232 +#define VLIMIT_SHMEM 19
14233 +#define VLIMIT_SEMARY 20
14234 +#define VLIMIT_NSEMS 21
14235 +#define VLIMIT_DENTRY 22
14236 +#define VLIMIT_MAPPED 23
14241 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
14243 +/* keep in sync with CRLIM_INFINITY */
14245 +#define VLIM_INFINITY (~0ULL)
14247 +#include <asm/atomic.h>
14248 +#include <asm/resource.h>
14250 +#ifndef RLIM_INFINITY
14251 +#warning RLIM_INFINITY is undefined
14254 +#define __rlim_val(l, r, v) ((l)->res[r].v)
14256 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
14257 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
14259 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
14260 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
14261 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
14263 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
14264 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
14266 +typedef atomic_long_t rlim_atomic_t;
14267 +typedef unsigned long rlim_t;
14269 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
14270 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
14271 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
14272 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
14273 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
14274 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
14277 +#if (RLIM_INFINITY == VLIM_INFINITY)
14278 +#define VX_VLIM(r) ((long long)(long)(r))
14279 +#define VX_RLIM(v) ((rlim_t)(v))
14281 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
14282 + ? VLIM_INFINITY : (long long)(r))
14283 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
14284 + ? RLIM_INFINITY : (rlim_t)(v))
14289 +void vx_vsi_meminfo(struct sysinfo *);
14290 +void vx_vsi_swapinfo(struct sysinfo *);
14292 +#define NUM_LIMITS 24
14294 +#endif /* __KERNEL__ */
14295 +#endif /* _VX_LIMIT_H */
14296 diff -Nurp linux-2.6.22.15/include/linux/vserver/limit_int.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/limit_int.h
14297 --- linux-2.6.22.15/include/linux/vserver/limit_int.h 1969-12-31 19:00:00.000000000 -0500
14298 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/limit_int.h 2007-12-09 06:44:22.000000000 -0500
14300 +#ifndef _VX_LIMIT_INT_H
14301 +#define _VX_LIMIT_INT_H
14303 +#include "context.h"
14307 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
14308 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
14310 +extern const char *vlimit_name[NUM_LIMITS];
14312 +static inline void __vx_acc_cres(struct vx_info *vxi,
14313 + int res, int dir, void *_data, char *_file, int _line)
14315 + if (VXD_RCRES_COND(res))
14316 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
14317 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14318 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14319 + (dir > 0) ? "++" : "--", _data, _file, _line);
14324 + __rlim_inc(&vxi->limit, res);
14326 + __rlim_dec(&vxi->limit, res);
14329 +static inline void __vx_add_cres(struct vx_info *vxi,
14330 + int res, int amount, void *_data, char *_file, int _line)
14332 + if (VXD_RCRES_COND(res))
14333 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
14334 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14335 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14336 + amount, _data, _file, _line);
14341 + __rlim_add(&vxi->limit, res, amount);
14345 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
14347 + int cond = (value > __rlim_rmax(limit, res));
14350 + __rlim_rmax(limit, res) = value;
14355 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
14357 + int cond = (value < __rlim_rmin(limit, res));
14360 + __rlim_rmin(limit, res) = value;
14365 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
14367 + if (!__vx_cres_adjust_max(limit, res, value))
14368 + __vx_cres_adjust_min(limit, res, value);
14373 + +1 ... no limit hit
14374 + -1 ... over soft limit
14375 + 0 ... over hard limit */
14377 +static inline int __vx_cres_avail(struct vx_info *vxi,
14378 + int res, int num, char *_file, int _line)
14380 + struct _vx_limit *limit;
14383 + if (VXD_RLIMIT_COND(res))
14384 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
14385 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14386 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
14387 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
14388 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14389 + num, _file, _line);
14393 + limit = &vxi->limit;
14394 + value = __rlim_get(limit, res);
14396 + if (!__vx_cres_adjust_max(limit, res, value))
14397 + __vx_cres_adjust_min(limit, res, value);
14402 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
14404 + if (value + num <= __rlim_soft(limit, res))
14407 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
14409 + if (value + num <= __rlim_hard(limit, res))
14412 + __rlim_hit(limit, res);
14417 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
14420 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
14422 + rlim_t value, sum = 0;
14425 + while ((res = *array++)) {
14426 + value = __rlim_get(limit, res);
14427 + __vx_cres_fixup(limit, res, value);
14434 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
14436 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
14437 + int res = *array;
14439 + if (value == __rlim_get(limit, res))
14442 + __rlim_set(limit, res, value);
14443 + /* now adjust min/max */
14444 + if (!__vx_cres_adjust_max(limit, res, value))
14445 + __vx_cres_adjust_min(limit, res, value);
14450 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
14451 + const int *array, int num, char *_file, int _line)
14453 + struct _vx_limit *limit;
14454 + rlim_t value = 0;
14462 + limit = &vxi->limit;
14464 + value = __vx_cres_array_sum(limit, array + 1);
14466 + __rlim_set(limit, res, value);
14467 + __vx_cres_fixup(limit, res, value);
14469 + return __vx_cres_avail(vxi, res, num, _file, _line);
14473 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
14478 + /* complex resources first */
14479 + if ((id < 0) || (id == RLIMIT_RSS))
14480 + __vx_cres_array_fixup(limit, VLA_RSS);
14482 + for (res = 0; res < NUM_LIMITS; res++) {
14483 + if ((id > 0) && (res != id))
14486 + value = __rlim_get(limit, res);
14487 + __vx_cres_fixup(limit, res, value);
14489 + /* not supposed to happen, maybe warn? */
14490 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
14491 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
14496 +#endif /* __KERNEL__ */
14497 +#endif /* _VX_LIMIT_INT_H */
14498 diff -Nurp linux-2.6.22.15/include/linux/vserver/monitor.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/monitor.h
14499 --- linux-2.6.22.15/include/linux/vserver/monitor.h 1969-12-31 19:00:00.000000000 -0500
14500 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/monitor.h 2007-12-09 06:44:22.000000000 -0500
14502 +#ifndef _VX_MONITOR_H
14503 +#define _VX_MONITOR_H
14505 +#include <linux/types.h>
14512 + VXM_UPDATE = 0x20,
14516 + VXM_RQINFO_1 = 0x24,
14519 + VXM_ACTIVATE = 0x40,
14526 + VXM_MIGRATE = 0x48,
14529 + /* all other bits are flags */
14530 + VXM_SCHED = 0x80,
14533 +struct _vxm_update_1 {
14534 + uint32_t tokens_max;
14535 + uint32_t fill_rate;
14536 + uint32_t interval;
14539 +struct _vxm_update_2 {
14540 + uint32_t tokens_min;
14541 + uint32_t fill_rate;
14542 + uint32_t interval;
14545 +struct _vxm_rqinfo_1 {
14546 + uint16_t running;
14550 + uint32_t idle_tokens;
14553 +struct _vxm_rqinfo_2 {
14554 + uint32_t norm_time;
14555 + uint32_t idle_time;
14556 + uint32_t idle_skip;
14559 +struct _vxm_sched {
14561 + uint32_t norm_time;
14562 + uint32_t idle_time;
14565 +struct _vxm_task {
14570 +struct _vxm_event {
14579 + struct _vxm_task tsk;
14583 +struct _vx_mon_entry {
14587 + struct _vxm_event ev;
14588 + struct _vxm_sched sd;
14589 + struct _vxm_update_1 u1;
14590 + struct _vxm_update_2 u2;
14591 + struct _vxm_rqinfo_1 q1;
14592 + struct _vxm_rqinfo_2 q2;
14597 +#endif /* _VX_MONITOR_H */
14598 diff -Nurp linux-2.6.22.15/include/linux/vserver/network_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/network_cmd.h
14599 --- linux-2.6.22.15/include/linux/vserver/network_cmd.h 1969-12-31 19:00:00.000000000 -0500
14600 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/network_cmd.h 2007-12-09 06:44:22.000000000 -0500
14602 +#ifndef _VX_NETWORK_CMD_H
14603 +#define _VX_NETWORK_CMD_H
14606 +/* vinfo commands */
14608 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
14611 +extern int vc_task_nid(uint32_t);
14613 +#endif /* __KERNEL__ */
14615 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
14617 +struct vcmd_nx_info_v0 {
14619 + /* more to come */
14623 +extern int vc_nx_info(struct nx_info *, void __user *);
14625 +#endif /* __KERNEL__ */
14627 +#include <linux/in.h>
14628 +#include <linux/in6.h>
14630 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
14631 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
14633 +struct vcmd_net_create {
14634 + uint64_t flagword;
14637 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
14639 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
14640 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
14642 +struct vcmd_net_addr_v0 {
14645 + struct in_addr ip[4];
14646 + struct in_addr mask[4];
14649 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
14650 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
14652 +struct vcmd_net_addr_ipv4_v1 {
14655 + struct in_addr ip;
14656 + struct in_addr mask;
14659 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
14660 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
14662 +struct vcmd_net_addr_ipv6_v1 {
14666 + struct in6_addr ip;
14667 + struct in6_addr mask;
14670 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
14671 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
14673 +struct vcmd_match_ipv4_v0 {
14678 + struct in_addr ip;
14679 + struct in_addr ip2;
14680 + struct in_addr mask;
14683 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
14684 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
14686 +struct vcmd_match_ipv6_v0 {
14691 + struct in6_addr ip;
14692 + struct in6_addr ip2;
14693 + struct in6_addr mask;
14698 +extern int vc_net_create(uint32_t, void __user *);
14699 +extern int vc_net_migrate(struct nx_info *, void __user *);
14701 +extern int vc_net_add(struct nx_info *, void __user *);
14702 +extern int vc_net_remove(struct nx_info *, void __user *);
14704 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
14705 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
14707 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
14708 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
14710 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
14711 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
14713 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
14714 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
14716 +#endif /* __KERNEL__ */
14719 +/* flag commands */
14721 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
14722 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
14724 +struct vcmd_net_flags_v0 {
14725 + uint64_t flagword;
14730 +extern int vc_get_nflags(struct nx_info *, void __user *);
14731 +extern int vc_set_nflags(struct nx_info *, void __user *);
14733 +#endif /* __KERNEL__ */
14736 +/* network caps commands */
14738 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
14739 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
14741 +struct vcmd_net_caps_v0 {
14747 +extern int vc_get_ncaps(struct nx_info *, void __user *);
14748 +extern int vc_set_ncaps(struct nx_info *, void __user *);
14750 +#endif /* __KERNEL__ */
14751 +#endif /* _VX_CONTEXT_CMD_H */
14752 diff -Nurp linux-2.6.22.15/include/linux/vserver/network.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/network.h
14753 --- linux-2.6.22.15/include/linux/vserver/network.h 1969-12-31 19:00:00.000000000 -0500
14754 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/network.h 2007-12-09 06:44:22.000000000 -0500
14756 +#ifndef _VX_NETWORK_H
14757 +#define _VX_NETWORK_H
14759 +#include <linux/types.h>
14762 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
14765 +/* network flags */
14767 +#define NXF_INFO_PRIVATE 0x00000008
14769 +#define NXF_SINGLE_IP 0x00000100
14770 +#define NXF_LBACK_REMAP 0x00000200
14772 +#define NXF_HIDE_NETIF 0x02000000
14773 +#define NXF_HIDE_LBACK 0x04000000
14775 +#define NXF_STATE_SETUP (1ULL << 32)
14776 +#define NXF_STATE_ADMIN (1ULL << 34)
14778 +#define NXF_SC_HELPER (1ULL << 36)
14779 +#define NXF_PERSISTENT (1ULL << 38)
14781 +#define NXF_ONE_TIME (0x0005ULL << 32)
14784 +#define NXF_INIT_SET (__nxf_init_set())
14786 +static inline uint64_t __nxf_init_set(void) {
14787 + return NXF_STATE_ADMIN
14788 +#ifdef CONFIG_VSERVER_AUTO_LBACK
14789 + | NXF_LBACK_REMAP
14792 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
14795 + | NXF_HIDE_NETIF;
14799 +/* network caps */
14801 +#define NXC_RAW_ICMP 0x00000100
14804 +/* address types */
14806 +#define NXA_TYPE_IPV4 0x0001
14807 +#define NXA_TYPE_IPV6 0x0002
14809 +#define NXA_TYPE_NONE 0x0000
14810 +#define NXA_TYPE_ANY 0x00FF
14812 +#define NXA_TYPE_ADDR 0x0010
14813 +#define NXA_TYPE_MASK 0x0020
14814 +#define NXA_TYPE_RANGE 0x0040
14816 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
14818 +#define NXA_MOD_BCAST 0x0100
14819 +#define NXA_MOD_LBACK 0x0200
14821 +#define NXA_LOOPBACK 0x1000
14823 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
14824 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
14828 +#include <linux/list.h>
14829 +#include <linux/spinlock.h>
14830 +#include <linux/rcupdate.h>
14831 +#include <linux/in.h>
14832 +#include <linux/in6.h>
14833 +#include <asm/atomic.h>
14835 +struct nx_addr_v4 {
14836 + struct nx_addr_v4 *next;
14837 + struct in_addr ip[2];
14838 + struct in_addr mask;
14843 +struct nx_addr_v6 {
14844 + struct nx_addr_v6 *next;
14845 + struct in6_addr ip;
14846 + struct in6_addr mask;
14853 + struct hlist_node nx_hlist; /* linked list of nxinfos */
14854 + nid_t nx_id; /* vnet id */
14855 + atomic_t nx_usecnt; /* usage count */
14856 + atomic_t nx_tasks; /* tasks count */
14857 + int nx_state; /* context state */
14859 + uint64_t nx_flags; /* network flag word */
14860 + uint64_t nx_ncaps; /* network capabilities */
14862 + struct in_addr v4_lback; /* Loopback address */
14863 + struct in_addr v4_bcast; /* Broadcast address */
14864 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
14865 +#ifdef CONFIG_IPV6
14866 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
14868 + char nx_name[65]; /* network context name */
14872 +/* status flags */
14874 +#define NXS_HASHED 0x0001
14875 +#define NXS_SHUTDOWN 0x0100
14876 +#define NXS_RELEASED 0x8000
14878 +extern struct nx_info *lookup_nx_info(int);
14880 +extern int get_nid_list(int, unsigned int *, int);
14881 +extern int nid_is_hashed(nid_t);
14883 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
14885 +extern long vs_net_change(struct nx_info *, unsigned int);
14890 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
14891 +#ifdef CONFIG_IPV6
14892 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
14894 +#define NX_IPV6(n) (0)
14897 +#endif /* __KERNEL__ */
14898 +#endif /* _VX_NETWORK_H */
14899 diff -Nurp linux-2.6.22.15/include/linux/vserver/percpu.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/percpu.h
14900 --- linux-2.6.22.15/include/linux/vserver/percpu.h 1969-12-31 19:00:00.000000000 -0500
14901 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/percpu.h 2007-12-09 06:44:22.000000000 -0500
14903 +#ifndef _VX_PERCPU_H
14904 +#define _VX_PERCPU_H
14906 +#include "cvirt_def.h"
14907 +#include "sched_def.h"
14909 +struct _vx_percpu {
14910 + struct _vx_cvirt_pc cvirt;
14911 + struct _vx_sched_pc sched;
14914 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
14916 +#endif /* _VX_PERCPU_H */
14917 diff -Nurp linux-2.6.22.15/include/linux/vserver/sched_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/sched_cmd.h
14918 --- linux-2.6.22.15/include/linux/vserver/sched_cmd.h 1969-12-31 19:00:00.000000000 -0500
14919 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/sched_cmd.h 2007-12-09 06:44:22.000000000 -0500
14921 +#ifndef _VX_SCHED_CMD_H
14922 +#define _VX_SCHED_CMD_H
14925 +/* sched vserver commands */
14927 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
14928 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
14929 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
14931 +struct vcmd_set_sched_v2 {
14932 + int32_t fill_rate;
14933 + int32_t interval;
14935 + int32_t tokens_min;
14936 + int32_t tokens_max;
14937 + uint64_t cpu_mask;
14940 +struct vcmd_set_sched_v3 {
14941 + uint32_t set_mask;
14942 + int32_t fill_rate;
14943 + int32_t interval;
14945 + int32_t tokens_min;
14946 + int32_t tokens_max;
14947 + int32_t priority_bias;
14950 +struct vcmd_set_sched_v4 {
14951 + uint32_t set_mask;
14952 + int32_t fill_rate;
14953 + int32_t interval;
14955 + int32_t tokens_min;
14956 + int32_t tokens_max;
14957 + int32_t prio_bias;
14959 + int32_t bucket_id;
14962 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
14963 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
14965 +struct vcmd_sched_v5 {
14968 + int32_t bucket_id;
14969 + int32_t fill_rate[2];
14970 + int32_t interval[2];
14972 + int32_t tokens_min;
14973 + int32_t tokens_max;
14974 + int32_t prio_bias;
14977 +#define VXSM_FILL_RATE 0x0001
14978 +#define VXSM_INTERVAL 0x0002
14979 +#define VXSM_FILL_RATE2 0x0004
14980 +#define VXSM_INTERVAL2 0x0008
14981 +#define VXSM_TOKENS 0x0010
14982 +#define VXSM_TOKENS_MIN 0x0020
14983 +#define VXSM_TOKENS_MAX 0x0040
14984 +#define VXSM_PRIO_BIAS 0x0100
14986 +#define VXSM_IDLE_TIME 0x0200
14987 +#define VXSM_FORCE 0x0400
14989 +#define VXSM_V3_MASK 0x0173
14990 +#define VXSM_SET_MASK 0x01FF
14992 +#define VXSM_CPU_ID 0x1000
14993 +#define VXSM_BUCKET_ID 0x2000
14995 +#define VXSM_MSEC 0x4000
14997 +#define SCHED_KEEP (-2) /* only for v2 */
15001 +#include <linux/compiler.h>
15003 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
15004 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
15005 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
15006 +extern int vc_set_sched(struct vx_info *, void __user *);
15007 +extern int vc_get_sched(struct vx_info *, void __user *);
15009 +#endif /* __KERNEL__ */
15011 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
15013 +struct vcmd_sched_info {
15015 + int32_t bucket_id;
15016 + uint64_t user_msec;
15017 + uint64_t sys_msec;
15018 + uint64_t hold_msec;
15019 + uint32_t token_usec;
15020 + int32_t vavavoom;
15025 +extern int vc_sched_info(struct vx_info *, void __user *);
15027 +#endif /* __KERNEL__ */
15028 +#endif /* _VX_SCHED_CMD_H */
15029 diff -Nurp linux-2.6.22.15/include/linux/vserver/sched_def.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/sched_def.h
15030 --- linux-2.6.22.15/include/linux/vserver/sched_def.h 1969-12-31 19:00:00.000000000 -0500
15031 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/sched_def.h 2007-12-09 06:44:22.000000000 -0500
15033 +#ifndef _VX_SCHED_DEF_H
15034 +#define _VX_SCHED_DEF_H
15036 +#include <linux/spinlock.h>
15037 +#include <linux/jiffies.h>
15038 +#include <linux/cpumask.h>
15039 +#include <asm/atomic.h>
15040 +#include <asm/param.h>
15043 +/* context sub struct */
15045 +struct _vx_sched {
15046 + spinlock_t tokens_lock; /* lock for token bucket */
15048 + int tokens; /* number of CPU tokens */
15049 + int fill_rate[2]; /* Fill rate: add X tokens... */
15050 + int interval[2]; /* Divisor: per Y jiffies */
15051 + int tokens_min; /* Limit: minimum for unhold */
15052 + int tokens_max; /* Limit: no more than N tokens */
15054 + int prio_bias; /* bias offset for priority */
15056 + unsigned update_mask; /* which features should be updated */
15057 + cpumask_t update; /* CPUs which should update */
15060 +struct _vx_sched_pc {
15061 + int tokens; /* number of CPU tokens */
15062 + int flags; /* bucket flags */
15064 + int fill_rate[2]; /* Fill rate: add X tokens... */
15065 + int interval[2]; /* Divisor: per Y jiffies */
15066 + int tokens_min; /* Limit: minimum for unhold */
15067 + int tokens_max; /* Limit: no more than N tokens */
15069 + int prio_bias; /* bias offset for priority */
15070 + int vavavoom; /* last calculated vavavoom */
15072 + unsigned long norm_time; /* last time accounted */
15073 + unsigned long idle_time; /* non linear time for fair sched */
15074 + unsigned long token_time; /* token time for accounting */
15075 + unsigned long onhold; /* jiffies when put on hold */
15077 + uint64_t user_ticks; /* token tick events */
15078 + uint64_t sys_ticks; /* token tick events */
15079 + uint64_t hold_ticks; /* token ticks paused */
15083 +#define VXSF_ONHOLD 0x0001
15084 +#define VXSF_IDLE_TIME 0x0100
15086 +#ifdef CONFIG_VSERVER_DEBUG
15088 +static inline void __dump_vx_sched(struct _vx_sched *sched)
15090 + printk("\t_vx_sched:\n");
15091 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
15092 + sched->fill_rate[0], sched->interval[0],
15093 + sched->fill_rate[1], sched->interval[1],
15094 + sched->tokens_min, sched->tokens_max);
15095 + printk("\t priority = %4d\n", sched->prio_bias);
15100 +#endif /* _VX_SCHED_DEF_H */
15101 diff -Nurp linux-2.6.22.15/include/linux/vserver/sched.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/sched.h
15102 --- linux-2.6.22.15/include/linux/vserver/sched.h 1969-12-31 19:00:00.000000000 -0500
15103 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/sched.h 2007-12-09 06:44:22.000000000 -0500
15105 +#ifndef _VX_SCHED_H
15106 +#define _VX_SCHED_H
15113 +void vx_vsi_uptime(struct timespec *, struct timespec *);
15118 +void vx_update_load(struct vx_info *);
15121 +int vx_tokens_recalc(struct _vx_sched_pc *,
15122 + unsigned long *, unsigned long *, int [2]);
15124 +void vx_update_sched_param(struct _vx_sched *sched,
15125 + struct _vx_sched_pc *sched_pc);
15127 +#endif /* __KERNEL__ */
15128 +#else /* _VX_SCHED_H */
15129 +#warning duplicate inclusion
15130 +#endif /* _VX_SCHED_H */
15131 diff -Nurp linux-2.6.22.15/include/linux/vserver/signal_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/signal_cmd.h
15132 --- linux-2.6.22.15/include/linux/vserver/signal_cmd.h 1969-12-31 19:00:00.000000000 -0500
15133 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/signal_cmd.h 2007-12-09 06:44:22.000000000 -0500
15135 +#ifndef _VX_SIGNAL_CMD_H
15136 +#define _VX_SIGNAL_CMD_H
15139 +/* signalling vserver commands */
15141 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
15142 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
15144 +struct vcmd_ctx_kill_v0 {
15149 +struct vcmd_wait_exit_v0 {
15150 + int32_t reboot_cmd;
15151 + int32_t exit_code;
15156 +extern int vc_ctx_kill(struct vx_info *, void __user *);
15157 +extern int vc_wait_exit(struct vx_info *, void __user *);
15159 +#endif /* __KERNEL__ */
15161 +/* process alteration commands */
15163 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
15164 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
15166 +struct vcmd_pflags_v0 {
15167 + uint32_t flagword;
15173 +extern int vc_get_pflags(uint32_t pid, void __user *);
15174 +extern int vc_set_pflags(uint32_t pid, void __user *);
15176 +#endif /* __KERNEL__ */
15177 +#endif /* _VX_SIGNAL_CMD_H */
15178 diff -Nurp linux-2.6.22.15/include/linux/vserver/signal.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/signal.h
15179 --- linux-2.6.22.15/include/linux/vserver/signal.h 1969-12-31 19:00:00.000000000 -0500
15180 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/signal.h 2007-12-09 06:44:22.000000000 -0500
15182 +#ifndef _VX_SIGNAL_H
15183 +#define _VX_SIGNAL_H
15190 +int vx_info_kill(struct vx_info *, int, int);
15192 +#endif /* __KERNEL__ */
15193 +#else /* _VX_SIGNAL_H */
15194 +#warning duplicate inclusion
15195 +#endif /* _VX_SIGNAL_H */
15196 diff -Nurp linux-2.6.22.15/include/linux/vserver/space_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/space_cmd.h
15197 --- linux-2.6.22.15/include/linux/vserver/space_cmd.h 1969-12-31 19:00:00.000000000 -0500
15198 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/space_cmd.h 2007-12-09 06:44:22.000000000 -0500
15200 +#ifndef _VX_SPACE_CMD_H
15201 +#define _VX_SPACE_CMD_H
15204 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
15205 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 1)
15207 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
15208 +#define VCMD_set_space VC_CMD(PROCALT, 3, 1)
15210 +#define VCMD_get_space_mask VC_CMD(PROCALT, 4, 0)
15213 +struct vcmd_space_mask {
15220 +extern int vc_enter_space(struct vx_info *, void __user *);
15221 +extern int vc_set_space(struct vx_info *, void __user *);
15222 +extern int vc_get_space_mask(struct vx_info *, void __user *);
15224 +#endif /* __KERNEL__ */
15225 +#endif /* _VX_SPACE_CMD_H */
15226 diff -Nurp linux-2.6.22.15/include/linux/vserver/space.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/space.h
15227 --- linux-2.6.22.15/include/linux/vserver/space.h 1969-12-31 19:00:00.000000000 -0500
15228 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/space.h 2007-12-09 06:44:22.000000000 -0500
15230 +#ifndef _VX_SPACE_H
15231 +#define _VX_SPACE_H
15234 +#include <linux/types.h>
15238 +int vx_set_space(struct vx_info *vxi, unsigned long mask);
15240 +#else /* _VX_SPACE_H */
15241 +#warning duplicate inclusion
15242 +#endif /* _VX_SPACE_H */
15243 diff -Nurp linux-2.6.22.15/include/linux/vserver/switch.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/switch.h
15244 --- linux-2.6.22.15/include/linux/vserver/switch.h 1969-12-31 19:00:00.000000000 -0500
15245 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/switch.h 2007-12-09 06:44:22.000000000 -0500
15247 +#ifndef _VX_SWITCH_H
15248 +#define _VX_SWITCH_H
15250 +#include <linux/types.h>
15253 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
15254 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
15255 +#define VC_VERSION(c) ((c) & 0xFFF)
15257 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
15258 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
15262 + Syscall Matrix V2.8
15264 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
15265 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
15266 + |INFO |SETUP | |MOVE | | | | | |
15267 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15268 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
15269 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
15270 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15271 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
15272 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
15273 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15274 + MEMORY | | | | |MEMCTRL| | |SWAP | |
15275 + | 16| 17| 18| 19| 20| 21| | 22| 23|
15276 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15277 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
15278 + | 24| 25| 26| 27| 28| 29| | 30| 31|
15279 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15280 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
15281 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
15282 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15283 + OTHER |VSTAT | | | | | | |VINFO | |
15284 + | 40| 41| 42| 43| 44| 45| | 46| 47|
15285 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
15286 + SPECIAL|EVENT | | | |FLAGS | | | | |
15287 + | 48| 49| 50| 51| 52| 53| | 54| 55|
15288 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15289 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
15290 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
15291 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15295 +#define VC_CAT_VERSION 0
15297 +#define VC_CAT_VSETUP 1
15298 +#define VC_CAT_VHOST 2
15300 +#define VC_CAT_DEVICE 6
15302 +#define VC_CAT_VPROC 9
15303 +#define VC_CAT_PROCALT 10
15304 +#define VC_CAT_PROCMIG 11
15305 +#define VC_CAT_PROCTRL 12
15307 +#define VC_CAT_SCHED 14
15308 +#define VC_CAT_MEMCTRL 20
15310 +#define VC_CAT_VNET 25
15311 +#define VC_CAT_NETALT 26
15312 +#define VC_CAT_NETMIG 27
15313 +#define VC_CAT_NETCTRL 28
15315 +#define VC_CAT_TAGMIG 35
15316 +#define VC_CAT_DLIMIT 36
15317 +#define VC_CAT_INODE 38
15319 +#define VC_CAT_VSTAT 40
15320 +#define VC_CAT_VINFO 46
15321 +#define VC_CAT_EVENT 48
15323 +#define VC_CAT_FLAGS 52
15324 +#define VC_CAT_DEBUG 56
15325 +#define VC_CAT_RLIMIT 60
15327 +#define VC_CAT_SYSTEST 61
15328 +#define VC_CAT_COMPAT 63
15330 +/* query version */
15332 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
15333 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
15338 +#include <linux/errno.h>
15341 +#else /* __KERNEL__ */
15343 +#endif /* __KERNEL__ */
15345 +#endif /* _VX_SWITCH_H */
15346 diff -Nurp linux-2.6.22.15/include/linux/vserver/tag_cmd.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/tag_cmd.h
15347 --- linux-2.6.22.15/include/linux/vserver/tag_cmd.h 1969-12-31 19:00:00.000000000 -0500
15348 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/tag_cmd.h 2007-12-09 06:44:22.000000000 -0500
15350 +#ifndef _VX_TAG_CMD_H
15351 +#define _VX_TAG_CMD_H
15354 +/* vinfo commands */
15356 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
15359 +extern int vc_task_tag(uint32_t);
15361 +#endif /* __KERNEL__ */
15363 +/* context commands */
15365 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
15368 +extern int vc_tag_migrate(uint32_t);
15370 +#endif /* __KERNEL__ */
15371 +#endif /* _VX_TAG_CMD_H */
15372 diff -Nurp linux-2.6.22.15/include/linux/vserver/tag.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/tag.h
15373 --- linux-2.6.22.15/include/linux/vserver/tag.h 1969-12-31 19:00:00.000000000 -0500
15374 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vserver/tag.h 2007-12-09 06:44:22.000000000 -0500
15379 +#include <linux/types.h>
15382 +#define DX_TAG(in) (IS_TAGGED(in))
15385 +#ifdef CONFIG_DX_TAG_NFSD
15386 +#define DX_TAG_NFSD 1
15388 +#define DX_TAG_NFSD 0
15392 +#ifdef CONFIG_TAGGING_NONE
15394 +#define MAX_UID 0xFFFFFFFF
15395 +#define MAX_GID 0xFFFFFFFF
15397 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
15399 +#define TAGINO_UID(cond, uid, tag) (uid)
15400 +#define TAGINO_GID(cond, gid, tag) (gid)
15405 +#ifdef CONFIG_TAGGING_GID16
15407 +#define MAX_UID 0xFFFFFFFF
15408 +#define MAX_GID 0x0000FFFF
15410 +#define INOTAG_TAG(cond, uid, gid, tag) \
15411 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
15413 +#define TAGINO_UID(cond, uid, tag) (uid)
15414 +#define TAGINO_GID(cond, gid, tag) \
15415 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
15420 +#ifdef CONFIG_TAGGING_ID24
15422 +#define MAX_UID 0x00FFFFFF
15423 +#define MAX_GID 0x00FFFFFF
15425 +#define INOTAG_TAG(cond, uid, gid, tag) \
15426 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
15428 +#define TAGINO_UID(cond, uid, tag) \
15429 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
15430 +#define TAGINO_GID(cond, gid, tag) \
15431 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
15436 +#ifdef CONFIG_TAGGING_UID16
15438 +#define MAX_UID 0x0000FFFF
15439 +#define MAX_GID 0xFFFFFFFF
15441 +#define INOTAG_TAG(cond, uid, gid, tag) \
15442 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
15444 +#define TAGINO_UID(cond, uid, tag) \
15445 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
15446 +#define TAGINO_GID(cond, gid, tag) (gid)
15451 +#ifdef CONFIG_TAGGING_INTERN
15453 +#define MAX_UID 0xFFFFFFFF
15454 +#define MAX_GID 0xFFFFFFFF
15456 +#define INOTAG_TAG(cond, uid, gid, tag) \
15457 + ((cond) ? (tag) : 0)
15459 +#define TAGINO_UID(cond, uid, tag) (uid)
15460 +#define TAGINO_GID(cond, gid, tag) (gid)
15465 +#ifndef CONFIG_TAGGING_NONE
15466 +#define dx_current_fstag(sb) \
15467 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
15469 +#define dx_current_fstag(sb) (0)
15472 +#ifndef CONFIG_TAGGING_INTERN
15473 +#define TAGINO_TAG(cond, tag) (0)
15475 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
15478 +#define INOTAG_UID(cond, uid, gid) \
15479 + ((cond) ? ((uid) & MAX_UID) : (uid))
15480 +#define INOTAG_GID(cond, uid, gid) \
15481 + ((cond) ? ((gid) & MAX_GID) : (gid))
15484 +static inline uid_t dx_map_uid(uid_t uid)
15486 + if ((uid > MAX_UID) && (uid != -1))
15488 + return (uid & MAX_UID);
15491 +static inline gid_t dx_map_gid(gid_t gid)
15493 + if ((gid > MAX_GID) && (gid != -1))
15495 + return (gid & MAX_GID);
15503 +#define dx_notagcheck(nd) \
15504 + ((nd) && (nd)->mnt && ((nd)->mnt->mnt_flags & MNT_NOTAGCHECK))
15506 +int dx_parse_tag(char *string, tag_t *tag, int remove);
15508 +#ifdef CONFIG_PROPAGATE
15510 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
15512 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
15515 +#define dx_propagate_tag(n, i) do { } while (0)
15518 +#endif /* _DX_TAG_H */
15519 diff -Nurp linux-2.6.22.15/include/linux/vs_inet6.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_inet6.h
15520 --- linux-2.6.22.15/include/linux/vs_inet6.h 1969-12-31 19:00:00.000000000 -0500
15521 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_inet6.h 2007-12-09 06:44:22.000000000 -0500
15523 +#ifndef _VS_INET6_H
15524 +#define _VS_INET6_H
15526 +#include <net/ipv6.h>
15527 +#include "vserver/base.h"
15528 +#include "vserver/network.h"
15529 +#include "vserver/debug.h"
15531 +#define NXAV6(a) NIP6((a)->ip), NIP6((a)->mask), (a)->prefix, (a)->type
15532 +#define NXAV6_FMT "[" NIP6_FMT "/" NIP6_FMT "/%d:%04x]"
15535 +#ifdef CONFIG_IPV6
15538 +int v6_addr_match(struct nx_addr_v6 *nxa,
15539 + const struct in6_addr *addr, uint16_t mask)
15541 + switch (nxa->type & mask) {
15542 + case NXA_TYPE_MASK:
15543 + return ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
15544 + case NXA_TYPE_ADDR:
15545 + return ipv6_addr_equal(&nxa->ip, addr);
15546 + case NXA_TYPE_ANY:
15554 +int v6_addr_in_nx_info(struct nx_info *nxi,
15555 + const struct in6_addr *addr, uint16_t mask)
15557 + struct nx_addr_v6 *nxa;
15561 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
15562 + if (v6_addr_match(nxa, addr, mask))
15568 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
15570 + /* FIXME: needs full range checks */
15571 + return v6_addr_match(nxa, &addr->ip, mask);
15575 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
15577 + struct nx_addr_v6 *ptr;
15579 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
15580 + if (v6_nx_addr_match(ptr, nxa, mask))
15587 + * Check if a given address matches for a socket
15589 + * nxi: the socket's nx_info if any
15590 + * addr: to be verified address
15593 +int v6_sock_addr_match (
15594 + struct nx_info *nxi,
15595 + struct inet_sock *inet,
15596 + struct in6_addr *addr)
15598 + struct sock *sk = &inet->sk;
15599 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
15601 + if (!ipv6_addr_any(addr) &&
15602 + ipv6_addr_equal(saddr, addr))
15604 + if (ipv6_addr_any(saddr))
15605 + return v6_addr_in_nx_info(nxi, addr, -1);
15610 + * check if address is covered by socket
15612 + * sk: the socket to check against
15613 + * addr: the address in question (must be != 0)
15617 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
15619 + struct nx_info *nxi = sk->sk_nx_info;
15620 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
15622 + vxdprintk(VXD_CBIT(net, 5),
15623 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:" NIP6_FMT " %p;%lx",
15624 + sk, NXAV6(nxa), nxi, NIP6(*saddr), sk->sk_socket,
15625 + (sk->sk_socket?sk->sk_socket->flags:0));
15627 + if (!ipv6_addr_any(saddr)) { /* direct address match */
15628 + return v6_addr_match(nxa, saddr, -1);
15629 + } else if (nxi) { /* match against nx_info */
15630 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
15631 + } else { /* unrestricted any socket */
15637 +/* inet related checks and helpers */
15641 +struct net_device;
15645 +#include <linux/netdevice.h>
15646 +#include <linux/inetdevice.h>
15647 +#include <net/inet_timewait_sock.h>
15650 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15651 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
15652 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
15657 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
15663 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
15667 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
15669 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15671 + if (v6_ifa_in_nx_info(ifa, nxi))
15677 +struct nx_v6_sock_addr {
15678 + struct in6_addr saddr; /* Address used for validation */
15679 + struct in6_addr baddr; /* Address used for socket bind */
15683 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
15684 + struct nx_v6_sock_addr *nsa)
15686 + // struct sock *sk = &inet->sk;
15687 + // struct nx_info *nxi = sk->sk_nx_info;
15688 + struct in6_addr saddr = addr->sin6_addr;
15689 + struct in6_addr baddr = saddr;
15691 + nsa->saddr = saddr;
15692 + nsa->baddr = baddr;
15697 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
15699 + // struct sock *sk = &inet->sk;
15700 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
15702 + // *saddr = nsa->baddr;
15703 + // inet->saddr = nsa->baddr;
15707 +int nx_info_has_v6(struct nx_info *nxi)
15711 + if (NX_IPV6(nxi))
15716 +#else /* CONFIG_IPV6 */
15719 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
15726 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
15732 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
15738 +int nx_info_has_v6(struct nx_info *nxi)
15743 +#endif /* CONFIG_IPV6 */
15745 +#define current_nx_info_has_v6() \
15746 + nx_info_has_v6(current_nx_info())
15749 +#warning duplicate inclusion
15751 diff -Nurp linux-2.6.22.15/include/linux/vs_inet.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_inet.h
15752 --- linux-2.6.22.15/include/linux/vs_inet.h 1969-12-31 19:00:00.000000000 -0500
15753 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_inet.h 2007-12-09 06:44:22.000000000 -0500
15755 +#ifndef _VS_INET_H
15756 +#define _VS_INET_H
15758 +#include "vserver/base.h"
15759 +#include "vserver/network.h"
15760 +#include "vserver/debug.h"
15762 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
15764 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
15765 + NIPQUAD((a)->mask), (a)->type
15766 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
15770 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
15772 + __be32 ip = nxa->ip[0].s_addr;
15773 + __be32 mask = nxa->mask.s_addr;
15774 + __be32 bcast = ip | ~mask;
15777 + switch (nxa->type & tmask) {
15778 + case NXA_TYPE_MASK:
15779 + ret = (ip == (addr & mask));
15781 + case NXA_TYPE_ADDR:
15785 + /* fall through to broadcast */
15786 + case NXA_MOD_BCAST:
15787 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
15789 + case NXA_TYPE_RANGE:
15790 + ret = ((nxa->ip[0].s_addr <= addr) &&
15791 + (nxa->ip[1].s_addr > addr));
15793 + case NXA_TYPE_ANY:
15798 + vxdprintk(VXD_CBIT(net, 0),
15799 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
15800 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
15805 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
15807 + struct nx_addr_v4 *nxa;
15814 + /* allow 127.0.0.1 when remapping lback */
15815 + if ((tmask & NXA_LOOPBACK) &&
15816 + (addr == IPI_LOOPBACK) &&
15817 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15820 + /* check for lback address */
15821 + if ((tmask & NXA_MOD_LBACK) &&
15822 + (nxi->v4_lback.s_addr == addr))
15825 + /* check for broadcast address */
15826 + if ((tmask & NXA_MOD_BCAST) &&
15827 + (nxi->v4_bcast.s_addr == addr))
15830 + /* check for v4 addresses */
15831 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
15832 + if (v4_addr_match(nxa, addr, tmask))
15836 + vxdprintk(VXD_CBIT(net, 0),
15837 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
15838 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
15843 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
15845 + /* FIXME: needs full range checks */
15846 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
15850 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
15852 + struct nx_addr_v4 *ptr;
15854 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
15855 + if (v4_nx_addr_match(ptr, nxa, mask))
15860 +#include <net/inet_sock.h>
15863 + * Check if a given address matches for a socket
15865 + * nxi: the socket's nx_info if any
15866 + * addr: to be verified address
15869 +int v4_sock_addr_match (
15870 + struct nx_info *nxi,
15871 + struct inet_sock *inet,
15874 + __be32 saddr = inet->rcv_saddr;
15875 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
15877 + if (addr && (saddr == addr || bcast == addr))
15880 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
15885 +/* inet related checks and helpers */
15889 +struct net_device;
15892 +#ifdef CONFIG_INET
15894 +#include <linux/netdevice.h>
15895 +#include <linux/inetdevice.h>
15896 +#include <net/inet_timewait_sock.h>
15899 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15900 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
15901 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
15905 + * check if address is covered by socket
15907 + * sk: the socket to check against
15908 + * addr: the address in question (must be != 0)
15912 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
15914 + struct nx_info *nxi = sk->sk_nx_info;
15915 + __be32 saddr = inet_rcv_saddr(sk);
15917 + vxdprintk(VXD_CBIT(net, 5),
15918 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
15919 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
15920 + (sk->sk_socket?sk->sk_socket->flags:0));
15922 + if (saddr) { /* direct address match */
15923 + return v4_addr_match(nxa, saddr, -1);
15924 + } else if (nxi) { /* match against nx_info */
15925 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
15926 + } else { /* unrestricted any socket */
15934 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
15936 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
15937 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
15938 + nxi ? dev_in_nx_info(dev, nxi) : 0);
15940 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15942 + if (dev_in_nx_info(dev, nxi))
15949 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
15955 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
15959 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
15961 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
15962 + nxi, nxi ? nxi->nx_id : 0, ifa,
15963 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
15965 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15967 + if (v4_ifa_in_nx_info(ifa, nxi))
15973 +struct nx_v4_sock_addr {
15974 + __be32 saddr; /* Address used for validation */
15975 + __be32 baddr; /* Address used for socket bind */
15979 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
15980 + struct nx_v4_sock_addr *nsa)
15982 + struct sock *sk = &inet->sk;
15983 + struct nx_info *nxi = sk->sk_nx_info;
15984 + __be32 saddr = addr->sin_addr.s_addr;
15985 + __be32 baddr = saddr;
15987 + vxdprintk(VXD_CBIT(net, 3),
15988 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
15989 + sk, sk->sk_nx_info, sk->sk_socket,
15990 + (sk->sk_socket ? sk->sk_socket->flags : 0),
15994 + if (saddr == INADDR_ANY) {
15995 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
15996 + baddr = nxi->v4.ip[0].s_addr;
15997 + } else if (saddr == IPI_LOOPBACK) {
15998 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15999 + baddr = nxi->v4_lback.s_addr;
16000 + } else { /* normal address bind */
16001 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
16002 + return -EADDRNOTAVAIL;
16006 + vxdprintk(VXD_CBIT(net, 3),
16007 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
16008 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
16010 + nsa->saddr = saddr;
16011 + nsa->baddr = baddr;
16016 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
16018 + inet->saddr = nsa->baddr;
16019 + inet->rcv_saddr = nsa->baddr;
16024 + * helper to simplify inet_lookup_listener
16026 + * nxi: the socket's nx_info if any
16027 + * addr: to be verified address
16028 + * saddr: socket address
16030 +static inline int v4_inet_addr_match (
16031 + struct nx_info *nxi,
16035 + if (addr && (saddr == addr))
16038 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
16042 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
16044 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
16045 + (addr == nxi->v4_lback.s_addr))
16046 + return IPI_LOOPBACK;
16051 +int nx_info_has_v4(struct nx_info *nxi)
16055 + if (NX_IPV4(nxi))
16057 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
16062 +#else /* CONFIG_INET */
16065 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
16071 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
16077 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
16083 +int nx_info_has_v4(struct nx_info *nxi)
16088 +#endif /* CONFIG_INET */
16090 +#define current_nx_info_has_v4() \
16091 + nx_info_has_v4(current_nx_info())
16094 +#warning duplicate inclusion
16096 diff -Nurp linux-2.6.22.15/include/linux/vs_limit.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_limit.h
16097 --- linux-2.6.22.15/include/linux/vs_limit.h 1969-12-31 19:00:00.000000000 -0500
16098 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_limit.h 2007-12-09 06:44:22.000000000 -0500
16100 +#ifndef _VS_LIMIT_H
16101 +#define _VS_LIMIT_H
16103 +#include "vserver/limit.h"
16104 +#include "vserver/base.h"
16105 +#include "vserver/context.h"
16106 +#include "vserver/debug.h"
16107 +#include "vserver/context.h"
16108 +#include "vserver/limit_int.h"
16111 +#define vx_acc_cres(v, d, p, r) \
16112 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
16114 +#define vx_acc_cres_cond(x, d, p, r) \
16115 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
16116 + r, d, p, __FILE__, __LINE__)
16119 +#define vx_add_cres(v, a, p, r) \
16120 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
16121 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
16123 +#define vx_add_cres_cond(x, a, p, r) \
16124 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
16125 + r, a, p, __FILE__, __LINE__)
16126 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
16129 +/* process and file limits */
16131 +#define vx_nproc_inc(p) \
16132 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
16134 +#define vx_nproc_dec(p) \
16135 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
16137 +#define vx_files_inc(f) \
16138 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
16140 +#define vx_files_dec(f) \
16141 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
16143 +#define vx_locks_inc(l) \
16144 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
16146 +#define vx_locks_dec(l) \
16147 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
16149 +#define vx_openfd_inc(f) \
16150 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
16152 +#define vx_openfd_dec(f) \
16153 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
16156 +#define vx_cres_avail(v, n, r) \
16157 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
16160 +#define vx_nproc_avail(n) \
16161 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
16163 +#define vx_files_avail(n) \
16164 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
16166 +#define vx_locks_avail(n) \
16167 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
16169 +#define vx_openfd_avail(n) \
16170 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
16173 +/* dentry limits */
16175 +#define vx_dentry_inc(d) do { \
16176 + if (atomic_read(&d->d_count) == 1) \
16177 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
16180 +#define vx_dentry_dec(d) do { \
16181 + if (atomic_read(&d->d_count) == 0) \
16182 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
16185 +#define vx_dentry_avail(n) \
16186 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
16189 +/* socket limits */
16191 +#define vx_sock_inc(s) \
16192 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
16194 +#define vx_sock_dec(s) \
16195 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
16197 +#define vx_sock_avail(n) \
16198 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
16201 +/* ipc resource limits */
16203 +#define vx_ipcmsg_add(v, u, a) \
16204 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
16206 +#define vx_ipcmsg_sub(v, u, a) \
16207 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
16209 +#define vx_ipcmsg_avail(v, a) \
16210 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
16213 +#define vx_ipcshm_add(v, k, a) \
16214 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
16216 +#define vx_ipcshm_sub(v, k, a) \
16217 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
16219 +#define vx_ipcshm_avail(v, a) \
16220 + vx_cres_avail(v, a, VLIMIT_SHMEM)
16223 +#define vx_semary_inc(a) \
16224 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
16226 +#define vx_semary_dec(a) \
16227 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
16230 +#define vx_nsems_add(a,n) \
16231 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
16233 +#define vx_nsems_sub(a,n) \
16234 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
16238 +#warning duplicate inclusion
16240 diff -Nurp linux-2.6.22.15/include/linux/vs_memory.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_memory.h
16241 --- linux-2.6.22.15/include/linux/vs_memory.h 1969-12-31 19:00:00.000000000 -0500
16242 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_memory.h 2007-12-09 06:44:22.000000000 -0500
16244 +#ifndef _VS_MEMORY_H
16245 +#define _VS_MEMORY_H
16247 +#include "vserver/limit.h"
16248 +#include "vserver/base.h"
16249 +#include "vserver/context.h"
16250 +#include "vserver/debug.h"
16251 +#include "vserver/context.h"
16252 +#include "vserver/limit_int.h"
16255 +#define __acc_add_long(a, v) (*(v) += (a))
16256 +#define __acc_inc_long(v) (++*(v))
16257 +#define __acc_dec_long(v) (--*(v))
16259 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
16260 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
16261 +#define __acc_inc_atomic(v) atomic_long_inc(v)
16262 +#define __acc_dec_atomic(v) atomic_long_dec(v)
16263 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
16264 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
16265 +#define __acc_inc_atomic(v) __acc_inc_long(v)
16266 +#define __acc_dec_atomic(v) __acc_dec_long(v)
16267 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
16270 +#define vx_acc_page(m, d, v, r) do { \
16272 + __acc_inc_long(&(m)->v); \
16274 + __acc_dec_long(&(m)->v); \
16275 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
16278 +#define vx_acc_page_atomic(m, d, v, r) do { \
16280 + __acc_inc_atomic(&(m)->v); \
16282 + __acc_dec_atomic(&(m)->v); \
16283 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
16287 +#define vx_acc_pages(m, p, v, r) do { \
16288 + unsigned long __p = (p); \
16289 + __acc_add_long(__p, &(m)->v); \
16290 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
16293 +#define vx_acc_pages_atomic(m, p, v, r) do { \
16294 + unsigned long __p = (p); \
16295 + __acc_add_atomic(__p, &(m)->v); \
16296 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
16301 +#define vx_acc_vmpage(m, d) \
16302 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
16303 +#define vx_acc_vmlpage(m, d) \
16304 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
16305 +#define vx_acc_file_rsspage(m, d) \
16306 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
16307 +#define vx_acc_anon_rsspage(m, d) \
16308 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
16310 +#define vx_acc_vmpages(m, p) \
16311 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
16312 +#define vx_acc_vmlpages(m, p) \
16313 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
16314 +#define vx_acc_file_rsspages(m, p) \
16315 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
16316 +#define vx_acc_anon_rsspages(m, p) \
16317 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
16319 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
16320 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
16322 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
16323 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
16324 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
16325 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
16327 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
16328 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
16329 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
16330 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
16332 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
16333 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
16334 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
16335 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
16337 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
16338 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
16339 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
16340 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
16343 +#define vx_pages_avail(m, p, r) \
16344 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
16346 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
16347 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
16348 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
16349 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
16351 +#define vx_rss_avail(m, p) \
16352 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
16356 + VXPT_UNKNOWN = 0,
16365 +#define vx_page_fault(mm, vma, type, ret)
16369 +void __vx_page_fault(struct mm_struct *mm,
16370 + struct vm_area_struct *vma, int type, int ret)
16372 + struct vx_info *vxi = mm->mm_vx_info;
16375 + static char *page_type[6] =
16376 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
16377 + static char *page_what[4] =
16378 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
16384 + what = (ret & 0x3);
16386 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
16387 + type, what, ret, page_type[type], page_what[what]);
16389 + if (ret & VM_FAULT_WRITE)
16391 + atomic_inc(&vxi->cacct.page[type][what]);
16394 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
16398 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
16401 +#warning duplicate inclusion
16403 diff -Nurp linux-2.6.22.15/include/linux/vs_network.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_network.h
16404 --- linux-2.6.22.15/include/linux/vs_network.h 1969-12-31 19:00:00.000000000 -0500
16405 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_network.h 2007-12-09 06:44:22.000000000 -0500
16407 +#ifndef _NX_VS_NETWORK_H
16408 +#define _NX_VS_NETWORK_H
16410 +#include "vserver/context.h"
16411 +#include "vserver/network.h"
16412 +#include "vserver/base.h"
16413 +#include "vserver/debug.h"
16416 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
16418 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
16419 + const char *_file, int _line)
16424 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
16425 + nxi, nxi ? nxi->nx_id : 0,
16426 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16429 + atomic_inc(&nxi->nx_usecnt);
16434 +extern void free_nx_info(struct nx_info *);
16436 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
16438 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
16443 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
16444 + nxi, nxi ? nxi->nx_id : 0,
16445 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16448 + if (atomic_dec_and_test(&nxi->nx_usecnt))
16449 + free_nx_info(nxi);
16453 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
16455 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
16456 + const char *_file, int _line)
16459 + vxlprintk(VXD_CBIT(nid, 3),
16460 + "init_nx_info(%p[#%d.%d])",
16461 + nxi, nxi ? nxi->nx_id : 0,
16462 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16465 + atomic_inc(&nxi->nx_usecnt);
16471 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
16473 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
16474 + const char *_file, int _line)
16476 + struct nx_info *nxo;
16481 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
16482 + nxi, nxi ? nxi->nx_id : 0,
16483 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16486 + atomic_inc(&nxi->nx_usecnt);
16487 + nxo = xchg(nxp, nxi);
16491 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
16493 +static inline void __clr_nx_info(struct nx_info **nxp,
16494 + const char *_file, int _line)
16496 + struct nx_info *nxo;
16498 + nxo = xchg(nxp, NULL);
16502 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
16503 + nxo, nxo ? nxo->nx_id : 0,
16504 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
16507 + if (atomic_dec_and_test(&nxo->nx_usecnt))
16508 + free_nx_info(nxo);
16512 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
16514 +static inline void __claim_nx_info(struct nx_info *nxi,
16515 + struct task_struct *task, const char *_file, int _line)
16517 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
16518 + nxi, nxi ? nxi->nx_id : 0,
16519 + nxi?atomic_read(&nxi->nx_usecnt):0,
16520 + nxi?atomic_read(&nxi->nx_tasks):0,
16521 + task, _file, _line);
16523 + atomic_inc(&nxi->nx_tasks);
16527 +extern void unhash_nx_info(struct nx_info *);
16529 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
16531 +static inline void __release_nx_info(struct nx_info *nxi,
16532 + struct task_struct *task, const char *_file, int _line)
16534 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
16535 + nxi, nxi ? nxi->nx_id : 0,
16536 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16537 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
16538 + task, _file, _line);
16542 + if (atomic_dec_and_test(&nxi->nx_tasks))
16543 + unhash_nx_info(nxi);
16547 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
16549 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
16550 + const char *_file, int _line)
16552 + struct nx_info *nxi;
16555 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
16556 + p, _file, _line);
16557 + nxi = __get_nx_info(p->nx_info, _file, _line);
16563 +static inline void exit_nx_info(struct task_struct *p)
16566 + release_nx_info(p->nx_info, p);
16571 +#warning duplicate inclusion
16573 diff -Nurp linux-2.6.22.15/include/linux/vs_pid.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_pid.h
16574 --- linux-2.6.22.15/include/linux/vs_pid.h 1969-12-31 19:00:00.000000000 -0500
16575 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_pid.h 2007-12-09 06:44:22.000000000 -0500
16580 +#include "vserver/base.h"
16581 +#include "vserver/context.h"
16582 +#include "vserver/debug.h"
16583 +#include <linux/pid_namespace.h>
16586 +/* pid faking stuff */
16589 +#define vx_info_map_pid(v, p) \
16590 + __vx_info_map_pid((v), (p), __FUNC__, __FILE__, __LINE__)
16591 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
16592 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
16593 +#define vx_map_tgid(p) vx_map_pid(p)
16595 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
16596 + const char *func, const char *file, int line)
16598 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
16599 + vxfprintk(VXD_CBIT(cvirt, 2),
16600 + "vx_map_tgid: %p/%llx: %d -> %d",
16601 + vxi, (long long)vxi->vx_flags, pid,
16602 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
16603 + func, file, line);
16606 + if (pid == vxi->vx_initpid)
16612 +#define vx_info_rmap_pid(v, p) \
16613 + __vx_info_rmap_pid((v), (p), __FUNC__, __FILE__, __LINE__)
16614 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
16615 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
16617 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
16618 + const char *func, const char *file, int line)
16620 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
16621 + vxfprintk(VXD_CBIT(cvirt, 2),
16622 + "vx_rmap_tgid: %p/%llx: %d -> %d",
16623 + vxi, (long long)vxi->vx_flags, pid,
16624 + (pid == 1) ? vxi->vx_initpid : pid,
16625 + func, file, line);
16626 + if ((pid == 1) && vxi->vx_initpid)
16627 + return vxi->vx_initpid;
16628 + if (pid == vxi->vx_initpid)
16635 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
16638 +int vx_proc_task_visible(struct task_struct *task)
16640 + if ((task->pid == 1) &&
16641 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
16642 + /* show a blend through init */
16644 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
16652 +struct task_struct *vx_find_proc_task_by_pid(int pid)
16654 + struct task_struct *task = find_task_by_pid(pid);
16656 + if (task && !vx_proc_task_visible(task)) {
16657 + vxdprintk(VXD_CBIT(misc, 6),
16658 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
16659 + task, task->xid, task->pid,
16660 + current, current->xid, current->pid);
16667 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
16669 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
16671 + if (task && !vx_proc_task_visible(task)) {
16672 + vxdprintk(VXD_CBIT(misc, 6),
16673 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
16674 + task, task->xid, task->pid,
16675 + current, current->xid, current->pid);
16676 + put_task_struct(task);
16684 +struct task_struct *vx_child_reaper(struct task_struct *p)
16686 + struct vx_info *vxi = p->vx_info;
16687 + struct task_struct *reaper = child_reaper(p);
16692 + BUG_ON(!p->vx_info->vx_reaper);
16694 + /* child reaper for the guest reaper */
16695 + if (vxi->vx_reaper == p)
16698 + reaper = vxi->vx_reaper;
16700 + vxdprintk(VXD_CBIT(xid, 7),
16701 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
16702 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
16708 +#warning duplicate inclusion
16710 diff -Nurp linux-2.6.22.15/include/linux/vs_sched.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_sched.h
16711 --- linux-2.6.22.15/include/linux/vs_sched.h 1969-12-31 19:00:00.000000000 -0500
16712 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_sched.h 2007-12-09 06:44:22.000000000 -0500
16714 +#ifndef _VS_SCHED_H
16715 +#define _VS_SCHED_H
16717 +#include "vserver/base.h"
16718 +#include "vserver/context.h"
16719 +#include "vserver/sched.h"
16722 +#define VAVAVOOM_RATIO 50
16724 +#define MAX_PRIO_BIAS 20
16725 +#define MIN_PRIO_BIAS -20
16728 +#ifdef CONFIG_VSERVER_HARDCPU
16731 + * effective_prio - return the priority that is based on the static
16732 + * priority but is modified by bonuses/penalties.
16734 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
16735 + * into a -4 ... 0 ... +4 bonus/penalty range.
16737 + * Additionally, we scale another amount based on the number of
16738 + * CPU tokens currently held by the context, if the process is
16739 + * part of a context (and the appropriate SCHED flag is set).
16740 + * This ranges from -5 ... 0 ... +15, quadratically.
16742 + * So, the total bonus is -9 .. 0 .. +19
16743 + * We use ~50% of the full 0...39 priority range so that:
16745 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
16746 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
16747 + * unless that context is far exceeding its CPU allocation.
16749 + * Both properties are important to certain workloads.
16752 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
16754 + int vavavoom, max;
16756 + /* lots of tokens = lots of vavavoom
16757 + * no tokens = no vavavoom */
16758 + if ((vavavoom = sched_pc->tokens) >= 0) {
16759 + max = sched_pc->tokens_max;
16760 + vavavoom = max - vavavoom;
16762 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
16763 + * (vavavoom*vavavoom - (max >> 2)) / max;
16771 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
16773 + struct vx_info *vxi = p->vx_info;
16774 + struct _vx_sched_pc *sched_pc;
16779 + sched_pc = &vx_cpu(vxi, sched_pc);
16780 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
16781 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
16783 + sched_pc->vavavoom = vavavoom;
16784 + prio += vavavoom;
16786 + prio += sched_pc->prio_bias;
16790 +#else /* !CONFIG_VSERVER_HARDCPU */
16793 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
16795 + struct vx_info *vxi = p->vx_info;
16798 + prio += vx_cpu(vxi, sched_pc).prio_bias;
16802 +#endif /* CONFIG_VSERVER_HARDCPU */
16805 +static inline void vx_account_user(struct vx_info *vxi,
16806 + cputime_t cputime, int nice)
16810 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
16813 +static inline void vx_account_system(struct vx_info *vxi,
16814 + cputime_t cputime, int idle)
16818 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
16822 +#warning duplicate inclusion
16824 diff -Nurp linux-2.6.22.15/include/linux/vs_socket.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_socket.h
16825 --- linux-2.6.22.15/include/linux/vs_socket.h 1969-12-31 19:00:00.000000000 -0500
16826 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_socket.h 2007-12-09 06:44:22.000000000 -0500
16828 +#ifndef _VS_SOCKET_H
16829 +#define _VS_SOCKET_H
16831 +#include "vserver/debug.h"
16832 +#include "vserver/base.h"
16833 +#include "vserver/cacct.h"
16834 +#include "vserver/context.h"
16835 +#include "vserver/tag.h"
16838 +/* socket accounting */
16840 +#include <linux/socket.h>
16842 +static inline int vx_sock_type(int family)
16844 + switch (family) {
16846 + return VXA_SOCK_UNSPEC;
16848 + return VXA_SOCK_UNIX;
16850 + return VXA_SOCK_INET;
16852 + return VXA_SOCK_INET6;
16854 + return VXA_SOCK_PACKET;
16856 + return VXA_SOCK_OTHER;
16860 +#define vx_acc_sock(v, f, p, s) \
16861 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
16863 +static inline void __vx_acc_sock(struct vx_info *vxi,
16864 + int family, int pos, int size, char *file, int line)
16867 + int type = vx_sock_type(family);
16869 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
16870 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
16874 +#define vx_sock_recv(sk, s) \
16875 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
16876 +#define vx_sock_send(sk, s) \
16877 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
16878 +#define vx_sock_fail(sk, s) \
16879 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
16882 +#define sock_vx_init(s) do { \
16883 + (s)->sk_xid = 0; \
16884 + (s)->sk_vx_info = NULL; \
16887 +#define sock_nx_init(s) do { \
16888 + (s)->sk_nid = 0; \
16889 + (s)->sk_nx_info = NULL; \
16893 +int vx_socket_peer_tag(struct socket *sock, int level,
16894 + char __user *optval, int __user *optlen, int len)
16896 + struct peer_tag tag;
16898 + tag.xid = sock->sk->sk_xid;
16899 + tag.nid = sock->sk->sk_nid;
16900 + if (copy_to_user(optval, &tag, sizeof(tag)))
16906 +#warning duplicate inclusion
16908 diff -Nurp linux-2.6.22.15/include/linux/vs_tag.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_tag.h
16909 --- linux-2.6.22.15/include/linux/vs_tag.h 1969-12-31 19:00:00.000000000 -0500
16910 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_tag.h 2007-12-09 06:44:22.000000000 -0500
16915 +#include <linux/vserver/tag.h>
16917 +/* check conditions */
16919 +#define DX_ADMIN 0x0001
16920 +#define DX_WATCH 0x0002
16921 +#define DX_HOSTID 0x0008
16923 +#define DX_IDENT 0x0010
16925 +#define DX_ARG_MASK 0x0010
16928 +#define dx_task_tag(t) ((t)->tag)
16930 +#define dx_current_tag() dx_task_tag(current)
16932 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
16934 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
16938 + * check current context for ADMIN/WATCH and
16939 + * optionally against supplied argument
16941 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
16943 + if (mode & DX_ARG_MASK) {
16944 + if ((mode & DX_IDENT) && (id == cid))
16947 + return (((mode & DX_ADMIN) && (cid == 0)) ||
16948 + ((mode & DX_WATCH) && (cid == 1)) ||
16949 + ((mode & DX_HOSTID) && (id == 0)));
16953 +#warning duplicate inclusion
16955 diff -Nurp linux-2.6.22.15/include/linux/vs_time.h linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_time.h
16956 --- linux-2.6.22.15/include/linux/vs_time.h 1969-12-31 19:00:00.000000000 -0500
16957 +++ linux-2.6.22.15-vs2.3.0.29.1/include/linux/vs_time.h 2007-12-09 06:44:22.000000000 -0500
16959 +#ifndef _VS_TIME_H
16960 +#define _VS_TIME_H
16963 +/* time faking stuff */
16965 +#ifdef CONFIG_VSERVER_VTIME
16967 +extern void vx_gettimeofday(struct timeval *tv);
16968 +extern int vx_settimeofday(struct timespec *ts);
16971 +#define vx_gettimeofday(t) do_gettimeofday(t)
16972 +#define vx_settimeofday(t) do_settimeofday(t)
16976 +#warning duplicate inclusion
16978 diff -Nurp linux-2.6.22.15/include/net/addrconf.h linux-2.6.22.15-vs2.3.0.29.1/include/net/addrconf.h
16979 --- linux-2.6.22.15/include/net/addrconf.h 2007-07-21 18:00:24.000000000 -0400
16980 +++ linux-2.6.22.15-vs2.3.0.29.1/include/net/addrconf.h 2007-12-09 06:44:22.000000000 -0500
16981 @@ -69,10 +69,12 @@ extern struct inet6_ifaddr * ipv6_get_if
16983 extern int ipv6_get_saddr(struct dst_entry *dst,
16984 struct in6_addr *daddr,
16985 - struct in6_addr *saddr);
16986 + struct in6_addr *saddr,
16987 + struct nx_info *nxi);
16988 extern int ipv6_dev_get_saddr(struct net_device *dev,
16989 struct in6_addr *daddr,
16990 - struct in6_addr *saddr);
16991 + struct in6_addr *saddr,
16992 + struct nx_info *nxi);
16993 extern int ipv6_get_lladdr(struct net_device *dev,
16994 struct in6_addr *addr,
16995 unsigned char banned_flags);
16996 diff -Nurp linux-2.6.22.15/include/net/af_unix.h linux-2.6.22.15-vs2.3.0.29.1/include/net/af_unix.h
16997 --- linux-2.6.22.15/include/net/af_unix.h 2007-07-21 18:00:24.000000000 -0400
16998 +++ linux-2.6.22.15-vs2.3.0.29.1/include/net/af_unix.h 2007-12-09 06:44:22.000000000 -0500
17000 #include <linux/socket.h>
17001 #include <linux/un.h>
17002 #include <linux/mutex.h>
17003 +#include <linux/vs_base.h>
17004 #include <net/sock.h>
17006 extern void unix_inflight(struct file *fp);
17007 @@ -17,9 +18,9 @@ extern spinlock_t unix_table_lock;
17009 extern atomic_t unix_tot_inflight;
17011 -static inline struct sock *first_unix_socket(int *i)
17012 +static inline struct sock *next_unix_socket_table(int *i)
17014 - for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
17015 + for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
17016 if (!hlist_empty(&unix_socket_table[*i]))
17017 return __sk_head(&unix_socket_table[*i]);
17019 @@ -28,16 +29,19 @@ static inline struct sock *first_unix_so
17021 static inline struct sock *next_unix_socket(int *i, struct sock *s)
17023 - struct sock *next = sk_next(s);
17024 - /* More in this chain? */
17027 - /* Look for next non-empty chain. */
17028 - for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
17029 - if (!hlist_empty(&unix_socket_table[*i]))
17030 - return __sk_head(&unix_socket_table[*i]);
17037 + s = next_unix_socket_table(i);
17038 + } while (s && !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT));
17042 +static inline struct sock *first_unix_socket(int *i)
17045 + return next_unix_socket(i, NULL);
17048 #define forall_unix_sockets(i, s) \
17049 diff -Nurp linux-2.6.22.15/include/net/inet_timewait_sock.h linux-2.6.22.15-vs2.3.0.29.1/include/net/inet_timewait_sock.h
17050 --- linux-2.6.22.15/include/net/inet_timewait_sock.h 2007-07-21 17:58:53.000000000 -0400
17051 +++ linux-2.6.22.15-vs2.3.0.29.1/include/net/inet_timewait_sock.h 2007-12-09 06:44:22.000000000 -0500
17052 @@ -115,6 +115,10 @@ struct inet_timewait_sock {
17053 #define tw_refcnt __tw_common.skc_refcnt
17054 #define tw_hash __tw_common.skc_hash
17055 #define tw_prot __tw_common.skc_prot
17056 +#define tw_xid __tw_common.skc_xid
17057 +#define tw_vx_info __tw_common.skc_vx_info
17058 +#define tw_nid __tw_common.skc_nid
17059 +#define tw_nx_info __tw_common.skc_nx_info
17060 volatile unsigned char tw_substate;
17061 /* 3 bits hole, try to pack */
17062 unsigned char tw_rcv_wscale;
17063 diff -Nurp linux-2.6.22.15/include/net/route.h linux-2.6.22.15-vs2.3.0.29.1/include/net/route.h
17064 --- linux-2.6.22.15/include/net/route.h 2007-07-21 17:58:53.000000000 -0400
17065 +++ linux-2.6.22.15-vs2.3.0.29.1/include/net/route.h 2007-12-09 06:44:22.000000000 -0500
17066 @@ -27,12 +27,16 @@
17067 #include <net/dst.h>
17068 #include <net/inetpeer.h>
17069 #include <net/flow.h>
17070 +#include <net/inet_sock.h>
17071 #include <linux/in_route.h>
17072 #include <linux/rtnetlink.h>
17073 #include <linux/route.h>
17074 #include <linux/ip.h>
17075 #include <linux/cache.h>
17076 #include <linux/security.h>
17077 +#include <linux/vs_base.h>
17078 +#include <linux/vs_inet.h>
17079 +#include <linux/in.h>
17082 #warning This file is not supposed to be used outside of kernel.
17083 @@ -143,6 +147,8 @@ static inline char rt_tos2priority(u8 to
17084 return ip_tos2prio[IPTOS_TOS(tos)>>1];
17087 +extern int ip_v4_find_src(struct nx_info *, struct rtable **, struct flowi *);
17089 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
17090 __be32 src, u32 tos, int oif, u8 protocol,
17091 __be16 sport, __be16 dport, struct sock *sk,
17092 @@ -158,7 +164,21 @@ static inline int ip_route_connect(struc
17093 .dport = dport } } };
17096 - if (!dst || !src) {
17097 + struct nx_info *nx_info = current->nx_info;
17100 + nx_info = sk->sk_nx_info;
17102 + vxdprintk(VXD_CBIT(net, 4),
17103 + "ip_route_connect(%p) %p,%p;%lx",
17104 + sk, nx_info, sk->sk_socket,
17105 + (sk->sk_socket?sk->sk_socket->flags:0));
17107 + err = ip_v4_find_src(nx_info, rp, &fl);
17111 + if (!fl.fl4_dst || !fl.fl4_src) {
17112 err = __ip_route_output_key(rp, &fl);
17115 diff -Nurp linux-2.6.22.15/include/net/sock.h linux-2.6.22.15-vs2.3.0.29.1/include/net/sock.h
17116 --- linux-2.6.22.15/include/net/sock.h 2007-07-21 18:00:24.000000000 -0400
17117 +++ linux-2.6.22.15-vs2.3.0.29.1/include/net/sock.h 2007-12-09 06:44:22.000000000 -0500
17118 @@ -119,6 +119,10 @@ struct sock_common {
17119 atomic_t skc_refcnt;
17120 unsigned int skc_hash;
17121 struct proto *skc_prot;
17123 + struct vx_info *skc_vx_info;
17125 + struct nx_info *skc_nx_info;
17129 @@ -195,6 +199,10 @@ struct sock {
17130 #define sk_refcnt __sk_common.skc_refcnt
17131 #define sk_hash __sk_common.skc_hash
17132 #define sk_prot __sk_common.skc_prot
17133 +#define sk_xid __sk_common.skc_xid
17134 +#define sk_vx_info __sk_common.skc_vx_info
17135 +#define sk_nid __sk_common.skc_nid
17136 +#define sk_nx_info __sk_common.skc_nx_info
17137 unsigned char sk_shutdown : 2,
17140 diff -Nurp linux-2.6.22.15/init/main.c linux-2.6.22.15-vs2.3.0.29.1/init/main.c
17141 --- linux-2.6.22.15/init/main.c 2007-07-21 18:00:24.000000000 -0400
17142 +++ linux-2.6.22.15-vs2.3.0.29.1/init/main.c 2007-12-09 06:44:22.000000000 -0500
17144 #include <linux/pid_namespace.h>
17145 #include <linux/device.h>
17146 #include <linux/kthread.h>
17147 +#include <linux/vserver/percpu.h>
17149 #include <asm/io.h>
17150 #include <asm/bugs.h>
17151 @@ -364,12 +365,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
17153 static void __init setup_per_cpu_areas(void)
17155 - unsigned long size, i;
17156 + unsigned long size, vspc, i;
17158 unsigned long nr_possible_cpus = num_possible_cpus();
17160 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
17162 /* Copy section for each CPU (we discard the original) */
17163 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
17164 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
17165 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
17167 for_each_possible_cpu(i) {
17168 diff -Nurp linux-2.6.22.15/ipc/mqueue.c linux-2.6.22.15-vs2.3.0.29.1/ipc/mqueue.c
17169 --- linux-2.6.22.15/ipc/mqueue.c 2007-12-09 06:43:53.000000000 -0500
17170 +++ linux-2.6.22.15-vs2.3.0.29.1/ipc/mqueue.c 2007-12-09 06:44:22.000000000 -0500
17172 #include <linux/audit.h>
17173 #include <linux/signal.h>
17174 #include <linux/mutex.h>
17175 +#include <linux/vs_context.h>
17176 +#include <linux/vs_limit.h>
17178 #include <net/sock.h>
17180 @@ -151,17 +153,20 @@ static struct inode *mqueue_get_inode(st
17181 spin_lock(&mq_lock);
17182 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
17183 u->mq_bytes + mq_bytes >
17184 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
17185 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
17186 + !vx_ipcmsg_avail(p->vx_info, mq_bytes)) {
17187 spin_unlock(&mq_lock);
17190 u->mq_bytes += mq_bytes;
17191 + vx_ipcmsg_add(p->vx_info, u, mq_bytes);
17192 spin_unlock(&mq_lock);
17194 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
17195 if (!info->messages) {
17196 spin_lock(&mq_lock);
17197 u->mq_bytes -= mq_bytes;
17198 + vx_ipcmsg_sub(p->vx_info, u, mq_bytes);
17199 spin_unlock(&mq_lock);
17202 @@ -257,10 +262,14 @@ static void mqueue_delete_inode(struct i
17203 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
17206 + struct vx_info *vxi = lookup_vx_info(user->xid);
17208 spin_lock(&mq_lock);
17209 user->mq_bytes -= mq_bytes;
17210 + vx_ipcmsg_sub(vxi, user, mq_bytes);
17212 spin_unlock(&mq_lock);
17213 + put_vx_info(vxi);
17217 @@ -748,7 +757,7 @@ asmlinkage long sys_mq_unlink(const char
17219 atomic_inc(&inode->i_count);
17221 - err = vfs_unlink(dentry->d_parent->d_inode, dentry);
17222 + err = vfs_unlink(dentry->d_parent->d_inode, dentry, NULL);
17226 diff -Nurp linux-2.6.22.15/ipc/msg.c linux-2.6.22.15-vs2.3.0.29.1/ipc/msg.c
17227 --- linux-2.6.22.15/ipc/msg.c 2007-05-04 09:58:24.000000000 -0400
17228 +++ linux-2.6.22.15-vs2.3.0.29.1/ipc/msg.c 2007-12-09 06:44:22.000000000 -0500
17230 #include <linux/seq_file.h>
17231 #include <linux/mutex.h>
17232 #include <linux/nsproxy.h>
17233 +#include <linux/vs_base.h>
17235 #include <asm/current.h>
17236 #include <asm/uaccess.h>
17237 @@ -149,6 +150,7 @@ static int newque (struct ipc_namespace
17239 msq->q_perm.mode = msgflg & S_IRWXUGO;
17240 msq->q_perm.key = key;
17241 + msq->q_perm.xid = vx_current_xid();
17243 msq->q_perm.security = NULL;
17244 retval = security_msg_queue_alloc(msq);
17245 diff -Nurp linux-2.6.22.15/ipc/sem.c linux-2.6.22.15-vs2.3.0.29.1/ipc/sem.c
17246 --- linux-2.6.22.15/ipc/sem.c 2007-07-21 18:00:24.000000000 -0400
17247 +++ linux-2.6.22.15-vs2.3.0.29.1/ipc/sem.c 2007-12-09 06:44:22.000000000 -0500
17249 #include <linux/seq_file.h>
17250 #include <linux/mutex.h>
17251 #include <linux/nsproxy.h>
17252 +#include <linux/vs_base.h>
17253 +#include <linux/vs_limit.h>
17255 #include <asm/uaccess.h>
17257 @@ -229,6 +231,7 @@ static int newary (struct ipc_namespace
17259 sma->sem_perm.mode = (semflg & S_IRWXUGO);
17260 sma->sem_perm.key = key;
17261 + sma->sem_perm.xid = vx_current_xid();
17263 sma->sem_perm.security = NULL;
17264 retval = security_sem_alloc(sma);
17265 @@ -244,6 +247,9 @@ static int newary (struct ipc_namespace
17268 ns->used_sems += nsems;
17269 + /* FIXME: obsoleted? */
17270 + vx_semary_inc(sma);
17271 + vx_nsems_add(sma, nsems);
17273 sma->sem_id = sem_buildid(ns, id, sma->sem_perm.seq);
17274 sma->sem_base = (struct sem *) &sma[1];
17275 @@ -525,6 +531,9 @@ static void freeary (struct ipc_namespac
17278 ns->used_sems -= sma->sem_nsems;
17279 + /* FIXME: obsoleted? */
17280 + vx_nsems_sub(sma, sma->sem_nsems);
17281 + vx_semary_dec(sma);
17282 size = sizeof (*sma) + sma->sem_nsems * sizeof (struct sem);
17283 security_sem_free(sma);
17284 ipc_rcu_putref(sma);
17285 diff -Nurp linux-2.6.22.15/ipc/shm.c linux-2.6.22.15-vs2.3.0.29.1/ipc/shm.c
17286 --- linux-2.6.22.15/ipc/shm.c 2007-08-11 21:54:37.000000000 -0400
17287 +++ linux-2.6.22.15-vs2.3.0.29.1/ipc/shm.c 2007-12-09 06:44:22.000000000 -0500
17289 #include <linux/mutex.h>
17290 #include <linux/nsproxy.h>
17291 #include <linux/mount.h>
17292 +#include <linux/vs_context.h>
17293 +#include <linux/vs_limit.h>
17295 #include <asm/uaccess.h>
17297 @@ -185,7 +187,12 @@ static void shm_open(struct vm_area_stru
17299 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
17301 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
17302 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
17303 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
17305 + vx_ipcshm_sub(vxi, shp, numpages);
17306 + ns->shm_tot -= numpages;
17308 shm_rmid(ns, shp->id);
17310 if (!is_file_hugepages(shp->shm_file))
17311 @@ -195,6 +202,7 @@ static void shm_destroy(struct ipc_names
17313 fput (shp->shm_file);
17314 security_shm_free(shp);
17315 + put_vx_info(vxi);
17316 ipc_rcu_putref(shp);
17319 @@ -351,11 +359,15 @@ static int newseg (struct ipc_namespace
17320 if (ns->shm_tot + numpages > ns->shm_ctlall)
17323 + if (!vx_ipcshm_avail(current->vx_info, numpages))
17326 shp = ipc_rcu_alloc(sizeof(*shp));
17330 shp->shm_perm.key = key;
17331 + shp->shm_perm.xid = vx_current_xid();
17332 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
17333 shp->mlock_user = NULL;
17335 @@ -406,6 +418,7 @@ static int newseg (struct ipc_namespace
17336 file->f_dentry->d_inode->i_ino = shp->id;
17338 ns->shm_tot += numpages;
17339 + vx_ipcshm_add(current->vx_info, key, numpages);
17343 diff -Nurp linux-2.6.22.15/ipc/util.c linux-2.6.22.15-vs2.3.0.29.1/ipc/util.c
17344 --- linux-2.6.22.15/ipc/util.c 2007-07-21 18:00:24.000000000 -0400
17345 +++ linux-2.6.22.15-vs2.3.0.29.1/ipc/util.c 2007-12-09 06:44:22.000000000 -0500
17347 #include <linux/proc_fs.h>
17348 #include <linux/audit.h>
17349 #include <linux/nsproxy.h>
17350 +#include <linux/vs_base.h>
17351 +#include <linux/vserver/global.h>
17353 #include <asm/unistd.h>
17355 @@ -72,6 +74,7 @@ static struct ipc_namespace *clone_ipc_n
17358 kref_init(&ns->kref);
17359 + atomic_inc(&vs_global_ipc_ns);
17363 @@ -108,6 +111,7 @@ void free_ipc_ns(struct kref *kref)
17367 + atomic_dec(&vs_global_ipc_ns);
17371 diff -Nurp linux-2.6.22.15/kernel/capability.c linux-2.6.22.15-vs2.3.0.29.1/kernel/capability.c
17372 --- linux-2.6.22.15/kernel/capability.c 2007-07-21 17:58:53.000000000 -0400
17373 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/capability.c 2007-12-09 06:44:22.000000000 -0500
17375 #include <linux/module.h>
17376 #include <linux/security.h>
17377 #include <linux/syscalls.h>
17378 +#include <linux/vs_context.h>
17379 #include <asm/uaccess.h>
17381 unsigned securebits = SECUREBITS_DEFAULT; /* systemwide security settings */
17382 @@ -103,6 +104,8 @@ static inline int cap_set_pg(int pgrp_nr
17384 pgrp = find_pid(pgrp_nr);
17385 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
17386 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
17389 while_each_thread(g, target) {
17390 if (!security_capset_check(target, effective,
17391 @@ -246,8 +249,12 @@ int __capable(struct task_struct *t, int
17393 EXPORT_SYMBOL(__capable);
17395 +#include <linux/vserver/base.h>
17396 int capable(int cap)
17398 + /* here for now so we don't require task locking */
17399 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
17401 return __capable(current, cap);
17403 EXPORT_SYMBOL(capable);
17404 diff -Nurp linux-2.6.22.15/kernel/compat.c linux-2.6.22.15-vs2.3.0.29.1/kernel/compat.c
17405 --- linux-2.6.22.15/kernel/compat.c 2007-07-21 18:00:24.000000000 -0400
17406 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/compat.c 2007-12-09 06:44:22.000000000 -0500
17407 @@ -846,7 +846,7 @@ asmlinkage long compat_sys_time(compat_t
17411 - do_gettimeofday(&tv);
17412 + vx_gettimeofday(&tv);
17416 @@ -870,7 +870,7 @@ asmlinkage long compat_sys_stime(compat_
17420 - do_settimeofday(&tv);
17421 + vx_settimeofday(&tv);
17425 diff -Nurp linux-2.6.22.15/kernel/exit.c linux-2.6.22.15-vs2.3.0.29.1/kernel/exit.c
17426 --- linux-2.6.22.15/kernel/exit.c 2007-12-09 06:43:49.000000000 -0500
17427 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/exit.c 2007-12-09 06:44:23.000000000 -0500
17429 #include <linux/resource.h>
17430 #include <linux/blkdev.h>
17431 #include <linux/task_io_accounting_ops.h>
17432 +#include <linux/vs_limit.h>
17433 +#include <linux/vs_context.h>
17434 +#include <linux/vs_network.h>
17435 +#include <linux/vs_pid.h>
17436 +#include <linux/vserver/global.h>
17438 #include <asm/uaccess.h>
17439 #include <asm/unistd.h>
17440 @@ -443,9 +448,11 @@ static void close_files(struct files_str
17441 filp_close(file, files);
17444 + vx_openfd_dec(i);
17452 @@ -525,6 +532,7 @@ static inline void __put_fs_struct(struc
17454 mntput(fs->altrootmnt);
17456 + atomic_dec(&vs_global_fs);
17457 kmem_cache_free(fs_cachep, fs);
17460 @@ -596,6 +604,14 @@ static void exit_mm(struct task_struct *
17462 choose_new_parent(struct task_struct *p, struct task_struct *reaper)
17464 + /* check for reaper context */
17465 + vxwprintk((p->xid != reaper->xid) && (reaper != child_reaper(p)),
17466 + "rogue reaper: %p[%d,#%u] <> %p[%d,#%u]",
17467 + p, p->pid, p->xid, reaper, reaper->pid, reaper->xid);
17470 + reaper = vx_child_reaper(p);
17473 * Make sure we're not reparenting to ourselves and that
17474 * the parent is not a zombie.
17475 @@ -687,7 +703,7 @@ forget_original_parent(struct task_struc
17477 reaper = next_thread(reaper);
17478 if (reaper == father) {
17479 - reaper = child_reaper(father);
17480 + reaper = vx_child_reaper(father);
17483 } while (reaper->exit_state);
17484 @@ -964,6 +980,8 @@ fastcall NORET_TYPE void do_exit(long co
17485 tsk->exit_code = code;
17486 proc_exit_connector(tsk);
17487 exit_task_namespaces(tsk);
17488 + /* needs to stay before exit_notify() */
17489 + exit_vx_info_early(tsk, code);
17492 mpol_free(tsk->mempolicy);
17493 @@ -994,6 +1012,10 @@ fastcall NORET_TYPE void do_exit(long co
17494 if (tsk->splice_pipe)
17495 __free_pipe_info(tsk->splice_pipe);
17497 + /* needs to stay after exit_notify() */
17498 + exit_vx_info(tsk, code);
17499 + exit_nx_info(tsk);
17502 /* causes final put_task_struct in finish_task_switch(). */
17503 tsk->state = TASK_DEAD;
17504 diff -Nurp linux-2.6.22.15/kernel/fork.c linux-2.6.22.15-vs2.3.0.29.1/kernel/fork.c
17505 --- linux-2.6.22.15/kernel/fork.c 2007-07-21 18:00:24.000000000 -0400
17506 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/fork.c 2007-12-09 06:44:23.000000000 -0500
17508 #include <linux/delayacct.h>
17509 #include <linux/taskstats_kern.h>
17510 #include <linux/random.h>
17511 +#include <linux/vs_context.h>
17512 +#include <linux/vs_network.h>
17513 +#include <linux/vs_limit.h>
17514 +#include <linux/vs_memory.h>
17515 +#include <linux/vserver/global.h>
17517 #include <asm/pgtable.h>
17518 #include <asm/pgalloc.h>
17519 @@ -108,6 +113,8 @@ void free_task(struct task_struct *tsk)
17521 free_thread_info(tsk->stack);
17522 rt_mutex_debug_task_free(tsk);
17523 + clr_vx_info(&tsk->vx_info);
17524 + clr_nx_info(&tsk->nx_info);
17525 free_task_struct(tsk);
17527 EXPORT_SYMBOL(free_task);
17528 @@ -215,6 +222,8 @@ static inline int dup_mmap(struct mm_str
17529 mm->free_area_cache = oldmm->mmap_base;
17530 mm->cached_hole_size = ~0UL;
17532 + __set_mm_counter(mm, file_rss, 0);
17533 + __set_mm_counter(mm, anon_rss, 0);
17534 cpus_clear(mm->cpu_vm_mask);
17535 mm->mm_rb = RB_ROOT;
17536 rb_link = &mm->mm_rb.rb_node;
17537 @@ -226,7 +235,7 @@ static inline int dup_mmap(struct mm_str
17539 if (mpnt->vm_flags & VM_DONTCOPY) {
17540 long pages = vma_pages(mpnt);
17541 - mm->total_vm -= pages;
17542 + vx_vmpages_sub(mm, pages);
17543 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
17546 @@ -327,7 +336,7 @@ static inline void mm_free_pgd(struct mm
17548 #include <linux/init_task.h>
17550 -static struct mm_struct * mm_init(struct mm_struct * mm)
17551 +static struct mm_struct * mm_init(struct mm_struct * mm, struct vx_info *vxi)
17553 atomic_set(&mm->mm_users, 1);
17554 atomic_set(&mm->mm_count, 1);
17555 @@ -335,8 +344,8 @@ static struct mm_struct * mm_init(struct
17556 INIT_LIST_HEAD(&mm->mmlist);
17557 mm->core_waiters = 0;
17559 - set_mm_counter(mm, file_rss, 0);
17560 - set_mm_counter(mm, anon_rss, 0);
17561 + __set_mm_counter(mm, file_rss, 0);
17562 + __set_mm_counter(mm, anon_rss, 0);
17563 spin_lock_init(&mm->page_table_lock);
17564 rwlock_init(&mm->ioctx_list_lock);
17565 mm->ioctx_list = NULL;
17566 @@ -345,6 +354,7 @@ static struct mm_struct * mm_init(struct
17568 if (likely(!mm_alloc_pgd(mm))) {
17570 + set_vx_info(&mm->mm_vx_info, vxi);
17574 @@ -361,7 +371,7 @@ struct mm_struct * mm_alloc(void)
17575 mm = allocate_mm();
17577 memset(mm, 0, sizeof(*mm));
17578 - mm = mm_init(mm);
17579 + mm = mm_init(mm, current->vx_info);
17583 @@ -376,6 +386,7 @@ void fastcall __mmdrop(struct mm_struct
17584 BUG_ON(mm == &init_mm);
17586 destroy_context(mm);
17587 + clr_vx_info(&mm->mm_vx_info);
17591 @@ -490,12 +501,13 @@ static struct mm_struct *dup_mm(struct t
17594 memcpy(mm, oldmm, sizeof(*mm));
17595 + mm->mm_vx_info = NULL;
17597 /* Initializing for Swap token stuff */
17598 mm->token_priority = 0;
17599 mm->last_interval = 0;
17601 - if (!mm_init(mm))
17602 + if (!mm_init(mm, oldmm->mm_vx_info))
17605 if (init_new_context(tsk, mm))
17606 @@ -521,6 +533,7 @@ fail_nocontext:
17607 * If init_new_context() failed, we cannot use mmput() to free the mm
17608 * because it calls destroy_context()
17610 + clr_vx_info(&mm->mm_vx_info);
17614 @@ -591,6 +604,7 @@ static inline struct fs_struct *__copy_f
17615 fs->altroot = NULL;
17617 read_unlock(&old->lock);
17618 + atomic_inc(&vs_global_fs);
17622 @@ -709,6 +723,8 @@ static struct files_struct *dup_fd(struc
17623 struct file *f = *old_fds++;
17626 + /* TODO: sum it first for check and performance */
17627 + vx_openfd_inc(open_files - i);
17630 * The fd may be claimed in the fd bitmap but not yet
17631 @@ -961,6 +977,8 @@ static struct task_struct *copy_process(
17634 struct task_struct *p = NULL;
17635 + struct vx_info *vxi;
17636 + struct nx_info *nxi;
17638 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
17639 return ERR_PTR(-EINVAL);
17640 @@ -995,12 +1013,30 @@ static struct task_struct *copy_process(
17641 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
17642 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
17644 + init_vx_info(&p->vx_info, current->vx_info);
17645 + init_nx_info(&p->nx_info, current->nx_info);
17647 + /* check vserver memory */
17648 + if (p->mm && !(clone_flags & CLONE_VM)) {
17649 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
17650 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17652 + goto bad_fork_free;
17654 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
17655 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
17656 + goto bad_fork_cleanup_vm;
17660 + if (!vx_nproc_avail(1))
17661 + goto bad_fork_cleanup_vm;
17663 if (atomic_read(&p->user->processes) >=
17664 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
17665 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
17666 p->user != &root_user)
17667 - goto bad_fork_free;
17668 + goto bad_fork_cleanup_vm;
17671 atomic_inc(&p->user->__count);
17672 @@ -1265,6 +1301,18 @@ static struct task_struct *copy_process(
17675 spin_unlock(¤t->sighand->siglock);
17677 + /* p is copy of current */
17678 + vxi = p->vx_info;
17680 + claim_vx_info(vxi, p);
17681 + atomic_inc(&vxi->cvirt.nr_threads);
17682 + atomic_inc(&vxi->cvirt.total_forks);
17685 + nxi = p->nx_info;
17687 + claim_nx_info(nxi, p);
17688 write_unlock_irq(&tasklist_lock);
17689 proc_fork_connector(p);
17691 @@ -1306,6 +1354,9 @@ bad_fork_cleanup_count:
17692 put_group_info(p->group_info);
17693 atomic_dec(&p->user->processes);
17695 +bad_fork_cleanup_vm:
17696 + if (p->mm && !(clone_flags & CLONE_VM))
17697 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17701 @@ -1367,6 +1418,15 @@ long do_fork(unsigned long clone_flags,
17706 + /* kernel threads are host only */
17707 + if ((clone_flags & CLONE_KTHREAD) &&
17708 + !vx_capable(CAP_SYS_ADMIN, VXC_KTHREAD)) {
17709 + vxwprintk_task(1, "tried to spawn a kernel thread.");
17715 if (unlikely(current->ptrace)) {
17716 trace = fork_traceflag (clone_flags);
17717 diff -Nurp linux-2.6.22.15/kernel/kthread.c linux-2.6.22.15-vs2.3.0.29.1/kernel/kthread.c
17718 --- linux-2.6.22.15/kernel/kthread.c 2007-07-21 18:00:24.000000000 -0400
17719 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/kthread.c 2007-12-09 06:44:23.000000000 -0500
17720 @@ -96,7 +96,7 @@ static void create_kthread(struct kthrea
17722 wait_for_completion(&create->started);
17723 read_lock(&tasklist_lock);
17724 - create->result = find_task_by_pid(pid);
17725 + create->result = find_task_by_real_pid(pid);
17726 read_unlock(&tasklist_lock);
17728 complete(&create->done);
17729 diff -Nurp linux-2.6.22.15/kernel/Makefile linux-2.6.22.15-vs2.3.0.29.1/kernel/Makefile
17730 --- linux-2.6.22.15/kernel/Makefile 2007-07-21 18:00:24.000000000 -0400
17731 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/Makefile 2007-12-09 06:44:22.000000000 -0500
17732 @@ -10,6 +10,8 @@ obj-y = sched.o fork.o exec_domain.o
17733 kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
17734 hrtimer.o rwsem.o latency.o nsproxy.o srcu.o die_notifier.o
17738 obj-$(CONFIG_STACKTRACE) += stacktrace.o
17740 obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
17741 diff -Nurp linux-2.6.22.15/kernel/nsproxy.c linux-2.6.22.15-vs2.3.0.29.1/kernel/nsproxy.c
17742 --- linux-2.6.22.15/kernel/nsproxy.c 2007-07-21 18:00:25.000000000 -0400
17743 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/nsproxy.c 2007-12-09 06:44:23.000000000 -0500
17744 @@ -20,14 +20,11 @@
17745 #include <linux/mnt_namespace.h>
17746 #include <linux/utsname.h>
17747 #include <linux/pid_namespace.h>
17748 +#include <linux/vserver/global.h>
17749 +#include <linux/vserver/debug.h>
17751 struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
17753 -static inline void get_nsproxy(struct nsproxy *ns)
17755 - atomic_inc(&ns->count);
17758 void get_task_namespaces(struct task_struct *tsk)
17760 struct nsproxy *ns = tsk->nsproxy;
17761 @@ -46,6 +43,9 @@ static inline struct nsproxy *clone_nspr
17762 ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL);
17764 atomic_set(&ns->count, 1);
17765 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
17766 + orig, atomic_read(&orig->count), ns);
17767 + atomic_inc(&vs_global_nsproxy);
17771 @@ -54,28 +54,32 @@ static inline struct nsproxy *clone_nspr
17772 * Return the newly created nsproxy. Do not attach this to the task,
17773 * leave it to the caller to do proper locking and attach it to task.
17775 -static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17776 +static struct nsproxy *unshare_namespaces(int flags, struct nsproxy *orig,
17777 struct fs_struct *new_fs)
17779 struct nsproxy *new_nsp;
17781 - new_nsp = clone_nsproxy(tsk->nsproxy);
17782 + vxdprintk(VXD_CBIT(space, 4),
17783 + "unshare_namespaces(0x%08x,%p,%p)",
17784 + flags, orig, new_fs);
17786 + new_nsp = clone_nsproxy(orig);
17788 return ERR_PTR(-ENOMEM);
17790 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
17791 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
17792 if (IS_ERR(new_nsp->mnt_ns))
17795 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
17796 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
17797 if (IS_ERR(new_nsp->uts_ns))
17800 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
17801 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
17802 if (IS_ERR(new_nsp->ipc_ns))
17805 - new_nsp->pid_ns = copy_pid_ns(flags, tsk->nsproxy->pid_ns);
17806 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
17807 if (IS_ERR(new_nsp->pid_ns))
17810 @@ -95,6 +99,33 @@ out_ns:
17811 return ERR_PTR(-ENOMEM);
17814 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17815 + struct fs_struct *new_fs)
17817 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
17821 + * copies the nsproxy, setting refcount to 1, and grabbing a
17822 + * reference to all contained namespaces.
17824 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
17826 + struct nsproxy *ns = clone_nsproxy(orig);
17830 + get_mnt_ns(ns->mnt_ns);
17832 + get_uts_ns(ns->uts_ns);
17834 + get_ipc_ns(ns->ipc_ns);
17836 + get_pid_ns(ns->pid_ns);
17842 * called from clone. This now handles copy for nsproxy and all
17843 * namespaces therein.
17844 @@ -102,9 +133,12 @@ out_ns:
17845 int copy_namespaces(int flags, struct task_struct *tsk)
17847 struct nsproxy *old_ns = tsk->nsproxy;
17848 - struct nsproxy *new_ns;
17849 + struct nsproxy *new_ns = NULL;
17852 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08x,%p[%p])",
17853 + flags, tsk, old_ns);
17858 @@ -127,6 +161,9 @@ int copy_namespaces(int flags, struct ta
17859 tsk->nsproxy = new_ns;
17861 put_nsproxy(old_ns);
17862 + vxdprintk(VXD_CBIT(space, 3),
17863 + "copy_namespaces(0x%08x,%p[%p]) = %d [%p]",
17864 + flags, tsk, old_ns, err, new_ns);
17868 @@ -140,6 +177,7 @@ void free_nsproxy(struct nsproxy *ns)
17869 put_ipc_ns(ns->ipc_ns);
17871 put_pid_ns(ns->pid_ns);
17872 + atomic_dec(&vs_global_nsproxy);
17876 @@ -152,6 +190,10 @@ int unshare_nsproxy_namespaces(unsigned
17880 + vxdprintk(VXD_CBIT(space, 4),
17881 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
17882 + unshare_flags, current->nsproxy);
17884 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC)))
17887 diff -Nurp linux-2.6.22.15/kernel/pid.c linux-2.6.22.15-vs2.3.0.29.1/kernel/pid.c
17888 --- linux-2.6.22.15/kernel/pid.c 2007-07-21 18:00:25.000000000 -0400
17889 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/pid.c 2007-12-09 06:44:23.000000000 -0500
17891 #include <linux/hash.h>
17892 #include <linux/pid_namespace.h>
17893 #include <linux/init_task.h>
17894 +#include <linux/vs_pid.h>
17896 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
17897 static struct hlist_head *pid_hash;
17898 @@ -295,6 +296,9 @@ void fastcall transfer_pid(struct task_s
17899 struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
17901 struct task_struct *result = NULL;
17903 + if (type == PIDTYPE_REALPID)
17904 + type = PIDTYPE_PID;
17906 struct hlist_node *first;
17907 first = rcu_dereference(pid->tasks[type].first);
17908 @@ -309,7 +313,17 @@ struct task_struct * fastcall pid_task(s
17910 struct task_struct *find_task_by_pid_type(int type, int nr)
17912 - return pid_task(find_pid(nr), type);
17913 + struct task_struct *task;
17915 + if (type == PIDTYPE_PID)
17916 + nr = vx_rmap_pid(nr);
17918 + task = pid_task(find_pid(nr), type);
17919 + if (task && (type != PIDTYPE_REALPID) &&
17920 + /* maybe VS_WATCH_P in the future? */
17921 + !vx_check(task->xid, VS_WATCH|VS_IDENT))
17926 EXPORT_SYMBOL(find_task_by_pid_type);
17927 diff -Nurp linux-2.6.22.15/kernel/posix-timers.c linux-2.6.22.15-vs2.3.0.29.1/kernel/posix-timers.c
17928 --- linux-2.6.22.15/kernel/posix-timers.c 2007-07-21 18:00:25.000000000 -0400
17929 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/posix-timers.c 2007-12-09 06:44:23.000000000 -0500
17931 #include <linux/wait.h>
17932 #include <linux/workqueue.h>
17933 #include <linux/module.h>
17934 +#include <linux/vs_context.h>
17937 * Management arrays for POSIX timers. Timers are kept in slab memory
17938 @@ -297,6 +298,12 @@ void do_schedule_next_timer(struct sigin
17940 int posix_timer_event(struct k_itimer *timr,int si_private)
17942 + struct vx_info_save vxis;
17943 + struct vx_info *vxi;
17946 + vxi = task_get_vx_info(timr->it_process);
17947 + enter_vx_info(vxi, &vxis);
17948 memset(&timr->sigq->info, 0, sizeof(siginfo_t));
17949 timr->sigq->info.si_sys_private = si_private;
17950 /* Send signal to the process that owns this timer.*/
17951 @@ -309,11 +316,11 @@ int posix_timer_event(struct k_itimer *t
17953 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
17954 struct task_struct *leader;
17955 - int ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
17956 - timr->it_process);
17958 + ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
17959 + timr->it_process);
17960 if (likely(ret >= 0))
17964 timr->it_sigev_notify = SIGEV_SIGNAL;
17965 leader = timr->it_process->group_leader;
17966 @@ -321,8 +328,12 @@ int posix_timer_event(struct k_itimer *t
17967 timr->it_process = leader;
17970 - return send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
17971 + ret = send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
17974 + leave_vx_info(&vxis);
17975 + put_vx_info(vxi);
17978 EXPORT_SYMBOL_GPL(posix_timer_event);
17980 @@ -402,7 +413,7 @@ static struct task_struct * good_sigeven
17981 struct task_struct *rtn = current->group_leader;
17983 if ((event->sigev_notify & SIGEV_THREAD_ID ) &&
17984 - (!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) ||
17985 + (!(rtn = find_task_by_real_pid(event->sigev_notify_thread_id)) ||
17986 rtn->tgid != current->tgid ||
17987 (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))
17989 diff -Nurp linux-2.6.22.15/kernel/printk.c linux-2.6.22.15-vs2.3.0.29.1/kernel/printk.c
17990 --- linux-2.6.22.15/kernel/printk.c 2007-07-21 18:00:25.000000000 -0400
17991 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/printk.c 2007-12-09 06:44:23.000000000 -0500
17993 #include <linux/bootmem.h>
17994 #include <linux/syscalls.h>
17995 #include <linux/jiffies.h>
17996 +#include <linux/vs_cvirt.h>
17998 #include <asm/uaccess.h>
18000 @@ -182,18 +183,13 @@ int do_syslog(int type, char __user *buf
18001 unsigned long i, j, limit, count;
18007 error = security_syslog(type);
18012 - case 0: /* Close log */
18014 - case 1: /* Open log */
18016 - case 2: /* Read from log */
18017 + if ((type >= 2) && (type <= 4)) {
18019 if (!buf || len < 0)
18021 @@ -204,6 +200,16 @@ int do_syslog(int type, char __user *buf
18026 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
18027 + return vx_do_syslog(type, buf, len);
18030 + case 0: /* Close log */
18032 + case 1: /* Open log */
18034 + case 2: /* Read from log */
18035 error = wait_event_interruptible(log_wait,
18036 (log_start - log_end));
18038 @@ -228,16 +234,6 @@ int do_syslog(int type, char __user *buf
18041 case 3: /* Read last kernel messages */
18043 - if (!buf || len < 0)
18048 - if (!access_ok(VERIFY_WRITE, buf, len)) {
18053 if (count > log_buf_len)
18054 count = log_buf_len;
18055 diff -Nurp linux-2.6.22.15/kernel/ptrace.c linux-2.6.22.15-vs2.3.0.29.1/kernel/ptrace.c
18056 --- linux-2.6.22.15/kernel/ptrace.c 2007-07-21 18:00:25.000000000 -0400
18057 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/ptrace.c 2007-12-09 06:44:23.000000000 -0500
18059 #include <linux/security.h>
18060 #include <linux/signal.h>
18061 #include <linux/audit.h>
18062 +#include <linux/vs_context.h>
18064 #include <asm/pgtable.h>
18065 #include <asm/uaccess.h>
18066 @@ -145,6 +146,11 @@ static int may_attach(struct task_struct
18067 dumpable = task->mm->dumpable;
18068 if (!dumpable && !capable(CAP_SYS_PTRACE))
18070 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
18072 + if (!vx_check(task->xid, VS_IDENT) &&
18073 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
18076 return security_ptrace(current, task);
18078 @@ -471,6 +477,10 @@ asmlinkage long sys_ptrace(long request,
18083 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
18084 + goto out_put_task_struct;
18086 if (request == PTRACE_ATTACH) {
18087 ret = ptrace_attach(child);
18088 goto out_put_task_struct;
18089 diff -Nurp linux-2.6.22.15/kernel/sched.c linux-2.6.22.15-vs2.3.0.29.1/kernel/sched.c
18090 --- linux-2.6.22.15/kernel/sched.c 2007-07-21 18:00:25.000000000 -0400
18091 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/sched.c 2007-12-09 06:44:23.000000000 -0500
18094 #include <asm/tlb.h>
18095 #include <asm/unistd.h>
18096 +#include <linux/vs_sched.h>
18097 +#include <linux/vs_cvirt.h>
18100 * Scheduler clock - returns current time in nanosec units.
18101 @@ -281,6 +283,16 @@ struct rq {
18102 struct task_struct *migration_thread;
18103 struct list_head migration_queue;
18105 + unsigned long norm_time;
18106 + unsigned long idle_time;
18107 +#ifdef CONFIG_VSERVER_IDLETIME
18110 +#ifdef CONFIG_VSERVER_HARDCPU
18111 + struct list_head hold_queue;
18112 + unsigned long nr_onhold;
18116 #ifdef CONFIG_SCHEDSTATS
18117 /* latency stats */
18118 @@ -714,6 +726,7 @@ sched_info_switch(struct task_struct *pr
18120 static void dequeue_task(struct task_struct *p, struct prio_array *array)
18122 + BUG_ON(p->state & TASK_ONHOLD);
18123 array->nr_active--;
18124 list_del(&p->run_list);
18125 if (list_empty(array->queue + p->prio))
18126 @@ -722,6 +735,7 @@ static void dequeue_task(struct task_str
18128 static void enqueue_task(struct task_struct *p, struct prio_array *array)
18130 + BUG_ON(p->state & TASK_ONHOLD);
18131 sched_info_queued(p);
18132 list_add_tail(&p->run_list, array->queue + p->prio);
18133 __set_bit(p->prio, array->bitmap);
18134 @@ -735,12 +749,14 @@ static void enqueue_task(struct task_str
18136 static void requeue_task(struct task_struct *p, struct prio_array *array)
18138 + BUG_ON(p->state & TASK_ONHOLD);
18139 list_move_tail(&p->run_list, array->queue + p->prio);
18143 enqueue_task_head(struct task_struct *p, struct prio_array *array)
18145 + BUG_ON(p->state & TASK_ONHOLD);
18146 list_add(&p->run_list, array->queue + p->prio);
18147 __set_bit(p->prio, array->bitmap);
18148 array->nr_active++;
18149 @@ -769,6 +785,10 @@ static inline int __normal_prio(struct t
18150 bonus = CURRENT_BONUS(p) - MAX_BONUS / 2;
18152 prio = p->static_prio - bonus;
18154 + /* adjust effective priority */
18155 + prio = vx_adjust_prio(p, prio, MAX_USER_PRIO);
18157 if (prio < MAX_RT_PRIO)
18158 prio = MAX_RT_PRIO;
18159 if (prio > MAX_PRIO-1)
18160 @@ -878,6 +898,9 @@ static int effective_prio(struct task_st
18164 +#include "sched_mon.h"
18168 * __activate_task - move a task to the runqueue.
18170 @@ -887,6 +910,7 @@ static void __activate_task(struct task_
18173 target = rq->expired;
18174 + vxm_activate_task(p, rq);
18175 enqueue_task(p, target);
18176 inc_nr_running(p, rq);
18178 @@ -896,6 +920,7 @@ static void __activate_task(struct task_
18180 static inline void __activate_idle_task(struct task_struct *p, struct rq *rq)
18182 + vxm_activate_idle(p, rq);
18183 enqueue_task_head(p, rq->active);
18184 inc_nr_running(p, rq);
18186 @@ -1030,19 +1055,30 @@ static void activate_task(struct task_st
18188 p->timestamp = now;
18190 + vx_activate_task(p);
18191 __activate_task(p, rq);
18195 - * deactivate_task - remove a task from the runqueue.
18196 + * __deactivate_task - remove a task from the runqueue.
18198 -static void deactivate_task(struct task_struct *p, struct rq *rq)
18199 +static void __deactivate_task(struct task_struct *p, struct rq *rq)
18201 dec_nr_running(p, rq);
18202 dequeue_task(p, p->array);
18203 + vxm_deactivate_task(p, rq);
18208 +void deactivate_task(struct task_struct *p, struct rq *rq)
18210 + vx_deactivate_task(p);
18211 + __deactivate_task(p, rq);
18214 +#include "sched_hard.h"
18217 * resched_task - mark a task 'to be rescheduled now'.
18219 @@ -1129,6 +1165,7 @@ migrate_task(struct task_struct *p, int
18221 struct rq *rq = task_rq(p);
18223 + vxm_migrate_task(p, rq, dest_cpu);
18225 * If the task is not on a runqueue (and not running), then
18226 * it is sufficient to simply update the task's cpu field.
18227 @@ -1518,6 +1555,12 @@ static int try_to_wake_up(struct task_st
18229 rq = task_rq_lock(p, &flags);
18230 old_state = p->state;
18232 + /* we need to unhold suspended tasks */
18233 + if (old_state & TASK_ONHOLD) {
18234 + vx_unhold_task(p, rq);
18235 + old_state = p->state;
18237 if (!(old_state & state))
18240 @@ -1625,6 +1668,7 @@ out_activate:
18241 #endif /* CONFIG_SMP */
18242 if (old_state == TASK_UNINTERRUPTIBLE) {
18243 rq->nr_uninterruptible--;
18244 + vx_uninterruptible_dec(p);
18246 * Tasks on involuntary sleep don't earn
18247 * sleep_avg beyond just interactive state.
18248 @@ -1676,7 +1720,7 @@ int fastcall wake_up_state(struct task_s
18249 return try_to_wake_up(p, state, 0);
18252 -static void task_running_tick(struct rq *rq, struct task_struct *p);
18253 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu);
18255 * Perform scheduler related setup for a newly forked process p.
18256 * p is forked by current.
18257 @@ -1737,7 +1781,7 @@ void fastcall sched_fork(struct task_str
18258 * runqueue lock is not a problem.
18260 current->time_slice = 1;
18261 - task_running_tick(cpu_rq(cpu), current);
18262 + task_running_tick(cpu_rq(cpu), current, cpu);
18264 local_irq_enable();
18266 @@ -1772,6 +1816,7 @@ void fastcall wake_up_new_task(struct ta
18268 p->prio = effective_prio(p);
18270 + vx_activate_task(p);
18271 if (likely(cpu == this_cpu)) {
18272 if (!(clone_flags & CLONE_VM)) {
18274 @@ -1783,6 +1828,7 @@ void fastcall wake_up_new_task(struct ta
18275 __activate_task(p, rq);
18277 p->prio = current->prio;
18278 + BUG_ON(p->state & TASK_ONHOLD);
18279 p->normal_prio = current->normal_prio;
18280 list_add_tail(&p->run_list, ¤t->run_list);
18281 p->array = current->array;
18282 @@ -3351,13 +3397,16 @@ static inline int expired_starving(struc
18283 void account_user_time(struct task_struct *p, cputime_t cputime)
18285 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
18286 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
18288 + int nice = (TASK_NICE(p) > 0);
18290 p->utime = cputime_add(p->utime, cputime);
18291 + vx_account_user(vxi, cputime, nice);
18293 /* Add user time to cpustat. */
18294 tmp = cputime_to_cputime64(cputime);
18295 - if (TASK_NICE(p) > 0)
18297 cpustat->nice = cputime64_add(cpustat->nice, tmp);
18299 cpustat->user = cputime64_add(cpustat->user, tmp);
18300 @@ -3373,10 +3422,12 @@ void account_system_time(struct task_str
18303 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
18304 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
18305 struct rq *rq = this_rq();
18308 p->stime = cputime_add(p->stime, cputime);
18309 + vx_account_system(vxi, cputime, (p == rq->idle));
18311 /* Add system time to cpustat. */
18312 tmp = cputime_to_cputime64(cputime);
18313 @@ -3415,7 +3466,7 @@ void account_steal_time(struct task_stru
18314 cpustat->steal = cputime64_add(cpustat->steal, tmp);
18317 -static void task_running_tick(struct rq *rq, struct task_struct *p)
18318 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu)
18320 if (p->array != rq->active) {
18321 /* Task has expired but was not scheduled yet */
18322 @@ -3445,7 +3496,7 @@ static void task_running_tick(struct rq
18326 - if (!--p->time_slice) {
18327 + if (vx_need_resched(p, --p->time_slice, cpu)) {
18328 dequeue_task(p, rq->active);
18329 set_tsk_need_resched(p);
18330 p->prio = effective_prio(p);
18331 @@ -3506,9 +3557,12 @@ void scheduler_tick(void)
18332 struct rq *rq = cpu_rq(cpu);
18334 update_cpu_clock(p, rq, now);
18335 + vxm_sync(now, cpu);
18337 - if (!idle_at_tick)
18338 - task_running_tick(rq, p);
18339 + if (idle_at_tick)
18340 + vx_idle_resched(rq);
18342 + task_running_tick(rq, p, cpu);
18345 rq->idle_at_tick = idle_at_tick;
18346 @@ -3630,14 +3684,25 @@ need_resched_nonpreemptible:
18347 unlikely(signal_pending(prev))))
18348 prev->state = TASK_RUNNING;
18350 - if (prev->state == TASK_UNINTERRUPTIBLE)
18351 + if (prev->state == TASK_UNINTERRUPTIBLE) {
18352 rq->nr_uninterruptible++;
18353 + vx_uninterruptible_inc(prev);
18355 deactivate_task(prev, rq);
18359 cpu = smp_processor_id();
18360 + vx_set_rq_time(rq, jiffies);
18362 + vx_try_unhold(rq, cpu);
18365 if (unlikely(!rq->nr_running)) {
18366 + /* can we skip idle time? */
18367 + if (vx_try_skip(rq, cpu))
18370 idle_balance(cpu, rq);
18371 if (!rq->nr_running) {
18373 @@ -3663,6 +3728,10 @@ need_resched_nonpreemptible:
18374 queue = array->queue + idx;
18375 next = list_entry(queue->next, struct task_struct, run_list);
18377 + /* check before we schedule this context */
18378 + if (!vx_schedule(next, rq, cpu))
18381 if (!rt_task(next) && interactive_sleep(next->sleep_type)) {
18382 unsigned long long delta = now - next->timestamp;
18383 if (unlikely((long long)(now - next->timestamp) < 0))
18384 @@ -4263,7 +4332,7 @@ asmlinkage long sys_nice(int increment)
18387 if (increment < 0 && !can_nice(current, nice))
18389 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
18391 retval = security_task_setnice(current, nice);
18393 @@ -4435,6 +4504,7 @@ recheck:
18395 __setscheduler(p, policy, param->sched_priority);
18397 + vx_activate_task(p);
18398 __activate_task(p, rq);
18400 * Reschedule if we are currently running on this runqueue and
18401 @@ -5188,6 +5258,7 @@ static int __migrate_task(struct task_st
18402 p->timestamp = p->timestamp - rq_src->most_recent_timestamp
18403 + rq_dest->most_recent_timestamp;
18404 deactivate_task(p, rq_src);
18405 + vx_activate_task(p);
18406 __activate_task(p, rq_dest);
18407 if (TASK_PREEMPTS_CURR(p, rq_dest))
18408 resched_task(rq_dest->curr);
18409 @@ -7058,7 +7129,10 @@ void __init sched_init(void)
18410 INIT_LIST_HEAD(&rq->migration_queue);
18412 atomic_set(&rq->nr_iowait, 0);
18414 +#ifdef CONFIG_VSERVER_HARDCPU
18415 + INIT_LIST_HEAD(&rq->hold_queue);
18416 + rq->nr_onhold = 0;
18418 for (j = 0; j < 2; j++) {
18419 array = rq->arrays + j;
18420 for (k = 0; k < MAX_PRIO; k++) {
18421 @@ -7144,6 +7218,7 @@ void normalize_rt_tasks(void)
18422 deactivate_task(p, task_rq(p));
18423 __setscheduler(p, SCHED_NORMAL, 0);
18425 + vx_activate_task(p);
18426 __activate_task(p, task_rq(p));
18427 resched_task(rq->curr);
18429 diff -Nurp linux-2.6.22.15/kernel/sched_hard.h linux-2.6.22.15-vs2.3.0.29.1/kernel/sched_hard.h
18430 --- linux-2.6.22.15/kernel/sched_hard.h 1969-12-31 19:00:00.000000000 -0500
18431 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/sched_hard.h 2007-12-09 06:44:23.000000000 -0500
18434 +#ifdef CONFIG_VSERVER_IDLELIMIT
18437 + * vx_idle_resched - reschedule after maxidle
18440 +void vx_idle_resched(struct rq *rq)
18442 + /* maybe have a better criterion for paused */
18443 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
18444 + set_need_resched();
18447 +#else /* !CONFIG_VSERVER_IDLELIMIT */
18449 +#define vx_idle_resched(rq)
18451 +#endif /* CONFIG_VSERVER_IDLELIMIT */
18455 +#ifdef CONFIG_VSERVER_IDLETIME
18457 +#define vx_set_rq_min_skip(rq, min) \
18458 + (rq)->idle_skip = (min)
18460 +#define vx_save_min_skip(ret, min, val) \
18461 + __vx_save_min_skip(ret, min, val)
18464 +void __vx_save_min_skip(int ret, int *min, int val)
18468 + if ((*min > val) || !*min)
18473 +int vx_try_skip(struct rq *rq, int cpu)
18475 + /* artificially advance time */
18476 + if (rq->idle_skip > 0) {
18477 + vxdprintk(list_empty(&rq->hold_queue),
18478 + "hold queue empty on cpu %d", cpu);
18479 + rq->idle_time += rq->idle_skip;
18480 + vxm_idle_skip(rq, cpu);
18486 +#else /* !CONFIG_VSERVER_IDLETIME */
18488 +#define vx_set_rq_min_skip(rq, min) \
18489 + ({ int dummy = (min); dummy; })
18491 +#define vx_save_min_skip(ret, min, val)
18494 +int vx_try_skip(struct rq *rq, int cpu)
18499 +#endif /* CONFIG_VSERVER_IDLETIME */
18503 +#ifdef CONFIG_VSERVER_HARDCPU
18505 +#define vx_set_rq_max_idle(rq, max) \
18506 + (rq)->idle_tokens = (max)
18508 +#define vx_save_max_idle(ret, min, val) \
18509 + __vx_save_max_idle(ret, min, val)
18512 +void __vx_save_max_idle(int ret, int *min, int val)
18520 + * vx_hold_task - put a task on the hold queue
18523 +void vx_hold_task(struct task_struct *p, struct rq *rq)
18525 + __deactivate_task(p, rq);
18526 + p->state |= TASK_ONHOLD;
18527 + /* a new one on hold */
18529 + vxm_hold_task(p, rq);
18530 + list_add_tail(&p->run_list, &rq->hold_queue);
18534 + * vx_unhold_task - put a task back to the runqueue
18537 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
18539 + list_del(&p->run_list);
18540 + /* one less waiting */
18542 + p->state &= ~TASK_ONHOLD;
18543 + enqueue_task(p, rq->expired);
18544 + inc_nr_running(p, rq);
18545 + vxm_unhold_task(p, rq);
18547 + if (p->static_prio < rq->best_expired_prio)
18548 + rq->best_expired_prio = p->static_prio;
18551 +unsigned long nr_onhold(void)
18553 + unsigned long i, sum = 0;
18555 + for_each_online_cpu(i)
18556 + sum += cpu_rq(i)->nr_onhold;
18564 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
18566 + return sched_pc->tokens;
18570 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
18572 + sched_pc->tokens--;
18576 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
18578 + struct vx_info *vxi = p->vx_info;
18580 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
18581 + struct _vx_sched_pc *sched_pc =
18582 + &vx_per_cpu(vxi, sched_pc, cpu);
18585 + /* maybe we can simplify that to decrement
18586 + the token counter unconditional? */
18588 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
18589 + __vx_consume_token(sched_pc);
18591 + /* for tokens > 0, one token was consumed */
18595 + vxm_need_resched(p, slice, cpu);
18596 + return (slice == 0);
18600 +#define vx_set_rq_time(rq, time) do { \
18601 + rq->norm_time = time; \
18606 +void vx_try_unhold(struct rq *rq, int cpu)
18608 + struct vx_info *vxi = NULL;
18609 + struct list_head *l, *n;
18610 + int maxidle = HZ;
18613 + /* nothing to do? what about pause? */
18614 + if (list_empty(&rq->hold_queue))
18617 + list_for_each_safe(l, n, &rq->hold_queue) {
18618 + int ret, delta_min[2];
18619 + struct _vx_sched_pc *sched_pc;
18620 + struct task_struct *p;
18622 + p = list_entry(l, struct task_struct, run_list);
18623 + /* don't bother with same context */
18624 + if (vxi == p->vx_info)
18627 + vxi = p->vx_info;
18628 + /* ignore paused contexts */
18629 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
18632 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18634 + /* recalc tokens */
18635 + vxm_sched_info(sched_pc, vxi, cpu);
18636 + ret = vx_tokens_recalc(sched_pc,
18637 + &rq->norm_time, &rq->idle_time, delta_min);
18638 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18641 + /* we found a runable context */
18642 + vx_unhold_task(p, rq);
18645 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
18646 + vx_save_min_skip(ret, &minskip, delta_min[1]);
18648 + vx_set_rq_max_idle(rq, maxidle);
18649 + vx_set_rq_min_skip(rq, minskip);
18650 + vxm_rq_max_min(rq, cpu);
18655 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
18657 + struct vx_info *vxi = next->vx_info;
18658 + struct _vx_sched_pc *sched_pc;
18659 + int delta_min[2];
18665 + flags = vxi->vx_flags;
18667 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
18668 + goto put_on_hold;
18669 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
18672 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18674 + /* update scheduler params */
18675 + if (cpu_isset(cpu, vxi->sched.update)) {
18676 + vx_update_sched_param(&vxi->sched, sched_pc);
18677 + vxm_update_sched(sched_pc, vxi, cpu);
18678 + cpu_clear(cpu, vxi->sched.update);
18681 + vxm_sched_info(sched_pc, vxi, cpu);
18682 + ret = vx_tokens_recalc(sched_pc,
18683 + &rq->norm_time, &rq->idle_time, delta_min);
18684 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18686 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
18689 + if (unlikely(ret < 0)) {
18690 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
18691 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
18692 + vxm_rq_max_min(rq, cpu);
18694 + vx_hold_task(next, rq);
18701 +#else /* CONFIG_VSERVER_HARDCPU */
18704 +void vx_hold_task(struct task_struct *p, struct rq *rq)
18710 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
18715 +unsigned long nr_onhold(void)
18722 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
18724 + return (slice == 0);
18728 +#define vx_set_rq_time(rq, time)
18731 +void vx_try_unhold(struct rq *rq, int cpu)
18737 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
18739 + struct vx_info *vxi = next->vx_info;
18740 + struct _vx_sched_pc *sched_pc;
18741 + int delta_min[2];
18744 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
18747 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18748 + vxm_sched_info(sched_pc, vxi, cpu);
18749 + ret = vx_tokens_recalc(sched_pc,
18750 + &rq->norm_time, &rq->idle_time, delta_min);
18751 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18755 +#endif /* CONFIG_VSERVER_HARDCPU */
18757 diff -Nurp linux-2.6.22.15/kernel/sched_mon.h linux-2.6.22.15-vs2.3.0.29.1/kernel/sched_mon.h
18758 --- linux-2.6.22.15/kernel/sched_mon.h 1969-12-31 19:00:00.000000000 -0500
18759 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/sched_mon.h 2007-12-09 06:44:23.000000000 -0500
18762 +#include <linux/vserver/monitor.h>
18764 +#ifdef CONFIG_VSERVER_MONITOR
18766 +#ifdef CONFIG_VSERVER_HARDCPU
18767 +#define HARDCPU(x) (x)
18769 +#define HARDCPU(x) (0)
18772 +#ifdef CONFIG_VSERVER_IDLETIME
18773 +#define IDLETIME(x) (x)
18775 +#define IDLETIME(x) (0)
18778 +struct _vx_mon_entry *vxm_advance(int cpu);
18782 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
18784 + entry->type = type;
18785 + entry->xid = xid;
18789 +void __vxm_sync(int cpu)
18791 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18793 + __vxm_basic(entry, 0, VXM_SYNC);
18794 + entry->ev.sec = xtime.tv_sec;
18795 + entry->ev.nsec = xtime.tv_nsec;
18799 +void __vxm_task(struct task_struct *p, int type)
18801 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
18803 + __vxm_basic(entry, p->xid, type);
18804 + entry->ev.tsk.pid = p->pid;
18805 + entry->ev.tsk.state = p->state;
18809 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18811 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18813 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
18814 + entry->sd.tokens = s->tokens;
18815 + entry->sd.norm_time = s->norm_time;
18816 + entry->sd.idle_time = s->idle_time;
18820 +void __vxm_rqinfo1(struct rq *q, int cpu)
18822 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18824 + entry->type = VXM_RQINFO_1;
18825 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
18826 + entry->q1.running = q->nr_running;
18827 + entry->q1.onhold = HARDCPU(q->nr_onhold);
18828 + entry->q1.iowait = atomic_read(&q->nr_iowait);
18829 + entry->q1.uintr = q->nr_uninterruptible;
18830 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
18834 +void __vxm_rqinfo2(struct rq *q, int cpu)
18836 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18838 + entry->type = VXM_RQINFO_2;
18839 + entry->xid = (unsigned long)q & 0xffff;
18840 + entry->q2.norm_time = q->norm_time;
18841 + entry->q2.idle_time = q->idle_time;
18842 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
18846 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18848 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18850 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
18851 + entry->ev.tokens = s->tokens;
18855 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18857 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18859 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
18860 + entry->u1.tokens_max = s->tokens_max;
18861 + entry->u1.fill_rate = s->fill_rate[0];
18862 + entry->u1.interval = s->interval[0];
18866 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18868 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18870 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
18871 + entry->u2.tokens_min = s->tokens_min;
18872 + entry->u2.fill_rate = s->fill_rate[1];
18873 + entry->u2.interval = s->interval[1];
18877 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
18878 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
18879 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
18880 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
18881 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
18884 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
18886 + __vxm_task(p, VXM_MIGRATE);
18887 + __vxm_rqinfo1(rq, task_cpu(p));
18888 + __vxm_rqinfo2(rq, task_cpu(p));
18892 +void vxm_idle_skip(struct rq *rq, int cpu)
18894 + __vxm_rqinfo1(rq, cpu);
18895 + __vxm_rqinfo2(rq, cpu);
18899 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
18904 + __vxm_task(p, VXM_RESCHED);
18908 +void vxm_sync(unsigned long now, int cpu)
18910 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
18911 + (now % CONFIG_VSERVER_MONITOR_SYNC))
18917 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
18920 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
18921 + struct vx_info *vxi, int cpu)
18923 + __vxm_sched(s, vxi, cpu);
18924 + __vxm_rqinfo2(rq, cpu);
18928 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18930 + __vxm_sched(s, vxi, cpu);
18931 + __vxm_update(s, vxi, cpu);
18932 + __vxm_update1(s, vxi, cpu);
18933 + __vxm_update2(s, vxi, cpu);
18937 +void vxm_rq_max_min(struct rq *rq, int cpu)
18939 + __vxm_rqinfo1(rq, cpu);
18940 + __vxm_rqinfo2(rq, cpu);
18943 +#else /* CONFIG_VSERVER_MONITOR */
18945 +#define vxm_activate_task(t,q) do { } while (0)
18946 +#define vxm_activate_idle(t,q) do { } while (0)
18947 +#define vxm_deactivate_task(t,q) do { } while (0)
18948 +#define vxm_hold_task(t,q) do { } while (0)
18949 +#define vxm_unhold_task(t,q) do { } while (0)
18950 +#define vxm_migrate_task(t,q,d) do { } while (0)
18951 +#define vxm_idle_skip(q,c) do { } while (0)
18952 +#define vxm_need_resched(t,s,c) do { } while (0)
18953 +#define vxm_sync(s,c) do { } while (0)
18954 +#define vxm_sched_info(s,v,c) do { } while (0)
18955 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
18956 +#define vxm_update_sched(s,v,c) do { } while (0)
18957 +#define vxm_rq_max_min(q,c) do { } while (0)
18959 +#endif /* CONFIG_VSERVER_MONITOR */
18961 diff -Nurp linux-2.6.22.15/kernel/signal.c linux-2.6.22.15-vs2.3.0.29.1/kernel/signal.c
18962 --- linux-2.6.22.15/kernel/signal.c 2007-09-29 08:11:49.000000000 -0400
18963 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/signal.c 2007-12-09 06:44:23.000000000 -0500
18965 #include <linux/freezer.h>
18966 #include <linux/pid_namespace.h>
18967 #include <linux/nsproxy.h>
18968 +#include <linux/vs_context.h>
18969 +#include <linux/vs_pid.h>
18971 #include <asm/param.h>
18972 #include <asm/uaccess.h>
18973 @@ -523,19 +525,34 @@ static int check_kill_permission(int sig
18974 if (!valid_signal(sig))
18977 + if ((info != SEND_SIG_NOINFO) &&
18978 + (is_si_special(info) || !SI_FROMUSER(info)))
18981 + vxdprintk(VXD_CBIT(misc, 7),
18982 + "check_kill_permission(%d,%p,%p[#%u,%u])",
18983 + sig, info, t, vx_task_xid(t), t->pid);
18985 error = audit_signal_info(sig, t); /* Let audit system see the signal */
18990 - if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
18991 - && ((sig != SIGCONT) ||
18992 + if (((sig != SIGCONT) ||
18993 (process_session(current) != process_session(t)))
18994 && (current->euid ^ t->suid) && (current->euid ^ t->uid)
18995 && (current->uid ^ t->suid) && (current->uid ^ t->uid)
18996 && !capable(CAP_KILL))
19000 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
19001 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
19002 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
19003 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
19007 return security_task_kill(t, info, sig, 0);
19010 @@ -1043,7 +1060,7 @@ int kill_pid_info(int sig, struct siginf
19012 p = pid_task(pid, PIDTYPE_PID);
19015 + if (p && vx_check(vx_task_xid(p), VS_IDENT))
19016 error = group_send_sig_info(sig, info, p);
19018 if (unlikely(sig_needs_tasklist(sig)))
19019 @@ -1057,7 +1074,7 @@ kill_proc_info(int sig, struct siginfo *
19023 - error = kill_pid_info(sig, info, find_pid(pid));
19024 + error = kill_pid_info(sig, info, find_pid(vx_rmap_pid(pid)));
19028 @@ -1118,7 +1135,8 @@ static int kill_something_info(int sig,
19030 read_lock(&tasklist_lock);
19031 for_each_process(p) {
19032 - if (p->pid > 1 && p->tgid != current->tgid) {
19033 + if (vx_check(vx_task_xid(p), VS_ADMIN_P|VS_IDENT) &&
19034 + p->pid > 1 && p->tgid != current->tgid) {
19035 int err = group_send_sig_info(sig, info, p);
19038 @@ -1814,6 +1832,11 @@ relock:
19039 if (current == child_reaper(current))
19042 + /* virtual init is protected against user signals */
19043 + if ((info->si_code == SI_USER) &&
19044 + vx_current_initpid(current->pid))
19047 if (sig_kernel_stop(signr)) {
19049 * The default action is to stop all threads in
19050 diff -Nurp linux-2.6.22.15/kernel/softirq.c linux-2.6.22.15-vs2.3.0.29.1/kernel/softirq.c
19051 --- linux-2.6.22.15/kernel/softirq.c 2007-07-21 18:00:25.000000000 -0400
19052 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/softirq.c 2007-12-09 06:44:23.000000000 -0500
19054 #include <linux/rcupdate.h>
19055 #include <linux/smp.h>
19056 #include <linux/tick.h>
19057 +#include <linux/vs_context.h>
19059 #include <asm/irq.h>
19061 diff -Nurp linux-2.6.22.15/kernel/sys.c linux-2.6.22.15-vs2.3.0.29.1/kernel/sys.c
19062 --- linux-2.6.22.15/kernel/sys.c 2007-10-29 21:18:04.000000000 -0400
19063 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/sys.c 2007-12-09 06:44:23.000000000 -0500
19065 #include <linux/compat.h>
19066 #include <linux/syscalls.h>
19067 #include <linux/kprobes.h>
19068 +#include <linux/vs_pid.h>
19070 #include <asm/uaccess.h>
19071 #include <asm/io.h>
19072 @@ -639,7 +640,10 @@ static int set_one_prio(struct task_stru
19075 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
19077 + if (vx_flags(VXF_IGNEG_NICE, 0))
19083 no_nice = security_task_setnice(p, niceval);
19084 @@ -687,6 +691,8 @@ asmlinkage long sys_setpriority(int whic
19086 pgrp = task_pgrp(current);
19087 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
19088 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
19090 error = set_one_prio(p, niceval, error);
19091 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
19093 @@ -695,7 +701,8 @@ asmlinkage long sys_setpriority(int whic
19095 who = current->uid;
19097 - if ((who != current->uid) && !(user = find_user(who)))
19098 + if ((who != current->uid) &&
19099 + !(user = find_user(vx_current_xid(), who)))
19100 goto out_unlock; /* No processes for this user */
19102 do_each_thread(g, p)
19103 @@ -747,6 +754,8 @@ asmlinkage long sys_getpriority(int whic
19105 pgrp = task_pgrp(current);
19106 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
19107 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
19109 niceval = 20 - task_nice(p);
19110 if (niceval > retval)
19112 @@ -757,7 +766,8 @@ asmlinkage long sys_getpriority(int whic
19114 who = current->uid;
19116 - if ((who != current->uid) && !(user = find_user(who)))
19117 + if ((who != current->uid) &&
19118 + !(user = find_user(vx_current_xid(), who)))
19119 goto out_unlock; /* No processes for this user */
19121 do_each_thread(g, p)
19122 @@ -871,6 +881,9 @@ void kernel_power_off(void)
19123 machine_power_off();
19125 EXPORT_SYMBOL_GPL(kernel_power_off);
19127 +long vs_reboot(unsigned int, void __user *);
19130 * Reboot system call: for obvious reasons only root may call it,
19131 * and even root needs to set up some magic numbers in the registers
19132 @@ -901,6 +914,9 @@ asmlinkage long sys_reboot(int magic1, i
19133 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
19134 cmd = LINUX_REBOOT_CMD_HALT;
19136 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
19137 + return vs_reboot(cmd, arg);
19141 case LINUX_REBOOT_CMD_RESTART:
19142 @@ -1080,7 +1096,7 @@ static int set_user(uid_t new_ruid, int
19144 struct user_struct *new_user;
19146 - new_user = alloc_uid(new_ruid);
19147 + new_user = alloc_uid(vx_current_xid(), new_ruid);
19151 @@ -1434,15 +1450,18 @@ asmlinkage long sys_setpgid(pid_t pid, p
19153 struct task_struct *p;
19154 struct task_struct *group_leader = current->group_leader;
19159 - pid = group_leader->pid;
19160 + pid = vx_map_pid(group_leader->pid);
19166 + rpgid = vx_rmap_pid(pgid);
19168 /* From this point forward we keep holding onto the tasklist lock
19169 * so that our parent does not change from under us. -DaveM
19171 @@ -1476,20 +1495,20 @@ asmlinkage long sys_setpgid(pid_t pid, p
19174 struct task_struct *g =
19175 - find_task_by_pid_type(PIDTYPE_PGID, pgid);
19176 + find_task_by_pid_type(PIDTYPE_PGID, rpgid);
19178 if (!g || task_session(g) != task_session(group_leader))
19182 - err = security_task_setpgid(p, pgid);
19183 + err = security_task_setpgid(p, rpgid);
19187 - if (process_group(p) != pgid) {
19188 + if (process_group(p) != rpgid) {
19189 detach_pid(p, PIDTYPE_PGID);
19190 - p->signal->pgrp = pgid;
19191 - attach_pid(p, PIDTYPE_PGID, find_pid(pgid));
19192 + p->signal->pgrp = rpgid;
19193 + attach_pid(p, PIDTYPE_PGID, find_pid(rpgid));
19197 @@ -1502,7 +1521,7 @@ out:
19198 asmlinkage long sys_getpgid(pid_t pid)
19201 - return process_group(current);
19202 + return vx_rmap_pid(process_group(current));
19205 struct task_struct *p;
19206 @@ -1514,7 +1533,7 @@ asmlinkage long sys_getpgid(pid_t pid)
19208 retval = security_task_getpgid(p);
19210 - retval = process_group(p);
19211 + retval = vx_rmap_pid(process_group(p));
19213 read_unlock(&tasklist_lock);
19215 @@ -1865,7 +1884,7 @@ asmlinkage long sys_sethostname(char __u
19217 char tmp[__NEW_UTS_LEN];
19219 - if (!capable(CAP_SYS_ADMIN))
19220 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
19222 if (len < 0 || len > __NEW_UTS_LEN)
19224 @@ -1910,7 +1929,7 @@ asmlinkage long sys_setdomainname(char _
19226 char tmp[__NEW_UTS_LEN];
19228 - if (!capable(CAP_SYS_ADMIN))
19229 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
19231 if (len < 0 || len > __NEW_UTS_LEN)
19233 @@ -1977,7 +1996,7 @@ asmlinkage long sys_setrlimit(unsigned i
19235 old_rlim = current->signal->rlim + resource;
19236 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
19237 - !capable(CAP_SYS_RESOURCE))
19238 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
19240 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
19242 diff -Nurp linux-2.6.22.15/kernel/sysctl.c linux-2.6.22.15-vs2.3.0.29.1/kernel/sysctl.c
19243 --- linux-2.6.22.15/kernel/sysctl.c 2007-07-21 18:00:25.000000000 -0400
19244 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/sysctl.c 2007-12-09 06:44:23.000000000 -0500
19245 @@ -89,6 +89,7 @@ static int ngroups_max = NGROUPS_MAX;
19247 extern char modprobe_path[];
19249 +extern char vshelper_path[];
19250 #ifdef CONFIG_CHR_DEV_SG
19251 extern int sg_big_buff;
19253 @@ -343,6 +344,15 @@ static ctl_table kern_table[] = {
19254 .strategy = &sysctl_string,
19258 + .ctl_name = KERN_VSHELPER,
19259 + .procname = "vshelper",
19260 + .data = &vshelper_path,
19263 + .proc_handler = &proc_dostring,
19264 + .strategy = &sysctl_string,
19266 #ifdef CONFIG_CHR_DEV_SG
19268 .ctl_name = KERN_SG_BIG_BUFF,
19269 diff -Nurp linux-2.6.22.15/kernel/time.c linux-2.6.22.15-vs2.3.0.29.1/kernel/time.c
19270 --- linux-2.6.22.15/kernel/time.c 2007-07-21 18:00:25.000000000 -0400
19271 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/time.c 2007-12-09 06:44:23.000000000 -0500
19272 @@ -60,7 +60,7 @@ asmlinkage long sys_time(time_t __user *
19276 - do_gettimeofday(&tv);
19277 + vx_gettimeofday(&tv);
19281 @@ -91,7 +91,7 @@ asmlinkage long sys_stime(time_t __user
19285 - do_settimeofday(&tv);
19286 + vx_settimeofday(&tv);
19290 @@ -101,7 +101,7 @@ asmlinkage long sys_gettimeofday(struct
19292 if (likely(tv != NULL)) {
19293 struct timeval ktv;
19294 - do_gettimeofday(&ktv);
19295 + vx_gettimeofday(&ktv);
19296 if (copy_to_user(tv, &ktv, sizeof(ktv)))
19299 @@ -175,7 +175,7 @@ int do_sys_settimeofday(struct timespec
19300 /* SMP safe, again the code in arch/foo/time.c should
19301 * globally block out interrupts when it runs.
19303 - return do_settimeofday(tv);
19304 + return vx_settimeofday(tv);
19308 @@ -388,7 +388,7 @@ void getnstimeofday(struct timespec *tv)
19312 - do_gettimeofday(&x);
19313 + vx_gettimeofday(&x);
19314 tv->tv_sec = x.tv_sec;
19315 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
19317 diff -Nurp linux-2.6.22.15/kernel/timer.c linux-2.6.22.15-vs2.3.0.29.1/kernel/timer.c
19318 --- linux-2.6.22.15/kernel/timer.c 2007-07-21 18:00:25.000000000 -0400
19319 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/timer.c 2007-12-09 06:44:23.000000000 -0500
19321 #include <linux/delay.h>
19322 #include <linux/tick.h>
19323 #include <linux/kallsyms.h>
19324 +#include <linux/vs_base.h>
19325 +#include <linux/vs_cvirt.h>
19326 +#include <linux/vs_pid.h>
19327 +#include <linux/vserver/sched.h>
19329 #include <asm/uaccess.h>
19330 #include <asm/unistd.h>
19331 @@ -921,12 +925,6 @@ asmlinkage unsigned long sys_alarm(unsig
19338 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
19339 - * should be moved into arch/i386 instead?
19343 * sys_getpid - return the thread group id of the current process
19344 @@ -939,7 +937,7 @@ asmlinkage unsigned long sys_alarm(unsig
19346 asmlinkage long sys_getpid(void)
19348 - return current->tgid;
19349 + return vx_map_tgid(current->tgid);
19353 @@ -955,10 +953,23 @@ asmlinkage long sys_getppid(void)
19355 pid = rcu_dereference(current->real_parent)->tgid;
19357 + return vx_map_pid(pid);
19364 + * The Alpha uses getxpid, getxuid, and getxgid instead.
19367 +asmlinkage long do_getxpid(long *ppid)
19369 + *ppid = sys_getppid();
19370 + return sys_getpid();
19373 +#else /* _alpha_ */
19375 asmlinkage long sys_getuid(void)
19377 /* Only we change this so SMP safe */
19378 @@ -1118,6 +1129,8 @@ int do_sysinfo(struct sysinfo *info)
19379 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
19382 + if (vx_flags(VXF_VIRT_UPTIME, 0))
19383 + vx_vsi_uptime(&tp, NULL);
19384 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
19386 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
19387 diff -Nurp linux-2.6.22.15/kernel/user.c linux-2.6.22.15-vs2.3.0.29.1/kernel/user.c
19388 --- linux-2.6.22.15/kernel/user.c 2007-05-04 09:58:24.000000000 -0400
19389 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/user.c 2007-12-09 06:44:23.000000000 -0500
19391 #define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8)
19392 #define UIDHASH_SZ (1 << UIDHASH_BITS)
19393 #define UIDHASH_MASK (UIDHASH_SZ - 1)
19394 -#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
19395 -#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid)))
19396 +#define __uidhashfn(xid,uid) ((((uid) >> UIDHASH_BITS) + ((uid)^(xid))) & UIDHASH_MASK)
19397 +#define uidhashentry(xid,uid) (uidhash_table + __uidhashfn((xid),(uid)))
19399 static struct kmem_cache *uid_cachep;
19400 static struct list_head uidhash_table[UIDHASH_SZ];
19401 @@ -66,7 +66,7 @@ static inline void uid_hash_remove(struc
19402 list_del(&up->uidhash_list);
19405 -static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
19406 +static inline struct user_struct *uid_hash_find(xid_t xid, uid_t uid, struct list_head *hashent)
19408 struct list_head *up;
19410 @@ -75,7 +75,7 @@ static inline struct user_struct *uid_ha
19412 user = list_entry(up, struct user_struct, uidhash_list);
19414 - if(user->uid == uid) {
19415 + if(user->uid == uid && user->xid == xid) {
19416 atomic_inc(&user->__count);
19419 @@ -90,13 +90,13 @@ static inline struct user_struct *uid_ha
19421 * If the user_struct could not be found, return NULL.
19423 -struct user_struct *find_user(uid_t uid)
19424 +struct user_struct *find_user(xid_t xid, uid_t uid)
19426 struct user_struct *ret;
19427 unsigned long flags;
19429 spin_lock_irqsave(&uidhash_lock, flags);
19430 - ret = uid_hash_find(uid, uidhashentry(uid));
19431 + ret = uid_hash_find(xid, uid, uidhashentry(xid, uid));
19432 spin_unlock_irqrestore(&uidhash_lock, flags);
19435 @@ -120,13 +120,13 @@ void free_uid(struct user_struct *up)
19439 -struct user_struct * alloc_uid(uid_t uid)
19440 +struct user_struct * alloc_uid(xid_t xid, uid_t uid)
19442 - struct list_head *hashent = uidhashentry(uid);
19443 + struct list_head *hashent = uidhashentry(xid, uid);
19444 struct user_struct *up;
19446 spin_lock_irq(&uidhash_lock);
19447 - up = uid_hash_find(uid, hashent);
19448 + up = uid_hash_find(xid, uid, hashent);
19449 spin_unlock_irq(&uidhash_lock);
19452 @@ -136,6 +136,7 @@ struct user_struct * alloc_uid(uid_t uid
19457 atomic_set(&new->__count, 1);
19458 atomic_set(&new->processes, 0);
19459 atomic_set(&new->files, 0);
19460 @@ -158,7 +159,7 @@ struct user_struct * alloc_uid(uid_t uid
19461 * on adding the same user already..
19463 spin_lock_irq(&uidhash_lock);
19464 - up = uid_hash_find(uid, hashent);
19465 + up = uid_hash_find(xid, uid, hashent);
19467 key_put(new->uid_keyring);
19468 key_put(new->session_keyring);
19469 @@ -215,7 +216,7 @@ static int __init uid_cache_init(void)
19471 /* Insert the root user immediately (init already runs as root) */
19472 spin_lock_irq(&uidhash_lock);
19473 - uid_hash_insert(&root_user, uidhashentry(0));
19474 + uid_hash_insert(&root_user, uidhashentry(0,0));
19475 spin_unlock_irq(&uidhash_lock);
19478 diff -Nurp linux-2.6.22.15/kernel/utsname.c linux-2.6.22.15-vs2.3.0.29.1/kernel/utsname.c
19479 --- linux-2.6.22.15/kernel/utsname.c 2007-07-21 18:00:25.000000000 -0400
19480 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/utsname.c 2007-12-09 06:44:23.000000000 -0500
19482 #include <linux/uts.h>
19483 #include <linux/utsname.h>
19484 #include <linux/version.h>
19485 +#include <linux/vserver/global.h>
19488 * Clone a new ns copying an original utsname, setting refcount to 1
19489 @@ -27,6 +28,7 @@ static struct uts_namespace *clone_uts_n
19491 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
19492 kref_init(&ns->kref);
19493 + atomic_inc(&vs_global_uts_ns);
19497 @@ -58,5 +60,6 @@ void free_uts_ns(struct kref *kref)
19498 struct uts_namespace *ns;
19500 ns = container_of(kref, struct uts_namespace, kref);
19501 + atomic_dec(&vs_global_uts_ns);
19504 diff -Nurp linux-2.6.22.15/kernel/vserver/cacct.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cacct.c
19505 --- linux-2.6.22.15/kernel/vserver/cacct.c 1969-12-31 19:00:00.000000000 -0500
19506 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cacct.c 2007-12-09 06:44:23.000000000 -0500
19509 + * linux/kernel/vserver/cacct.c
19511 + * Virtual Server: Context Accounting
19513 + * Copyright (C) 2006-2007 Herbert Pötzl
19515 + * V0.01 added accounting stats
19519 +#include <linux/types.h>
19520 +#include <linux/vs_context.h>
19521 +#include <linux/vserver/cacct_cmd.h>
19522 +#include <linux/vserver/cacct_int.h>
19524 +#include <asm/errno.h>
19525 +#include <asm/uaccess.h>
19528 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
19530 + struct vcmd_sock_stat_v0 vc_data;
19533 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19536 + field = vc_data.field;
19537 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
19540 + for (j = 0; j < 3; j++) {
19541 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
19542 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
19545 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19550 diff -Nurp linux-2.6.22.15/kernel/vserver/cacct_init.h linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cacct_init.h
19551 --- linux-2.6.22.15/kernel/vserver/cacct_init.h 1969-12-31 19:00:00.000000000 -0500
19552 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cacct_init.h 2007-12-09 06:44:23.000000000 -0500
19556 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
19561 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
19562 + for (j = 0; j < 3; j++) {
19563 + atomic_set(&cacct->sock[i][j].count, 0);
19564 + atomic_set(&cacct->sock[i][j].total, 0);
19567 + for (i = 0; i < 8; i++)
19568 + atomic_set(&cacct->slab[i], 0);
19569 + for (i = 0; i < 5; i++)
19570 + for (j = 0; j < 4; j++)
19571 + atomic_set(&cacct->page[i][j], 0);
19574 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
19579 diff -Nurp linux-2.6.22.15/kernel/vserver/cacct_proc.h linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cacct_proc.h
19580 --- linux-2.6.22.15/kernel/vserver/cacct_proc.h 1969-12-31 19:00:00.000000000 -0500
19581 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cacct_proc.h 2007-12-09 06:44:23.000000000 -0500
19583 +#ifndef _VX_CACCT_PROC_H
19584 +#define _VX_CACCT_PROC_H
19586 +#include <linux/vserver/cacct_int.h>
19589 +#define VX_SOCKA_TOP \
19590 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
19592 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
19594 + int i, j, length = 0;
19595 + static char *type[VXA_SOCK_SIZE] = {
19596 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
19599 + length += sprintf(buffer + length, VX_SOCKA_TOP);
19600 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
19601 + length += sprintf(buffer + length, "%s:", type[i]);
19602 + for (j = 0; j < 3; j++) {
19603 + length += sprintf(buffer + length,
19604 + "\t%10lu/%-10lu",
19605 + vx_sock_count(cacct, i, j),
19606 + vx_sock_total(cacct, i, j));
19608 + buffer[length++] = '\n';
19611 + length += sprintf(buffer + length, "\n");
19612 + length += sprintf(buffer + length,
19613 + "slab:\t %8u %8u %8u %8u\n",
19614 + atomic_read(&cacct->slab[1]),
19615 + atomic_read(&cacct->slab[4]),
19616 + atomic_read(&cacct->slab[0]),
19617 + atomic_read(&cacct->slab[2]));
19619 + length += sprintf(buffer + length, "\n");
19620 + for (i = 0; i < 5; i++) {
19621 + length += sprintf(buffer + length,
19622 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
19623 + atomic_read(&cacct->page[i][0]),
19624 + atomic_read(&cacct->page[i][1]),
19625 + atomic_read(&cacct->page[i][2]),
19626 + atomic_read(&cacct->page[i][3]),
19627 + atomic_read(&cacct->page[i][4]),
19628 + atomic_read(&cacct->page[i][5]),
19629 + atomic_read(&cacct->page[i][6]),
19630 + atomic_read(&cacct->page[i][7]));
19635 +#endif /* _VX_CACCT_PROC_H */
19636 diff -Nurp linux-2.6.22.15/kernel/vserver/context.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/context.c
19637 --- linux-2.6.22.15/kernel/vserver/context.c 1969-12-31 19:00:00.000000000 -0500
19638 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/context.c 2007-12-09 06:45:11.000000000 -0500
19641 + * linux/kernel/vserver/context.c
19643 + * Virtual Server: Context Support
19645 + * Copyright (C) 2003-2007 Herbert Pötzl
19647 + * V0.01 context helper
19648 + * V0.02 vx_ctx_kill syscall command
19649 + * V0.03 replaced context_info calls
19650 + * V0.04 redesign of struct (de)alloc
19651 + * V0.05 rlimit basic implementation
19652 + * V0.06 task_xid and info commands
19653 + * V0.07 context flags and caps
19654 + * V0.08 switch to RCU based hash
19655 + * V0.09 revert to non RCU for now
19656 + * V0.10 and back to working RCU hash
19657 + * V0.11 and back to locking again
19658 + * V0.12 referenced context store
19659 + * V0.13 separate per cpu data
19660 + * V0.14 changed vcmds to vxi arg
19661 + * V0.15 added context stat
19662 + * V0.16 have __create claim() the vxi
19663 + * V0.17 removed older and legacy stuff
19667 +#include <linux/slab.h>
19668 +#include <linux/types.h>
19669 +#include <linux/pid_namespace.h>
19671 +#include <linux/vserver/context.h>
19672 +#include <linux/vserver/network.h>
19673 +#include <linux/vserver/debug.h>
19674 +#include <linux/vserver/limit.h>
19675 +#include <linux/vserver/limit_int.h>
19676 +#include <linux/vserver/space.h>
19678 +#include <linux/vs_context.h>
19679 +#include <linux/vs_limit.h>
19680 +#include <linux/vserver/context_cmd.h>
19682 +#include "cvirt_init.h"
19683 +#include "cacct_init.h"
19684 +#include "limit_init.h"
19685 +#include "sched_init.h"
19688 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
19689 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
19692 +/* now inactive context structures */
19694 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
19696 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
19699 +/* __alloc_vx_info()
19701 + * allocate an initialized vx_info struct
19702 + * doesn't make it visible (hash) */
19704 +static struct vx_info *__alloc_vx_info(xid_t xid)
19706 + struct vx_info *new = NULL;
19709 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
19711 + /* would this benefit from a slab cache? */
19712 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
19716 + memset(new, 0, sizeof(struct vx_info));
19718 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
19719 + if (!new->ptr_pc)
19722 + new->vx_id = xid;
19723 + INIT_HLIST_NODE(&new->vx_hlist);
19724 + atomic_set(&new->vx_usecnt, 0);
19725 + atomic_set(&new->vx_tasks, 0);
19726 + new->vx_parent = NULL;
19727 + new->vx_state = 0;
19728 + init_waitqueue_head(&new->vx_wait);
19730 + /* prepare reaper */
19731 + get_task_struct(init_pid_ns.child_reaper);
19732 + new->vx_reaper = init_pid_ns.child_reaper;
19733 + new->vx_badness_bias = 0;
19735 + /* rest of init goes here */
19736 + vx_info_init_limit(&new->limit);
19737 + vx_info_init_sched(&new->sched);
19738 + vx_info_init_cvirt(&new->cvirt);
19739 + vx_info_init_cacct(&new->cacct);
19741 + /* per cpu data structures */
19742 + for_each_possible_cpu(cpu) {
19743 + vx_info_init_sched_pc(
19744 + &vx_per_cpu(new, sched_pc, cpu), cpu);
19745 + vx_info_init_cvirt_pc(
19746 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
19749 + new->vx_flags = VXF_INIT_SET;
19750 + new->vx_bcaps = CAP_INIT_EFF_SET;
19751 + new->vx_ccaps = 0;
19752 + new->vx_cap_bset = cap_bset;
19754 + new->reboot_cmd = 0;
19755 + new->exit_code = 0;
19757 + vxdprintk(VXD_CBIT(xid, 0),
19758 + "alloc_vx_info(%d) = %p", xid, new);
19759 + vxh_alloc_vx_info(new);
19760 + atomic_inc(&vx_global_ctotal);
19769 +/* __dealloc_vx_info()
19771 + * final disposal of vx_info */
19773 +static void __dealloc_vx_info(struct vx_info *vxi)
19777 + vxdprintk(VXD_CBIT(xid, 0),
19778 + "dealloc_vx_info(%p)", vxi);
19779 + vxh_dealloc_vx_info(vxi);
19783 + vx_info_exit_limit(&vxi->limit);
19784 + vx_info_exit_sched(&vxi->sched);
19785 + vx_info_exit_cvirt(&vxi->cvirt);
19786 + vx_info_exit_cacct(&vxi->cacct);
19788 + for_each_possible_cpu(cpu) {
19789 + vx_info_exit_sched_pc(
19790 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
19791 + vx_info_exit_cvirt_pc(
19792 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
19795 + vxi->vx_state |= VXS_RELEASED;
19798 + free_percpu(vxi->ptr_pc);
19801 + atomic_dec(&vx_global_ctotal);
19804 +static void __shutdown_vx_info(struct vx_info *vxi)
19806 + struct nsproxy *nsproxy;
19807 + struct fs_struct *fs;
19811 + vxi->vx_state |= VXS_SHUTDOWN;
19812 + vs_state_change(vxi, VSC_SHUTDOWN);
19814 + nsproxy = xchg(&vxi->vx_nsproxy, NULL);
19815 + fs = xchg(&vxi->vx_fs, NULL);
19818 + put_nsproxy(nsproxy);
19820 + put_fs_struct(fs);
19823 +/* exported stuff */
19825 +void free_vx_info(struct vx_info *vxi)
19827 + unsigned long flags;
19829 + /* check for reference counts first */
19830 + BUG_ON(atomic_read(&vxi->vx_usecnt));
19831 + BUG_ON(atomic_read(&vxi->vx_tasks));
19833 + /* context must not be hashed */
19834 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
19836 + /* context shutdown is mandatory */
19837 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
19839 + BUG_ON(vxi->vx_nsproxy);
19840 + BUG_ON(vxi->vx_fs);
19842 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
19843 + hlist_del(&vxi->vx_hlist);
19844 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
19846 + __dealloc_vx_info(vxi);
19850 +/* hash table for vx_info hash */
19852 +#define VX_HASH_SIZE 13
19854 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
19855 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
19857 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
19860 +static inline unsigned int __hashval(xid_t xid)
19862 + return (xid % VX_HASH_SIZE);
19867 +/* __hash_vx_info()
19869 + * add the vxi to the global hash table
19870 + * requires the hash_lock to be held */
19872 +static inline void __hash_vx_info(struct vx_info *vxi)
19874 + struct hlist_head *head;
19876 + vxd_assert_lock(&vx_info_hash_lock);
19877 + vxdprintk(VXD_CBIT(xid, 4),
19878 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
19879 + vxh_hash_vx_info(vxi);
19881 + /* context must not be hashed */
19882 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
19884 + vxi->vx_state |= VXS_HASHED;
19885 + head = &vx_info_hash[__hashval(vxi->vx_id)];
19886 + hlist_add_head(&vxi->vx_hlist, head);
19887 + atomic_inc(&vx_global_cactive);
19890 +/* __unhash_vx_info()
19892 + * remove the vxi from the global hash table
19893 + * requires the hash_lock to be held */
19895 +static inline void __unhash_vx_info(struct vx_info *vxi)
19897 + unsigned long flags;
19899 + vxd_assert_lock(&vx_info_hash_lock);
19900 + vxdprintk(VXD_CBIT(xid, 4),
19901 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
19902 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
19903 + vxh_unhash_vx_info(vxi);
19905 + /* context must be hashed */
19906 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
19907 + /* but without tasks */
19908 + BUG_ON(atomic_read(&vxi->vx_tasks));
19910 + vxi->vx_state &= ~VXS_HASHED;
19911 + hlist_del_init(&vxi->vx_hlist);
19912 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
19913 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
19914 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
19915 + atomic_dec(&vx_global_cactive);
19919 +/* __lookup_vx_info()
19921 + * requires the hash_lock to be held
19922 + * doesn't increment the vx_refcnt */
19924 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
19926 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
19927 + struct hlist_node *pos;
19928 + struct vx_info *vxi;
19930 + vxd_assert_lock(&vx_info_hash_lock);
19931 + hlist_for_each(pos, head) {
19932 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
19934 + if (vxi->vx_id == xid)
19939 + vxdprintk(VXD_CBIT(xid, 0),
19940 + "__lookup_vx_info(#%u): %p[#%u]",
19941 + xid, vxi, vxi ? vxi->vx_id : 0);
19942 + vxh_lookup_vx_info(vxi, xid);
19947 +/* __create_vx_info()
19949 + * create the requested context
19950 + * get(), claim() and hash it */
19952 +static struct vx_info *__create_vx_info(int id)
19954 + struct vx_info *new, *vxi = NULL;
19956 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
19958 + if (!(new = __alloc_vx_info(id)))
19959 + return ERR_PTR(-ENOMEM);
19961 + /* required to make dynamic xids unique */
19962 + spin_lock(&vx_info_hash_lock);
19964 + /* static context requested */
19965 + if ((vxi = __lookup_vx_info(id))) {
19966 + vxdprintk(VXD_CBIT(xid, 0),
19967 + "create_vx_info(%d) = %p (already there)", id, vxi);
19968 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
19969 + vxi = ERR_PTR(-EBUSY);
19971 + vxi = ERR_PTR(-EEXIST);
19974 + /* new context */
19975 + vxdprintk(VXD_CBIT(xid, 0),
19976 + "create_vx_info(%d) = %p (new)", id, new);
19977 + claim_vx_info(new, NULL);
19978 + __hash_vx_info(get_vx_info(new));
19979 + vxi = new, new = NULL;
19982 + spin_unlock(&vx_info_hash_lock);
19983 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
19985 + __dealloc_vx_info(new);
19990 +/* exported stuff */
19993 +void unhash_vx_info(struct vx_info *vxi)
19995 + __shutdown_vx_info(vxi);
19996 + spin_lock(&vx_info_hash_lock);
19997 + __unhash_vx_info(vxi);
19998 + spin_unlock(&vx_info_hash_lock);
19999 + __wakeup_vx_info(vxi);
20003 +/* lookup_vx_info()
20005 + * search for a vx_info and get() it
20006 + * negative id means current */
20008 +struct vx_info *lookup_vx_info(int id)
20010 + struct vx_info *vxi = NULL;
20013 + vxi = get_vx_info(current->vx_info);
20014 + } else if (id > 1) {
20015 + spin_lock(&vx_info_hash_lock);
20016 + vxi = get_vx_info(__lookup_vx_info(id));
20017 + spin_unlock(&vx_info_hash_lock);
20022 +/* xid_is_hashed()
20024 + * verify that xid is still hashed */
20026 +int xid_is_hashed(xid_t xid)
20030 + spin_lock(&vx_info_hash_lock);
20031 + hashed = (__lookup_vx_info(xid) != NULL);
20032 + spin_unlock(&vx_info_hash_lock);
20036 +#ifdef CONFIG_PROC_FS
20040 + * get a subset of hashed xids for proc
20041 + * assumes size is at least one */
20043 +int get_xid_list(int index, unsigned int *xids, int size)
20045 + int hindex, nr_xids = 0;
20047 + /* only show current and children */
20048 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
20051 + xids[nr_xids] = vx_current_xid();
20055 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
20056 + struct hlist_head *head = &vx_info_hash[hindex];
20057 + struct hlist_node *pos;
20059 + spin_lock(&vx_info_hash_lock);
20060 + hlist_for_each(pos, head) {
20061 + struct vx_info *vxi;
20066 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
20067 + xids[nr_xids] = vxi->vx_id;
20068 + if (++nr_xids >= size) {
20069 + spin_unlock(&vx_info_hash_lock);
20073 + /* keep the lock time short */
20074 + spin_unlock(&vx_info_hash_lock);
20081 +#ifdef CONFIG_VSERVER_DEBUG
20083 +void dump_vx_info_inactive(int level)
20085 + struct hlist_node *entry, *next;
20087 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
20088 + struct vx_info *vxi =
20089 + list_entry(entry, struct vx_info, vx_hlist);
20091 + dump_vx_info(vxi, level);
20097 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
20099 + struct user_struct *new_user, *old_user;
20104 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
20107 + new_user = alloc_uid(vxi->vx_id, p->uid);
20111 + old_user = p->user;
20112 + if (new_user != old_user) {
20113 + atomic_inc(&new_user->processes);
20114 + atomic_dec(&old_user->processes);
20115 + p->user = new_user;
20117 + free_uid(old_user);
20121 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
20123 + p->cap_effective &= vxi->vx_cap_bset;
20124 + p->cap_inheritable &= vxi->vx_cap_bset;
20125 + p->cap_permitted &= vxi->vx_cap_bset;
20129 +#include <linux/file.h>
20131 +static int vx_openfd_task(struct task_struct *tsk)
20133 + struct files_struct *files = tsk->files;
20134 + struct fdtable *fdt;
20135 + const unsigned long *bptr;
20136 + int count, total;
20138 + /* no rcu_read_lock() because of spin_lock() */
20139 + spin_lock(&files->file_lock);
20140 + fdt = files_fdtable(files);
20141 + bptr = fdt->open_fds->fds_bits;
20142 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
20143 + for (total = 0; count > 0; count--) {
20145 + total += hweight_long(*bptr);
20148 + spin_unlock(&files->file_lock);
20153 +/* for *space compatibility */
20155 +asmlinkage long sys_unshare(unsigned long);
20158 + * migrate task to new context
20159 + * gets vxi, puts old_vxi on change
20160 + * optionally unshares namespaces (hack)
20163 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
20165 + struct vx_info *old_vxi;
20171 + vxdprintk(VXD_CBIT(xid, 5),
20172 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
20173 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
20175 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
20176 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
20179 + if (vx_info_state(vxi, VXS_SHUTDOWN))
20182 + old_vxi = task_get_vx_info(p);
20183 + if (old_vxi == vxi)
20186 + if (!(ret = vx_migrate_user(p, vxi))) {
20190 + openfd = vx_openfd_task(p);
20193 + atomic_dec(&old_vxi->cvirt.nr_threads);
20194 + atomic_dec(&old_vxi->cvirt.nr_running);
20195 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
20196 + /* FIXME: what about the struct files here? */
20197 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
20198 + /* account for the executable */
20199 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
20201 + atomic_inc(&vxi->cvirt.nr_threads);
20202 + atomic_inc(&vxi->cvirt.nr_running);
20203 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
20204 + /* FIXME: what about the struct files here? */
20205 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
20206 + /* account for the executable */
20207 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
20210 + release_vx_info(old_vxi, p);
20211 + clr_vx_info(&p->vx_info);
20213 + claim_vx_info(vxi, p);
20214 + set_vx_info(&p->vx_info, vxi);
20215 + p->xid = vxi->vx_id;
20217 + vxdprintk(VXD_CBIT(xid, 5),
20218 + "moved task %p into vxi:%p[#%d]",
20219 + p, vxi, vxi->vx_id);
20221 + vx_mask_cap_bset(vxi, p);
20224 + /* hack for *spaces to provide compatibility */
20226 + struct nsproxy *old_nsp, *new_nsp;
20228 + ret = unshare_nsproxy_namespaces(
20229 + CLONE_NEWUTS | CLONE_NEWIPC,
20234 + old_nsp = xchg(&p->nsproxy, new_nsp);
20235 + vx_set_space(vxi, CLONE_NEWUTS | CLONE_NEWIPC);
20236 + put_nsproxy(old_nsp);
20240 + put_vx_info(old_vxi);
20244 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
20246 + struct task_struct *old_reaper;
20251 + vxdprintk(VXD_CBIT(xid, 6),
20252 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
20253 + vxi, vxi->vx_id, p, p->xid, p->pid);
20255 + old_reaper = vxi->vx_reaper;
20256 + if (old_reaper == p)
20259 + /* set new child reaper */
20260 + get_task_struct(p);
20261 + vxi->vx_reaper = p;
20262 + put_task_struct(old_reaper);
20266 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
20271 + vxdprintk(VXD_CBIT(xid, 6),
20272 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
20273 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
20275 + vxi->vx_flags &= ~VXF_STATE_INIT;
20276 + vxi->vx_initpid = p->tgid;
20280 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
20282 + vxdprintk(VXD_CBIT(xid, 6),
20283 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
20284 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
20286 + vxi->exit_code = code;
20287 + vxi->vx_initpid = 0;
20291 +void vx_set_persistent(struct vx_info *vxi)
20293 + vxdprintk(VXD_CBIT(xid, 6),
20294 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
20296 + get_vx_info(vxi);
20297 + claim_vx_info(vxi, NULL);
20300 +void vx_clear_persistent(struct vx_info *vxi)
20302 + vxdprintk(VXD_CBIT(xid, 6),
20303 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
20305 + release_vx_info(vxi, NULL);
20306 + put_vx_info(vxi);
20309 +void vx_update_persistent(struct vx_info *vxi)
20311 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
20312 + vx_set_persistent(vxi);
20314 + vx_clear_persistent(vxi);
20318 +/* task must be current or locked */
20320 +void exit_vx_info(struct task_struct *p, int code)
20322 + struct vx_info *vxi = p->vx_info;
20325 + atomic_dec(&vxi->cvirt.nr_threads);
20328 + vxi->exit_code = code;
20329 + release_vx_info(vxi, p);
20333 +void exit_vx_info_early(struct task_struct *p, int code)
20335 + struct vx_info *vxi = p->vx_info;
20338 + if (vxi->vx_initpid == p->tgid)
20339 + vx_exit_init(vxi, p, code);
20340 + if (vxi->vx_reaper == p)
20341 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
20346 +/* vserver syscall commands below here */
20348 +/* taks xid and vx_info functions */
20350 +#include <asm/uaccess.h>
20353 +int vc_task_xid(uint32_t id)
20358 + struct task_struct *tsk;
20360 + read_lock(&tasklist_lock);
20361 + tsk = find_task_by_real_pid(id);
20362 + xid = (tsk) ? tsk->xid : -ESRCH;
20363 + read_unlock(&tasklist_lock);
20365 + xid = vx_current_xid();
20370 +int vc_vx_info(struct vx_info *vxi, void __user *data)
20372 + struct vcmd_vx_info_v0 vc_data;
20374 + vc_data.xid = vxi->vx_id;
20375 + vc_data.initpid = vxi->vx_initpid;
20377 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20383 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
20385 + struct vcmd_ctx_stat_v0 vc_data;
20387 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
20388 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
20390 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20396 +/* context functions */
20398 +int vc_ctx_create(uint32_t xid, void __user *data)
20400 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
20401 + struct vx_info *new_vxi;
20404 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20407 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
20410 + new_vxi = __create_vx_info(xid);
20411 + if (IS_ERR(new_vxi))
20412 + return PTR_ERR(new_vxi);
20414 + /* initial flags */
20415 + new_vxi->vx_flags = vc_data.flagword;
20418 + if (vs_state_change(new_vxi, VSC_STARTUP))
20421 + ret = vx_migrate_task(current, new_vxi, (!data));
20425 + /* return context id on success */
20426 + ret = new_vxi->vx_id;
20428 + /* get a reference for persistent contexts */
20429 + if ((vc_data.flagword & VXF_PERSISTENT))
20430 + vx_set_persistent(new_vxi);
20432 + release_vx_info(new_vxi, NULL);
20433 + put_vx_info(new_vxi);
20438 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
20440 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
20443 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20446 + ret = vx_migrate_task(current, vxi, 0);
20449 + if (vc_data.flagword & VXM_SET_INIT)
20450 + ret = vx_set_init(vxi, current);
20453 + if (vc_data.flagword & VXM_SET_REAPER)
20454 + ret = vx_set_reaper(vxi, current);
20459 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
20461 + struct vcmd_ctx_flags_v0 vc_data;
20463 + vc_data.flagword = vxi->vx_flags;
20465 + /* special STATE flag handling */
20466 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
20468 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20473 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
20475 + struct vcmd_ctx_flags_v0 vc_data;
20476 + uint64_t mask, trigger;
20478 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20481 + /* special STATE flag handling */
20482 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
20483 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
20485 + if (vxi == current->vx_info) {
20486 + if (trigger & VXF_STATE_SETUP)
20487 + vx_mask_cap_bset(vxi, current);
20488 + if (trigger & VXF_STATE_INIT) {
20491 + ret = vx_set_init(vxi, current);
20494 + ret = vx_set_reaper(vxi, current);
20500 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
20501 + vc_data.flagword, mask);
20502 + if (trigger & VXF_PERSISTENT)
20503 + vx_update_persistent(vxi);
20508 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
20511 + *bcaps = vxi->vx_bcaps;
20513 + *ccaps = vxi->vx_ccaps;
20518 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
20520 + struct vcmd_ctx_caps_v1 vc_data;
20523 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
20526 + vc_data.cmask = ~0ULL;
20528 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20533 +static int do_set_caps(struct vx_info *vxi,
20534 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
20536 + vxi->vx_bcaps = vs_mask_flags(vxi->vx_bcaps, bcaps, bmask);
20537 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
20542 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
20544 + struct vcmd_ctx_caps_v1 vc_data;
20546 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20549 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
20552 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
20554 + struct vcmd_bcaps vc_data;
20557 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
20560 + vc_data.bmask = ~0ULL;
20562 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20567 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
20569 + struct vcmd_bcaps vc_data;
20571 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20574 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
20578 +int vc_get_badness(struct vx_info *vxi, void __user *data)
20580 + struct vcmd_badness_v0 vc_data;
20582 + vc_data.bias = vxi->vx_badness_bias;
20584 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20589 +int vc_set_badness(struct vx_info *vxi, void __user *data)
20591 + struct vcmd_badness_v0 vc_data;
20593 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20596 + vxi->vx_badness_bias = vc_data.bias;
20600 +#include <linux/module.h>
20602 +EXPORT_SYMBOL_GPL(free_vx_info);
20604 diff -Nurp linux-2.6.22.15/kernel/vserver/cvirt.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cvirt.c
20605 --- linux-2.6.22.15/kernel/vserver/cvirt.c 1969-12-31 19:00:00.000000000 -0500
20606 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cvirt.c 2007-12-09 06:44:23.000000000 -0500
20609 + * linux/kernel/vserver/cvirt.c
20611 + * Virtual Server: Context Virtualization
20613 + * Copyright (C) 2004-2007 Herbert Pötzl
20615 + * V0.01 broken out from limit.c
20616 + * V0.02 added utsname stuff
20617 + * V0.03 changed vcmds to vxi arg
20621 +#include <linux/types.h>
20622 +#include <linux/vs_cvirt.h>
20623 +#include <linux/vserver/switch.h>
20624 +#include <linux/vserver/cvirt_cmd.h>
20626 +#include <asm/uaccess.h>
20629 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
20631 + struct vx_info *vxi = current->vx_info;
20633 + set_normalized_timespec(uptime,
20634 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
20635 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
20638 + set_normalized_timespec(idle,
20639 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
20640 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
20644 +uint64_t vx_idle_jiffies(void)
20646 + return init_task.utime + init_task.stime;
20651 +static inline uint32_t __update_loadavg(uint32_t load,
20652 + int wsize, int delta, int n)
20654 + unsigned long long calc, prev;
20656 + /* just set it to n */
20657 + if (unlikely(delta >= wsize))
20658 + return (n << FSHIFT);
20660 + calc = delta * n;
20662 + prev = (wsize - delta);
20665 + do_div(calc, wsize);
20670 +void vx_update_load(struct vx_info *vxi)
20672 + uint32_t now, last, delta;
20673 + unsigned int nr_running, nr_uninterruptible;
20674 + unsigned int total;
20675 + unsigned long flags;
20677 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
20680 + last = vxi->cvirt.load_last;
20681 + delta = now - last;
20683 + if (delta < 5*HZ)
20686 + nr_running = atomic_read(&vxi->cvirt.nr_running);
20687 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
20688 + total = nr_running + nr_uninterruptible;
20690 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
20691 + 60*HZ, delta, total);
20692 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
20693 + 5*60*HZ, delta, total);
20694 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
20695 + 15*60*HZ, delta, total);
20697 + vxi->cvirt.load_last = now;
20699 + atomic_inc(&vxi->cvirt.load_updates);
20700 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
20705 + * Commands to do_syslog:
20707 + * 0 -- Close the log. Currently a NOP.
20708 + * 1 -- Open the log. Currently a NOP.
20709 + * 2 -- Read from the log.
20710 + * 3 -- Read all messages remaining in the ring buffer.
20711 + * 4 -- Read and clear all messages remaining in the ring buffer
20712 + * 5 -- Clear ring buffer.
20713 + * 6 -- Disable printk's to console
20714 + * 7 -- Enable printk's to console
20715 + * 8 -- Set level of messages printed to console
20716 + * 9 -- Return number of unread characters in the log buffer
20717 + * 10 -- Return size of the log buffer
20719 +int vx_do_syslog(int type, char __user *buf, int len)
20722 + int do_clear = 0;
20723 + struct vx_info *vxi = current->vx_info;
20724 + struct _vx_syslog *log;
20728 + log = &vxi->cvirt.syslog;
20731 + case 0: /* Close log */
20732 + case 1: /* Open log */
20734 + case 2: /* Read from log */
20735 + error = wait_event_interruptible(log->log_wait,
20736 + (log->log_start - log->log_end));
20739 + spin_lock_irq(&log->logbuf_lock);
20740 + spin_unlock_irq(&log->logbuf_lock);
20742 + case 4: /* Read/clear last kernel messages */
20744 + /* fall through */
20745 + case 3: /* Read last kernel messages */
20748 + case 5: /* Clear ring buffer */
20751 + case 6: /* Disable logging to console */
20752 + case 7: /* Enable logging to console */
20753 + case 8: /* Set level of messages printed to console */
20756 + case 9: /* Number of chars in the log buffer */
20758 + case 10: /* Size of the log buffer */
20768 +/* virtual host info names */
20770 +static char *vx_vhi_name(struct vx_info *vxi, int id)
20772 + struct nsproxy *nsproxy;
20773 + struct uts_namespace *uts;
20776 + if (id == VHIN_CONTEXT)
20777 + return vxi->vx_name;
20779 + nsproxy = vxi->vx_nsproxy;
20783 + uts = nsproxy->uts_ns;
20788 + case VHIN_SYSNAME:
20789 + return uts->name.sysname;
20790 + case VHIN_NODENAME:
20791 + return uts->name.nodename;
20792 + case VHIN_RELEASE:
20793 + return uts->name.release;
20794 + case VHIN_VERSION:
20795 + return uts->name.version;
20796 + case VHIN_MACHINE:
20797 + return uts->name.machine;
20798 + case VHIN_DOMAINNAME:
20799 + return uts->name.domainname;
20806 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
20808 + struct vcmd_vhi_name_v0 vc_data;
20811 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20814 + name = vx_vhi_name(vxi, vc_data.field);
20818 + memcpy(name, vc_data.name, 65);
20822 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
20824 + struct vcmd_vhi_name_v0 vc_data;
20827 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20830 + name = vx_vhi_name(vxi, vc_data.field);
20834 + memcpy(vc_data.name, name, 65);
20835 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20841 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
20843 + struct vcmd_virt_stat_v0 vc_data;
20844 + struct _vx_cvirt *cvirt = &vxi->cvirt;
20845 + struct timespec uptime;
20847 + do_posix_clock_monotonic_gettime(&uptime);
20848 + set_normalized_timespec(&uptime,
20849 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
20850 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
20852 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
20853 + vc_data.uptime = timespec_to_ns(&uptime);
20854 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
20855 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
20856 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
20857 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
20858 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
20859 + vc_data.load[0] = cvirt->load[0];
20860 + vc_data.load[1] = cvirt->load[1];
20861 + vc_data.load[2] = cvirt->load[2];
20863 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20869 +#ifdef CONFIG_VSERVER_VTIME
20871 +/* virtualized time base */
20873 +void vx_gettimeofday(struct timeval *tv)
20875 + do_gettimeofday(tv);
20876 + if (!vx_flags(VXF_VIRT_TIME, 0))
20879 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
20880 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
20882 + if (tv->tv_usec >= USEC_PER_SEC) {
20884 + tv->tv_usec -= USEC_PER_SEC;
20885 + } else if (tv->tv_usec < 0) {
20887 + tv->tv_usec += USEC_PER_SEC;
20891 +int vx_settimeofday(struct timespec *ts)
20893 + struct timeval tv;
20895 + if (!vx_flags(VXF_VIRT_TIME, 0))
20896 + return do_settimeofday(ts);
20898 + do_gettimeofday(&tv);
20899 + current->vx_info->cvirt.bias_tv.tv_sec =
20900 + ts->tv_sec - tv.tv_sec;
20901 + current->vx_info->cvirt.bias_tv.tv_usec =
20902 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
20908 diff -Nurp linux-2.6.22.15/kernel/vserver/cvirt_init.h linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cvirt_init.h
20909 --- linux-2.6.22.15/kernel/vserver/cvirt_init.h 1969-12-31 19:00:00.000000000 -0500
20910 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cvirt_init.h 2007-12-09 06:44:23.000000000 -0500
20914 +extern uint64_t vx_idle_jiffies(void);
20916 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
20918 + uint64_t idle_jiffies = vx_idle_jiffies();
20919 + uint64_t nsuptime;
20921 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
20922 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
20923 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
20924 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
20925 + cvirt->bias_tv.tv_sec = 0;
20926 + cvirt->bias_tv.tv_usec = 0;
20928 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
20929 + atomic_set(&cvirt->nr_threads, 0);
20930 + atomic_set(&cvirt->nr_running, 0);
20931 + atomic_set(&cvirt->nr_uninterruptible, 0);
20932 + atomic_set(&cvirt->nr_onhold, 0);
20934 + spin_lock_init(&cvirt->load_lock);
20935 + cvirt->load_last = jiffies;
20936 + atomic_set(&cvirt->load_updates, 0);
20937 + cvirt->load[0] = 0;
20938 + cvirt->load[1] = 0;
20939 + cvirt->load[2] = 0;
20940 + atomic_set(&cvirt->total_forks, 0);
20942 + spin_lock_init(&cvirt->syslog.logbuf_lock);
20943 + init_waitqueue_head(&cvirt->syslog.log_wait);
20944 + cvirt->syslog.log_start = 0;
20945 + cvirt->syslog.log_end = 0;
20946 + cvirt->syslog.con_start = 0;
20947 + cvirt->syslog.logged_chars = 0;
20951 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
20953 + // cvirt_pc->cpustat = { 0 };
20956 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
20960 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
20961 + "!!! cvirt: %p[nr_threads] = %d on exit.",
20963 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
20964 + "!!! cvirt: %p[nr_running] = %d on exit.",
20966 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
20967 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
20969 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
20970 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
20976 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
20981 diff -Nurp linux-2.6.22.15/kernel/vserver/cvirt_proc.h linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cvirt_proc.h
20982 --- linux-2.6.22.15/kernel/vserver/cvirt_proc.h 1969-12-31 19:00:00.000000000 -0500
20983 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/cvirt_proc.h 2007-12-09 06:44:23.000000000 -0500
20985 +#ifndef _VX_CVIRT_PROC_H
20986 +#define _VX_CVIRT_PROC_H
20988 +#include <linux/nsproxy.h>
20989 +#include <linux/mnt_namespace.h>
20990 +#include <linux/utsname.h>
20991 +#include <linux/ipc.h>
20995 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
20997 + struct mnt_namespace *ns;
20998 + struct uts_namespace *uts;
20999 + struct ipc_namespace *ipc;
21000 + struct vfsmount *mnt;
21001 + char *path, *root;
21007 + length += sprintf(buffer + length,
21008 + "NSProxy:\t%p [%p,%p,%p]\n",
21009 + nsproxy, nsproxy->mnt_ns,
21010 + nsproxy->uts_ns, nsproxy->ipc_ns);
21012 + ns = nsproxy->mnt_ns;
21016 + path = kmalloc(PATH_MAX, GFP_KERNEL);
21021 + root = d_path(mnt->mnt_root, mnt->mnt_parent, path, PATH_MAX - 2);
21022 + length += sprintf(buffer + length,
21023 + "Namespace:\t%p [#%u]\n"
21024 + "RootPath:\t%s\n",
21025 + ns, atomic_read(&ns->count),
21030 + uts = nsproxy->uts_ns;
21034 + length += sprintf(buffer + length,
21035 + "SysName:\t%.*s\n"
21036 + "NodeName:\t%.*s\n"
21037 + "Release:\t%.*s\n"
21038 + "Version:\t%.*s\n"
21039 + "Machine:\t%.*s\n"
21040 + "DomainName:\t%.*s\n",
21041 + __NEW_UTS_LEN, uts->name.sysname,
21042 + __NEW_UTS_LEN, uts->name.nodename,
21043 + __NEW_UTS_LEN, uts->name.release,
21044 + __NEW_UTS_LEN, uts->name.version,
21045 + __NEW_UTS_LEN, uts->name.machine,
21046 + __NEW_UTS_LEN, uts->name.domainname);
21049 + ipc = nsproxy->ipc_ns;
21053 + length += sprintf(buffer + length,
21054 + "SEMS:\t\t%d %d %d %d %d\n"
21055 + "MSG:\t\t%d %d %d\n"
21056 + "SHM:\t\t%lu %lu %d %d\n",
21057 + ipc->sem_ctls[0], ipc->sem_ctls[1],
21058 + ipc->sem_ctls[2], ipc->sem_ctls[3],
21060 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
21061 + (unsigned long)ipc->shm_ctlmax,
21062 + (unsigned long)ipc->shm_ctlall,
21063 + ipc->shm_ctlmni, ipc->shm_tot);
21070 +#include <linux/sched.h>
21072 +#define LOAD_INT(x) ((x) >> FSHIFT)
21073 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
21076 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
21081 + length += sprintf(buffer + length,
21082 + "BiasUptime:\t%lu.%02lu\n",
21083 + (unsigned long)cvirt->bias_uptime.tv_sec,
21084 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
21086 + a = cvirt->load[0] + (FIXED_1 / 200);
21087 + b = cvirt->load[1] + (FIXED_1 / 200);
21088 + c = cvirt->load[2] + (FIXED_1 / 200);
21089 + length += sprintf(buffer + length,
21090 + "nr_threads:\t%d\n"
21091 + "nr_running:\t%d\n"
21092 + "nr_unintr:\t%d\n"
21093 + "nr_onhold:\t%d\n"
21094 + "load_updates:\t%d\n"
21095 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
21096 + "total_forks:\t%d\n",
21097 + atomic_read(&cvirt->nr_threads),
21098 + atomic_read(&cvirt->nr_running),
21099 + atomic_read(&cvirt->nr_uninterruptible),
21100 + atomic_read(&cvirt->nr_onhold),
21101 + atomic_read(&cvirt->load_updates),
21102 + LOAD_INT(a), LOAD_FRAC(a),
21103 + LOAD_INT(b), LOAD_FRAC(b),
21104 + LOAD_INT(c), LOAD_FRAC(c),
21105 + atomic_read(&cvirt->total_forks));
21110 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
21111 + char *buffer, int cpu)
21117 +#endif /* _VX_CVIRT_PROC_H */
21118 diff -Nurp linux-2.6.22.15/kernel/vserver/debug.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/debug.c
21119 --- linux-2.6.22.15/kernel/vserver/debug.c 1969-12-31 19:00:00.000000000 -0500
21120 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/debug.c 2007-12-09 06:44:23.000000000 -0500
21123 + * kernel/vserver/debug.c
21125 + * Copyright (C) 2005-2007 Herbert Pötzl
21127 + * V0.01 vx_info dump support
21131 +#include <linux/module.h>
21133 +#include <linux/vserver/context.h>
21136 +void dump_vx_info(struct vx_info *vxi, int level)
21138 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
21139 + atomic_read(&vxi->vx_usecnt),
21140 + atomic_read(&vxi->vx_tasks),
21143 + __dump_vx_limit(&vxi->limit);
21144 + __dump_vx_sched(&vxi->sched);
21145 + __dump_vx_cvirt(&vxi->cvirt);
21146 + __dump_vx_cacct(&vxi->cacct);
21152 +EXPORT_SYMBOL_GPL(dump_vx_info);
21154 diff -Nurp linux-2.6.22.15/kernel/vserver/device.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/device.c
21155 --- linux-2.6.22.15/kernel/vserver/device.c 1969-12-31 19:00:00.000000000 -0500
21156 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/device.c 2007-12-09 06:44:23.000000000 -0500
21159 + * linux/kernel/vserver/device.c
21161 + * Linux-VServer: Device Support
21163 + * Copyright (C) 2006 Herbert Pötzl
21164 + * Copyright (C) 2007 Daniel Hokka Zakrisson
21166 + * V0.01 device mapping basics
21167 + * V0.02 added defaults
21171 +#include <linux/slab.h>
21172 +#include <linux/rcupdate.h>
21173 +#include <linux/fs.h>
21174 +#include <linux/namei.h>
21175 +#include <linux/hash.h>
21177 +#include <asm/errno.h>
21178 +#include <asm/uaccess.h>
21179 +#include <linux/vserver/base.h>
21180 +#include <linux/vserver/debug.h>
21181 +#include <linux/vserver/context.h>
21182 +#include <linux/vserver/device.h>
21183 +#include <linux/vserver/device_cmd.h>
21186 +#define DMAP_HASH_BITS 4
21189 +struct vs_mapping {
21191 + struct hlist_node hlist;
21192 + struct list_head list;
21194 +#define dm_hlist u.hlist
21195 +#define dm_list u.list
21198 + struct vx_dmap_target target;
21202 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
21204 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
21206 +static struct vx_dmap_target dmap_defaults[2] = {
21207 + { .flags = DATTR_OPEN },
21208 + { .flags = DATTR_OPEN },
21212 +struct kmem_cache *dmap_cachep __read_mostly;
21214 +int __init dmap_cache_init(void)
21216 + dmap_cachep = kmem_cache_create("dmap_cache",
21217 + sizeof(struct vs_mapping), 0,
21218 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
21222 +__initcall(dmap_cache_init);
21225 +static inline unsigned int __hashval(dev_t dev, int bits)
21227 + return hash_long((unsigned long)dev, bits);
21231 +/* __hash_mapping()
21232 + * add the mapping to the hash table
21234 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
21236 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21237 + struct hlist_head *head, *hash = dmap_main_hash;
21238 + int device = vdm->device;
21240 + spin_lock(hash_lock);
21241 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
21242 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
21244 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
21245 + hlist_add_head(&vdm->dm_hlist, head);
21246 + spin_unlock(hash_lock);
21250 +static inline int __mode_to_default(umode_t mode)
21263 +/* __set_default()
21266 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
21267 + struct vx_dmap_target *vdmt)
21269 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21270 + spin_lock(hash_lock);
21273 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
21275 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
21278 + spin_unlock(hash_lock);
21280 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
21281 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
21285 +/* __remove_default()
21286 + * remove a default
21288 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
21290 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21291 + spin_lock(hash_lock);
21294 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
21295 + else /* remove == reset */
21296 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
21298 + spin_unlock(hash_lock);
21303 +/* __find_mapping()
21304 + * find a mapping in the hash table
21306 + * caller must hold hash_lock
21308 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
21309 + struct vs_mapping **local, struct vs_mapping **global)
21311 + struct hlist_head *hash = dmap_main_hash;
21312 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
21313 + struct hlist_node *pos;
21314 + struct vs_mapping *vdm;
21320 + hlist_for_each(pos, head) {
21321 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
21323 + if ((vdm->device == device) &&
21324 + !((vdm->target.flags ^ mode) & S_IFMT)) {
21325 + if (vdm->xid == xid) {
21328 + } else if (global && vdm->xid == 0)
21333 + if (global && *global)
21340 +/* __lookup_mapping()
21341 + * find a mapping and store the result in target and flags
21343 +static inline int __lookup_mapping(struct vx_info *vxi,
21344 + dev_t device, dev_t *target, int *flags, umode_t mode)
21346 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21347 + struct vs_mapping *vdm, *global;
21348 + struct vx_dmap_target *vdmt;
21350 + xid_t xid = vxi->vx_id;
21353 + spin_lock(hash_lock);
21354 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
21356 + vdmt = &vdm->target;
21360 + index = __mode_to_default(mode);
21361 + if (vxi && vxi->dmap.targets[index].flags) {
21363 + vdmt = &vxi->dmap.targets[index];
21364 + } else if (global) {
21366 + vdmt = &global->target;
21370 + vdmt = &dmap_defaults[index];
21374 + if (target && (vdmt->flags & DATTR_REMAP))
21375 + *target = vdmt->target;
21377 + *target = device;
21379 + *flags = vdmt->flags;
21381 + spin_unlock(hash_lock);
21387 +/* __remove_mapping()
21388 + * remove a mapping from the hash table
21390 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
21393 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21394 + struct vs_mapping *vdm = NULL;
21397 + spin_lock(hash_lock);
21399 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
21401 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
21402 + vxi, vxi ? vxi->vx_id : 0, device, mode);
21405 + hlist_del(&vdm->dm_hlist);
21408 + spin_unlock(hash_lock);
21410 + kmem_cache_free(dmap_cachep, vdm);
21416 +int vs_map_device(struct vx_info *vxi,
21417 + dev_t device, dev_t *target, umode_t mode)
21419 + int ret, flags = DATTR_MASK;
21423 + *target = device;
21426 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
21427 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
21428 + device, target ? *target : 0, flags, mode, ret);
21430 + return (flags & DATTR_MASK);
21435 +static int do_set_mapping(struct vx_info *vxi,
21436 + dev_t device, dev_t target, int flags, umode_t mode)
21439 + struct vs_mapping *new;
21441 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
21445 + INIT_HLIST_NODE(&new->dm_hlist);
21446 + new->device = device;
21447 + new->target.target = target;
21448 + new->target.flags = flags | mode;
21449 + new->xid = (vxi ? vxi->vx_id : 0);
21451 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
21452 + __hash_mapping(vxi, new);
21454 + struct vx_dmap_target new = {
21455 + .target = target,
21456 + .flags = flags | mode,
21458 + __set_default(vxi, mode, &new);
21464 +static int do_unset_mapping(struct vx_info *vxi,
21465 + dev_t device, dev_t target, int flags, umode_t mode)
21467 + int ret = -EINVAL;
21470 + ret = __remove_mapping(vxi, device, mode);
21474 + ret = __remove_default(vxi, mode);
21484 +static inline int __user_device(const char __user *name, dev_t *dev,
21487 + struct nameidata nd;
21494 + ret = user_path_walk_link(name, &nd);
21497 + if (nd.dentry->d_inode) {
21498 + *dev = nd.dentry->d_inode->i_rdev;
21499 + *mode = nd.dentry->d_inode->i_mode;
21501 + path_release(&nd);
21505 +static inline int __mapping_mode(dev_t device, dev_t target,
21506 + umode_t device_mode, umode_t target_mode, umode_t *mode)
21509 + *mode = device_mode & S_IFMT;
21511 + *mode = target_mode & S_IFMT;
21515 + /* if both given, device and target mode have to match */
21516 + if (device && target &&
21517 + ((device_mode ^ target_mode) & S_IFMT))
21523 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
21524 + const char __user *target_path, int flags, int set)
21526 + dev_t device = ~0, target = ~0;
21527 + umode_t device_mode = 0, target_mode = 0, mode;
21530 + ret = __user_device(device_path, &device, &device_mode);
21533 + ret = __user_device(target_path, &target, &target_mode);
21537 + ret = __mapping_mode(device, target,
21538 + device_mode, target_mode, &mode);
21543 + return do_set_mapping(vxi, device, target,
21546 + return do_unset_mapping(vxi, device, target,
21551 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
21553 + struct vcmd_set_mapping_v0 vc_data;
21555 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21558 + return do_mapping(vxi, vc_data.device, vc_data.target,
21559 + vc_data.flags, 1);
21562 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
21564 + struct vcmd_set_mapping_v0 vc_data;
21566 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21569 + return do_mapping(vxi, vc_data.device, vc_data.target,
21570 + vc_data.flags, 0);
21574 +#ifdef CONFIG_COMPAT
21576 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
21578 + struct vcmd_set_mapping_v0_x32 vc_data;
21580 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21583 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
21584 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
21587 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
21589 + struct vcmd_set_mapping_v0_x32 vc_data;
21591 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21594 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
21595 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
21598 +#endif /* CONFIG_COMPAT */
21601 diff -Nurp linux-2.6.22.15/kernel/vserver/dlimit.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/dlimit.c
21602 --- linux-2.6.22.15/kernel/vserver/dlimit.c 1969-12-31 19:00:00.000000000 -0500
21603 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/dlimit.c 2007-12-09 06:44:23.000000000 -0500
21606 + * linux/kernel/vserver/dlimit.c
21608 + * Virtual Server: Context Disk Limits
21610 + * Copyright (C) 2004-2007 Herbert Pötzl
21612 + * V0.01 initial version
21613 + * V0.02 compat32 splitup
21617 +#include <linux/statfs.h>
21618 +#include <linux/vs_tag.h>
21619 +#include <linux/vs_dlimit.h>
21620 +#include <linux/vserver/dlimit_cmd.h>
21622 +#include <asm/uaccess.h>
21624 +/* __alloc_dl_info()
21626 + * allocate an initialized dl_info struct
21627 + * doesn't make it visible (hash) */
21629 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
21631 + struct dl_info *new = NULL;
21633 + vxdprintk(VXD_CBIT(dlim, 5),
21634 + "alloc_dl_info(%p,%d)*", sb, tag);
21636 + /* would this benefit from a slab cache? */
21637 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
21641 + memset(new, 0, sizeof(struct dl_info));
21642 + new->dl_tag = tag;
21644 + INIT_RCU_HEAD(&new->dl_rcu);
21645 + INIT_HLIST_NODE(&new->dl_hlist);
21646 + spin_lock_init(&new->dl_lock);
21647 + atomic_set(&new->dl_refcnt, 0);
21648 + atomic_set(&new->dl_usecnt, 0);
21650 + /* rest of init goes here */
21652 + vxdprintk(VXD_CBIT(dlim, 4),
21653 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
21657 +/* __dealloc_dl_info()
21659 + * final disposal of dl_info */
21661 +static void __dealloc_dl_info(struct dl_info *dli)
21663 + vxdprintk(VXD_CBIT(dlim, 4),
21664 + "dealloc_dl_info(%p)", dli);
21666 + dli->dl_hlist.next = LIST_POISON1;
21667 + dli->dl_tag = -1;
21670 + BUG_ON(atomic_read(&dli->dl_usecnt));
21671 + BUG_ON(atomic_read(&dli->dl_refcnt));
21677 +/* hash table for dl_info hash */
21679 +#define DL_HASH_SIZE 13
21681 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
21683 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
21686 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
21688 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
21693 +/* __hash_dl_info()
21695 + * add the dli to the global hash table
21696 + * requires the hash_lock to be held */
21698 +static inline void __hash_dl_info(struct dl_info *dli)
21700 + struct hlist_head *head;
21702 + vxdprintk(VXD_CBIT(dlim, 6),
21703 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
21704 + get_dl_info(dli);
21705 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
21706 + hlist_add_head_rcu(&dli->dl_hlist, head);
21709 +/* __unhash_dl_info()
21711 + * remove the dli from the global hash table
21712 + * requires the hash_lock to be held */
21714 +static inline void __unhash_dl_info(struct dl_info *dli)
21716 + vxdprintk(VXD_CBIT(dlim, 6),
21717 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
21718 + hlist_del_rcu(&dli->dl_hlist);
21719 + put_dl_info(dli);
21723 +/* __lookup_dl_info()
21725 + * requires the rcu_read_lock()
21726 + * doesn't increment the dl_refcnt */
21728 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
21730 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
21731 + struct hlist_node *pos;
21732 + struct dl_info *dli;
21734 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
21736 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
21744 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
21746 + struct dl_info *dli;
21749 + dli = get_dl_info(__lookup_dl_info(sb, tag));
21750 + vxdprintk(VXD_CBIT(dlim, 7),
21751 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
21752 + rcu_read_unlock();
21756 +void rcu_free_dl_info(struct rcu_head *head)
21758 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
21759 + int usecnt, refcnt;
21761 + BUG_ON(!dli || !head);
21763 + usecnt = atomic_read(&dli->dl_usecnt);
21764 + BUG_ON(usecnt < 0);
21766 + refcnt = atomic_read(&dli->dl_refcnt);
21767 + BUG_ON(refcnt < 0);
21769 + vxdprintk(VXD_CBIT(dlim, 3),
21770 + "rcu_free_dl_info(%p)", dli);
21772 + __dealloc_dl_info(dli);
21774 + printk("!!! rcu didn't free\n");
21780 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
21781 + uint32_t flags, int add)
21783 + struct nameidata nd;
21786 + ret = user_path_walk_link(name, &nd);
21788 + struct super_block *sb;
21789 + struct dl_info *dli;
21792 + if (!nd.dentry->d_inode)
21793 + goto out_release;
21794 + if (!(sb = nd.dentry->d_inode->i_sb))
21795 + goto out_release;
21798 + dli = __alloc_dl_info(sb, id);
21799 + spin_lock(&dl_info_hash_lock);
21802 + if (__lookup_dl_info(sb, id))
21804 + __hash_dl_info(dli);
21807 + spin_lock(&dl_info_hash_lock);
21808 + dli = __lookup_dl_info(sb, id);
21813 + __unhash_dl_info(dli);
21817 + spin_unlock(&dl_info_hash_lock);
21819 + __dealloc_dl_info(dli);
21821 + path_release(&nd);
21826 +int vc_add_dlimit(uint32_t id, void __user *data)
21828 + struct vcmd_ctx_dlimit_base_v0 vc_data;
21830 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21833 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
21836 +int vc_rem_dlimit(uint32_t id, void __user *data)
21838 + struct vcmd_ctx_dlimit_base_v0 vc_data;
21840 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21843 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
21846 +#ifdef CONFIG_COMPAT
21848 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
21850 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
21852 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21855 + return do_addrem_dlimit(id,
21856 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
21859 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
21861 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
21863 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21866 + return do_addrem_dlimit(id,
21867 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
21870 +#endif /* CONFIG_COMPAT */
21874 +int do_set_dlimit(uint32_t id, const char __user *name,
21875 + uint32_t space_used, uint32_t space_total,
21876 + uint32_t inodes_used, uint32_t inodes_total,
21877 + uint32_t reserved, uint32_t flags)
21879 + struct nameidata nd;
21882 + ret = user_path_walk_link(name, &nd);
21884 + struct super_block *sb;
21885 + struct dl_info *dli;
21888 + if (!nd.dentry->d_inode)
21889 + goto out_release;
21890 + if (!(sb = nd.dentry->d_inode->i_sb))
21891 + goto out_release;
21892 + if ((reserved != CDLIM_KEEP &&
21893 + reserved > 100) ||
21894 + (inodes_used != CDLIM_KEEP &&
21895 + inodes_used > inodes_total) ||
21896 + (space_used != CDLIM_KEEP &&
21897 + space_used > space_total))
21898 + goto out_release;
21901 + dli = locate_dl_info(sb, id);
21903 + goto out_release;
21905 + spin_lock(&dli->dl_lock);
21907 + if (inodes_used != CDLIM_KEEP)
21908 + dli->dl_inodes_used = inodes_used;
21909 + if (inodes_total != CDLIM_KEEP)
21910 + dli->dl_inodes_total = inodes_total;
21911 + if (space_used != CDLIM_KEEP) {
21912 + dli->dl_space_used = space_used;
21913 + dli->dl_space_used <<= 10;
21915 + if (space_total == CDLIM_INFINITY)
21916 + dli->dl_space_total = DLIM_INFINITY;
21917 + else if (space_total != CDLIM_KEEP) {
21918 + dli->dl_space_total = space_total;
21919 + dli->dl_space_total <<= 10;
21921 + if (reserved != CDLIM_KEEP)
21922 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
21924 + spin_unlock(&dli->dl_lock);
21926 + put_dl_info(dli);
21930 + path_release(&nd);
21935 +int vc_set_dlimit(uint32_t id, void __user *data)
21937 + struct vcmd_ctx_dlimit_v0 vc_data;
21939 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21942 + return do_set_dlimit(id, vc_data.name,
21943 + vc_data.space_used, vc_data.space_total,
21944 + vc_data.inodes_used, vc_data.inodes_total,
21945 + vc_data.reserved, vc_data.flags);
21948 +#ifdef CONFIG_COMPAT
21950 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
21952 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
21954 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21957 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
21958 + vc_data.space_used, vc_data.space_total,
21959 + vc_data.inodes_used, vc_data.inodes_total,
21960 + vc_data.reserved, vc_data.flags);
21963 +#endif /* CONFIG_COMPAT */
21967 +int do_get_dlimit(uint32_t id, const char __user *name,
21968 + uint32_t *space_used, uint32_t *space_total,
21969 + uint32_t *inodes_used, uint32_t *inodes_total,
21970 + uint32_t *reserved, uint32_t *flags)
21972 + struct nameidata nd;
21975 + ret = user_path_walk_link(name, &nd);
21977 + struct super_block *sb;
21978 + struct dl_info *dli;
21981 + if (!nd.dentry->d_inode)
21982 + goto out_release;
21983 + if (!(sb = nd.dentry->d_inode->i_sb))
21984 + goto out_release;
21987 + dli = locate_dl_info(sb, id);
21989 + goto out_release;
21991 + spin_lock(&dli->dl_lock);
21992 + *inodes_used = dli->dl_inodes_used;
21993 + *inodes_total = dli->dl_inodes_total;
21994 + *space_used = dli->dl_space_used >> 10;
21995 + if (dli->dl_space_total == DLIM_INFINITY)
21996 + *space_total = CDLIM_INFINITY;
21998 + *space_total = dli->dl_space_total >> 10;
22000 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
22001 + spin_unlock(&dli->dl_lock);
22003 + put_dl_info(dli);
22008 + path_release(&nd);
22014 +int vc_get_dlimit(uint32_t id, void __user *data)
22016 + struct vcmd_ctx_dlimit_v0 vc_data;
22019 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22022 + ret = do_get_dlimit(id, vc_data.name,
22023 + &vc_data.space_used, &vc_data.space_total,
22024 + &vc_data.inodes_used, &vc_data.inodes_total,
22025 + &vc_data.reserved, &vc_data.flags);
22029 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22034 +#ifdef CONFIG_COMPAT
22036 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
22038 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
22041 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22044 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
22045 + &vc_data.space_used, &vc_data.space_total,
22046 + &vc_data.inodes_used, &vc_data.inodes_total,
22047 + &vc_data.reserved, &vc_data.flags);
22051 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22056 +#endif /* CONFIG_COMPAT */
22059 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
22061 + struct dl_info *dli;
22062 + __u64 blimit, bfree, bavail;
22065 + dli = locate_dl_info(sb, dx_current_tag());
22069 + spin_lock(&dli->dl_lock);
22070 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
22073 + /* reduce max inodes available to limit */
22074 + if (buf->f_files > dli->dl_inodes_total)
22075 + buf->f_files = dli->dl_inodes_total;
22077 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
22078 + /* reduce free inodes to min */
22079 + if (ifree < buf->f_ffree)
22080 + buf->f_ffree = ifree;
22083 + if (dli->dl_space_total == DLIM_INFINITY)
22086 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
22088 + if (dli->dl_space_total < dli->dl_space_used)
22091 + bfree = (dli->dl_space_total - dli->dl_space_used)
22092 + >> sb->s_blocksize_bits;
22094 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
22095 + if (bavail < dli->dl_space_used)
22098 + bavail = (bavail - dli->dl_space_used)
22099 + >> sb->s_blocksize_bits;
22101 + /* reduce max space available to limit */
22102 + if (buf->f_blocks > blimit)
22103 + buf->f_blocks = blimit;
22105 + /* reduce free space to min */
22106 + if (bfree < buf->f_bfree)
22107 + buf->f_bfree = bfree;
22109 + /* reduce avail space to min */
22110 + if (bavail < buf->f_bavail)
22111 + buf->f_bavail = bavail;
22114 + spin_unlock(&dli->dl_lock);
22115 + put_dl_info(dli);
22120 +#include <linux/module.h>
22122 +EXPORT_SYMBOL_GPL(locate_dl_info);
22123 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
22125 diff -Nurp linux-2.6.22.15/kernel/vserver/helper.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/helper.c
22126 --- linux-2.6.22.15/kernel/vserver/helper.c 1969-12-31 19:00:00.000000000 -0500
22127 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/helper.c 2007-12-09 06:44:23.000000000 -0500
22130 + * linux/kernel/vserver/helper.c
22132 + * Virtual Context Support
22134 + * Copyright (C) 2004-2007 Herbert Pötzl
22136 + * V0.01 basic helper
22140 +#include <linux/kmod.h>
22141 +#include <linux/reboot.h>
22142 +#include <linux/vs_context.h>
22143 +#include <linux/vs_network.h>
22144 +#include <linux/vserver/signal.h>
22147 +char vshelper_path[255] = "/sbin/vshelper";
22150 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
22154 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
22155 + printk( KERN_WARNING
22156 + "%s: (%s %s) returned %s with %d\n",
22157 + name, argv[1], argv[2],
22158 + sync ? "sync" : "async", ret);
22160 + vxdprintk(VXD_CBIT(switch, 4),
22161 + "%s: (%s %s) returned %s with %d",
22162 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
22167 + * vshelper path is set via /proc/sys
22168 + * invoked by vserver sys_reboot(), with
22169 + * the following arguments
22171 + * argv [0] = vshelper_path;
22172 + * argv [1] = action: "restart", "halt", "poweroff", ...
22173 + * argv [2] = context identifier
22175 + * envp [*] = type-specific parameters
22178 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
22180 + char id_buf[8], cmd_buf[16];
22181 + char uid_buf[16], pid_buf[16];
22184 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22185 + char *envp[] = {"HOME=/", "TERM=linux",
22186 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
22187 + uid_buf, pid_buf, cmd_buf, 0};
22189 + if (vx_info_state(vxi, VXS_HELPER))
22191 + vxi->vx_state |= VXS_HELPER;
22193 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
22195 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22196 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
22197 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
22200 + case LINUX_REBOOT_CMD_RESTART:
22201 + argv[1] = "restart";
22204 + case LINUX_REBOOT_CMD_HALT:
22205 + argv[1] = "halt";
22208 + case LINUX_REBOOT_CMD_POWER_OFF:
22209 + argv[1] = "poweroff";
22212 + case LINUX_REBOOT_CMD_SW_SUSPEND:
22213 + argv[1] = "swsusp";
22217 + vxi->vx_state &= ~VXS_HELPER;
22221 + ret = do_vshelper(vshelper_path, argv, envp, 0);
22222 + vxi->vx_state &= ~VXS_HELPER;
22223 + __wakeup_vx_info(vxi);
22224 + return (ret) ? -EPERM : 0;
22228 +long vs_reboot(unsigned int cmd, void __user *arg)
22230 + struct vx_info *vxi = current->vx_info;
22233 + vxdprintk(VXD_CBIT(misc, 5),
22234 + "vs_reboot(%p[#%d],%d)",
22235 + vxi, vxi ? vxi->vx_id : 0, cmd);
22237 + ret = vs_reboot_helper(vxi, cmd, arg);
22241 + vxi->reboot_cmd = cmd;
22242 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
22244 + case LINUX_REBOOT_CMD_RESTART:
22245 + case LINUX_REBOOT_CMD_HALT:
22246 + case LINUX_REBOOT_CMD_POWER_OFF:
22247 + vx_info_kill(vxi, 0, SIGKILL);
22248 + vx_info_kill(vxi, 1, SIGKILL);
22258 + * argv [0] = vshelper_path;
22259 + * argv [1] = action: "startup", "shutdown"
22260 + * argv [2] = context identifier
22262 + * envp [*] = type-specific parameters
22265 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
22267 + char id_buf[8], cmd_buf[16];
22268 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22269 + char *envp[] = {"HOME=/", "TERM=linux",
22270 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
22272 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
22275 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
22276 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22279 + case VSC_STARTUP:
22280 + argv[1] = "startup";
22282 + case VSC_SHUTDOWN:
22283 + argv[1] = "shutdown";
22289 + return do_vshelper(vshelper_path, argv, envp, 1);
22294 + * argv [0] = vshelper_path;
22295 + * argv [1] = action: "netup", "netdown"
22296 + * argv [2] = context identifier
22298 + * envp [*] = type-specific parameters
22301 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
22303 + char id_buf[8], cmd_buf[16];
22304 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22305 + char *envp[] = {"HOME=/", "TERM=linux",
22306 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
22308 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
22311 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
22312 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22316 + argv[1] = "netup";
22318 + case VSC_NETDOWN:
22319 + argv[1] = "netdown";
22325 + return do_vshelper(vshelper_path, argv, envp, 1);
22328 diff -Nurp linux-2.6.22.15/kernel/vserver/history.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/history.c
22329 --- linux-2.6.22.15/kernel/vserver/history.c 1969-12-31 19:00:00.000000000 -0500
22330 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/history.c 2007-12-09 06:44:23.000000000 -0500
22333 + * kernel/vserver/history.c
22335 + * Virtual Context History Backtrace
22337 + * Copyright (C) 2004-2007 Herbert Pötzl
22339 + * V0.01 basic structure
22340 + * V0.02 hash/unhash and trace
22341 + * V0.03 preemption fixes
22345 +#include <linux/module.h>
22346 +#include <asm/uaccess.h>
22348 +#include <linux/vserver/context.h>
22349 +#include <linux/vserver/debug.h>
22350 +#include <linux/vserver/debug_cmd.h>
22351 +#include <linux/vserver/history.h>
22354 +#ifdef CONFIG_VSERVER_HISTORY
22355 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
22357 +#define VXH_SIZE 64
22360 +struct _vx_history {
22361 + unsigned int counter;
22363 + struct _vx_hist_entry entry[VXH_SIZE + 1];
22367 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
22369 +unsigned volatile int vxh_active = 1;
22371 +static atomic_t sequence = ATOMIC_INIT(0);
22376 + * requires disabled preemption */
22378 +struct _vx_hist_entry *vxh_advance(void *loc)
22380 + unsigned int cpu = smp_processor_id();
22381 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
22382 + struct _vx_hist_entry *entry;
22383 + unsigned int index;
22385 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
22386 + entry = &hist->entry[index];
22388 + entry->seq = atomic_inc_return(&sequence);
22389 + entry->loc = loc;
22393 +EXPORT_SYMBOL_GPL(vxh_advance);
22396 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
22398 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
22401 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
22403 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
22404 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
22405 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
22406 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
22408 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
22410 + switch (e->type) {
22411 + case VXH_THROW_OOPS:
22412 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
22415 + case VXH_GET_VX_INFO:
22416 + case VXH_PUT_VX_INFO:
22417 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
22419 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
22420 + VXH_VXI_ARGS(e));
22423 + case VXH_INIT_VX_INFO:
22424 + case VXH_SET_VX_INFO:
22425 + case VXH_CLR_VX_INFO:
22426 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
22428 + (e->type == VXH_INIT_VX_INFO) ? "init" :
22429 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
22430 + VXH_VXI_ARGS(e), e->sc.data);
22433 + case VXH_CLAIM_VX_INFO:
22434 + case VXH_RELEASE_VX_INFO:
22435 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
22437 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
22438 + VXH_VXI_ARGS(e), e->sc.data);
22441 + case VXH_ALLOC_VX_INFO:
22442 + case VXH_DEALLOC_VX_INFO:
22443 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
22445 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
22446 + VXH_VXI_ARGS(e));
22449 + case VXH_HASH_VX_INFO:
22450 + case VXH_UNHASH_VX_INFO:
22451 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
22453 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
22454 + VXH_VXI_ARGS(e));
22457 + case VXH_LOC_VX_INFO:
22458 + case VXH_LOOKUP_VX_INFO:
22459 + case VXH_CREATE_VX_INFO:
22460 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
22462 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
22463 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
22464 + e->ll.arg, VXH_VXI_ARGS(e));
22469 +static void __vxh_dump_history(void)
22471 + unsigned int i, cpu;
22473 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
22474 + atomic_read(&sequence), NR_CPUS);
22476 + for (i = 0; i < VXH_SIZE; i++) {
22477 + for_each_online_cpu(cpu) {
22478 + struct _vx_history *hist =
22479 + &per_cpu(vx_history_buffer, cpu);
22480 + unsigned int index = (hist->counter - i) % VXH_SIZE;
22481 + struct _vx_hist_entry *entry = &hist->entry[index];
22483 + vxh_dump_entry(entry, cpu);
22488 +void vxh_dump_history(void)
22492 + local_irq_enable();
22494 + local_irq_disable();
22496 + __vxh_dump_history();
22500 +/* vserver syscall commands below here */
22503 +int vc_dump_history(uint32_t id)
22506 + __vxh_dump_history();
22513 +int do_read_history(struct __user _vx_hist_entry *data,
22514 + int cpu, uint32_t *index, uint32_t *count)
22516 + int pos, ret = 0;
22517 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
22518 + int end = hist->counter;
22519 + int start = end - VXH_SIZE + 2;
22520 + int idx = *index;
22522 + /* special case: get current pos */
22528 + /* have we lost some data? */
22532 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22533 + struct _vx_hist_entry *entry =
22534 + &hist->entry[idx % VXH_SIZE];
22536 + /* send entry to userspace */
22537 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22541 + /* save new index and count */
22544 + return ret ? ret : (*index < end);
22547 +int vc_read_history(uint32_t id, void __user *data)
22549 + struct vcmd_read_history_v0 vc_data;
22552 + if (id >= NR_CPUS)
22555 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22558 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
22559 + id, &vc_data.index, &vc_data.count);
22561 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22566 +#ifdef CONFIG_COMPAT
22568 +int vc_read_history_x32(uint32_t id, void __user *data)
22570 + struct vcmd_read_history_v0_x32 vc_data;
22573 + if (id >= NR_CPUS)
22576 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22579 + ret = do_read_history((struct __user _vx_hist_entry *)
22580 + compat_ptr(vc_data.data_ptr),
22581 + id, &vc_data.index, &vc_data.count);
22583 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22588 +#endif /* CONFIG_COMPAT */
22590 diff -Nurp linux-2.6.22.15/kernel/vserver/inet.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/inet.c
22591 --- linux-2.6.22.15/kernel/vserver/inet.c 1969-12-31 19:00:00.000000000 -0500
22592 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/inet.c 2007-12-09 06:44:23.000000000 -0500
22595 +#include <linux/in.h>
22596 +#include <linux/inetdevice.h>
22597 +#include <linux/vs_inet6.h>
22598 +#include <linux/vserver/debug.h>
22599 +#include <net/route.h>
22600 +#include <net/addrconf.h>
22603 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
22607 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
22610 + struct nx_addr_v4 *ptr;
22612 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
22613 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
22620 + vxdprintk(VXD_CBIT(net, 2),
22621 + "nx_v4_addr_conflict(%p,%p): %d",
22622 + nxi1, nxi2, ret);
22628 +#ifdef CONFIG_IPV6
22630 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
22634 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
22637 + struct nx_addr_v6 *ptr;
22639 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
22640 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
22647 + vxdprintk(VXD_CBIT(net, 2),
22648 + "nx_v6_addr_conflict(%p,%p): %d",
22649 + nxi1, nxi2, ret);
22656 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22658 + struct in_device *in_dev;
22659 + struct in_ifaddr **ifap;
22660 + struct in_ifaddr *ifa;
22665 + in_dev = in_dev_get(dev);
22669 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
22670 + ifap = &ifa->ifa_next) {
22671 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
22676 + in_dev_put(in_dev);
22682 +#ifdef CONFIG_IPV6
22684 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22686 + struct inet6_dev *in_dev;
22687 + struct inet6_ifaddr **ifap;
22688 + struct inet6_ifaddr *ifa;
22693 + in_dev = in6_dev_get(dev);
22697 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
22698 + ifap = &ifa->if_next) {
22699 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
22704 + in6_dev_put(in_dev);
22711 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22717 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
22719 +#ifdef CONFIG_IPV6
22721 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
22726 + vxdprintk(VXD_CBIT(net, 3),
22727 + "dev_in_nx_info(%p,%p[#%d]) = %d",
22728 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
22732 +int ip_v4_find_src(struct nx_info *nxi, struct rtable **rp, struct flowi *fl)
22737 + /* FIXME: handle lback only case */
22738 + if (!NX_IPV4(nxi))
22741 + vxdprintk(VXD_CBIT(net, 4),
22742 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
22743 + nxi, nxi ? nxi->nx_id : 0,
22744 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
22746 + /* single IP is unconditional */
22747 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
22748 + (fl->fl4_src == INADDR_ANY))
22749 + fl->fl4_src = nxi->v4.ip[0].s_addr;
22751 + if (fl->fl4_src == INADDR_ANY) {
22752 + struct nx_addr_v4 *ptr;
22756 + err = __ip_route_output_key(rp, fl);
22758 + found = (*rp)->rt_src;
22760 + vxdprintk(VXD_CBIT(net, 4),
22761 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
22762 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
22763 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
22767 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
22768 + __be32 primary = ptr->ip[0].s_addr;
22769 + __be32 mask = ptr->mask.s_addr;
22770 + __be32 net = primary & mask;
22772 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
22773 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
22774 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
22775 + NIPQUAD(mask), NIPQUAD(net));
22776 + if ((found & mask) != net)
22779 + fl->fl4_src = primary;
22780 + err = __ip_route_output_key(rp, fl);
22781 + vxdprintk(VXD_CBIT(net, 4),
22782 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
22783 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
22785 + found = (*rp)->rt_src;
22787 + if (found == primary)
22791 + /* still no source ip? */
22792 + found = LOOPBACK(fl->fl4_dst)
22793 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
22795 + /* assign src ip to flow */
22796 + fl->fl4_src = found;
22799 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
22803 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
22804 + if (LOOPBACK(fl->fl4_dst))
22805 + fl->fl4_dst = nxi->v4_lback.s_addr;
22806 + if (LOOPBACK(fl->fl4_src))
22807 + fl->fl4_src = nxi->v4_lback.s_addr;
22808 + } else if (LOOPBACK(fl->fl4_dst))
22814 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
22816 diff -Nurp linux-2.6.22.15/kernel/vserver/init.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/init.c
22817 --- linux-2.6.22.15/kernel/vserver/init.c 1969-12-31 19:00:00.000000000 -0500
22818 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/init.c 2007-12-09 06:44:23.000000000 -0500
22821 + * linux/kernel/init.c
22823 + * Virtual Server Init
22825 + * Copyright (C) 2004-2007 Herbert Pötzl
22827 + * V0.01 basic structure
22831 +#include <linux/init.h>
22833 +int vserver_register_sysctl(void);
22834 +void vserver_unregister_sysctl(void);
22837 +static int __init init_vserver(void)
22841 +#ifdef CONFIG_VSERVER_DEBUG
22842 + vserver_register_sysctl();
22848 +static void __exit exit_vserver(void)
22851 +#ifdef CONFIG_VSERVER_DEBUG
22852 + vserver_unregister_sysctl();
22857 +/* FIXME: GFP_ZONETYPES gone
22858 +long vx_slab[GFP_ZONETYPES]; */
22862 +module_init(init_vserver);
22863 +module_exit(exit_vserver);
22865 diff -Nurp linux-2.6.22.15/kernel/vserver/inode.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/inode.c
22866 --- linux-2.6.22.15/kernel/vserver/inode.c 1969-12-31 19:00:00.000000000 -0500
22867 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/inode.c 2007-12-09 06:44:23.000000000 -0500
22870 + * linux/kernel/vserver/inode.c
22872 + * Virtual Server: File System Support
22874 + * Copyright (C) 2004-2007 Herbert Pötzl
22876 + * V0.01 separated from vcontext V0.05
22877 + * V0.02 moved to tag (instead of xid)
22881 +#include <linux/tty.h>
22882 +#include <linux/proc_fs.h>
22883 +#include <linux/devpts_fs.h>
22884 +#include <linux/fs.h>
22885 +#include <linux/file.h>
22886 +#include <linux/mount.h>
22887 +#include <linux/parser.h>
22888 +#include <linux/vserver/inode.h>
22889 +#include <linux/vserver/inode_cmd.h>
22890 +#include <linux/vs_base.h>
22891 +#include <linux/vs_tag.h>
22893 +#include <asm/uaccess.h>
22896 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
22898 + struct proc_dir_entry *entry;
22900 + if (!in || !in->i_sb)
22903 + *flags = IATTR_TAG
22904 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
22905 + | (IS_IUNLINK(in) ? IATTR_IUNLINK : 0)
22906 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
22907 + *mask = IATTR_IUNLINK | IATTR_IMMUTABLE;
22909 + if (S_ISDIR(in->i_mode))
22910 + *mask |= IATTR_BARRIER;
22912 + if (IS_TAGGED(in)) {
22913 + *tag = in->i_tag;
22914 + *mask |= IATTR_TAG;
22917 + switch (in->i_sb->s_magic) {
22918 + case PROC_SUPER_MAGIC:
22919 + entry = PROC_I(in)->pde;
22921 + /* check for specific inodes? */
22923 + *mask |= IATTR_FLAGS;
22925 + *flags |= (entry->vx_flags & IATTR_FLAGS);
22927 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
22930 + case DEVPTS_SUPER_MAGIC:
22931 + *tag = in->i_tag;
22932 + *mask |= IATTR_TAG;
22941 +int vc_get_iattr(void __user *data)
22943 + struct nameidata nd;
22944 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
22947 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22950 + ret = user_path_walk_link(vc_data.name, &nd);
22952 + ret = __vc_get_iattr(nd.dentry->d_inode,
22953 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
22954 + path_release(&nd);
22959 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22964 +#ifdef CONFIG_COMPAT
22966 +int vc_get_iattr_x32(void __user *data)
22968 + struct nameidata nd;
22969 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
22972 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22975 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
22977 + ret = __vc_get_iattr(nd.dentry->d_inode,
22978 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
22979 + path_release(&nd);
22984 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22989 +#endif /* CONFIG_COMPAT */
22992 +int vc_fget_iattr(uint32_t fd, void __user *data)
22994 + struct file *filp;
22995 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
22998 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23002 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
23005 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
23006 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23010 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23016 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
23018 + struct inode *in = de->d_inode;
23019 + int error = 0, is_proc = 0, has_tag = 0;
23020 + struct iattr attr = { 0 };
23022 + if (!in || !in->i_sb)
23025 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
23026 + if ((*mask & IATTR_FLAGS) && !is_proc)
23029 + has_tag = IS_TAGGED(in) ||
23030 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
23031 + if ((*mask & IATTR_TAG) && !has_tag)
23034 + mutex_lock(&in->i_mutex);
23035 + if (*mask & IATTR_TAG) {
23036 + attr.ia_tag = *tag;
23037 + attr.ia_valid |= ATTR_TAG;
23040 + if (*mask & IATTR_FLAGS) {
23041 + struct proc_dir_entry *entry = PROC_I(in)->pde;
23042 + unsigned int iflags = PROC_I(in)->vx_flags;
23044 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
23045 + | (*flags & IATTR_FLAGS);
23046 + PROC_I(in)->vx_flags = iflags;
23048 + entry->vx_flags = iflags;
23051 + if (*mask & (IATTR_BARRIER | IATTR_IUNLINK | IATTR_IMMUTABLE)) {
23052 + if (*mask & IATTR_IMMUTABLE) {
23053 + if (*flags & IATTR_IMMUTABLE)
23054 + in->i_flags |= S_IMMUTABLE;
23056 + in->i_flags &= ~S_IMMUTABLE;
23058 + if (*mask & IATTR_IUNLINK) {
23059 + if (*flags & IATTR_IUNLINK)
23060 + in->i_flags |= S_IUNLINK;
23062 + in->i_flags &= ~S_IUNLINK;
23064 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
23065 + if (*flags & IATTR_BARRIER)
23066 + in->i_flags |= S_BARRIER;
23068 + in->i_flags &= ~S_BARRIER;
23070 + if (in->i_op && in->i_op->sync_flags) {
23071 + error = in->i_op->sync_flags(in);
23077 + if (attr.ia_valid) {
23078 + if (in->i_op && in->i_op->setattr)
23079 + error = in->i_op->setattr(de, &attr);
23081 + error = inode_change_ok(in, &attr);
23083 + error = inode_setattr(in, &attr);
23088 + mutex_unlock(&in->i_mutex);
23092 +int vc_set_iattr(void __user *data)
23094 + struct nameidata nd;
23095 + struct vcmd_ctx_iattr_v1 vc_data;
23098 + if (!capable(CAP_LINUX_IMMUTABLE))
23100 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23103 + ret = user_path_walk_link(vc_data.name, &nd);
23105 + ret = __vc_set_iattr(nd.dentry,
23106 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23107 + path_release(&nd);
23110 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23115 +#ifdef CONFIG_COMPAT
23117 +int vc_set_iattr_x32(void __user *data)
23119 + struct nameidata nd;
23120 + struct vcmd_ctx_iattr_v1_x32 vc_data;
23123 + if (!capable(CAP_LINUX_IMMUTABLE))
23125 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23128 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
23130 + ret = __vc_set_iattr(nd.dentry,
23131 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23132 + path_release(&nd);
23135 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23140 +#endif /* CONFIG_COMPAT */
23142 +int vc_fset_iattr(uint32_t fd, void __user *data)
23144 + struct file *filp;
23145 + struct vcmd_ctx_fiattr_v0 vc_data;
23148 + if (!capable(CAP_LINUX_IMMUTABLE))
23150 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23154 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
23157 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
23158 + &vc_data.flags, &vc_data.mask);
23162 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23168 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
23170 +static match_table_t tokens = {
23171 + {Opt_notagcheck, "notagcheck"},
23172 +#ifdef CONFIG_PROPAGATE
23173 + {Opt_notag, "notag"},
23174 + {Opt_tag, "tag"},
23175 + {Opt_tagid, "tagid=%u"},
23181 +static void __dx_parse_remove(char *string, char *opt)
23183 + char *p = strstr(string, opt);
23187 + while (*q != '\0' && *q != ',')
23197 +int __dx_parse_tag(char *string, tag_t *tag, int remove)
23199 + substring_t args[MAX_OPT_ARGS];
23200 + int token, option = 0;
23205 + token = match_token(string, tokens, args);
23207 + vxdprintk(VXD_CBIT(tag, 7),
23208 + "dx_parse_tag(»%s«): %d:#%d",
23209 + string, token, option);
23216 + __dx_parse_remove(string, "tag");
23217 + return MNT_TAGID;
23220 + __dx_parse_remove(string, "notag");
23221 + return MNT_NOTAG;
23222 + case Opt_notagcheck:
23224 + __dx_parse_remove(string, "notagcheck");
23225 + return MNT_NOTAGCHECK;
23227 + if (tag && !match_int(args, &option))
23230 + __dx_parse_remove(string, "tagid");
23231 + return MNT_TAGID;
23236 +int dx_parse_tag(char *string, tag_t *tag, int remove)
23238 + int retval, flags = 0;
23240 + while ((retval = __dx_parse_tag(string, tag, remove)))
23245 +#ifdef CONFIG_PROPAGATE
23247 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
23249 + tag_t new_tag = 0;
23250 + struct vfsmount *mnt;
23259 + propagate = (mnt->mnt_flags & MNT_TAGID);
23261 + new_tag = mnt->mnt_tag;
23263 + vxdprintk(VXD_CBIT(tag, 7),
23264 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
23265 + inode, inode->i_ino, inode->i_tag,
23266 + new_tag, (propagate) ? 1 : 0);
23269 + inode->i_tag = new_tag;
23272 +#include <linux/module.h>
23274 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
23276 +#endif /* CONFIG_PROPAGATE */
23278 diff -Nurp linux-2.6.22.15/kernel/vserver/Kconfig linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/Kconfig
23279 --- linux-2.6.22.15/kernel/vserver/Kconfig 1969-12-31 19:00:00.000000000 -0500
23280 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/Kconfig 2007-12-09 06:44:23.000000000 -0500
23283 +# Linux VServer configuration
23286 +menu "Linux VServer"
23288 +config VSERVER_AUTO_LBACK
23289 + bool "Automatically Assign Loopback IP"
23292 + Automatically assign a guest specific loopback
23293 + IP and add it to the kernel network stack on
23296 +config VSERVER_AUTO_SINGLE
23297 + bool "Automatic Single IP Special Casing"
23298 + depends on EXPERIMENTAL
23301 + This allows network contexts with a single IP to
23302 + automatically remap 0.0.0.0 bindings to that IP,
23303 + avoiding further network checks and improving
23306 + (note: such guests do not allow to change the ip
23307 + on the fly and do not show loopback addresses)
23309 +config VSERVER_COWBL
23310 + bool "Enable COW Immutable Link Breaking"
23313 + This enables the COW (Copy-On-Write) link break code.
23314 + It allows you to treat unified files like normal files
23315 + when writing to them (which will implicitely break the
23316 + link and create a copy of the unified file)
23318 +config VSERVER_VTIME
23319 + bool "Enable Virtualized Guest Time"
23320 + depends on EXPERIMENTAL
23323 + This enables per guest time offsets to allow for
23324 + adjusting the system clock individually per guest.
23325 + this adds some overhead to the time functions and
23326 + therefore should not be enabled without good reason.
23328 +config VSERVER_DEVICE
23329 + bool "Enable Guest Device Mapping"
23330 + depends on EXPERIMENTAL
23333 + This enables generic device remapping.
23335 +config VSERVER_PROC_SECURE
23336 + bool "Enable Proc Security"
23337 + depends on PROC_FS
23340 + This configures ProcFS security to initially hide
23341 + non-process entries for all contexts except the main and
23342 + spectator context (i.e. for all guests), which is a secure
23345 + (note: on 1.2x the entries were visible by default)
23347 +config VSERVER_HARDCPU
23348 + bool "Enable Hard CPU Limits"
23351 + Activate the Hard CPU Limits
23353 + This will compile in code that allows the Token Bucket
23354 + Scheduler to put processes on hold when a context's
23355 + tokens are depleted (provided that its per-context
23356 + sched_hard flag is set).
23358 + Processes belonging to that context will not be able
23359 + to consume CPU resources again until a per-context
23360 + configured minimum of tokens has been reached.
23362 +config VSERVER_IDLETIME
23363 + bool "Avoid idle CPUs by skipping Time"
23364 + depends on VSERVER_HARDCPU
23367 + This option allows the scheduler to artificially
23368 + advance time (per cpu) when otherwise the idle
23369 + task would be scheduled, thus keeping the cpu
23370 + busy and sharing the available resources among
23371 + certain contexts.
23373 +config VSERVER_IDLELIMIT
23374 + bool "Limit the IDLE task"
23375 + depends on VSERVER_HARDCPU
23378 + Limit the idle slices, so the the next context
23379 + will be scheduled as soon as possible.
23381 + This might improve interactivity and latency, but
23382 + will also marginally increase scheduling overhead.
23385 + prompt "Persistent Inode Tagging"
23386 + default TAGGING_ID24
23388 + This adds persistent context information to filesystems
23389 + mounted with the tagxid option. Tagging is a requirement
23390 + for per-context disk limits and per-context quota.
23393 +config TAGGING_NONE
23396 + do not store per-context information in inodes.
23398 +config TAGGING_UID16
23399 + bool "UID16/GID32"
23401 + reduces UID to 16 bit, but leaves GID at 32 bit.
23403 +config TAGGING_GID16
23404 + bool "UID32/GID16"
23406 + reduces GID to 16 bit, but leaves UID at 32 bit.
23408 +config TAGGING_ID24
23409 + bool "UID24/GID24"
23411 + uses the upper 8bit from UID and GID for XID tagging
23412 + which leaves 24bit for UID/GID each, which should be
23413 + more than sufficient for normal use.
23415 +config TAGGING_INTERN
23416 + bool "UID32/GID32"
23418 + this uses otherwise reserved inode fields in the on
23419 + disk representation, which limits the use to a few
23420 + filesystems (currently ext2 and ext3)
23425 + bool "Tag NFSD User Auth and Files"
23428 + Enable this if you do want the in-kernel NFS
23429 + Server to use the tagging specified above.
23430 + (will require patched clients too)
23432 +config VSERVER_PRIVACY
23433 + bool "Honor Privacy Aspects of Guests"
23436 + When enabled, most context checks will disallow
23437 + access to structures assigned to a specific context,
23438 + like ptys or loop devices.
23440 +config VSERVER_CONTEXTS
23441 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
23443 + default "768" if 64BIT
23446 + This setting will optimize certain data structures
23447 + and memory allocations according to the expected
23450 + note: this is not a strict upper limit.
23452 +config VSERVER_WARN
23453 + bool "VServer Warnings"
23456 + This enables various runtime warnings, which will
23457 + notify about potential manipulation attempts or
23458 + resource shortage. It is generally considered to
23459 + be a good idea to have that enabled.
23461 +config VSERVER_DEBUG
23462 + bool "VServer Debugging Code"
23465 + Set this to yes if you want to be able to activate
23466 + debugging output at runtime. It adds a very small
23467 + overhead to all vserver related functions and
23468 + increases the kernel size by about 20k.
23470 +config VSERVER_HISTORY
23471 + bool "VServer History Tracing"
23472 + depends on VSERVER_DEBUG
23475 + Set this to yes if you want to record the history of
23476 + linux-vserver activities, so they can be replayed in
23477 + the event of a kernel panic or oops.
23479 +config VSERVER_HISTORY_SIZE
23480 + int "Per-CPU History Size (32-65536)"
23481 + depends on VSERVER_HISTORY
23485 + This allows you to specify the number of entries in
23486 + the per-CPU history buffer.
23488 +config VSERVER_MONITOR
23489 + bool "VServer Scheduling Monitor"
23490 + depends on VSERVER_DEBUG
23493 + Set this to yes if you want to record the scheduling
23494 + decisions, so that they can be relayed to userspace
23495 + for detailed analysis.
23497 +config VSERVER_MONITOR_SIZE
23498 + int "Per-CPU Monitor Queue Size (32-65536)"
23499 + depends on VSERVER_MONITOR
23503 + This allows you to specify the number of entries in
23504 + the per-CPU scheduling monitor buffer.
23506 +config VSERVER_MONITOR_SYNC
23507 + int "Per-CPU Monitor Sync Interval (0-65536)"
23508 + depends on VSERVER_MONITOR
23512 + This allows you to specify the interval in ticks
23513 + when a time sync entry is inserted.
23525 +config VSERVER_SECURITY
23527 + depends on SECURITY
23529 + select SECURITY_CAPABILITIES
23531 diff -Nurp linux-2.6.22.15/kernel/vserver/limit.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/limit.c
23532 --- linux-2.6.22.15/kernel/vserver/limit.c 1969-12-31 19:00:00.000000000 -0500
23533 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/limit.c 2007-12-09 06:44:23.000000000 -0500
23536 + * linux/kernel/vserver/limit.c
23538 + * Virtual Server: Context Limits
23540 + * Copyright (C) 2004-2007 Herbert Pötzl
23542 + * V0.01 broken out from vcontext V0.05
23543 + * V0.02 changed vcmds to vxi arg
23547 +#include <linux/module.h>
23548 +#include <linux/vs_limit.h>
23549 +#include <linux/vserver/limit.h>
23550 +#include <linux/vserver/limit_cmd.h>
23552 +#include <asm/uaccess.h>
23555 +const char *vlimit_name[NUM_LIMITS] = {
23556 + [RLIMIT_CPU] = "CPU",
23557 + [RLIMIT_RSS] = "RSS",
23558 + [RLIMIT_NPROC] = "NPROC",
23559 + [RLIMIT_NOFILE] = "NOFILE",
23560 + [RLIMIT_MEMLOCK] = "VML",
23561 + [RLIMIT_AS] = "VM",
23562 + [RLIMIT_LOCKS] = "LOCKS",
23563 + [RLIMIT_SIGPENDING] = "SIGP",
23564 + [RLIMIT_MSGQUEUE] = "MSGQ",
23566 + [VLIMIT_NSOCK] = "NSOCK",
23567 + [VLIMIT_OPENFD] = "OPENFD",
23568 + [VLIMIT_ANON] = "ANON",
23569 + [VLIMIT_SHMEM] = "SHMEM",
23570 + [VLIMIT_DENTRY] = "DENTRY",
23573 +EXPORT_SYMBOL_GPL(vlimit_name);
23575 +#define MASK_ENTRY(x) (1 << (x))
23577 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
23580 + , /* softlimit */
23581 + MASK_ENTRY( RLIMIT_RSS ) |
23582 + MASK_ENTRY( VLIMIT_ANON ) |
23585 + MASK_ENTRY( RLIMIT_RSS ) |
23586 + MASK_ENTRY( RLIMIT_NPROC ) |
23587 + MASK_ENTRY( RLIMIT_NOFILE ) |
23588 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
23589 + MASK_ENTRY( RLIMIT_AS ) |
23590 + MASK_ENTRY( RLIMIT_LOCKS ) |
23591 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
23593 + MASK_ENTRY( VLIMIT_NSOCK ) |
23594 + MASK_ENTRY( VLIMIT_OPENFD ) |
23595 + MASK_ENTRY( VLIMIT_ANON ) |
23596 + MASK_ENTRY( VLIMIT_SHMEM ) |
23597 + MASK_ENTRY( VLIMIT_DENTRY ) |
23600 + /* accounting only */
23601 +uint32_t account_mask =
23602 + MASK_ENTRY( VLIMIT_SEMARY ) |
23603 + MASK_ENTRY( VLIMIT_NSEMS ) |
23604 + MASK_ENTRY( VLIMIT_MAPPED ) |
23608 +static int is_valid_vlimit(int id)
23610 + uint32_t mask = vlimit_mask.minimum |
23611 + vlimit_mask.softlimit | vlimit_mask.maximum;
23612 + return mask & (1 << id);
23615 +static int is_accounted_vlimit(int id)
23617 + if (is_valid_vlimit(id))
23619 + return account_mask & (1 << id);
23623 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
23625 + rlim_t limit = __rlim_soft(&vxi->limit, id);
23626 + return VX_VLIM(limit);
23629 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
23631 + rlim_t limit = __rlim_hard(&vxi->limit, id);
23632 + return VX_VLIM(limit);
23635 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
23636 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
23638 + if (!is_valid_vlimit(id))
23642 + *minimum = CRLIM_UNSET;
23644 + *softlimit = vc_get_soft(vxi, id);
23646 + *maximum = vc_get_hard(vxi, id);
23650 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
23652 + struct vcmd_ctx_rlimit_v0 vc_data;
23655 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23658 + ret = do_get_rlimit(vxi, vc_data.id,
23659 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
23663 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23668 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
23669 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
23671 + if (!is_valid_vlimit(id))
23674 + if (maximum != CRLIM_KEEP)
23675 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
23676 + if (softlimit != CRLIM_KEEP)
23677 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
23679 + /* clamp soft limit */
23680 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
23681 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
23686 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
23688 + struct vcmd_ctx_rlimit_v0 vc_data;
23690 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23693 + return do_set_rlimit(vxi, vc_data.id,
23694 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
23697 +#ifdef CONFIG_IA32_EMULATION
23699 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
23701 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
23703 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23706 + return do_set_rlimit(vxi, vc_data.id,
23707 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
23710 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
23712 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
23715 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23718 + ret = do_get_rlimit(vxi, vc_data.id,
23719 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
23723 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23728 +#endif /* CONFIG_IA32_EMULATION */
23731 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
23733 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
23739 +static inline void vx_reset_minmax(struct _vx_limit *limit)
23744 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23745 + value = __rlim_get(limit, lim);
23746 + __rlim_rmax(limit, lim) = value;
23747 + __rlim_rmin(limit, lim) = value;
23752 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
23754 + vx_reset_minmax(&vxi->limit);
23759 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
23761 + struct vcmd_rlimit_stat_v0 vc_data;
23762 + struct _vx_limit *limit = &vxi->limit;
23765 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23769 + if (!is_accounted_vlimit(id))
23772 + vx_limit_fixup(limit, id);
23773 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
23774 + vc_data.value = __rlim_get(limit, id);
23775 + vc_data.minimum = __rlim_rmin(limit, id);
23776 + vc_data.maximum = __rlim_rmax(limit, id);
23778 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23784 +void vx_vsi_meminfo(struct sysinfo *val)
23786 + struct vx_info *vxi = current->vx_info;
23787 + unsigned long totalram, freeram;
23790 + /* we blindly accept the max */
23791 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23792 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
23794 + /* total minus used equals free */
23795 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23796 + freeram = (v < totalram) ? totalram - v : 0;
23798 + val->totalram = totalram;
23799 + val->freeram = freeram;
23800 + val->bufferram = 0;
23801 + val->totalhigh = 0;
23802 + val->freehigh = 0;
23806 +void vx_vsi_swapinfo(struct sysinfo *val)
23808 + struct vx_info *vxi = current->vx_info;
23809 + unsigned long totalswap, freeswap;
23812 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23813 + if (v == RLIM_INFINITY) {
23814 + val->freeswap = val->totalswap;
23818 + /* we blindly accept the max */
23819 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
23820 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
23822 + /* currently 'used' swap */
23823 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23824 + w -= (w > v) ? v : w;
23826 + /* total minus used equals free */
23827 + freeswap = (w < totalswap) ? totalswap - w : 0;
23829 + val->totalswap = totalswap;
23830 + val->freeswap = freeswap;
23835 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
23837 + struct vx_info *vxi = mm->mm_vx_info;
23838 + unsigned long points;
23844 + points = vxi->vx_badness_bias;
23846 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23847 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23848 + points += (v > w) ? (v - w) : 0;
23853 diff -Nurp linux-2.6.22.15/kernel/vserver/limit_init.h linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/limit_init.h
23854 --- linux-2.6.22.15/kernel/vserver/limit_init.h 1969-12-31 19:00:00.000000000 -0500
23855 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/limit_init.h 2007-12-09 06:44:23.000000000 -0500
23859 +static inline void vx_info_init_limit(struct _vx_limit *limit)
23863 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23864 + __rlim_soft(limit, lim) = RLIM_INFINITY;
23865 + __rlim_hard(limit, lim) = RLIM_INFINITY;
23866 + __rlim_set(limit, lim, 0);
23867 + atomic_set(&__rlim_lhit(limit, lim), 0);
23868 + __rlim_rmin(limit, lim) = 0;
23869 + __rlim_rmax(limit, lim) = 0;
23873 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
23875 +#ifdef CONFIG_VSERVER_WARN
23879 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23880 + if ((1 << lim) & VLIM_NOCHECK)
23882 + value = __rlim_get(limit, lim);
23883 + vxwprintk_xid(value,
23884 + "!!! limit: %p[%s,%d] = %ld on exit.",
23885 + limit, vlimit_name[lim], lim, (long)value);
23890 diff -Nurp linux-2.6.22.15/kernel/vserver/limit_proc.h linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/limit_proc.h
23891 --- linux-2.6.22.15/kernel/vserver/limit_proc.h 1969-12-31 19:00:00.000000000 -0500
23892 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/limit_proc.h 2007-12-09 06:44:23.000000000 -0500
23894 +#ifndef _VX_LIMIT_PROC_H
23895 +#define _VX_LIMIT_PROC_H
23897 +#include <linux/vserver/limit_int.h>
23900 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
23901 +#define VX_LIMIT_TOP \
23902 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
23904 +#define VX_LIMIT_ARG(r) \
23905 + (unsigned long)__rlim_get(limit, r), \
23906 + (unsigned long)__rlim_rmin(limit, r), \
23907 + (unsigned long)__rlim_rmax(limit, r), \
23908 + VX_VLIM(__rlim_soft(limit, r)), \
23909 + VX_VLIM(__rlim_hard(limit, r)), \
23910 + atomic_read(&__rlim_lhit(limit, r))
23912 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
23914 + vx_limit_fixup(limit, -1);
23915 + return sprintf(buffer, VX_LIMIT_TOP
23916 + "PROC" VX_LIMIT_FMT
23917 + "VM" VX_LIMIT_FMT
23918 + "VML" VX_LIMIT_FMT
23919 + "RSS" VX_LIMIT_FMT
23920 + "ANON" VX_LIMIT_FMT
23921 + "RMAP" VX_LIMIT_FMT
23922 + "FILES" VX_LIMIT_FMT
23923 + "OFD" VX_LIMIT_FMT
23924 + "LOCKS" VX_LIMIT_FMT
23925 + "SOCK" VX_LIMIT_FMT
23926 + "MSGQ" VX_LIMIT_FMT
23927 + "SHM" VX_LIMIT_FMT
23928 + "SEMA" VX_LIMIT_FMT
23929 + "SEMS" VX_LIMIT_FMT
23930 + "DENT" VX_LIMIT_FMT,
23931 + VX_LIMIT_ARG(RLIMIT_NPROC),
23932 + VX_LIMIT_ARG(RLIMIT_AS),
23933 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
23934 + VX_LIMIT_ARG(RLIMIT_RSS),
23935 + VX_LIMIT_ARG(VLIMIT_ANON),
23936 + VX_LIMIT_ARG(VLIMIT_MAPPED),
23937 + VX_LIMIT_ARG(RLIMIT_NOFILE),
23938 + VX_LIMIT_ARG(VLIMIT_OPENFD),
23939 + VX_LIMIT_ARG(RLIMIT_LOCKS),
23940 + VX_LIMIT_ARG(VLIMIT_NSOCK),
23941 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
23942 + VX_LIMIT_ARG(VLIMIT_SHMEM),
23943 + VX_LIMIT_ARG(VLIMIT_SEMARY),
23944 + VX_LIMIT_ARG(VLIMIT_NSEMS),
23945 + VX_LIMIT_ARG(VLIMIT_DENTRY));
23948 +#endif /* _VX_LIMIT_PROC_H */
23951 diff -Nurp linux-2.6.22.15/kernel/vserver/Makefile linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/Makefile
23952 --- linux-2.6.22.15/kernel/vserver/Makefile 1969-12-31 19:00:00.000000000 -0500
23953 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/Makefile 2007-12-09 06:44:23.000000000 -0500
23956 +# Makefile for the Linux vserver routines.
23960 +obj-y += vserver.o
23962 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
23963 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
23966 +vserver-$(CONFIG_INET) += inet.o
23967 +vserver-$(CONFIG_PROC_FS) += proc.o
23968 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
23969 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
23970 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
23971 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
23973 diff -Nurp linux-2.6.22.15/kernel/vserver/monitor.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/monitor.c
23974 --- linux-2.6.22.15/kernel/vserver/monitor.c 1969-12-31 19:00:00.000000000 -0500
23975 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/monitor.c 2007-12-09 06:44:23.000000000 -0500
23978 + * kernel/vserver/monitor.c
23980 + * Virtual Context Scheduler Monitor
23982 + * Copyright (C) 2006-2007 Herbert Pötzl
23984 + * V0.01 basic design
23988 +#include <linux/module.h>
23989 +#include <linux/jiffies.h>
23990 +#include <asm/uaccess.h>
23991 +#include <asm/atomic.h>
23993 +#include <linux/vserver/monitor.h>
23994 +#include <linux/vserver/debug_cmd.h>
23997 +#ifdef CONFIG_VSERVER_MONITOR
23998 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
24000 +#define VXM_SIZE 64
24003 +struct _vx_monitor {
24004 + unsigned int counter;
24006 + struct _vx_mon_entry entry[VXM_SIZE+1];
24010 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
24012 +unsigned volatile int vxm_active = 1;
24014 +static atomic_t sequence = ATOMIC_INIT(0);
24019 + * requires disabled preemption */
24021 +struct _vx_mon_entry *vxm_advance(int cpu)
24023 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
24024 + struct _vx_mon_entry *entry;
24025 + unsigned int index;
24027 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
24028 + entry = &mon->entry[index];
24030 + entry->ev.seq = atomic_inc_return(&sequence);
24031 + entry->ev.jif = jiffies;
24035 +EXPORT_SYMBOL_GPL(vxm_advance);
24038 +int do_read_monitor(struct __user _vx_mon_entry *data,
24039 + int cpu, uint32_t *index, uint32_t *count)
24041 + int pos, ret = 0;
24042 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
24043 + int end = mon->counter;
24044 + int start = end - VXM_SIZE + 2;
24045 + int idx = *index;
24047 + /* special case: get current pos */
24053 + /* have we lost some data? */
24057 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
24058 + struct _vx_mon_entry *entry =
24059 + &mon->entry[idx % VXM_SIZE];
24061 + /* send entry to userspace */
24062 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
24066 + /* save new index and count */
24069 + return ret ? ret : (*index < end);
24072 +int vc_read_monitor(uint32_t id, void __user *data)
24074 + struct vcmd_read_monitor_v0 vc_data;
24077 + if (id >= NR_CPUS)
24080 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24083 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
24084 + id, &vc_data.index, &vc_data.count);
24086 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24091 +#ifdef CONFIG_COMPAT
24093 +int vc_read_monitor_x32(uint32_t id, void __user *data)
24095 + struct vcmd_read_monitor_v0_x32 vc_data;
24098 + if (id >= NR_CPUS)
24101 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24104 + ret = do_read_monitor((struct __user _vx_mon_entry *)
24105 + compat_ptr(vc_data.data_ptr),
24106 + id, &vc_data.index, &vc_data.count);
24108 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24113 +#endif /* CONFIG_COMPAT */
24115 diff -Nurp linux-2.6.22.15/kernel/vserver/network.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/network.c
24116 --- linux-2.6.22.15/kernel/vserver/network.c 1969-12-31 19:00:00.000000000 -0500
24117 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/network.c 2007-12-09 06:44:23.000000000 -0500
24120 + * linux/kernel/vserver/network.c
24122 + * Virtual Server: Network Support
24124 + * Copyright (C) 2003-2007 Herbert Pötzl
24126 + * V0.01 broken out from vcontext V0.05
24127 + * V0.02 cleaned up implementation
24128 + * V0.03 added equiv nx commands
24129 + * V0.04 switch to RCU based hash
24130 + * V0.05 and back to locking again
24131 + * V0.06 changed vcmds to nxi arg
24132 + * V0.07 have __create claim() the nxi
24136 +#include <linux/err.h>
24137 +#include <linux/slab.h>
24138 +#include <linux/rcupdate.h>
24140 +#include <linux/vs_network.h>
24141 +#include <linux/vserver/network_cmd.h>
24144 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
24145 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
24147 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
24148 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
24151 +static int __init init_network(void)
24153 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
24154 + sizeof(struct nx_addr_v4), 0, SLAB_PANIC, NULL, NULL);
24155 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
24156 + sizeof(struct nx_addr_v6), 0, SLAB_PANIC, NULL, NULL);
24161 +/* __alloc_nx_addr_v4() */
24163 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
24165 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
24166 + nx_addr_v4_cachep, GFP_KERNEL);
24168 + if (!IS_ERR(nxa))
24169 + memset(nxa, 0, sizeof(*nxa));
24173 +/* __dealloc_nx_addr_v4() */
24175 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
24177 + kmem_cache_free(nx_addr_v4_cachep, nxa);
24180 +/* __dealloc_nx_addr_v4_all() */
24182 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
24185 + struct nx_addr_v4 *next = nxa->next;
24187 + __dealloc_nx_addr_v4(nxa);
24193 +#ifdef CONFIG_IPV6
24195 +/* __alloc_nx_addr_v6() */
24197 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
24199 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
24200 + nx_addr_v6_cachep, GFP_KERNEL);
24202 + if (!IS_ERR(nxa))
24203 + memset(nxa, 0, sizeof(*nxa));
24207 +/* __dealloc_nx_addr_v6() */
24209 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
24211 + kmem_cache_free(nx_addr_v6_cachep, nxa);
24214 +/* __dealloc_nx_addr_v6_all() */
24216 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
24219 + struct nx_addr_v6 *next = nxa->next;
24221 + __dealloc_nx_addr_v6(nxa);
24226 +#endif /* CONFIG_IPV6 */
24229 +/* __alloc_nx_info()
24231 + * allocate an initialized nx_info struct
24232 + * doesn't make it visible (hash) */
24234 +static struct nx_info *__alloc_nx_info(nid_t nid)
24236 + struct nx_info *new = NULL;
24238 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
24240 + /* would this benefit from a slab cache? */
24241 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
24245 + memset(new, 0, sizeof(struct nx_info));
24246 + new->nx_id = nid;
24247 + INIT_HLIST_NODE(&new->nx_hlist);
24248 + atomic_set(&new->nx_usecnt, 0);
24249 + atomic_set(&new->nx_tasks, 0);
24250 + new->nx_state = 0;
24252 + new->nx_flags = NXF_INIT_SET;
24254 + /* rest of init goes here */
24256 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
24257 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
24259 + vxdprintk(VXD_CBIT(nid, 0),
24260 + "alloc_nx_info(%d) = %p", nid, new);
24261 + atomic_inc(&nx_global_ctotal);
24265 +/* __dealloc_nx_info()
24267 + * final disposal of nx_info */
24269 +static void __dealloc_nx_info(struct nx_info *nxi)
24271 + vxdprintk(VXD_CBIT(nid, 0),
24272 + "dealloc_nx_info(%p)", nxi);
24274 + nxi->nx_hlist.next = LIST_POISON1;
24277 + BUG_ON(atomic_read(&nxi->nx_usecnt));
24278 + BUG_ON(atomic_read(&nxi->nx_tasks));
24280 + __dealloc_nx_addr_v4_all(nxi->v4.next);
24282 + nxi->nx_state |= NXS_RELEASED;
24284 + atomic_dec(&nx_global_ctotal);
24287 +static void __shutdown_nx_info(struct nx_info *nxi)
24289 + nxi->nx_state |= NXS_SHUTDOWN;
24290 + vs_net_change(nxi, VSC_NETDOWN);
24293 +/* exported stuff */
24295 +void free_nx_info(struct nx_info *nxi)
24297 + /* context shutdown is mandatory */
24298 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
24300 + /* context must not be hashed */
24301 + BUG_ON(nxi->nx_state & NXS_HASHED);
24303 + BUG_ON(atomic_read(&nxi->nx_usecnt));
24304 + BUG_ON(atomic_read(&nxi->nx_tasks));
24306 + __dealloc_nx_info(nxi);
24310 +void __nx_set_lback(struct nx_info *nxi)
24312 + int nid = nxi->nx_id;
24313 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
24315 + nxi->v4_lback.s_addr = lback;
24318 +extern int __nx_inet_add_lback(__be32 addr);
24319 +extern int __nx_inet_del_lback(__be32 addr);
24322 +/* hash table for nx_info hash */
24324 +#define NX_HASH_SIZE 13
24326 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
24328 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
24331 +static inline unsigned int __hashval(nid_t nid)
24333 + return (nid % NX_HASH_SIZE);
24338 +/* __hash_nx_info()
24340 + * add the nxi to the global hash table
24341 + * requires the hash_lock to be held */
24343 +static inline void __hash_nx_info(struct nx_info *nxi)
24345 + struct hlist_head *head;
24347 + vxd_assert_lock(&nx_info_hash_lock);
24348 + vxdprintk(VXD_CBIT(nid, 4),
24349 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
24351 + /* context must not be hashed */
24352 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
24354 + nxi->nx_state |= NXS_HASHED;
24355 + head = &nx_info_hash[__hashval(nxi->nx_id)];
24356 + hlist_add_head(&nxi->nx_hlist, head);
24357 + atomic_inc(&nx_global_cactive);
24360 +/* __unhash_nx_info()
24362 + * remove the nxi from the global hash table
24363 + * requires the hash_lock to be held */
24365 +static inline void __unhash_nx_info(struct nx_info *nxi)
24367 + vxd_assert_lock(&nx_info_hash_lock);
24368 + vxdprintk(VXD_CBIT(nid, 4),
24369 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
24370 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
24372 + /* context must be hashed */
24373 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
24374 + /* but without tasks */
24375 + BUG_ON(atomic_read(&nxi->nx_tasks));
24377 + nxi->nx_state &= ~NXS_HASHED;
24378 + hlist_del(&nxi->nx_hlist);
24379 + atomic_dec(&nx_global_cactive);
24383 +/* __lookup_nx_info()
24385 + * requires the hash_lock to be held
24386 + * doesn't increment the nx_refcnt */
24388 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
24390 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
24391 + struct hlist_node *pos;
24392 + struct nx_info *nxi;
24394 + vxd_assert_lock(&nx_info_hash_lock);
24395 + hlist_for_each(pos, head) {
24396 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
24398 + if (nxi->nx_id == nid)
24403 + vxdprintk(VXD_CBIT(nid, 0),
24404 + "__lookup_nx_info(#%u): %p[#%u]",
24405 + nid, nxi, nxi ? nxi->nx_id : 0);
24410 +/* __create_nx_info()
24412 + * create the requested context
24413 + * get(), claim() and hash it */
24415 +static struct nx_info *__create_nx_info(int id)
24417 + struct nx_info *new, *nxi = NULL;
24419 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
24421 + if (!(new = __alloc_nx_info(id)))
24422 + return ERR_PTR(-ENOMEM);
24424 + /* required to make dynamic xids unique */
24425 + spin_lock(&nx_info_hash_lock);
24427 + /* static context requested */
24428 + if ((nxi = __lookup_nx_info(id))) {
24429 + vxdprintk(VXD_CBIT(nid, 0),
24430 + "create_nx_info(%d) = %p (already there)", id, nxi);
24431 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
24432 + nxi = ERR_PTR(-EBUSY);
24434 + nxi = ERR_PTR(-EEXIST);
24437 + /* new context */
24438 + vxdprintk(VXD_CBIT(nid, 0),
24439 + "create_nx_info(%d) = %p (new)", id, new);
24440 + claim_nx_info(new, NULL);
24441 + __nx_set_lback(new);
24442 + __hash_nx_info(get_nx_info(new));
24443 + nxi = new, new = NULL;
24446 + spin_unlock(&nx_info_hash_lock);
24448 + __dealloc_nx_info(new);
24454 +/* exported stuff */
24457 +void unhash_nx_info(struct nx_info *nxi)
24459 + __shutdown_nx_info(nxi);
24460 + spin_lock(&nx_info_hash_lock);
24461 + __unhash_nx_info(nxi);
24462 + spin_unlock(&nx_info_hash_lock);
24465 +/* lookup_nx_info()
24467 + * search for a nx_info and get() it
24468 + * negative id means current */
24470 +struct nx_info *lookup_nx_info(int id)
24472 + struct nx_info *nxi = NULL;
24475 + nxi = get_nx_info(current->nx_info);
24476 + } else if (id > 1) {
24477 + spin_lock(&nx_info_hash_lock);
24478 + nxi = get_nx_info(__lookup_nx_info(id));
24479 + spin_unlock(&nx_info_hash_lock);
24484 +/* nid_is_hashed()
24486 + * verify that nid is still hashed */
24488 +int nid_is_hashed(nid_t nid)
24492 + spin_lock(&nx_info_hash_lock);
24493 + hashed = (__lookup_nx_info(nid) != NULL);
24494 + spin_unlock(&nx_info_hash_lock);
24499 +#ifdef CONFIG_PROC_FS
24503 + * get a subset of hashed nids for proc
24504 + * assumes size is at least one */
24506 +int get_nid_list(int index, unsigned int *nids, int size)
24508 + int hindex, nr_nids = 0;
24510 + /* only show current and children */
24511 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
24514 + nids[nr_nids] = nx_current_nid();
24518 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
24519 + struct hlist_head *head = &nx_info_hash[hindex];
24520 + struct hlist_node *pos;
24522 + spin_lock(&nx_info_hash_lock);
24523 + hlist_for_each(pos, head) {
24524 + struct nx_info *nxi;
24529 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
24530 + nids[nr_nids] = nxi->nx_id;
24531 + if (++nr_nids >= size) {
24532 + spin_unlock(&nx_info_hash_lock);
24536 + /* keep the lock time short */
24537 + spin_unlock(&nx_info_hash_lock);
24546 + * migrate task to new network
24547 + * gets nxi, puts old_nxi on change
24550 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
24552 + struct nx_info *old_nxi;
24558 + vxdprintk(VXD_CBIT(nid, 5),
24559 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
24560 + p, nxi, nxi->nx_id,
24561 + atomic_read(&nxi->nx_usecnt),
24562 + atomic_read(&nxi->nx_tasks));
24564 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
24565 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
24568 + if (nx_info_state(nxi, NXS_SHUTDOWN))
24571 + /* maybe disallow this completely? */
24572 + old_nxi = task_get_nx_info(p);
24573 + if (old_nxi == nxi)
24578 + clr_nx_info(&p->nx_info);
24579 + claim_nx_info(nxi, p);
24580 + set_nx_info(&p->nx_info, nxi);
24581 + p->nid = nxi->nx_id;
24584 + vxdprintk(VXD_CBIT(nid, 5),
24585 + "moved task %p into nxi:%p[#%d]",
24586 + p, nxi, nxi->nx_id);
24589 + release_nx_info(old_nxi, p);
24592 + put_nx_info(old_nxi);
24597 +void nx_set_persistent(struct nx_info *nxi)
24599 + vxdprintk(VXD_CBIT(nid, 6),
24600 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
24602 + get_nx_info(nxi);
24603 + claim_nx_info(nxi, NULL);
24606 +void nx_clear_persistent(struct nx_info *nxi)
24608 + vxdprintk(VXD_CBIT(nid, 6),
24609 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
24611 + release_nx_info(nxi, NULL);
24612 + put_nx_info(nxi);
24615 +void nx_update_persistent(struct nx_info *nxi)
24617 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
24618 + nx_set_persistent(nxi);
24620 + nx_clear_persistent(nxi);
24623 +/* vserver syscall commands below here */
24625 +/* taks nid and nx_info functions */
24627 +#include <asm/uaccess.h>
24630 +int vc_task_nid(uint32_t id)
24635 + struct task_struct *tsk;
24637 + read_lock(&tasklist_lock);
24638 + tsk = find_task_by_real_pid(id);
24639 + nid = (tsk) ? tsk->nid : -ESRCH;
24640 + read_unlock(&tasklist_lock);
24642 + nid = nx_current_nid();
24647 +int vc_nx_info(struct nx_info *nxi, void __user *data)
24649 + struct vcmd_nx_info_v0 vc_data;
24651 + vc_data.nid = nxi->nx_id;
24653 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24659 +/* network functions */
24661 +int vc_net_create(uint32_t nid, void __user *data)
24663 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
24664 + struct nx_info *new_nxi;
24667 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24670 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
24673 + new_nxi = __create_nx_info(nid);
24674 + if (IS_ERR(new_nxi))
24675 + return PTR_ERR(new_nxi);
24677 + /* initial flags */
24678 + new_nxi->nx_flags = vc_data.flagword;
24681 + if (vs_net_change(new_nxi, VSC_NETUP))
24684 + ret = nx_migrate_task(current, new_nxi);
24688 + /* return context id on success */
24689 + ret = new_nxi->nx_id;
24691 + /* get a reference for persistent contexts */
24692 + if ((vc_data.flagword & NXF_PERSISTENT))
24693 + nx_set_persistent(new_nxi);
24695 + release_nx_info(new_nxi, NULL);
24696 + put_nx_info(new_nxi);
24701 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
24703 + return nx_migrate_task(current, nxi);
24708 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
24709 + uint16_t type, uint16_t flags)
24711 + struct nx_addr_v4 *nxa = &nxi->v4;
24713 + if (NX_IPV4(nxi)) {
24714 + /* locate last entry */
24715 + for (; nxa->next; nxa = nxa->next);
24716 + nxa->next = __alloc_nx_addr_v4();
24720 + return PTR_ERR(nxa);
24723 + if (nxi->v4.next)
24724 + /* remove single ip for ip list */
24725 + nxi->nx_flags &= ~NXF_SINGLE_IP;
24727 + nxa->ip[0].s_addr = ip;
24728 + nxa->ip[1].s_addr = ip2;
24729 + nxa->mask.s_addr = mask;
24730 + nxa->type = type;
24731 + nxa->flags = flags;
24736 +int vc_net_add(struct nx_info *nxi, void __user *data)
24738 + struct vcmd_net_addr_v0 vc_data;
24739 + int index, ret = 0;
24741 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24744 + switch (vc_data.type) {
24745 + case NXA_TYPE_IPV4:
24746 + if ((vc_data.count < 1) || (vc_data.count > 4))
24750 + while (index < vc_data.count) {
24751 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
24752 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
24760 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
24761 + nxi->v4_bcast = vc_data.ip[0];
24765 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
24766 + nxi->v4_lback = vc_data.ip[0];
24777 +int vc_net_remove(struct nx_info *nxi, void __user *data)
24779 + struct vcmd_net_addr_v0 vc_data;
24781 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24784 + switch (vc_data.type) {
24785 + case NXA_TYPE_ANY:
24786 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24787 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24797 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
24799 + struct vcmd_net_addr_ipv4_v1 vc_data;
24801 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24804 + switch (vc_data.type) {
24805 + case NXA_TYPE_ADDR:
24806 + case NXA_TYPE_RANGE:
24807 + case NXA_TYPE_MASK:
24808 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
24809 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
24811 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
24812 + nxi->v4_bcast = vc_data.ip;
24815 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
24816 + nxi->v4_lback = vc_data.ip;
24825 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
24827 + struct vcmd_net_addr_ipv4_v1 vc_data;
24829 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24832 + switch (vc_data.type) {
24833 +/* case NXA_TYPE_ADDR:
24836 + case NXA_TYPE_ANY:
24837 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24838 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24848 +#ifdef CONFIG_IPV6
24850 +int do_add_v6_addr(struct nx_info *nxi,
24851 + struct in6_addr *ip, struct in6_addr *mask,
24852 + uint32_t prefix, uint16_t type, uint16_t flags)
24854 + struct nx_addr_v6 *nxa = &nxi->v6;
24856 + if (NX_IPV6(nxi)) {
24857 + /* locate last entry */
24858 + for (; nxa->next; nxa = nxa->next);
24859 + nxa->next = __alloc_nx_addr_v6();
24863 + return PTR_ERR(nxa);
24867 + nxa->mask = *mask;
24868 + nxa->prefix = prefix;
24869 + nxa->type = type;
24870 + nxa->flags = flags;
24875 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
24877 + struct vcmd_net_addr_ipv6_v1 vc_data;
24879 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24882 + switch (vc_data.type) {
24883 + case NXA_TYPE_ADDR:
24884 + case NXA_TYPE_MASK:
24885 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
24886 + vc_data.prefix, vc_data.type, vc_data.flags);
24893 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
24895 + struct vcmd_net_addr_ipv6_v1 vc_data;
24897 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24900 + switch (vc_data.type) {
24901 + case NXA_TYPE_ANY:
24902 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
24903 + memset(&nxi->v6, 0, sizeof(nxi->v6));
24912 +#endif /* CONFIG_IPV6 */
24915 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
24917 + struct vcmd_net_flags_v0 vc_data;
24919 + vc_data.flagword = nxi->nx_flags;
24921 + /* special STATE flag handling */
24922 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
24924 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24929 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
24931 + struct vcmd_net_flags_v0 vc_data;
24932 + uint64_t mask, trigger;
24934 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24937 + /* special STATE flag handling */
24938 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
24939 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
24941 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
24942 + vc_data.flagword, mask);
24943 + if (trigger & NXF_PERSISTENT)
24944 + nx_update_persistent(nxi);
24949 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
24951 + struct vcmd_net_caps_v0 vc_data;
24953 + vc_data.ncaps = nxi->nx_ncaps;
24954 + vc_data.cmask = ~0ULL;
24956 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24961 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
24963 + struct vcmd_net_caps_v0 vc_data;
24965 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24968 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
24969 + vc_data.ncaps, vc_data.cmask);
24974 +#include <linux/module.h>
24976 +module_init(init_network);
24978 +EXPORT_SYMBOL_GPL(free_nx_info);
24979 +EXPORT_SYMBOL_GPL(unhash_nx_info);
24981 diff -Nurp linux-2.6.22.15/kernel/vserver/proc.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/proc.c
24982 --- linux-2.6.22.15/kernel/vserver/proc.c 1969-12-31 19:00:00.000000000 -0500
24983 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/proc.c 2007-12-09 06:44:23.000000000 -0500
24986 + * linux/kernel/vserver/proc.c
24988 + * Virtual Context Support
24990 + * Copyright (C) 2003-2007 Herbert Pötzl
24992 + * V0.01 basic structure
24993 + * V0.02 adaptation vs1.3.0
24994 + * V0.03 proc permissions
24995 + * V0.04 locking/generic
24996 + * V0.05 next generation procfs
24997 + * V0.06 inode validation
24998 + * V0.07 generic rewrite vid
24999 + * V0.08 remove inode type
25003 +#include <linux/proc_fs.h>
25004 +#include <asm/unistd.h>
25006 +#include <linux/vs_context.h>
25007 +#include <linux/vs_network.h>
25008 +#include <linux/vs_cvirt.h>
25009 +#include <linux/vs_inet.h>
25010 +#include <linux/vs_inet6.h>
25012 +#include <linux/vserver/global.h>
25014 +#include "cvirt_proc.h"
25015 +#include "cacct_proc.h"
25016 +#include "limit_proc.h"
25017 +#include "sched_proc.h"
25018 +#include "vci_config.h"
25020 +static struct proc_dir_entry *proc_virtual;
25022 +static struct proc_dir_entry *proc_virtnet;
25025 +/* first the actual feeds */
25028 +static int proc_vci(char *buffer)
25030 + return sprintf(buffer,
25031 + "VCIVersion:\t%04x:%04x\n"
25032 + "VCISyscall:\t%d\n"
25033 + "VCIKernel:\t%08x\n",
25034 + VCI_VERSION >> 16,
25035 + VCI_VERSION & 0xFFFF,
25037 + vci_kernel_config());
25040 +static int proc_virtual_info(char *buffer)
25042 + return proc_vci(buffer);
25045 +static int proc_virtual_status(char *buffer)
25047 + return sprintf(buffer,
25049 + "#CActive:\t%d\n"
25050 + "#NSProxy:\t%d\t%d %d %d %d\n",
25051 + atomic_read(&vx_global_ctotal),
25052 + atomic_read(&vx_global_cactive),
25053 + atomic_read(&vs_global_nsproxy),
25054 + atomic_read(&vs_global_fs),
25055 + atomic_read(&vs_global_mnt_ns),
25056 + atomic_read(&vs_global_uts_ns),
25057 + atomic_read(&vs_global_ipc_ns));
25061 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
25065 + length = sprintf(buffer,
25073 + vxi->vx_badness_bias);
25077 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
25081 + length = sprintf(buffer,
25084 + "Flags:\t%016llx\n"
25085 + "BCaps:\t%016llx\n"
25086 + "CCaps:\t%016llx\n"
25087 + "Spaces:\t%08lx\n",
25088 + atomic_read(&vxi->vx_usecnt),
25089 + atomic_read(&vxi->vx_tasks),
25090 + (unsigned long long)vxi->vx_flags,
25091 + (unsigned long long)vxi->vx_bcaps,
25092 + (unsigned long long)vxi->vx_ccaps,
25097 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
25099 + return vx_info_proc_limit(&vxi->limit, buffer);
25102 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
25106 + length = vx_info_proc_sched(&vxi->sched, buffer);
25107 + for_each_online_cpu(cpu) {
25108 + length += vx_info_proc_sched_pc(
25109 + &vx_per_cpu(vxi, sched_pc, cpu),
25110 + buffer + length, cpu);
25115 +int proc_vxi_nsproxy(struct vx_info *vxi, char *buffer)
25117 + return vx_info_proc_nsproxy(vxi->vx_nsproxy, buffer);
25120 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
25124 + vx_update_load(vxi);
25125 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
25126 + for_each_online_cpu(cpu) {
25127 + length += vx_info_proc_cvirt_pc(
25128 + &vx_per_cpu(vxi, cvirt_pc, cpu),
25129 + buffer + length, cpu);
25134 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
25136 + return vx_info_proc_cacct(&vxi->cacct, buffer);
25140 +static int proc_virtnet_info(char *buffer)
25142 + return proc_vci(buffer);
25145 +static int proc_virtnet_status(char *buffer)
25147 + return sprintf(buffer,
25149 + "#CActive:\t%d\n",
25150 + atomic_read(&nx_global_ctotal),
25151 + atomic_read(&nx_global_cactive));
25154 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
25156 + struct nx_addr_v4 *v4a;
25157 +#ifdef CONFIG_IPV6
25158 + struct nx_addr_v6 *v6a;
25162 + length = sprintf(buffer,
25165 + "Bcast:\t" NIPQUAD_FMT "\n"
25166 + "Lback:\t" NIPQUAD_FMT "\n",
25169 + NIPQUAD(nxi->v4_bcast.s_addr),
25170 + NIPQUAD(nxi->v4_lback.s_addr));
25172 + if (!NX_IPV4(nxi))
25174 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
25175 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
25178 +#ifdef CONFIG_IPV6
25179 + if (!NX_IPV6(nxi))
25181 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
25182 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
25189 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
25193 + length = sprintf(buffer,
25196 + "Flags:\t%016llx\n"
25197 + "NCaps:\t%016llx\n",
25198 + atomic_read(&nxi->nx_usecnt),
25199 + atomic_read(&nxi->nx_tasks),
25200 + (unsigned long long)nxi->nx_flags,
25201 + (unsigned long long)nxi->nx_ncaps);
25207 +/* here the inode helpers */
25213 + struct inode_operations *iop;
25214 + struct file_operations *fop;
25215 + union proc_op op;
25218 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
25220 + struct inode *inode = new_inode(sb);
25225 + inode->i_mode = p->mode;
25227 + inode->i_op = p->iop;
25229 + inode->i_fop = p->fop;
25231 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
25232 + inode->i_flags |= S_IMMUTABLE;
25234 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
25236 + inode->i_uid = 0;
25237 + inode->i_gid = 0;
25238 + inode->i_tag = 0;
25243 +static struct dentry *vs_proc_instantiate(struct inode *dir,
25244 + struct dentry *dentry, int id, void *ptr)
25246 + struct vs_entry *p = ptr;
25247 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
25248 + struct dentry *error = ERR_PTR(-EINVAL);
25253 + PROC_I(inode)->op = p->op;
25254 + PROC_I(inode)->fd = id;
25255 + d_add(dentry, inode);
25263 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
25266 + * Fill a directory entry.
25268 + * If possible create the dcache entry and derive our inode number and
25269 + * file type from dcache entry.
25271 + * Since all of the proc inode numbers are dynamically generated, the inode
25272 + * numbers do not exist until the inode is cache. This means creating the
25273 + * the dcache entry in readdir is necessary to keep the inode numbers
25274 + * reported by readdir in sync with the inode numbers reported
25277 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
25278 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
25280 + struct dentry *child, *dir = filp->f_dentry;
25281 + struct inode *inode;
25282 + struct qstr qname;
25284 + unsigned type = DT_UNKNOWN;
25286 + qname.name = name;
25288 + qname.hash = full_name_hash(name, len);
25290 + child = d_lookup(dir, &qname);
25292 + struct dentry *new;
25293 + new = d_alloc(dir, &qname);
25295 + child = instantiate(dir->d_inode, new, id, ptr);
25302 + if (!child || IS_ERR(child) || !child->d_inode)
25303 + goto end_instantiate;
25304 + inode = child->d_inode;
25306 + ino = inode->i_ino;
25307 + type = inode->i_mode >> 12;
25312 + ino = find_inode_number(dir, &qname);
25315 + return filldir(dirent, name, len, filp->f_pos, ino, type);
25320 +/* get and revalidate vx_info/xid */
25323 +struct vx_info *get_proc_vx_info(struct inode *inode)
25325 + return lookup_vx_info(PROC_I(inode)->fd);
25328 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
25330 + struct inode *inode = dentry->d_inode;
25331 + xid_t xid = PROC_I(inode)->fd;
25333 + if (!xid || xid_is_hashed(xid))
25340 +/* get and revalidate nx_info/nid */
25342 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
25344 + struct inode *inode = dentry->d_inode;
25345 + nid_t nid = PROC_I(inode)->fd;
25347 + if (!nid || nid_is_hashed(nid))
25355 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
25357 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
25358 + size_t count, loff_t *ppos)
25360 + struct inode *inode = file->f_dentry->d_inode;
25361 + unsigned long page;
25362 + ssize_t length = 0;
25364 + if (count > PROC_BLOCK_SIZE)
25365 + count = PROC_BLOCK_SIZE;
25367 + /* fade that out as soon as stable */
25368 + WARN_ON(PROC_I(inode)->fd);
25370 + if (!(page = __get_free_page(GFP_KERNEL)))
25373 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
25374 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
25377 + length = simple_read_from_buffer(buf, count, ppos,
25378 + (char *)page, length);
25384 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
25385 + size_t count, loff_t *ppos)
25387 + struct inode *inode = file->f_dentry->d_inode;
25388 + struct vx_info *vxi = NULL;
25389 + xid_t xid = PROC_I(inode)->fd;
25390 + unsigned long page;
25391 + ssize_t length = 0;
25393 + if (count > PROC_BLOCK_SIZE)
25394 + count = PROC_BLOCK_SIZE;
25396 + /* fade that out as soon as stable */
25398 + vxi = lookup_vx_info(xid);
25402 + length = -ENOMEM;
25403 + if (!(page = __get_free_page(GFP_KERNEL)))
25406 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
25407 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
25410 + length = simple_read_from_buffer(buf, count, ppos,
25411 + (char *)page, length);
25415 + put_vx_info(vxi);
25420 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
25421 + size_t count, loff_t *ppos)
25423 + struct inode *inode = file->f_dentry->d_inode;
25424 + struct nx_info *nxi = NULL;
25425 + nid_t nid = PROC_I(inode)->fd;
25426 + unsigned long page;
25427 + ssize_t length = 0;
25429 + if (count > PROC_BLOCK_SIZE)
25430 + count = PROC_BLOCK_SIZE;
25432 + /* fade that out as soon as stable */
25434 + nxi = lookup_nx_info(nid);
25438 + length = -ENOMEM;
25439 + if (!(page = __get_free_page(GFP_KERNEL)))
25442 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
25443 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
25446 + length = simple_read_from_buffer(buf, count, ppos,
25447 + (char *)page, length);
25451 + put_nx_info(nxi);
25458 +/* here comes the lower level */
25461 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
25462 + .len = sizeof(NAME) - 1, \
25463 + .name = (NAME), \
25471 +#define DIR(NAME, MODE, OTYPE) \
25472 + NOD(NAME, (S_IFDIR | (MODE)), \
25473 + &proc_ ## OTYPE ## _inode_operations, \
25474 + &proc_ ## OTYPE ## _file_operations, { } )
25476 +#define INF(NAME, MODE, OTYPE) \
25477 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25478 + &proc_vs_info_file_operations, \
25479 + { .proc_vs_read = &proc_##OTYPE } )
25481 +#define VINF(NAME, MODE, OTYPE) \
25482 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25483 + &proc_vx_info_file_operations, \
25484 + { .proc_vxi_read = &proc_##OTYPE } )
25486 +#define NINF(NAME, MODE, OTYPE) \
25487 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25488 + &proc_nx_info_file_operations, \
25489 + { .proc_nxi_read = &proc_##OTYPE } )
25492 +static struct file_operations proc_vs_info_file_operations = {
25493 + .read = proc_vs_info_read,
25496 +static struct file_operations proc_vx_info_file_operations = {
25497 + .read = proc_vx_info_read,
25500 +static struct dentry_operations proc_xid_dentry_operations = {
25501 + .d_revalidate = proc_xid_revalidate,
25504 +static struct vs_entry vx_base_stuff[] = {
25505 + VINF("info", S_IRUGO, vxi_info),
25506 + VINF("status", S_IRUGO, vxi_status),
25507 + VINF("limit", S_IRUGO, vxi_limit),
25508 + VINF("sched", S_IRUGO, vxi_sched),
25509 + VINF("nsproxy", S_IRUGO, vxi_nsproxy),
25510 + VINF("cvirt", S_IRUGO, vxi_cvirt),
25511 + VINF("cacct", S_IRUGO, vxi_cacct),
25518 +static struct dentry *proc_xid_instantiate(struct inode *dir,
25519 + struct dentry *dentry, int id, void *ptr)
25521 + dentry->d_op = &proc_xid_dentry_operations;
25522 + return vs_proc_instantiate(dir, dentry, id, ptr);
25525 +static struct dentry *proc_xid_lookup(struct inode *dir,
25526 + struct dentry *dentry, struct nameidata *nd)
25528 + struct vs_entry *p = vx_base_stuff;
25529 + struct dentry *error = ERR_PTR(-ENOENT);
25531 + for (; p->name; p++) {
25532 + if (p->len != dentry->d_name.len)
25534 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25540 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
25545 +static int proc_xid_readdir(struct file *filp,
25546 + void *dirent, filldir_t filldir)
25548 + struct dentry *dentry = filp->f_dentry;
25549 + struct inode *inode = dentry->d_inode;
25550 + struct vs_entry *p = vx_base_stuff;
25551 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
25555 + pos = filp->f_pos;
25558 + ino = inode->i_ino;
25559 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25562 + /* fall through */
25564 + ino = parent_ino(dentry);
25565 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25568 + /* fall through */
25571 + if (index >= size)
25573 + for (p += index; p->name; p++) {
25574 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25575 + vs_proc_instantiate, PROC_I(inode)->fd, p))
25581 + filp->f_pos = pos;
25587 +static struct file_operations proc_nx_info_file_operations = {
25588 + .read = proc_nx_info_read,
25591 +static struct dentry_operations proc_nid_dentry_operations = {
25592 + .d_revalidate = proc_nid_revalidate,
25595 +static struct vs_entry nx_base_stuff[] = {
25596 + NINF("info", S_IRUGO, nxi_info),
25597 + NINF("status", S_IRUGO, nxi_status),
25602 +static struct dentry *proc_nid_instantiate(struct inode *dir,
25603 + struct dentry *dentry, int id, void *ptr)
25605 + dentry->d_op = &proc_nid_dentry_operations;
25606 + return vs_proc_instantiate(dir, dentry, id, ptr);
25609 +static struct dentry *proc_nid_lookup(struct inode *dir,
25610 + struct dentry *dentry, struct nameidata *nd)
25612 + struct vs_entry *p = nx_base_stuff;
25613 + struct dentry *error = ERR_PTR(-ENOENT);
25615 + for (; p->name; p++) {
25616 + if (p->len != dentry->d_name.len)
25618 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25624 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
25629 +static int proc_nid_readdir(struct file *filp,
25630 + void *dirent, filldir_t filldir)
25632 + struct dentry *dentry = filp->f_dentry;
25633 + struct inode *inode = dentry->d_inode;
25634 + struct vs_entry *p = nx_base_stuff;
25635 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
25639 + pos = filp->f_pos;
25642 + ino = inode->i_ino;
25643 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25646 + /* fall through */
25648 + ino = parent_ino(dentry);
25649 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25652 + /* fall through */
25655 + if (index >= size)
25657 + for (p += index; p->name; p++) {
25658 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25659 + vs_proc_instantiate, PROC_I(inode)->fd, p))
25665 + filp->f_pos = pos;
25670 +#define MAX_MULBY10 ((~0U - 9) / 10)
25672 +static inline int atovid(const char *str, int len)
25677 + while (len-- > 0) {
25682 + if (vid >= MAX_MULBY10)
25692 +/* now the upper level (virtual) */
25695 +static struct file_operations proc_xid_file_operations = {
25696 + .read = generic_read_dir,
25697 + .readdir = proc_xid_readdir,
25700 +static struct inode_operations proc_xid_inode_operations = {
25701 + .lookup = proc_xid_lookup,
25704 +static struct vs_entry vx_virtual_stuff[] = {
25705 + INF("info", S_IRUGO, virtual_info),
25706 + INF("status", S_IRUGO, virtual_status),
25707 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
25711 +static struct dentry *proc_virtual_lookup(struct inode *dir,
25712 + struct dentry *dentry, struct nameidata *nd)
25714 + struct vs_entry *p = vx_virtual_stuff;
25715 + struct dentry *error = ERR_PTR(-ENOENT);
25718 + for (; p->name; p++) {
25719 + if (p->len != dentry->d_name.len)
25721 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25725 + goto instantiate;
25727 + id = atovid(dentry->d_name.name, dentry->d_name.len);
25728 + if ((id < 0) || !xid_is_hashed(id))
25732 + error = proc_xid_instantiate(dir, dentry, id, p);
25737 +static struct file_operations proc_nid_file_operations = {
25738 + .read = generic_read_dir,
25739 + .readdir = proc_nid_readdir,
25742 +static struct inode_operations proc_nid_inode_operations = {
25743 + .lookup = proc_nid_lookup,
25746 +static struct vs_entry nx_virtnet_stuff[] = {
25747 + INF("info", S_IRUGO, virtnet_info),
25748 + INF("status", S_IRUGO, virtnet_status),
25749 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
25753 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
25754 + struct dentry *dentry, struct nameidata *nd)
25756 + struct vs_entry *p = nx_virtnet_stuff;
25757 + struct dentry *error = ERR_PTR(-ENOENT);
25760 + for (; p->name; p++) {
25761 + if (p->len != dentry->d_name.len)
25763 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25767 + goto instantiate;
25769 + id = atovid(dentry->d_name.name, dentry->d_name.len);
25770 + if ((id < 0) || !nid_is_hashed(id))
25774 + error = proc_nid_instantiate(dir, dentry, id, p);
25781 +#define PROC_NUMBUF 10
25782 +#define PROC_MAXVIDS 32
25784 +int proc_virtual_readdir(struct file *filp,
25785 + void *dirent, filldir_t filldir)
25787 + struct dentry *dentry = filp->f_dentry;
25788 + struct inode *inode = dentry->d_inode;
25789 + struct vs_entry *p = vx_virtual_stuff;
25790 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
25792 + unsigned int xid_array[PROC_MAXVIDS];
25793 + char buf[PROC_NUMBUF];
25794 + unsigned int nr_xids, i;
25797 + pos = filp->f_pos;
25800 + ino = inode->i_ino;
25801 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25804 + /* fall through */
25806 + ino = parent_ino(dentry);
25807 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25810 + /* fall through */
25813 + if (index >= size)
25815 + for (p += index; p->name; p++) {
25816 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25817 + vs_proc_instantiate, 0, p))
25822 + index = pos - size;
25823 + p = &vx_virtual_stuff[size - 1];
25824 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
25825 + for (i = 0; i < nr_xids; i++) {
25826 + int n, xid = xid_array[i];
25827 + unsigned int j = PROC_NUMBUF;
25831 + buf[--j] = '0' + (n % 10);
25834 + if (proc_fill_cache(filp, dirent, filldir,
25835 + buf + j, PROC_NUMBUF - j,
25836 + vs_proc_instantiate, xid, p))
25842 + filp->f_pos = pos;
25846 +static int proc_virtual_getattr(struct vfsmount *mnt,
25847 + struct dentry *dentry, struct kstat *stat)
25849 + struct inode *inode = dentry->d_inode;
25851 + generic_fillattr(inode, stat);
25852 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
25856 +static struct file_operations proc_virtual_dir_operations = {
25857 + .read = generic_read_dir,
25858 + .readdir = proc_virtual_readdir,
25861 +static struct inode_operations proc_virtual_dir_inode_operations = {
25862 + .getattr = proc_virtual_getattr,
25863 + .lookup = proc_virtual_lookup,
25870 +int proc_virtnet_readdir(struct file *filp,
25871 + void *dirent, filldir_t filldir)
25873 + struct dentry *dentry = filp->f_dentry;
25874 + struct inode *inode = dentry->d_inode;
25875 + struct vs_entry *p = nx_virtnet_stuff;
25876 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
25878 + unsigned int nid_array[PROC_MAXVIDS];
25879 + char buf[PROC_NUMBUF];
25880 + unsigned int nr_nids, i;
25883 + pos = filp->f_pos;
25886 + ino = inode->i_ino;
25887 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25890 + /* fall through */
25892 + ino = parent_ino(dentry);
25893 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25896 + /* fall through */
25899 + if (index >= size)
25901 + for (p += index; p->name; p++) {
25902 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25903 + vs_proc_instantiate, 0, p))
25908 + index = pos - size;
25909 + p = &nx_virtnet_stuff[size - 1];
25910 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
25911 + for (i = 0; i < nr_nids; i++) {
25912 + int n, nid = nid_array[i];
25913 + unsigned int j = PROC_NUMBUF;
25917 + buf[--j] = '0' + (n % 10);
25920 + if (proc_fill_cache(filp, dirent, filldir,
25921 + buf + j, PROC_NUMBUF - j,
25922 + vs_proc_instantiate, nid, p))
25928 + filp->f_pos = pos;
25932 +static int proc_virtnet_getattr(struct vfsmount *mnt,
25933 + struct dentry *dentry, struct kstat *stat)
25935 + struct inode *inode = dentry->d_inode;
25937 + generic_fillattr(inode, stat);
25938 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
25942 +static struct file_operations proc_virtnet_dir_operations = {
25943 + .read = generic_read_dir,
25944 + .readdir = proc_virtnet_readdir,
25947 +static struct inode_operations proc_virtnet_dir_inode_operations = {
25948 + .getattr = proc_virtnet_getattr,
25949 + .lookup = proc_virtnet_lookup,
25954 +void proc_vx_init(void)
25956 + struct proc_dir_entry *ent;
25958 + ent = proc_mkdir("virtual", 0);
25960 + ent->proc_fops = &proc_virtual_dir_operations;
25961 + ent->proc_iops = &proc_virtual_dir_inode_operations;
25963 + proc_virtual = ent;
25965 + ent = proc_mkdir("virtnet", 0);
25967 + ent->proc_fops = &proc_virtnet_dir_operations;
25968 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
25970 + proc_virtnet = ent;
25976 +/* per pid info */
25979 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
25981 + struct vx_info *vxi;
25982 + char *orig = buffer;
25984 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
25986 + vxi = task_get_vx_info(p);
25990 + buffer += sprintf(buffer, "BCaps:\t%016llx\n",
25991 + (unsigned long long)vxi->vx_bcaps);
25992 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
25993 + (unsigned long long)vxi->vx_ccaps);
25994 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
25995 + (unsigned long long)vxi->vx_flags);
25996 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
25998 + put_vx_info(vxi);
26000 + return buffer - orig;
26004 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
26006 + struct nx_info *nxi;
26007 + struct nx_addr_v4 *v4a;
26008 +#ifdef CONFIG_IPV6
26009 + struct nx_addr_v6 *v6a;
26011 + char *orig = buffer;
26014 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
26016 + nxi = task_get_nx_info(p);
26020 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
26021 + (unsigned long long)nxi->nx_ncaps);
26022 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
26023 + (unsigned long long)nxi->nx_flags);
26025 + buffer += sprintf(buffer,
26026 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
26027 + NIPQUAD(nxi->v4_bcast.s_addr));
26028 + buffer += sprintf (buffer,
26029 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
26030 + NIPQUAD(nxi->v4_lback.s_addr));
26031 + if (!NX_IPV4(nxi))
26033 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
26034 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
26037 +#ifdef CONFIG_IPV6
26038 + if (!NX_IPV6(nxi))
26040 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
26041 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
26045 + put_nx_info(nxi);
26047 + return buffer - orig;
26050 diff -Nurp linux-2.6.22.15/kernel/vserver/sched.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/sched.c
26051 --- linux-2.6.22.15/kernel/vserver/sched.c 1969-12-31 19:00:00.000000000 -0500
26052 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/sched.c 2007-12-09 06:44:23.000000000 -0500
26055 + * linux/kernel/vserver/sched.c
26057 + * Virtual Server: Scheduler Support
26059 + * Copyright (C) 2004-2007 Herbert Pötzl
26061 + * V0.01 adapted Sam Vilains version to 2.6.3
26062 + * V0.02 removed legacy interface
26063 + * V0.03 changed vcmds to vxi arg
26064 + * V0.04 removed older and legacy interfaces
26068 +#include <linux/vs_context.h>
26069 +#include <linux/vs_sched.h>
26070 +#include <linux/vserver/sched_cmd.h>
26072 +#include <asm/uaccess.h>
26075 +#define vxd_check_range(val, min, max) do { \
26076 + vxlprintk((val < min) || (val > max), \
26077 + "check_range(%ld,%ld,%ld)", \
26078 + (long)val, (long)min, (long)max, \
26079 + __FILE__, __LINE__); \
26083 +void vx_update_sched_param(struct _vx_sched *sched,
26084 + struct _vx_sched_pc *sched_pc)
26086 + unsigned int set_mask = sched->update_mask;
26088 + if (set_mask & VXSM_FILL_RATE)
26089 + sched_pc->fill_rate[0] = sched->fill_rate[0];
26090 + if (set_mask & VXSM_INTERVAL)
26091 + sched_pc->interval[0] = sched->interval[0];
26092 + if (set_mask & VXSM_FILL_RATE2)
26093 + sched_pc->fill_rate[1] = sched->fill_rate[1];
26094 + if (set_mask & VXSM_INTERVAL2)
26095 + sched_pc->interval[1] = sched->interval[1];
26096 + if (set_mask & VXSM_TOKENS)
26097 + sched_pc->tokens = sched->tokens;
26098 + if (set_mask & VXSM_TOKENS_MIN)
26099 + sched_pc->tokens_min = sched->tokens_min;
26100 + if (set_mask & VXSM_TOKENS_MAX)
26101 + sched_pc->tokens_max = sched->tokens_max;
26102 + if (set_mask & VXSM_PRIO_BIAS)
26103 + sched_pc->prio_bias = sched->prio_bias;
26105 + if (set_mask & VXSM_IDLE_TIME)
26106 + sched_pc->flags |= VXSF_IDLE_TIME;
26108 + sched_pc->flags &= ~VXSF_IDLE_TIME;
26111 + sched_pc->norm_time = jiffies;
26116 + * recalculate the context's scheduling tokens
26118 + * ret > 0 : number of tokens available
26119 + * ret < 0 : on hold, check delta_min[]
26120 + * -1 only jiffies
26121 + * -2 also idle time
26124 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
26125 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
26129 + int flags = sched_pc->flags;
26131 + /* how much time did pass? */
26132 + delta = *norm_time - sched_pc->norm_time;
26133 + vxd_check_range(delta, 0, INT_MAX);
26135 + if (delta >= sched_pc->interval[0]) {
26136 + long tokens, integral;
26138 + /* calc integral token part */
26139 + tokens = delta / sched_pc->interval[0];
26140 + integral = tokens * sched_pc->interval[0];
26141 + tokens *= sched_pc->fill_rate[0];
26142 +#ifdef CONFIG_VSERVER_HARDCPU
26143 + delta_min[0] = delta - integral;
26144 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
26146 + /* advance time */
26147 + sched_pc->norm_time += delta;
26150 + sched_pc->tokens += tokens;
26151 + sched_pc->token_time += tokens;
26153 + delta_min[0] = delta;
26155 +#ifdef CONFIG_VSERVER_IDLETIME
26156 + if (!(flags & VXSF_IDLE_TIME))
26159 + /* how much was the idle skip? */
26160 + delta = *idle_time - sched_pc->idle_time;
26161 + vxd_check_range(delta, 0, INT_MAX);
26163 + if (delta >= sched_pc->interval[1]) {
26164 + long tokens, integral;
26166 + /* calc fair share token part */
26167 + tokens = delta / sched_pc->interval[1];
26168 + integral = tokens * sched_pc->interval[1];
26169 + tokens *= sched_pc->fill_rate[1];
26170 + delta_min[1] = delta - integral;
26171 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
26173 + /* advance idle time */
26174 + sched_pc->idle_time += integral;
26177 + sched_pc->tokens += tokens;
26178 + sched_pc->token_time += tokens;
26180 + delta_min[1] = delta;
26184 + /* clip at maximum */
26185 + if (sched_pc->tokens > sched_pc->tokens_max)
26186 + sched_pc->tokens = sched_pc->tokens_max;
26187 + tokens = sched_pc->tokens;
26189 + if ((flags & VXSF_ONHOLD)) {
26190 + /* can we unhold? */
26191 + if (tokens >= sched_pc->tokens_min) {
26192 + flags &= ~VXSF_ONHOLD;
26193 + sched_pc->hold_ticks +=
26194 + *norm_time - sched_pc->onhold;
26198 + /* put on hold? */
26199 + if (tokens <= 0) {
26200 + flags |= VXSF_ONHOLD;
26201 + sched_pc->onhold = *norm_time;
26205 + sched_pc->flags = flags;
26209 + tokens = sched_pc->tokens_min - tokens;
26210 + sched_pc->flags = flags;
26211 + BUG_ON(tokens < 0);
26213 +#ifdef CONFIG_VSERVER_HARDCPU
26214 + /* next interval? */
26215 + if (!sched_pc->fill_rate[0])
26216 + delta_min[0] = HZ;
26217 + else if (tokens > sched_pc->fill_rate[0])
26218 + delta_min[0] += sched_pc->interval[0] *
26219 + tokens / sched_pc->fill_rate[0];
26221 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
26222 + vxd_check_range(delta_min[0], 0, INT_MAX);
26224 +#ifdef CONFIG_VSERVER_IDLETIME
26225 + if (!(flags & VXSF_IDLE_TIME))
26228 + /* next interval? */
26229 + if (!sched_pc->fill_rate[1])
26230 + delta_min[1] = HZ;
26231 + else if (tokens > sched_pc->fill_rate[1])
26232 + delta_min[1] += sched_pc->interval[1] *
26233 + tokens / sched_pc->fill_rate[1];
26235 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
26236 + vxd_check_range(delta_min[1], 0, INT_MAX);
26241 +#endif /* CONFIG_VSERVER_IDLETIME */
26244 +#endif /* CONFIG_VSERVER_HARDCPU */
26247 +static inline unsigned long msec_to_ticks(unsigned long msec)
26249 + return msecs_to_jiffies(msec);
26252 +static inline unsigned long ticks_to_msec(unsigned long ticks)
26254 + return jiffies_to_msecs(ticks);
26257 +static inline unsigned long ticks_to_usec(unsigned long ticks)
26259 + return jiffies_to_usecs(ticks);
26263 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
26265 + unsigned int set_mask = data->mask;
26266 + unsigned int update_mask;
26269 + /* Sanity check data values */
26270 + if (data->tokens_max <= 0)
26271 + data->tokens_max = HZ;
26272 + if (data->tokens_min < 0)
26273 + data->tokens_min = HZ / 3;
26274 + if (data->tokens_min >= data->tokens_max)
26275 + data->tokens_min = data->tokens_max;
26277 + if (data->prio_bias > MAX_PRIO_BIAS)
26278 + data->prio_bias = MAX_PRIO_BIAS;
26279 + if (data->prio_bias < MIN_PRIO_BIAS)
26280 + data->prio_bias = MIN_PRIO_BIAS;
26282 + spin_lock(&vxi->sched.tokens_lock);
26284 + /* sync up on delayed updates */
26285 + for_each_cpu_mask(cpu, vxi->sched.update)
26286 + vx_update_sched_param(&vxi->sched,
26287 + &vx_per_cpu(vxi, sched_pc, cpu));
26289 + if (set_mask & VXSM_FILL_RATE)
26290 + vxi->sched.fill_rate[0] = data->fill_rate[0];
26291 + if (set_mask & VXSM_FILL_RATE2)
26292 + vxi->sched.fill_rate[1] = data->fill_rate[1];
26293 + if (set_mask & VXSM_INTERVAL)
26294 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
26295 + msec_to_ticks(data->interval[0]) : data->interval[0];
26296 + if (set_mask & VXSM_INTERVAL2)
26297 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
26298 + msec_to_ticks(data->interval[1]) : data->interval[1];
26299 + if (set_mask & VXSM_TOKENS)
26300 + vxi->sched.tokens = data->tokens;
26301 + if (set_mask & VXSM_TOKENS_MIN)
26302 + vxi->sched.tokens_min = data->tokens_min;
26303 + if (set_mask & VXSM_TOKENS_MAX)
26304 + vxi->sched.tokens_max = data->tokens_max;
26305 + if (set_mask & VXSM_PRIO_BIAS)
26306 + vxi->sched.prio_bias = data->prio_bias;
26308 + /* Sanity check rate/interval */
26309 + for (i = 0; i < 2; i++) {
26310 + if (data->fill_rate[i] < 0)
26311 + data->fill_rate[i] = 0;
26312 + if (data->interval[i] <= 0)
26313 + data->interval[i] = HZ;
26316 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
26317 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
26318 + vxi->sched.update_mask = update_mask;
26322 + if (set_mask & VXSM_CPU_ID) {
26323 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
26324 + cpus_and(vxi->sched.update, cpu_online_map,
26325 + vxi->sched.update);
26327 + vxi->sched.update = cpu_online_map;
26329 + /* forced reload? */
26330 + if (set_mask & VXSM_FORCE) {
26331 + for_each_cpu_mask(cpu, vxi->sched.update)
26332 + vx_update_sched_param(&vxi->sched,
26333 + &vx_per_cpu(vxi, sched_pc, cpu));
26334 + vxi->sched.update = CPU_MASK_NONE;
26337 + /* on UP we update immediately */
26338 + vx_update_sched_param(&vxi->sched,
26339 + &vx_per_cpu(vxi, sched_pc, 0));
26342 + spin_unlock(&vxi->sched.tokens_lock);
26347 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
26348 +#define COPY_PRI(C) C(prio_bias)
26349 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
26350 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
26351 + C(fill_rate[1]); C(interval[1]);
26353 +#define COPY_VALUE(name) vc_data.name = data->name
26355 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
26357 + struct vcmd_sched_v5 vc_data;
26359 + vc_data.mask = data->set_mask;
26360 + COPY_IDS(COPY_VALUE);
26361 + COPY_PRI(COPY_VALUE);
26362 + COPY_TOK(COPY_VALUE);
26363 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
26364 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
26365 + return do_set_sched(vxi, &vc_data);
26368 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
26370 + struct vcmd_set_sched_v4 vc_data;
26372 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26375 + return do_set_sched_v4(vxi, &vc_data);
26378 + /* latest interface is v5 */
26380 +int vc_set_sched(struct vx_info *vxi, void __user *data)
26382 + struct vcmd_sched_v5 vc_data;
26384 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26387 + return do_set_sched(vxi, &vc_data);
26391 +#define COPY_PRI(C) C(prio_bias)
26392 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
26393 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
26394 + C(fill_rate[1]); C(interval[1]);
26396 +#define COPY_VALUE(name) vc_data.name = data->name
26399 +int vc_get_sched(struct vx_info *vxi, void __user *data)
26401 + struct vcmd_sched_v5 vc_data;
26403 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26406 + if (vc_data.mask & VXSM_CPU_ID) {
26407 + int cpu = vc_data.cpu_id;
26408 + struct _vx_sched_pc *data;
26410 + if (!cpu_possible(cpu))
26413 + data = &vx_per_cpu(vxi, sched_pc, cpu);
26414 + COPY_TOK(COPY_VALUE);
26415 + COPY_PRI(COPY_VALUE);
26416 + COPY_FRI(COPY_VALUE);
26418 + if (data->flags & VXSF_IDLE_TIME)
26419 + vc_data.mask |= VXSM_IDLE_TIME;
26421 + struct _vx_sched *data = &vxi->sched;
26423 + COPY_TOK(COPY_VALUE);
26424 + COPY_PRI(COPY_VALUE);
26425 + COPY_FRI(COPY_VALUE);
26428 + if (vc_data.mask & VXSM_MSEC) {
26429 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
26430 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
26433 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26439 +int vc_sched_info(struct vx_info *vxi, void __user *data)
26441 + struct vcmd_sched_info vc_data;
26444 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26447 + cpu = vc_data.cpu_id;
26448 + if (!cpu_possible(cpu))
26452 + struct _vx_sched_pc *sched_pc =
26453 + &vx_per_cpu(vxi, sched_pc, cpu);
26455 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
26456 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
26457 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
26458 + vc_data.vavavoom = sched_pc->vavavoom;
26460 + vc_data.token_usec = ticks_to_usec(1);
26462 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26467 diff -Nurp linux-2.6.22.15/kernel/vserver/sched_init.h linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/sched_init.h
26468 --- linux-2.6.22.15/kernel/vserver/sched_init.h 1969-12-31 19:00:00.000000000 -0500
26469 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/sched_init.h 2007-12-09 06:44:23.000000000 -0500
26472 +static inline void vx_info_init_sched(struct _vx_sched *sched)
26474 + static struct lock_class_key tokens_lock_key;
26476 + /* scheduling; hard code starting values as constants */
26477 + sched->fill_rate[0] = 1;
26478 + sched->interval[0] = 4;
26479 + sched->fill_rate[1] = 1;
26480 + sched->interval[1] = 8;
26481 + sched->tokens = HZ >> 2;
26482 + sched->tokens_min = HZ >> 4;
26483 + sched->tokens_max = HZ >> 1;
26484 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
26485 + sched->prio_bias = 0;
26487 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
26491 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
26493 + sched_pc->fill_rate[0] = 1;
26494 + sched_pc->interval[0] = 4;
26495 + sched_pc->fill_rate[1] = 1;
26496 + sched_pc->interval[1] = 8;
26497 + sched_pc->tokens = HZ >> 2;
26498 + sched_pc->tokens_min = HZ >> 4;
26499 + sched_pc->tokens_max = HZ >> 1;
26500 + sched_pc->prio_bias = 0;
26501 + sched_pc->vavavoom = 0;
26502 + sched_pc->token_time = 0;
26503 + sched_pc->idle_time = 0;
26504 + sched_pc->norm_time = jiffies;
26506 + sched_pc->user_ticks = 0;
26507 + sched_pc->sys_ticks = 0;
26508 + sched_pc->hold_ticks = 0;
26511 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
26517 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
26521 diff -Nurp linux-2.6.22.15/kernel/vserver/sched_proc.h linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/sched_proc.h
26522 --- linux-2.6.22.15/kernel/vserver/sched_proc.h 1969-12-31 19:00:00.000000000 -0500
26523 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/sched_proc.h 2007-12-09 06:44:23.000000000 -0500
26525 +#ifndef _VX_SCHED_PROC_H
26526 +#define _VX_SCHED_PROC_H
26530 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
26534 + length += sprintf(buffer,
26535 + "FillRate:\t%8d,%d\n"
26536 + "Interval:\t%8d,%d\n"
26537 + "TokensMin:\t%8d\n"
26538 + "TokensMax:\t%8d\n"
26539 + "PrioBias:\t%8d\n",
26540 + sched->fill_rate[0],
26541 + sched->fill_rate[1],
26542 + sched->interval[0],
26543 + sched->interval[1],
26544 + sched->tokens_min,
26545 + sched->tokens_max,
26546 + sched->prio_bias);
26551 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
26552 + char *buffer, int cpu)
26556 + length += sprintf(buffer + length,
26557 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
26558 + (unsigned long long)sched_pc->user_ticks,
26559 + (unsigned long long)sched_pc->sys_ticks,
26560 + (unsigned long long)sched_pc->hold_ticks,
26561 + sched_pc->token_time,
26562 + sched_pc->idle_time);
26563 + length += sprintf(buffer + length,
26564 + " %c%c %d %d %d %d/%d %d/%d",
26565 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
26566 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
26567 + sched_pc->tokens,
26568 + sched_pc->tokens_min,
26569 + sched_pc->tokens_max,
26570 + sched_pc->fill_rate[0],
26571 + sched_pc->interval[0],
26572 + sched_pc->fill_rate[1],
26573 + sched_pc->interval[1]);
26574 + length += sprintf(buffer + length,
26576 + sched_pc->prio_bias,
26577 + sched_pc->vavavoom);
26581 +#endif /* _VX_SCHED_PROC_H */
26582 diff -Nurp linux-2.6.22.15/kernel/vserver/signal.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/signal.c
26583 --- linux-2.6.22.15/kernel/vserver/signal.c 1969-12-31 19:00:00.000000000 -0500
26584 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/signal.c 2007-12-09 06:44:23.000000000 -0500
26587 + * linux/kernel/vserver/signal.c
26589 + * Virtual Server: Signal Support
26591 + * Copyright (C) 2003-2007 Herbert Pötzl
26593 + * V0.01 broken out from vcontext V0.05
26594 + * V0.02 changed vcmds to vxi arg
26595 + * V0.03 adjusted siginfo for kill
26599 +#include <asm/uaccess.h>
26601 +#include <linux/vs_context.h>
26602 +#include <linux/vserver/signal_cmd.h>
26605 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
26607 + int retval, count = 0;
26608 + struct task_struct *p;
26609 + struct siginfo *sip = SEND_SIG_PRIV;
26612 + vxdprintk(VXD_CBIT(misc, 4),
26613 + "vx_info_kill(%p[#%d],%d,%d)*",
26614 + vxi, vxi->vx_id, pid, sig);
26615 + read_lock(&tasklist_lock);
26619 + for_each_process(p) {
26622 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
26623 + (pid && vxi->vx_initpid == p->pid))
26626 + err = group_send_sig_info(sig, sip, p);
26628 + if (err != -EPERM)
26634 + if (vxi->vx_initpid) {
26635 + pid = vxi->vx_initpid;
26636 + /* for now, only SIGINT to private init ... */
26637 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
26638 + /* ... as long as there are tasks left */
26639 + (atomic_read(&vxi->vx_tasks) > 1))
26642 + /* fallthrough */
26644 + p = find_task_by_real_pid(pid);
26646 + if (vx_task_xid(p) == vxi->vx_id)
26647 + retval = group_send_sig_info(sig, sip, p);
26651 + read_unlock(&tasklist_lock);
26652 + vxdprintk(VXD_CBIT(misc, 4),
26653 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
26654 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
26658 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
26660 + struct vcmd_ctx_kill_v0 vc_data;
26662 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26665 + /* special check to allow guest shutdown */
26666 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
26667 + /* forbid killall pid=0 when init is present */
26668 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
26669 + (vc_data.pid > 1)))
26672 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
26676 +static int __wait_exit(struct vx_info *vxi)
26678 + DECLARE_WAITQUEUE(wait, current);
26681 + add_wait_queue(&vxi->vx_wait, &wait);
26682 + set_current_state(TASK_INTERRUPTIBLE);
26685 + if (vx_info_state(vxi,
26686 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
26688 + if (signal_pending(current)) {
26689 + ret = -ERESTARTSYS;
26696 + set_current_state(TASK_RUNNING);
26697 + remove_wait_queue(&vxi->vx_wait, &wait);
26703 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
26705 + struct vcmd_wait_exit_v0 vc_data;
26708 + ret = __wait_exit(vxi);
26709 + vc_data.reboot_cmd = vxi->reboot_cmd;
26710 + vc_data.exit_code = vxi->exit_code;
26712 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26717 diff -Nurp linux-2.6.22.15/kernel/vserver/space.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/space.c
26718 --- linux-2.6.22.15/kernel/vserver/space.c 1969-12-31 19:00:00.000000000 -0500
26719 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/space.c 2007-12-09 06:44:23.000000000 -0500
26722 + * linux/kernel/vserver/space.c
26724 + * Virtual Server: Context Space Support
26726 + * Copyright (C) 2003-2007 Herbert Pötzl
26728 + * V0.01 broken out from context.c 0.07
26729 + * V0.02 added task locking for namespace
26730 + * V0.03 broken out vx_enter_namespace
26731 + * V0.04 added *space support and commands
26735 +#include <linux/utsname.h>
26736 +#include <linux/nsproxy.h>
26737 +#include <linux/err.h>
26738 +#include <asm/uaccess.h>
26740 +#include <linux/vs_context.h>
26741 +#include <linux/vserver/space.h>
26742 +#include <linux/vserver/space_cmd.h>
26745 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
26746 +atomic_t vs_global_fs = ATOMIC_INIT(0);
26747 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
26748 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
26749 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
26752 +/* namespace functions */
26754 +#include <linux/mnt_namespace.h>
26756 +const struct vcmd_space_mask space_mask = {
26757 + .mask = CLONE_NEWNS |
26765 + * build a new nsproxy mix
26766 + * assumes that both proxies are 'const'
26767 + * does not touch nsproxy refcounts
26768 + * will hold a reference on the result.
26771 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
26772 + struct nsproxy *new_nsproxy, unsigned long mask)
26774 + struct mnt_namespace *old_ns;
26775 + struct uts_namespace *old_uts;
26776 + struct ipc_namespace *old_ipc;
26777 + struct nsproxy *nsproxy;
26779 + nsproxy = copy_nsproxy(old_nsproxy);
26783 + if (mask & CLONE_NEWNS) {
26784 + old_ns = nsproxy->mnt_ns;
26785 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
26786 + if (nsproxy->mnt_ns)
26787 + get_mnt_ns(nsproxy->mnt_ns);
26791 + if (mask & CLONE_NEWUTS) {
26792 + old_uts = nsproxy->uts_ns;
26793 + nsproxy->uts_ns = new_nsproxy->uts_ns;
26794 + if (nsproxy->uts_ns)
26795 + get_uts_ns(nsproxy->uts_ns);
26799 + if (mask & CLONE_NEWIPC) {
26800 + old_ipc = nsproxy->ipc_ns;
26801 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
26802 + if (nsproxy->ipc_ns)
26803 + get_ipc_ns(nsproxy->ipc_ns);
26808 + put_mnt_ns(old_ns);
26810 + put_uts_ns(old_uts);
26812 + put_ipc_ns(old_ipc);
26819 + * merge two nsproxy structs into a new one.
26820 + * will hold a reference on the result.
26824 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
26825 + struct nsproxy *proxy, unsigned long mask)
26827 + struct nsproxy null_proxy = { .mnt_ns = NULL };
26833 + /* vs_mix_nsproxy returns with reference */
26834 + return vs_mix_nsproxy(old ? old : &null_proxy,
26837 + get_nsproxy(proxy);
26842 + * merge two fs structs into a new one.
26843 + * will take a reference on the result.
26847 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
26848 + struct fs_struct *fs, unsigned long mask)
26850 + if (!(mask & CLONE_FS)) {
26852 + atomic_inc(&old->count);
26859 + return copy_fs_struct(fs);
26863 +int vx_enter_space(struct vx_info *vxi, unsigned long mask)
26865 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
26866 + struct fs_struct *fs, *fs_cur, *fs_new;
26869 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
26873 + mask = vxi->vx_nsmask;
26875 + if ((mask & vxi->vx_nsmask) != mask)
26878 + proxy = vxi->vx_nsproxy;
26881 + task_lock(current);
26882 + fs_cur = current->fs;
26883 + atomic_inc(&fs_cur->count);
26884 + proxy_cur = current->nsproxy;
26885 + get_nsproxy(proxy_cur);
26886 + task_unlock(current);
26888 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
26889 + if (IS_ERR(fs_new)) {
26890 + ret = PTR_ERR(fs_new);
26894 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
26895 + if (IS_ERR(proxy_new)) {
26896 + ret = PTR_ERR(proxy_new);
26900 + fs_new = xchg(¤t->fs, fs_new);
26901 + proxy_new = xchg(¤t->nsproxy, proxy_new);
26905 + put_nsproxy(proxy_new);
26908 + put_fs_struct(fs_new);
26911 + put_nsproxy(proxy_cur);
26913 + put_fs_struct(fs_cur);
26918 +int vx_set_space(struct vx_info *vxi, unsigned long mask)
26920 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
26921 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
26925 + mask = space_mask.mask;
26927 + if ((mask & space_mask.mask) != mask)
26930 + proxy_vxi = vxi->vx_nsproxy;
26931 + fs_vxi = vxi->vx_fs;
26933 + task_lock(current);
26934 + fs_cur = current->fs;
26935 + atomic_inc(&fs_cur->count);
26936 + proxy_cur = current->nsproxy;
26937 + get_nsproxy(proxy_cur);
26938 + task_unlock(current);
26940 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
26941 + if (IS_ERR(fs_new)) {
26942 + ret = PTR_ERR(fs_new);
26946 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
26947 + if (IS_ERR(proxy_new)) {
26948 + ret = PTR_ERR(proxy_new);
26952 + fs_new = xchg(&vxi->vx_fs, fs_new);
26953 + proxy_new = xchg(&vxi->vx_nsproxy, proxy_new);
26954 + vxi->vx_nsmask |= mask;
26958 + put_nsproxy(proxy_new);
26961 + put_fs_struct(fs_new);
26964 + put_nsproxy(proxy_cur);
26966 + put_fs_struct(fs_cur);
26971 +int vc_enter_space(struct vx_info *vxi, void __user *data)
26973 + struct vcmd_space_mask vc_data = { .mask = 0 };
26975 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
26978 + return vx_enter_space(vxi, vc_data.mask);
26981 +int vc_set_space(struct vx_info *vxi, void __user *data)
26983 + struct vcmd_space_mask vc_data = { .mask = 0 };
26985 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
26988 + return vx_set_space(vxi, vc_data.mask);
26991 +int vc_get_space_mask(struct vx_info *vxi, void __user *data)
26993 + if (copy_to_user(data, &space_mask, sizeof(space_mask)))
26998 diff -Nurp linux-2.6.22.15/kernel/vserver/switch.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/switch.c
26999 --- linux-2.6.22.15/kernel/vserver/switch.c 1969-12-31 19:00:00.000000000 -0500
27000 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/switch.c 2007-12-09 06:44:23.000000000 -0500
27003 + * linux/kernel/vserver/switch.c
27005 + * Virtual Server: Syscall Switch
27007 + * Copyright (C) 2003-2007 Herbert Pötzl
27009 + * V0.01 syscall switch
27010 + * V0.02 added signal to context
27011 + * V0.03 added rlimit functions
27012 + * V0.04 added iattr, task/xid functions
27013 + * V0.05 added debug/history stuff
27014 + * V0.06 added compat32 layer
27015 + * V0.07 vcmd args and perms
27016 + * V0.08 added status commands
27017 + * V0.09 added tag commands
27018 + * V0.10 added oom bias
27019 + * V0.11 added device commands
27023 +#include <linux/vs_context.h>
27024 +#include <linux/vs_network.h>
27025 +#include <linux/vserver/switch.h>
27027 +#include "vci_config.h"
27031 +int vc_get_version(uint32_t id)
27033 + return VCI_VERSION;
27037 +int vc_get_vci(uint32_t id)
27039 + return vci_kernel_config();
27042 +#include <linux/vserver/context_cmd.h>
27043 +#include <linux/vserver/cvirt_cmd.h>
27044 +#include <linux/vserver/cacct_cmd.h>
27045 +#include <linux/vserver/limit_cmd.h>
27046 +#include <linux/vserver/network_cmd.h>
27047 +#include <linux/vserver/sched_cmd.h>
27048 +#include <linux/vserver/debug_cmd.h>
27049 +#include <linux/vserver/inode_cmd.h>
27050 +#include <linux/vserver/dlimit_cmd.h>
27051 +#include <linux/vserver/signal_cmd.h>
27052 +#include <linux/vserver/space_cmd.h>
27053 +#include <linux/vserver/tag_cmd.h>
27054 +#include <linux/vserver/device_cmd.h>
27056 +#include <linux/vserver/inode.h>
27057 +#include <linux/vserver/dlimit.h>
27060 +#ifdef CONFIG_COMPAT
27061 +#define __COMPAT(name, id, data, compat) \
27062 + (compat) ? name ## _x32(id, data) : name(id, data)
27063 +#define __COMPAT_NO_ID(name, data, compat) \
27064 + (compat) ? name ## _x32(data) : name(data)
27066 +#define __COMPAT(name, id, data, compat) \
27068 +#define __COMPAT_NO_ID(name, data, compat) \
27074 +long do_vcmd(uint32_t cmd, uint32_t id,
27075 + struct vx_info *vxi, struct nx_info *nxi,
27076 + void __user *data, int compat)
27080 + case VCMD_get_version:
27081 + return vc_get_version(id);
27082 + case VCMD_get_vci:
27083 + return vc_get_vci(id);
27085 + case VCMD_task_xid:
27086 + return vc_task_xid(id);
27087 + case VCMD_vx_info:
27088 + return vc_vx_info(vxi, data);
27090 + case VCMD_task_nid:
27091 + return vc_task_nid(id);
27092 + case VCMD_nx_info:
27093 + return vc_nx_info(nxi, data);
27095 + case VCMD_task_tag:
27096 + return vc_task_tag(id);
27098 + /* this is version 1 */
27099 + case VCMD_set_space:
27100 + return vc_set_space(vxi, data);
27102 + case VCMD_get_space_mask:
27103 + return vc_get_space_mask(vxi, data);
27105 +#ifdef CONFIG_IA32_EMULATION
27106 + case VCMD_get_rlimit:
27107 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
27108 + case VCMD_set_rlimit:
27109 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
27111 + case VCMD_get_rlimit:
27112 + return vc_get_rlimit(vxi, data);
27113 + case VCMD_set_rlimit:
27114 + return vc_set_rlimit(vxi, data);
27116 + case VCMD_get_rlimit_mask:
27117 + return vc_get_rlimit_mask(id, data);
27118 + case VCMD_reset_minmax:
27119 + return vc_reset_minmax(vxi, data);
27121 + case VCMD_get_vhi_name:
27122 + return vc_get_vhi_name(vxi, data);
27123 + case VCMD_set_vhi_name:
27124 + return vc_set_vhi_name(vxi, data);
27126 + case VCMD_ctx_stat:
27127 + return vc_ctx_stat(vxi, data);
27128 + case VCMD_virt_stat:
27129 + return vc_virt_stat(vxi, data);
27130 + case VCMD_sock_stat:
27131 + return vc_sock_stat(vxi, data);
27132 + case VCMD_rlimit_stat:
27133 + return vc_rlimit_stat(vxi, data);
27135 + case VCMD_set_cflags:
27136 + return vc_set_cflags(vxi, data);
27137 + case VCMD_get_cflags:
27138 + return vc_get_cflags(vxi, data);
27140 + /* this is version 1 */
27141 + case VCMD_set_ccaps:
27142 + return vc_set_ccaps(vxi, data);
27143 + /* this is version 1 */
27144 + case VCMD_get_ccaps:
27145 + return vc_get_ccaps(vxi, data);
27146 + case VCMD_set_bcaps:
27147 + return vc_set_bcaps(vxi, data);
27148 + case VCMD_get_bcaps:
27149 + return vc_get_bcaps(vxi, data);
27151 + case VCMD_set_badness:
27152 + return vc_set_badness(vxi, data);
27153 + case VCMD_get_badness:
27154 + return vc_get_badness(vxi, data);
27156 + case VCMD_set_nflags:
27157 + return vc_set_nflags(nxi, data);
27158 + case VCMD_get_nflags:
27159 + return vc_get_nflags(nxi, data);
27161 + case VCMD_set_ncaps:
27162 + return vc_set_ncaps(nxi, data);
27163 + case VCMD_get_ncaps:
27164 + return vc_get_ncaps(nxi, data);
27166 + case VCMD_set_sched_v4:
27167 + return vc_set_sched_v4(vxi, data);
27168 + /* this is version 5 */
27169 + case VCMD_set_sched:
27170 + return vc_set_sched(vxi, data);
27171 + case VCMD_get_sched:
27172 + return vc_get_sched(vxi, data);
27173 + case VCMD_sched_info:
27174 + return vc_sched_info(vxi, data);
27176 + case VCMD_add_dlimit:
27177 + return __COMPAT(vc_add_dlimit, id, data, compat);
27178 + case VCMD_rem_dlimit:
27179 + return __COMPAT(vc_rem_dlimit, id, data, compat);
27180 + case VCMD_set_dlimit:
27181 + return __COMPAT(vc_set_dlimit, id, data, compat);
27182 + case VCMD_get_dlimit:
27183 + return __COMPAT(vc_get_dlimit, id, data, compat);
27185 + case VCMD_ctx_kill:
27186 + return vc_ctx_kill(vxi, data);
27188 + case VCMD_wait_exit:
27189 + return vc_wait_exit(vxi, data);
27191 + case VCMD_get_iattr:
27192 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
27193 + case VCMD_set_iattr:
27194 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
27196 + case VCMD_fget_iattr:
27197 + return vc_fget_iattr(id, data);
27198 + case VCMD_fset_iattr:
27199 + return vc_fset_iattr(id, data);
27201 + case VCMD_enter_space_v0:
27202 + return vc_enter_space(vxi, NULL);
27203 + /* this is version 1 */
27204 + case VCMD_enter_space:
27205 + return vc_enter_space(vxi, data);
27207 + case VCMD_ctx_create_v0:
27208 + return vc_ctx_create(id, NULL);
27209 + case VCMD_ctx_create:
27210 + return vc_ctx_create(id, data);
27211 + case VCMD_ctx_migrate_v0:
27212 + return vc_ctx_migrate(vxi, NULL);
27213 + case VCMD_ctx_migrate:
27214 + return vc_ctx_migrate(vxi, data);
27216 + case VCMD_net_create_v0:
27217 + return vc_net_create(id, NULL);
27218 + case VCMD_net_create:
27219 + return vc_net_create(id, data);
27220 + case VCMD_net_migrate:
27221 + return vc_net_migrate(nxi, data);
27223 + case VCMD_tag_migrate:
27224 + return vc_tag_migrate(id);
27226 + case VCMD_net_add:
27227 + return vc_net_add(nxi, data);
27228 + case VCMD_net_remove:
27229 + return vc_net_remove(nxi, data);
27231 + case VCMD_net_add_ipv4:
27232 + return vc_net_add_ipv4(nxi, data);
27233 + case VCMD_net_remove_ipv4:
27234 + return vc_net_remove_ipv4(nxi, data);
27235 +#ifdef CONFIG_IPV6
27236 + case VCMD_net_add_ipv6:
27237 + return vc_net_add_ipv6(nxi, data);
27238 + case VCMD_net_remove_ipv6:
27239 + return vc_net_remove_ipv6(nxi, data);
27241 +/* case VCMD_add_match_ipv4:
27242 + return vc_add_match_ipv4(nxi, data);
27243 + case VCMD_get_match_ipv4:
27244 + return vc_get_match_ipv4(nxi, data);
27245 +#ifdef CONFIG_IPV6
27246 + case VCMD_add_match_ipv6:
27247 + return vc_add_match_ipv6(nxi, data);
27248 + case VCMD_get_match_ipv6:
27249 + return vc_get_match_ipv6(nxi, data);
27252 +#ifdef CONFIG_VSERVER_DEVICE
27253 + case VCMD_set_mapping:
27254 + return __COMPAT(vc_set_mapping, vxi, data, compat);
27255 + case VCMD_unset_mapping:
27256 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
27258 +#ifdef CONFIG_VSERVER_HISTORY
27259 + case VCMD_dump_history:
27260 + return vc_dump_history(id);
27261 + case VCMD_read_history:
27262 + return __COMPAT(vc_read_history, id, data, compat);
27264 +#ifdef CONFIG_VSERVER_MONITOR
27265 + case VCMD_read_monitor:
27266 + return __COMPAT(vc_read_monitor, id, data, compat);
27269 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
27270 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
27276 +#define __VCMD(vcmd, _perm, _args, _flags) \
27277 + case VCMD_ ## vcmd: perm = _perm; \
27278 + args = _args; flags = _flags; break
27281 +#define VCA_NONE 0x00
27282 +#define VCA_VXI 0x01
27283 +#define VCA_NXI 0x02
27285 +#define VCF_NONE 0x00
27286 +#define VCF_INFO 0x01
27287 +#define VCF_ADMIN 0x02
27288 +#define VCF_ARES 0x06 /* includes admin */
27289 +#define VCF_SETUP 0x08
27291 +#define VCF_ZIDOK 0x10 /* zero id okay */
27295 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
27298 + int permit = -1, state = 0;
27299 + int perm = -1, args = 0, flags = 0;
27300 + struct vx_info *vxi = NULL;
27301 + struct nx_info *nxi = NULL;
27304 + /* unpriviledged commands */
27305 + __VCMD(get_version, 0, VCA_NONE, 0);
27306 + __VCMD(get_vci, 0, VCA_NONE, 0);
27307 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
27308 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
27310 + /* info commands */
27311 + __VCMD(task_xid, 2, VCA_NONE, 0);
27312 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
27313 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
27314 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
27315 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
27316 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
27317 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
27318 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
27319 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
27321 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
27322 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
27323 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
27324 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
27326 + __VCMD(task_nid, 2, VCA_NONE, 0);
27327 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
27328 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
27329 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
27331 + __VCMD(task_tag, 2, VCA_NONE, 0);
27333 + __VCMD(get_iattr, 2, VCA_NONE, 0);
27334 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
27335 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
27336 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
27337 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
27339 + /* lower admin commands */
27340 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
27341 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
27342 + __VCMD(ctx_create, 5, VCA_NONE, 0);
27343 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
27344 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
27345 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
27346 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
27348 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
27349 + __VCMD(net_create, 5, VCA_NONE, 0);
27350 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
27352 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
27354 + /* higher admin commands */
27355 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
27356 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27358 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27359 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27360 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27361 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27363 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27364 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27365 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27366 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27368 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
27369 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
27370 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27371 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27372 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27373 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27374 +#ifdef CONFIG_IPV6
27375 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27376 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27378 + __VCMD(set_iattr, 7, VCA_NONE, 0);
27379 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
27380 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
27381 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
27382 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
27384 +#ifdef CONFIG_VSERVER_DEVICE
27385 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
27386 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
27388 + /* debug level admin commands */
27389 +#ifdef CONFIG_VSERVER_HISTORY
27390 + __VCMD(dump_history, 9, VCA_NONE, 0);
27391 + __VCMD(read_history, 9, VCA_NONE, 0);
27393 +#ifdef CONFIG_VSERVER_MONITOR
27394 + __VCMD(read_monitor, 9, VCA_NONE, 0);
27401 + vxdprintk(VXD_CBIT(switch, 0),
27402 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
27403 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
27404 + VC_VERSION(cmd), id, data, compat,
27405 + perm, args, flags);
27412 + if (!capable(CAP_CONTEXT))
27416 + /* moved here from the individual commands */
27418 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
27422 + /* vcmd involves resource management */
27424 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
27428 + /* various legacy exceptions */
27430 + /* will go away when spectator is a cap */
27431 + case VCMD_ctx_migrate_v0:
27432 + case VCMD_ctx_migrate:
27434 + current->xid = 1;
27440 + /* will go away when spectator is a cap */
27441 + case VCMD_net_migrate:
27443 + current->nid = 1;
27450 + /* vcmds are fine by default */
27453 + /* admin type vcmds require admin ... */
27454 + if (flags & VCF_ADMIN)
27455 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
27457 + /* ... but setup type vcmds override that */
27458 + if (!permit && (flags & VCF_SETUP))
27459 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
27467 + if (!id && (flags & VCF_ZIDOK))
27471 + if (args & VCA_VXI) {
27472 + vxi = lookup_vx_info(id);
27476 + if ((flags & VCF_ADMIN) &&
27477 + /* special case kill for shutdown */
27478 + (cmd != VCMD_ctx_kill) &&
27479 + /* can context be administrated? */
27480 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
27486 + if (args & VCA_NXI) {
27487 + nxi = lookup_nx_info(id);
27491 + if ((flags & VCF_ADMIN) &&
27492 + /* can context be administrated? */
27493 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
27500 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
27503 + if ((args & VCA_NXI) && nxi)
27504 + put_nx_info(nxi);
27506 + if ((args & VCA_VXI) && vxi)
27507 + put_vx_info(vxi);
27509 + vxdprintk(VXD_CBIT(switch, 1),
27510 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
27511 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
27512 + VC_VERSION(cmd), ret, ret, state, permit);
27517 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
27519 + return do_vserver(cmd, id, data, 0);
27522 +#ifdef CONFIG_COMPAT
27525 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
27527 + return do_vserver(cmd, id, data, 1);
27530 +#endif /* CONFIG_COMPAT */
27531 diff -Nurp linux-2.6.22.15/kernel/vserver/sysctl.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/sysctl.c
27532 --- linux-2.6.22.15/kernel/vserver/sysctl.c 1969-12-31 19:00:00.000000000 -0500
27533 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/sysctl.c 2007-12-09 06:44:23.000000000 -0500
27536 + * kernel/vserver/sysctl.c
27538 + * Virtual Context Support
27540 + * Copyright (C) 2004-2007 Herbert Pötzl
27542 + * V0.01 basic structure
27546 +#include <linux/module.h>
27547 +#include <linux/ctype.h>
27548 +#include <linux/sysctl.h>
27549 +#include <linux/parser.h>
27550 +#include <asm/uaccess.h>
27553 +#define CTL_VSERVER 4242 /* unused? */
27556 + CTL_DEBUG_ERROR = 0,
27557 + CTL_DEBUG_SWITCH = 1,
27572 +unsigned int vx_debug_switch = 0;
27573 +unsigned int vx_debug_xid = 0;
27574 +unsigned int vx_debug_nid = 0;
27575 +unsigned int vx_debug_tag = 0;
27576 +unsigned int vx_debug_net = 0;
27577 +unsigned int vx_debug_limit = 0;
27578 +unsigned int vx_debug_cres = 0;
27579 +unsigned int vx_debug_dlim = 0;
27580 +unsigned int vx_debug_quota = 0;
27581 +unsigned int vx_debug_cvirt = 0;
27582 +unsigned int vx_debug_space = 0;
27583 +unsigned int vx_debug_misc = 0;
27586 +static struct ctl_table_header *vserver_table_header;
27587 +static ctl_table vserver_table[];
27590 +void vserver_register_sysctl(void)
27592 + if (!vserver_table_header) {
27593 + vserver_table_header = register_sysctl_table(vserver_table);
27598 +void vserver_unregister_sysctl(void)
27600 + if (vserver_table_header) {
27601 + unregister_sysctl_table(vserver_table_header);
27602 + vserver_table_header = NULL;
27607 +static int proc_dodebug(ctl_table *table, int write,
27608 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
27610 + char tmpbuf[20], *p, c;
27611 + unsigned int value;
27612 + size_t left, len;
27614 + if ((*ppos && !write) || !*lenp) {
27622 + if (!access_ok(VERIFY_READ, buffer, left))
27624 + p = (char *)buffer;
27625 + while (left && __get_user(c, p) >= 0 && isspace(c))
27630 + if (left > sizeof(tmpbuf) - 1)
27632 + if (copy_from_user(tmpbuf, p, left))
27634 + tmpbuf[left] = '\0';
27636 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
27637 + value = 10 * value + (*p - '0');
27638 + if (*p && !isspace(*p))
27640 + while (left && isspace(*p))
27642 + *(unsigned int *)table->data = value;
27644 + if (!access_ok(VERIFY_WRITE, buffer, left))
27646 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
27649 + if (__copy_to_user(buffer, tmpbuf, len))
27651 + if ((left -= len) > 0) {
27652 + if (put_user('\n', (char *)buffer + len))
27665 +#define CTL_ENTRY(ctl, name) \
27667 + .ctl_name = ctl, \
27668 + .procname = #name, \
27669 + .data = &vx_ ## name, \
27670 + .maxlen = sizeof(int), \
27672 + .proc_handler = &proc_dodebug \
27675 +static ctl_table debug_table[] = {
27676 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
27677 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
27678 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
27679 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
27680 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
27681 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
27682 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
27683 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
27684 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
27685 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
27686 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
27687 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
27688 + { .ctl_name = 0 }
27691 +static ctl_table vserver_table[] = {
27693 + .ctl_name = CTL_VSERVER,
27694 + .procname = "vserver",
27696 + .child = debug_table
27698 + { .ctl_name = 0 }
27702 +static match_table_t tokens = {
27703 + { CTL_DEBUG_SWITCH, "switch=%x" },
27704 + { CTL_DEBUG_XID, "xid=%x" },
27705 + { CTL_DEBUG_NID, "nid=%x" },
27706 + { CTL_DEBUG_TAG, "tag=%x" },
27707 + { CTL_DEBUG_NET, "net=%x" },
27708 + { CTL_DEBUG_LIMIT, "limit=%x" },
27709 + { CTL_DEBUG_CRES, "cres=%x" },
27710 + { CTL_DEBUG_DLIM, "dlim=%x" },
27711 + { CTL_DEBUG_QUOTA, "quota=%x" },
27712 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
27713 + { CTL_DEBUG_SPACE, "space=%x" },
27714 + { CTL_DEBUG_MISC, "misc=%x" },
27715 + { CTL_DEBUG_ERROR, NULL }
27718 +#define HANDLE_CASE(id, name, val) \
27719 + case CTL_DEBUG_ ## id: \
27720 + vx_debug_ ## name = val; \
27721 + printk("vs_debug_" #name "=0x%x\n", val); \
27725 +static int __init vs_debug_setup(char *str)
27730 + printk("vs_debug_setup(%s)\n", str);
27731 + while ((p = strsep(&str, ",")) != NULL) {
27732 + substring_t args[MAX_OPT_ARGS];
27733 + unsigned int value;
27738 + token = match_token(p, tokens, args);
27739 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
27742 + HANDLE_CASE(SWITCH, switch, value);
27743 + HANDLE_CASE(XID, xid, value);
27744 + HANDLE_CASE(NID, nid, value);
27745 + HANDLE_CASE(TAG, tag, value);
27746 + HANDLE_CASE(NET, net, value);
27747 + HANDLE_CASE(LIMIT, limit, value);
27748 + HANDLE_CASE(CRES, cres, value);
27749 + HANDLE_CASE(DLIM, dlim, value);
27750 + HANDLE_CASE(QUOTA, quota, value);
27751 + HANDLE_CASE(CVIRT, cvirt, value);
27752 + HANDLE_CASE(SPACE, space, value);
27753 + HANDLE_CASE(MISC, misc, value);
27762 +__setup("vsdebug=", vs_debug_setup);
27766 +EXPORT_SYMBOL_GPL(vx_debug_switch);
27767 +EXPORT_SYMBOL_GPL(vx_debug_xid);
27768 +EXPORT_SYMBOL_GPL(vx_debug_nid);
27769 +EXPORT_SYMBOL_GPL(vx_debug_net);
27770 +EXPORT_SYMBOL_GPL(vx_debug_limit);
27771 +EXPORT_SYMBOL_GPL(vx_debug_cres);
27772 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
27773 +EXPORT_SYMBOL_GPL(vx_debug_quota);
27774 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
27775 +EXPORT_SYMBOL_GPL(vx_debug_space);
27776 +EXPORT_SYMBOL_GPL(vx_debug_misc);
27778 diff -Nurp linux-2.6.22.15/kernel/vserver/tag.c linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/tag.c
27779 --- linux-2.6.22.15/kernel/vserver/tag.c 1969-12-31 19:00:00.000000000 -0500
27780 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/tag.c 2007-12-09 06:44:23.000000000 -0500
27783 + * linux/kernel/vserver/tag.c
27785 + * Virtual Server: Shallow Tag Space
27787 + * Copyright (C) 2007 Herbert Pötzl
27789 + * V0.01 basic implementation
27793 +#include <linux/sched.h>
27794 +#include <linux/vserver/debug.h>
27795 +#include <linux/vs_tag.h>
27797 +#include <linux/vserver/tag_cmd.h>
27800 +int dx_migrate_task(struct task_struct *p, tag_t tag)
27805 + vxdprintk(VXD_CBIT(tag, 5),
27806 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
27812 + vxdprintk(VXD_CBIT(tag, 5),
27813 + "moved task %p into [#%d]", p, tag);
27817 +/* vserver syscall commands below here */
27819 +/* taks xid and vx_info functions */
27822 +int vc_task_tag(uint32_t id)
27827 + struct task_struct *tsk;
27828 + read_lock(&tasklist_lock);
27829 + tsk = find_task_by_real_pid(id);
27830 + tag = (tsk) ? tsk->tag : -ESRCH;
27831 + read_unlock(&tasklist_lock);
27833 + tag = dx_current_tag();
27838 +int vc_tag_migrate(uint32_t tag)
27840 + return dx_migrate_task(current, tag & 0xFFFF);
27844 diff -Nurp linux-2.6.22.15/kernel/vserver/vci_config.h linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/vci_config.h
27845 --- linux-2.6.22.15/kernel/vserver/vci_config.h 1969-12-31 19:00:00.000000000 -0500
27846 +++ linux-2.6.22.15-vs2.3.0.29.1/kernel/vserver/vci_config.h 2007-12-09 06:44:23.000000000 -0500
27849 +/* interface version */
27851 +#define VCI_VERSION 0x00020302
27855 + VCI_KCBIT_NO_DYNAMIC = 0,
27857 + VCI_KCBIT_PROC_SECURE = 4,
27858 + VCI_KCBIT_HARDCPU = 5,
27859 + VCI_KCBIT_IDLELIMIT = 6,
27860 + VCI_KCBIT_IDLETIME = 7,
27862 + VCI_KCBIT_COWBL = 8,
27863 + VCI_KCBIT_FULLCOWBL = 9,
27864 + VCI_KCBIT_SPACES = 10,
27865 + VCI_KCBIT_NETV2 = 11,
27867 + VCI_KCBIT_DEBUG = 16,
27868 + VCI_KCBIT_HISTORY = 20,
27869 + VCI_KCBIT_TAGGED = 24,
27870 + VCI_KCBIT_PPTAG = 28,
27872 + VCI_KCBIT_MORE = 31,
27876 +static inline uint32_t vci_kernel_config(void)
27879 + (1 << VCI_KCBIT_NO_DYNAMIC) |
27881 + /* configured features */
27882 +#ifdef CONFIG_VSERVER_PROC_SECURE
27883 + (1 << VCI_KCBIT_PROC_SECURE) |
27885 +#ifdef CONFIG_VSERVER_HARDCPU
27886 + (1 << VCI_KCBIT_HARDCPU) |
27888 +#ifdef CONFIG_VSERVER_IDLELIMIT
27889 + (1 << VCI_KCBIT_IDLELIMIT) |
27891 +#ifdef CONFIG_VSERVER_IDLETIME
27892 + (1 << VCI_KCBIT_IDLETIME) |
27894 +#ifdef CONFIG_VSERVER_COWBL
27895 + (1 << VCI_KCBIT_COWBL) |
27896 + (1 << VCI_KCBIT_FULLCOWBL) |
27898 + (1 << VCI_KCBIT_SPACES) |
27899 + (1 << VCI_KCBIT_NETV2) |
27901 + /* debug options */
27902 +#ifdef CONFIG_VSERVER_DEBUG
27903 + (1 << VCI_KCBIT_DEBUG) |
27905 +#ifdef CONFIG_VSERVER_HISTORY
27906 + (1 << VCI_KCBIT_HISTORY) |
27909 + /* inode context tagging */
27910 +#if defined(CONFIG_TAGGING_NONE)
27911 + (0 << VCI_KCBIT_TAGGED) |
27912 +#elif defined(CONFIG_TAGGING_UID16)
27913 + (1 << VCI_KCBIT_TAGGED) |
27914 +#elif defined(CONFIG_TAGGING_GID16)
27915 + (2 << VCI_KCBIT_TAGGED) |
27916 +#elif defined(CONFIG_TAGGING_ID24)
27917 + (3 << VCI_KCBIT_TAGGED) |
27918 +#elif defined(CONFIG_TAGGING_INTERN)
27919 + (4 << VCI_KCBIT_TAGGED) |
27920 +#elif defined(CONFIG_TAGGING_RUNTIME)
27921 + (5 << VCI_KCBIT_TAGGED) |
27923 + (7 << VCI_KCBIT_TAGGED) |
27925 + (1 << VCI_KCBIT_PPTAG) |
27929 diff -Nurp linux-2.6.22.15/Makefile linux-2.6.22.15-vs2.3.0.29.1/Makefile
27930 --- linux-2.6.22.15/Makefile 2007-12-09 06:43:53.000000000 -0500
27931 +++ linux-2.6.22.15-vs2.3.0.29.1/Makefile 2007-12-09 06:44:39.000000000 -0500
27936 -EXTRAVERSION = .19
27937 +EXTRAVERSION = .19-vs2.3.0.29.1
27938 NAME = Holy Dancing Manatees, Batman!
27941 diff -Nurp linux-2.6.22.15/mm/filemap_xip.c linux-2.6.22.15-vs2.3.0.29.1/mm/filemap_xip.c
27942 --- linux-2.6.22.15/mm/filemap_xip.c 2007-07-21 18:00:25.000000000 -0400
27943 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/filemap_xip.c 2007-12-09 06:44:23.000000000 -0500
27945 #include <linux/uio.h>
27946 #include <linux/rmap.h>
27947 #include <linux/sched.h>
27948 +#include <linux/vs_memory.h>
27949 #include <asm/tlbflush.h>
27950 #include "filemap.h"
27952 diff -Nurp linux-2.6.22.15/mm/fremap.c linux-2.6.22.15-vs2.3.0.29.1/mm/fremap.c
27953 --- linux-2.6.22.15/mm/fremap.c 2007-05-04 09:58:24.000000000 -0400
27954 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/fremap.c 2007-12-09 06:44:23.000000000 -0500
27956 #include <linux/rmap.h>
27957 #include <linux/module.h>
27958 #include <linux/syscalls.h>
27959 +#include <linux/vs_memory.h>
27961 #include <asm/mmu_context.h>
27962 #include <asm/cacheflush.h>
27963 @@ -74,6 +75,8 @@ int install_page(struct mm_struct *mm, s
27965 if (page_mapcount(page) > INT_MAX/2)
27967 + if (!vx_rss_avail(mm, 1))
27970 if (pte_none(*pte) || !zap_pte(mm, vma, addr, pte))
27971 inc_mm_counter(mm, file_rss);
27972 diff -Nurp linux-2.6.22.15/mm/hugetlb.c linux-2.6.22.15-vs2.3.0.29.1/mm/hugetlb.c
27973 --- linux-2.6.22.15/mm/hugetlb.c 2007-08-11 21:54:37.000000000 -0400
27974 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/hugetlb.c 2007-12-09 06:44:23.000000000 -0500
27976 #include <asm/pgtable.h>
27978 #include <linux/hugetlb.h>
27979 +#include <linux/vs_memory.h>
27980 #include "internal.h"
27982 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
27983 diff -Nurp linux-2.6.22.15/mm/memory.c linux-2.6.22.15-vs2.3.0.29.1/mm/memory.c
27984 --- linux-2.6.22.15/mm/memory.c 2007-07-21 18:00:25.000000000 -0400
27985 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/memory.c 2007-12-09 06:44:23.000000000 -0500
27986 @@ -498,6 +498,9 @@ static int copy_pte_range(struct mm_stru
27990 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
27994 rss[1] = rss[0] = 0;
27995 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
27996 @@ -2157,6 +2160,11 @@ static int do_swap_page(struct mm_struct
27997 count_vm_event(PGMAJFAULT);
28000 + if (!vx_rss_avail(mm, 1)) {
28001 + ret = VM_FAULT_OOM;
28005 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
28006 mark_page_accessed(page);
28008 @@ -2229,6 +2237,8 @@ static int do_anonymous_page(struct mm_s
28009 /* Allocate our own private page. */
28010 pte_unmap(page_table);
28012 + if (!vx_rss_avail(mm, 1))
28014 if (unlikely(anon_vma_prepare(vma)))
28016 page = alloc_zeroed_user_highpage(vma, address);
28017 @@ -2302,6 +2312,9 @@ static int do_no_page(struct mm_struct *
28018 pte_unmap(page_table);
28019 BUG_ON(vma->vm_flags & VM_PFNMAP);
28021 + if (!vx_rss_avail(mm, 1))
28022 + return VM_FAULT_OOM;
28024 if (vma->vm_file) {
28025 mapping = vma->vm_file->f_mapping;
28026 sequence = mapping->truncate_count;
28027 @@ -2527,6 +2540,7 @@ static inline int handle_pte_fault(struc
28031 + int ret, type = VXPT_UNKNOWN;
28034 if (!pte_present(entry)) {
28035 @@ -2555,9 +2569,12 @@ static inline int handle_pte_fault(struc
28036 if (unlikely(!pte_same(*pte, entry)))
28038 if (write_access) {
28039 - if (!pte_write(entry))
28040 - return do_wp_page(mm, vma, address,
28041 + if (!pte_write(entry)) {
28042 + ret = do_wp_page(mm, vma, address,
28043 pte, pmd, ptl, entry);
28044 + type = VXPT_WRITE;
28047 entry = pte_mkdirty(entry);
28049 entry = pte_mkyoung(entry);
28050 @@ -2576,7 +2593,10 @@ static inline int handle_pte_fault(struc
28053 pte_unmap_unlock(pte, ptl);
28054 - return VM_FAULT_MINOR;
28055 + ret = VM_FAULT_MINOR;
28057 + vx_page_fault(mm, vma, type, ret);
28062 diff -Nurp linux-2.6.22.15/mm/mlock.c linux-2.6.22.15-vs2.3.0.29.1/mm/mlock.c
28063 --- linux-2.6.22.15/mm/mlock.c 2007-08-11 21:54:37.000000000 -0400
28064 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/mlock.c 2007-12-09 06:44:23.000000000 -0500
28066 #include <linux/syscalls.h>
28067 #include <linux/sched.h>
28068 #include <linux/module.h>
28069 +#include <linux/vs_memory.h>
28071 int can_do_mlock(void)
28073 @@ -76,7 +77,7 @@ success:
28074 ret = make_pages_present(start, end);
28077 - mm->locked_vm -= pages;
28078 + vx_vmlocked_sub(mm, pages);
28080 if (ret == -ENOMEM)
28082 @@ -134,7 +135,7 @@ static int do_mlock(unsigned long start,
28084 asmlinkage long sys_mlock(unsigned long start, size_t len)
28086 - unsigned long locked;
28087 + unsigned long locked, grow;
28088 unsigned long lock_limit;
28089 int error = -ENOMEM;
28091 @@ -145,8 +146,10 @@ asmlinkage long sys_mlock(unsigned long
28092 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
28093 start &= PAGE_MASK;
28095 - locked = len >> PAGE_SHIFT;
28096 - locked += current->mm->locked_vm;
28097 + grow = len >> PAGE_SHIFT;
28098 + if (!vx_vmlocked_avail(current->mm, grow))
28100 + locked = current->mm->locked_vm + grow;
28102 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
28103 lock_limit >>= PAGE_SHIFT;
28104 @@ -154,6 +157,7 @@ asmlinkage long sys_mlock(unsigned long
28105 /* check against resource limits */
28106 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
28107 error = do_mlock(start, len, 1);
28109 up_write(¤t->mm->mmap_sem);
28112 @@ -213,6 +217,8 @@ asmlinkage long sys_mlockall(int flags)
28113 lock_limit >>= PAGE_SHIFT;
28116 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
28118 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
28119 capable(CAP_IPC_LOCK))
28120 ret = do_mlockall(flags);
28121 diff -Nurp linux-2.6.22.15/mm/mmap.c linux-2.6.22.15-vs2.3.0.29.1/mm/mmap.c
28122 --- linux-2.6.22.15/mm/mmap.c 2007-07-21 18:00:25.000000000 -0400
28123 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/mmap.c 2007-12-09 06:44:23.000000000 -0500
28124 @@ -1144,10 +1144,10 @@ munmap_back:
28125 kmem_cache_free(vm_area_cachep, vma);
28128 - mm->total_vm += len >> PAGE_SHIFT;
28129 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28130 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
28131 if (vm_flags & VM_LOCKED) {
28132 - mm->locked_vm += len >> PAGE_SHIFT;
28133 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
28134 make_pages_present(addr, addr + len);
28136 if (flags & MAP_POPULATE) {
28137 @@ -1502,9 +1502,9 @@ static int acct_stack_growth(struct vm_a
28140 /* Ok, everything looks good - let it rip */
28141 - mm->total_vm += grow;
28142 + vx_vmpages_add(mm, grow);
28143 if (vma->vm_flags & VM_LOCKED)
28144 - mm->locked_vm += grow;
28145 + vx_vmlocked_add(mm, grow);
28146 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
28149 @@ -1662,9 +1662,9 @@ static void remove_vma_list(struct mm_st
28151 long nrpages = vma_pages(vma);
28153 - mm->total_vm -= nrpages;
28154 + vx_vmpages_sub(mm, nrpages);
28155 if (vma->vm_flags & VM_LOCKED)
28156 - mm->locked_vm -= nrpages;
28157 + vx_vmlocked_sub(mm, nrpages);
28158 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
28159 vma = remove_vma(vma);
28161 @@ -1903,6 +1903,8 @@ unsigned long do_brk(unsigned long addr,
28162 lock_limit >>= PAGE_SHIFT;
28163 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
28165 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
28170 @@ -1929,7 +1931,8 @@ unsigned long do_brk(unsigned long addr,
28171 if (mm->map_count > sysctl_max_map_count)
28174 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
28175 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
28176 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
28179 /* Can we just expand an old private anonymous mapping? */
28180 @@ -1955,9 +1958,9 @@ unsigned long do_brk(unsigned long addr,
28181 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)];
28182 vma_link(mm, vma, prev, rb_link, rb_parent);
28184 - mm->total_vm += len >> PAGE_SHIFT;
28185 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28186 if (flags & VM_LOCKED) {
28187 - mm->locked_vm += len >> PAGE_SHIFT;
28188 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
28189 make_pages_present(addr, addr + len);
28192 @@ -1986,6 +1989,11 @@ void exit_mmap(struct mm_struct *mm)
28193 free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, 0);
28194 tlb_finish_mmu(tlb, 0, end);
28196 + set_mm_counter(mm, file_rss, 0);
28197 + set_mm_counter(mm, anon_rss, 0);
28198 + vx_vmpages_sub(mm, mm->total_vm);
28199 + vx_vmlocked_sub(mm, mm->locked_vm);
28202 * Walk the list again, actually closing and freeing it,
28203 * with preemption enabled, without holding any MM locks.
28204 @@ -2025,7 +2033,8 @@ int insert_vm_struct(struct mm_struct *
28205 if (__vma && __vma->vm_start < vma->vm_end)
28207 if ((vma->vm_flags & VM_ACCOUNT) &&
28208 - security_vm_enough_memory(vma_pages(vma)))
28209 + (security_vm_enough_memory(vma_pages(vma)) ||
28210 + !vx_vmpages_avail(mm, vma_pages(vma))))
28212 vma_link(mm, vma, prev, rb_link, rb_parent);
28214 @@ -2098,6 +2107,8 @@ int may_expand_vm(struct mm_struct *mm,
28216 if (cur + npages > lim)
28218 + if (!vx_vmpages_avail(mm, npages))
28223 @@ -2168,7 +2179,6 @@ int install_special_mapping(struct mm_st
28227 - mm->total_vm += len >> PAGE_SHIFT;
28229 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28232 diff -Nurp linux-2.6.22.15/mm/mremap.c linux-2.6.22.15-vs2.3.0.29.1/mm/mremap.c
28233 --- linux-2.6.22.15/mm/mremap.c 2007-05-04 09:58:24.000000000 -0400
28234 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/mremap.c 2007-12-09 06:44:23.000000000 -0500
28236 #include <linux/highmem.h>
28237 #include <linux/security.h>
28238 #include <linux/syscalls.h>
28239 +#include <linux/vs_memory.h>
28241 #include <asm/uaccess.h>
28242 #include <asm/cacheflush.h>
28243 @@ -212,7 +213,7 @@ static unsigned long move_vma(struct vm_
28244 * If this were a serious issue, we'd add a flag to do_munmap().
28246 hiwater_vm = mm->hiwater_vm;
28247 - mm->total_vm += new_len >> PAGE_SHIFT;
28248 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
28249 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
28251 if (do_munmap(mm, old_addr, old_len) < 0) {
28252 @@ -230,7 +231,7 @@ static unsigned long move_vma(struct vm_
28255 if (vm_flags & VM_LOCKED) {
28256 - mm->locked_vm += new_len >> PAGE_SHIFT;
28257 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
28258 if (new_len > old_len)
28259 make_pages_present(new_addr + old_len,
28260 new_addr + new_len);
28261 @@ -337,6 +338,9 @@ unsigned long do_mremap(unsigned long ad
28263 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
28265 + if (!vx_vmlocked_avail(current->mm,
28266 + (new_len - old_len) >> PAGE_SHIFT))
28269 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
28271 @@ -365,10 +369,10 @@ unsigned long do_mremap(unsigned long ad
28272 vma_adjust(vma, vma->vm_start,
28273 addr + new_len, vma->vm_pgoff, NULL);
28275 - mm->total_vm += pages;
28276 + vx_vmpages_add(mm, pages);
28277 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
28278 if (vma->vm_flags & VM_LOCKED) {
28279 - mm->locked_vm += pages;
28280 + vx_vmlocked_add(mm, pages);
28281 make_pages_present(addr + old_len,
28284 diff -Nurp linux-2.6.22.15/mm/nommu.c linux-2.6.22.15-vs2.3.0.29.1/mm/nommu.c
28285 --- linux-2.6.22.15/mm/nommu.c 2007-07-21 18:00:25.000000000 -0400
28286 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/nommu.c 2007-12-09 06:44:23.000000000 -0500
28287 @@ -936,7 +936,7 @@ unsigned long do_mmap_pgoff(struct file
28288 realalloc += kobjsize(vma);
28289 askedalloc += sizeof(*vma);
28291 - current->mm->total_vm += len >> PAGE_SHIFT;
28292 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
28294 add_nommu_vma(vma);
28296 @@ -1061,7 +1061,7 @@ int do_munmap(struct mm_struct *mm, unsi
28299 update_hiwater_vm(mm);
28300 - mm->total_vm -= len >> PAGE_SHIFT;
28301 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
28304 show_process_blocks();
28305 @@ -1093,7 +1093,7 @@ void exit_mmap(struct mm_struct * mm)
28306 printk("Exit_mmap:\n");
28309 - mm->total_vm = 0;
28310 + vx_vmpages_sub(mm, mm->total_vm);
28312 while ((tmp = mm->context.vmlist)) {
28313 mm->context.vmlist = tmp->next;
28314 diff -Nurp linux-2.6.22.15/mm/oom_kill.c linux-2.6.22.15-vs2.3.0.29.1/mm/oom_kill.c
28315 --- linux-2.6.22.15/mm/oom_kill.c 2007-07-21 18:00:25.000000000 -0400
28316 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/oom_kill.c 2007-12-09 06:44:23.000000000 -0500
28318 #include <linux/cpuset.h>
28319 #include <linux/module.h>
28320 #include <linux/notifier.h>
28321 +#include <linux/vs_memory.h>
28323 int sysctl_panic_on_oom;
28324 /* #define DEBUG */
28325 @@ -66,6 +67,12 @@ unsigned long badness(struct task_struct
28326 points = mm->total_vm;
28329 + * add points for context badness
28332 + points += vx_badness(p, mm);
28335 * After this unlock we can no longer dereference local variable `mm'
28338 @@ -156,8 +163,8 @@ unsigned long badness(struct task_struct
28342 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %d points\n",
28343 - p->pid, p->comm, points);
28344 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
28345 + p->pid, p->xid, p->comm, points);
28349 @@ -288,7 +295,8 @@ static void __oom_kill_task(struct task_
28353 - printk(KERN_ERR "Killed process %d (%s)\n", p->pid, p->comm);
28354 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
28355 + p->pid, p->xid, p->comm);
28358 * We give our sacrificial lamb high priority and access to
28359 @@ -358,8 +366,8 @@ static int oom_kill_process(struct task_
28363 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
28364 - message, p->pid, p->comm, points);
28365 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
28366 + message, p->pid, p->xid, p->comm, points);
28368 /* Try to kill a child first */
28369 list_for_each(tsk, &p->children) {
28370 diff -Nurp linux-2.6.22.15/mm/page_alloc.c linux-2.6.22.15-vs2.3.0.29.1/mm/page_alloc.c
28371 --- linux-2.6.22.15/mm/page_alloc.c 2007-07-21 18:00:25.000000000 -0400
28372 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/page_alloc.c 2007-12-09 06:44:23.000000000 -0500
28374 #include <linux/pfn.h>
28375 #include <linux/backing-dev.h>
28376 #include <linux/fault-inject.h>
28377 +#include <linux/vs_base.h>
28378 +#include <linux/vs_limit.h>
28380 #include <asm/tlbflush.h>
28381 #include <asm/div64.h>
28382 @@ -1488,6 +1490,9 @@ void si_meminfo(struct sysinfo *val)
28383 val->totalhigh = totalhigh_pages;
28384 val->freehigh = nr_free_highpages();
28385 val->mem_unit = PAGE_SIZE;
28387 + if (vx_flags(VXF_VIRT_MEM, 0))
28388 + vx_vsi_meminfo(val);
28391 EXPORT_SYMBOL(si_meminfo);
28392 @@ -1508,6 +1513,9 @@ void si_meminfo_node(struct sysinfo *val
28395 val->mem_unit = PAGE_SIZE;
28397 + if (vx_flags(VXF_VIRT_MEM, 0))
28398 + vx_vsi_meminfo(val);
28402 diff -Nurp linux-2.6.22.15/mm/rmap.c linux-2.6.22.15-vs2.3.0.29.1/mm/rmap.c
28403 --- linux-2.6.22.15/mm/rmap.c 2007-07-21 18:00:25.000000000 -0400
28404 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/rmap.c 2007-12-09 06:44:23.000000000 -0500
28406 #include <linux/rcupdate.h>
28407 #include <linux/module.h>
28408 #include <linux/kallsyms.h>
28409 +#include <linux/vs_memory.h>
28411 #include <asm/tlbflush.h>
28413 diff -Nurp linux-2.6.22.15/mm/shmem.c linux-2.6.22.15-vs2.3.0.29.1/mm/shmem.c
28414 --- linux-2.6.22.15/mm/shmem.c 2007-12-09 06:43:53.000000000 -0500
28415 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/shmem.c 2007-12-09 06:44:23.000000000 -0500
28417 #include <asm/pgtable.h>
28419 /* This magic number is used in glibc for posix shared memory */
28420 -#define TMPFS_MAGIC 0x01021994
28422 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
28423 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
28424 @@ -1749,7 +1748,7 @@ static int shmem_statfs(struct dentry *d
28426 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
28428 - buf->f_type = TMPFS_MAGIC;
28429 + buf->f_type = TMPFS_SUPER_MAGIC;
28430 buf->f_bsize = PAGE_CACHE_SIZE;
28431 buf->f_namelen = NAME_MAX;
28432 spin_lock(&sbinfo->stat_lock);
28433 @@ -2323,7 +2322,7 @@ static int shmem_fill_super(struct super
28434 sb->s_maxbytes = SHMEM_MAX_BYTES;
28435 sb->s_blocksize = PAGE_CACHE_SIZE;
28436 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
28437 - sb->s_magic = TMPFS_MAGIC;
28438 + sb->s_magic = TMPFS_SUPER_MAGIC;
28439 sb->s_op = &shmem_ops;
28440 sb->s_time_gran = 1;
28441 #ifdef CONFIG_TMPFS_POSIX_ACL
28442 diff -Nurp linux-2.6.22.15/mm/slab.c linux-2.6.22.15-vs2.3.0.29.1/mm/slab.c
28443 --- linux-2.6.22.15/mm/slab.c 2007-07-21 18:00:25.000000000 -0400
28444 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/slab.c 2007-12-09 06:44:23.000000000 -0500
28445 @@ -510,6 +510,8 @@ struct kmem_cache {
28446 #define STATS_INC_FREEMISS(x) do { } while (0)
28449 +#include "slab_vs.h"
28454 @@ -3314,6 +3316,7 @@ retry:
28456 obj = slab_get_obj(cachep, slabp, nodeid);
28457 check_slabp(cachep, slabp);
28458 + vx_slab_alloc(cachep, flags);
28459 l3->free_objects--;
28460 /* move slabp to correct slabp list: */
28461 list_del(&slabp->list);
28462 @@ -3386,6 +3389,7 @@ __cache_alloc_node(struct kmem_cache *ca
28463 /* ___cache_alloc_node can fall back to other nodes */
28464 ptr = ____cache_alloc_node(cachep, flags, nodeid);
28466 + vx_slab_alloc(cachep, flags);
28467 local_irq_restore(save_flags);
28468 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
28470 @@ -3551,6 +3555,7 @@ static inline void __cache_free(struct k
28473 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
28474 + vx_slab_free(cachep);
28476 if (cache_free_alien(cachep, objp))
28478 diff -Nurp linux-2.6.22.15/mm/slab_vs.h linux-2.6.22.15-vs2.3.0.29.1/mm/slab_vs.h
28479 --- linux-2.6.22.15/mm/slab_vs.h 1969-12-31 19:00:00.000000000 -0500
28480 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/slab_vs.h 2007-12-09 06:44:23.000000000 -0500
28483 +#include <linux/vserver/context.h>
28485 +#include <linux/vs_context.h>
28488 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
28490 + int what = gfp_zone(cachep->gfpflags);
28492 + if (!current->vx_info)
28495 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
28499 +void vx_slab_free(struct kmem_cache *cachep)
28501 + int what = gfp_zone(cachep->gfpflags);
28503 + if (!current->vx_info)
28506 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
28509 diff -Nurp linux-2.6.22.15/mm/swapfile.c linux-2.6.22.15-vs2.3.0.29.1/mm/swapfile.c
28510 --- linux-2.6.22.15/mm/swapfile.c 2007-07-21 18:00:25.000000000 -0400
28511 +++ linux-2.6.22.15-vs2.3.0.29.1/mm/swapfile.c 2007-12-09 06:44:23.000000000 -0500
28513 #include <asm/pgtable.h>
28514 #include <asm/tlbflush.h>
28515 #include <linux/swapops.h>
28516 +#include <linux/vs_base.h>
28517 +#include <linux/vs_memory.h>
28519 DEFINE_SPINLOCK(swap_lock);
28520 unsigned int nr_swapfiles;
28521 @@ -1712,6 +1714,8 @@ void si_swapinfo(struct sysinfo *val)
28522 val->freeswap = nr_swap_pages + nr_to_be_unused;
28523 val->totalswap = total_swap_pages + nr_to_be_unused;
28524 spin_unlock(&swap_lock);
28525 + if (vx_flags(VXF_VIRT_MEM, 0))
28526 + vx_vsi_swapinfo(val);
28530 diff -Nurp linux-2.6.22.15/net/core/dev.c linux-2.6.22.15-vs2.3.0.29.1/net/core/dev.c
28531 --- linux-2.6.22.15/net/core/dev.c 2007-09-05 01:07:59.000000000 -0400
28532 +++ linux-2.6.22.15-vs2.3.0.29.1/net/core/dev.c 2007-12-09 06:44:23.000000000 -0500
28533 @@ -117,6 +117,7 @@
28534 #include <linux/err.h>
28535 #include <linux/ctype.h>
28536 #include <linux/if_arp.h>
28537 +#include <linux/vs_inet.h>
28540 * The list of packet types we will receive (as opposed to discard)
28541 @@ -2120,6 +2121,8 @@ static int dev_ifconf(char __user *arg)
28544 for_each_netdev(dev) {
28545 + if (!nx_dev_visible(current->nx_info, dev))
28547 for (i = 0; i < NPROTO; i++) {
28548 if (gifconf_list[i]) {
28550 @@ -2184,6 +2187,9 @@ static void dev_seq_printf_stats(struct
28552 struct net_device_stats *stats = dev->get_stats(dev);
28554 + if (!nx_dev_visible(current->nx_info, dev))
28557 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
28558 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
28559 dev->name, stats->rx_bytes, stats->rx_packets,
28560 diff -Nurp linux-2.6.22.15/net/core/rtnetlink.c linux-2.6.22.15-vs2.3.0.29.1/net/core/rtnetlink.c
28561 --- linux-2.6.22.15/net/core/rtnetlink.c 2007-07-21 18:00:25.000000000 -0400
28562 +++ linux-2.6.22.15-vs2.3.0.29.1/net/core/rtnetlink.c 2007-12-09 06:44:23.000000000 -0500
28563 @@ -537,6 +537,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
28566 for_each_netdev(dev) {
28567 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
28571 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
28572 @@ -797,6 +799,9 @@ void rtmsg_ifinfo(int type, struct net_d
28573 struct sk_buff *skb;
28574 int err = -ENOBUFS;
28576 + if (!nx_dev_visible(current->nx_info, dev))
28579 skb = nlmsg_new(if_nlmsg_size(), GFP_KERNEL);
28582 diff -Nurp linux-2.6.22.15/net/core/sock.c linux-2.6.22.15-vs2.3.0.29.1/net/core/sock.c
28583 --- linux-2.6.22.15/net/core/sock.c 2007-07-21 18:00:25.000000000 -0400
28584 +++ linux-2.6.22.15-vs2.3.0.29.1/net/core/sock.c 2007-12-09 06:44:23.000000000 -0500
28585 @@ -125,6 +125,10 @@
28586 #include <linux/ipsec.h>
28588 #include <linux/filter.h>
28589 +#include <linux/vs_socket.h>
28590 +#include <linux/vs_limit.h>
28591 +#include <linux/vs_context.h>
28592 +#include <linux/vs_network.h>
28595 #include <net/tcp.h>
28596 @@ -812,6 +816,9 @@ int sock_getsockopt(struct socket *sock,
28598 return security_socket_getpeersec_stream(sock, optval, optlen, len);
28601 + return vx_socket_peer_tag(sock, level, optval, optlen, len);
28604 return -ENOPROTOOPT;
28606 @@ -869,6 +876,8 @@ struct sock *sk_alloc(int family, gfp_t
28607 sk->sk_prot = sk->sk_prot_creator = prot;
28608 sock_lock_init(sk);
28610 + sock_vx_init(sk);
28611 + sock_nx_init(sk);
28613 if (security_sk_alloc(sk, family, priority))
28615 @@ -907,6 +916,11 @@ void sk_free(struct sock *sk)
28616 __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
28618 security_sk_free(sk);
28620 + clr_vx_info(&sk->sk_vx_info);
28622 + clr_nx_info(&sk->sk_nx_info);
28624 if (sk->sk_prot_creator->slab != NULL)
28625 kmem_cache_free(sk->sk_prot_creator->slab, sk);
28627 @@ -924,6 +938,8 @@ struct sock *sk_clone(const struct sock
28628 sock_copy(newsk, sk);
28631 + sock_vx_init(newsk);
28632 + sock_nx_init(newsk);
28633 sk_node_init(&newsk->sk_node);
28634 sock_lock_init(newsk);
28635 bh_lock_sock(newsk);
28636 @@ -969,6 +985,12 @@ struct sock *sk_clone(const struct sock
28637 newsk->sk_priority = 0;
28638 atomic_set(&newsk->sk_refcnt, 2);
28640 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
28641 + newsk->sk_xid = sk->sk_xid;
28642 + vx_sock_inc(newsk);
28643 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
28644 + newsk->sk_nid = sk->sk_nid;
28647 * Increment the counter in the same struct proto as the master
28648 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
28649 @@ -1551,6 +1573,11 @@ void sock_init_data(struct socket *sock,
28651 sk->sk_stamp = ktime_set(-1L, -1L);
28653 + set_vx_info(&sk->sk_vx_info, current->vx_info);
28654 + sk->sk_xid = vx_current_xid();
28656 + set_nx_info(&sk->sk_nx_info, current->nx_info);
28657 + sk->sk_nid = nx_current_nid();
28658 atomic_set(&sk->sk_refcnt, 1);
28661 diff -Nurp linux-2.6.22.15/net/ipv4/af_inet.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/af_inet.c
28662 --- linux-2.6.22.15/net/ipv4/af_inet.c 2007-09-05 01:07:59.000000000 -0400
28663 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/af_inet.c 2007-12-09 06:44:23.000000000 -0500
28664 @@ -115,6 +115,7 @@
28665 #ifdef CONFIG_IP_MROUTE
28666 #include <linux/mroute.h>
28668 +#include <linux/vs_limit.h>
28670 DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly;
28672 @@ -308,9 +309,12 @@ lookup_protocol:
28676 + if ((protocol == IPPROTO_ICMP) &&
28677 + nx_capable(answer->capability, NXC_RAW_ICMP))
28679 if (answer->capability > 0 && !capable(answer->capability))
28680 goto out_rcu_unlock;
28683 sock->ops = answer->ops;
28684 answer_prot = answer->prot;
28685 answer_no_check = answer->no_check;
28686 @@ -424,6 +428,7 @@ int inet_bind(struct socket *sock, struc
28687 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
28688 struct sock *sk = sock->sk;
28689 struct inet_sock *inet = inet_sk(sk);
28690 + struct nx_v4_sock_addr nsa;
28691 unsigned short snum;
28694 @@ -437,7 +442,11 @@ int inet_bind(struct socket *sock, struc
28695 if (addr_len < sizeof(struct sockaddr_in))
28698 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
28699 + err = v4_map_sock_addr(inet, addr, &nsa);
28703 + chk_addr_ret = inet_addr_type(nsa.saddr);
28705 /* Not specified by any standard per-se, however it breaks too
28706 * many applications when removed. It is unfortunate since
28707 @@ -449,7 +458,7 @@ int inet_bind(struct socket *sock, struc
28708 err = -EADDRNOTAVAIL;
28709 if (!sysctl_ip_nonlocal_bind &&
28711 - addr->sin_addr.s_addr != INADDR_ANY &&
28712 + nsa.saddr != INADDR_ANY &&
28713 chk_addr_ret != RTN_LOCAL &&
28714 chk_addr_ret != RTN_MULTICAST &&
28715 chk_addr_ret != RTN_BROADCAST)
28716 @@ -474,7 +483,7 @@ int inet_bind(struct socket *sock, struc
28717 if (sk->sk_state != TCP_CLOSE || inet->num)
28718 goto out_release_sock;
28720 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
28721 + v4_set_sock_addr(inet, &nsa);
28722 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
28723 inet->saddr = 0; /* Use device */
28725 @@ -667,11 +676,13 @@ int inet_getname(struct socket *sock, st
28728 sin->sin_port = inet->dport;
28729 - sin->sin_addr.s_addr = inet->daddr;
28730 + sin->sin_addr.s_addr =
28731 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
28733 __be32 addr = inet->rcv_saddr;
28735 addr = inet->saddr;
28736 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
28737 sin->sin_port = inet->sport;
28738 sin->sin_addr.s_addr = addr;
28740 diff -Nurp linux-2.6.22.15/net/ipv4/devinet.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/devinet.c
28741 --- linux-2.6.22.15/net/ipv4/devinet.c 2007-09-29 08:11:49.000000000 -0400
28742 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/devinet.c 2007-12-09 06:44:23.000000000 -0500
28743 @@ -427,6 +427,7 @@ struct in_device *inetdev_by_index(int i
28748 /* Called only from RTNL semaphored context. No locks. */
28750 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
28751 @@ -676,6 +677,8 @@ int devinet_ioctl(unsigned int cmd, void
28754 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
28755 + struct nx_info *nxi = current->nx_info;
28757 if (tryaddrmatch) {
28758 /* Matthias Andree */
28759 /* compare label and address (4.4BSD style) */
28760 @@ -684,6 +687,8 @@ int devinet_ioctl(unsigned int cmd, void
28761 This is checked above. */
28762 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
28763 ifap = &ifa->ifa_next) {
28764 + if (!nx_v4_ifa_visible(nxi, ifa))
28766 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
28767 sin_orig.sin_addr.s_addr ==
28768 ifa->ifa_address) {
28769 @@ -696,9 +701,12 @@ int devinet_ioctl(unsigned int cmd, void
28770 comparing just the label */
28772 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
28773 - ifap = &ifa->ifa_next)
28774 + ifap = &ifa->ifa_next) {
28775 + if (!nx_v4_ifa_visible(nxi, ifa))
28777 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
28783 @@ -849,6 +857,8 @@ static int inet_gifconf(struct net_devic
28786 for (; ifa; ifa = ifa->ifa_next) {
28787 + if (!nx_v4_ifa_visible(current->nx_info, ifa))
28790 done += sizeof(ifr);
28792 @@ -1179,6 +1189,7 @@ static int inet_dump_ifaddr(struct sk_bu
28793 struct net_device *dev;
28794 struct in_device *in_dev;
28795 struct in_ifaddr *ifa;
28796 + struct sock *sk = skb->sk;
28797 int s_ip_idx, s_idx = cb->args[0];
28799 s_ip_idx = ip_idx = cb->args[1];
28800 @@ -1193,6 +1204,8 @@ static int inet_dump_ifaddr(struct sk_bu
28802 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
28803 ifa = ifa->ifa_next, ip_idx++) {
28804 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
28806 if (ip_idx < s_ip_idx)
28808 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
28809 diff -Nurp linux-2.6.22.15/net/ipv4/fib_hash.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/fib_hash.c
28810 --- linux-2.6.22.15/net/ipv4/fib_hash.c 2007-07-21 18:00:25.000000000 -0400
28811 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/fib_hash.c 2007-12-09 06:44:23.000000000 -0500
28812 @@ -1012,7 +1012,7 @@ static int fib_seq_show(struct seq_file
28813 prefix = f->fn_key;
28814 mask = FZ_MASK(iter->zone);
28815 flags = fib_flag_trans(fa->fa_type, mask, fi);
28817 + if (fi && nx_dev_visible(current->nx_info, fi->fib_dev))
28818 snprintf(bf, sizeof(bf),
28819 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
28820 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
28821 diff -Nurp linux-2.6.22.15/net/ipv4/inet_connection_sock.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/inet_connection_sock.c
28822 --- linux-2.6.22.15/net/ipv4/inet_connection_sock.c 2007-07-21 18:00:25.000000000 -0400
28823 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/inet_connection_sock.c 2007-12-09 06:44:23.000000000 -0500
28824 @@ -34,10 +34,40 @@ EXPORT_SYMBOL(inet_csk_timer_bug_msg);
28826 int sysctl_local_port_range[2] = { 32768, 61000 };
28828 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
28830 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
28831 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
28833 + if (inet_v6_ipv6only(sk2))
28836 + if (sk1_rcv_saddr &&
28838 + sk1_rcv_saddr == sk2_rcv_saddr)
28841 + if (sk1_rcv_saddr &&
28842 + !sk2_rcv_saddr &&
28843 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
28846 + if (sk2_rcv_saddr &&
28847 + !sk1_rcv_saddr &&
28848 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
28851 + if (!sk1_rcv_saddr &&
28852 + !sk2_rcv_saddr &&
28853 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
28859 int inet_csk_bind_conflict(const struct sock *sk,
28860 const struct inet_bind_bucket *tb)
28862 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
28864 struct hlist_node *node;
28865 int reuse = sk->sk_reuse;
28866 @@ -50,9 +80,7 @@ int inet_csk_bind_conflict(const struct
28867 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
28868 if (!reuse || !sk2->sk_reuse ||
28869 sk2->sk_state == TCP_LISTEN) {
28870 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28871 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
28872 - sk2_rcv_saddr == sk_rcv_saddr)
28873 + if (ipv4_rcv_saddr_equal(sk, sk2))
28877 diff -Nurp linux-2.6.22.15/net/ipv4/inet_diag.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/inet_diag.c
28878 --- linux-2.6.22.15/net/ipv4/inet_diag.c 2007-09-29 08:11:49.000000000 -0400
28879 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/inet_diag.c 2007-12-09 06:44:23.000000000 -0500
28880 @@ -98,8 +98,8 @@ static int inet_csk_diag_fill(struct soc
28882 r->id.idiag_sport = inet->sport;
28883 r->id.idiag_dport = inet->dport;
28884 - r->id.idiag_src[0] = inet->rcv_saddr;
28885 - r->id.idiag_dst[0] = inet->daddr;
28886 + r->id.idiag_src[0] = nx_map_sock_lback(skb->sk->sk_nx_info, inet->rcv_saddr);
28887 + r->id.idiag_dst[0] = nx_map_sock_lback(skb->sk->sk_nx_info, inet->daddr);
28889 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
28890 if (r->idiag_family == AF_INET6) {
28891 @@ -186,8 +186,8 @@ static int inet_twsk_diag_fill(struct in
28892 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
28893 r->id.idiag_sport = tw->tw_sport;
28894 r->id.idiag_dport = tw->tw_dport;
28895 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
28896 - r->id.idiag_dst[0] = tw->tw_daddr;
28897 + r->id.idiag_src[0] = nx_map_sock_lback(skb->sk->sk_nx_info, tw->tw_rcv_saddr);
28898 + r->id.idiag_dst[0] = nx_map_sock_lback(skb->sk->sk_nx_info, tw->tw_daddr);
28899 r->idiag_state = tw->tw_substate;
28900 r->idiag_timer = 3;
28901 r->idiag_expires = (tmo * 1000 + HZ - 1) / HZ;
28902 @@ -239,6 +239,7 @@ static int inet_diag_get_exact(struct sk
28903 hashinfo = handler->idiag_hashinfo;
28905 if (req->idiag_family == AF_INET) {
28906 + /* TODO: lback */
28907 sk = inet_lookup(hashinfo, req->id.idiag_dst[0],
28908 req->id.idiag_dport, req->id.idiag_src[0],
28909 req->id.idiag_sport, req->id.idiag_if);
28910 @@ -478,6 +479,7 @@ static int inet_csk_diag_dump(struct soc
28914 + /* TODO: lback */
28915 entry.saddr = &inet->rcv_saddr;
28916 entry.daddr = &inet->daddr;
28918 @@ -514,6 +516,7 @@ static int inet_twsk_diag_dump(struct in
28922 + /* TODO: lback */
28923 entry.saddr = &tw->tw_rcv_saddr;
28924 entry.daddr = &tw->tw_daddr;
28926 @@ -560,8 +563,8 @@ static int inet_diag_fill_req(struct sk_
28928 r->id.idiag_sport = inet->sport;
28929 r->id.idiag_dport = ireq->rmt_port;
28930 - r->id.idiag_src[0] = ireq->loc_addr;
28931 - r->id.idiag_dst[0] = ireq->rmt_addr;
28932 + r->id.idiag_src[0] = nx_map_sock_lback(skb->sk->sk_nx_info, ireq->loc_addr);
28933 + r->id.idiag_dst[0] = nx_map_sock_lback(skb->sk->sk_nx_info, ireq->rmt_addr);
28934 r->idiag_expires = jiffies_to_msecs(tmo);
28935 r->idiag_rqueue = 0;
28936 r->idiag_wqueue = 0;
28937 @@ -631,6 +634,7 @@ static int inet_diag_dump_reqs(struct sk
28941 + /* TODO: lback */
28943 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
28944 (entry.family == AF_INET6) ?
28945 @@ -697,6 +701,8 @@ static int inet_diag_dump(struct sk_buff
28946 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
28947 struct inet_sock *inet = inet_sk(sk);
28949 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28954 @@ -757,6 +763,8 @@ skip_listen_ht:
28955 sk_for_each(sk, node, &head->chain) {
28956 struct inet_sock *inet = inet_sk(sk);
28958 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28962 if (!(r->idiag_states & (1 << sk->sk_state)))
28963 @@ -781,6 +789,8 @@ next_normal:
28964 inet_twsk_for_each(tw, node,
28967 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
28971 if (r->id.idiag_sport != tw->tw_sport &&
28972 diff -Nurp linux-2.6.22.15/net/ipv4/inet_hashtables.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/inet_hashtables.c
28973 --- linux-2.6.22.15/net/ipv4/inet_hashtables.c 2007-07-21 17:58:55.000000000 -0400
28974 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/inet_hashtables.c 2007-12-09 06:44:23.000000000 -0500
28975 @@ -140,11 +140,10 @@ static struct sock *inet_lookup_listener
28976 const __be32 rcv_saddr = inet->rcv_saddr;
28977 int score = sk->sk_family == PF_INET ? 1 : 0;
28980 - if (rcv_saddr != daddr)
28982 + if (v4_inet_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
28987 if (sk->sk_bound_dev_if) {
28988 if (sk->sk_bound_dev_if != dif)
28990 @@ -175,7 +174,7 @@ struct sock *__inet_lookup_listener(stru
28991 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
28993 if (inet->num == hnum && !sk->sk_node.next &&
28994 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
28995 + v4_inet_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
28996 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
28997 !sk->sk_bound_dev_if)
28999 diff -Nurp linux-2.6.22.15/net/ipv4/raw.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/raw.c
29000 --- linux-2.6.22.15/net/ipv4/raw.c 2007-07-21 18:00:27.000000000 -0400
29001 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/raw.c 2007-12-09 06:44:23.000000000 -0500
29002 @@ -112,7 +112,7 @@ struct sock *__raw_v4_lookup(struct sock
29004 if (inet->num == num &&
29005 !(inet->daddr && inet->daddr != raddr) &&
29006 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
29007 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
29008 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
29009 goto found; /* gotcha */
29011 @@ -314,6 +314,12 @@ static int raw_send_hdrinc(struct sock *
29012 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
29016 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
29017 + sk->sk_nx_info &&
29018 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
29021 err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
29024 @@ -325,6 +331,7 @@ out:
29031 IP_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
29032 @@ -491,6 +498,12 @@ static int raw_sendmsg(struct kiocb *ioc
29035 security_sk_classify_flow(sk, &fl);
29036 + if (sk->sk_nx_info) {
29037 + err = ip_v4_find_src(sk->sk_nx_info, &rt, &fl);
29042 err = ip_route_output_flow(&rt, &fl, sk, 1);
29045 @@ -553,17 +566,19 @@ static int raw_bind(struct sock *sk, str
29047 struct inet_sock *inet = inet_sk(sk);
29048 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
29049 + struct nx_v4_sock_addr nsa = { 0 };
29053 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
29055 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
29056 + v4_map_sock_addr(inet, addr, &nsa);
29057 + chk_addr_ret = inet_addr_type(nsa.saddr);
29058 ret = -EADDRNOTAVAIL;
29059 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
29060 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
29061 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
29063 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
29064 + v4_set_sock_addr(inet, &nsa);
29065 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
29066 inet->saddr = 0; /* Use device */
29068 @@ -615,7 +630,8 @@ static int raw_recvmsg(struct kiocb *ioc
29069 /* Copy the address. */
29071 sin->sin_family = AF_INET;
29072 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
29073 + sin->sin_addr.s_addr =
29074 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
29076 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
29078 @@ -795,7 +811,8 @@ static struct sock *raw_get_first(struct
29079 struct hlist_node *node;
29081 sk_for_each(sk, node, &raw_v4_htable[state->bucket])
29082 - if (sk->sk_family == PF_INET)
29083 + if (sk->sk_family == PF_INET &&
29084 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29088 @@ -811,7 +828,8 @@ static struct sock *raw_get_next(struct
29092 - } while (sk && sk->sk_family != PF_INET);
29093 + } while (sk && (sk->sk_family != PF_INET ||
29094 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
29096 if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
29097 sk = sk_head(&raw_v4_htable[state->bucket]);
29098 @@ -863,7 +881,10 @@ static __inline__ char *get_raw_sock(str
29100 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29101 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
29102 - i, src, srcp, dest, destp, sp->sk_state,
29104 + nx_map_sock_lback(current_nx_info(), src), srcp,
29105 + nx_map_sock_lback(current_nx_info(), dest), destp,
29107 atomic_read(&sp->sk_wmem_alloc),
29108 atomic_read(&sp->sk_rmem_alloc),
29109 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
29110 diff -Nurp linux-2.6.22.15/net/ipv4/tcp.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/tcp.c
29111 --- linux-2.6.22.15/net/ipv4/tcp.c 2007-09-05 01:07:59.000000000 -0400
29112 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/tcp.c 2007-12-09 06:44:23.000000000 -0500
29113 @@ -258,6 +258,7 @@
29114 #include <linux/cache.h>
29115 #include <linux/err.h>
29116 #include <linux/crypto.h>
29117 +#include <linux/in.h>
29119 #include <net/icmp.h>
29120 #include <net/tcp.h>
29121 diff -Nurp linux-2.6.22.15/net/ipv4/tcp_ipv4.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/tcp_ipv4.c
29122 --- linux-2.6.22.15/net/ipv4/tcp_ipv4.c 2007-12-09 06:43:41.000000000 -0500
29123 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/tcp_ipv4.c 2007-12-09 06:44:23.000000000 -0500
29124 @@ -1974,6 +1974,12 @@ static void *listening_get_next(struct s
29125 req = req->dl_next;
29128 + vxdprintk(VXD_CBIT(net, 6),
29129 + "sk,req: %p [#%d] (from %d)", req->sk,
29130 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
29132 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
29134 if (req->rsk_ops->family == st->family) {
29137 @@ -1998,6 +2004,10 @@ get_req:
29140 sk_for_each_from(sk, node) {
29141 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
29142 + sk, sk->sk_nid, nx_current_nid());
29143 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29145 if (sk->sk_family == st->family) {
29148 @@ -2049,18 +2059,26 @@ static void *established_get_first(struc
29150 read_lock(&tcp_hashinfo.ehash[st->bucket].lock);
29151 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
29152 - if (sk->sk_family != st->family) {
29153 + vxdprintk(VXD_CBIT(net, 6),
29154 + "sk,egf: %p [#%d] (from %d)",
29155 + sk, sk->sk_nid, nx_current_nid());
29156 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29158 + if (sk->sk_family != st->family)
29164 st->state = TCP_SEQ_STATE_TIME_WAIT;
29165 inet_twsk_for_each(tw, node,
29166 &tcp_hashinfo.ehash[st->bucket].twchain) {
29167 - if (tw->tw_family != st->family) {
29168 + vxdprintk(VXD_CBIT(net, 6),
29169 + "tw: %p [#%d] (from %d)",
29170 + tw, tw->tw_nid, nx_current_nid());
29171 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
29173 + if (tw->tw_family != st->family)
29179 @@ -2084,7 +2102,8 @@ static void *established_get_next(struct
29183 - while (tw && tw->tw_family != st->family) {
29184 + while (tw && (tw->tw_family != st->family ||
29185 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
29189 @@ -2108,6 +2127,11 @@ get_tw:
29192 sk_for_each_from(sk, node) {
29193 + vxdprintk(VXD_CBIT(net, 6),
29194 + "sk,egn: %p [#%d] (from %d)",
29195 + sk, sk->sk_nid, nx_current_nid());
29196 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29198 if (sk->sk_family == st->family)
29201 @@ -2283,9 +2307,9 @@ static void get_openreq4(struct sock *sk
29202 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29203 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p",
29206 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
29207 ntohs(inet_sk(sk)->sport),
29209 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
29210 ntohs(ireq->rmt_port),
29212 0, 0, /* could print option size, but that is af dependent. */
29213 @@ -2327,7 +2351,10 @@ static void get_tcp4_sock(struct sock *s
29215 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
29216 "%08X %5d %8d %lu %d %p %u %u %u %u %d",
29217 - i, src, srcp, dest, destp, sk->sk_state,
29219 + nx_map_sock_lback(current_nx_info(), src), srcp,
29220 + nx_map_sock_lback(current_nx_info(), dest), destp,
29222 tp->write_seq - tp->snd_una,
29223 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
29224 (tp->rcv_nxt - tp->copied_seq),
29225 @@ -2362,7 +2389,10 @@ static void get_timewait4_sock(struct in
29227 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29228 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p",
29229 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
29231 + nx_map_sock_lback(current_nx_info(), src), srcp,
29232 + nx_map_sock_lback(current_nx_info(), dest), destp,
29233 + tw->tw_substate, 0, 0,
29234 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
29235 atomic_read(&tw->tw_refcnt), tw);
29237 diff -Nurp linux-2.6.22.15/net/ipv4/tcp_minisocks.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/tcp_minisocks.c
29238 --- linux-2.6.22.15/net/ipv4/tcp_minisocks.c 2007-07-21 18:00:27.000000000 -0400
29239 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/tcp_minisocks.c 2007-12-09 06:44:23.000000000 -0500
29241 #include <net/inet_common.h>
29242 #include <net/xfrm.h>
29244 +#include <linux/vs_limit.h>
29245 +#include <linux/vs_socket.h>
29246 +#include <linux/vs_context.h>
29248 #ifdef CONFIG_SYSCTL
29249 #define SYNC_INIT 0 /* let the user enable it */
29251 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
29252 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
29253 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
29255 + tw->tw_xid = sk->sk_xid;
29256 + tw->tw_vx_info = NULL;
29257 + tw->tw_nid = sk->sk_nid;
29258 + tw->tw_nx_info = NULL;
29260 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
29261 if (tw->tw_family == PF_INET6) {
29262 struct ipv6_pinfo *np = inet6_sk(sk);
29263 diff -Nurp linux-2.6.22.15/net/ipv4/udp.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/udp.c
29264 --- linux-2.6.22.15/net/ipv4/udp.c 2007-07-21 18:00:27.000000000 -0400
29265 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv4/udp.c 2007-12-09 06:44:23.000000000 -0500
29266 @@ -219,14 +219,7 @@ int udp_get_port(struct sock *sk, unsign
29267 return __udp_lib_get_port(sk, snum, udp_hash, &udp_port_rover, scmp);
29270 -int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
29272 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
29274 - return ( !ipv6_only_sock(sk2) &&
29275 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
29276 - inet1->rcv_saddr == inet2->rcv_saddr ));
29278 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
29280 static inline int udp_v4_get_port(struct sock *sk, unsigned short snum)
29282 @@ -246,15 +239,22 @@ static struct sock *__udp4_lib_lookup(__
29285 read_lock(&udp_hash_lock);
29287 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
29288 struct inet_sock *inet = inet_sk(sk);
29290 if (sk->sk_hash == hnum && !ipv6_only_sock(sk)) {
29291 int score = (sk->sk_family == PF_INET ? 1 : 0);
29293 if (inet->rcv_saddr) {
29294 if (inet->rcv_saddr != daddr)
29298 + /* block non nx_info ips */
29299 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
29300 + daddr, NXA_MASK_BIND))
29304 if (inet->daddr != saddr)
29305 @@ -280,6 +280,7 @@ static struct sock *__udp4_lib_lookup(__
29312 read_unlock(&udp_hash_lock);
29313 @@ -301,7 +302,7 @@ static inline struct sock *udp_v4_mcast_
29314 if (s->sk_hash != hnum ||
29315 (inet->daddr && inet->daddr != rmt_addr) ||
29316 (inet->dport != rmt_port && inet->dport) ||
29317 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
29318 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
29319 ipv6_only_sock(s) ||
29320 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
29322 @@ -631,7 +632,14 @@ int udp_sendmsg(struct kiocb *iocb, stru
29323 .uli_u = { .ports =
29324 { .sport = inet->sport,
29325 .dport = dport } } };
29326 + struct nx_info *nxi = sk->sk_nx_info;
29328 security_sk_classify_flow(sk, &fl);
29330 + err = ip_v4_find_src(nxi, &rt, &fl);
29334 err = ip_route_output_flow(&rt, &fl, sk, 1);
29336 if (err == -ENETUNREACH)
29337 @@ -871,7 +879,8 @@ try_again:
29339 sin->sin_family = AF_INET;
29340 sin->sin_port = udp_hdr(skb)->source;
29341 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
29342 + sin->sin_addr.s_addr = nx_map_sock_lback(
29343 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
29344 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
29346 if (inet->cmsg_flags)
29347 @@ -1551,7 +1560,8 @@ static struct sock *udp_get_first(struct
29348 for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
29349 struct hlist_node *node;
29350 sk_for_each(sk, node, state->hashtable + state->bucket) {
29351 - if (sk->sk_family == state->family)
29352 + if (sk->sk_family == state->family &&
29353 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29357 @@ -1568,7 +1578,8 @@ static struct sock *udp_get_next(struct
29361 - } while (sk && sk->sk_family != state->family);
29362 + } while (sk && (sk->sk_family != state->family ||
29363 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
29365 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
29366 sk = sk_head(state->hashtable + state->bucket);
29367 @@ -1681,7 +1692,10 @@ static void udp4_format_sock(struct sock
29369 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29370 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
29371 - bucket, src, srcp, dest, destp, sp->sk_state,
29373 + nx_map_sock_lback(current_nx_info(), src), srcp,
29374 + nx_map_sock_lback(current_nx_info(), dest), destp,
29376 atomic_read(&sp->sk_wmem_alloc),
29377 atomic_read(&sp->sk_rmem_alloc),
29378 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
29379 diff -Nurp linux-2.6.22.15/net/ipv6/addrconf.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/addrconf.c
29380 --- linux-2.6.22.15/net/ipv6/addrconf.c 2007-12-09 06:43:41.000000000 -0500
29381 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/addrconf.c 2007-12-09 06:44:23.000000000 -0500
29384 #include <linux/proc_fs.h>
29385 #include <linux/seq_file.h>
29386 +#include <linux/vs_inet6.h>
29388 /* Set to 3 to get tracing... */
29389 #define ACONF_DEBUG 2
29390 @@ -904,7 +905,8 @@ static inline int ipv6_saddr_label(const
29393 int ipv6_dev_get_saddr(struct net_device *daddr_dev,
29394 - struct in6_addr *daddr, struct in6_addr *saddr)
29395 + struct in6_addr *daddr, struct in6_addr *saddr,
29396 + struct nx_info *nxi)
29398 struct ipv6_saddr_score hiscore;
29399 struct inet6_ifaddr *ifa_result = NULL;
29400 @@ -949,6 +951,10 @@ int ipv6_dev_get_saddr(struct net_device
29402 score.addr_type = __ipv6_addr_type(&ifa->addr);
29404 + /* Use only addresses assigned to the context */
29405 + if (!v6_ifa_in_nx_info(ifa, nxi))
29409 * - Tentative Address (RFC2462 section 5.4)
29410 * - A tentative address is not considered
29411 @@ -1162,9 +1168,10 @@ record_it:
29414 int ipv6_get_saddr(struct dst_entry *dst,
29415 - struct in6_addr *daddr, struct in6_addr *saddr)
29416 + struct in6_addr *daddr, struct in6_addr *saddr,
29417 + struct nx_info *nxi)
29419 - return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr);
29420 + return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr, nxi);
29423 EXPORT_SYMBOL(ipv6_get_saddr);
29424 @@ -1260,35 +1267,46 @@ struct inet6_ifaddr * ipv6_get_ifaddr(st
29428 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
29430 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
29432 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
29433 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
29434 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
29435 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
29436 int sk_ipv6only = ipv6_only_sock(sk);
29437 int sk2_ipv6only = inet_v6_ipv6only(sk2);
29438 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
29439 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
29441 - if (!sk2_rcv_saddr && !sk_ipv6only)
29442 + /* FIXME: needs handling for v4 ANY */
29443 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
29446 if (addr_type2 == IPV6_ADDR_ANY &&
29447 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
29448 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
29449 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
29452 if (addr_type == IPV6_ADDR_ANY &&
29453 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
29454 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
29455 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
29458 + if (addr_type == IPV6_ADDR_ANY &&
29459 + addr_type2 == IPV6_ADDR_ANY &&
29460 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
29463 if (sk2_rcv_saddr6 &&
29464 + addr_type != IPV6_ADDR_ANY &&
29465 + addr_type != IPV6_ADDR_ANY &&
29466 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
29469 if (addr_type == IPV6_ADDR_MAPPED &&
29471 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
29472 + ipv4_rcv_saddr_equal(sk, sk2))
29476 @@ -2779,7 +2797,10 @@ static void if6_seq_stop(struct seq_file
29477 static int if6_seq_show(struct seq_file *seq, void *v)
29479 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
29482 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
29483 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
29485 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
29487 ifp->idev->dev->ifindex,
29488 @@ -3261,6 +3282,11 @@ static int inet6_dump_addr(struct sk_buf
29489 struct inet6_ifaddr *ifa;
29490 struct ifmcaddr6 *ifmca;
29491 struct ifacaddr6 *ifaca;
29492 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29494 + /* disable ipv6 on non v6 guests */
29495 + if (nxi && !nx_info_has_v6(nxi))
29498 s_idx = cb->args[0];
29499 s_ip_idx = ip_idx = cb->args[1];
29500 @@ -3282,6 +3308,8 @@ static int inet6_dump_addr(struct sk_buf
29501 ifa = ifa->if_next, ip_idx++) {
29502 if (ip_idx < s_ip_idx)
29504 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
29506 if ((err = inet6_fill_ifaddr(skb, ifa,
29507 NETLINK_CB(cb->skb).pid,
29508 cb->nlh->nlmsg_seq, RTM_NEWADDR,
29509 @@ -3295,6 +3323,8 @@ static int inet6_dump_addr(struct sk_buf
29510 ifmca = ifmca->next, ip_idx++) {
29511 if (ip_idx < s_ip_idx)
29513 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
29515 if ((err = inet6_fill_ifmcaddr(skb, ifmca,
29516 NETLINK_CB(cb->skb).pid,
29517 cb->nlh->nlmsg_seq, RTM_GETMULTICAST,
29518 @@ -3308,6 +3338,8 @@ static int inet6_dump_addr(struct sk_buf
29519 ifaca = ifaca->aca_next, ip_idx++) {
29520 if (ip_idx < s_ip_idx)
29522 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
29524 if ((err = inet6_fill_ifacaddr(skb, ifaca,
29525 NETLINK_CB(cb->skb).pid,
29526 cb->nlh->nlmsg_seq, RTM_GETANYCAST,
29527 @@ -3584,12 +3616,19 @@ static int inet6_dump_ifinfo(struct sk_b
29528 int s_idx = cb->args[0];
29529 struct net_device *dev;
29530 struct inet6_dev *idev;
29531 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29533 + /* FIXME: maybe disable ipv6 on non v6 guests?
29534 + if (skb->sk && skb->sk->sk_vx_info)
29535 + return skb->len; */
29537 read_lock(&dev_base_lock);
29539 for_each_netdev(dev) {
29542 + if (!v6_dev_in_nx_info(dev, nxi))
29544 if ((idev = in6_dev_get(dev)) == NULL)
29546 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
29547 diff -Nurp linux-2.6.22.15/net/ipv6/af_inet6.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/af_inet6.c
29548 --- linux-2.6.22.15/net/ipv6/af_inet6.c 2007-09-05 01:08:00.000000000 -0400
29549 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/af_inet6.c 2007-12-09 06:44:23.000000000 -0500
29551 #include <linux/netdevice.h>
29552 #include <linux/icmpv6.h>
29553 #include <linux/netfilter_ipv6.h>
29554 +#include <linux/vs_inet6.h>
29556 #include <net/ip.h>
29557 #include <net/ipv6.h>
29558 @@ -150,9 +151,12 @@ lookup_protocol:
29562 + if ((protocol == IPPROTO_ICMPV6) &&
29563 + nx_capable(answer->capability, NXC_RAW_ICMP))
29565 if (answer->capability > 0 && !capable(answer->capability))
29566 goto out_rcu_unlock;
29569 sock->ops = answer->ops;
29570 answer_prot = answer->prot;
29571 answer_no_check = answer->no_check;
29572 @@ -250,6 +254,7 @@ int inet6_bind(struct socket *sock, stru
29573 struct sock *sk = sock->sk;
29574 struct inet_sock *inet = inet_sk(sk);
29575 struct ipv6_pinfo *np = inet6_sk(sk);
29576 + struct nx_v6_sock_addr nsa;
29578 unsigned short snum;
29580 @@ -261,6 +266,11 @@ int inet6_bind(struct socket *sock, stru
29582 if (addr_len < SIN6_LEN_RFC2133)
29585 + err = v6_map_sock_addr(inet, addr, &nsa);
29589 addr_type = ipv6_addr_type(&addr->sin6_addr);
29590 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
29592 @@ -284,6 +294,10 @@ int inet6_bind(struct socket *sock, stru
29593 err = -EADDRNOTAVAIL;
29596 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
29597 + err = -EADDRNOTAVAIL;
29601 if (addr_type != IPV6_ADDR_ANY) {
29602 struct net_device *dev = NULL;
29603 @@ -309,6 +323,11 @@ int inet6_bind(struct socket *sock, stru
29607 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
29608 + err = -EADDRNOTAVAIL;
29612 /* ipv4 addr of the socket is invalid. Only the
29613 * unspecified and mapped address have a v4 equivalent.
29615 @@ -326,6 +345,8 @@ int inet6_bind(struct socket *sock, stru
29619 + v6_set_sock_addr(inet, &nsa);
29621 inet->rcv_saddr = v4addr;
29622 inet->saddr = v4addr;
29624 @@ -420,9 +441,11 @@ int inet6_getname(struct socket *sock, s
29626 sin->sin6_port = inet->dport;
29627 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
29628 + /* FIXME: remap lback? */
29630 sin->sin6_flowinfo = np->flow_label;
29632 + /* FIXME: remap lback? */
29633 if (ipv6_addr_any(&np->rcv_saddr))
29634 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
29636 diff -Nurp linux-2.6.22.15/net/ipv6/fib6_rules.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/fib6_rules.c
29637 --- linux-2.6.22.15/net/ipv6/fib6_rules.c 2007-07-21 18:00:27.000000000 -0400
29638 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/fib6_rules.c 2007-12-09 06:44:23.000000000 -0500
29639 @@ -107,7 +107,7 @@ static int fib6_rule_action(struct fib_r
29640 r->src.plen && !(flags & RT6_LOOKUP_F_HAS_SADDR)) {
29641 struct in6_addr saddr;
29642 if (ipv6_get_saddr(&rt->u.dst, &flp->fl6_dst,
29646 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
29648 diff -Nurp linux-2.6.22.15/net/ipv6/inet6_hashtables.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/inet6_hashtables.c
29649 --- linux-2.6.22.15/net/ipv6/inet6_hashtables.c 2007-07-21 17:58:56.000000000 -0400
29650 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/inet6_hashtables.c 2007-12-09 06:44:23.000000000 -0500
29653 #include <linux/module.h>
29654 #include <linux/random.h>
29655 +#include <linux/vs_inet6.h>
29657 #include <net/inet_connection_sock.h>
29658 #include <net/inet_hashtables.h>
29659 @@ -121,6 +122,9 @@ struct sock *inet6_lookup_listener(struc
29660 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29664 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29667 if (sk->sk_bound_dev_if) {
29668 if (sk->sk_bound_dev_if != dif)
29669 diff -Nurp linux-2.6.22.15/net/ipv6/ip6_output.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/ip6_output.c
29670 --- linux-2.6.22.15/net/ipv6/ip6_output.c 2007-09-29 08:11:49.000000000 -0400
29671 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/ip6_output.c 2007-12-09 06:44:23.000000000 -0500
29672 @@ -884,7 +884,7 @@ static int ip6_dst_lookup_tail(struct so
29673 goto out_err_release;
29675 if (ipv6_addr_any(&fl->fl6_src)) {
29676 - err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src);
29677 + err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src, sk->sk_nx_info);
29679 goto out_err_release;
29681 diff -Nurp linux-2.6.22.15/net/ipv6/Kconfig linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/Kconfig
29682 --- linux-2.6.22.15/net/ipv6/Kconfig 2007-07-21 18:00:27.000000000 -0400
29683 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/Kconfig 2007-12-09 06:44:23.000000000 -0500
29686 # IPv6 as module will cause a CRASH if you try to unload it
29688 - tristate "The IPv6 protocol"
29690 + bool "The IPv6 protocol"
29693 This is complemental support for the IP version 6.
29694 You will still be able to do traditional IPv4 networking as well.
29695 diff -Nurp linux-2.6.22.15/net/ipv6/ndisc.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/ndisc.c
29696 --- linux-2.6.22.15/net/ipv6/ndisc.c 2007-12-09 06:43:41.000000000 -0500
29697 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/ndisc.c 2007-12-09 06:44:23.000000000 -0500
29698 @@ -531,7 +531,7 @@ static void ndisc_send_na(struct net_dev
29702 - if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr))
29703 + if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr, NULL))
29705 src_addr = &tmpaddr;
29707 diff -Nurp linux-2.6.22.15/net/ipv6/route.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/route.c
29708 --- linux-2.6.22.15/net/ipv6/route.c 2007-07-21 18:00:27.000000000 -0400
29709 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/route.c 2007-12-09 06:44:23.000000000 -0500
29710 @@ -2182,7 +2182,7 @@ static int rt6_fill_node(struct sk_buff
29711 NLA_PUT_U32(skb, RTA_IIF, iif);
29713 struct in6_addr saddr_buf;
29714 - if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf) == 0)
29715 + if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf, skb->sk->sk_nx_info) == 0)
29716 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
29719 diff -Nurp linux-2.6.22.15/net/ipv6/tcp_ipv6.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/tcp_ipv6.c
29720 --- linux-2.6.22.15/net/ipv6/tcp_ipv6.c 2007-12-09 06:43:41.000000000 -0500
29721 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/tcp_ipv6.c 2007-12-09 06:44:23.000000000 -0500
29724 #include <linux/crypto.h>
29725 #include <linux/scatterlist.h>
29726 +#include <linux/vs_inet6.h>
29728 /* Socket used for sending RSTs and ACKs */
29729 static struct socket *tcp6_socket;
29730 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
29731 * connect() to INADDR_ANY means loopback (BSD'ism).
29734 - if(ipv6_addr_any(&usin->sin6_addr))
29735 - usin->sin6_addr.s6_addr[15] = 0x1;
29736 + if(ipv6_addr_any(&usin->sin6_addr)) {
29737 + struct nx_info *nxi = sk->sk_nx_info;
29739 + if (nxi && nx_info_has_v6(nxi))
29740 + /* FIXME: remap lback? */
29741 + usin->sin6_addr = nxi->v6.ip;
29743 + usin->sin6_addr.s6_addr[15] = 0x1;
29746 addr_type = ipv6_addr_type(&usin->sin6_addr);
29748 diff -Nurp linux-2.6.22.15/net/ipv6/udp.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/udp.c
29749 --- linux-2.6.22.15/net/ipv6/udp.c 2007-07-21 18:00:27.000000000 -0400
29750 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/udp.c 2007-12-09 06:44:23.000000000 -0500
29753 #include <linux/proc_fs.h>
29754 #include <linux/seq_file.h>
29755 +#include <linux/vs_inet6.h>
29756 #include "udp_impl.h"
29758 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
29759 @@ -82,6 +83,10 @@ static struct sock *__udp6_lib_lookup(st
29760 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29764 + /* block non nx_info ips */
29765 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29768 if (!ipv6_addr_any(&np->daddr)) {
29769 if (!ipv6_addr_equal(&np->daddr, saddr))
29770 diff -Nurp linux-2.6.22.15/net/ipv6/xfrm6_policy.c linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/xfrm6_policy.c
29771 --- linux-2.6.22.15/net/ipv6/xfrm6_policy.c 2007-07-21 18:00:27.000000000 -0400
29772 +++ linux-2.6.22.15-vs2.3.0.29.1/net/ipv6/xfrm6_policy.c 2007-12-09 06:44:23.000000000 -0500
29773 @@ -49,7 +49,7 @@ static int xfrm6_get_saddr(xfrm_address_
29775 if (!xfrm6_dst_lookup((struct xfrm_dst **)&rt, &fl_tunnel)) {
29776 ipv6_get_saddr(&rt->u.dst, (struct in6_addr *)&daddr->a6,
29777 - (struct in6_addr *)&saddr->a6);
29778 + (struct in6_addr *)&saddr->a6, NULL);
29779 dst_release(&rt->u.dst);
29782 diff -Nurp linux-2.6.22.15/net/netlink/af_netlink.c linux-2.6.22.15-vs2.3.0.29.1/net/netlink/af_netlink.c
29783 --- linux-2.6.22.15/net/netlink/af_netlink.c 2007-12-09 06:43:53.000000000 -0500
29784 +++ linux-2.6.22.15-vs2.3.0.29.1/net/netlink/af_netlink.c 2007-12-09 06:44:23.000000000 -0500
29786 #include <linux/audit.h>
29787 #include <linux/selinux.h>
29788 #include <linux/mutex.h>
29789 +#include <linux/vs_context.h>
29790 +#include <linux/vs_network.h>
29791 +#include <linux/vs_limit.h>
29793 #include <net/sock.h>
29794 #include <net/scm.h>
29795 diff -Nurp linux-2.6.22.15/net/rxrpc/Kconfig linux-2.6.22.15-vs2.3.0.29.1/net/rxrpc/Kconfig
29796 --- linux-2.6.22.15/net/rxrpc/Kconfig 2007-07-21 18:00:27.000000000 -0400
29797 +++ linux-2.6.22.15-vs2.3.0.29.1/net/rxrpc/Kconfig 2007-12-09 06:45:27.000000000 -0500
29801 tristate "RxRPC session sockets"
29802 - depends on INET && EXPERIMENTAL
29803 + depends on INET && EXPERIMENTAL && !VSERVER_SECURITY
29807 diff -Nurp linux-2.6.22.15/net/sctp/ipv6.c linux-2.6.22.15-vs2.3.0.29.1/net/sctp/ipv6.c
29808 --- linux-2.6.22.15/net/sctp/ipv6.c 2007-08-11 21:54:37.000000000 -0400
29809 +++ linux-2.6.22.15-vs2.3.0.29.1/net/sctp/ipv6.c 2007-12-09 06:44:23.000000000 -0500
29810 @@ -303,7 +303,7 @@ static void sctp_v6_get_saddr(struct sct
29811 __FUNCTION__, asoc, dst, NIP6(daddr->v6.sin6_addr));
29814 - ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr);
29815 + ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr, asoc->base.sk->sk_nx_info);
29816 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n",
29817 NIP6(saddr->v6.sin6_addr));
29819 diff -Nurp linux-2.6.22.15/net/socket.c linux-2.6.22.15-vs2.3.0.29.1/net/socket.c
29820 --- linux-2.6.22.15/net/socket.c 2007-12-09 06:43:53.000000000 -0500
29821 +++ linux-2.6.22.15-vs2.3.0.29.1/net/socket.c 2007-12-09 06:44:23.000000000 -0500
29824 #include <net/sock.h>
29825 #include <linux/netfilter.h>
29826 +#include <linux/vs_base.h>
29827 +#include <linux/vs_socket.h>
29828 +#include <linux/vs_inet.h>
29829 +#include <linux/vs_inet6.h>
29831 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
29832 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
29833 @@ -543,7 +547,7 @@ static inline int __sock_sendmsg(struct
29834 struct msghdr *msg, size_t size)
29836 struct sock_iocb *si = kiocb_to_siocb(iocb);
29842 @@ -554,7 +558,22 @@ static inline int __sock_sendmsg(struct
29846 - return sock->ops->sendmsg(iocb, sock, msg, size);
29847 + len = sock->ops->sendmsg(iocb, sock, msg, size);
29850 + vx_sock_send(sock->sk, size);
29852 + vx_sock_fail(sock->sk, size);
29854 + vxdprintk(VXD_CBIT(net, 7),
29855 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29857 + (sock->sk)?sock->sk->sk_nx_info:0,
29858 + (sock->sk)?sock->sk->sk_vx_info:0,
29859 + (sock->sk)?sock->sk->sk_xid:0,
29860 + (sock->sk)?sock->sk->sk_nid:0,
29861 + (unsigned int)size, len);
29865 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
29866 @@ -623,7 +642,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
29867 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
29868 struct msghdr *msg, size_t size, int flags)
29872 struct sock_iocb *si = kiocb_to_siocb(iocb);
29875 @@ -636,7 +655,18 @@ static inline int __sock_recvmsg(struct
29879 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
29880 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
29881 + if ((len >= 0) && sock->sk)
29882 + vx_sock_recv(sock->sk, len);
29883 + vxdprintk(VXD_CBIT(net, 7),
29884 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29886 + (sock->sk)?sock->sk->sk_nx_info:0,
29887 + (sock->sk)?sock->sk->sk_vx_info:0,
29888 + (sock->sk)?sock->sk->sk_xid:0,
29889 + (sock->sk)?sock->sk->sk_nid:0,
29890 + (unsigned int)size, len);
29894 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
29895 @@ -1087,6 +1117,13 @@ static int __sock_create(int family, int
29896 if (type < 0 || type >= SOCK_MAX)
29899 + if (!nx_check(0, VS_ADMIN)) {
29900 + if (family == PF_INET && !current_nx_info_has_v4())
29901 + return -EAFNOSUPPORT;
29902 + if (family == PF_INET6 && !current_nx_info_has_v6())
29903 + return -EAFNOSUPPORT;
29908 This uglymoron is moved from INET layer to here to avoid
29909 @@ -1204,6 +1241,7 @@ asmlinkage long sys_socket(int family, i
29913 + set_bit(SOCK_USER_SOCKET, &sock->flags);
29914 retval = sock_map_fd(sock);
29917 @@ -1236,10 +1274,12 @@ asmlinkage long sys_socketpair(int famil
29918 err = sock_create(family, type, protocol, &sock1);
29921 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
29923 err = sock_create(family, type, protocol, &sock2);
29925 goto out_release_1;
29926 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
29928 err = sock1->ops->socketpair(sock1, sock2);
29930 diff -Nurp linux-2.6.22.15/net/sunrpc/auth.c linux-2.6.22.15-vs2.3.0.29.1/net/sunrpc/auth.c
29931 --- linux-2.6.22.15/net/sunrpc/auth.c 2007-07-21 17:59:04.000000000 -0400
29932 +++ linux-2.6.22.15-vs2.3.0.29.1/net/sunrpc/auth.c 2007-12-09 06:44:23.000000000 -0500
29934 #include <linux/errno.h>
29935 #include <linux/sunrpc/clnt.h>
29936 #include <linux/spinlock.h>
29937 +#include <linux/vs_tag.h>
29940 # define RPCDBG_FACILITY RPCDBG_AUTH
29941 @@ -263,6 +264,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
29942 struct auth_cred acred = {
29943 .uid = current->fsuid,
29944 .gid = current->fsgid,
29945 + .tag = dx_current_tag(),
29946 .group_info = current->group_info,
29948 struct rpc_cred *ret;
29949 @@ -282,6 +284,7 @@ rpcauth_bindcred(struct rpc_task *task)
29950 struct auth_cred acred = {
29951 .uid = current->fsuid,
29952 .gid = current->fsgid,
29953 + .tag = dx_current_tag(),
29954 .group_info = current->group_info,
29956 struct rpc_cred *ret;
29957 diff -Nurp linux-2.6.22.15/net/sunrpc/auth_unix.c linux-2.6.22.15-vs2.3.0.29.1/net/sunrpc/auth_unix.c
29958 --- linux-2.6.22.15/net/sunrpc/auth_unix.c 2007-07-21 17:59:04.000000000 -0400
29959 +++ linux-2.6.22.15-vs2.3.0.29.1/net/sunrpc/auth_unix.c 2007-12-09 06:44:23.000000000 -0500
29960 @@ -11,12 +11,14 @@
29961 #include <linux/module.h>
29962 #include <linux/sunrpc/clnt.h>
29963 #include <linux/sunrpc/auth.h>
29964 +#include <linux/vs_tag.h>
29966 #define NFS_NGROUPS 16
29969 struct rpc_cred uc_base;
29972 gid_t uc_gids[NFS_NGROUPS];
29974 #define uc_uid uc_base.cr_uid
29975 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
29976 if (flags & RPCAUTH_LOOKUP_ROOTCREDS) {
29979 + cred->uc_tag = dx_current_tag();
29980 cred->uc_gids[0] = NOGROUP;
29982 int groups = acred->group_info->ngroups;
29983 @@ -87,6 +90,7 @@ unx_create_cred(struct rpc_auth *auth, s
29985 cred->uc_uid = acred->uid;
29986 cred->uc_gid = acred->gid;
29987 + cred->uc_tag = acred->tag;
29988 for (i = 0; i < groups; i++)
29989 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
29990 if (i < NFS_NGROUPS)
29991 @@ -118,7 +122,8 @@ unx_match(struct auth_cred *acred, struc
29994 if (cred->uc_uid != acred->uid
29995 - || cred->uc_gid != acred->gid)
29996 + || cred->uc_gid != acred->gid
29997 + || cred->uc_tag != acred->tag)
30000 groups = acred->group_info->ngroups;
30001 @@ -144,7 +149,7 @@ unx_marshal(struct rpc_task *task, __be3
30002 struct rpc_clnt *clnt = task->tk_client;
30003 struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred;
30004 __be32 *base, *hold;
30008 *p++ = htonl(RPC_AUTH_UNIX);
30010 @@ -154,9 +159,12 @@ unx_marshal(struct rpc_task *task, __be3
30011 * Copy the UTS nodename captured when the client was created.
30013 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
30014 + tag = task->tk_client->cl_tag;
30016 - *p++ = htonl((u32) cred->uc_uid);
30017 - *p++ = htonl((u32) cred->uc_gid);
30018 + *p++ = htonl((u32) TAGINO_UID(tag,
30019 + cred->uc_uid, cred->uc_tag));
30020 + *p++ = htonl((u32) TAGINO_GID(tag,
30021 + cred->uc_gid, cred->uc_tag));
30023 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
30024 *p++ = htonl((u32) cred->uc_gids[i]);
30025 diff -Nurp linux-2.6.22.15/net/sunrpc/clnt.c linux-2.6.22.15-vs2.3.0.29.1/net/sunrpc/clnt.c
30026 --- linux-2.6.22.15/net/sunrpc/clnt.c 2007-07-21 18:00:28.000000000 -0400
30027 +++ linux-2.6.22.15-vs2.3.0.29.1/net/sunrpc/clnt.c 2007-12-09 06:44:23.000000000 -0500
30029 #include <linux/smp_lock.h>
30030 #include <linux/utsname.h>
30031 #include <linux/workqueue.h>
30032 +#include <linux/vs_cvirt.h>
30034 #include <linux/sunrpc/clnt.h>
30035 #include <linux/sunrpc/rpc_pipe_fs.h>
30036 @@ -249,7 +250,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
30037 clnt->cl_oneshot = 1;
30038 if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
30039 clnt->cl_discrtry = 1;
30041 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
30042 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
30043 + clnt->cl_tag = 1; */
30046 EXPORT_SYMBOL_GPL(rpc_create);
30047 diff -Nurp linux-2.6.22.15/net/unix/af_unix.c linux-2.6.22.15-vs2.3.0.29.1/net/unix/af_unix.c
30048 --- linux-2.6.22.15/net/unix/af_unix.c 2007-07-21 18:00:28.000000000 -0400
30049 +++ linux-2.6.22.15-vs2.3.0.29.1/net/unix/af_unix.c 2007-12-09 06:44:23.000000000 -0500
30050 @@ -115,6 +115,8 @@
30051 #include <linux/mount.h>
30052 #include <net/checksum.h>
30053 #include <linux/security.h>
30054 +#include <linux/vs_context.h>
30055 +#include <linux/vs_limit.h>
30057 int sysctl_unix_max_dgram_qlen __read_mostly = 10;
30059 @@ -252,6 +254,8 @@ static struct sock *__unix_find_socket_b
30060 sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
30061 struct unix_sock *u = unix_sk(s);
30063 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
30065 if (u->addr->len == len &&
30066 !memcmp(u->addr->name, sunname, len))
30068 @@ -807,7 +811,7 @@ static int unix_bind(struct socket *sock
30071 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
30072 - err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
30073 + err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0, NULL);
30075 goto out_mknod_dput;
30076 mutex_unlock(&nd.dentry->d_inode->i_mutex);
30077 diff -Nurp linux-2.6.22.15/net/x25/af_x25.c linux-2.6.22.15-vs2.3.0.29.1/net/x25/af_x25.c
30078 --- linux-2.6.22.15/net/x25/af_x25.c 2007-07-21 18:00:28.000000000 -0400
30079 +++ linux-2.6.22.15-vs2.3.0.29.1/net/x25/af_x25.c 2007-12-09 06:44:23.000000000 -0500
30080 @@ -500,7 +500,10 @@ static int x25_create(struct socket *soc
30084 - sock_init_data(sock, sk);
30085 + sk->sk_socket = sock;
30086 + sk->sk_type = sock->type;
30087 + sk->sk_sleep = &sock->wait;
30090 x25_init_timers(sk);
30092 diff -Nurp linux-2.6.22.15/security/commoncap.c linux-2.6.22.15-vs2.3.0.29.1/security/commoncap.c
30093 --- linux-2.6.22.15/security/commoncap.c 2007-07-21 18:00:28.000000000 -0400
30094 +++ linux-2.6.22.15-vs2.3.0.29.1/security/commoncap.c 2007-12-09 06:44:23.000000000 -0500
30095 @@ -22,10 +22,11 @@
30096 #include <linux/ptrace.h>
30097 #include <linux/xattr.h>
30098 #include <linux/hugetlb.h>
30099 +#include <linux/vs_context.h>
30101 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
30103 - NETLINK_CB(skb).eff_cap = current->cap_effective;
30104 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
30108 @@ -43,7 +44,7 @@ EXPORT_SYMBOL(cap_netlink_recv);
30109 int cap_capable (struct task_struct *tsk, int cap)
30111 /* Derived from include/linux/sched.h:capable. */
30112 - if (cap_raised(tsk->cap_effective, cap))
30113 + if (vx_cap_raised(tsk->vx_info, tsk->cap_effective, cap))
30117 @@ -141,7 +142,8 @@ void cap_bprm_apply_creds (struct linux_
30118 /* Derived from fs/exec.c:compute_creds. */
30119 kernel_cap_t new_permitted, working;
30121 - new_permitted = cap_intersect (bprm->cap_permitted, cap_bset);
30122 + new_permitted = cap_intersect (bprm->cap_permitted,
30123 + vx_current_cap_bset());
30124 working = cap_intersect (bprm->cap_inheritable,
30125 current->cap_inheritable);
30126 new_permitted = cap_combine (new_permitted, working);
30127 @@ -310,7 +312,8 @@ void cap_task_reparent_to_init (struct t
30129 int cap_syslog (int type)
30131 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
30132 + if ((type != 3 && type != 10) &&
30133 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
30137 diff -Nurp linux-2.6.22.15/security/dummy.c linux-2.6.22.15-vs2.3.0.29.1/security/dummy.c
30138 --- linux-2.6.22.15/security/dummy.c 2007-07-21 17:59:05.000000000 -0400
30139 +++ linux-2.6.22.15-vs2.3.0.29.1/security/dummy.c 2007-12-09 06:44:23.000000000 -0500
30141 #include <linux/hugetlb.h>
30142 #include <linux/ptrace.h>
30143 #include <linux/file.h>
30144 +#include <linux/vs_context.h>
30146 static int dummy_ptrace (struct task_struct *parent, struct task_struct *child)
30148 @@ -678,7 +679,7 @@ static int dummy_sem_semop (struct sem_a
30150 static int dummy_netlink_send (struct sock *sk, struct sk_buff *skb)
30152 - NETLINK_CB(skb).eff_cap = current->cap_effective;
30153 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
30157 diff -Nurp linux-2.6.22.15/security/Kconfig linux-2.6.22.15-vs2.3.0.29.1/security/Kconfig
30158 --- linux-2.6.22.15/security/Kconfig 2007-05-04 09:57:46.000000000 -0400
30159 +++ linux-2.6.22.15-vs2.3.0.29.1/security/Kconfig 2007-12-09 06:44:23.000000000 -0500
30160 @@ -6,6 +6,7 @@ menu "Security options"
30163 bool "Enable access key retention support"
30164 + depends on !VSERVER_SECURITY
30166 This option provides support for retaining authentication tokens and
30167 access keys in the kernel.
30168 diff -Nurp linux-2.6.22.15/security/selinux/hooks.c linux-2.6.22.15-vs2.3.0.29.1/security/selinux/hooks.c
30169 --- linux-2.6.22.15/security/selinux/hooks.c 2007-10-29 21:18:04.000000000 -0400
30170 +++ linux-2.6.22.15-vs2.3.0.29.1/security/selinux/hooks.c 2007-12-09 06:44:23.000000000 -0500
30172 #include <linux/dccp.h>
30173 #include <linux/quota.h>
30174 #include <linux/un.h> /* for Unix socket types */
30175 -#include <net/af_unix.h> /* for Unix socket types */
30176 #include <linux/parser.h>
30177 #include <linux/nfs_mount.h>
30178 #include <net/ipv6.h>
30179 diff -u linux-2.6.22.16-vs2.3.0.29.1/fs/ocfs2/ioctl.c linux-2.6.22.16-vs2.3.0.29.2/fs/ocfs2/ioctl.c
30180 --- linux-2.6.22.16-vs2.3.0.29.1/fs/ocfs2/ioctl.c 2008-01-15 16:18:33.000000000 +0100
30181 +++ linux-2.6.22.16-vs2.3.0.29.2/fs/ocfs2/ioctl.c 2008-01-18 12:45:12.000000000 +0100
30186 +/* Called with inode->i_mutex locked */
30187 int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
30194 - mutex_lock(&inode->i_mutex);
30196 status = ocfs2_meta_lock(inode, &bh, 1);
30198 mlog_errno(status);
30199 @@ -101,8 +100,6 @@
30201 ocfs2_meta_unlock(inode, 1);
30203 - mutex_unlock(&inode->i_mutex);
30208 @@ -110,6 +107,16 @@
30212 +static inline int ocfs2_set_inode_attr_lock(struct inode *inode,
30213 + unsigned flags, unsigned mask)
30216 + mutex_lock(&inode->i_mutex);
30217 + ret = ocfs2_set_inode_attr(inode, flags, mask);
30218 + mutex_unlock(&inode->i_mutex);
30222 int ocfs2_ioctl(struct inode * inode, struct file * filp,
30223 unsigned int cmd, unsigned long arg)
30225 @@ -128,7 +135,7 @@
30226 if (get_user(flags, (int __user *) arg))
30229 - return ocfs2_set_inode_attr(inode, flags,
30230 + return ocfs2_set_inode_attr_lock(inode, flags,
30231 OCFS2_FL_MODIFIABLE);
30234 diff -u linux-2.6.22.16-vs2.3.0.29.1/kernel/signal.c linux-2.6.22.16-vs2.3.0.29.2/kernel/signal.c
30235 --- linux-2.6.22.16-vs2.3.0.29.1/kernel/signal.c 2008-01-15 16:18:34.000000000 +0100
30236 +++ linux-2.6.22.16-vs2.3.0.29.2/kernel/signal.c 2008-01-18 12:45:49.000000000 +0100
30237 @@ -1136,7 +1136,8 @@
30238 read_lock(&tasklist_lock);
30239 for_each_process(p) {
30240 if (vx_check(vx_task_xid(p), VS_ADMIN_P|VS_IDENT) &&
30241 - p->pid > 1 && p->tgid != current->tgid) {
30242 + p->pid > 1 && p->tgid != current->tgid &&
30243 + !vx_current_initpid(p->pid)) {
30244 int err = group_send_sig_info(sig, info, p);
30247 @@ -1146,9 +1147,9 @@
30248 read_unlock(&tasklist_lock);
30249 ret = count ? retval : -ESRCH;
30250 } else if (pid < 0) {
30251 - ret = kill_pgrp_info(sig, info, find_pid(-pid));
30252 + ret = kill_pgrp_info(sig, info, find_pid(vx_rmap_pid(-pid)));
30254 - ret = kill_pid_info(sig, info, find_pid(pid));
30255 + ret = kill_pid_info(sig, info, find_pid(vx_rmap_pid(pid)));