1 diff -NurpP --minimal linux-2.6.22.10/Documentation/vserver/debug.txt linux-2.6.22.10-vs2.3.0.29/Documentation/vserver/debug.txt
2 --- linux-2.6.22.10/Documentation/vserver/debug.txt 1970-01-01 01:00:00 +0100
3 +++ linux-2.6.22.10-vs2.3.0.29/Documentation/vserver/debug.txt 2007-08-05 20:53:12 +0200
8 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
9 + "vx_rmap_tgid: %p/%llx: %d -> %d"
13 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
14 + "FREE (%p,#%d)%c inode"
15 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
16 + "FREE (%p,#%d)%c %lld bytes"
17 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
18 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
19 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
20 + "rcu_free_dl_info(%p)"
21 + 4 10 "alloc_dl_info(%p,%d) = %p"
22 + "dealloc_dl_info(%p)"
23 + "get_dl_info(%p[#%d.%d])"
24 + "put_dl_info(%p[#%d.%d])"
25 + 5 20 "alloc_dl_info(%p,%d)*"
26 + 6 40 "__hash_dl_info: %p[#%d]"
27 + "__unhash_dl_info: %p[#%d]"
28 + 7 80 "locate_dl_info(%p,#%d) = %p"
32 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
33 + "new_dqhash: %p [#0x%08x]"
34 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
35 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
36 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
37 + "vroot_get_real_bdev not set"
38 + 1 2 "cow_break_link(»%s«)"
40 + 2 4 "dentry_open(new): %p"
41 + "dentry_open(old): %p"
42 + "lookup_create(new): %p"
44 + "path_lookup(old): %d"
45 + "vfs_create(new): %d"
48 + 3 8 "fput(new_file=%p[#%d])"
49 + "fput(old_file=%p[#%d])"
50 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
51 + "vx_info_kill(%p[#%d],%d,%d)*"
52 + 5 20 "vs_reboot(%p[#%d],%d)"
53 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
57 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
58 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
59 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
60 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
61 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
62 + 6 40 "sk,egf: %p [#%d] (from %d)"
63 + "sk,egn: %p [#%d] (from %d)"
64 + "sk,req: %p [#%d] (from %d)"
65 + "sk: %p [#%d] (from %d)"
66 + "tw: %p [#%d] (from %d)"
67 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
68 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
72 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
73 + "alloc_nx_info(%d) = %p"
74 + "create_nx_info(%d) (dynamic rejected)"
75 + "create_nx_info(%d) = %p (already there)"
76 + "create_nx_info(%d) = %p (new)"
77 + "dealloc_nx_info(%p)"
78 + 1 2 "alloc_nx_info(%d)*"
79 + "create_nx_info(%d)*"
80 + 2 4 "get_nx_info(%p[#%d.%d])"
81 + "put_nx_info(%p[#%d.%d])"
82 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
83 + "clr_nx_info(%p[#%d.%d])"
84 + "init_nx_info(%p[#%d.%d])"
85 + "release_nx_info(%p[#%d.%d.%d]) %p"
86 + "set_nx_info(%p[#%d.%d])"
87 + 4 10 "__hash_nx_info: %p[#%d]"
88 + "__nx_dynamic_id: [#%d]"
89 + "__unhash_nx_info: %p[#%d.%d.%d]"
90 + 5 20 "moved task %p into nxi:%p[#%d]"
91 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
92 + "task_get_nx_info(%p)"
93 + 6 40 "nx_clear_persistent(%p[#%d])"
97 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
98 + 1 2 "quota_sync_dqh(%p,%d)"
99 + "sync_dquots(%p,%d)"
100 + "sync_dquots_dqh(%p,%d)"
101 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
105 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
106 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
107 + 4 10 "%s: (%s %s) returned %s with %d"
111 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
112 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
116 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
117 + "alloc_vx_info(%d) = %p"
118 + "alloc_vx_info(%d)*"
119 + "create_vx_info(%d) (dynamic rejected)"
120 + "create_vx_info(%d) = %p (already there)"
121 + "create_vx_info(%d) = %p (new)"
122 + "dealloc_vx_info(%p)"
123 + "loc_vx_info(%d) = %p (found)"
124 + "loc_vx_info(%d) = %p (new)"
125 + "loc_vx_info(%d) = %p (not available)"
126 + 1 2 "create_vx_info(%d)*"
128 + 2 4 "get_vx_info(%p[#%d.%d])"
129 + "put_vx_info(%p[#%d.%d])"
130 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
131 + "clr_vx_info(%p[#%d.%d])"
132 + "init_vx_info(%p[#%d.%d])"
133 + "release_vx_info(%p[#%d.%d.%d]) %p"
134 + "set_vx_info(%p[#%d.%d])"
135 + 4 10 "__hash_vx_info: %p[#%d]"
136 + "__unhash_vx_info: %p[#%d.%d.%d]"
137 + "__vx_dynamic_id: [#%d]"
138 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
139 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
140 + "moved task %p into vxi:%p[#%d]"
141 + "task_get_vx_info(%p)"
142 + "vx_migrate_task(%p,%p[#%d.%d])"
143 + 6 40 "vx_clear_persistent(%p[#%d])"
144 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
145 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
146 + "vx_set_persistent(%p[#%d])"
147 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
148 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
153 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
154 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
156 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
157 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
158 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
159 diff -NurpP --minimal linux-2.6.22.10/Makefile linux-2.6.22.10-vs2.3.0.29/Makefile
160 --- linux-2.6.22.10/Makefile 2007-10-30 01:57:11 +0100
161 +++ linux-2.6.22.10-vs2.3.0.29/Makefile 2007-10-30 02:41:27 +0100
167 +EXTRAVERSION = .14-vs2.3.0.29
168 NAME = Holy Dancing Manatees, Batman!
171 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/alpha/Kconfig
172 --- linux-2.6.22.10/arch/alpha/Kconfig 2007-07-09 13:17:31 +0200
173 +++ linux-2.6.22.10-vs2.3.0.29/arch/alpha/Kconfig 2007-08-05 20:53:12 +0200
174 @@ -662,6 +662,8 @@ config DUMMY_CONSOLE
178 +source "kernel/vserver/Kconfig"
180 source "security/Kconfig"
182 source "crypto/Kconfig"
183 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/asm-offsets.c linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/asm-offsets.c
184 --- linux-2.6.22.10/arch/alpha/kernel/asm-offsets.c 2006-02-15 13:54:10 +0100
185 +++ linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/asm-offsets.c 2007-08-05 20:53:12 +0200
186 @@ -36,6 +36,7 @@ void foo(void)
187 DEFINE(PT_PTRACED, PT_PTRACED);
188 DEFINE(CLONE_VM, CLONE_VM);
189 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
190 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
191 DEFINE(SIGCHLD, SIGCHLD);
194 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/entry.S linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/entry.S
195 --- linux-2.6.22.10/arch/alpha/kernel/entry.S 2007-07-09 13:17:31 +0200
196 +++ linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/entry.S 2007-08-05 20:53:12 +0200
197 @@ -643,7 +643,7 @@ kernel_thread:
198 stq $2, 152($sp) /* HAE */
200 /* Shuffle FLAGS to the front; add CLONE_VM. */
201 - ldi $1, CLONE_VM|CLONE_UNTRACED
202 + ldi $1, CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
206 @@ -872,24 +872,15 @@ sys_getxgid:
213 - ldq $2, TI_TASK($8)
215 - /* See linux/kernel/timer.c sys_getppid for discussion
216 - about this loop. */
217 - ldq $3, TASK_GROUP_LEADER($2)
218 - ldq $4, TASK_REAL_PARENT($3)
219 - ldl $0, TASK_TGID($2)
220 -1: ldl $1, TASK_TGID($4)
224 - ldq $3, TASK_GROUP_LEADER($2)
225 - ldq $4, TASK_REAL_PARENT($3)
231 + jsr $26, do_getxpid
238 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/osf_sys.c linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/osf_sys.c
239 --- linux-2.6.22.10/arch/alpha/kernel/osf_sys.c 2007-07-09 13:17:31 +0200
240 +++ linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/osf_sys.c 2007-08-05 20:53:12 +0200
241 @@ -883,7 +883,7 @@ osf_gettimeofday(struct timeval32 __user
245 - do_gettimeofday(&ktv);
246 + vx_gettimeofday(&ktv);
247 if (put_tv32(tv, &ktv))
250 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/ptrace.c
251 --- linux-2.6.22.10/arch/alpha/kernel/ptrace.c 2006-04-09 13:49:39 +0200
252 +++ linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/ptrace.c 2007-08-05 20:53:12 +0200
254 #include <linux/slab.h>
255 #include <linux/security.h>
256 #include <linux/signal.h>
257 +#include <linux/vs_base.h>
259 #include <asm/uaccess.h>
260 #include <asm/pgtable.h>
261 @@ -283,6 +284,11 @@ do_sys_ptrace(long request, long pid, lo
265 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
270 if (request == PTRACE_ATTACH) {
271 ret = ptrace_attach(child);
273 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/semaphore.c linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/semaphore.c
274 --- linux-2.6.22.10/arch/alpha/kernel/semaphore.c 2004-08-14 12:55:32 +0200
275 +++ linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/semaphore.c 2007-08-05 20:53:12 +0200
276 @@ -68,8 +68,8 @@ __down_failed(struct semaphore *sem)
277 DECLARE_WAITQUEUE(wait, tsk);
279 #ifdef CONFIG_DEBUG_SEMAPHORE
280 - printk("%s(%d): down failed(%p)\n",
281 - tsk->comm, tsk->pid, sem);
282 + printk("%s(%d:#%u): down failed(%p)\n",
283 + tsk->comm, tsk->pid, tsk->xid, sem);
286 tsk->state = TASK_UNINTERRUPTIBLE;
287 @@ -97,8 +97,8 @@ __down_failed(struct semaphore *sem)
290 #ifdef CONFIG_DEBUG_SEMAPHORE
291 - printk("%s(%d): down acquired(%p)\n",
292 - tsk->comm, tsk->pid, sem);
293 + printk("%s(%d:#%u): down acquired(%p)\n",
294 + tsk->comm, tsk->pid, tsk->xid, sem);
298 @@ -110,8 +110,8 @@ __down_failed_interruptible(struct semap
301 #ifdef CONFIG_DEBUG_SEMAPHORE
302 - printk("%s(%d): down failed(%p)\n",
303 - tsk->comm, tsk->pid, sem);
304 + printk("%s(%d:#%u): down failed(%p)\n",
305 + tsk->comm, tsk->pid, tsk->xid, sem);
308 tsk->state = TASK_INTERRUPTIBLE;
309 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/systbls.S linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/systbls.S
310 --- linux-2.6.22.10/arch/alpha/kernel/systbls.S 2007-07-09 13:17:31 +0200
311 +++ linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/systbls.S 2007-08-05 20:53:12 +0200
312 @@ -446,7 +446,7 @@ sys_call_table:
313 .quad sys_stat64 /* 425 */
316 - .quad sys_ni_syscall /* sys_vserver */
317 + .quad sys_vserver /* sys_vserver */
318 .quad sys_ni_syscall /* sys_mbind */
319 .quad sys_ni_syscall /* sys_get_mempolicy */
320 .quad sys_ni_syscall /* sys_set_mempolicy */
321 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/traps.c
322 --- linux-2.6.22.10/arch/alpha/kernel/traps.c 2006-09-20 16:57:57 +0200
323 +++ linux-2.6.22.10-vs2.3.0.29/arch/alpha/kernel/traps.c 2007-08-05 20:53:12 +0200
324 @@ -182,7 +182,8 @@ die_if_kernel(char * str, struct pt_regs
326 printk("CPU %d ", hard_smp_processor_id());
328 - printk("%s(%d): %s %ld\n", current->comm, current->pid, str, err);
329 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
330 + current->pid, current->xid, str, err);
331 dik_show_regs(regs, r9_15);
332 dik_show_trace((unsigned long *)(regs+1));
333 dik_show_code((unsigned int *)regs->pc);
334 diff -NurpP --minimal linux-2.6.22.10/arch/alpha/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/alpha/mm/fault.c
335 --- linux-2.6.22.10/arch/alpha/mm/fault.c 2007-07-09 13:17:32 +0200
336 +++ linux-2.6.22.10-vs2.3.0.29/arch/alpha/mm/fault.c 2007-08-05 20:53:12 +0200
337 @@ -197,8 +197,8 @@ do_page_fault(unsigned long address, uns
338 down_read(&mm->mmap_sem);
341 - printk(KERN_ALERT "VM: killing process %s(%d)\n",
342 - current->comm, current->pid);
343 + printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
344 + current->comm, current->pid, current->xid);
345 if (!user_mode(regs))
348 diff -NurpP --minimal linux-2.6.22.10/arch/arm/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/arm/Kconfig
349 --- linux-2.6.22.10/arch/arm/Kconfig 2007-07-09 13:17:32 +0200
350 +++ linux-2.6.22.10-vs2.3.0.29/arch/arm/Kconfig 2007-08-05 20:53:12 +0200
351 @@ -1042,6 +1042,8 @@ source "arch/arm/oprofile/Kconfig"
353 source "arch/arm/Kconfig.debug"
355 +source "kernel/vserver/Kconfig"
357 source "security/Kconfig"
359 source "crypto/Kconfig"
360 diff -NurpP --minimal linux-2.6.22.10/arch/arm/kernel/calls.S linux-2.6.22.10-vs2.3.0.29/arch/arm/kernel/calls.S
361 --- linux-2.6.22.10/arch/arm/kernel/calls.S 2007-07-09 13:17:32 +0200
362 +++ linux-2.6.22.10-vs2.3.0.29/arch/arm/kernel/calls.S 2007-08-05 20:53:12 +0200
364 /* 310 */ CALL(sys_request_key)
366 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
367 -/* vserver */ CALL(sys_ni_syscall)
370 /* 315 */ CALL(sys_ioprio_get)
371 CALL(sys_inotify_init)
372 diff -NurpP --minimal linux-2.6.22.10/arch/arm/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/arm/kernel/process.c
373 --- linux-2.6.22.10/arch/arm/kernel/process.c 2007-07-09 13:17:32 +0200
374 +++ linux-2.6.22.10-vs2.3.0.29/arch/arm/kernel/process.c 2007-08-05 20:53:12 +0200
375 @@ -261,7 +261,8 @@ void __show_regs(struct pt_regs *regs)
376 void show_regs(struct pt_regs * regs)
379 - printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
380 + printk("Pid: %d[#%u], comm: %20s\n",
381 + current->pid, current->xid, current->comm);
385 @@ -423,7 +424,8 @@ pid_t kernel_thread(int (*fn)(void *), v
386 regs.ARM_pc = (unsigned long)kernel_thread_helper;
387 regs.ARM_cpsr = SVC_MODE;
389 - return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
390 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
391 + 0, ®s, 0, NULL, NULL);
393 EXPORT_SYMBOL(kernel_thread);
395 diff -NurpP --minimal linux-2.6.22.10/arch/arm/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/arm/kernel/traps.c
396 --- linux-2.6.22.10/arch/arm/kernel/traps.c 2007-07-09 13:17:32 +0200
397 +++ linux-2.6.22.10-vs2.3.0.29/arch/arm/kernel/traps.c 2007-08-05 20:53:12 +0200
398 @@ -222,8 +222,8 @@ static void __die(const char *str, int e
399 str, err, ++die_counter);
402 - printk("Process %s (pid: %d, stack limit = 0x%p)\n",
403 - tsk->comm, tsk->pid, thread + 1);
404 + printk("Process %s (pid: %d:#%u, stack limit = 0x%p)\n",
405 + tsk->comm, tsk->pid, tsk->xid, thread + 1);
407 if (!user_mode(regs) || in_interrupt()) {
408 dump_mem("Stack: ", regs->ARM_sp,
409 diff -NurpP --minimal linux-2.6.22.10/arch/arm/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/arm/mm/fault.c
410 --- linux-2.6.22.10/arch/arm/mm/fault.c 2007-07-09 13:17:39 +0200
411 +++ linux-2.6.22.10-vs2.3.0.29/arch/arm/mm/fault.c 2007-08-05 20:53:12 +0200
412 @@ -266,7 +266,8 @@ do_page_fault(unsigned long addr, unsign
413 * happened to us that made us unable to handle
414 * the page fault gracefully.
416 - printk("VM: killing process %s\n", tsk->comm);
417 + printk("VM: killing process %s(%d:#%u)\n",
418 + tsk->comm, tsk->pid, tsk->xid);
422 diff -NurpP --minimal linux-2.6.22.10/arch/arm26/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/arm26/Kconfig
423 --- linux-2.6.22.10/arch/arm26/Kconfig 2007-07-09 13:17:40 +0200
424 +++ linux-2.6.22.10-vs2.3.0.29/arch/arm26/Kconfig 2007-08-05 20:53:12 +0200
425 @@ -243,6 +243,8 @@ source "drivers/usb/Kconfig"
427 source "arch/arm26/Kconfig.debug"
429 +source "kernel/vserver/Kconfig"
431 source "security/Kconfig"
433 source "crypto/Kconfig"
434 diff -NurpP --minimal linux-2.6.22.10/arch/arm26/kernel/calls.S linux-2.6.22.10-vs2.3.0.29/arch/arm26/kernel/calls.S
435 --- linux-2.6.22.10/arch/arm26/kernel/calls.S 2005-03-02 12:38:19 +0100
436 +++ linux-2.6.22.10-vs2.3.0.29/arch/arm26/kernel/calls.S 2007-08-05 20:53:12 +0200
437 @@ -257,6 +257,11 @@ __syscall_start:
438 .long sys_lremovexattr
439 .long sys_fremovexattr
442 + .rept 313 - (. - __syscall_start) / 4
443 + .long sys_ni_syscall
445 + .long sys_vserver /* 313 */
448 .rept NR_syscalls - (__syscall_end - __syscall_start) / 4
449 diff -NurpP --minimal linux-2.6.22.10/arch/arm26/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/arm26/kernel/process.c
450 --- linux-2.6.22.10/arch/arm26/kernel/process.c 2006-09-20 16:57:57 +0200
451 +++ linux-2.6.22.10-vs2.3.0.29/arch/arm26/kernel/process.c 2007-08-05 20:53:12 +0200
452 @@ -365,7 +365,8 @@ pid_t kernel_thread(int (*fn)(void *), v
453 regs.ARM_r3 = (unsigned long)do_exit;
454 regs.ARM_pc = (unsigned long)kernel_thread_helper | MODE_SVC26;
456 - return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
457 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
458 + 0, ®s, 0, NULL, NULL);
460 EXPORT_SYMBOL(kernel_thread);
462 diff -NurpP --minimal linux-2.6.22.10/arch/arm26/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/arm26/kernel/traps.c
463 --- linux-2.6.22.10/arch/arm26/kernel/traps.c 2006-09-20 16:57:57 +0200
464 +++ linux-2.6.22.10-vs2.3.0.29/arch/arm26/kernel/traps.c 2007-08-05 20:53:12 +0200
465 @@ -185,8 +185,9 @@ NORET_TYPE void die(const char *str, str
466 printk("Internal error: %s: %x\n", str, err);
467 printk("CPU: %d\n", smp_processor_id());
469 - printk("Process %s (pid: %d, stack limit = 0x%p)\n",
470 - current->comm, current->pid, end_of_stack(tsk));
471 + printk("Process %s (pid: %d[#%u], stack limit = 0x%p)\n",
472 + current->comm, current->pid,
473 + current->xid, end_of_stack(tsk));
475 if (!user_mode(regs) || in_interrupt()) {
476 __dump_stack(tsk, (unsigned long)(regs + 1));
477 diff -NurpP --minimal linux-2.6.22.10/arch/cris/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/cris/Kconfig
478 --- linux-2.6.22.10/arch/cris/Kconfig 2007-05-02 19:24:19 +0200
479 +++ linux-2.6.22.10-vs2.3.0.29/arch/cris/Kconfig 2007-08-05 20:53:12 +0200
480 @@ -200,6 +200,8 @@ source "drivers/usb/Kconfig"
482 source "arch/cris/Kconfig.debug"
484 +source "kernel/vserver/Kconfig"
486 source "security/Kconfig"
488 source "crypto/Kconfig"
489 diff -NurpP --minimal linux-2.6.22.10/arch/cris/arch-v10/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/cris/arch-v10/kernel/process.c
490 --- linux-2.6.22.10/arch/cris/arch-v10/kernel/process.c 2006-09-20 16:57:57 +0200
491 +++ linux-2.6.22.10-vs2.3.0.29/arch/cris/arch-v10/kernel/process.c 2007-08-05 20:53:12 +0200
492 @@ -103,7 +103,8 @@ int kernel_thread(int (*fn)(void *), voi
493 regs.dccr = 1 << I_DCCR_BITNR;
495 /* Ok, create the new process.. */
496 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
497 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
498 + 0, ®s, 0, NULL, NULL);
501 /* setup the child's kernel stack with a pt_regs and switch_stack on it.
502 diff -NurpP --minimal linux-2.6.22.10/arch/cris/arch-v32/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/cris/arch-v32/kernel/process.c
503 --- linux-2.6.22.10/arch/cris/arch-v32/kernel/process.c 2006-09-20 16:57:57 +0200
504 +++ linux-2.6.22.10-vs2.3.0.29/arch/cris/arch-v32/kernel/process.c 2007-08-05 20:53:12 +0200
505 @@ -120,7 +120,8 @@ kernel_thread(int (*fn)(void *), void *
506 regs.ccs = 1 << (I_CCS_BITNR + CCS_SHIFT);
508 /* Create the new process. */
509 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
510 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
511 + 0, ®s, 0, NULL, NULL);
515 diff -NurpP --minimal linux-2.6.22.10/arch/frv/kernel/kernel_thread.S linux-2.6.22.10-vs2.3.0.29/arch/frv/kernel/kernel_thread.S
516 --- linux-2.6.22.10/arch/frv/kernel/kernel_thread.S 2005-03-02 12:38:20 +0100
517 +++ linux-2.6.22.10-vs2.3.0.29/arch/frv/kernel/kernel_thread.S 2007-08-05 20:53:12 +0200
519 #include <asm/unistd.h>
521 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
522 +#define CLONE_KTHREAD 0x10000000 /* kernel thread */
523 +#define CLONE_KT (CLONE_VM | CLONE_KTHREAD) /* kernel thread flags */
524 #define KERN_ERR "<3>"
527 @@ -37,7 +39,7 @@ kernel_thread:
529 # start by forking the current process, but with shared VM
530 setlos.p #__NR_clone,gr7 ; syscall number
531 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
532 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
533 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
535 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
536 diff -NurpP --minimal linux-2.6.22.10/arch/h8300/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/h8300/Kconfig
537 --- linux-2.6.22.10/arch/h8300/Kconfig 2007-07-09 13:17:41 +0200
538 +++ linux-2.6.22.10-vs2.3.0.29/arch/h8300/Kconfig 2007-08-05 20:53:12 +0200
539 @@ -222,6 +222,8 @@ source "fs/Kconfig"
541 source "arch/h8300/Kconfig.debug"
543 +source "kernel/vserver/Kconfig"
545 source "security/Kconfig"
547 source "crypto/Kconfig"
548 diff -NurpP --minimal linux-2.6.22.10/arch/h8300/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/h8300/kernel/process.c
549 --- linux-2.6.22.10/arch/h8300/kernel/process.c 2006-09-20 16:57:58 +0200
550 +++ linux-2.6.22.10-vs2.3.0.29/arch/h8300/kernel/process.c 2007-08-05 20:53:12 +0200
551 @@ -134,7 +134,7 @@ int kernel_thread(int (*fn)(void *), voi
555 - clone_arg = flags | CLONE_VM;
556 + clone_arg = flags | CLONE_VM | CLONE_KTHREAD;
557 __asm__("mov.l sp,er3\n\t"
560 diff -NurpP --minimal linux-2.6.22.10/arch/i386/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/i386/Kconfig
561 --- linux-2.6.22.10/arch/i386/Kconfig 2007-07-09 13:17:41 +0200
562 +++ linux-2.6.22.10-vs2.3.0.29/arch/i386/Kconfig 2007-08-05 20:53:12 +0200
563 @@ -1230,6 +1230,8 @@ endmenu
565 source "arch/i386/Kconfig.debug"
567 +source "kernel/vserver/Kconfig"
569 source "security/Kconfig"
571 source "crypto/Kconfig"
572 diff -NurpP --minimal linux-2.6.22.10/arch/i386/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/i386/kernel/process.c
573 --- linux-2.6.22.10/arch/i386/kernel/process.c 2007-07-09 13:17:42 +0200
574 +++ linux-2.6.22.10-vs2.3.0.29/arch/i386/kernel/process.c 2007-08-05 20:53:12 +0200
575 @@ -302,8 +302,10 @@ void show_regs(struct pt_regs * regs)
576 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
579 - printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
580 - printk("EIP: %04x:[<%08lx>] CPU: %d\n",0xffff & regs->xcs,regs->eip, smp_processor_id());
581 + printk("Pid: %d[#%u], comm: %20s\n",
582 + current->pid, current->xid, current->comm);
583 + printk("EIP: %04x:[<%08lx>] CPU: %d\n",
584 + 0xffff & regs->xcs,regs->eip, smp_processor_id());
585 print_symbol("EIP is at %s\n", regs->eip);
587 if (user_mode_vm(regs))
588 @@ -355,7 +357,8 @@ int kernel_thread(int (*fn)(void *), voi
589 regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2;
591 /* Ok, create the new process.. */
592 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
593 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
594 + 0, ®s, 0, NULL, NULL);
596 EXPORT_SYMBOL(kernel_thread);
598 diff -NurpP --minimal linux-2.6.22.10/arch/i386/kernel/syscall_table.S linux-2.6.22.10-vs2.3.0.29/arch/i386/kernel/syscall_table.S
599 --- linux-2.6.22.10/arch/i386/kernel/syscall_table.S 2007-07-09 13:17:42 +0200
600 +++ linux-2.6.22.10-vs2.3.0.29/arch/i386/kernel/syscall_table.S 2007-08-05 20:53:12 +0200
601 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
602 .long sys_tgkill /* 270 */
604 .long sys_fadvise64_64
605 - .long sys_ni_syscall /* sys_vserver */
608 .long sys_get_mempolicy
609 .long sys_set_mempolicy
610 diff -NurpP --minimal linux-2.6.22.10/arch/i386/kernel/sysenter.c linux-2.6.22.10-vs2.3.0.29/arch/i386/kernel/sysenter.c
611 --- linux-2.6.22.10/arch/i386/kernel/sysenter.c 2007-10-30 01:57:12 +0100
612 +++ linux-2.6.22.10-vs2.3.0.29/arch/i386/kernel/sysenter.c 2007-09-05 03:06:10 +0200
614 #include <linux/elf.h>
615 #include <linux/mm.h>
616 #include <linux/module.h>
617 +#include <linux/vs_memory.h>
619 #include <asm/cpufeature.h>
621 diff -NurpP --minimal linux-2.6.22.10/arch/i386/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/i386/kernel/traps.c
622 --- linux-2.6.22.10/arch/i386/kernel/traps.c 2007-07-09 13:17:42 +0200
623 +++ linux-2.6.22.10-vs2.3.0.29/arch/i386/kernel/traps.c 2007-08-05 20:53:12 +0200
625 #include <asm/stacktrace.h>
627 #include <linux/module.h>
628 +#include <linux/vs_context.h>
629 +#include <linux/vserver/history.h>
631 #include "mach_traps.h"
633 @@ -303,8 +305,8 @@ void show_registers(struct pt_regs *regs
634 regs->esi, regs->edi, regs->ebp, esp);
635 printk(KERN_EMERG "ds: %04x es: %04x fs: %04x gs: %04x ss: %04x\n",
636 regs->xds & 0xffff, regs->xes & 0xffff, regs->xfs & 0xffff, gs, ss);
637 - printk(KERN_EMERG "Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)",
638 - TASK_COMM_LEN, current->comm, current->pid,
639 + printk(KERN_EMERG "Process %.*s (pid: %d[#%u], ti=%p task=%p task.ti=%p)",
640 + TASK_COMM_LEN, current->comm, current->pid, current->xid,
641 current_thread_info(), current, task_thread_info(current));
643 * When in-kernel, we also print out the stack and code at the
644 @@ -375,6 +377,8 @@ void die(const char * str, struct pt_reg
650 if (die.lock_owner != raw_smp_processor_id()) {
652 spin_lock_irqsave(&die.lock, flags);
653 @@ -412,9 +416,9 @@ void die(const char * str, struct pt_reg
656 if (notify_die(DIE_OOPS, str, regs, err,
657 - current->thread.trap_no, SIGSEGV) !=
659 + current->thread.trap_no, SIGSEGV) != NOTIFY_STOP) {
660 show_registers(regs);
661 + vxh_dump_history();
662 /* Executive summary in case the oops scrolled away */
663 esp = (unsigned long) (®s->esp);
665 diff -NurpP --minimal linux-2.6.22.10/arch/i386/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/i386/mm/fault.c
666 --- linux-2.6.22.10/arch/i386/mm/fault.c 2007-10-30 01:57:12 +0100
667 +++ linux-2.6.22.10-vs2.3.0.29/arch/i386/mm/fault.c 2007-09-05 03:06:10 +0200
668 @@ -587,7 +587,8 @@ out_of_memory:
669 down_read(&mm->mmap_sem);
672 - printk("VM: killing process %s\n", tsk->comm);
673 + printk("VM: killing process %s(%d:#%u)\n",
674 + tsk->comm, tsk->pid, tsk->xid);
678 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/ia64/Kconfig
679 --- linux-2.6.22.10/arch/ia64/Kconfig 2007-07-09 13:17:43 +0200
680 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/Kconfig 2007-08-05 20:53:12 +0200
681 @@ -592,6 +592,8 @@ endmenu
683 source "arch/ia64/Kconfig.debug"
685 +source "kernel/vserver/Kconfig"
687 source "security/Kconfig"
689 source "crypto/Kconfig"
690 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/ia32/binfmt_elf32.c linux-2.6.22.10-vs2.3.0.29/arch/ia64/ia32/binfmt_elf32.c
691 --- linux-2.6.22.10/arch/ia64/ia32/binfmt_elf32.c 2007-05-02 19:24:20 +0200
692 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/ia32/binfmt_elf32.c 2007-08-05 20:53:12 +0200
693 @@ -233,7 +233,8 @@ ia32_setup_arg_pages (struct linux_binpr
694 kmem_cache_free(vm_area_cachep, mpnt);
697 - current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt);
698 + vx_vmpages_sub(current->mm, current->mm->total_vm - vma_pages(mpnt));
699 + current->mm->stack_vm = current->mm->total_vm;
702 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
703 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/ia32/ia32_entry.S linux-2.6.22.10-vs2.3.0.29/arch/ia64/ia32/ia32_entry.S
704 --- linux-2.6.22.10/arch/ia64/ia32/ia32_entry.S 2007-07-09 13:17:43 +0200
705 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/ia32/ia32_entry.S 2007-08-05 20:53:12 +0200
706 @@ -446,7 +446,7 @@ ia32_syscall_table:
707 data8 sys_tgkill /* 270 */
708 data8 compat_sys_utimes
709 data8 sys32_fadvise64_64
710 - data8 sys_ni_syscall
711 + data8 sys32_vserver
713 data8 sys_ni_syscall /* 275 */
715 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/ia32/sys_ia32.c linux-2.6.22.10-vs2.3.0.29/arch/ia64/ia32/sys_ia32.c
716 --- linux-2.6.22.10/arch/ia64/ia32/sys_ia32.c 2007-05-02 19:24:20 +0200
717 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/ia32/sys_ia32.c 2007-08-05 20:53:12 +0200
718 @@ -1182,7 +1182,7 @@ sys32_gettimeofday (struct compat_timeva
722 - do_gettimeofday(&ktv);
723 + vx_gettimeofday(&ktv);
724 if (put_tv32(tv, &ktv))
727 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/asm-offsets.c linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/asm-offsets.c
728 --- linux-2.6.22.10/arch/ia64/kernel/asm-offsets.c 2007-05-02 19:24:20 +0200
729 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/asm-offsets.c 2007-08-05 20:53:12 +0200
730 @@ -192,6 +192,7 @@ void foo(void)
731 /* for assembly files which can't include sched.h: */
732 DEFINE(IA64_CLONE_VFORK, CLONE_VFORK);
733 DEFINE(IA64_CLONE_VM, CLONE_VM);
734 + DEFINE(IA64_CLONE_KTHREAD, CLONE_KTHREAD);
737 DEFINE(IA64_CPUINFO_NSEC_PER_CYC_OFFSET,
738 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/entry.S linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/entry.S
739 --- linux-2.6.22.10/arch/ia64/kernel/entry.S 2007-07-09 13:17:43 +0200
740 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/entry.S 2007-08-05 20:53:12 +0200
741 @@ -1547,7 +1547,7 @@ sys_call_table:
743 data8 sys_mq_getsetattr
745 - data8 sys_ni_syscall // reserved for vserver
747 data8 sys_waitid // 1270
749 data8 sys_request_key
750 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/perfmon.c linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/perfmon.c
751 --- linux-2.6.22.10/arch/ia64/kernel/perfmon.c 2007-07-09 13:17:43 +0200
752 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/perfmon.c 2007-08-05 20:53:12 +0200
754 #include <linux/capability.h>
755 #include <linux/rcupdate.h>
756 #include <linux/completion.h>
757 +#include <linux/vs_memory.h>
759 #include <asm/errno.h>
760 #include <asm/intrinsics.h>
761 @@ -2395,7 +2396,7 @@ pfm_smpl_buffer_alloc(struct task_struct
763 insert_vm_struct(mm, vma);
765 - mm->total_vm += size >> PAGE_SHIFT;
766 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
767 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
769 up_write(&task->mm->mmap_sem);
770 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/process.c
771 --- linux-2.6.22.10/arch/ia64/kernel/process.c 2007-07-09 13:17:43 +0200
772 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/process.c 2007-08-05 20:53:12 +0200
773 @@ -105,7 +105,8 @@ show_regs (struct pt_regs *regs)
774 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
777 - printk("\nPid: %d, CPU %d, comm: %20s\n", current->pid, smp_processor_id(), current->comm);
778 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n",
779 + current->pid, current->xid, smp_processor_id(), current->comm);
780 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s\n",
781 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted());
782 print_symbol("ip is at %s\n", ip);
783 @@ -696,7 +697,8 @@ kernel_thread (int (*fn)(void *), void *
784 regs.sw.ar_fpsr = regs.pt.ar_fpsr = ia64_getreg(_IA64_REG_AR_FPSR);
785 regs.sw.ar_bspstore = (unsigned long) current + IA64_RBS_OFFSET;
786 regs.sw.pr = (1 << PRED_KERNEL_STACK);
787 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s.pt, 0, NULL, NULL);
788 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
789 + 0, ®s.pt, 0, NULL, NULL);
791 EXPORT_SYMBOL(kernel_thread);
793 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/ptrace.c
794 --- linux-2.6.22.10/arch/ia64/kernel/ptrace.c 2007-05-02 19:24:20 +0200
795 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/ptrace.c 2007-08-05 20:53:12 +0200
797 #include <linux/security.h>
798 #include <linux/audit.h>
799 #include <linux/signal.h>
800 +#include <linux/vs_base.h>
802 #include <asm/pgtable.h>
803 #include <asm/processor.h>
804 @@ -1443,6 +1444,9 @@ sys_ptrace (long request, pid_t pid, uns
805 read_unlock(&tasklist_lock);
808 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
812 if (pid == 1) /* no messing around with init! */
814 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/traps.c
815 --- linux-2.6.22.10/arch/ia64/kernel/traps.c 2007-07-09 13:17:43 +0200
816 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/kernel/traps.c 2007-08-05 20:53:12 +0200
817 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
820 if (++die.lock_owner_depth < 3) {
821 - printk("%s[%d]: %s %ld [%d]\n",
822 - current->comm, current->pid, str, err, ++die_counter);
823 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
824 + current->comm, current->pid, current->xid,
825 + str, err, ++die_counter);
826 (void) notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV);
829 @@ -313,8 +314,9 @@ handle_fpu_swa (int fp_fault, struct pt_
830 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
831 last.time = current_jiffies + 5 * HZ;
833 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
834 - current->comm, current->pid, regs->cr_iip + ia64_psr(regs)->ri, isr);
835 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
836 + current->comm, current->pid, current->xid,
837 + regs->cr_iip + ia64_psr(regs)->ri, isr);
841 diff -NurpP --minimal linux-2.6.22.10/arch/ia64/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/ia64/mm/fault.c
842 --- linux-2.6.22.10/arch/ia64/mm/fault.c 2007-07-09 13:17:43 +0200
843 +++ linux-2.6.22.10-vs2.3.0.29/arch/ia64/mm/fault.c 2007-08-05 20:53:12 +0200
845 #include <linux/interrupt.h>
846 #include <linux/kprobes.h>
847 #include <linux/kdebug.h>
848 +#include <linux/vs_memory.h>
850 #include <asm/pgtable.h>
851 #include <asm/processor.h>
852 diff -NurpP --minimal linux-2.6.22.10/arch/m32r/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/m32r/kernel/process.c
853 --- linux-2.6.22.10/arch/m32r/kernel/process.c 2007-05-02 19:24:21 +0200
854 +++ linux-2.6.22.10-vs2.3.0.29/arch/m32r/kernel/process.c 2007-08-05 20:53:12 +0200
855 @@ -211,8 +211,8 @@ int kernel_thread(int (*fn)(void *), voi
856 regs.psw = M32R_PSW_BIE;
858 /* Ok, create the new process. */
859 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL,
861 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
862 + 0, ®s, 0, NULL, NULL);
866 diff -NurpP --minimal linux-2.6.22.10/arch/m32r/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/m32r/kernel/traps.c
867 --- linux-2.6.22.10/arch/m32r/kernel/traps.c 2006-11-30 21:18:28 +0100
868 +++ linux-2.6.22.10-vs2.3.0.29/arch/m32r/kernel/traps.c 2007-08-05 20:53:12 +0200
869 @@ -195,8 +195,9 @@ static void show_registers(struct pt_reg
871 printk("SPI: %08lx\n", sp);
873 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
874 - current->comm, current->pid, 0xffff & i, 4096+(unsigned long)current);
875 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
876 + current->comm, current->pid, current->xid,
877 + 0xffff & i, 4096+(unsigned long)current);
880 * When in-kernel, we also print out the stack and code at the
881 diff -NurpP --minimal linux-2.6.22.10/arch/m68k/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/m68k/Kconfig
882 --- linux-2.6.22.10/arch/m68k/Kconfig 2007-07-09 13:17:47 +0200
883 +++ linux-2.6.22.10-vs2.3.0.29/arch/m68k/Kconfig 2007-08-05 20:53:12 +0200
884 @@ -678,6 +678,8 @@ source "fs/Kconfig"
886 source "arch/m68k/Kconfig.debug"
888 +source "kernel/vserver/Kconfig"
890 source "security/Kconfig"
892 source "crypto/Kconfig"
893 diff -NurpP --minimal linux-2.6.22.10/arch/m68k/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/m68k/kernel/process.c
894 --- linux-2.6.22.10/arch/m68k/kernel/process.c 2006-11-30 21:18:28 +0100
895 +++ linux-2.6.22.10-vs2.3.0.29/arch/m68k/kernel/process.c 2007-08-05 20:53:12 +0200
896 @@ -159,7 +159,8 @@ int kernel_thread(int (*fn)(void *), voi
899 register long retval __asm__ ("d0");
900 - register long clone_arg __asm__ ("d1") = flags | CLONE_VM | CLONE_UNTRACED;
901 + register long clone_arg __asm__ ("d1") =
902 + flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
906 diff -NurpP --minimal linux-2.6.22.10/arch/m68k/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/arch/m68k/kernel/ptrace.c
907 --- linux-2.6.22.10/arch/m68k/kernel/ptrace.c 2007-07-09 13:17:47 +0200
908 +++ linux-2.6.22.10-vs2.3.0.29/arch/m68k/kernel/ptrace.c 2007-08-05 20:53:12 +0200
910 #include <linux/ptrace.h>
911 #include <linux/user.h>
912 #include <linux/signal.h>
913 +#include <linux/vs_base.h>
915 #include <asm/uaccess.h>
916 #include <asm/page.h>
917 @@ -278,6 +279,8 @@ long arch_ptrace(struct task_struct *chi
918 ret = ptrace_request(child, request, addr, data);
921 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
926 diff -NurpP --minimal linux-2.6.22.10/arch/m68k/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/m68k/kernel/traps.c
927 --- linux-2.6.22.10/arch/m68k/kernel/traps.c 2007-05-02 19:24:21 +0200
928 +++ linux-2.6.22.10-vs2.3.0.29/arch/m68k/kernel/traps.c 2007-08-05 20:53:12 +0200
929 @@ -899,8 +899,8 @@ void show_registers(struct pt_regs *regs
930 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
931 regs->d4, regs->d5, regs->a0, regs->a1);
933 - printk("Process %s (pid: %d, task=%p)\n",
934 - current->comm, current->pid, current);
935 + printk("Process %s (pid: %d[#%u], task=%p)\n",
936 + current->comm, current->pid, current->xid, current);
937 addr = (unsigned long)&fp->un;
938 printk("Frame format=%X ", regs->format);
939 switch (regs->format) {
940 diff -NurpP --minimal linux-2.6.22.10/arch/m68knommu/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/m68knommu/Kconfig
941 --- linux-2.6.22.10/arch/m68knommu/Kconfig 2007-07-09 13:17:47 +0200
942 +++ linux-2.6.22.10-vs2.3.0.29/arch/m68knommu/Kconfig 2007-08-05 20:53:12 +0200
943 @@ -670,6 +670,8 @@ source "fs/Kconfig"
945 source "arch/m68knommu/Kconfig.debug"
947 +source "kernel/vserver/Kconfig"
949 source "security/Kconfig"
951 source "crypto/Kconfig"
952 diff -NurpP --minimal linux-2.6.22.10/arch/m68knommu/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/m68knommu/kernel/process.c
953 --- linux-2.6.22.10/arch/m68knommu/kernel/process.c 2007-02-06 03:00:08 +0100
954 +++ linux-2.6.22.10-vs2.3.0.29/arch/m68knommu/kernel/process.c 2007-08-05 20:53:12 +0200
955 @@ -122,7 +122,7 @@ void show_regs(struct pt_regs * regs)
956 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
959 - long clone_arg = flags | CLONE_VM;
960 + long clone_arg = flags | CLONE_VM | CLONE_KTHREAD;
964 diff -NurpP --minimal linux-2.6.22.10/arch/m68knommu/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/m68knommu/kernel/traps.c
965 --- linux-2.6.22.10/arch/m68knommu/kernel/traps.c 2007-05-02 19:24:21 +0200
966 +++ linux-2.6.22.10-vs2.3.0.29/arch/m68knommu/kernel/traps.c 2007-08-05 20:53:12 +0200
967 @@ -80,8 +80,9 @@ void die_if_kernel(char *str, struct pt_
968 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
969 fp->d4, fp->d5, fp->a0, fp->a1);
971 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
972 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
973 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
974 + current->comm, current->pid, current->xid,
975 + PAGE_SIZE+(unsigned long)current);
976 show_stack(NULL, (unsigned long *)fp);
979 diff -NurpP --minimal linux-2.6.22.10/arch/mips/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/mips/Kconfig
980 --- linux-2.6.22.10/arch/mips/Kconfig 2007-07-09 13:17:47 +0200
981 +++ linux-2.6.22.10-vs2.3.0.29/arch/mips/Kconfig 2007-08-05 20:53:12 +0200
982 @@ -1959,6 +1959,8 @@ source "arch/mips/oprofile/Kconfig"
984 source "arch/mips/Kconfig.debug"
986 +source "kernel/vserver/Kconfig"
988 source "security/Kconfig"
990 source "crypto/Kconfig"
991 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/linux32.c linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/linux32.c
992 --- linux-2.6.22.10/arch/mips/kernel/linux32.c 2007-07-09 13:17:48 +0200
993 +++ linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/linux32.c 2007-08-05 20:53:12 +0200
994 @@ -229,7 +229,7 @@ sys32_gettimeofday(struct compat_timeval
998 - do_gettimeofday(&ktv);
999 + vx_gettimeofday(&ktv);
1000 if (put_tv32(tv, &ktv))
1003 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/process.c
1004 --- linux-2.6.22.10/arch/mips/kernel/process.c 2007-05-02 19:24:23 +0200
1005 +++ linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/process.c 2007-08-05 20:53:12 +0200
1006 @@ -236,7 +236,8 @@ long kernel_thread(int (*fn)(void *), vo
1009 /* Ok, create the new process.. */
1010 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
1011 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
1012 + 0, ®s, 0, NULL, NULL);
1016 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/ptrace.c
1017 --- linux-2.6.22.10/arch/mips/kernel/ptrace.c 2007-07-09 13:17:48 +0200
1018 +++ linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/ptrace.c 2007-08-05 20:53:12 +0200
1020 #include <linux/user.h>
1021 #include <linux/security.h>
1022 #include <linux/signal.h>
1023 +#include <linux/vs_base.h>
1025 #include <asm/byteorder.h>
1026 #include <asm/cpu.h>
1027 @@ -171,6 +172,9 @@ long arch_ptrace(struct task_struct *chi
1031 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
1035 /* when I and D space are separate, these will need to be fixed. */
1036 case PTRACE_PEEKTEXT: /* read word at location addr. */
1037 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/scall32-o32.S linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/scall32-o32.S
1038 --- linux-2.6.22.10/arch/mips/kernel/scall32-o32.S 2007-07-09 13:17:48 +0200
1039 +++ linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/scall32-o32.S 2007-08-05 20:53:12 +0200
1040 @@ -619,7 +619,7 @@ einval: li v0, -EINVAL
1041 sys sys_mq_timedreceive 5
1042 sys sys_mq_notify 2 /* 4275 */
1043 sys sys_mq_getsetattr 3
1044 - sys sys_ni_syscall 0 /* sys_vserver */
1047 sys sys_ni_syscall 0 /* available, was setaltroot */
1048 sys sys_add_key 5 /* 4280 */
1049 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/scall64-64.S linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/scall64-64.S
1050 --- linux-2.6.22.10/arch/mips/kernel/scall64-64.S 2007-07-09 13:17:48 +0200
1051 +++ linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/scall64-64.S 2007-08-05 20:53:12 +0200
1052 @@ -434,7 +434,7 @@ sys_call_table:
1053 PTR sys_mq_timedreceive
1055 PTR sys_mq_getsetattr /* 5235 */
1056 - PTR sys_ni_syscall /* sys_vserver */
1059 PTR sys_ni_syscall /* available, was setaltroot */
1061 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/scall64-n32.S linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/scall64-n32.S
1062 --- linux-2.6.22.10/arch/mips/kernel/scall64-n32.S 2007-07-09 13:17:48 +0200
1063 +++ linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/scall64-n32.S 2007-08-05 20:53:12 +0200
1064 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
1065 PTR compat_sys_mq_timedreceive
1066 PTR compat_sys_mq_notify
1067 PTR compat_sys_mq_getsetattr
1068 - PTR sys_ni_syscall /* 6240, sys_vserver */
1069 + PTR sys32_vserver /* 6240 */
1070 PTR compat_sys_waitid
1071 PTR sys_ni_syscall /* available, was setaltroot */
1073 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/scall64-o32.S linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/scall64-o32.S
1074 --- linux-2.6.22.10/arch/mips/kernel/scall64-o32.S 2007-07-09 13:17:48 +0200
1075 +++ linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/scall64-o32.S 2007-08-05 20:53:12 +0200
1076 @@ -482,7 +482,7 @@ sys_call_table:
1077 PTR compat_sys_mq_timedreceive
1078 PTR compat_sys_mq_notify /* 4275 */
1079 PTR compat_sys_mq_getsetattr
1080 - PTR sys_ni_syscall /* sys_vserver */
1083 PTR sys_ni_syscall /* available, was setaltroot */
1084 PTR sys_add_key /* 4280 */
1085 diff -NurpP --minimal linux-2.6.22.10/arch/mips/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/traps.c
1086 --- linux-2.6.22.10/arch/mips/kernel/traps.c 2007-07-09 13:17:48 +0200
1087 +++ linux-2.6.22.10-vs2.3.0.29/arch/mips/kernel/traps.c 2007-08-05 20:53:12 +0200
1088 @@ -302,8 +302,9 @@ void show_registers(struct pt_regs *regs
1092 - printk("Process %s (pid: %d, threadinfo=%p, task=%p)\n",
1093 - current->comm, current->pid, current_thread_info(), current);
1094 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p)\n",
1095 + current->comm, current->pid, current->xid,
1096 + current_thread_info(), current);
1097 show_stacktrace(current, regs);
1098 show_code((unsigned int *) regs->cp0_epc);
1100 diff -NurpP --minimal linux-2.6.22.10/arch/mips/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/mips/mm/fault.c
1101 --- linux-2.6.22.10/arch/mips/mm/fault.c 2007-07-09 13:17:48 +0200
1102 +++ linux-2.6.22.10-vs2.3.0.29/arch/mips/mm/fault.c 2007-08-05 20:53:12 +0200
1103 @@ -179,7 +179,8 @@ out_of_memory:
1104 down_read(&mm->mmap_sem);
1107 - printk("VM: killing process %s\n", tsk->comm);
1108 + printk("VM: killing process %s(%d:#%u)\n",
1109 + tsk->comm, tsk->pid, tsk->xid);
1110 if (user_mode(regs))
1113 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/parisc/Kconfig
1114 --- linux-2.6.22.10/arch/parisc/Kconfig 2007-05-02 19:24:26 +0200
1115 +++ linux-2.6.22.10-vs2.3.0.29/arch/parisc/Kconfig 2007-08-05 20:53:12 +0200
1116 @@ -271,6 +271,8 @@ source "arch/parisc/oprofile/Kconfig"
1118 source "arch/parisc/Kconfig.debug"
1120 +source "kernel/vserver/Kconfig"
1122 source "security/Kconfig"
1124 source "crypto/Kconfig"
1125 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/kernel/entry.S linux-2.6.22.10-vs2.3.0.29/arch/parisc/kernel/entry.S
1126 --- linux-2.6.22.10/arch/parisc/kernel/entry.S 2007-07-09 13:17:50 +0200
1127 +++ linux-2.6.22.10-vs2.3.0.29/arch/parisc/kernel/entry.S 2007-08-05 20:53:12 +0200
1128 @@ -761,6 +761,7 @@ END(fault_vector_11)
1130 #define CLONE_VM 0x100 /* Must agree with <linux/sched.h> */
1131 #define CLONE_UNTRACED 0x00800000
1132 +#define CLONE_KTHREAD 0x10000000
1135 ENTRY(__kernel_thread)
1136 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/parisc/kernel/process.c
1137 --- linux-2.6.22.10/arch/parisc/kernel/process.c 2007-07-09 13:17:50 +0200
1138 +++ linux-2.6.22.10-vs2.3.0.29/arch/parisc/kernel/process.c 2007-08-05 20:53:12 +0200
1139 @@ -173,7 +173,7 @@ pid_t kernel_thread(int (*fn)(void *), v
1140 * kernel_thread can become a #define.
1143 - return __kernel_thread(fn, arg, flags);
1144 + return __kernel_thread(fn, arg, flags | CLONE_KTHREAD);
1146 EXPORT_SYMBOL(kernel_thread);
1148 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/kernel/sys_parisc32.c linux-2.6.22.10-vs2.3.0.29/arch/parisc/kernel/sys_parisc32.c
1149 --- linux-2.6.22.10/arch/parisc/kernel/sys_parisc32.c 2007-07-09 13:17:50 +0200
1150 +++ linux-2.6.22.10-vs2.3.0.29/arch/parisc/kernel/sys_parisc32.c 2007-08-05 20:53:12 +0200
1151 @@ -204,11 +204,11 @@ static inline long get_ts32(struct times
1153 sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
1155 - extern void do_gettimeofday(struct timeval *tv);
1156 + extern void vx_gettimeofday(struct timeval *tv);
1160 - do_gettimeofday(&ktv);
1161 + vx_gettimeofday(&ktv);
1162 if (put_compat_timeval(tv, &ktv))
1165 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/kernel/syscall_table.S linux-2.6.22.10-vs2.3.0.29/arch/parisc/kernel/syscall_table.S
1166 --- linux-2.6.22.10/arch/parisc/kernel/syscall_table.S 2007-07-09 13:17:50 +0200
1167 +++ linux-2.6.22.10-vs2.3.0.29/arch/parisc/kernel/syscall_table.S 2007-08-05 20:53:12 +0200
1169 ENTRY_COMP(mbind) /* 260 */
1170 ENTRY_COMP(get_mempolicy)
1171 ENTRY_COMP(set_mempolicy)
1172 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
1173 + ENTRY_DIFF(vserver)
1175 ENTRY_SAME(request_key) /* 265 */
1177 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/parisc/kernel/traps.c
1178 --- linux-2.6.22.10/arch/parisc/kernel/traps.c 2007-07-09 13:17:50 +0200
1179 +++ linux-2.6.22.10-vs2.3.0.29/arch/parisc/kernel/traps.c 2007-08-05 20:53:12 +0200
1180 @@ -218,8 +218,9 @@ void die_if_kernel(char *str, struct pt_
1184 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
1185 - current->comm, current->pid, str, err, regs->iaoq[0]);
1186 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
1187 + current->comm, current->pid, current->xid,
1188 + str, err, regs->iaoq[0]);
1189 #ifdef PRINT_USER_FAULTS
1190 /* XXX for debugging only */
1192 @@ -251,8 +252,8 @@ KERN_CRIT " || |
1193 pdc_console_restart();
1196 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
1197 - current->comm, current->pid, str, err);
1198 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
1199 + current->comm, current->pid, current->xid, str, err);
1201 /* Wot's wrong wif bein' racy? */
1202 if (current->thread.flags & PARISC_KERNEL_DEATH) {
1203 diff -NurpP --minimal linux-2.6.22.10/arch/parisc/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/parisc/mm/fault.c
1204 --- linux-2.6.22.10/arch/parisc/mm/fault.c 2007-05-02 19:24:26 +0200
1205 +++ linux-2.6.22.10-vs2.3.0.29/arch/parisc/mm/fault.c 2007-08-05 20:53:12 +0200
1206 @@ -209,8 +209,9 @@ bad_area:
1208 #ifdef PRINT_USER_FAULTS
1209 printk(KERN_DEBUG "\n");
1210 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
1211 - tsk->pid, tsk->comm, code, address);
1212 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
1213 + "command='%s' type=%lu address=0x%08lx\n",
1214 + tsk->pid, tsk->xid, tsk->comm, code, address);
1216 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
1217 vma->vm_start, vma->vm_end);
1218 @@ -260,7 +261,8 @@ no_context:
1221 up_read(&mm->mmap_sem);
1222 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
1223 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
1224 + current->comm, current->pid, current->xid);
1225 if (user_mode(regs))
1228 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/powerpc/Kconfig
1229 --- linux-2.6.22.10/arch/powerpc/Kconfig 2007-07-09 13:17:50 +0200
1230 +++ linux-2.6.22.10-vs2.3.0.29/arch/powerpc/Kconfig 2007-08-05 20:53:12 +0200
1231 @@ -906,6 +906,8 @@ endmenu
1233 source "arch/powerpc/Kconfig.debug"
1235 +source "kernel/vserver/Kconfig"
1237 source "security/Kconfig"
1240 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/asm-offsets.c linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/asm-offsets.c
1241 --- linux-2.6.22.10/arch/powerpc/kernel/asm-offsets.c 2007-07-09 13:17:51 +0200
1242 +++ linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/asm-offsets.c 2007-08-05 20:53:12 +0200
1243 @@ -250,6 +250,7 @@ int main(void)
1245 DEFINE(CLONE_VM, CLONE_VM);
1246 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
1247 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
1249 #ifndef CONFIG_PPC64
1250 DEFINE(MM_PGD, offsetof(struct mm_struct, pgd));
1251 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/irq.c linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/irq.c
1252 --- linux-2.6.22.10/arch/powerpc/kernel/irq.c 2007-07-09 13:17:51 +0200
1253 +++ linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/irq.c 2007-08-05 20:53:12 +0200
1255 #include <linux/mutex.h>
1256 #include <linux/bootmem.h>
1257 #include <linux/pci.h>
1258 +#include <linux/vs_context.h>
1260 #include <asm/uaccess.h>
1261 #include <asm/system.h>
1262 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/misc_32.S linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/misc_32.S
1263 --- linux-2.6.22.10/arch/powerpc/kernel/misc_32.S 2007-07-09 13:17:51 +0200
1264 +++ linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/misc_32.S 2007-08-05 20:53:12 +0200
1265 @@ -745,7 +745,7 @@ _GLOBAL(kernel_thread)
1266 mr r30,r3 /* function */
1267 mr r31,r4 /* argument */
1268 ori r3,r5,CLONE_VM /* flags */
1269 - oris r3,r3,CLONE_UNTRACED>>16
1270 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1271 li r4,0 /* new sp (unused) */
1274 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/misc_64.S linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/misc_64.S
1275 --- linux-2.6.22.10/arch/powerpc/kernel/misc_64.S 2007-05-02 19:24:27 +0200
1276 +++ linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/misc_64.S 2007-08-05 20:53:12 +0200
1277 @@ -434,7 +434,7 @@ _GLOBAL(kernel_thread)
1280 ori r3,r5,CLONE_VM /* flags */
1281 - oris r3,r3,(CLONE_UNTRACED>>16)
1282 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1283 li r4,0 /* new sp (unused) */
1286 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/process.c
1287 --- linux-2.6.22.10/arch/powerpc/kernel/process.c 2007-10-30 01:57:12 +0100
1288 +++ linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/process.c 2007-09-30 14:57:55 +0200
1289 @@ -422,8 +422,9 @@ void show_regs(struct pt_regs * regs)
1291 if (trap == 0x300 || trap == 0x600)
1292 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
1293 - printk("TASK = %p[%d] '%s' THREAD: %p",
1294 - current, current->pid, current->comm, task_thread_info(current));
1295 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
1296 + current, current->pid, current->xid,
1297 + current->comm, task_thread_info(current));
1300 printk(" CPU: %d", smp_processor_id());
1301 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/sys_ppc32.c linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/sys_ppc32.c
1302 --- linux-2.6.22.10/arch/powerpc/kernel/sys_ppc32.c 2007-07-09 13:17:51 +0200
1303 +++ linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/sys_ppc32.c 2007-08-05 20:53:12 +0200
1304 @@ -205,7 +205,7 @@ asmlinkage long compat_sys_gettimeofday(
1308 - do_gettimeofday(&ktv);
1309 + vx_gettimeofday(&ktv);
1310 if (put_tv32(tv, &ktv))
1313 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/traps.c
1314 --- linux-2.6.22.10/arch/powerpc/kernel/traps.c 2007-07-09 13:17:51 +0200
1315 +++ linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/traps.c 2007-08-05 20:53:12 +0200
1316 @@ -878,8 +878,9 @@ void nonrecoverable_exception(struct pt_
1318 void trace_syscall(struct pt_regs *regs)
1320 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1321 - current, current->pid, regs->nip, regs->link, regs->gpr[0],
1322 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1323 + current, current->pid, current->xid,
1324 + regs->nip, regs->link, regs->gpr[0],
1325 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
1328 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/kernel/vdso.c linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/vdso.c
1329 --- linux-2.6.22.10/arch/powerpc/kernel/vdso.c 2007-07-09 13:17:51 +0200
1330 +++ linux-2.6.22.10-vs2.3.0.29/arch/powerpc/kernel/vdso.c 2007-08-05 20:53:12 +0200
1332 #include <linux/elf.h>
1333 #include <linux/security.h>
1334 #include <linux/bootmem.h>
1335 +#include <linux/vs_memory.h>
1337 #include <asm/pgtable.h>
1338 #include <asm/system.h>
1339 diff -NurpP --minimal linux-2.6.22.10/arch/powerpc/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/powerpc/mm/fault.c
1340 --- linux-2.6.22.10/arch/powerpc/mm/fault.c 2007-07-09 13:17:51 +0200
1341 +++ linux-2.6.22.10-vs2.3.0.29/arch/powerpc/mm/fault.c 2007-08-05 20:53:12 +0200
1342 @@ -378,7 +378,8 @@ out_of_memory:
1343 down_read(&mm->mmap_sem);
1346 - printk("VM: killing process %s\n", current->comm);
1347 + printk("VM: killing process %s(%d:#%u)\n",
1348 + current->comm, current->pid, current->xid);
1349 if (user_mode(regs))
1352 diff -NurpP --minimal linux-2.6.22.10/arch/ppc/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/ppc/Kconfig
1353 --- linux-2.6.22.10/arch/ppc/Kconfig 2007-05-02 19:24:28 +0200
1354 +++ linux-2.6.22.10-vs2.3.0.29/arch/ppc/Kconfig 2007-08-05 20:53:12 +0200
1355 @@ -1455,6 +1455,8 @@ source "arch/powerpc/oprofile/Kconfig"
1357 source "arch/ppc/Kconfig.debug"
1359 +source "kernel/vserver/Kconfig"
1361 source "security/Kconfig"
1363 source "crypto/Kconfig"
1364 diff -NurpP --minimal linux-2.6.22.10/arch/ppc/kernel/asm-offsets.c linux-2.6.22.10-vs2.3.0.29/arch/ppc/kernel/asm-offsets.c
1365 --- linux-2.6.22.10/arch/ppc/kernel/asm-offsets.c 2007-07-09 13:18:01 +0200
1366 +++ linux-2.6.22.10-vs2.3.0.29/arch/ppc/kernel/asm-offsets.c 2007-08-05 20:53:12 +0200
1367 @@ -120,6 +120,7 @@ main(void)
1368 DEFINE(TRAP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, trap));
1369 DEFINE(CLONE_VM, CLONE_VM);
1370 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
1371 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
1372 DEFINE(MM_PGD, offsetof(struct mm_struct, pgd));
1374 /* About the CPU features table */
1375 diff -NurpP --minimal linux-2.6.22.10/arch/ppc/kernel/misc.S linux-2.6.22.10-vs2.3.0.29/arch/ppc/kernel/misc.S
1376 --- linux-2.6.22.10/arch/ppc/kernel/misc.S 2006-11-30 21:18:32 +0100
1377 +++ linux-2.6.22.10-vs2.3.0.29/arch/ppc/kernel/misc.S 2007-08-05 20:53:12 +0200
1378 @@ -848,7 +848,7 @@ _GLOBAL(kernel_thread)
1379 mr r30,r3 /* function */
1380 mr r31,r4 /* argument */
1381 ori r3,r5,CLONE_VM /* flags */
1382 - oris r3,r3,CLONE_UNTRACED>>16
1383 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1384 li r4,0 /* new sp (unused) */
1387 diff -NurpP --minimal linux-2.6.22.10/arch/ppc/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/ppc/kernel/traps.c
1388 --- linux-2.6.22.10/arch/ppc/kernel/traps.c 2007-07-09 13:18:01 +0200
1389 +++ linux-2.6.22.10-vs2.3.0.29/arch/ppc/kernel/traps.c 2007-08-05 20:53:12 +0200
1390 @@ -696,8 +696,9 @@ void nonrecoverable_exception(struct pt_
1392 void trace_syscall(struct pt_regs *regs)
1394 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1395 - current, current->pid, regs->nip, regs->link, regs->gpr[0],
1396 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1397 + current, current->pid, current->xid,
1398 + regs->nip, regs->link, regs->gpr[0],
1399 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
1402 diff -NurpP --minimal linux-2.6.22.10/arch/ppc/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/ppc/mm/fault.c
1403 --- linux-2.6.22.10/arch/ppc/mm/fault.c 2006-11-30 21:18:32 +0100
1404 +++ linux-2.6.22.10-vs2.3.0.29/arch/ppc/mm/fault.c 2007-08-05 20:53:12 +0200
1405 @@ -296,7 +296,8 @@ out_of_memory:
1406 down_read(&mm->mmap_sem);
1409 - printk("VM: killing process %s\n", current->comm);
1410 + printk("VM: killing process %s(%d:#%u)\n",
1411 + current->comm, current->pid, current->xid);
1412 if (user_mode(regs))
1415 diff -NurpP --minimal linux-2.6.22.10/arch/s390/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/s390/Kconfig
1416 --- linux-2.6.22.10/arch/s390/Kconfig 2007-07-09 13:18:02 +0200
1417 +++ linux-2.6.22.10-vs2.3.0.29/arch/s390/Kconfig 2007-08-05 20:53:12 +0200
1418 @@ -551,6 +551,8 @@ endmenu
1420 source "arch/s390/Kconfig.debug"
1422 +source "kernel/vserver/Kconfig"
1424 source "security/Kconfig"
1426 source "crypto/Kconfig"
1427 diff -NurpP --minimal linux-2.6.22.10/arch/s390/kernel/compat_linux.c linux-2.6.22.10-vs2.3.0.29/arch/s390/kernel/compat_linux.c
1428 --- linux-2.6.22.10/arch/s390/kernel/compat_linux.c 2007-07-09 13:18:02 +0200
1429 +++ linux-2.6.22.10-vs2.3.0.29/arch/s390/kernel/compat_linux.c 2007-08-05 20:53:12 +0200
1430 @@ -567,7 +567,7 @@ asmlinkage long sys32_gettimeofday(struc
1434 - do_gettimeofday(&ktv);
1435 + vx_gettimeofday(&ktv);
1436 if (put_tv32(tv, &ktv))
1439 diff -NurpP --minimal linux-2.6.22.10/arch/s390/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/s390/kernel/process.c
1440 --- linux-2.6.22.10/arch/s390/kernel/process.c 2007-07-09 13:18:02 +0200
1441 +++ linux-2.6.22.10-vs2.3.0.29/arch/s390/kernel/process.c 2007-08-05 20:53:12 +0200
1442 @@ -164,9 +164,9 @@ void show_regs(struct pt_regs *regs)
1443 struct task_struct *tsk = current;
1445 printk("CPU: %d %s\n", task_thread_info(tsk)->cpu, print_tainted());
1446 - printk("Process %s (pid: %d, task: %p, ksp: %p)\n",
1447 - current->comm, current->pid, (void *) tsk,
1448 - (void *) tsk->thread.ksp);
1449 + printk("Process %s (pid: %d[#%u], task: %p, ksp: %p)\n",
1450 + current->comm, current->pid, current->xid,
1451 + (void *) tsk, (void *) tsk->thread.ksp);
1453 show_registers(regs);
1454 /* Show stack backtrace if pt_regs is from kernel mode */
1455 @@ -197,7 +197,7 @@ int kernel_thread(int (*fn)(void *), voi
1456 regs.orig_gpr2 = -1;
1458 /* Ok, create the new process.. */
1459 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED,
1460 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
1461 0, ®s, 0, NULL, NULL);
1464 diff -NurpP --minimal linux-2.6.22.10/arch/s390/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/arch/s390/kernel/ptrace.c
1465 --- linux-2.6.22.10/arch/s390/kernel/ptrace.c 2007-05-02 19:24:29 +0200
1466 +++ linux-2.6.22.10-vs2.3.0.29/arch/s390/kernel/ptrace.c 2007-08-05 20:53:12 +0200
1468 #include <linux/security.h>
1469 #include <linux/audit.h>
1470 #include <linux/signal.h>
1471 +#include <linux/vs_base.h>
1473 #include <asm/segment.h>
1474 #include <asm/page.h>
1475 @@ -725,7 +726,13 @@ sys_ptrace(long request, long pid, long
1479 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1484 ret = do_ptrace(child, request, addr, data);
1486 put_task_struct(child);
1489 diff -NurpP --minimal linux-2.6.22.10/arch/s390/kernel/syscalls.S linux-2.6.22.10-vs2.3.0.29/arch/s390/kernel/syscalls.S
1490 --- linux-2.6.22.10/arch/s390/kernel/syscalls.S 2007-07-09 13:18:02 +0200
1491 +++ linux-2.6.22.10-vs2.3.0.29/arch/s390/kernel/syscalls.S 2007-08-05 20:53:12 +0200
1492 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
1493 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
1494 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
1495 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
1496 -NI_SYSCALL /* reserved for vserver */
1497 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
1498 SYSCALL(s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
1499 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
1500 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
1501 diff -NurpP --minimal linux-2.6.22.10/arch/s390/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/s390/mm/fault.c
1502 --- linux-2.6.22.10/arch/s390/mm/fault.c 2007-07-09 13:18:02 +0200
1503 +++ linux-2.6.22.10-vs2.3.0.29/arch/s390/mm/fault.c 2007-08-05 20:53:12 +0200
1504 @@ -216,7 +216,8 @@ static int do_out_of_memory(struct pt_re
1505 down_read(&mm->mmap_sem);
1508 - printk("VM: killing process %s\n", tsk->comm);
1509 + printk("VM: killing process %s(%d:#%u)\n",
1510 + tsk->comm, tsk->pid, tsk->xid);
1511 if (regs->psw.mask & PSW_MASK_PSTATE)
1513 do_no_context(regs, error_code, address);
1514 diff -NurpP --minimal linux-2.6.22.10/arch/sh/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/sh/Kconfig
1515 --- linux-2.6.22.10/arch/sh/Kconfig 2007-07-09 13:18:02 +0200
1516 +++ linux-2.6.22.10-vs2.3.0.29/arch/sh/Kconfig 2007-08-05 20:53:12 +0200
1517 @@ -723,6 +723,8 @@ source "arch/sh/oprofile/Kconfig"
1519 source "arch/sh/Kconfig.debug"
1521 +source "kernel/vserver/Kconfig"
1523 source "security/Kconfig"
1525 source "crypto/Kconfig"
1526 diff -NurpP --minimal linux-2.6.22.10/arch/sh/kernel/irq.c linux-2.6.22.10-vs2.3.0.29/arch/sh/kernel/irq.c
1527 --- linux-2.6.22.10/arch/sh/kernel/irq.c 2007-07-09 13:18:03 +0200
1528 +++ linux-2.6.22.10-vs2.3.0.29/arch/sh/kernel/irq.c 2007-08-05 20:53:12 +0200
1530 #include <linux/kernel_stat.h>
1531 #include <linux/seq_file.h>
1532 #include <linux/irq.h>
1533 +#include <linux/vs_context.h>
1534 #include <asm/processor.h>
1535 #include <asm/machvec.h>
1536 #include <asm/uaccess.h>
1537 diff -NurpP --minimal linux-2.6.22.10/arch/sh/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/sh/kernel/process.c
1538 --- linux-2.6.22.10/arch/sh/kernel/process.c 2007-07-09 13:18:03 +0200
1539 +++ linux-2.6.22.10-vs2.3.0.29/arch/sh/kernel/process.c 2007-08-05 20:53:12 +0200
1540 @@ -118,7 +118,8 @@ void machine_power_off(void)
1541 void show_regs(struct pt_regs * regs)
1544 - printk("Pid : %d, Comm: %20s\n", current->pid, current->comm);
1545 + printk("Pid : %d:#%u, Comm: %20s\n",
1546 + current->pid, current->xid, current->comm);
1547 print_symbol("PC is at %s\n", instruction_pointer(regs));
1548 printk("PC : %08lx SP : %08lx SR : %08lx ",
1549 regs->pc, regs->regs[15], regs->sr);
1550 @@ -179,7 +180,7 @@ int kernel_thread(int (*fn)(void *), voi
1551 regs.sr = (1 << 30);
1553 /* Ok, create the new process.. */
1554 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
1555 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD, 0,
1556 ®s, 0, NULL, NULL);
1559 diff -NurpP --minimal linux-2.6.22.10/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.22.10-vs2.3.0.29/arch/sh/kernel/vsyscall/vsyscall.c
1560 --- linux-2.6.22.10/arch/sh/kernel/vsyscall/vsyscall.c 2007-07-09 13:18:03 +0200
1561 +++ linux-2.6.22.10-vs2.3.0.29/arch/sh/kernel/vsyscall/vsyscall.c 2007-08-05 20:53:12 +0200
1563 #include <linux/module.h>
1564 #include <linux/elf.h>
1565 #include <linux/sched.h>
1566 +#include <linux/vs_memory.h>
1569 * Should the kernel map a VDSO page into processes and pass its
1570 diff -NurpP --minimal linux-2.6.22.10/arch/sh/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/sh/mm/fault.c
1571 --- linux-2.6.22.10/arch/sh/mm/fault.c 2007-07-09 13:18:03 +0200
1572 +++ linux-2.6.22.10-vs2.3.0.29/arch/sh/mm/fault.c 2007-08-05 20:53:12 +0200
1573 @@ -201,7 +201,8 @@ out_of_memory:
1574 down_read(&mm->mmap_sem);
1577 - printk("VM: killing process %s\n", tsk->comm);
1578 + printk("VM: killing process %s(%d:#%u)\n",
1579 + tsk->comm, tsk->pid, tsk->xid);
1580 if (user_mode(regs))
1583 diff -NurpP --minimal linux-2.6.22.10/arch/sh64/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/sh64/kernel/process.c
1584 --- linux-2.6.22.10/arch/sh64/kernel/process.c 2007-07-09 13:18:03 +0200
1585 +++ linux-2.6.22.10-vs2.3.0.29/arch/sh64/kernel/process.c 2007-08-05 20:53:12 +0200
1586 @@ -400,8 +400,8 @@ int kernel_thread(int (*fn)(void *), voi
1587 regs.pc = (unsigned long)kernel_thread_helper;
1588 regs.sr = (1 << 30);
1590 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
1591 - ®s, 0, NULL, NULL);
1592 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
1593 + 0, ®s, 0, NULL, NULL);
1597 diff -NurpP --minimal linux-2.6.22.10/arch/sh64/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/sh64/mm/fault.c
1598 --- linux-2.6.22.10/arch/sh64/mm/fault.c 2007-07-09 13:18:04 +0200
1599 +++ linux-2.6.22.10-vs2.3.0.29/arch/sh64/mm/fault.c 2007-08-05 20:53:12 +0200
1600 @@ -81,7 +81,7 @@ static inline void print_vma(struct vm_a
1602 static inline void print_task(struct task_struct *tsk)
1604 - printk("Task pid %d\n", tsk->pid);
1605 + printk("Task pid %d:#%u\n", tsk->pid, tsk->xid);
1608 static pte_t *lookup_pte(struct mm_struct *mm, unsigned long address)
1609 @@ -330,7 +330,8 @@ out_of_memory:
1610 down_read(&mm->mmap_sem);
1613 - printk("VM: killing process %s\n", tsk->comm);
1614 + printk("VM: killing process %s(%d:#%u)\n",
1615 + tsk->comm, tsk->pid, tsk->xid);
1616 if (user_mode(regs))
1619 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/sparc/Kconfig
1620 --- linux-2.6.22.10/arch/sparc/Kconfig 2007-07-09 13:18:04 +0200
1621 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc/Kconfig 2007-08-05 20:53:12 +0200
1622 @@ -317,6 +317,8 @@ endmenu
1624 source "arch/sparc/Kconfig.debug"
1626 +source "kernel/vserver/Kconfig"
1628 source "security/Kconfig"
1630 source "crypto/Kconfig"
1631 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/sparc/kernel/process.c
1632 --- linux-2.6.22.10/arch/sparc/kernel/process.c 2007-07-09 13:18:04 +0200
1633 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc/kernel/process.c 2007-08-05 20:53:12 +0200
1634 @@ -705,7 +705,8 @@ pid_t kernel_thread(int (*fn)(void *), v
1635 /* Notreached by child. */
1636 "1: mov %%o0, %0\n\t" :
1638 - "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
1639 + "i" (__NR_clone), "r" (flags |
1640 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD),
1641 "i" (__NR_exit), "r" (fn), "r" (arg) :
1642 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
1644 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/arch/sparc/kernel/ptrace.c
1645 --- linux-2.6.22.10/arch/sparc/kernel/ptrace.c 2007-02-06 03:00:18 +0100
1646 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc/kernel/ptrace.c 2007-08-05 20:53:12 +0200
1648 #include <linux/smp_lock.h>
1649 #include <linux/security.h>
1650 #include <linux/signal.h>
1651 +#include <linux/vs_base.h>
1653 #include <asm/pgtable.h>
1654 #include <asm/system.h>
1655 @@ -302,6 +303,10 @@ asmlinkage void do_ptrace(struct pt_regs
1656 pt_error_return(regs, -ret);
1659 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1660 + pt_error_return(regs, ESRCH);
1664 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1665 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1666 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/kernel/systbls.S linux-2.6.22.10-vs2.3.0.29/arch/sparc/kernel/systbls.S
1667 --- linux-2.6.22.10/arch/sparc/kernel/systbls.S 2007-07-09 13:18:04 +0200
1668 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc/kernel/systbls.S 2007-08-05 20:53:12 +0200
1669 @@ -71,7 +71,7 @@ sys_call_table:
1670 /*250*/ .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1671 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1672 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1673 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
1674 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1675 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1676 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1677 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
1678 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/sparc/kernel/traps.c
1679 --- linux-2.6.22.10/arch/sparc/kernel/traps.c 2007-07-09 13:18:05 +0200
1680 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc/kernel/traps.c 2007-08-05 20:53:12 +0200
1681 @@ -99,7 +99,8 @@ void die_if_kernel(char *str, struct pt_
1685 - printk("%s(%d): %s [#%d]\n", current->comm, current->pid, str, ++die_counter);
1686 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
1687 + current->pid, current->xid, str, ++die_counter);
1690 __SAVE; __SAVE; __SAVE; __SAVE;
1691 diff -NurpP --minimal linux-2.6.22.10/arch/sparc/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/sparc/mm/fault.c
1692 --- linux-2.6.22.10/arch/sparc/mm/fault.c 2007-07-09 13:18:05 +0200
1693 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc/mm/fault.c 2007-08-05 20:53:12 +0200
1694 @@ -367,7 +367,8 @@ no_context:
1697 up_read(&mm->mmap_sem);
1698 - printk("VM: killing process %s\n", tsk->comm);
1699 + printk("VM: killing process %s(%d:#%u)\n",
1700 + tsk->comm, tsk->pid, tsk->xid);
1704 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/sparc64/Kconfig
1705 --- linux-2.6.22.10/arch/sparc64/Kconfig 2007-07-09 13:18:06 +0200
1706 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc64/Kconfig 2007-08-05 20:53:12 +0200
1707 @@ -451,6 +451,8 @@ endmenu
1709 source "arch/sparc64/Kconfig.debug"
1711 +source "kernel/vserver/Kconfig"
1713 source "security/Kconfig"
1715 source "crypto/Kconfig"
1716 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/binfmt_aout32.c linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/binfmt_aout32.c
1717 --- linux-2.6.22.10/arch/sparc64/kernel/binfmt_aout32.c 2007-02-06 03:00:18 +0100
1718 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/binfmt_aout32.c 2007-08-05 20:53:12 +0200
1720 #include <linux/binfmts.h>
1721 #include <linux/personality.h>
1722 #include <linux/init.h>
1723 +#include <linux/vs_memory.h>
1725 #include <asm/system.h>
1726 #include <asm/uaccess.h>
1727 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/process.c
1728 --- linux-2.6.22.10/arch/sparc64/kernel/process.c 2007-07-09 13:18:06 +0200
1729 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/process.c 2007-08-05 20:53:12 +0200
1730 @@ -707,7 +707,8 @@ pid_t kernel_thread(int (*fn)(void *), v
1731 /* Notreached by child. */
1734 - "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
1735 + "i" (__NR_clone), "r" (flags |
1736 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD),
1737 "i" (__NR_exit), "r" (fn), "r" (arg) :
1738 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
1740 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/ptrace.c
1741 --- linux-2.6.22.10/arch/sparc64/kernel/ptrace.c 2007-02-06 03:00:18 +0100
1742 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/ptrace.c 2007-08-05 20:53:12 +0200
1744 #include <linux/seccomp.h>
1745 #include <linux/audit.h>
1746 #include <linux/signal.h>
1747 +#include <linux/vs_base.h>
1749 #include <asm/asi.h>
1750 #include <asm/pgtable.h>
1751 @@ -215,6 +216,10 @@ asmlinkage void do_ptrace(struct pt_regs
1752 pt_error_return(regs, -ret);
1755 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1756 + pt_error_return(regs, ESRCH);
1760 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1761 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1762 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/sys_sparc32.c linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/sys_sparc32.c
1763 --- linux-2.6.22.10/arch/sparc64/kernel/sys_sparc32.c 2007-07-09 13:18:06 +0200
1764 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/sys_sparc32.c 2007-08-05 20:53:12 +0200
1765 @@ -729,7 +729,7 @@ asmlinkage long sys32_gettimeofday(struc
1769 - do_gettimeofday(&ktv);
1770 + vx_gettimeofday(&ktv);
1771 if (put_tv32(tv, &ktv))
1774 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/systbls.S linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/systbls.S
1775 --- linux-2.6.22.10/arch/sparc64/kernel/systbls.S 2007-07-09 13:18:06 +0200
1776 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/systbls.S 2007-08-05 20:53:12 +0200
1777 @@ -72,7 +72,7 @@ sys_call_table32:
1778 /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
1779 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
1780 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
1781 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
1782 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
1783 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
1784 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
1785 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
1786 @@ -144,7 +144,7 @@ sys_call_table:
1787 /*250*/ .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1788 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1789 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1790 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
1791 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1792 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1793 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1794 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
1795 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/traps.c
1796 --- linux-2.6.22.10/arch/sparc64/kernel/traps.c 2007-10-30 01:57:12 +0100
1797 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc64/kernel/traps.c 2007-09-05 03:06:11 +0200
1798 @@ -2225,7 +2225,8 @@ void die_if_kernel(char *str, struct pt_
1802 - printk("%s(%d): %s [#%d]\n", current->comm, current->pid, str, ++die_counter);
1803 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
1804 + current->pid, current->xid, str, ++die_counter);
1805 notify_die(DIE_OOPS, str, regs, 0, 255, SIGSEGV);
1806 __asm__ __volatile__("flushw");
1808 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/sparc64/mm/fault.c
1809 --- linux-2.6.22.10/arch/sparc64/mm/fault.c 2007-10-30 01:57:12 +0100
1810 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc64/mm/fault.c 2007-09-05 03:06:11 +0200
1811 @@ -463,7 +463,8 @@ handle_kernel_fault:
1813 insn = get_fault_insn(regs, insn);
1814 up_read(&mm->mmap_sem);
1815 - printk("VM: killing process %s\n", current->comm);
1816 + printk("VM: killing process %s(%d:#%u)\n",
1817 + current->comm, current->pid, current->xid);
1818 if (!(regs->tstate & TSTATE_PRIV))
1820 goto handle_kernel_fault;
1821 diff -NurpP --minimal linux-2.6.22.10/arch/sparc64/solaris/fs.c linux-2.6.22.10-vs2.3.0.29/arch/sparc64/solaris/fs.c
1822 --- linux-2.6.22.10/arch/sparc64/solaris/fs.c 2007-02-06 03:00:21 +0100
1823 +++ linux-2.6.22.10-vs2.3.0.29/arch/sparc64/solaris/fs.c 2007-08-05 20:53:12 +0200
1824 @@ -368,7 +368,7 @@ static int report_statvfs(struct vfsmoun
1828 - if (IS_RDONLY(inode)) i = 1;
1829 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
1830 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
1831 if (!sysv_valid_dev(inode->i_sb->s_dev))
1833 @@ -404,7 +404,7 @@ static int report_statvfs64(struct vfsmo
1837 - if (IS_RDONLY(inode)) i = 1;
1838 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
1839 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
1840 if (!sysv_valid_dev(inode->i_sb->s_dev))
1842 diff -NurpP --minimal linux-2.6.22.10/arch/um/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/um/Kconfig
1843 --- linux-2.6.22.10/arch/um/Kconfig 2007-07-09 13:18:07 +0200
1844 +++ linux-2.6.22.10-vs2.3.0.29/arch/um/Kconfig 2007-08-05 20:53:12 +0200
1845 @@ -316,6 +316,8 @@ source "drivers/connector/Kconfig"
1849 +source "kernel/vserver/Kconfig"
1851 source "security/Kconfig"
1853 source "crypto/Kconfig"
1854 diff -NurpP --minimal linux-2.6.22.10/arch/um/kernel/trap.c linux-2.6.22.10-vs2.3.0.29/arch/um/kernel/trap.c
1855 --- linux-2.6.22.10/arch/um/kernel/trap.c 2007-07-09 13:18:07 +0200
1856 +++ linux-2.6.22.10-vs2.3.0.29/arch/um/kernel/trap.c 2007-08-05 20:53:12 +0200
1857 @@ -210,7 +210,8 @@ unsigned long segv(struct faultinfo fi,
1858 current->thread.arch.faultinfo = fi;
1859 force_sig_info(SIGBUS, &si, current);
1860 } else if (err == -ENOMEM) {
1861 - printk("VM: killing process %s\n", current->comm);
1862 + printk("VM: killing process %s(%d:#%u)\n",
1863 + current->comm, current->pid, current->xid);
1866 BUG_ON(err != -EFAULT);
1867 diff -NurpP --minimal linux-2.6.22.10/arch/v850/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/v850/Kconfig
1868 --- linux-2.6.22.10/arch/v850/Kconfig 2007-07-09 13:18:08 +0200
1869 +++ linux-2.6.22.10-vs2.3.0.29/arch/v850/Kconfig 2007-08-05 20:53:12 +0200
1870 @@ -333,6 +333,8 @@ source "drivers/usb/Kconfig"
1872 source "arch/v850/Kconfig.debug"
1874 +source "kernel/vserver/Kconfig"
1876 source "security/Kconfig"
1878 source "crypto/Kconfig"
1879 diff -NurpP --minimal linux-2.6.22.10/arch/v850/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/v850/kernel/process.c
1880 --- linux-2.6.22.10/arch/v850/kernel/process.c 2007-07-09 13:18:08 +0200
1881 +++ linux-2.6.22.10-vs2.3.0.29/arch/v850/kernel/process.c 2007-08-05 20:53:12 +0200
1882 @@ -82,7 +82,7 @@ int kernel_thread (int (*fn)(void *), vo
1883 /* Clone this thread. Note that we don't pass the clone syscall's
1884 second argument -- it's ignored for calls from kernel mode (the
1885 child's SP is always set to the top of the kernel stack). */
1886 - arg0 = flags | CLONE_VM;
1887 + arg0 = flags | CLONE_VM | CLONE_KTHREAD;
1888 syscall = __NR_clone;
1889 asm volatile ("trap " SYSCALL_SHORT_TRAP
1890 : "=r" (ret), "=r" (syscall)
1891 diff -NurpP --minimal linux-2.6.22.10/arch/v850/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/arch/v850/kernel/ptrace.c
1892 --- linux-2.6.22.10/arch/v850/kernel/ptrace.c 2007-07-09 13:18:08 +0200
1893 +++ linux-2.6.22.10-vs2.3.0.29/arch/v850/kernel/ptrace.c 2007-08-05 20:53:12 +0200
1895 #include <linux/sched.h>
1896 #include <linux/ptrace.h>
1897 #include <linux/signal.h>
1898 +#include <linux/vs_base.h>
1900 #include <asm/errno.h>
1901 #include <asm/ptrace.h>
1902 @@ -116,6 +117,9 @@ long arch_ptrace(struct task_struct *chi
1906 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
1910 unsigned long val, copied;
1912 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/Kconfig linux-2.6.22.10-vs2.3.0.29/arch/x86_64/Kconfig
1913 --- linux-2.6.22.10/arch/x86_64/Kconfig 2007-07-09 13:18:08 +0200
1914 +++ linux-2.6.22.10-vs2.3.0.29/arch/x86_64/Kconfig 2007-08-05 20:53:12 +0200
1915 @@ -782,6 +782,8 @@ endmenu
1917 source "arch/x86_64/Kconfig.debug"
1919 +source "kernel/vserver/Kconfig"
1921 source "security/Kconfig"
1923 source "crypto/Kconfig"
1924 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/ia32/ia32_aout.c linux-2.6.22.10-vs2.3.0.29/arch/x86_64/ia32/ia32_aout.c
1925 --- linux-2.6.22.10/arch/x86_64/ia32/ia32_aout.c 2007-02-06 03:00:21 +0100
1926 +++ linux-2.6.22.10-vs2.3.0.29/arch/x86_64/ia32/ia32_aout.c 2007-08-05 20:53:12 +0200
1928 #include <linux/binfmts.h>
1929 #include <linux/personality.h>
1930 #include <linux/init.h>
1931 +#include <linux/vs_memory.h>
1933 #include <asm/system.h>
1934 #include <asm/uaccess.h>
1935 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/ia32/ia32_binfmt.c linux-2.6.22.10-vs2.3.0.29/arch/x86_64/ia32/ia32_binfmt.c
1936 --- linux-2.6.22.10/arch/x86_64/ia32/ia32_binfmt.c 2007-07-09 13:18:08 +0200
1937 +++ linux-2.6.22.10-vs2.3.0.29/arch/x86_64/ia32/ia32_binfmt.c 2007-08-05 20:53:12 +0200
1938 @@ -324,7 +324,8 @@ int ia32_setup_arg_pages(struct linux_bi
1939 kmem_cache_free(vm_area_cachep, mpnt);
1942 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
1943 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
1944 + mm->stack_vm = mm->total_vm;
1947 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
1948 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/ia32/ia32entry.S linux-2.6.22.10-vs2.3.0.29/arch/x86_64/ia32/ia32entry.S
1949 --- linux-2.6.22.10/arch/x86_64/ia32/ia32entry.S 2007-10-30 01:57:12 +0100
1950 +++ linux-2.6.22.10-vs2.3.0.29/arch/x86_64/ia32/ia32entry.S 2007-09-30 14:57:59 +0200
1951 @@ -680,7 +680,7 @@ ia32_sys_call_table:
1952 .quad sys_tgkill /* 270 */
1953 .quad compat_sys_utimes
1954 .quad sys32_fadvise64_64
1955 - .quad quiet_ni_syscall /* sys_vserver */
1956 + .quad sys32_vserver
1958 .quad compat_sys_get_mempolicy /* 275 */
1959 .quad sys_set_mempolicy
1960 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/ia32/sys_ia32.c linux-2.6.22.10-vs2.3.0.29/arch/x86_64/ia32/sys_ia32.c
1961 --- linux-2.6.22.10/arch/x86_64/ia32/sys_ia32.c 2007-07-09 13:18:08 +0200
1962 +++ linux-2.6.22.10-vs2.3.0.29/arch/x86_64/ia32/sys_ia32.c 2007-08-05 20:53:12 +0200
1963 @@ -454,7 +454,7 @@ sys32_gettimeofday(struct compat_timeval
1967 - do_gettimeofday(&ktv);
1968 + vx_gettimeofday(&ktv);
1969 if (put_tv32(tv, &ktv))
1972 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/ia32/syscall32.c linux-2.6.22.10-vs2.3.0.29/arch/x86_64/ia32/syscall32.c
1973 --- linux-2.6.22.10/arch/x86_64/ia32/syscall32.c 2007-07-09 13:18:08 +0200
1974 +++ linux-2.6.22.10-vs2.3.0.29/arch/x86_64/ia32/syscall32.c 2007-08-05 20:53:12 +0200
1976 #include <linux/init.h>
1977 #include <linux/stringify.h>
1978 #include <linux/security.h>
1979 +#include <linux/vs_memory.h>
1980 #include <asm/proto.h>
1981 #include <asm/tlbflush.h>
1982 #include <asm/ia32_unistd.h>
1983 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/kernel/process.c linux-2.6.22.10-vs2.3.0.29/arch/x86_64/kernel/process.c
1984 --- linux-2.6.22.10/arch/x86_64/kernel/process.c 2007-07-09 13:18:08 +0200
1985 +++ linux-2.6.22.10-vs2.3.0.29/arch/x86_64/kernel/process.c 2007-08-05 20:53:12 +0200
1988 asmlinkage extern void ret_from_fork(void);
1990 -unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
1991 +unsigned long kernel_thread_flags =
1992 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
1994 unsigned long boot_option_idle_override = 0;
1995 EXPORT_SYMBOL(boot_option_idle_override);
1996 @@ -310,8 +311,8 @@ void __show_regs(struct pt_regs * regs)
2000 - printk("Pid: %d, comm: %.20s %s %s %.*s\n",
2001 - current->pid, current->comm, print_tainted(),
2002 + printk("Pid: %d:#%u, comm: %.20s %s %s %.*s\n",
2003 + current->pid, current->xid, current->comm, print_tainted(),
2004 init_utsname()->release,
2005 (int)strcspn(init_utsname()->version, " "),
2006 init_utsname()->version);
2007 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/kernel/traps.c linux-2.6.22.10-vs2.3.0.29/arch/x86_64/kernel/traps.c
2008 --- linux-2.6.22.10/arch/x86_64/kernel/traps.c 2007-07-09 13:18:08 +0200
2009 +++ linux-2.6.22.10-vs2.3.0.29/arch/x86_64/kernel/traps.c 2007-09-30 17:11:18 +0200
2011 #include <linux/uaccess.h>
2012 #include <linux/bug.h>
2013 #include <linux/kdebug.h>
2014 +#include <linux/vs_context.h>
2015 +#include <linux/vserver/history.h>
2017 #include <asm/system.h>
2019 @@ -413,8 +415,9 @@ void show_registers(struct pt_regs *regs
2021 printk("CPU %d ", cpu);
2023 - printk("Process %s (pid: %d, threadinfo %p, task %p)\n",
2024 - cur->comm, cur->pid, task_thread_info(cur), cur);
2025 + printk("Process %s (pid: %d[#%u], threadinfo %p, task %p)\n",
2026 + cur->comm, cur->pid, cur->xid,
2027 + task_thread_info(cur), cur);
2030 * When in-kernel, we also print out the stack and code at the
2031 @@ -518,6 +521,7 @@ void __kprobes __die(const char * str, s
2033 notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
2034 show_registers(regs);
2035 + vxh_dump_history();
2036 /* Executive summary in case the oops scrolled away */
2037 printk(KERN_ALERT "RIP ");
2038 printk_address(regs->rip);
2039 @@ -530,6 +534,7 @@ void die(const char * str, struct pt_reg
2041 unsigned long flags = oops_begin();
2044 if (!user_mode(regs))
2045 report_bug(regs->rip);
2047 @@ -542,12 +547,14 @@ void __kprobes die_nmi(char *str, struct
2049 unsigned long flags = oops_begin();
2053 * We are in trouble anyway, lets at least try
2054 * to get a message out.
2056 printk(str, smp_processor_id());
2057 show_registers(regs);
2058 + vxh_dump_history();
2059 if (kexec_should_crash(current))
2061 if (do_panic || panic_on_oops)
2062 @@ -580,8 +587,8 @@ static void __kprobes do_trap(int trapnr
2064 if (exception_trace && unhandled_signal(tsk, signr))
2066 - "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
2067 - tsk->comm, tsk->pid, str,
2068 + "%s[%d:#%u] trap %s rip:%lx rsp:%lx error:%lx\n",
2069 + tsk->comm, tsk->pid, tsk->xid, str,
2070 regs->rip, regs->rsp, error_code);
2073 @@ -684,8 +691,8 @@ asmlinkage void __kprobes do_general_pro
2075 if (exception_trace && unhandled_signal(tsk, SIGSEGV))
2077 - "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
2078 - tsk->comm, tsk->pid,
2079 + "%s[%d:#%u] general protection rip:%lx rsp:%lx error:%lx\n",
2080 + tsk->comm, tsk->pid, tsk->xid,
2081 regs->rip, regs->rsp, error_code);
2083 force_sig(SIGSEGV, tsk);
2084 diff -NurpP --minimal linux-2.6.22.10/arch/x86_64/mm/fault.c linux-2.6.22.10-vs2.3.0.29/arch/x86_64/mm/fault.c
2085 --- linux-2.6.22.10/arch/x86_64/mm/fault.c 2007-07-09 13:18:08 +0200
2086 +++ linux-2.6.22.10-vs2.3.0.29/arch/x86_64/mm/fault.c 2007-08-05 20:53:12 +0200
2087 @@ -497,10 +497,10 @@ bad_area_nosemaphore:
2089 if (exception_trace && unhandled_signal(tsk, SIGSEGV)) {
2091 - "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
2092 + "%s%s[%d:#%u]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
2093 tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
2094 - tsk->comm, tsk->pid, address, regs->rip,
2095 - regs->rsp, error_code);
2096 + tsk->comm, tsk->pid, tsk->xid, address,
2097 + regs->rip, regs->rsp, error_code);
2100 tsk->thread.cr2 = address;
2101 @@ -567,7 +567,8 @@ out_of_memory:
2105 - printk("VM: killing process %s\n", tsk->comm);
2106 + printk("VM: killing process %s(%d:#%u)\n",
2107 + tsk->comm, tsk->pid, tsk->xid);
2111 Files linux-2.6.22.10/core and linux-2.6.22.10-vs2.3.0.29/core differ
2112 diff -NurpP --minimal linux-2.6.22.10/drivers/block/Kconfig linux-2.6.22.10-vs2.3.0.29/drivers/block/Kconfig
2113 --- linux-2.6.22.10/drivers/block/Kconfig 2007-07-09 13:18:16 +0200
2114 +++ linux-2.6.22.10-vs2.3.0.29/drivers/block/Kconfig 2007-08-05 20:53:12 +0200
2115 @@ -311,6 +311,13 @@ config BLK_DEV_CRYPTOLOOP
2116 instead, which can be configured to be on-disk compatible with the
2119 +config BLK_DEV_VROOT
2120 + tristate "Virtual Root device support"
2121 + depends on QUOTACTL
2123 + Saying Y here will allow you to use quota/fs ioctls on a shared
2124 + partition within a virtual server without compromising security.
2127 tristate "Network block device support"
2129 diff -NurpP --minimal linux-2.6.22.10/drivers/block/Makefile linux-2.6.22.10-vs2.3.0.29/drivers/block/Makefile
2130 --- linux-2.6.22.10/drivers/block/Makefile 2007-02-06 03:00:26 +0100
2131 +++ linux-2.6.22.10-vs2.3.0.29/drivers/block/Makefile 2007-08-05 20:53:12 +0200
2132 @@ -28,4 +28,5 @@ obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryp
2133 obj-$(CONFIG_VIODASD) += viodasd.o
2134 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
2135 obj-$(CONFIG_BLK_DEV_UB) += ub.o
2136 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
2138 diff -NurpP --minimal linux-2.6.22.10/drivers/block/loop.c linux-2.6.22.10-vs2.3.0.29/drivers/block/loop.c
2139 --- linux-2.6.22.10/drivers/block/loop.c 2007-07-09 13:18:16 +0200
2140 +++ linux-2.6.22.10-vs2.3.0.29/drivers/block/loop.c 2007-08-16 04:06:51 +0200
2142 #include <linux/highmem.h>
2143 #include <linux/gfp.h>
2144 #include <linux/kthread.h>
2145 +#include <linux/vs_context.h>
2147 #include <asm/uaccess.h>
2149 @@ -790,6 +791,7 @@ static int loop_set_fd(struct loop_devic
2150 lo->lo_blocksize = lo_blocksize;
2151 lo->lo_device = bdev;
2152 lo->lo_flags = lo_flags;
2153 + lo->lo_xid = vx_current_xid();
2154 lo->lo_backing_file = file;
2155 lo->transfer = transfer_none;
2157 @@ -909,6 +911,7 @@ static int loop_clr_fd(struct loop_devic
2158 lo->lo_encrypt_key_size = 0;
2160 lo->lo_thread = NULL;
2162 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2163 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2164 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2165 @@ -930,7 +933,7 @@ loop_set_status(struct loop_device *lo,
2166 struct loop_func_table *xfer;
2168 if (lo->lo_encrypt_key_size && lo->lo_key_owner != current->uid &&
2169 - !capable(CAP_SYS_ADMIN))
2170 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2172 if (lo->lo_state != Lo_bound)
2174 @@ -1010,7 +1013,8 @@ loop_get_status(struct loop_device *lo,
2175 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2176 info->lo_encrypt_type =
2177 lo->lo_encryption ? lo->lo_encryption->number : 0;
2178 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2179 + if (lo->lo_encrypt_key_size &&
2180 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2181 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2182 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2183 lo->lo_encrypt_key_size);
2184 @@ -1321,6 +1325,9 @@ static int lo_open(struct inode *inode,
2186 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
2188 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID))
2191 mutex_lock(&lo->lo_ctl_mutex);
2193 mutex_unlock(&lo->lo_ctl_mutex);
2194 diff -NurpP --minimal linux-2.6.22.10/drivers/block/vroot.c linux-2.6.22.10-vs2.3.0.29/drivers/block/vroot.c
2195 --- linux-2.6.22.10/drivers/block/vroot.c 1970-01-01 01:00:00 +0100
2196 +++ linux-2.6.22.10-vs2.3.0.29/drivers/block/vroot.c 2007-08-05 20:53:12 +0200
2199 + * linux/drivers/block/vroot.c
2201 + * written by Herbert Pötzl, 9/11/2002
2202 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2204 + * based on the loop.c code by Theodore Ts'o.
2206 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2207 + * Redistribution of this file is permitted under the
2208 + * GNU General Public License.
2212 +#include <linux/module.h>
2213 +#include <linux/moduleparam.h>
2214 +#include <linux/file.h>
2215 +#include <linux/major.h>
2216 +#include <linux/blkdev.h>
2218 +#include <linux/vroot.h>
2219 +#include <linux/vs_context.h>
2222 +static int max_vroot = 8;
2224 +static struct vroot_device *vroot_dev;
2225 +static struct gendisk **disks;
2228 +static int vroot_set_dev(
2229 + struct vroot_device *vr,
2230 + struct file *vr_file,
2231 + struct block_device *bdev,
2234 + struct block_device *real_bdev;
2235 + struct file *file;
2236 + struct inode *inode;
2240 + if (vr->vr_state != Vr_unbound)
2249 + inode = file->f_dentry->d_inode;
2252 + if (S_ISBLK(inode->i_mode)) {
2253 + real_bdev = inode->i_bdev;
2254 + vr->vr_device = real_bdev;
2255 + __iget(real_bdev->bd_inode);
2259 + vxdprintk(VXD_CBIT(misc, 0),
2260 + "vroot[%d]_set_dev: dev=" VXF_DEV,
2261 + vr->vr_number, VXD_DEV(real_bdev));
2263 + vr->vr_state = Vr_bound;
2272 +static int vroot_clr_dev(
2273 + struct vroot_device *vr,
2274 + struct file *vr_file,
2275 + struct block_device *bdev)
2277 + struct block_device *real_bdev;
2279 + if (vr->vr_state != Vr_bound)
2281 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
2284 + real_bdev = vr->vr_device;
2286 + vxdprintk(VXD_CBIT(misc, 0),
2287 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
2288 + vr->vr_number, VXD_DEV(real_bdev));
2291 + vr->vr_state = Vr_unbound;
2292 + vr->vr_device = NULL;
2297 +static int vr_ioctl(struct inode *inode, struct file *file,
2298 + unsigned int cmd, unsigned long arg)
2300 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2303 + down(&vr->vr_ctl_mutex);
2305 + case VROOT_SET_DEV:
2306 + err = vroot_set_dev(vr, file, inode->i_bdev, arg);
2308 + case VROOT_CLR_DEV:
2309 + err = vroot_clr_dev(vr, file, inode->i_bdev);
2315 + up(&vr->vr_ctl_mutex);
2319 +static int vr_open(struct inode *inode, struct file *file)
2321 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2323 + down(&vr->vr_ctl_mutex);
2325 + up(&vr->vr_ctl_mutex);
2329 +static int vr_release(struct inode *inode, struct file *file)
2331 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
2333 + down(&vr->vr_ctl_mutex);
2335 + up(&vr->vr_ctl_mutex);
2339 +static struct block_device_operations vr_fops = {
2340 + .owner = THIS_MODULE,
2342 + .release = vr_release,
2343 + .ioctl = vr_ioctl,
2346 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2348 + struct inode *inode = bdev->bd_inode;
2349 + struct vroot_device *vr;
2350 + struct block_device *real_bdev;
2351 + int minor = iminor(inode);
2353 + vr = &vroot_dev[minor];
2354 + real_bdev = vr->vr_device;
2356 + vxdprintk(VXD_CBIT(misc, 0),
2357 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2358 + vr->vr_number, VXD_DEV(real_bdev));
2360 + if (vr->vr_state != Vr_bound)
2361 + return ERR_PTR(-ENXIO);
2363 + __iget(real_bdev->bd_inode);
2368 + * And now the modules code and kernel interface.
2371 +module_param(max_vroot, int, 0);
2373 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
2374 +MODULE_LICENSE("GPL");
2375 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
2377 +MODULE_AUTHOR ("Herbert Pötzl");
2378 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
2381 +int __init vroot_init(void)
2385 + if (max_vroot < 1 || max_vroot > 256) {
2386 + max_vroot = MAX_VROOT_DEFAULT;
2387 + printk(KERN_WARNING "vroot: invalid max_vroot "
2388 + "(must be between 1 and 256), "
2389 + "using default (%d)\n", max_vroot);
2392 + if (register_blkdev(VROOT_MAJOR, "vroot"))
2396 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2399 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2401 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2405 + for (i = 0; i < max_vroot; i++) {
2406 + disks[i] = alloc_disk(1);
2411 + for (i = 0; i < max_vroot; i++) {
2412 + struct vroot_device *vr = &vroot_dev[i];
2413 + struct gendisk *disk = disks[i];
2415 + memset(vr, 0, sizeof(*vr));
2416 + init_MUTEX(&vr->vr_ctl_mutex);
2417 + vr->vr_number = i;
2418 + disk->major = VROOT_MAJOR;
2419 + disk->first_minor = i;
2420 + disk->fops = &vr_fops;
2421 + sprintf(disk->disk_name, "vroot%d", i);
2422 + disk->private_data = vr;
2425 + err = register_vroot_grb(&__vroot_get_real_bdev);
2429 + for (i = 0; i < max_vroot; i++)
2430 + add_disk(disks[i]);
2431 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2436 + put_disk(disks[i]);
2441 + unregister_blkdev(VROOT_MAJOR, "vroot");
2442 + printk(KERN_ERR "vroot: ran out of memory\n");
2446 +void vroot_exit(void)
2450 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
2451 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
2453 + for (i = 0; i < max_vroot; i++) {
2454 + del_gendisk(disks[i]);
2455 + put_disk(disks[i]);
2457 + if (unregister_blkdev(VROOT_MAJOR, "vroot"))
2458 + printk(KERN_WARNING "vroot: cannot unregister blkdev\n");
2464 +module_init(vroot_init);
2465 +module_exit(vroot_exit);
2469 +static int __init max_vroot_setup(char *str)
2471 + max_vroot = simple_strtol(str, NULL, 0);
2475 +__setup("max_vroot=", max_vroot_setup);
2479 diff -NurpP --minimal linux-2.6.22.10/drivers/char/sysrq.c linux-2.6.22.10-vs2.3.0.29/drivers/char/sysrq.c
2480 --- linux-2.6.22.10/drivers/char/sysrq.c 2007-07-09 13:18:20 +0200
2481 +++ linux-2.6.22.10-vs2.3.0.29/drivers/char/sysrq.c 2007-08-05 20:53:12 +0200
2483 #include <linux/kexec.h>
2484 #include <linux/irq.h>
2485 #include <linux/hrtimer.h>
2486 +#include <linux/vserver/debug.h>
2488 #include <asm/ptrace.h>
2489 #include <asm/irq_regs.h>
2490 @@ -309,6 +310,21 @@ static struct sysrq_key_op sysrq_unrt_op
2491 .enable_mask = SYSRQ_ENABLE_RTNICE,
2495 +#ifdef CONFIG_VSERVER_DEBUG
2496 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
2498 + dump_vx_info_inactive((key == 'x')?0:1);
2501 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2502 + .handler = sysrq_handle_vxinfo,
2503 + .help_msg = "conteXt",
2504 + .action_msg = "Show Context Info",
2505 + .enable_mask = SYSRQ_ENABLE_DUMP,
2509 /* Key Operations table and lock */
2510 static DEFINE_SPINLOCK(sysrq_key_table_lock);
2512 @@ -357,7 +373,11 @@ static struct sysrq_key_op *sysrq_key_ta
2513 /* x: May be registered on ppc/powerpc for xmon */
2517 +#ifdef CONFIG_VSERVER_DEBUG
2518 + &sysrq_showvxinfo_op, /* z */
2524 /* key2index calculation, -1 on invalid index */
2525 @@ -369,6 +389,8 @@ static int sysrq_key_table_key2index(int
2527 else if ((key >= 'a') && (key <= 'z'))
2528 retval = key + 10 - 'a';
2529 + else if ((key >= 'A') && (key <= 'Z'))
2530 + retval = key + 10 - 'A';
2534 diff -NurpP --minimal linux-2.6.22.10/drivers/char/tty_io.c linux-2.6.22.10-vs2.3.0.29/drivers/char/tty_io.c
2535 --- linux-2.6.22.10/drivers/char/tty_io.c 2007-07-09 13:18:20 +0200
2536 +++ linux-2.6.22.10-vs2.3.0.29/drivers/char/tty_io.c 2007-08-05 20:53:12 +0200
2538 #include <linux/selection.h>
2540 #include <linux/kmod.h>
2541 +#include <linux/vs_pid.h>
2543 #undef TTY_DEBUG_HANGUP
2545 @@ -3049,13 +3050,15 @@ unlock:
2547 static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
2551 * (tty == real_tty) is a cheap way of
2552 * testing if the tty is NOT a master pty.
2554 if (tty == real_tty && current->signal->tty != real_tty)
2556 - return put_user(pid_nr(real_tty->pgrp), p);
2557 + pgrp = vx_map_pid(pid_nr(real_tty->pgrp));
2558 + return put_user(pgrp, p);
2562 @@ -3086,6 +3089,7 @@ static int tiocspgrp(struct tty_struct *
2564 if (get_user(pgrp_nr, p))
2566 + pgrp_nr = vx_rmap_pid(pgrp_nr);
2570 diff -NurpP --minimal linux-2.6.22.10/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.22.10-vs2.3.0.29/drivers/infiniband/hw/ipath/ipath_user_pages.c
2571 --- linux-2.6.22.10/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-02-06 03:00:37 +0100
2572 +++ linux-2.6.22.10-vs2.3.0.29/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-08-05 20:53:12 +0200
2575 #include <linux/mm.h>
2576 #include <linux/device.h>
2577 +#include <linux/vs_memory.h>
2579 #include "ipath_kernel.h"
2581 @@ -61,7 +62,8 @@ static int __get_user_pages(unsigned lon
2582 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
2585 - if (num_pages > lock_limit) {
2586 + if (num_pages > lock_limit ||
2587 + !vx_vmlocked_avail(current->mm, num_pages)) {
2591 @@ -78,7 +80,7 @@ static int __get_user_pages(unsigned lon
2595 - current->mm->locked_vm += num_pages;
2596 + vx_vmlocked_add(current->mm, num_pages);
2600 @@ -203,7 +205,7 @@ void ipath_release_user_pages(struct pag
2602 __ipath_release_user_pages(p, num_pages, 1);
2604 - current->mm->locked_vm -= num_pages;
2605 + vx_vmlocked_sub(current->mm, num_pages);
2607 up_write(¤t->mm->mmap_sem);
2609 @@ -220,7 +222,7 @@ static void user_pages_account(struct wo
2610 container_of(_work, struct ipath_user_pages_work, work);
2612 down_write(&work->mm->mmap_sem);
2613 - work->mm->locked_vm -= work->num_pages;
2614 + vx_vmlocked_sub(work->mm, work->num_pages);
2615 up_write(&work->mm->mmap_sem);
2618 diff -NurpP --minimal linux-2.6.22.10/drivers/md/dm-ioctl.c linux-2.6.22.10-vs2.3.0.29/drivers/md/dm-ioctl.c
2619 --- linux-2.6.22.10/drivers/md/dm-ioctl.c 2007-05-02 19:24:50 +0200
2620 +++ linux-2.6.22.10-vs2.3.0.29/drivers/md/dm-ioctl.c 2007-08-05 20:53:12 +0200
2622 #include <linux/slab.h>
2623 #include <linux/dm-ioctl.h>
2624 #include <linux/hdreg.h>
2625 +#include <linux/vs_context.h>
2627 #include <asm/uaccess.h>
2629 @@ -100,7 +101,8 @@ static struct hash_cell *__get_name_cell
2630 unsigned int h = hash_str(str);
2632 list_for_each_entry (hc, _name_buckets + h, name_list)
2633 - if (!strcmp(hc->name, str)) {
2634 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2635 + !strcmp(hc->name, str)) {
2639 @@ -114,7 +116,8 @@ static struct hash_cell *__get_uuid_cell
2640 unsigned int h = hash_str(str);
2642 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
2643 - if (!strcmp(hc->uuid, str)) {
2644 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2645 + !strcmp(hc->uuid, str)) {
2649 @@ -349,6 +352,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
2651 static int remove_all(struct dm_ioctl *param, size_t param_size)
2653 + if (!vx_check(0, VS_ADMIN))
2656 dm_hash_remove_all(1);
2657 param->data_size = 0;
2659 @@ -396,6 +402,8 @@ static int list_devices(struct dm_ioctl
2661 for (i = 0; i < NUM_BUCKETS; i++) {
2662 list_for_each_entry (hc, _name_buckets + i, name_list) {
2663 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2665 needed += sizeof(struct dm_name_list);
2666 needed += strlen(hc->name) + 1;
2667 needed += ALIGN_MASK;
2668 @@ -419,6 +427,8 @@ static int list_devices(struct dm_ioctl
2670 for (i = 0; i < NUM_BUCKETS; i++) {
2671 list_for_each_entry (hc, _name_buckets + i, name_list) {
2672 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2675 old_nl->next = (uint32_t) ((void *) nl -
2677 @@ -609,10 +619,11 @@ static struct hash_cell *__find_device_h
2681 - mdptr = dm_get_mdptr(md);
2682 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
2683 + mdptr = dm_get_mdptr(md);
2691 @@ -1409,8 +1420,8 @@ static int ctl_ioctl(struct inode *inode
2695 - /* only root can play with this */
2696 - if (!capable(CAP_SYS_ADMIN))
2697 + /* only root and certain contexts can play with this */
2698 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
2701 if (_IOC_TYPE(command) != DM_IOCTL)
2702 diff -NurpP --minimal linux-2.6.22.10/drivers/md/dm.c linux-2.6.22.10-vs2.3.0.29/drivers/md/dm.c
2703 --- linux-2.6.22.10/drivers/md/dm.c 2007-10-30 01:57:13 +0100
2704 +++ linux-2.6.22.10-vs2.3.0.29/drivers/md/dm.c 2007-08-11 22:41:50 +0200
2706 #include <linux/hdreg.h>
2707 #include <linux/blktrace_api.h>
2708 #include <linux/smp_lock.h>
2709 +#include <linux/vs_base.h>
2711 #define DM_MSG_PREFIX "core"
2713 @@ -77,6 +78,7 @@ struct mapped_device {
2716 atomic_t open_count;
2719 unsigned long flags;
2721 @@ -223,6 +225,7 @@ static void __exit dm_exit(void)
2722 static int dm_blk_open(struct inode *inode, struct file *file)
2724 struct mapped_device *md;
2727 spin_lock(&_minor_lock);
2729 @@ -231,18 +234,19 @@ static int dm_blk_open(struct inode *ino
2732 if (test_bit(DMF_FREEING, &md->flags) ||
2733 - test_bit(DMF_DELETING, &md->flags)) {
2735 + test_bit(DMF_DELETING, &md->flags))
2739 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
2744 atomic_inc(&md->open_count);
2748 spin_unlock(&_minor_lock);
2750 - return md ? 0 : -ENXIO;
2754 static int dm_blk_close(struct inode *inode, struct file *file)
2755 @@ -438,6 +442,14 @@ int dm_set_geometry(struct mapped_device
2760 + * Get the xid associated with a dm device
2762 +xid_t dm_get_xid(struct mapped_device *md)
2767 /*-----------------------------------------------------------------
2769 * A more elegant soln is in the works that uses the queue
2770 @@ -1000,6 +1012,7 @@ static struct mapped_device *alloc_dev(i
2771 atomic_set(&md->holders, 1);
2772 atomic_set(&md->open_count, 0);
2773 atomic_set(&md->event_nr, 0);
2774 + md->xid = vx_current_xid();
2776 md->queue = blk_alloc_queue(GFP_KERNEL);
2778 diff -NurpP --minimal linux-2.6.22.10/drivers/md/dm.h linux-2.6.22.10-vs2.3.0.29/drivers/md/dm.h
2779 --- linux-2.6.22.10/drivers/md/dm.h 2007-02-06 03:00:41 +0100
2780 +++ linux-2.6.22.10-vs2.3.0.29/drivers/md/dm.h 2007-08-05 20:53:12 +0200
2781 @@ -91,6 +91,8 @@ void dm_put_target_type(struct target_ty
2782 int dm_target_iterate(void (*iter_func)(struct target_type *tt,
2783 void *param), void *param);
2785 +xid_t dm_get_xid(struct mapped_device *md);
2787 /*-----------------------------------------------------------------
2789 *---------------------------------------------------------------*/
2790 diff -NurpP --minimal linux-2.6.22.10/fs/attr.c linux-2.6.22.10-vs2.3.0.29/fs/attr.c
2791 --- linux-2.6.22.10/fs/attr.c 2007-07-09 13:19:22 +0200
2792 +++ linux-2.6.22.10-vs2.3.0.29/fs/attr.c 2007-10-25 17:05:55 +0200
2794 #include <linux/fcntl.h>
2795 #include <linux/quotaops.h>
2796 #include <linux/security.h>
2797 +#include <linux/proc_fs.h>
2798 +#include <linux/devpts_fs.h>
2799 +#include <linux/vs_base.h>
2801 /* Taken over from the old code... */
2803 @@ -55,6 +58,27 @@ int inode_change_ok(struct inode *inode,
2804 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
2808 + /* Check for evil vserver activity */
2809 + if (vx_check(0, VS_ADMIN))
2812 + if (IS_BARRIER(inode)) {
2813 + vxwprintk_task(1, "messing with the barrier.");
2816 + switch (inode->i_sb->s_magic) {
2817 + case PROC_SUPER_MAGIC:
2818 + /* maybe allow that in the future? */
2819 + vxwprintk_task(1, "messing with the procfs.");
2821 + case DEVPTS_SUPER_MAGIC:
2822 + /* devpts is xid tagged */
2823 + if (vx_check((xid_t)inode->i_tag, VS_IDENT))
2825 + vxwprintk_task(1, "messing with the devpts.");
2831 @@ -78,6 +102,8 @@ int inode_setattr(struct inode * inode,
2832 inode->i_uid = attr->ia_uid;
2833 if (ia_valid & ATTR_GID)
2834 inode->i_gid = attr->ia_gid;
2835 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2836 + inode->i_tag = attr->ia_tag;
2837 if (ia_valid & ATTR_ATIME)
2838 inode->i_atime = timespec_trunc(attr->ia_atime,
2839 inode->i_sb->s_time_gran);
2840 @@ -152,7 +178,8 @@ int notify_change(struct dentry * dentry
2841 error = security_inode_setattr(dentry, attr);
2843 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2844 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2845 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2846 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2847 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
2849 error = inode_setattr(inode, attr);
2850 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_aout.c linux-2.6.22.10-vs2.3.0.29/fs/binfmt_aout.c
2851 --- linux-2.6.22.10/fs/binfmt_aout.c 2007-02-06 03:01:16 +0100
2852 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_aout.c 2007-08-05 20:53:12 +0200
2854 #include <linux/binfmts.h>
2855 #include <linux/personality.h>
2856 #include <linux/init.h>
2857 +#include <linux/vs_memory.h>
2859 #include <asm/system.h>
2860 #include <asm/uaccess.h>
2861 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_elf.c linux-2.6.22.10-vs2.3.0.29/fs/binfmt_elf.c
2862 --- linux-2.6.22.10/fs/binfmt_elf.c 2007-07-09 13:19:22 +0200
2863 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_elf.c 2007-08-05 20:53:12 +0200
2865 #include <linux/random.h>
2866 #include <linux/elf.h>
2867 #include <linux/utsname.h>
2868 +#include <linux/vs_memory.h>
2869 #include <asm/uaccess.h>
2870 #include <asm/param.h>
2871 #include <asm/page.h>
2872 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_flat.c linux-2.6.22.10-vs2.3.0.29/fs/binfmt_flat.c
2873 --- linux-2.6.22.10/fs/binfmt_flat.c 2007-07-09 13:19:22 +0200
2874 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_flat.c 2007-08-05 20:53:12 +0200
2876 #include <linux/init.h>
2877 #include <linux/flat.h>
2878 #include <linux/syscalls.h>
2879 +#include <linux/vs_memory.h>
2881 #include <asm/byteorder.h>
2882 #include <asm/system.h>
2883 diff -NurpP --minimal linux-2.6.22.10/fs/binfmt_som.c linux-2.6.22.10-vs2.3.0.29/fs/binfmt_som.c
2884 --- linux-2.6.22.10/fs/binfmt_som.c 2006-11-30 21:19:19 +0100
2885 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_som.c 2007-08-05 20:53:12 +0200
2887 #include <linux/shm.h>
2888 #include <linux/personality.h>
2889 #include <linux/init.h>
2890 +#include <linux/vs_memory.h>
2892 #include <asm/a.out.h>
2893 #include <asm/uaccess.h>
2894 diff -NurpP --minimal linux-2.6.22.10/fs/block_dev.c linux-2.6.22.10-vs2.3.0.29/fs/block_dev.c
2895 --- linux-2.6.22.10/fs/block_dev.c 2007-07-09 13:19:22 +0200
2896 +++ linux-2.6.22.10-vs2.3.0.29/fs/block_dev.c 2007-10-11 01:10:22 +0200
2898 #include <linux/uio.h>
2899 #include <linux/namei.h>
2900 #include <linux/log2.h>
2901 +#include <linux/vs_device.h>
2902 #include <asm/uaccess.h>
2903 #include "internal.h"
2905 @@ -572,6 +573,7 @@ struct block_device *bdget(dev_t dev)
2906 bdev->bd_invalidated = 0;
2907 inode->i_mode = S_IFBLK;
2908 inode->i_rdev = dev;
2909 + inode->i_mdev = dev;
2910 inode->i_bdev = bdev;
2911 inode->i_data.a_ops = &def_blk_aops;
2912 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2913 @@ -610,6 +612,11 @@ EXPORT_SYMBOL(bdput);
2914 static struct block_device *bd_acquire(struct inode *inode)
2916 struct block_device *bdev;
2919 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2921 + inode->i_mdev = mdev;
2923 spin_lock(&bdev_lock);
2924 bdev = inode->i_bdev;
2925 @@ -620,7 +627,7 @@ static struct block_device *bd_acquire(s
2927 spin_unlock(&bdev_lock);
2929 - bdev = bdget(inode->i_rdev);
2930 + bdev = bdget(mdev);
2932 spin_lock(&bdev_lock);
2933 if (!inode->i_bdev) {
2934 diff -NurpP --minimal linux-2.6.22.10/fs/char_dev.c linux-2.6.22.10-vs2.3.0.29/fs/char_dev.c
2935 --- linux-2.6.22.10/fs/char_dev.c 2007-05-02 19:25:16 +0200
2936 +++ linux-2.6.22.10-vs2.3.0.29/fs/char_dev.c 2007-10-11 01:10:22 +0200
2938 #include <linux/cdev.h>
2939 #include <linux/mutex.h>
2940 #include <linux/backing-dev.h>
2941 +#include <linux/vs_device.h>
2944 #include <linux/kmod.h>
2945 @@ -363,14 +364,21 @@ int chrdev_open(struct inode * inode, st
2947 struct cdev *new = NULL;
2951 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2953 + inode->i_mdev = mdev;
2955 spin_lock(&cdev_lock);
2958 struct kobject *kobj;
2961 spin_unlock(&cdev_lock);
2962 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2964 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2967 new = container_of(kobj, struct cdev, kobj);
2968 diff -NurpP --minimal linux-2.6.22.10/fs/dcache.c linux-2.6.22.10-vs2.3.0.29/fs/dcache.c
2969 --- linux-2.6.22.10/fs/dcache.c 2007-07-09 13:19:23 +0200
2970 +++ linux-2.6.22.10-vs2.3.0.29/fs/dcache.c 2007-08-05 20:53:12 +0200
2972 #include <linux/seqlock.h>
2973 #include <linux/swap.h>
2974 #include <linux/bootmem.h>
2975 +#include <linux/vs_limit.h>
2976 #include "internal.h"
2979 @@ -176,6 +177,7 @@ void dput(struct dentry *dentry)
2983 + vx_dentry_dec(dentry);
2985 if (atomic_read(&dentry->d_count) == 1)
2987 @@ -189,6 +191,8 @@ repeat:
2991 + vx_dentry_dec(dentry);
2994 * AV: ->d_delete() is _NOT_ allowed to block now.
2996 @@ -288,6 +292,7 @@ static inline struct dentry * __dget_loc
2997 if (!list_empty(&dentry->d_lru)) {
2998 dentry_stat.nr_unused--;
2999 list_del_init(&dentry->d_lru);
3000 + vx_dentry_inc(dentry);
3004 @@ -898,6 +903,9 @@ struct dentry *d_alloc(struct dentry * p
3005 struct dentry *dentry;
3008 + if (!vx_dentry_avail(1))
3011 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
3014 @@ -946,6 +954,7 @@ struct dentry *d_alloc(struct dentry * p
3016 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
3017 dentry_stat.nr_dentry++;
3018 + vx_dentry_inc(dentry);
3019 spin_unlock(&dcache_lock);
3022 @@ -1295,6 +1304,7 @@ struct dentry * __d_lookup(struct dentry
3024 if (!d_unhashed(dentry)) {
3025 atomic_inc(&dentry->d_count);
3026 + vx_dentry_inc(dentry);
3029 spin_unlock(&dentry->d_lock);
3030 diff -NurpP --minimal linux-2.6.22.10/fs/devpts/inode.c linux-2.6.22.10-vs2.3.0.29/fs/devpts/inode.c
3031 --- linux-2.6.22.10/fs/devpts/inode.c 2007-07-09 13:19:23 +0200
3032 +++ linux-2.6.22.10-vs2.3.0.29/fs/devpts/inode.c 2007-10-18 00:59:53 +0200
3034 #include <linux/namei.h>
3035 #include <linux/mount.h>
3036 #include <linux/tty.h>
3037 +#include <linux/magic.h>
3038 #include <linux/devpts_fs.h>
3039 #include <linux/parser.h>
3040 #include <linux/fsnotify.h>
3041 +#include <linux/vs_base.h>
3043 -#define DEVPTS_SUPER_MAGIC 0x1cd1
3045 +static int devpts_permission(struct inode *inode, int mask, struct nameidata *nd)
3047 + int ret = -EACCES;
3049 + /* devpts is xid tagged */
3050 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
3051 + ret = generic_permission(inode, mask, NULL);
3055 +static struct inode_operations devpts_file_inode_operations = {
3056 + .permission = devpts_permission,
3059 static struct vfsmount *devpts_mnt;
3060 static struct dentry *devpts_root;
3061 @@ -92,6 +107,25 @@ static int devpts_remount(struct super_b
3065 +static int devpts_filter(struct dentry *de)
3067 + /* devpts is xid tagged */
3068 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
3071 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
3073 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
3076 +static struct file_operations devpts_dir_operations = {
3077 + .open = dcache_dir_open,
3078 + .release = dcache_dir_close,
3079 + .llseek = dcache_dir_lseek,
3080 + .read = generic_read_dir,
3081 + .readdir = devpts_readdir,
3084 static const struct super_operations devpts_sops = {
3085 .statfs = simple_statfs,
3086 .remount_fs = devpts_remount,
3087 @@ -117,8 +151,10 @@ devpts_fill_super(struct super_block *s,
3088 inode->i_uid = inode->i_gid = 0;
3089 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
3090 inode->i_op = &simple_dir_inode_operations;
3091 - inode->i_fop = &simple_dir_operations;
3092 + inode->i_fop = &devpts_dir_operations;
3094 + /* devpts is xid tagged */
3095 + inode->i_tag = (tag_t)vx_current_xid();
3097 devpts_root = s->s_root = d_alloc_root(inode);
3099 @@ -176,6 +212,9 @@ int devpts_pty_new(struct tty_struct *tt
3100 inode->i_gid = config.setgid ? config.gid : current->fsgid;
3101 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
3102 init_special_inode(inode, S_IFCHR|config.mode, device);
3103 + /* devpts is xid tagged */
3104 + inode->i_tag = (tag_t)vx_current_xid();
3105 + inode->i_op = &devpts_file_inode_operations;
3106 inode->i_private = tty;
3108 dentry = get_node(number);
3109 diff -NurpP --minimal linux-2.6.22.10/fs/ecryptfs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/ecryptfs/inode.c
3110 --- linux-2.6.22.10/fs/ecryptfs/inode.c 2007-10-30 01:57:14 +0100
3111 +++ linux-2.6.22.10-vs2.3.0.29/fs/ecryptfs/inode.c 2007-08-11 22:41:51 +0200
3112 @@ -423,7 +423,7 @@ static int ecryptfs_link(struct dentry *
3113 dget(lower_new_dentry);
3114 lower_dir_dentry = lock_parent(lower_new_dentry);
3115 rc = vfs_link(lower_old_dentry, lower_dir_dentry->d_inode,
3116 - lower_new_dentry);
3117 + lower_new_dentry, NULL);
3118 if (rc || !lower_new_dentry->d_inode)
3120 rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
3121 @@ -451,7 +451,7 @@ static int ecryptfs_unlink(struct inode
3122 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
3124 lock_parent(lower_dentry);
3125 - rc = vfs_unlink(lower_dir_inode, lower_dentry);
3126 + rc = vfs_unlink(lower_dir_inode, lower_dentry, NULL);
3128 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
3130 @@ -488,7 +488,7 @@ static int ecryptfs_symlink(struct inode
3133 rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry,
3134 - encoded_symname, mode);
3135 + encoded_symname, mode, NULL);
3136 kfree(encoded_symname);
3137 if (rc || !lower_dentry->d_inode)
3139 @@ -513,7 +513,7 @@ static int ecryptfs_mkdir(struct inode *
3141 lower_dentry = ecryptfs_dentry_to_lower(dentry);
3142 lower_dir_dentry = lock_parent(lower_dentry);
3143 - rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode);
3144 + rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode, NULL);
3145 if (rc || !lower_dentry->d_inode)
3147 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
3148 @@ -539,7 +539,7 @@ static int ecryptfs_rmdir(struct inode *
3150 lower_dir_dentry = lock_parent(lower_dentry);
3152 - rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry);
3153 + rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry, NULL);
3156 d_delete(lower_dentry);
3157 @@ -561,7 +561,7 @@ ecryptfs_mknod(struct inode *dir, struct
3159 lower_dentry = ecryptfs_dentry_to_lower(dentry);
3160 lower_dir_dentry = lock_parent(lower_dentry);
3161 - rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev);
3162 + rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev, NULL);
3163 if (rc || !lower_dentry->d_inode)
3165 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
3166 diff -NurpP --minimal linux-2.6.22.10/fs/exec.c linux-2.6.22.10-vs2.3.0.29/fs/exec.c
3167 --- linux-2.6.22.10/fs/exec.c 2007-10-30 01:57:14 +0100
3168 +++ linux-2.6.22.10-vs2.3.0.29/fs/exec.c 2007-10-04 23:47:06 +0200
3170 #include <linux/cn_proc.h>
3171 #include <linux/audit.h>
3172 #include <linux/signalfd.h>
3173 +#include <linux/vs_memory.h>
3175 #include <asm/uaccess.h>
3176 #include <asm/mmu_context.h>
3177 @@ -440,7 +441,8 @@ int setup_arg_pages(struct linux_binprm
3178 kmem_cache_free(vm_area_cachep, mpnt);
3181 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
3182 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
3183 + mm->stack_vm = mm->total_vm;
3186 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
3187 @@ -1336,7 +1338,7 @@ static int format_corename(char *corenam
3188 /* UNIX time of coredump */
3191 - do_gettimeofday(&tv);
3192 + vx_gettimeofday(&tv);
3193 rc = snprintf(out_ptr, out_end - out_ptr,
3195 if (rc > out_end - out_ptr)
3196 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/balloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/balloc.c
3197 --- linux-2.6.22.10/fs/ext2/balloc.c 2007-05-02 19:25:17 +0200
3198 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/balloc.c 2007-08-05 20:53:12 +0200
3200 #include <linux/sched.h>
3201 #include <linux/buffer_head.h>
3202 #include <linux/capability.h>
3203 +#include <linux/vs_dlimit.h>
3204 +#include <linux/vs_tag.h>
3207 * balloc.c contains the blocks allocation and deallocation routines
3208 @@ -102,12 +104,13 @@ static int reserve_blocks(struct super_b
3210 struct ext2_sb_info *sbi = EXT2_SB(sb);
3211 struct ext2_super_block *es = sbi->s_es;
3212 - unsigned free_blocks;
3213 - unsigned root_blocks;
3214 + unsigned long long free_blocks, root_blocks;
3216 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3217 root_blocks = le32_to_cpu(es->s_r_blocks_count);
3219 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3221 if (free_blocks < count)
3222 count = free_blocks;
3224 @@ -258,6 +261,7 @@ do_more:
3228 + DLIMIT_FREE_BLOCK(inode, freed);
3229 release_blocks(sb, freed);
3230 DQUOT_FREE_BLOCK(inode, freed);
3232 @@ -361,6 +365,10 @@ int ext2_new_block(struct inode *inode,
3236 + if (DLIMIT_ALLOC_BLOCK(inode, es_alloc)) {
3241 ext2_debug ("goal=%lu.\n", goal);
3243 @@ -508,6 +516,8 @@ got_block:
3246 group_release_blocks(sb, group_no, desc, gdp_bh, group_alloc);
3247 + DLIMIT_FREE_BLOCK(inode, es_alloc);
3249 release_blocks(sb, es_alloc);
3251 DQUOT_FREE_BLOCK(inode, dq_alloc);
3252 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/ext2.h linux-2.6.22.10-vs2.3.0.29/fs/ext2/ext2.h
3253 --- linux-2.6.22.10/fs/ext2/ext2.h 2007-07-09 13:19:23 +0200
3254 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/ext2.h 2007-08-05 20:53:12 +0200
3255 @@ -167,6 +167,7 @@ extern const struct file_operations ext2
3256 extern const struct address_space_operations ext2_aops;
3257 extern const struct address_space_operations ext2_aops_xip;
3258 extern const struct address_space_operations ext2_nobh_aops;
3259 +extern int ext2_sync_flags(struct inode *inode);
3262 extern const struct inode_operations ext2_dir_inode_operations;
3263 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/file.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/file.c
3264 --- linux-2.6.22.10/fs/ext2/file.c 2007-05-02 19:25:17 +0200
3265 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/file.c 2007-09-12 20:04:16 +0200
3266 @@ -85,4 +85,5 @@ const struct inode_operations ext2_file_
3268 .setattr = ext2_setattr,
3269 .permission = ext2_permission,
3270 + .sync_flags = ext2_sync_flags,
3272 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/ialloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/ialloc.c
3273 --- linux-2.6.22.10/fs/ext2/ialloc.c 2006-11-30 21:19:19 +0100
3274 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/ialloc.c 2007-08-05 20:53:12 +0200
3276 #include <linux/backing-dev.h>
3277 #include <linux/buffer_head.h>
3278 #include <linux/random.h>
3279 +#include <linux/vs_dlimit.h>
3280 +#include <linux/vs_tag.h>
3284 @@ -125,6 +127,7 @@ void ext2_free_inode (struct inode * ino
3285 ext2_xattr_delete_inode(inode);
3286 DQUOT_FREE_INODE(inode);
3288 + DLIMIT_FREE_INODE(inode);
3291 es = EXT2_SB(sb)->s_es;
3292 @@ -464,6 +467,11 @@ struct inode *ext2_new_inode(struct inod
3294 return ERR_PTR(-ENOMEM);
3296 + inode->i_tag = dx_current_fstag(sb);
3297 + if (DLIMIT_ALLOC_INODE(inode)) {
3304 @@ -577,7 +585,8 @@ got:
3305 inode->i_blocks = 0;
3306 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
3307 memset(ei->i_data, 0, sizeof(ei->i_data));
3308 - ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
3309 + ei->i_flags = EXT2_I(dir)->i_flags &
3310 + ~(EXT2_BTREE_FL|EXT2_IUNLINK_FL|EXT2_BARRIER_FL);
3312 ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
3313 /* dirsync is only applied to directories */
3314 @@ -625,12 +634,15 @@ fail_free_drop:
3318 + DLIMIT_FREE_INODE(inode);
3319 inode->i_flags |= S_NOQUOTA;
3322 return ERR_PTR(err);
3325 + DLIMIT_FREE_INODE(inode);
3327 make_bad_inode(inode);
3329 return ERR_PTR(err);
3330 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/inode.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/inode.c
3331 --- linux-2.6.22.10/fs/ext2/inode.c 2007-07-09 13:19:23 +0200
3332 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/inode.c 2007-08-18 02:52:34 +0200
3334 #include <linux/writeback.h>
3335 #include <linux/buffer_head.h>
3336 #include <linux/mpage.h>
3337 +#include <linux/vs_tag.h>
3341 @@ -913,7 +914,7 @@ void ext2_truncate (struct inode * inode
3343 if (ext2_inode_is_fast_symlink(inode))
3345 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3346 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3349 ext2_discard_prealloc(inode);
3350 @@ -1042,13 +1043,20 @@ void ext2_set_inode_flags(struct inode *
3352 unsigned int flags = EXT2_I(inode)->i_flags;
3354 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3355 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3356 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3358 + if (flags & EXT2_IMMUTABLE_FL)
3359 + inode->i_flags |= S_IMMUTABLE;
3360 + if (flags & EXT2_IUNLINK_FL)
3361 + inode->i_flags |= S_IUNLINK;
3362 + if (flags & EXT2_BARRIER_FL)
3363 + inode->i_flags |= S_BARRIER;
3365 if (flags & EXT2_SYNC_FL)
3366 inode->i_flags |= S_SYNC;
3367 if (flags & EXT2_APPEND_FL)
3368 inode->i_flags |= S_APPEND;
3369 - if (flags & EXT2_IMMUTABLE_FL)
3370 - inode->i_flags |= S_IMMUTABLE;
3371 if (flags & EXT2_NOATIME_FL)
3372 inode->i_flags |= S_NOATIME;
3373 if (flags & EXT2_DIRSYNC_FL)
3374 @@ -1074,12 +1082,37 @@ void ext2_get_inode_flags(struct ext2_in
3375 ei->i_flags |= EXT2_DIRSYNC_FL;
3378 +int ext2_sync_flags(struct inode *inode)
3380 + unsigned int oldflags, newflags;
3382 + oldflags = EXT2_I(inode)->i_flags;
3383 + newflags = oldflags & ~(EXT2_IMMUTABLE_FL |
3384 + EXT2_IUNLINK_FL | EXT2_BARRIER_FL);
3386 + if (IS_IMMUTABLE(inode))
3387 + newflags |= EXT2_IMMUTABLE_FL;
3388 + if (IS_IUNLINK(inode))
3389 + newflags |= EXT2_IUNLINK_FL;
3390 + if (IS_BARRIER(inode))
3391 + newflags |= EXT2_BARRIER_FL;
3393 + if (oldflags ^ newflags) {
3394 + EXT2_I(inode)->i_flags = newflags;
3395 + inode->i_ctime = CURRENT_TIME;
3396 + mark_inode_dirty(inode);
3401 void ext2_read_inode (struct inode * inode)
3403 struct ext2_inode_info *ei = EXT2_I(inode);
3404 ino_t ino = inode->i_ino;
3405 struct buffer_head * bh;
3406 struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh);
3411 #ifdef CONFIG_EXT2_FS_POSIX_ACL
3412 @@ -1090,12 +1123,17 @@ void ext2_read_inode (struct inode * ino
3415 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3416 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3417 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3418 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3419 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3420 if (!(test_opt (inode->i_sb, NO_UID32))) {
3421 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3422 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3423 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3424 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3426 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3427 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3428 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3429 + le16_to_cpu(raw_inode->i_raw_tag));
3431 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3432 inode->i_size = le32_to_cpu(raw_inode->i_size);
3433 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3434 @@ -1192,8 +1230,8 @@ static int ext2_update_inode(struct inod
3435 struct ext2_inode_info *ei = EXT2_I(inode);
3436 struct super_block *sb = inode->i_sb;
3437 ino_t ino = inode->i_ino;
3438 - uid_t uid = inode->i_uid;
3439 - gid_t gid = inode->i_gid;
3440 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3441 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3442 struct buffer_head * bh;
3443 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
3445 @@ -1229,6 +1267,9 @@ static int ext2_update_inode(struct inod
3446 raw_inode->i_uid_high = 0;
3447 raw_inode->i_gid_high = 0;
3449 +#ifdef CONFIG_TAGGING_INTERN
3450 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3452 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3453 raw_inode->i_size = cpu_to_le32(inode->i_size);
3454 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3455 @@ -1315,7 +1356,8 @@ int ext2_setattr(struct dentry *dentry,
3458 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3459 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3460 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3461 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3462 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
3465 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/ioctl.c
3466 --- linux-2.6.22.10/fs/ext2/ioctl.c 2007-07-09 13:19:23 +0200
3467 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/ioctl.c 2007-08-05 20:53:12 +0200
3469 #include <linux/sched.h>
3470 #include <linux/compat.h>
3471 #include <linux/smp_lock.h>
3472 +#include <linux/mount.h>
3473 #include <asm/current.h>
3474 #include <asm/uaccess.h>
3476 @@ -33,7 +34,8 @@ int ext2_ioctl (struct inode * inode, st
3477 case EXT2_IOC_SETFLAGS: {
3478 unsigned int oldflags;
3480 - if (IS_RDONLY(inode))
3481 + if (IS_RDONLY(inode) ||
3482 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3485 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3486 @@ -54,7 +56,9 @@ int ext2_ioctl (struct inode * inode, st
3488 * This test looks nicer. Thanks to Pauline Middelink
3490 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
3491 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3492 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3493 + EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL))) {
3494 if (!capable(CAP_LINUX_IMMUTABLE)) {
3495 mutex_unlock(&inode->i_mutex);
3497 @@ -76,7 +80,8 @@ int ext2_ioctl (struct inode * inode, st
3498 case EXT2_IOC_SETVERSION:
3499 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3501 - if (IS_RDONLY(inode))
3502 + if (IS_RDONLY(inode) ||
3503 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3505 if (get_user(inode->i_generation, (int __user *) arg))
3507 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/namei.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/namei.c
3508 --- linux-2.6.22.10/fs/ext2/namei.c 2007-05-02 19:25:17 +0200
3509 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/namei.c 2007-08-05 20:53:12 +0200
3513 #include <linux/pagemap.h>
3514 +#include <linux/vs_tag.h>
3518 @@ -66,6 +67,7 @@ static struct dentry *ext2_lookup(struct
3519 inode = iget(dir->i_sb, ino);
3521 return ERR_PTR(-EACCES);
3522 + dx_propagate_tag(nd, inode);
3524 return d_splice_alias(inode, dentry);
3526 @@ -391,6 +393,7 @@ const struct inode_operations ext2_dir_i
3528 .setattr = ext2_setattr,
3529 .permission = ext2_permission,
3530 + .sync_flags = ext2_sync_flags,
3533 const struct inode_operations ext2_special_inode_operations = {
3534 @@ -402,4 +405,5 @@ const struct inode_operations ext2_speci
3536 .setattr = ext2_setattr,
3537 .permission = ext2_permission,
3538 + .sync_flags = ext2_sync_flags,
3540 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/super.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/super.c
3541 --- linux-2.6.22.10/fs/ext2/super.c 2007-07-09 13:19:23 +0200
3542 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/super.c 2007-08-05 20:53:12 +0200
3543 @@ -321,7 +321,7 @@ enum {
3544 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3545 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3546 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3547 - Opt_usrquota, Opt_grpquota
3548 + Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3551 static match_table_t tokens = {
3552 @@ -349,6 +349,9 @@ static match_table_t tokens = {
3554 {Opt_noacl, "noacl"},
3557 + {Opt_notag, "notag"},
3558 + {Opt_tagid, "tagid=%u"},
3559 {Opt_grpquota, "grpquota"},
3560 {Opt_ignore, "noquota"},
3561 {Opt_quota, "quota"},
3562 @@ -417,6 +420,20 @@ static int parse_options (char * options
3564 set_opt (sbi->s_mount_opt, NO_UID32);
3566 +#ifndef CONFIG_TAGGING_NONE
3568 + set_opt (sbi->s_mount_opt, TAGGED);
3571 + clear_opt (sbi->s_mount_opt, TAGGED);
3574 +#ifdef CONFIG_PROPAGATE
3577 + set_opt (sbi->s_mount_opt, TAGGED);
3581 clear_opt (sbi->s_mount_opt, CHECK);
3583 @@ -727,6 +744,8 @@ static int ext2_fill_super(struct super_
3584 if (!parse_options ((char *) data, sbi))
3587 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3588 + sb->s_flags |= MS_TAGGED;
3589 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3590 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3592 @@ -1035,6 +1054,13 @@ static int ext2_remount (struct super_bl
3596 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3597 + !(sb->s_flags & MS_TAGGED)) {
3598 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3603 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3604 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3606 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/symlink.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/symlink.c
3607 --- linux-2.6.22.10/fs/ext2/symlink.c 2007-05-02 19:25:17 +0200
3608 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/symlink.c 2007-08-05 20:53:12 +0200
3609 @@ -38,6 +38,7 @@ const struct inode_operations ext2_symli
3610 .listxattr = ext2_listxattr,
3611 .removexattr = generic_removexattr,
3613 + .sync_flags = ext2_sync_flags,
3616 const struct inode_operations ext2_fast_symlink_inode_operations = {
3617 @@ -49,4 +50,5 @@ const struct inode_operations ext2_fast_
3618 .listxattr = ext2_listxattr,
3619 .removexattr = generic_removexattr,
3621 + .sync_flags = ext2_sync_flags,
3623 diff -NurpP --minimal linux-2.6.22.10/fs/ext2/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/ext2/xattr.c
3624 --- linux-2.6.22.10/fs/ext2/xattr.c 2007-02-06 03:01:18 +0100
3625 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/xattr.c 2007-08-05 20:53:12 +0200
3627 #include <linux/mbcache.h>
3628 #include <linux/quotaops.h>
3629 #include <linux/rwsem.h>
3630 +#include <linux/vs_dlimit.h>
3634 @@ -641,8 +642,12 @@ ext2_xattr_set2(struct inode *inode, str
3636 ea_bdebug(new_bh, "reusing block");
3639 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3642 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
3643 + DLIMIT_FREE_BLOCK(inode, 1);
3644 unlock_buffer(new_bh);
3647 @@ -736,6 +741,7 @@ ext2_xattr_set2(struct inode *inode, str
3648 le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
3650 mb_cache_entry_release(ce);
3651 + DLIMIT_FREE_BLOCK(inode, 1);
3652 DQUOT_FREE_BLOCK(inode, 1);
3653 mark_buffer_dirty(old_bh);
3654 ea_bdebug(old_bh, "refcount now=%d",
3655 @@ -800,6 +806,7 @@ ext2_xattr_delete_inode(struct inode *in
3656 mark_buffer_dirty(bh);
3658 sync_dirty_buffer(bh);
3659 + DLIMIT_FREE_BLOCK(inode, 1);
3660 DQUOT_FREE_BLOCK(inode, 1);
3662 EXT2_I(inode)->i_file_acl = 0;
3663 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/balloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/balloc.c
3664 --- linux-2.6.22.10/fs/ext3/balloc.c 2007-05-02 19:25:17 +0200
3665 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/balloc.c 2007-08-05 20:53:12 +0200
3667 #include <linux/ext3_jbd.h>
3668 #include <linux/quotaops.h>
3669 #include <linux/buffer_head.h>
3670 +#include <linux/vs_dlimit.h>
3671 +#include <linux/vs_tag.h>
3674 * balloc.c contains the blocks allocation and deallocation routines
3675 @@ -613,8 +615,10 @@ void ext3_free_blocks(handle_t *handle,
3678 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
3679 - if (dquot_freed_blocks)
3680 + if (dquot_freed_blocks) {
3681 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3682 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3687 @@ -1353,18 +1357,33 @@ out:
3689 * Check if filesystem has at least 1 free block available for allocation.
3691 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
3692 +static int ext3_has_free_blocks(struct super_block *sb)
3694 - ext3_fsblk_t free_blocks, root_blocks;
3695 + struct ext3_sb_info *sbi = EXT3_SB(sb);
3696 + unsigned long long free_blocks, root_blocks;
3699 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3700 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
3701 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
3703 + vxdprintk(VXD_CBIT(dlim, 3),
3704 + "ext3_has_free_blocks(%p): free=%llu, root=%llu",
3705 + sb, free_blocks, root_blocks);
3707 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3709 + cond = (free_blocks < root_blocks + 1 &&
3710 + !capable(CAP_SYS_RESOURCE) &&
3711 sbi->s_resuid != current->fsuid &&
3712 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
3716 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
3718 + vxdprintk(VXD_CBIT(dlim, 3),
3719 + "ext3_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
3720 + sb, free_blocks, root_blocks,
3721 + !capable(CAP_SYS_RESOURCE)?'1':'0',
3722 + sbi->s_resuid, current->fsuid, cond?0:1);
3724 + return (cond ? 0 : 1);
3728 @@ -1381,7 +1400,7 @@ static int ext3_has_free_blocks(struct e
3730 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
3732 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
3733 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
3736 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
3737 @@ -1444,6 +1463,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3741 + if (DLIMIT_ALLOC_BLOCK(inode, num))
3745 es = EXT3_SB(sb)->s_es;
3746 @@ -1460,7 +1481,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3747 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
3748 my_rsv = &block_i->rsv_window_node;
3750 - if (!ext3_has_free_blocks(sbi)) {
3751 + if (!ext3_has_free_blocks(sb)) {
3755 @@ -1647,12 +1668,16 @@ allocated:
3758 DQUOT_FREE_BLOCK(inode, *count-num);
3759 + DLIMIT_FREE_BLOCK(inode, *count-num);
3766 + if (!performed_allocation)
3767 + DLIMIT_FREE_BLOCK(inode, *count);
3771 ext3_std_error(sb, fatal);
3772 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/file.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/file.c
3773 --- linux-2.6.22.10/fs/ext3/file.c 2007-05-02 19:25:17 +0200
3774 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/file.c 2007-09-12 20:04:16 +0200
3775 @@ -135,5 +135,6 @@ const struct inode_operations ext3_file_
3776 .removexattr = generic_removexattr,
3778 .permission = ext3_permission,
3779 + .sync_flags = ext3_sync_flags,
3782 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/ialloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/ialloc.c
3783 --- linux-2.6.22.10/fs/ext3/ialloc.c 2006-11-30 21:19:19 +0100
3784 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/ialloc.c 2007-08-05 20:53:12 +0200
3786 #include <linux/buffer_head.h>
3787 #include <linux/random.h>
3788 #include <linux/bitops.h>
3789 +#include <linux/vs_dlimit.h>
3790 +#include <linux/vs_tag.h>
3792 #include <asm/byteorder.h>
3794 @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle,
3795 ext3_xattr_delete_inode(handle, inode);
3796 DQUOT_FREE_INODE(inode);
3798 + DLIMIT_FREE_INODE(inode);
3800 is_directory = S_ISDIR(inode->i_mode);
3802 @@ -445,6 +448,12 @@ struct inode *ext3_new_inode(handle_t *h
3803 inode = new_inode(sb);
3805 return ERR_PTR(-ENOMEM);
3807 + inode->i_tag = dx_current_fstag(sb);
3808 + if (DLIMIT_ALLOC_INODE(inode)) {
3815 @@ -566,7 +575,8 @@ got:
3816 ei->i_dir_start_lookup = 0;
3819 - ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
3820 + ei->i_flags = EXT3_I(dir)->i_flags &
3821 + ~(EXT3_INDEX_FL|EXT3_IUNLINK_FL|EXT3_BARRIER_FL);
3823 ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
3824 /* dirsync only applies to directories */
3825 @@ -621,6 +631,8 @@ got:
3827 ext3_std_error(sb, err);
3829 + DLIMIT_FREE_INODE(inode);
3834 @@ -632,6 +644,7 @@ fail_free_drop:
3838 + DLIMIT_FREE_INODE(inode);
3839 inode->i_flags |= S_NOQUOTA;
3842 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/inode.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/inode.c
3843 --- linux-2.6.22.10/fs/ext3/inode.c 2007-07-09 13:19:23 +0200
3844 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/inode.c 2007-08-18 02:52:34 +0200
3846 #include <linux/mpage.h>
3847 #include <linux/uio.h>
3848 #include <linux/bio.h>
3849 +#include <linux/vs_tag.h>
3853 @@ -2237,7 +2238,7 @@ void ext3_truncate(struct inode *inode)
3855 if (ext3_inode_is_fast_symlink(inode))
3857 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3858 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3862 @@ -2559,13 +2560,20 @@ void ext3_set_inode_flags(struct inode *
3864 unsigned int flags = EXT3_I(inode)->i_flags;
3866 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3867 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3868 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3870 + if (flags & EXT3_IMMUTABLE_FL)
3871 + inode->i_flags |= S_IMMUTABLE;
3872 + if (flags & EXT3_IUNLINK_FL)
3873 + inode->i_flags |= S_IUNLINK;
3874 + if (flags & EXT3_BARRIER_FL)
3875 + inode->i_flags |= S_BARRIER;
3877 if (flags & EXT3_SYNC_FL)
3878 inode->i_flags |= S_SYNC;
3879 if (flags & EXT3_APPEND_FL)
3880 inode->i_flags |= S_APPEND;
3881 - if (flags & EXT3_IMMUTABLE_FL)
3882 - inode->i_flags |= S_IMMUTABLE;
3883 if (flags & EXT3_NOATIME_FL)
3884 inode->i_flags |= S_NOATIME;
3885 if (flags & EXT3_DIRSYNC_FL)
3886 @@ -2591,6 +2599,45 @@ void ext3_get_inode_flags(struct ext3_in
3887 ei->i_flags |= EXT3_DIRSYNC_FL;
3890 +int ext3_sync_flags(struct inode *inode)
3892 + unsigned int oldflags, newflags;
3895 + oldflags = EXT3_I(inode)->i_flags;
3896 + newflags = oldflags & ~(EXT3_IMMUTABLE_FL |
3897 + EXT3_IUNLINK_FL | EXT3_BARRIER_FL);
3899 + if (IS_IMMUTABLE(inode))
3900 + newflags |= EXT3_IMMUTABLE_FL;
3901 + if (IS_IUNLINK(inode))
3902 + newflags |= EXT3_IUNLINK_FL;
3903 + if (IS_BARRIER(inode))
3904 + newflags |= EXT3_BARRIER_FL;
3906 + if (oldflags ^ newflags) {
3908 + struct ext3_iloc iloc;
3910 + handle = ext3_journal_start(inode, 1);
3911 + if (IS_ERR(handle))
3912 + return PTR_ERR(handle);
3913 + if (IS_SYNC(inode))
3914 + handle->h_sync = 1;
3915 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3919 + EXT3_I(inode)->i_flags = newflags;
3920 + inode->i_ctime = CURRENT_TIME;
3922 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3924 + ext3_journal_stop(handle);
3929 void ext3_read_inode(struct inode * inode)
3931 struct ext3_iloc iloc;
3932 @@ -2598,6 +2645,8 @@ void ext3_read_inode(struct inode * inod
3933 struct ext3_inode_info *ei = EXT3_I(inode);
3934 struct buffer_head *bh;
3939 #ifdef CONFIG_EXT3_FS_POSIX_ACL
3940 ei->i_acl = EXT3_ACL_NOT_CACHED;
3941 @@ -2610,12 +2659,17 @@ void ext3_read_inode(struct inode * inod
3943 raw_inode = ext3_raw_inode(&iloc);
3944 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3945 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3946 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3947 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3948 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3949 if(!(test_opt (inode->i_sb, NO_UID32))) {
3950 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3951 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3952 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3953 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3955 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3956 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3957 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3958 + le16_to_cpu(raw_inode->i_raw_tag));
3960 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3961 inode->i_size = le32_to_cpu(raw_inode->i_size);
3962 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3963 @@ -2741,6 +2795,8 @@ static int ext3_do_update_inode(handle_t
3964 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3965 struct ext3_inode_info *ei = EXT3_I(inode);
3966 struct buffer_head *bh = iloc->bh;
3967 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3968 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3969 int err = 0, rc, block;
3971 /* For fields not not tracking in the in-memory inode,
3972 @@ -2751,29 +2807,32 @@ static int ext3_do_update_inode(handle_t
3973 ext3_get_inode_flags(ei);
3974 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3975 if(!(test_opt(inode->i_sb, NO_UID32))) {
3976 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3977 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3978 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3979 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3981 * Fix up interoperability with old kernels. Otherwise, old inodes get
3982 * re-used with the upper 16 bits of the uid/gid intact
3985 raw_inode->i_uid_high =
3986 - cpu_to_le16(high_16_bits(inode->i_uid));
3987 + cpu_to_le16(high_16_bits(uid));
3988 raw_inode->i_gid_high =
3989 - cpu_to_le16(high_16_bits(inode->i_gid));
3990 + cpu_to_le16(high_16_bits(gid));
3992 raw_inode->i_uid_high = 0;
3993 raw_inode->i_gid_high = 0;
3996 raw_inode->i_uid_low =
3997 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3998 + cpu_to_le16(fs_high2lowuid(uid));
3999 raw_inode->i_gid_low =
4000 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4001 + cpu_to_le16(fs_high2lowgid(gid));
4002 raw_inode->i_uid_high = 0;
4003 raw_inode->i_gid_high = 0;
4005 +#ifdef CONFIG_TAGGING_INTERN
4006 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4008 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4009 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4010 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4011 @@ -2926,7 +2985,8 @@ int ext3_setattr(struct dentry *dentry,
4014 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4015 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4016 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4017 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4020 /* (user+group)*(old+new) structure, inode write (sb,
4021 @@ -2948,6 +3008,8 @@ int ext3_setattr(struct dentry *dentry,
4022 inode->i_uid = attr->ia_uid;
4023 if (attr->ia_valid & ATTR_GID)
4024 inode->i_gid = attr->ia_gid;
4025 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4026 + inode->i_tag = attr->ia_tag;
4027 error = ext3_mark_inode_dirty(handle, inode);
4028 ext3_journal_stop(handle);
4030 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/ioctl.c
4031 --- linux-2.6.22.10/fs/ext3/ioctl.c 2007-07-09 13:19:23 +0200
4032 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/ioctl.c 2007-08-05 20:53:12 +0200
4036 #include <linux/fs.h>
4037 +#include <linux/mount.h>
4038 #include <linux/jbd.h>
4039 #include <linux/capability.h>
4040 #include <linux/ext3_fs.h>
4042 #include <linux/time.h>
4043 #include <linux/compat.h>
4044 #include <linux/smp_lock.h>
4045 +#include <linux/vs_tag.h>
4046 #include <asm/uaccess.h>
4048 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
4049 @@ -38,7 +40,8 @@ int ext3_ioctl (struct inode * inode, st
4050 unsigned int oldflags;
4053 - if (IS_RDONLY(inode))
4054 + if (IS_RDONLY(inode) ||
4055 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4058 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4059 @@ -62,7 +65,9 @@ int ext3_ioctl (struct inode * inode, st
4061 * This test looks nicer. Thanks to Pauline Middelink
4063 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
4064 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
4065 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
4066 + EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL))) {
4067 if (!capable(CAP_LINUX_IMMUTABLE)) {
4068 mutex_unlock(&inode->i_mutex);
4070 @@ -124,7 +129,8 @@ flags_err:
4072 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4074 - if (IS_RDONLY(inode))
4075 + if (IS_RDONLY(inode) ||
4076 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4078 if (get_user(generation, (int __user *) arg))
4080 @@ -178,7 +184,8 @@ flags_err:
4081 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
4084 - if (IS_RDONLY(inode))
4085 + if (IS_RDONLY(inode) ||
4086 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4089 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4090 @@ -213,7 +220,8 @@ flags_err:
4091 if (!capable(CAP_SYS_RESOURCE))
4094 - if (IS_RDONLY(inode))
4095 + if (IS_RDONLY(inode) ||
4096 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4099 if (get_user(n_blocks_count, (__u32 __user *)arg))
4100 @@ -234,7 +242,8 @@ flags_err:
4101 if (!capable(CAP_SYS_RESOURCE))
4104 - if (IS_RDONLY(inode))
4105 + if (IS_RDONLY(inode) ||
4106 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4109 if (copy_from_user(&input, (struct ext3_new_group_input __user *)arg,
4110 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/namei.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/namei.c
4111 --- linux-2.6.22.10/fs/ext3/namei.c 2007-10-30 01:57:14 +0100
4112 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/namei.c 2007-09-30 14:58:01 +0200
4114 #include <linux/quotaops.h>
4115 #include <linux/buffer_head.h>
4116 #include <linux/bio.h>
4117 +#include <linux/vs_tag.h>
4121 @@ -1052,6 +1053,7 @@ static struct dentry *ext3_lookup(struct
4124 return ERR_PTR(-EACCES);
4125 + dx_propagate_tag(nd, inode);
4127 return d_splice_alias(inode, dentry);
4129 @@ -2443,6 +2445,7 @@ const struct inode_operations ext3_dir_i
4130 .removexattr = generic_removexattr,
4132 .permission = ext3_permission,
4133 + .sync_flags = ext3_sync_flags,
4136 const struct inode_operations ext3_special_inode_operations = {
4137 @@ -2454,4 +2457,5 @@ const struct inode_operations ext3_speci
4138 .removexattr = generic_removexattr,
4140 .permission = ext3_permission,
4141 + .sync_flags = ext3_sync_flags,
4143 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/super.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/super.c
4144 --- linux-2.6.22.10/fs/ext3/super.c 2007-07-09 13:19:23 +0200
4145 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/super.c 2007-08-05 20:53:12 +0200
4146 @@ -674,7 +674,7 @@ enum {
4147 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4148 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4149 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4151 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
4154 static match_table_t tokens = {
4155 @@ -724,6 +724,9 @@ static match_table_t tokens = {
4156 {Opt_quota, "quota"},
4157 {Opt_usrquota, "usrquota"},
4158 {Opt_barrier, "barrier=%u"},
4160 + {Opt_notag, "notag"},
4161 + {Opt_tagid, "tagid=%u"},
4163 {Opt_resize, "resize"},
4165 @@ -817,6 +820,20 @@ static int parse_options (char *options,
4167 set_opt (sbi->s_mount_opt, NO_UID32);
4169 +#ifndef CONFIG_TAGGING_NONE
4171 + set_opt (sbi->s_mount_opt, TAGGED);
4174 + clear_opt (sbi->s_mount_opt, TAGGED);
4177 +#ifdef CONFIG_PROPAGATE
4180 + set_opt (sbi->s_mount_opt, TAGGED);
4184 clear_opt (sbi->s_mount_opt, CHECK);
4186 @@ -1487,6 +1504,9 @@ static int ext3_fill_super (struct super
4190 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
4191 + sb->s_flags |= MS_TAGGED;
4193 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4194 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4196 @@ -2302,6 +2322,12 @@ static int ext3_remount (struct super_bl
4198 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
4199 ext3_abort(sb, __FUNCTION__, "Abort forced by user");
4200 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
4201 + !(sb->s_flags & MS_TAGGED)) {
4202 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
4207 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4208 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4209 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/symlink.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/symlink.c
4210 --- linux-2.6.22.10/fs/ext3/symlink.c 2007-05-02 19:25:17 +0200
4211 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/symlink.c 2007-08-05 20:53:12 +0200
4212 @@ -40,6 +40,7 @@ const struct inode_operations ext3_symli
4213 .listxattr = ext3_listxattr,
4214 .removexattr = generic_removexattr,
4216 + .sync_flags = ext3_sync_flags,
4219 const struct inode_operations ext3_fast_symlink_inode_operations = {
4220 @@ -51,4 +52,5 @@ const struct inode_operations ext3_fast_
4221 .listxattr = ext3_listxattr,
4222 .removexattr = generic_removexattr,
4224 + .sync_flags = ext3_sync_flags,
4226 diff -NurpP --minimal linux-2.6.22.10/fs/ext3/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/ext3/xattr.c
4227 --- linux-2.6.22.10/fs/ext3/xattr.c 2007-05-02 19:25:17 +0200
4228 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/xattr.c 2007-08-05 20:53:12 +0200
4230 #include <linux/mbcache.h>
4231 #include <linux/quotaops.h>
4232 #include <linux/rwsem.h>
4233 +#include <linux/vs_dlimit.h>
4237 @@ -497,6 +498,7 @@ ext3_xattr_release_block(handle_t *handl
4238 error = ext3_journal_dirty_metadata(handle, bh);
4241 + DLIMIT_FREE_BLOCK(inode, 1);
4242 DQUOT_FREE_BLOCK(inode, 1);
4243 ea_bdebug(bh, "refcount now=%d; releasing",
4244 le32_to_cpu(BHDR(bh)->h_refcount));
4245 @@ -771,11 +773,14 @@ inserted:
4246 if (new_bh == bs->bh)
4247 ea_bdebug(new_bh, "keeping");
4250 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4252 /* The old block is released after updating
4255 if (DQUOT_ALLOC_BLOCK(inode, 1))
4257 + goto cleanup_dlimit;
4258 error = ext3_journal_get_write_access(handle,
4261 @@ -852,6 +857,8 @@ cleanup:
4264 DQUOT_FREE_BLOCK(inode, 1);
4266 + DLIMIT_FREE_BLOCK(inode, 1);
4270 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/balloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/balloc.c
4271 --- linux-2.6.22.10/fs/ext4/balloc.c 2007-07-09 13:19:23 +0200
4272 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/balloc.c 2007-08-05 20:53:12 +0200
4274 #include <linux/ext4_jbd2.h>
4275 #include <linux/quotaops.h>
4276 #include <linux/buffer_head.h>
4277 +#include <linux/vs_dlimit.h>
4278 +#include <linux/vs_tag.h>
4281 * balloc.c contains the blocks allocation and deallocation routines
4282 @@ -630,8 +632,10 @@ void ext4_free_blocks(handle_t *handle,
4285 ext4_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
4286 - if (dquot_freed_blocks)
4287 + if (dquot_freed_blocks) {
4288 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
4289 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
4294 @@ -1370,18 +1374,33 @@ out:
4296 * Check if filesystem has at least 1 free block available for allocation.
4298 -static int ext4_has_free_blocks(struct ext4_sb_info *sbi)
4299 +static int ext4_has_free_blocks(struct super_block *sb)
4301 + struct ext4_sb_info *sbi = EXT4_SB(sb);
4302 ext4_fsblk_t free_blocks, root_blocks;
4305 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
4306 root_blocks = ext4_r_blocks_count(sbi->s_es);
4307 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
4309 + vxdprintk(VXD_CBIT(dlim, 3),
4310 + "ext4_has_free_blocks(%p): free=%llu, root=%llu",
4311 + sb, free_blocks, root_blocks);
4313 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
4315 + cond = (free_blocks < root_blocks + 1 &&
4316 + !capable(CAP_SYS_RESOURCE) &&
4317 sbi->s_resuid != current->fsuid &&
4318 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
4322 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
4324 + vxdprintk(VXD_CBIT(dlim, 3),
4325 + "ext4_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
4326 + sb, free_blocks, root_blocks,
4327 + !capable(CAP_SYS_RESOURCE)?'1':'0',
4328 + sbi->s_resuid, current->fsuid, cond?0:1);
4330 + return (cond ? 0 : 1);
4334 @@ -1398,7 +1417,7 @@ static int ext4_has_free_blocks(struct e
4336 int ext4_should_retry_alloc(struct super_block *sb, int *retries)
4338 - if (!ext4_has_free_blocks(EXT4_SB(sb)) || (*retries)++ > 3)
4339 + if (!ext4_has_free_blocks(sb) || (*retries)++ > 3)
4342 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
4343 @@ -1461,6 +1480,8 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
4347 + if (DLIMIT_ALLOC_BLOCK(inode, num))
4351 es = EXT4_SB(sb)->s_es;
4352 @@ -1477,7 +1498,7 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
4353 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
4354 my_rsv = &block_i->rsv_window_node;
4356 - if (!ext4_has_free_blocks(sbi)) {
4357 + if (!ext4_has_free_blocks(sb)) {
4361 @@ -1661,12 +1682,16 @@ allocated:
4364 DQUOT_FREE_BLOCK(inode, *count-num);
4365 + DLIMIT_FREE_BLOCK(inode, *count-num);
4372 + if (!performed_allocation)
4373 + DLIMIT_FREE_BLOCK(inode, *count);
4377 ext4_std_error(sb, fatal);
4378 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/file.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/file.c
4379 --- linux-2.6.22.10/fs/ext4/file.c 2007-05-02 19:25:17 +0200
4380 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/file.c 2007-09-12 20:04:16 +0200
4381 @@ -135,5 +135,6 @@ const struct inode_operations ext4_file_
4382 .removexattr = generic_removexattr,
4384 .permission = ext4_permission,
4385 + .sync_flags = ext4_sync_flags,
4388 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/ialloc.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/ialloc.c
4389 --- linux-2.6.22.10/fs/ext4/ialloc.c 2006-11-30 21:19:20 +0100
4390 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/ialloc.c 2007-08-05 20:53:12 +0200
4392 #include <linux/random.h>
4393 #include <linux/bitops.h>
4394 #include <linux/blkdev.h>
4395 +#include <linux/vs_dlimit.h>
4396 +#include <linux/vs_tag.h>
4397 #include <asm/byteorder.h>
4400 @@ -127,6 +129,7 @@ void ext4_free_inode (handle_t *handle,
4401 ext4_xattr_delete_inode(handle, inode);
4402 DQUOT_FREE_INODE(inode);
4404 + DLIMIT_FREE_INODE(inode);
4406 is_directory = S_ISDIR(inode->i_mode);
4408 @@ -448,6 +451,12 @@ struct inode *ext4_new_inode(handle_t *h
4409 inode = new_inode(sb);
4411 return ERR_PTR(-ENOMEM);
4413 + inode->i_tag = dx_current_fstag(sb);
4414 + if (DLIMIT_ALLOC_INODE(inode)) {
4421 @@ -569,7 +578,8 @@ got:
4422 ei->i_dir_start_lookup = 0;
4425 - ei->i_flags = EXT4_I(dir)->i_flags & ~EXT4_INDEX_FL;
4426 + ei->i_flags = EXT4_I(dir)->i_flags &
4427 + ~(EXT4_INDEX_FL|EXT4_IUNLINK_FL|EXT4_BARRIER_FL);
4429 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
4430 /* dirsync only applies to directories */
4431 @@ -635,6 +645,8 @@ got:
4433 ext4_std_error(sb, err);
4435 + DLIMIT_FREE_INODE(inode);
4440 @@ -646,6 +658,7 @@ fail_free_drop:
4444 + DLIMIT_FREE_INODE(inode);
4445 inode->i_flags |= S_NOQUOTA;
4448 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/inode.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/inode.c
4449 --- linux-2.6.22.10/fs/ext4/inode.c 2007-07-09 13:19:23 +0200
4450 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/inode.c 2007-08-18 02:52:34 +0200
4452 #include <linux/mpage.h>
4453 #include <linux/uio.h>
4454 #include <linux/bio.h>
4455 +#include <linux/vs_tag.h>
4459 @@ -2244,7 +2245,7 @@ void ext4_truncate(struct inode *inode)
4461 if (ext4_inode_is_fast_symlink(inode))
4463 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4464 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4468 @@ -2570,19 +2571,65 @@ void ext4_set_inode_flags(struct inode *
4470 unsigned int flags = EXT4_I(inode)->i_flags;
4472 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4473 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
4474 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4476 + if (flags & EXT4_IMMUTABLE_FL)
4477 + inode->i_flags |= S_IMMUTABLE;
4478 + if (flags & EXT4_IUNLINK_FL)
4479 + inode->i_flags |= S_IUNLINK;
4480 + if (flags & EXT4_BARRIER_FL)
4481 + inode->i_flags |= S_BARRIER;
4483 if (flags & EXT4_SYNC_FL)
4484 inode->i_flags |= S_SYNC;
4485 if (flags & EXT4_APPEND_FL)
4486 inode->i_flags |= S_APPEND;
4487 - if (flags & EXT4_IMMUTABLE_FL)
4488 - inode->i_flags |= S_IMMUTABLE;
4489 if (flags & EXT4_NOATIME_FL)
4490 inode->i_flags |= S_NOATIME;
4491 if (flags & EXT4_DIRSYNC_FL)
4492 inode->i_flags |= S_DIRSYNC;
4495 +int ext4_sync_flags(struct inode *inode)
4497 + unsigned int oldflags, newflags;
4500 + oldflags = EXT4_I(inode)->i_flags;
4501 + newflags = oldflags & ~(EXT4_IMMUTABLE_FL |
4502 + EXT4_IUNLINK_FL | EXT4_BARRIER_FL);
4504 + if (IS_IMMUTABLE(inode))
4505 + newflags |= EXT4_IMMUTABLE_FL;
4506 + if (IS_IUNLINK(inode))
4507 + newflags |= EXT4_IUNLINK_FL;
4508 + if (IS_BARRIER(inode))
4509 + newflags |= EXT4_BARRIER_FL;
4511 + if (oldflags ^ newflags) {
4513 + struct ext4_iloc iloc;
4515 + handle = ext4_journal_start(inode, 1);
4516 + if (IS_ERR(handle))
4517 + return PTR_ERR(handle);
4518 + if (IS_SYNC(inode))
4519 + handle->h_sync = 1;
4520 + err = ext4_reserve_inode_write(handle, inode, &iloc);
4524 + EXT4_I(inode)->i_flags = newflags;
4525 + inode->i_ctime = CURRENT_TIME;
4527 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
4529 + ext4_journal_stop(handle);
4534 void ext4_read_inode(struct inode * inode)
4536 struct ext4_iloc iloc;
4537 @@ -2590,6 +2637,8 @@ void ext4_read_inode(struct inode * inod
4538 struct ext4_inode_info *ei = EXT4_I(inode);
4539 struct buffer_head *bh;
4544 #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
4545 ei->i_acl = EXT4_ACL_NOT_CACHED;
4546 @@ -2602,12 +2651,17 @@ void ext4_read_inode(struct inode * inod
4548 raw_inode = ext4_raw_inode(&iloc);
4549 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4550 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4551 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4552 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4553 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4554 if(!(test_opt (inode->i_sb, NO_UID32))) {
4555 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4556 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4557 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4558 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4560 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4561 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4562 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4563 + le16_to_cpu(raw_inode->i_raw_tag));
4565 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4566 inode->i_size = le32_to_cpu(raw_inode->i_size);
4567 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4568 @@ -2737,6 +2791,8 @@ static int ext4_do_update_inode(handle_t
4569 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
4570 struct ext4_inode_info *ei = EXT4_I(inode);
4571 struct buffer_head *bh = iloc->bh;
4572 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4573 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4574 int err = 0, rc, block;
4576 /* For fields not not tracking in the in-memory inode,
4577 @@ -2746,29 +2802,32 @@ static int ext4_do_update_inode(handle_t
4579 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4580 if(!(test_opt(inode->i_sb, NO_UID32))) {
4581 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4582 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4583 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4584 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4586 * Fix up interoperability with old kernels. Otherwise, old inodes get
4587 * re-used with the upper 16 bits of the uid/gid intact
4590 raw_inode->i_uid_high =
4591 - cpu_to_le16(high_16_bits(inode->i_uid));
4592 + cpu_to_le16(high_16_bits(uid));
4593 raw_inode->i_gid_high =
4594 - cpu_to_le16(high_16_bits(inode->i_gid));
4595 + cpu_to_le16(high_16_bits(gid));
4597 raw_inode->i_uid_high = 0;
4598 raw_inode->i_gid_high = 0;
4601 raw_inode->i_uid_low =
4602 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4603 + cpu_to_le16(fs_high2lowuid(uid));
4604 raw_inode->i_gid_low =
4605 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4606 + cpu_to_le16(fs_high2lowgid(gid));
4607 raw_inode->i_uid_high = 0;
4608 raw_inode->i_gid_high = 0;
4610 +#ifdef CONFIG_TAGGING_INTERN
4611 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4613 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4614 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4615 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4616 @@ -2925,7 +2984,8 @@ int ext4_setattr(struct dentry *dentry,
4619 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4620 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4621 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4622 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4625 /* (user+group)*(old+new) structure, inode write (sb,
4626 @@ -2947,6 +3007,8 @@ int ext4_setattr(struct dentry *dentry,
4627 inode->i_uid = attr->ia_uid;
4628 if (attr->ia_valid & ATTR_GID)
4629 inode->i_gid = attr->ia_gid;
4630 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4631 + inode->i_tag = attr->ia_tag;
4632 error = ext4_mark_inode_dirty(handle, inode);
4633 ext4_journal_stop(handle);
4635 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/ioctl.c
4636 --- linux-2.6.22.10/fs/ext4/ioctl.c 2007-02-06 03:01:18 +0100
4637 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/ioctl.c 2007-08-05 20:53:12 +0200
4641 #include <linux/fs.h>
4642 +#include <linux/mount.h>
4643 #include <linux/jbd2.h>
4644 #include <linux/capability.h>
4645 #include <linux/ext4_fs.h>
4647 #include <linux/time.h>
4648 #include <linux/compat.h>
4649 #include <linux/smp_lock.h>
4650 +#include <linux/vs_tag.h>
4651 #include <asm/uaccess.h>
4653 int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
4654 @@ -37,7 +39,8 @@ int ext4_ioctl (struct inode * inode, st
4655 unsigned int oldflags;
4658 - if (IS_RDONLY(inode))
4659 + if (IS_RDONLY(inode) ||
4660 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4663 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4664 @@ -61,7 +64,9 @@ int ext4_ioctl (struct inode * inode, st
4666 * This test looks nicer. Thanks to Pauline Middelink
4668 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
4669 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
4670 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
4671 + EXT4_IMMUTABLE_FL | EXT4_IUNLINK_FL))) {
4672 if (!capable(CAP_LINUX_IMMUTABLE)) {
4673 mutex_unlock(&inode->i_mutex);
4675 @@ -123,7 +128,8 @@ flags_err:
4677 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4679 - if (IS_RDONLY(inode))
4680 + if (IS_RDONLY(inode) ||
4681 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4683 if (get_user(generation, (int __user *) arg))
4685 @@ -177,7 +183,8 @@ flags_err:
4686 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
4689 - if (IS_RDONLY(inode))
4690 + if (IS_RDONLY(inode) ||
4691 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4694 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4695 @@ -212,7 +219,8 @@ flags_err:
4696 if (!capable(CAP_SYS_RESOURCE))
4699 - if (IS_RDONLY(inode))
4700 + if (IS_RDONLY(inode) ||
4701 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4704 if (get_user(n_blocks_count, (__u32 __user *)arg))
4705 @@ -233,7 +241,8 @@ flags_err:
4706 if (!capable(CAP_SYS_RESOURCE))
4709 - if (IS_RDONLY(inode))
4710 + if (IS_RDONLY(inode) ||
4711 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4714 if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg,
4715 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/namei.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/namei.c
4716 --- linux-2.6.22.10/fs/ext4/namei.c 2007-10-30 01:57:14 +0100
4717 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/namei.c 2007-09-30 14:58:01 +0200
4719 #include <linux/quotaops.h>
4720 #include <linux/buffer_head.h>
4721 #include <linux/bio.h>
4722 +#include <linux/vs_tag.h>
4726 @@ -1050,6 +1051,7 @@ static struct dentry *ext4_lookup(struct
4729 return ERR_PTR(-EACCES);
4730 + dx_propagate_tag(nd, inode);
4732 return d_splice_alias(inode, dentry);
4734 @@ -2441,6 +2443,7 @@ const struct inode_operations ext4_dir_i
4735 .removexattr = generic_removexattr,
4737 .permission = ext4_permission,
4738 + .sync_flags = ext4_sync_flags,
4741 const struct inode_operations ext4_special_inode_operations = {
4742 @@ -2452,4 +2455,5 @@ const struct inode_operations ext4_speci
4743 .removexattr = generic_removexattr,
4745 .permission = ext4_permission,
4746 + .sync_flags = ext4_sync_flags,
4748 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/super.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/super.c
4749 --- linux-2.6.22.10/fs/ext4/super.c 2007-07-09 13:19:23 +0200
4750 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/super.c 2007-08-05 20:53:12 +0200
4751 @@ -725,7 +725,7 @@ enum {
4752 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4753 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4754 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4755 - Opt_grpquota, Opt_extents,
4756 + Opt_grpquota, Opt_extents, Opt_tag, Opt_notag, Opt_tagid
4759 static match_table_t tokens = {
4760 @@ -776,6 +776,9 @@ static match_table_t tokens = {
4761 {Opt_usrquota, "usrquota"},
4762 {Opt_barrier, "barrier=%u"},
4763 {Opt_extents, "extents"},
4765 + {Opt_notag, "notag"},
4766 + {Opt_tagid, "tagid=%u"},
4768 {Opt_resize, "resize"},
4770 @@ -869,6 +872,20 @@ static int parse_options (char *options,
4772 set_opt (sbi->s_mount_opt, NO_UID32);
4774 +#ifndef CONFIG_TAGGING_NONE
4776 + set_opt (sbi->s_mount_opt, TAGGED);
4779 + clear_opt (sbi->s_mount_opt, TAGGED);
4782 +#ifdef CONFIG_PROPAGATE
4785 + set_opt (sbi->s_mount_opt, TAGGED);
4789 clear_opt (sbi->s_mount_opt, CHECK);
4791 @@ -1546,6 +1563,9 @@ static int ext4_fill_super (struct super
4795 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
4796 + sb->s_flags |= MS_TAGGED;
4798 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4799 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4801 @@ -2377,6 +2397,12 @@ static int ext4_remount (struct super_bl
4803 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
4804 ext4_abort(sb, __FUNCTION__, "Abort forced by user");
4805 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
4806 + !(sb->s_flags & MS_TAGGED)) {
4807 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
4812 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4813 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4814 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/symlink.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/symlink.c
4815 --- linux-2.6.22.10/fs/ext4/symlink.c 2007-05-02 19:25:17 +0200
4816 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/symlink.c 2007-08-05 20:53:12 +0200
4817 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
4818 .listxattr = ext4_listxattr,
4819 .removexattr = generic_removexattr,
4821 + .sync_flags = ext4_sync_flags,
4824 const struct inode_operations ext4_fast_symlink_inode_operations = {
4825 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
4826 .listxattr = ext4_listxattr,
4827 .removexattr = generic_removexattr,
4829 + .sync_flags = ext4_sync_flags,
4831 diff -NurpP --minimal linux-2.6.22.10/fs/ext4/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/ext4/xattr.c
4832 --- linux-2.6.22.10/fs/ext4/xattr.c 2007-05-02 19:25:17 +0200
4833 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/xattr.c 2007-08-05 20:53:12 +0200
4835 #include <linux/mbcache.h>
4836 #include <linux/quotaops.h>
4837 #include <linux/rwsem.h>
4838 +#include <linux/vs_dlimit.h>
4842 @@ -496,6 +497,7 @@ ext4_xattr_release_block(handle_t *handl
4843 error = ext4_journal_dirty_metadata(handle, bh);
4846 + DLIMIT_FREE_BLOCK(inode, 1);
4847 DQUOT_FREE_BLOCK(inode, 1);
4848 ea_bdebug(bh, "refcount now=%d; releasing",
4849 le32_to_cpu(BHDR(bh)->h_refcount));
4850 @@ -769,11 +771,14 @@ inserted:
4851 if (new_bh == bs->bh)
4852 ea_bdebug(new_bh, "keeping");
4855 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4857 /* The old block is released after updating
4860 if (DQUOT_ALLOC_BLOCK(inode, 1))
4862 + goto cleanup_dlimit;
4863 error = ext4_journal_get_write_access(handle,
4866 @@ -850,6 +855,8 @@ cleanup:
4869 DQUOT_FREE_BLOCK(inode, 1);
4871 + DLIMIT_FREE_BLOCK(inode, 1);
4875 diff -NurpP --minimal linux-2.6.22.10/fs/fcntl.c linux-2.6.22.10-vs2.3.0.29/fs/fcntl.c
4876 --- linux-2.6.22.10/fs/fcntl.c 2007-02-06 03:01:18 +0100
4877 +++ linux-2.6.22.10-vs2.3.0.29/fs/fcntl.c 2007-08-05 20:53:12 +0200
4879 #include <linux/ptrace.h>
4880 #include <linux/signal.h>
4881 #include <linux/rcupdate.h>
4882 +#include <linux/vs_limit.h>
4884 #include <asm/poll.h>
4885 #include <asm/siginfo.h>
4886 @@ -84,6 +85,8 @@ repeat:
4888 if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
4890 + if (!vx_files_avail(1))
4893 error = expand_files(files, newfd);
4895 @@ -124,6 +127,7 @@ static int dupfd(struct file *file, unsi
4896 FD_SET(fd, fdt->open_fds);
4897 FD_CLR(fd, fdt->close_on_exec);
4898 spin_unlock(&files->file_lock);
4899 + vx_openfd_inc(fd);
4900 fd_install(fd, file);
4902 spin_unlock(&files->file_lock);
4903 @@ -176,6 +180,9 @@ asmlinkage long sys_dup2(unsigned int ol
4906 filp_close(tofree, files);
4908 + vx_openfd_inc(newfd); /* fd was unused */
4913 diff -NurpP --minimal linux-2.6.22.10/fs/file_table.c linux-2.6.22.10-vs2.3.0.29/fs/file_table.c
4914 --- linux-2.6.22.10/fs/file_table.c 2007-07-09 13:19:23 +0200
4915 +++ linux-2.6.22.10-vs2.3.0.29/fs/file_table.c 2007-08-05 20:53:12 +0200
4917 #include <linux/fsnotify.h>
4918 #include <linux/sysctl.h>
4919 #include <linux/percpu_counter.h>
4920 +#include <linux/vs_limit.h>
4921 +#include <linux/vs_context.h>
4923 #include <asm/atomic.h>
4925 @@ -119,6 +121,8 @@ struct file *get_empty_filp(void)
4926 f->f_gid = tsk->fsgid;
4927 eventpoll_init_file(f);
4928 /* f->f_version: 0 */
4929 + f->f_xid = vx_current_xid();
4934 @@ -174,6 +178,8 @@ void fastcall __fput(struct file *file)
4935 if (file->f_mode & FMODE_WRITE)
4936 put_write_access(inode);
4937 put_pid(file->f_owner.pid);
4938 + vx_files_dec(file);
4941 file->f_path.dentry = NULL;
4942 file->f_path.mnt = NULL;
4943 @@ -239,6 +245,8 @@ void put_filp(struct file *file)
4945 if (atomic_dec_and_test(&file->f_count)) {
4946 security_file_free(file);
4947 + vx_files_dec(file);
4952 diff -NurpP --minimal linux-2.6.22.10/fs/hfsplus/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/hfsplus/ioctl.c
4953 --- linux-2.6.22.10/fs/hfsplus/ioctl.c 2006-11-30 21:19:25 +0100
4954 +++ linux-2.6.22.10-vs2.3.0.29/fs/hfsplus/ioctl.c 2007-08-05 20:53:12 +0200
4956 #include <linux/fs.h>
4957 #include <linux/sched.h>
4958 #include <linux/xattr.h>
4959 +#include <linux/mount.h>
4960 #include <asm/uaccess.h>
4961 #include "hfsplus_fs.h"
4963 @@ -35,7 +36,8 @@ int hfsplus_ioctl(struct inode *inode, s
4964 flags |= FS_NODUMP_FL; /* EXT2_NODUMP_FL */
4965 return put_user(flags, (int __user *)arg);
4966 case HFSPLUS_IOC_EXT2_SETFLAGS: {
4967 - if (IS_RDONLY(inode))
4968 + if (IS_RDONLY(inode) ||
4969 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4972 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4973 diff -NurpP --minimal linux-2.6.22.10/fs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/inode.c
4974 --- linux-2.6.22.10/fs/inode.c 2007-07-09 13:19:24 +0200
4975 +++ linux-2.6.22.10-vs2.3.0.29/fs/inode.c 2007-10-11 01:10:22 +0200
4976 @@ -115,6 +115,9 @@ static struct inode *alloc_inode(struct
4977 struct address_space * const mapping = &inode->i_data;
4981 + /* essential because of inode slab reuse */
4983 inode->i_blkbits = sb->s_blocksize_bits;
4985 atomic_set(&inode->i_count, 1);
4986 @@ -133,6 +136,7 @@ static struct inode *alloc_inode(struct
4987 inode->i_bdev = NULL;
4988 inode->i_cdev = NULL;
4990 + inode->i_mdev = 0;
4991 inode->dirtied_when = 0;
4992 if (security_inode_alloc(inode)) {
4993 if (inode->i_sb->s_op->destroy_inode)
4994 @@ -231,6 +235,8 @@ void __iget(struct inode * inode)
4995 inodes_stat.nr_unused--;
4998 +EXPORT_SYMBOL_GPL(__iget);
5001 * clear_inode - clear an inode
5002 * @inode: inode to clear
5003 @@ -1405,9 +1411,11 @@ void init_special_inode(struct inode *in
5004 if (S_ISCHR(mode)) {
5005 inode->i_fop = &def_chr_fops;
5006 inode->i_rdev = rdev;
5007 + inode->i_mdev = rdev;
5008 } else if (S_ISBLK(mode)) {
5009 inode->i_fop = &def_blk_fops;
5010 inode->i_rdev = rdev;
5011 + inode->i_mdev = rdev;
5012 } else if (S_ISFIFO(mode))
5013 inode->i_fop = &def_fifo_fops;
5014 else if (S_ISSOCK(mode))
5015 diff -NurpP --minimal linux-2.6.22.10/fs/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ioctl.c
5016 --- linux-2.6.22.10/fs/ioctl.c 2007-07-09 13:19:24 +0200
5017 +++ linux-2.6.22.10-vs2.3.0.29/fs/ioctl.c 2007-08-05 20:53:12 +0200
5019 #include <linux/security.h>
5020 #include <linux/module.h>
5021 #include <linux/kallsyms.h>
5022 +#include <linux/proc_fs.h>
5023 +#include <linux/vserver/inode.h>
5024 +#include <linux/vs_tag.h>
5026 #include <asm/uaccess.h>
5027 #include <asm/ioctls.h>
5028 diff -NurpP --minimal linux-2.6.22.10/fs/ioprio.c linux-2.6.22.10-vs2.3.0.29/fs/ioprio.c
5029 --- linux-2.6.22.10/fs/ioprio.c 2007-05-02 19:25:18 +0200
5030 +++ linux-2.6.22.10-vs2.3.0.29/fs/ioprio.c 2007-08-05 20:53:12 +0200
5032 #include <linux/capability.h>
5033 #include <linux/syscalls.h>
5034 #include <linux/security.h>
5035 +#include <linux/vs_base.h>
5037 static int set_task_ioprio(struct task_struct *task, int ioprio)
5039 @@ -103,6 +104,8 @@ asmlinkage long sys_ioprio_set(int which
5041 pgrp = find_pid(who);
5042 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
5043 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5045 ret = set_task_ioprio(p, ioprio);
5048 @@ -112,7 +115,7 @@ asmlinkage long sys_ioprio_set(int which
5050 user = current->user;
5052 - user = find_user(who);
5053 + user = find_user(vx_current_xid(), who);
5057 @@ -190,6 +193,8 @@ asmlinkage long sys_ioprio_get(int which
5059 pgrp = find_pid(who);
5060 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
5061 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5063 tmpio = get_task_ioprio(p);
5066 @@ -203,7 +208,7 @@ asmlinkage long sys_ioprio_get(int which
5068 user = current->user;
5070 - user = find_user(who);
5071 + user = find_user(vx_current_xid(), who);
5075 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/dir.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/dir.c
5076 --- linux-2.6.22.10/fs/jffs2/dir.c 2007-07-09 13:19:26 +0200
5077 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/dir.c 2007-10-05 15:07:22 +0200
5078 @@ -32,7 +32,9 @@ static int jffs2_mkdir (struct inode *,s
5079 static int jffs2_rmdir (struct inode *,struct dentry *);
5080 static int jffs2_mknod (struct inode *,struct dentry *,int,dev_t);
5081 static int jffs2_rename (struct inode *, struct dentry *,
5082 - struct inode *, struct dentry *);
5083 + struct inode *, struct dentry *);
5085 +extern int jffs2_sync_flags(struct inode *);
5087 const struct file_operations jffs2_dir_operations =
5089 @@ -56,6 +58,7 @@ const struct inode_operations jffs2_dir_
5090 .rename = jffs2_rename,
5091 .permission = jffs2_permission,
5092 .setattr = jffs2_setattr,
5093 + .sync_flags = jffs2_sync_flags,
5094 .setxattr = jffs2_setxattr,
5095 .getxattr = jffs2_getxattr,
5096 .listxattr = jffs2_listxattr,
5097 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/file.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/file.c
5098 --- linux-2.6.22.10/fs/jffs2/file.c 2007-07-09 13:19:26 +0200
5099 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/file.c 2007-10-01 20:52:25 +0200
5101 #include <linux/highmem.h>
5102 #include <linux/crc32.h>
5103 #include <linux/jffs2.h>
5104 +#include <linux/vs_tag.h>
5105 #include "nodelist.h"
5107 static int jffs2_commit_write (struct file *filp, struct page *pg,
5108 @@ -25,6 +26,9 @@ static int jffs2_prepare_write (struct f
5109 unsigned start, unsigned end);
5110 static int jffs2_readpage (struct file *filp, struct page *pg);
5112 +extern int jffs2_sync_flags(struct inode *);
5115 int jffs2_fsync(struct file *filp, struct dentry *dentry, int datasync)
5117 struct inode *inode = dentry->d_inode;
5118 @@ -47,7 +51,9 @@ const struct file_operations jffs2_file_
5119 .ioctl = jffs2_ioctl,
5120 .mmap = generic_file_readonly_mmap,
5121 .fsync = jffs2_fsync,
5122 - .sendfile = generic_file_sendfile
5123 + .sendfile = generic_file_sendfile,
5124 + .splice_read = generic_file_splice_read,
5125 + .splice_write = generic_file_splice_write
5128 /* jffs2_file_inode_operations */
5129 @@ -56,6 +62,7 @@ const struct inode_operations jffs2_file
5131 .permission = jffs2_permission,
5132 .setattr = jffs2_setattr,
5133 + .sync_flags = jffs2_sync_flags,
5134 .setxattr = jffs2_setxattr,
5135 .getxattr = jffs2_getxattr,
5136 .listxattr = jffs2_listxattr,
5137 @@ -157,12 +164,14 @@ static int jffs2_prepare_write (struct f
5138 ri.mode = cpu_to_jemode(inode->i_mode);
5139 ri.uid = cpu_to_je16(inode->i_uid);
5140 ri.gid = cpu_to_je16(inode->i_gid);
5141 + ri.tag = cpu_to_je16(TAGINO_TAG(DX_TAG(inode), inode->i_tag));
5142 ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs));
5143 ri.atime = ri.ctime = ri.mtime = cpu_to_je32(get_seconds());
5144 ri.offset = cpu_to_je32(inode->i_size);
5145 ri.dsize = cpu_to_je32(pageofs - inode->i_size);
5146 ri.csize = cpu_to_je32(0);
5147 ri.compr = JFFS2_COMPR_ZERO;
5148 + ri.flags = cpu_to_je16(f->flags);
5149 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
5150 ri.data_crc = cpu_to_je32(0);
5152 @@ -248,8 +257,10 @@ static int jffs2_commit_write (struct fi
5153 ri->mode = cpu_to_jemode(inode->i_mode);
5154 ri->uid = cpu_to_je16(inode->i_uid);
5155 ri->gid = cpu_to_je16(inode->i_gid);
5156 + ri->tag = cpu_to_je16(TAGINO_TAG(DX_TAG(inode), inode->i_tag));
5157 ri->isize = cpu_to_je32((uint32_t)inode->i_size);
5158 ri->atime = ri->ctime = ri->mtime = cpu_to_je32(get_seconds());
5159 + ri->flags = cpu_to_je16(f->flags);
5161 /* In 2.4, it was already kmapped by generic_file_write(). Doesn't
5162 hurt to do it again. The alternative is ifdefs, which are ugly. */
5163 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/fs.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/fs.c
5164 --- linux-2.6.22.10/fs/jffs2/fs.c 2007-10-30 01:57:14 +0100
5165 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/fs.c 2007-09-30 14:58:01 +0200
5167 #include <linux/vmalloc.h>
5168 #include <linux/vfs.h>
5169 #include <linux/crc32.h>
5170 +#include <linux/vs_tag.h>
5171 #include "nodelist.h"
5173 static int jffs2_flash_setup(struct jffs2_sb_info *c);
5174 @@ -97,6 +98,7 @@ static int jffs2_do_setattr (struct inod
5176 ri->uid = cpu_to_je16((ivalid & ATTR_UID)?iattr->ia_uid:inode->i_uid);
5177 ri->gid = cpu_to_je16((ivalid & ATTR_GID)?iattr->ia_gid:inode->i_gid);
5178 + ri->tag = cpu_to_je16((ivalid & ATTR_TAG)?iattr->ia_tag:inode->i_tag);
5180 if (ivalid & ATTR_MODE)
5181 if (iattr->ia_mode & S_ISGID &&
5182 @@ -116,6 +118,8 @@ static int jffs2_do_setattr (struct inod
5183 ri->offset = cpu_to_je32(0);
5184 ri->csize = ri->dsize = cpu_to_je32(mdatalen);
5185 ri->compr = JFFS2_COMPR_NONE;
5186 + ri->flags = cpu_to_je16(f->flags);
5188 if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
5189 /* It's an extension. Make it a hole node */
5190 ri->compr = JFFS2_COMPR_ZERO;
5191 @@ -145,6 +149,7 @@ static int jffs2_do_setattr (struct inod
5192 inode->i_mode = jemode_to_cpu(ri->mode);
5193 inode->i_uid = je16_to_cpu(ri->uid);
5194 inode->i_gid = je16_to_cpu(ri->gid);
5195 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0, je16_to_cpu(ri->tag));
5198 old_metadata = f->metadata;
5199 @@ -179,6 +184,48 @@ static int jffs2_do_setattr (struct inod
5203 +void jffs2_set_inode_flags(struct inode *inode)
5205 + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
5206 + unsigned int flags = f->flags;
5208 + inode->i_flags &= ~(JFFS2_INO_FLAG_IMMUTABLE |
5209 + JFFS2_INO_FLAG_IUNLINK | JFFS2_INO_FLAG_BARRIER);
5211 + if (flags & JFFS2_INO_FLAG_IMMUTABLE)
5212 + inode->i_flags |= S_IMMUTABLE;
5213 + if (flags & JFFS2_INO_FLAG_IUNLINK)
5214 + inode->i_flags |= S_IUNLINK;
5215 + if (flags & JFFS2_INO_FLAG_BARRIER)
5216 + inode->i_flags |= S_BARRIER;
5219 +int jffs2_sync_flags(struct inode *inode)
5221 + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
5222 + unsigned int oldflags, newflags;
5224 + oldflags = f->flags;
5225 + newflags = oldflags & ~(JFFS2_INO_FLAG_IMMUTABLE |
5226 + JFFS2_INO_FLAG_IUNLINK | JFFS2_INO_FLAG_BARRIER);
5228 + if (IS_IMMUTABLE(inode))
5229 + newflags |= JFFS2_INO_FLAG_IMMUTABLE;
5230 + if (IS_IUNLINK(inode))
5231 + newflags |= JFFS2_INO_FLAG_IUNLINK;
5232 + if (IS_BARRIER(inode))
5233 + newflags |= JFFS2_INO_FLAG_BARRIER;
5235 + if (oldflags ^ newflags) {
5236 + f->flags = newflags;
5237 + inode->i_ctime = CURRENT_TIME;
5238 + /* strange requirement, see jffs2_dirty_inode() */
5239 + inode->i_state |= I_DIRTY_DATASYNC;
5240 + mark_inode_dirty(inode);
5245 int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
5248 @@ -254,6 +301,8 @@ void jffs2_read_inode (struct inode *ino
5249 inode->i_mode = jemode_to_cpu(latest_node.mode);
5250 inode->i_uid = je16_to_cpu(latest_node.uid);
5251 inode->i_gid = je16_to_cpu(latest_node.gid);
5252 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0,
5253 + je16_to_cpu(latest_node.tag));
5254 inode->i_size = je32_to_cpu(latest_node.isize);
5255 inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
5256 inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
5257 @@ -285,6 +334,7 @@ void jffs2_read_inode (struct inode *ino
5259 inode->i_op = &jffs2_dir_inode_operations;
5260 inode->i_fop = &jffs2_dir_operations;
5261 + f->flags = je16_to_cpu(latest_node.flags);
5265 @@ -292,6 +342,7 @@ void jffs2_read_inode (struct inode *ino
5266 inode->i_fop = &jffs2_file_operations;
5267 inode->i_mapping->a_ops = &jffs2_file_address_operations;
5268 inode->i_mapping->nrpages = 0;
5269 + f->flags = je16_to_cpu(latest_node.flags);
5273 @@ -328,7 +379,7 @@ void jffs2_read_inode (struct inode *ino
5275 printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino);
5278 + jffs2_set_inode_flags(inode);
5281 D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n"));
5282 @@ -345,10 +396,11 @@ void jffs2_dirty_inode(struct inode *ino
5284 D1(printk(KERN_DEBUG "jffs2_dirty_inode() calling setattr() for ino #%lu\n", inode->i_ino));
5286 - iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME;
5287 + iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME|ATTR_TAG;
5288 iattr.ia_mode = inode->i_mode;
5289 iattr.ia_uid = inode->i_uid;
5290 iattr.ia_gid = inode->i_gid;
5291 + iattr.ia_tag = inode->i_tag;
5292 iattr.ia_atime = inode->i_atime;
5293 iattr.ia_mtime = inode->i_mtime;
5294 iattr.ia_ctime = inode->i_ctime;
5295 @@ -422,6 +474,7 @@ struct inode *jffs2_new_inode (struct in
5297 memset(ri, 0, sizeof(*ri));
5298 /* Set OS-specific defaults for new inodes */
5299 + ri->tag = cpu_to_je16(dx_current_tag());
5300 ri->uid = cpu_to_je16(current->fsuid);
5302 if (dir_i->i_mode & S_ISGID) {
5303 @@ -443,14 +496,16 @@ struct inode *jffs2_new_inode (struct in
5304 inode->i_mode = jemode_to_cpu(ri->mode);
5305 inode->i_gid = je16_to_cpu(ri->gid);
5306 inode->i_uid = je16_to_cpu(ri->uid);
5307 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0, je16_to_cpu(ri->tag));
5308 inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
5309 ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
5311 inode->i_blocks = 0;
5314 + f->flags = je16_to_cpu(ri->flags);
5315 + jffs2_set_inode_flags(inode);
5316 insert_inode_hash(inode);
5321 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/gc.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/gc.c
5322 --- linux-2.6.22.10/fs/jffs2/gc.c 2007-07-09 13:19:26 +0200
5323 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/gc.c 2007-08-05 20:53:12 +0200
5324 @@ -735,6 +735,7 @@ static int jffs2_garbage_collect_metadat
5325 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5326 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5327 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5328 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5329 ri.isize = cpu_to_je32(ilen);
5330 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5331 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5332 @@ -998,6 +999,7 @@ static int jffs2_garbage_collect_hole(st
5333 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5334 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5335 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5336 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5337 ri.isize = cpu_to_je32(ilen);
5338 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5339 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5340 @@ -1256,6 +1258,7 @@ static int jffs2_garbage_collect_dnode(s
5341 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5342 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5343 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5344 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5345 ri.isize = cpu_to_je32(JFFS2_F_I_SIZE(f));
5346 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5347 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5348 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/ioctl.c
5349 --- linux-2.6.22.10/fs/jffs2/ioctl.c 2007-07-09 13:19:26 +0200
5350 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/ioctl.c 2007-08-05 20:53:12 +0200
5354 #include <linux/fs.h>
5355 +#include <linux/types.h>
5356 +#include <linux/mount.h>
5357 +#include <linux/jffs2.h>
5358 +#include <linux/uaccess.h>
5359 +#include <linux/vs_base.h>
5360 +#include "jffs2_fs_sb.h"
5361 +#include "jffs2_fs_i.h"
5363 +#include "os-linux.h"
5365 +extern void jffs2_set_inode_flags(struct inode *);
5367 int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
5370 - /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which
5371 - will include compression support etc. */
5373 + struct jffs2_inode_info *j = JFFS2_INODE_INFO(inode);
5374 + unsigned int flags, oldflags, newflags;
5377 + case JFFS2_IOC_GETFLAGS:
5378 + flags = j->flags & JFFS2_USER_VISIBLE;
5379 + return put_user(flags, (int __user *) arg);
5381 + case JFFS2_IOC_SETFLAGS:
5382 + if (IS_RDONLY(inode) ||
5383 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
5386 + if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
5389 + if (get_user(flags, (int __user *) arg))
5392 + oldflags = j->flags;
5393 + newflags = flags & JFFS2_USER_MODIFIABLE;
5394 + newflags |= oldflags & ~JFFS2_USER_MODIFIABLE;
5397 + * The IMMUTABLE flags can only be changed by
5398 + * the relevant capability.
5400 + if (((oldflags ^ newflags) &
5401 + (JFFS2_INO_FLAG_IMMUTABLE | JFFS2_INO_FLAG_IUNLINK)) ||
5402 + (oldflags & JFFS2_INO_FLAG_IMMUTABLE)) {
5403 + if (!capable(CAP_LINUX_IMMUTABLE))
5407 + if (oldflags ^ newflags) {
5408 + j->flags = newflags;
5409 + inode->i_ctime = CURRENT_TIME;
5410 + /* strange requirement, see jffs2_dirty_inode() */
5411 + inode->i_state |= I_DIRTY_DATASYNC;
5412 + mark_inode_dirty(inode);
5413 + jffs2_set_inode_flags(inode);
5422 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/jffs2_fs_sb.h linux-2.6.22.10-vs2.3.0.29/fs/jffs2/jffs2_fs_sb.h
5423 --- linux-2.6.22.10/fs/jffs2/jffs2_fs_sb.h 2007-07-09 13:19:26 +0200
5424 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/jffs2_fs_sb.h 2007-08-05 20:53:12 +0200
5425 @@ -39,6 +39,7 @@ struct jffs2_sb_info {
5426 uint32_t checked_ino;
5429 + unsigned int s_mount_opt;
5431 struct task_struct *gc_task; /* GC task struct */
5432 struct completion gc_thread_start; /* GC thread start completion */
5433 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/nodelist.h linux-2.6.22.10-vs2.3.0.29/fs/jffs2/nodelist.h
5434 --- linux-2.6.22.10/fs/jffs2/nodelist.h 2007-07-09 13:19:26 +0200
5435 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/nodelist.h 2007-08-05 20:53:12 +0200
5437 #elif defined(JFFS2_BIG_ENDIAN)
5438 #define cpu_to_je16(x) ((jint16_t){cpu_to_be16(x)})
5439 #define cpu_to_je32(x) ((jint32_t){cpu_to_be32(x)})
5440 -#define cpu_to_jemode(x) ((jmode_t){cpu_to_be32(os_to_jffs2_mode(x))})
5441 +#define cpu_to_jemode(x) ((jmode_t){cpu_to_be16(os_to_jffs2_mode(x))})
5443 #define constant_cpu_to_je16(x) ((jint16_t){__constant_cpu_to_be16(x)})
5444 #define constant_cpu_to_je32(x) ((jint32_t){__constant_cpu_to_be32(x)})
5446 #define je16_to_cpu(x) (be16_to_cpu(x.v16))
5447 #define je32_to_cpu(x) (be32_to_cpu(x.v32))
5448 -#define jemode_to_cpu(x) (be32_to_cpu(jffs2_to_os_mode((x).m)))
5449 +#define jemode_to_cpu(x) (be16_to_cpu(jffs2_to_os_mode((x).m)))
5450 #elif defined(JFFS2_LITTLE_ENDIAN)
5451 #define cpu_to_je16(x) ((jint16_t){cpu_to_le16(x)})
5452 #define cpu_to_je32(x) ((jint32_t){cpu_to_le32(x)})
5453 -#define cpu_to_jemode(x) ((jmode_t){cpu_to_le32(os_to_jffs2_mode(x))})
5454 +#define cpu_to_jemode(x) ((jmode_t){cpu_to_le16(os_to_jffs2_mode(x))})
5456 #define constant_cpu_to_je16(x) ((jint16_t){__constant_cpu_to_le16(x)})
5457 #define constant_cpu_to_je32(x) ((jint32_t){__constant_cpu_to_le32(x)})
5459 #define je16_to_cpu(x) (le16_to_cpu(x.v16))
5460 #define je32_to_cpu(x) (le32_to_cpu(x.v32))
5461 -#define jemode_to_cpu(x) (le32_to_cpu(jffs2_to_os_mode((x).m)))
5462 +#define jemode_to_cpu(x) (le16_to_cpu(jffs2_to_os_mode((x).m)))
5466 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/os-linux.h linux-2.6.22.10-vs2.3.0.29/fs/jffs2/os-linux.h
5467 --- linux-2.6.22.10/fs/jffs2/os-linux.h 2007-07-09 13:19:26 +0200
5468 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/os-linux.h 2007-08-05 20:53:12 +0200
5469 @@ -29,6 +29,7 @@ struct kvec;
5470 #define JFFS2_F_I_MODE(f) (OFNI_EDONI_2SFFJ(f)->i_mode)
5471 #define JFFS2_F_I_UID(f) (OFNI_EDONI_2SFFJ(f)->i_uid)
5472 #define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid)
5473 +#define JFFS2_F_I_TAG(f) (OFNI_EDONI_2SFFJ(f)->i_tag)
5474 #define JFFS2_F_I_RDEV(f) (OFNI_EDONI_2SFFJ(f)->i_rdev)
5476 #define ITIME(sec) ((struct timespec){sec, 0})
5477 @@ -204,6 +205,9 @@ int jffs2_flash_direct_writev(struct jff
5478 int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len,
5479 size_t *retlen, const u_char *buf);
5481 +#define JFFS2_IOC_GETFLAGS FS_IOC_GETFLAGS
5482 +#define JFFS2_IOC_SETFLAGS FS_IOC_SETFLAGS
5484 #endif /* __JFFS2_OS_LINUX_H__ */
5487 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/readinode.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/readinode.c
5488 --- linux-2.6.22.10/fs/jffs2/readinode.c 2007-07-09 13:19:26 +0200
5489 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/readinode.c 2007-08-05 20:53:12 +0200
5490 @@ -1182,6 +1182,8 @@ static int jffs2_do_read_inode_internal(
5491 latest_node->isize = cpu_to_je32(0);
5492 latest_node->gid = cpu_to_je16(0);
5493 latest_node->uid = cpu_to_je16(0);
5494 + latest_node->tag = cpu_to_je16(0);
5495 + latest_node->flags = cpu_to_je16(0);
5496 if (f->inocache->state == INO_STATE_READING)
5497 jffs2_set_inocache_state(c, f->inocache, INO_STATE_PRESENT);
5499 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/super.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/super.c
5500 --- linux-2.6.22.10/fs/jffs2/super.c 2007-07-09 13:19:26 +0200
5501 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/super.c 2007-08-05 20:53:12 +0200
5503 #include <linux/mtd/super.h>
5504 #include <linux/ctype.h>
5505 #include <linux/namei.h>
5506 +#include <linux/parser.h>
5508 #include "nodelist.h"
5510 @@ -75,6 +76,49 @@ static const struct super_operations jff
5511 .sync_fs = jffs2_sync_fs,
5515 + Opt_tag, Opt_notag, Opt_ignore, Opt_err
5518 +static match_table_t tokens = {
5520 + {Opt_notag, "notag"},
5524 +static int parse_options (char * options,
5525 + struct jffs2_sb_info *sbi)
5528 + substring_t args[MAX_OPT_ARGS];
5533 + while ((p = strsep (&options, ",")) != NULL) {
5538 + token = match_token(p, tokens, args);
5540 +#ifndef CONFIG_TAGGING_NONE
5542 + set_opt (sbi->s_mount_opt, TAGGED);
5545 + clear_opt (sbi->s_mount_opt, TAGGED);
5558 * fill in the superblock
5560 @@ -109,6 +153,12 @@ static int jffs2_fill_super(struct super
5561 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
5562 sb->s_flags |= MS_POSIXACL;
5564 + if (!parse_options ((char *) data, c))
5567 + if (c->s_mount_opt & JFFS2_MOUNT_TAGGED)
5568 + sb->s_flags |= MS_TAGGED;
5570 return jffs2_do_fill_super(sb, data, silent);
5573 diff -NurpP --minimal linux-2.6.22.10/fs/jffs2/write.c linux-2.6.22.10-vs2.3.0.29/fs/jffs2/write.c
5574 --- linux-2.6.22.10/fs/jffs2/write.c 2007-10-30 01:57:14 +0100
5575 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/write.c 2007-09-05 03:06:11 +0200
5576 @@ -44,6 +44,7 @@ int jffs2_do_new_inode(struct jffs2_sb_i
5577 ri->totlen = cpu_to_je32(PAD(sizeof(*ri)));
5578 ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));
5579 ri->mode = cpu_to_jemode(mode);
5580 + ri->flags = cpu_to_je16(0);
5582 f->highest_version = 1;
5583 ri->version = cpu_to_je32(f->highest_version);
5584 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/acl.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/acl.c
5585 --- linux-2.6.22.10/fs/jfs/acl.c 2006-11-30 21:19:25 +0100
5586 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/acl.c 2007-08-05 20:53:12 +0200
5587 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
5590 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5591 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5592 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5593 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5594 if (DQUOT_TRANSFER(inode, iattr))
5597 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/file.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/file.c
5598 --- linux-2.6.22.10/fs/jfs/file.c 2007-05-02 19:25:18 +0200
5599 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/file.c 2007-09-12 20:04:16 +0200
5600 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
5601 .setattr = jfs_setattr,
5602 .permission = jfs_permission,
5604 + .sync_flags = jfs_sync_flags,
5607 const struct file_operations jfs_file_operations = {
5608 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/inode.c
5609 --- linux-2.6.22.10/fs/jfs/inode.c 2007-07-09 13:19:26 +0200
5610 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/inode.c 2007-08-05 20:53:12 +0200
5612 #include <linux/buffer_head.h>
5613 #include <linux/pagemap.h>
5614 #include <linux/quotaops.h>
5615 +#include <linux/vs_dlimit.h>
5616 #include "jfs_incore.h"
5617 #include "jfs_inode.h"
5618 #include "jfs_filsys.h"
5619 @@ -143,6 +144,7 @@ void jfs_delete_inode(struct inode *inod
5621 DQUOT_FREE_INODE(inode);
5623 + DLIMIT_FREE_INODE(inode);
5627 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/ioctl.c
5628 --- linux-2.6.22.10/fs/jfs/ioctl.c 2007-07-09 13:19:27 +0200
5629 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/ioctl.c 2007-08-05 20:53:12 +0200
5631 #include <linux/capability.h>
5632 #include <linux/time.h>
5633 #include <linux/sched.h>
5634 +#include <linux/mount.h>
5635 #include <asm/current.h>
5636 #include <asm/uaccess.h>
5638 @@ -66,7 +67,8 @@ int jfs_ioctl(struct inode * inode, stru
5639 case JFS_IOC_SETFLAGS: {
5640 unsigned int oldflags;
5642 - if (IS_RDONLY(inode))
5643 + if (IS_RDONLY(inode) ||
5644 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
5647 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
5648 @@ -87,8 +89,8 @@ int jfs_ioctl(struct inode * inode, stru
5649 * the relevant capability.
5651 if ((oldflags & JFS_IMMUTABLE_FL) ||
5652 - ((flags ^ oldflags) &
5653 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5654 + ((flags ^ oldflags) & (JFS_APPEND_FL |
5655 + JFS_IMMUTABLE_FL | JFS_IUNLINK_FL))) {
5656 if (!capable(CAP_LINUX_IMMUTABLE))
5659 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_dinode.h linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_dinode.h
5660 --- linux-2.6.22.10/fs/jfs/jfs_dinode.h 2006-11-30 21:19:25 +0100
5661 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_dinode.h 2007-08-05 20:53:12 +0200
5662 @@ -162,9 +162,12 @@ struct dinode {
5663 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
5664 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
5666 -#define JFS_FL_USER_VISIBLE 0x03F80000
5667 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5668 +#define JFS_IUNLINK_FL 0x08000000 /* Immutable unlink */
5670 +#define JFS_FL_USER_VISIBLE 0x0FF80000
5671 #define JFS_FL_USER_MODIFIABLE 0x03F80000
5672 -#define JFS_FL_INHERIT 0x03C80000
5673 +#define JFS_FL_INHERIT 0x0BC80000
5675 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5676 #define JFS_IOC_GETFLAGS _IOR('f', 1, long)
5677 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_dtree.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_dtree.c
5678 --- linux-2.6.22.10/fs/jfs/jfs_dtree.c 2007-02-06 03:01:24 +0100
5679 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_dtree.c 2007-08-05 20:53:12 +0200
5682 #include <linux/fs.h>
5683 #include <linux/quotaops.h>
5684 +#include <linux/vs_dlimit.h>
5685 #include "jfs_incore.h"
5686 #include "jfs_superblock.h"
5687 #include "jfs_filsys.h"
5688 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
5690 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
5692 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
5693 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
5696 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
5697 + goto clean_up_dquot;
5698 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
5699 + goto clean_up_dlimit;
5702 * Save the table, we're going to overwrite it with the
5703 @@ -479,6 +480,12 @@ static u32 add_index(tid_t tid, struct i
5708 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
5711 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
5715 jfs_ip->next_index--;
5716 @@ -952,6 +959,7 @@ static int dtSplitUp(tid_t tid,
5719 int quota_allocation = 0;
5720 + int dlimit_allocation = 0;
5722 /* get split page */
5724 @@ -1036,6 +1044,12 @@ static int dtSplitUp(tid_t tid,
5726 quota_allocation += n;
5728 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
5732 + dlimit_allocation += n;
5734 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
5737 @@ -1309,6 +1323,9 @@ static int dtSplitUp(tid_t tid,
5741 + /* Rollback dlimit allocation */
5742 + if (rc && dlimit_allocation)
5743 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
5744 /* Rollback quota allocation */
5745 if (rc && quota_allocation)
5746 DQUOT_FREE_BLOCK(ip, quota_allocation);
5747 @@ -1376,6 +1393,12 @@ static int dtSplitPage(tid_t tid, struct
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 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
5760 @@ -1926,6 +1949,12 @@ static int dtSplitRoot(tid_t tid,
5761 release_metapage(rmp);
5764 + /* Allocate blocks to dlimit. */
5765 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5766 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5767 + release_metapage(rmp);
5771 BT_MARK_DIRTY(rmp, ip);
5773 @@ -2292,6 +2321,8 @@ static int dtDeleteUp(tid_t tid, struct
5775 xlen = lengthPXD(&fp->header.self);
5777 + /* Free dlimit allocation. */
5778 + DLIMIT_FREE_BLOCK(ip, xlen);
5779 /* Free quota allocation. */
5780 DQUOT_FREE_BLOCK(ip, xlen);
5782 @@ -2368,6 +2399,8 @@ static int dtDeleteUp(tid_t tid, struct
5784 xlen = lengthPXD(&p->header.self);
5786 + /* Free dlimit allocation */
5787 + DLIMIT_FREE_BLOCK(ip, xlen);
5788 /* Free quota allocation */
5789 DQUOT_FREE_BLOCK(ip, xlen);
5791 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_extent.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_extent.c
5792 --- linux-2.6.22.10/fs/jfs/jfs_extent.c 2006-11-30 21:19:25 +0100
5793 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_extent.c 2007-08-05 20:53:12 +0200
5796 #include <linux/fs.h>
5797 #include <linux/quotaops.h>
5798 +#include <linux/vs_dlimit.h>
5799 #include "jfs_incore.h"
5800 #include "jfs_inode.h"
5801 #include "jfs_superblock.h"
5802 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
5806 + /* Allocate blocks to dlimit. */
5807 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
5808 + DQUOT_FREE_BLOCK(ip, nxlen);
5809 + dbFree(ip, nxaddr, (s64) nxlen);
5810 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
5814 /* determine the value of the extent flag */
5815 xflag = abnr ? XAD_NOTRECORDED : 0;
5817 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
5820 dbFree(ip, nxaddr, nxlen);
5821 + DLIMIT_FREE_BLOCK(ip, nxlen);
5822 DQUOT_FREE_BLOCK(ip, nxlen);
5823 mutex_unlock(&JFS_IP(ip)->commit_mutex);
5825 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
5826 mutex_unlock(&JFS_IP(ip)->commit_mutex);
5829 + /* Allocate blocks to dlimit. */
5830 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
5831 + DQUOT_FREE_BLOCK(ip, nxlen);
5832 + dbFree(ip, nxaddr, (s64) nxlen);
5833 + up(&JFS_IP(ip)->commit_sem);
5837 delta = nxlen - xlen;
5839 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
5840 /* extend the extent */
5841 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
5842 dbFree(ip, xaddr + xlen, delta);
5843 + DLIMIT_FREE_BLOCK(ip, nxlen);
5844 DQUOT_FREE_BLOCK(ip, nxlen);
5847 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
5849 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
5850 dbFree(ip, nxaddr, nxlen);
5851 + DLIMIT_FREE_BLOCK(ip, nxlen);
5852 DQUOT_FREE_BLOCK(ip, nxlen);
5855 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_filsys.h linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_filsys.h
5856 --- linux-2.6.22.10/fs/jfs/jfs_filsys.h 2007-02-06 03:01:24 +0100
5857 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_filsys.h 2007-08-05 20:53:12 +0200
5859 #define JFS_NAME_MAX 255
5860 #define JFS_PATH_MAX BPSIZE
5862 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
5865 * file system state (superblock state)
5866 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_imap.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_imap.c
5867 --- linux-2.6.22.10/fs/jfs/jfs_imap.c 2007-07-09 13:19:27 +0200
5868 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_imap.c 2007-08-05 20:53:12 +0200
5870 #include <linux/buffer_head.h>
5871 #include <linux/pagemap.h>
5872 #include <linux/quotaops.h>
5873 +#include <linux/vs_tag.h>
5875 #include "jfs_incore.h"
5876 #include "jfs_inode.h"
5877 @@ -3075,6 +3076,8 @@ static int copy_from_dinode(struct dinod
5879 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5880 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5884 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5885 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5886 @@ -3095,14 +3098,18 @@ static int copy_from_dinode(struct dinod
5888 ip->i_nlink = le32_to_cpu(dip->di_nlink);
5890 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
5891 + uid = le32_to_cpu(dip->di_uid);
5892 + gid = le32_to_cpu(dip->di_gid);
5893 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
5895 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
5897 ip->i_uid = jfs_ip->saved_uid;
5899 ip->i_uid = sbi->uid;
5902 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
5903 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
5905 ip->i_gid = jfs_ip->saved_gid;
5907 @@ -3167,14 +3174,12 @@ static void copy_to_dinode(struct dinode
5908 dip->di_size = cpu_to_le64(ip->i_size);
5909 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
5910 dip->di_nlink = cpu_to_le32(ip->i_nlink);
5911 - if (sbi->uid == -1)
5912 - dip->di_uid = cpu_to_le32(ip->i_uid);
5914 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
5915 - if (sbi->gid == -1)
5916 - dip->di_gid = cpu_to_le32(ip->i_gid);
5918 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
5920 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
5921 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
5922 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
5923 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
5925 jfs_get_inode_flags(jfs_ip);
5927 * mode2 is only needed for storing the higher order bits.
5928 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_inode.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_inode.c
5929 --- linux-2.6.22.10/fs/jfs/jfs_inode.c 2007-07-09 13:19:27 +0200
5930 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_inode.c 2007-08-05 20:53:12 +0200
5933 #include <linux/fs.h>
5934 #include <linux/quotaops.h>
5935 +#include <linux/vs_dlimit.h>
5936 +#include <linux/vs_tag.h>
5937 #include "jfs_incore.h"
5938 #include "jfs_inode.h"
5939 #include "jfs_filsys.h"
5940 @@ -30,19 +32,47 @@ void jfs_set_inode_flags(struct inode *i
5942 unsigned int flags = JFS_IP(inode)->mode2;
5944 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
5945 - S_NOATIME | S_DIRSYNC | S_SYNC);
5946 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
5947 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5949 if (flags & JFS_IMMUTABLE_FL)
5950 inode->i_flags |= S_IMMUTABLE;
5951 + if (flags & JFS_IUNLINK_FL)
5952 + inode->i_flags |= S_IUNLINK;
5953 + if (flags & JFS_BARRIER_FL)
5954 + inode->i_flags |= S_BARRIER;
5956 + if (flags & JFS_SYNC_FL)
5957 + inode->i_flags |= S_SYNC;
5958 if (flags & JFS_APPEND_FL)
5959 inode->i_flags |= S_APPEND;
5960 if (flags & JFS_NOATIME_FL)
5961 inode->i_flags |= S_NOATIME;
5962 if (flags & JFS_DIRSYNC_FL)
5963 inode->i_flags |= S_DIRSYNC;
5964 - if (flags & JFS_SYNC_FL)
5965 - inode->i_flags |= S_SYNC;
5968 +int jfs_sync_flags(struct inode *inode)
5970 + unsigned int oldflags, newflags;
5972 + oldflags = JFS_IP(inode)->mode2;
5973 + newflags = oldflags & ~(JFS_IMMUTABLE_FL |
5974 + JFS_IUNLINK_FL | JFS_BARRIER_FL);
5976 + if (IS_IMMUTABLE(inode))
5977 + newflags |= JFS_IMMUTABLE_FL;
5978 + if (IS_IUNLINK(inode))
5979 + newflags |= JFS_IUNLINK_FL;
5980 + if (IS_BARRIER(inode))
5981 + newflags |= JFS_BARRIER_FL;
5983 + if (oldflags ^ newflags) {
5984 + JFS_IP(inode)->mode2 = newflags;
5985 + inode->i_ctime = CURRENT_TIME;
5986 + mark_inode_dirty(inode);
5991 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
5992 @@ -108,10 +138,17 @@ struct inode *ialloc(struct inode *paren
5993 jfs_inode->saved_uid = inode->i_uid;
5994 jfs_inode->saved_gid = inode->i_gid;
5996 + inode->i_tag = dx_current_fstag(sb);
5997 + if (DLIMIT_ALLOC_INODE(inode)) {
5999 + return ERR_PTR(-ENOSPC);
6003 * Allocate inode to quota.
6005 if (DQUOT_ALLOC_INODE(inode)) {
6006 + DLIMIT_FREE_INODE(inode);
6008 inode->i_flags |= S_NOQUOTA;
6010 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_inode.h linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_inode.h
6011 --- linux-2.6.22.10/fs/jfs/jfs_inode.h 2007-07-09 13:19:27 +0200
6012 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_inode.h 2007-08-05 20:53:12 +0200
6013 @@ -33,6 +33,7 @@ extern void jfs_free_zero_link(struct in
6014 extern struct dentry *jfs_get_parent(struct dentry *dentry);
6015 extern void jfs_get_inode_flags(struct jfs_inode_info *);
6016 extern void jfs_set_inode_flags(struct inode *);
6017 +extern int jfs_sync_flags(struct inode *);
6018 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
6020 extern const struct address_space_operations jfs_aops;
6021 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/jfs_xtree.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_xtree.c
6022 --- linux-2.6.22.10/fs/jfs/jfs_xtree.c 2007-05-02 19:25:18 +0200
6023 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_xtree.c 2007-08-05 20:53:12 +0200
6026 #include <linux/fs.h>
6027 #include <linux/quotaops.h>
6028 +#include <linux/vs_dlimit.h>
6029 #include "jfs_incore.h"
6030 #include "jfs_filsys.h"
6031 #include "jfs_metapage.h"
6032 @@ -846,7 +847,12 @@ int xtInsert(tid_t tid, /* transaction
6034 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
6036 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
6037 + DQUOT_FREE_BLOCK(ip, xlen);
6040 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
6041 + DLIMIT_FREE_BLOCK(ip, xlen);
6042 DQUOT_FREE_BLOCK(ip, xlen);
6045 @@ -876,6 +882,7 @@ int xtInsert(tid_t tid, /* transaction
6046 /* undo data extent allocation */
6048 dbFree(ip, xaddr, (s64) xlen);
6049 + DLIMIT_FREE_BLOCK(ip, xlen);
6050 DQUOT_FREE_BLOCK(ip, xlen);
6053 @@ -1236,6 +1243,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
6055 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
6056 int quota_allocation = 0;
6057 + int dlimit_allocation = 0;
6060 sp = XT_PAGE(ip, smp);
6061 @@ -1255,6 +1263,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
6063 quota_allocation += lengthPXD(pxd);
6065 + /* Allocate blocks to dlimit. */
6066 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
6070 + dlimit_allocation += lengthPXD(pxd);
6073 * allocate the new right page for the split
6075 @@ -1456,6 +1471,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
6079 + /* Rollback dlimit allocation. */
6080 + if (dlimit_allocation)
6081 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
6082 /* Rollback quota allocation. */
6083 if (quota_allocation)
6084 DQUOT_FREE_BLOCK(ip, quota_allocation);
6085 @@ -1520,6 +1538,12 @@ xtSplitRoot(tid_t tid,
6086 release_metapage(rmp);
6089 + /* Allocate blocks to dlimit. */
6090 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
6091 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
6092 + release_metapage(rmp);
6096 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
6098 @@ -3951,6 +3975,8 @@ s64 xtTruncate(tid_t tid, struct inode *
6100 ip->i_size = newsize;
6102 + /* update dlimit allocation to reflect freed blocks */
6103 + DLIMIT_FREE_BLOCK(ip, nfreed);
6104 /* update quota allocation to reflect freed blocks */
6105 DQUOT_FREE_BLOCK(ip, nfreed);
6107 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/namei.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/namei.c
6108 --- linux-2.6.22.10/fs/jfs/namei.c 2007-05-02 19:25:18 +0200
6109 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/namei.c 2007-08-05 20:53:12 +0200
6111 #include <linux/fs.h>
6112 #include <linux/ctype.h>
6113 #include <linux/quotaops.h>
6114 +#include <linux/vs_tag.h>
6115 #include "jfs_incore.h"
6116 #include "jfs_superblock.h"
6117 #include "jfs_inode.h"
6118 @@ -1469,6 +1470,7 @@ static struct dentry *jfs_lookup(struct
6119 return ERR_PTR(-EACCES);
6122 + dx_propagate_tag(nd, ip);
6123 dentry = d_splice_alias(ip, dentry);
6125 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
6126 @@ -1521,6 +1523,7 @@ const struct inode_operations jfs_dir_in
6127 .setattr = jfs_setattr,
6128 .permission = jfs_permission,
6130 + .sync_flags = jfs_sync_flags,
6133 const struct file_operations jfs_dir_operations = {
6134 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/super.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/super.c
6135 --- linux-2.6.22.10/fs/jfs/super.c 2007-07-09 13:19:27 +0200
6136 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/super.c 2007-08-05 20:53:12 +0200
6137 @@ -194,7 +194,8 @@ static void jfs_put_super(struct super_b
6139 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
6140 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
6141 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
6142 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
6143 + Opt_tag, Opt_notag, Opt_tagid
6146 static match_table_t tokens = {
6147 @@ -204,6 +205,10 @@ static match_table_t tokens = {
6148 {Opt_resize, "resize=%u"},
6149 {Opt_resize_nosize, "resize"},
6150 {Opt_errors, "errors=%s"},
6152 + {Opt_notag, "notag"},
6153 + {Opt_tagid, "tagid=%u"},
6154 + {Opt_tag, "tagxid"},
6155 {Opt_ignore, "noquota"},
6156 {Opt_ignore, "quota"},
6157 {Opt_usrquota, "usrquota"},
6158 @@ -338,6 +343,20 @@ static int parse_options(char *options,
6162 +#ifndef CONFIG_TAGGING_NONE
6164 + *flag |= JFS_TAGGED;
6167 + *flag &= JFS_TAGGED;
6170 +#ifdef CONFIG_PROPAGATE
6173 + *flag |= JFS_TAGGED;
6177 printk("jfs: Unrecognized mount option \"%s\" "
6178 " or missing value\n", p);
6179 @@ -368,6 +387,13 @@ static int jfs_remount(struct super_bloc
6180 if (!parse_options(data, sb, &newLVSize, &flag)) {
6184 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
6185 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
6191 if (sb->s_flags & MS_RDONLY) {
6193 @@ -439,6 +465,9 @@ static int jfs_fill_super(struct super_b
6194 #ifdef CONFIG_JFS_POSIX_ACL
6195 sb->s_flags |= MS_POSIXACL;
6197 + /* map mount option tagxid */
6198 + if (sbi->flag & JFS_TAGGED)
6199 + sb->s_flags |= MS_TAGGED;
6202 printk(KERN_ERR "resize option for remount only\n");
6203 diff -NurpP --minimal linux-2.6.22.10/fs/jfs/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/jfs/xattr.c
6204 --- linux-2.6.22.10/fs/jfs/xattr.c 2006-11-30 21:19:26 +0100
6205 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/xattr.c 2007-08-05 20:53:12 +0200
6207 #include <linux/posix_acl_xattr.h>
6208 #include <linux/quotaops.h>
6209 #include <linux/security.h>
6210 +#include <linux/vs_dlimit.h>
6211 #include "jfs_incore.h"
6212 #include "jfs_superblock.h"
6213 #include "jfs_dmap.h"
6214 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
6215 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
6218 + /* Allocate new blocks to dlimit. */
6219 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
6220 + DQUOT_FREE_BLOCK(ip, nblocks);
6224 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
6226 + /*Rollback dlimit allocation. */
6227 + DLIMIT_FREE_BLOCK(ip, nblocks);
6228 /*Rollback quota allocation. */
6229 DQUOT_FREE_BLOCK(ip, nblocks);
6231 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
6234 /* Rollback quota allocation. */
6235 + DLIMIT_FREE_BLOCK(ip, nblocks);
6236 + /* Rollback quota allocation. */
6237 DQUOT_FREE_BLOCK(ip, nblocks);
6239 dbFree(ip, blkno, nblocks);
6240 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
6243 int quota_allocation = 0;
6244 + int dlimit_allocation = 0;
6246 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
6247 if (ji->ea.flag == 0)
6248 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
6250 quota_allocation = blocks_needed;
6252 + /* Allocate new blocks to dlimit. */
6254 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
6256 + dlimit_allocation = blocks_needed;
6258 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
6261 @@ -599,6 +616,9 @@ static int ea_get(struct inode *inode, s
6265 + /* Rollback dlimit allocation */
6266 + if (dlimit_allocation)
6267 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
6268 /* Rollback quota allocation */
6269 if (quota_allocation)
6270 DQUOT_FREE_BLOCK(inode, quota_allocation);
6271 @@ -675,8 +695,10 @@ static int ea_put(tid_t tid, struct inod
6274 /* If old blocks exist, they must be removed from quota allocation. */
6277 + DLIMIT_FREE_BLOCK(inode, old_blocks);
6278 DQUOT_FREE_BLOCK(inode, old_blocks);
6281 inode->i_ctime = CURRENT_TIME;
6283 diff -NurpP --minimal linux-2.6.22.10/fs/libfs.c linux-2.6.22.10-vs2.3.0.29/fs/libfs.c
6284 --- linux-2.6.22.10/fs/libfs.c 2007-07-09 13:19:27 +0200
6285 +++ linux-2.6.22.10-vs2.3.0.29/fs/libfs.c 2007-08-05 20:53:12 +0200
6286 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
6287 * both impossible due to the lock on directory.
6290 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6291 +static inline int do_dcache_readdir_filter(struct file *filp,
6292 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6294 struct dentry *dentry = filp->f_path.dentry;
6295 struct dentry *cursor = filp->private_data;
6296 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
6297 next = list_entry(p, struct dentry, d_u.d_child);
6298 if (d_unhashed(next) || !next->d_inode)
6300 + if (filter && !filter(next))
6303 spin_unlock(&dcache_lock);
6304 if (filldir(dirent, next->d_name.name,
6305 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
6309 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6311 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6314 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6315 + int (*filter)(struct dentry *))
6317 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6321 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6324 @@ -640,6 +655,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6325 EXPORT_SYMBOL(dcache_dir_lseek);
6326 EXPORT_SYMBOL(dcache_dir_open);
6327 EXPORT_SYMBOL(dcache_readdir);
6328 +EXPORT_SYMBOL(dcache_readdir_filter);
6329 EXPORT_SYMBOL(generic_read_dir);
6330 EXPORT_SYMBOL(get_sb_pseudo);
6331 EXPORT_SYMBOL(simple_commit_write);
6332 diff -NurpP --minimal linux-2.6.22.10/fs/locks.c linux-2.6.22.10-vs2.3.0.29/fs/locks.c
6333 --- linux-2.6.22.10/fs/locks.c 2007-10-30 01:57:14 +0100
6334 +++ linux-2.6.22.10-vs2.3.0.29/fs/locks.c 2007-10-05 15:07:22 +0200
6336 #include <linux/syscalls.h>
6337 #include <linux/time.h>
6338 #include <linux/rcupdate.h>
6339 +#include <linux/vs_base.h>
6340 +#include <linux/vs_limit.h>
6342 #include <asm/semaphore.h>
6343 #include <asm/uaccess.h>
6344 @@ -147,6 +149,8 @@ static struct kmem_cache *filelock_cache
6345 /* Allocate an empty lock structure. */
6346 static struct file_lock *locks_alloc_lock(void)
6348 + if (!vx_locks_avail(1))
6350 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6353 @@ -172,6 +176,7 @@ static void locks_free_lock(struct file_
6354 BUG_ON(!list_empty(&fl->fl_block));
6355 BUG_ON(!list_empty(&fl->fl_link));
6358 locks_release_private(fl);
6359 kmem_cache_free(filelock_cache, fl);
6361 @@ -191,6 +196,7 @@ void locks_init_lock(struct file_lock *f
6362 fl->fl_start = fl->fl_end = 0;
6364 fl->fl_lmops = NULL;
6368 EXPORT_SYMBOL(locks_init_lock);
6369 @@ -244,6 +250,7 @@ void locks_copy_lock(struct file_lock *n
6370 new->fl_file = fl->fl_file;
6371 new->fl_ops = fl->fl_ops;
6372 new->fl_lmops = fl->fl_lmops;
6373 + new->fl_xid = fl->fl_xid;
6375 locks_copy_private(new, fl);
6377 @@ -282,6 +289,11 @@ static int flock_make_lock(struct file *
6378 fl->fl_flags = FL_FLOCK;
6380 fl->fl_end = OFFSET_MAX;
6382 + vxd_assert(filp->f_xid == vx_current_xid(),
6383 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6384 + fl->fl_xid = filp->f_xid;
6389 @@ -447,6 +459,7 @@ static int lease_init(struct file *filp,
6391 fl->fl_owner = current->files;
6392 fl->fl_pid = current->tgid;
6393 + fl->fl_xid = vx_current_xid();
6396 fl->fl_flags = FL_LEASE;
6397 @@ -466,6 +479,11 @@ static int lease_alloc(struct file *filp
6401 + fl->fl_xid = vx_current_xid();
6403 + vxd_assert(filp->f_xid == fl->fl_xid,
6404 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6406 error = lease_init(filp, type, fl);
6408 locks_free_lock(fl);
6409 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
6413 + new_fl->fl_xid = -1;
6415 for_each_lock(inode, before) {
6416 struct file_lock *fl = *before;
6417 @@ -787,6 +806,7 @@ find_conflict:
6419 locks_copy_lock(new_fl, request);
6420 locks_insert_lock(before, new_fl);
6421 + vx_locks_inc(new_fl);
6425 @@ -797,7 +817,8 @@ out:
6429 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6430 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6431 + struct file_lock *conflock, xid_t xid)
6433 struct file_lock *fl;
6434 struct file_lock *new_fl = NULL;
6435 @@ -807,6 +828,8 @@ static int __posix_lock_file(struct inod
6436 struct file_lock **before;
6437 int error, added = 0;
6439 + vxd_assert(xid == vx_current_xid(),
6440 + "xid(%d) == current(%d)", xid, vx_current_xid());
6442 * We may need two file_lock structures for this operation,
6443 * so we get them in advance to avoid races.
6444 @@ -817,7 +840,11 @@ static int __posix_lock_file(struct inod
6445 (request->fl_type != F_UNLCK ||
6446 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6447 new_fl = locks_alloc_lock();
6448 + new_fl->fl_xid = xid;
6449 + vx_locks_inc(new_fl);
6450 new_fl2 = locks_alloc_lock();
6451 + new_fl2->fl_xid = xid;
6452 + vx_locks_inc(new_fl2);
6456 @@ -1016,7 +1043,8 @@ static int __posix_lock_file(struct inod
6457 int posix_lock_file(struct file *filp, struct file_lock *fl,
6458 struct file_lock *conflock)
6460 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6461 + return __posix_lock_file(filp->f_path.dentry->d_inode,
6462 + fl, conflock, filp->f_xid);
6464 EXPORT_SYMBOL(posix_lock_file);
6466 @@ -1106,7 +1134,7 @@ int locks_mandatory_area(int read_write,
6467 fl.fl_end = offset + count - 1;
6470 - error = __posix_lock_file(inode, &fl, NULL);
6471 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6472 if (error != -EAGAIN)
6474 if (!(fl.fl_flags & FL_SLEEP))
6475 @@ -1410,8 +1438,8 @@ static int __setlease(struct file *filp,
6478 locks_copy_lock(fl, lease);
6480 locks_insert_lock(before, fl);
6485 @@ -1738,6 +1766,11 @@ int fcntl_setlk(unsigned int fd, struct
6486 if (file_lock == NULL)
6489 + vxd_assert(filp->f_xid == vx_current_xid(),
6490 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6491 + file_lock->fl_xid = filp->f_xid;
6492 + vx_locks_inc(file_lock);
6495 * This might block, so we do it before checking the inode.
6497 @@ -1864,6 +1897,11 @@ int fcntl_setlk64(unsigned int fd, struc
6498 if (file_lock == NULL)
6501 + vxd_assert(filp->f_xid == vx_current_xid(),
6502 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6503 + file_lock->fl_xid = filp->f_xid;
6504 + vx_locks_inc(file_lock);
6507 * This might block, so we do it before checking the inode.
6509 @@ -2168,6 +2206,10 @@ int get_locks_status(char *buffer, char
6510 list_for_each(tmp, &file_lock_list) {
6511 struct list_head *btmp;
6512 struct file_lock *fl = list_entry(tmp, struct file_lock, fl_link);
6514 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6517 lock_get_status(q, fl, ++i, "");
6518 move_lock_status(&q, &pos, offset);
6520 diff -NurpP --minimal linux-2.6.22.10/fs/namei.c linux-2.6.22.10-vs2.3.0.29/fs/namei.c
6521 --- linux-2.6.22.10/fs/namei.c 2007-07-09 13:19:27 +0200
6522 +++ linux-2.6.22.10-vs2.3.0.29/fs/namei.c 2007-10-29 23:41:56 +0100
6524 #include <linux/file.h>
6525 #include <linux/fcntl.h>
6526 #include <linux/namei.h>
6527 +#include <linux/proc_fs.h>
6528 +#include <linux/vserver/inode.h>
6529 +#include <linux/vs_base.h>
6530 +#include <linux/vs_tag.h>
6531 +#include <linux/vs_cowbl.h>
6532 +#include <linux/vs_device.h>
6533 +#include <linux/vs_context.h>
6534 #include <asm/namei.h>
6535 #include <asm/uaccess.h>
6537 @@ -224,6 +231,28 @@ int generic_permission(struct inode *ino
6541 +static inline int dx_barrier(struct inode *inode)
6543 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN)) {
6544 + vxwprintk_task(1, "did hit the barrier.");
6550 +static inline int dx_permission(struct inode *inode, int mask, struct nameidata *nd)
6552 + if (dx_barrier(inode))
6554 + if (dx_notagcheck(nd) ||
6555 + dx_check(inode->i_tag, DX_HOSTID|DX_ADMIN|DX_WATCH|DX_IDENT))
6558 + vxwprintk_task(1, "denied access to %p[#%d,%lu] »%s«.",
6559 + inode, inode->i_tag, inode->i_ino, vxd_cond_path(nd));
6563 int permission(struct inode *inode, int mask, struct nameidata *nd)
6565 umode_t mode = inode->i_mode;
6566 @@ -234,14 +263,14 @@ int permission(struct inode *inode, int
6568 * Nobody gets write access to a read-only fs.
6570 - if (IS_RDONLY(inode) &&
6571 + if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
6572 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
6576 * Nobody gets write access to an immutable file.
6578 - if (IS_IMMUTABLE(inode))
6579 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6583 @@ -257,6 +286,12 @@ int permission(struct inode *inode, int
6585 /* Ordinary permission routines do not understand MAY_APPEND. */
6586 submask = mask & ~MAY_APPEND;
6588 + if ((inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC) &&
6589 + (inode->i_sb->s_magic != PROC_SUPER_MAGIC) &&
6590 + (retval = dx_permission(inode, mask, nd)))
6593 if (inode->i_op && inode->i_op->permission)
6594 retval = inode->i_op->permission(inode, submask, nd);
6596 @@ -432,6 +467,8 @@ static int exec_permission_lite(struct i
6598 umode_t mode = inode->i_mode;
6600 + if (dx_barrier(inode))
6602 if (inode->i_op && inode->i_op->permission)
6605 @@ -732,7 +769,8 @@ static __always_inline void follow_dotdo
6606 if (nd->dentry == fs->root &&
6607 nd->mnt == fs->rootmnt) {
6608 read_unlock(&fs->lock);
6610 + /* for sane '/' avoid follow_mount() */
6613 read_unlock(&fs->lock);
6614 spin_lock(&dcache_lock);
6615 @@ -769,16 +807,39 @@ static int do_lookup(struct nameidata *n
6617 struct vfsmount *mnt = nd->mnt;
6618 struct dentry *dentry = __d_lookup(nd->dentry, name);
6619 + struct inode *inode;
6623 if (dentry->d_op && dentry->d_op->d_revalidate)
6624 goto need_revalidate;
6625 + inode = dentry->d_inode;
6629 + if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6630 + struct proc_dir_entry *de = PDE(inode);
6632 + if (de && !vx_hide_check(0, de->vx_flags))
6634 + } else if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6635 + if (!vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
6638 + if (!dx_notagcheck(nd) && !dx_check(inode->i_tag,
6639 + DX_WATCH | DX_ADMIN | DX_HOSTID | DX_IDENT))
6644 path->dentry = dentry;
6645 __follow_mount(path);
6648 + vxwprintk_task(1, "did lookup hidden %p[#%d,%lu] »%s«.",
6649 + inode, inode->i_tag, inode->i_ino, vxd_path(dentry, mnt));
6654 dentry = real_lookup(nd->dentry, name, nd);
6655 @@ -1399,7 +1460,8 @@ static inline int check_sticky(struct in
6656 * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
6657 * nfs_async_unlink().
6659 -static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
6660 +static int may_delete(struct inode *dir, struct dentry *victim,
6661 + int isdir, struct nameidata *nd)
6665 @@ -1409,13 +1471,13 @@ static int may_delete(struct inode *dir,
6666 BUG_ON(victim->d_parent->d_inode != dir);
6667 audit_inode_child(victim->d_name.name, victim->d_inode, dir);
6669 - error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
6670 + error = permission(dir,MAY_WRITE | MAY_EXEC, nd);
6675 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6676 - IS_IMMUTABLE(victim->d_inode))
6677 + IS_IXORUNLINK(victim->d_inode))
6680 if (!S_ISDIR(victim->d_inode->i_mode))
6681 @@ -1546,6 +1608,14 @@ int may_open(struct nameidata *nd, int a
6682 if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE))
6685 +#ifdef CONFIG_VSERVER_COWBL
6686 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
6687 + if (IS_COW_LINK(inode))
6689 + inode->i_flags &= ~(S_IUNLINK|S_IMMUTABLE);
6690 + mark_inode_dirty(inode);
6693 error = vfs_permission(nd, acc_mode);
6696 @@ -1562,7 +1632,8 @@ int may_open(struct nameidata *nd, int a
6700 - } else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
6701 + } else if ((IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
6702 + && (flag & FMODE_WRITE))
6705 * An append-only file must be opened in append mode for writing.
6706 @@ -1650,6 +1721,11 @@ int open_namei(int dfd, const char *path
6710 +#ifdef CONFIG_VSERVER_COWBL
6715 acc_mode = ACC_MODE(flag);
6717 /* O_TRUNC implies we need access checks for write permissions */
6718 @@ -1743,6 +1819,22 @@ do_last:
6721 error = may_open(nd, acc_mode, flag);
6722 +#ifdef CONFIG_VSERVER_COWBL
6723 + if (error == -EMLINK) {
6724 + struct dentry *dentry;
6725 + dentry = cow_break_link(pathname);
6726 + if (IS_ERR(dentry)) {
6727 + error = PTR_ERR(dentry);
6731 + release_open_intent(nd);
6741 @@ -1854,16 +1946,25 @@ fail:
6743 EXPORT_SYMBOL_GPL(lookup_create);
6745 -int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
6746 +int vfs_mknod(struct inode *dir, struct dentry *dentry,
6747 + int mode, dev_t dev, struct nameidata *nd)
6749 - int error = may_create(dir, dentry, NULL);
6750 + int error = may_create(dir, dentry, nd);
6755 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
6756 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
6759 + if (!capable(CAP_MKNOD))
6762 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
6764 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
6767 if (!dir->i_op || !dir->i_op->mknod)
6770 @@ -1906,11 +2007,12 @@ asmlinkage long sys_mknodat(int dfd, con
6771 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
6773 case S_IFCHR: case S_IFBLK:
6774 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
6775 - new_decode_dev(dev));
6776 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6777 + new_decode_dev(dev), &nd);
6779 case S_IFIFO: case S_IFSOCK:
6780 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
6781 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6786 @@ -1933,9 +2035,10 @@ asmlinkage long sys_mknod(const char __u
6787 return sys_mknodat(AT_FDCWD, filename, mode, dev);
6790 -int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
6791 +int vfs_mkdir(struct inode *dir, struct dentry *dentry,
6792 + int mode, struct nameidata *nd)
6794 - int error = may_create(dir, dentry, NULL);
6795 + int error = may_create(dir, dentry, nd);
6799 @@ -1977,7 +2080,7 @@ asmlinkage long sys_mkdirat(int dfd, con
6801 if (!IS_POSIXACL(nd.dentry->d_inode))
6802 mode &= ~current->fs->umask;
6803 - error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
6804 + error = vfs_mkdir(nd.dentry->d_inode, dentry, mode, &nd);
6807 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6808 @@ -2020,9 +2123,10 @@ void dentry_unhash(struct dentry *dentry
6809 spin_unlock(&dcache_lock);
6812 -int vfs_rmdir(struct inode *dir, struct dentry *dentry)
6813 +int vfs_rmdir(struct inode *dir, struct dentry *dentry,
6814 + struct nameidata *nd)
6816 - int error = may_delete(dir, dentry, 1);
6817 + int error = may_delete(dir, dentry, 1, nd);
6821 @@ -2084,7 +2188,7 @@ static long do_rmdir(int dfd, const char
6822 error = PTR_ERR(dentry);
6825 - error = vfs_rmdir(nd.dentry->d_inode, dentry);
6826 + error = vfs_rmdir(nd.dentry->d_inode, dentry, &nd);
6829 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6830 @@ -2100,9 +2204,10 @@ asmlinkage long sys_rmdir(const char __u
6831 return do_rmdir(AT_FDCWD, pathname);
6834 -int vfs_unlink(struct inode *dir, struct dentry *dentry)
6835 +int vfs_unlink(struct inode *dir, struct dentry *dentry,
6836 + struct nameidata *nd)
6838 - int error = may_delete(dir, dentry, 0);
6839 + int error = may_delete(dir, dentry, 0, nd);
6843 @@ -2164,7 +2269,7 @@ static long do_unlinkat(int dfd, const c
6844 inode = dentry->d_inode;
6846 atomic_inc(&inode->i_count);
6847 - error = vfs_unlink(nd.dentry->d_inode, dentry);
6848 + error = vfs_unlink(nd.dentry->d_inode, dentry, &nd);
6852 @@ -2199,9 +2304,10 @@ asmlinkage long sys_unlink(const char __
6853 return do_unlinkat(AT_FDCWD, pathname);
6856 -int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode)
6857 +int vfs_symlink(struct inode *dir, struct dentry *dentry,
6858 + const char *oldname, int mode, struct nameidata *nd)
6860 - int error = may_create(dir, dentry, NULL);
6861 + int error = may_create(dir, dentry, nd);
6865 @@ -2245,7 +2351,7 @@ asmlinkage long sys_symlinkat(const char
6869 - error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
6870 + error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO, &nd);
6873 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6874 @@ -2262,7 +2368,8 @@ asmlinkage long sys_symlink(const char _
6875 return sys_symlinkat(oldname, AT_FDCWD, newname);
6878 -int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
6879 +int vfs_link(struct dentry *old_dentry, struct inode *dir,
6880 + struct dentry *new_dentry, struct nameidata *nd)
6882 struct inode *inode = old_dentry->d_inode;
6884 @@ -2270,7 +2377,7 @@ int vfs_link(struct dentry *old_dentry,
6888 - error = may_create(dir, new_dentry, NULL);
6889 + error = may_create(dir, new_dentry, nd);
6893 @@ -2280,7 +2387,7 @@ int vfs_link(struct dentry *old_dentry,
6895 * A link to an append-only or immutable file cannot be created.
6897 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6898 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6900 if (!dir->i_op || !dir->i_op->link)
6902 @@ -2340,7 +2447,7 @@ asmlinkage long sys_linkat(int olddfd, c
6903 error = PTR_ERR(new_dentry);
6904 if (IS_ERR(new_dentry))
6906 - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
6907 + error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry, &nd);
6910 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6911 @@ -2472,14 +2579,14 @@ int vfs_rename(struct inode *old_dir, st
6912 if (old_dentry->d_inode == new_dentry->d_inode)
6915 - error = may_delete(old_dir, old_dentry, is_dir);
6916 + error = may_delete(old_dir, old_dentry, is_dir, NULL);
6920 if (!new_dentry->d_inode)
6921 error = may_create(new_dir, new_dentry, NULL);
6923 - error = may_delete(new_dir, new_dentry, is_dir);
6924 + error = may_delete(new_dir, new_dentry, is_dir, NULL);
6928 @@ -2557,6 +2664,9 @@ static int do_rename(int olddfd, const c
6930 if (old_dentry == trap)
6933 + if (MNT_IS_RDONLY(newnd.mnt))
6935 new_dentry = lookup_hash(&newnd);
6936 error = PTR_ERR(new_dentry);
6937 if (IS_ERR(new_dentry))
6938 @@ -2650,6 +2760,216 @@ int vfs_follow_link(struct nameidata *nd
6939 return __vfs_follow_link(nd, link);
6943 +#ifdef CONFIG_VSERVER_COWBL
6945 +#include <linux/file.h>
6948 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6952 + return do_splice_direct(in, &ppos, out, len, 0);
6955 +struct dentry *cow_break_link(const char *pathname)
6957 + int ret, mode, pathlen, redo = 0;
6958 + struct nameidata old_nd, dir_nd;
6959 + struct dentry *old_dentry, *new_dentry;
6960 + struct dentry *dir, *res = NULL;
6961 + struct vfsmount *old_mnt, *new_mnt;
6962 + struct file *old_file;
6963 + struct file *new_file;
6964 + char *to, *path, pad='\251';
6967 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6968 + path = kmalloc(PATH_MAX, GFP_KERNEL);
6973 + /* old_nd will have refs to dentry and mnt */
6974 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6975 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6977 + goto out_free_path;
6979 + old_dentry = old_nd.dentry;
6980 + old_mnt = old_nd.mnt;
6981 + mode = old_dentry->d_inode->i_mode;
6983 + to = d_path(old_dentry, old_mnt, path, PATH_MAX-2);
6984 + pathlen = strlen(to);
6985 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
6986 + old_dentry->d_name.len, old_dentry->d_name.name,
6987 + old_dentry->d_name.len);
6989 + to[pathlen + 1] = 0;
6991 + to[pathlen] = pad--;
6993 + if (pad <= '\240')
6996 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
6997 + /* dir_nd will have refs to dentry and mnt */
6998 + ret = path_lookup(to,
6999 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
7000 + vxdprintk(VXD_CBIT(misc, 2),
7001 + "path_lookup(new): %d", ret);
7005 + /* this puppy downs the inode mutex */
7006 + new_dentry = lookup_create(&dir_nd, 0);
7007 + vxdprintk(VXD_CBIT(misc, 2),
7008 + "lookup_create(new): %p [»%.*s«:%d]", new_dentry,
7009 + new_dentry->d_name.len, new_dentry->d_name.name,
7010 + new_dentry->d_name.len);
7011 + if (!new_dentry || IS_ERR(new_dentry)) {
7012 + path_release(&dir_nd);
7015 + dir = dir_nd.dentry;
7017 + ret = vfs_create(dir_nd.dentry->d_inode, new_dentry, mode, &dir_nd);
7018 + vxdprintk(VXD_CBIT(misc, 2),
7019 + "vfs_create(new): %d", ret);
7020 + if (ret == -EEXIST) {
7021 + mutex_unlock(&dir->d_inode->i_mutex);
7023 + path_release(&dir_nd);
7027 + goto out_unlock_new;
7029 + /* drop out early, ret passes ENOENT */
7031 + if ((redo = d_unhashed(old_dentry)))
7032 + goto out_unlock_new;
7034 + new_mnt = dir_nd.mnt;
7037 + /* this one cleans up the dentry/mnt in case of failure */
7038 + old_file = dentry_open(old_dentry, old_mnt, O_RDONLY);
7039 + vxdprintk(VXD_CBIT(misc, 2),
7040 + "dentry_open(old): %p", old_file);
7041 + if (!old_file || IS_ERR(old_file)) {
7042 + res = IS_ERR(old_file) ? (void *) old_file : res;
7043 + goto out_unlock_new;
7048 + /* this one cleans up the dentry/mnt in case of failure */
7049 + new_file = dentry_open(new_dentry, new_mnt, O_WRONLY);
7050 + vxdprintk(VXD_CBIT(misc, 2),
7051 + "dentry_open(new): %p", new_file);
7053 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
7054 + if (!new_file || IS_ERR(new_file))
7055 + goto out_fput_old;
7057 + size = i_size_read(old_file->f_dentry->d_inode);
7058 + ret = do_cow_splice(old_file, new_file, size);
7059 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
7061 + goto out_fput_both;
7062 + } else if (ret < size) {
7064 + goto out_fput_both;
7066 + struct inode *old_inode = old_dentry->d_inode;
7067 + struct inode *new_inode = new_dentry->d_inode;
7068 + struct iattr attr = {
7069 + .ia_uid = old_inode->i_uid,
7070 + .ia_gid = old_inode->i_gid,
7071 + .ia_valid = ATTR_UID | ATTR_GID
7074 + ret = inode_setattr(new_inode, &attr);
7076 + goto out_fput_both;
7079 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
7081 + /* drop out late */
7083 + if ((redo = d_unhashed(old_dentry)))
7086 + vxdprintk(VXD_CBIT(misc, 2),
7087 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
7088 + new_dentry->d_name.len, new_dentry->d_name.name,
7089 + new_dentry->d_name.len,
7090 + old_dentry->d_name.len, old_dentry->d_name.name,
7091 + old_dentry->d_name.len);
7092 + ret = vfs_rename(dir_nd.dentry->d_inode, new_dentry,
7093 + old_nd.dentry->d_parent->d_inode, old_dentry);
7094 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
7098 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
7101 + vxdprintk(VXD_CBIT(misc, 3),
7102 + "fput(new_file=%p[#%d])", new_file,
7103 + atomic_read(&new_file->f_count));
7107 + vxdprintk(VXD_CBIT(misc, 3),
7108 + "fput(old_file=%p[#%d])", old_file,
7109 + atomic_read(&old_file->f_count));
7113 + mutex_unlock(&dir->d_inode->i_mutex);
7117 + /* error path cleanup */
7118 + vfs_unlink(dir->d_inode, new_dentry, &dir_nd);
7123 + goto out_rel_both;
7124 + /* lookup dentry once again */
7125 + path_release(&old_nd);
7126 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
7128 + goto out_rel_both;
7130 + new_dentry = old_nd.dentry;
7131 + vxdprintk(VXD_CBIT(misc, 2),
7132 + "path_lookup(redo): %p [»%.*s«:%d]", new_dentry,
7133 + new_dentry->d_name.len, new_dentry->d_name.name,
7134 + new_dentry->d_name.len);
7139 + path_release(&dir_nd);
7141 + path_release(&old_nd);
7146 + res = ERR_PTR(ret);
7152 /* get the link contents into pagecache */
7153 static char *page_getlink(struct dentry * dentry, struct page **ppage)
7155 diff -NurpP --minimal linux-2.6.22.10/fs/namespace.c linux-2.6.22.10-vs2.3.0.29/fs/namespace.c
7156 --- linux-2.6.22.10/fs/namespace.c 2007-07-09 13:19:27 +0200
7157 +++ linux-2.6.22.10-vs2.3.0.29/fs/namespace.c 2007-09-05 02:29:17 +0200
7159 #include <linux/security.h>
7160 #include <linux/mount.h>
7161 #include <linux/ramfs.h>
7162 +#include <linux/vs_base.h>
7163 +#include <linux/vs_context.h>
7164 +#include <linux/vs_tag.h>
7165 +#include <linux/vserver/space.h>
7166 +#include <linux/vserver/global.h>
7167 #include <asm/uaccess.h>
7168 #include <asm/unistd.h>
7170 @@ -240,6 +245,7 @@ static struct vfsmount *clone_mnt(struct
7171 mnt->mnt_root = dget(root);
7172 mnt->mnt_mountpoint = mnt->mnt_root;
7173 mnt->mnt_parent = mnt;
7174 + mnt->mnt_tag = old->mnt_tag;
7176 if (flag & CL_SLAVE) {
7177 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
7178 @@ -348,48 +354,91 @@ static inline void mangle(struct seq_fil
7179 seq_escape(m, s, " \t\n\\");
7182 +static int mnt_is_reachable(struct vfsmount *mnt)
7184 + struct vfsmount *root_mnt;
7185 + struct dentry *root, *point;
7188 + if (mnt == mnt->mnt_ns->root)
7191 + spin_lock(&vfsmount_lock);
7192 + root_mnt = current->fs->rootmnt;
7193 + root = current->fs->root;
7196 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
7197 + point = mnt->mnt_mountpoint;
7198 + mnt = mnt->mnt_parent;
7201 + ret = (mnt == root_mnt) && is_subdir(point, root);
7203 + spin_unlock(&vfsmount_lock);
7208 static int show_vfsmnt(struct seq_file *m, void *v)
7210 struct vfsmount *mnt = v;
7212 static struct proc_fs_info {
7220 - { MS_SYNCHRONOUS, ",sync" },
7221 - { MS_DIRSYNC, ",dirsync" },
7222 - { MS_MANDLOCK, ",mand" },
7225 - static struct proc_fs_info mnt_info[] = {
7226 - { MNT_NOSUID, ",nosuid" },
7227 - { MNT_NODEV, ",nodev" },
7228 - { MNT_NOEXEC, ",noexec" },
7229 - { MNT_NOATIME, ",noatime" },
7230 - { MNT_NODIRATIME, ",nodiratime" },
7231 - { MNT_RELATIME, ",relatime" },
7233 + { MS_RDONLY, MNT_RDONLY, "ro", "rw" },
7234 + { MS_SYNCHRONOUS, 0, ",sync", NULL },
7235 + { MS_DIRSYNC, 0, ",dirsync", NULL },
7236 + { MS_MANDLOCK, 0, ",mand", NULL },
7237 + { MS_TAGGED, 0, ",tag", NULL },
7238 + { MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
7239 + { MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
7240 + { MS_RELATIME, MNT_RELATIME, ",relatime", NULL },
7241 + { 0, MNT_NOSUID, ",nosuid", NULL },
7242 + { 0, MNT_NODEV, ",nodev", NULL },
7243 + { 0, MNT_NOEXEC, ",noexec", NULL },
7244 + { 0, 0, NULL, NULL }
7246 - struct proc_fs_info *fs_infop;
7247 + struct proc_fs_info *p;
7248 + unsigned long s_flags = mnt->mnt_sb->s_flags;
7249 + int mnt_flags = mnt->mnt_flags;
7251 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7253 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7255 - mangle(m, mnt->mnt_sb->s_type->name);
7256 - if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
7258 - mangle(m, mnt->mnt_sb->s_subtype);
7260 - seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
7261 - for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
7262 - if (mnt->mnt_sb->s_flags & fs_infop->flag)
7263 - seq_puts(m, fs_infop->str);
7264 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7266 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7269 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7270 + mnt == current->fs->rootmnt) {
7271 + seq_puts(m, "/dev/root / ");
7273 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7275 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7278 + if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
7280 + mangle(m, mnt->mnt_sb->s_subtype);
7283 - for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
7284 - if (mnt->mnt_flags & fs_infop->flag)
7285 - seq_puts(m, fs_infop->str);
7286 + mangle(m, mnt->mnt_sb->s_type->name);
7288 + for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
7289 + if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
7291 + seq_puts(m, p->set_str);
7294 + seq_puts(m, p->unset_str);
7297 + if (mnt->mnt_flags & MNT_TAGID)
7298 + seq_printf(m, ",tag=%d", mnt->mnt_tag);
7299 if (mnt->mnt_sb->s_op->show_options)
7300 err = mnt->mnt_sb->s_op->show_options(m, mnt);
7301 seq_puts(m, " 0 0\n");
7302 @@ -408,17 +457,27 @@ static int show_vfsstat(struct seq_file
7303 struct vfsmount *mnt = v;
7307 - if (mnt->mnt_devname) {
7308 - seq_puts(m, "device ");
7309 - mangle(m, mnt->mnt_devname);
7311 - seq_puts(m, "no device");
7312 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7314 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7318 - seq_puts(m, " mounted on ");
7319 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7321 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7322 + mnt == current->fs->rootmnt) {
7323 + seq_puts(m, "device /dev/root mounted on / ");
7326 + if (mnt->mnt_devname) {
7327 + seq_puts(m, "device ");
7328 + mangle(m, mnt->mnt_devname);
7330 + seq_puts(m, "no device");
7333 + seq_puts(m, " mounted on ");
7334 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7338 /* file system type */
7339 seq_puts(m, "with fstype ");
7340 @@ -648,7 +707,7 @@ asmlinkage long sys_umount(char __user *
7344 - if (!capable(CAP_SYS_ADMIN))
7345 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7348 retval = do_umount(nd.mnt, flags);
7349 @@ -672,7 +731,7 @@ asmlinkage long sys_oldumount(char __use
7351 static int mount_is_safe(struct nameidata *nd)
7353 - if (capable(CAP_SYS_ADMIN))
7354 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7358 @@ -904,11 +963,13 @@ static int do_change_type(struct nameida
7360 * do loopback mount.
7362 -static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
7363 +static int do_loopback(struct nameidata *nd, char *old_name, tag_t tag,
7364 + unsigned long flags, int mnt_flags)
7366 struct nameidata old_nd;
7367 struct vfsmount *mnt = NULL;
7368 int err = mount_is_safe(nd);
7369 + int recurse = flags & MS_REC;
7372 if (!old_name || !*old_name)
7373 @@ -934,6 +995,12 @@ static int do_loopback(struct nameidata
7377 + mnt->mnt_flags = mnt_flags;
7378 + if (flags & MS_TAGID) {
7379 + mnt->mnt_tag = tag;
7380 + mnt->mnt_flags |= MNT_TAGID;
7383 err = graft_tree(mnt, nd);
7385 LIST_HEAD(umount_list);
7386 @@ -942,6 +1009,7 @@ static int do_loopback(struct nameidata
7387 spin_unlock(&vfsmount_lock);
7388 release_mounts(&umount_list);
7390 + mnt->mnt_flags = mnt_flags;
7393 up_write(&namespace_sem);
7394 @@ -955,12 +1023,12 @@ out:
7395 * on it - tough luck.
7397 static int do_remount(struct nameidata *nd, int flags, int mnt_flags,
7399 + void *data, xid_t xid)
7402 struct super_block *sb = nd->mnt->mnt_sb;
7404 - if (!capable(CAP_SYS_ADMIN))
7405 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7408 if (!check_mnt(nd->mnt))
7409 @@ -994,7 +1062,7 @@ static int do_move_mount(struct nameidat
7410 struct nameidata old_nd, parent_nd;
7413 - if (!capable(CAP_SYS_ADMIN))
7414 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7416 if (!old_name || !*old_name)
7418 @@ -1074,7 +1142,7 @@ static int do_new_mount(struct nameidata
7421 /* we need capabilities... */
7422 - if (!capable(CAP_SYS_ADMIN))
7423 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7426 mnt = do_kern_mount(type, flags, name, data);
7427 @@ -1386,6 +1454,7 @@ long do_mount(char *dev_name, char *dir_
7428 struct nameidata nd;
7434 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7435 @@ -1401,7 +1470,17 @@ long do_mount(char *dev_name, char *dir_
7437 ((char *)data_page)[PAGE_SIZE - 1] = 0;
7439 + retval = dx_parse_tag(data_page, &tag, 1);
7441 + mnt_flags |= retval;
7442 + /* FIXME: bind and re-mounts get the tag flag? */
7443 + if (flags & (MS_BIND|MS_REMOUNT))
7444 + flags |= MS_TAGID;
7447 /* Separate the per-mountpoint flags */
7448 + if (flags & MS_RDONLY)
7449 + mnt_flags |= MNT_RDONLY;
7450 if (flags & MS_NOSUID)
7451 mnt_flags |= MNT_NOSUID;
7452 if (flags & MS_NODEV)
7453 @@ -1415,6 +1494,8 @@ long do_mount(char *dev_name, char *dir_
7454 if (flags & MS_RELATIME)
7455 mnt_flags |= MNT_RELATIME;
7457 + if (!capable(CAP_SYS_ADMIN))
7458 + mnt_flags |= MNT_NODEV;
7459 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
7460 MS_NOATIME | MS_NODIRATIME | MS_RELATIME);
7462 @@ -1429,9 +1510,9 @@ long do_mount(char *dev_name, char *dir_
7464 if (flags & MS_REMOUNT)
7465 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
7468 else if (flags & MS_BIND)
7469 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
7470 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
7471 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7472 retval = do_change_type(&nd, flags);
7473 else if (flags & MS_MOVE)
7474 @@ -1504,6 +1585,7 @@ static struct mnt_namespace *dup_mnt_ns(
7475 q = next_mnt(q, new_ns->root);
7477 up_write(&namespace_sem);
7478 + atomic_inc(&vs_global_mnt_ns);
7482 @@ -1866,5 +1948,6 @@ void __put_mnt_ns(struct mnt_namespace *
7483 spin_unlock(&vfsmount_lock);
7484 up_write(&namespace_sem);
7485 release_mounts(&umount_list);
7486 + atomic_dec(&vs_global_mnt_ns);
7489 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/client.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/client.c
7490 --- linux-2.6.22.10/fs/nfs/client.c 2007-07-09 13:19:27 +0200
7491 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/client.c 2007-08-05 20:53:13 +0200
7492 @@ -521,6 +521,9 @@ static int nfs_init_server_rpcclient(str
7493 if (server->flags & NFS4_MOUNT_INTR)
7494 server->client->cl_intr = 1;
7496 + server->client->cl_tag = 0;
7497 + if (server->flags & NFS_MOUNT_TAGGED)
7498 + server->client->cl_tag = 1;
7502 @@ -678,6 +681,10 @@ static void nfs_server_set_fsinfo(struct
7503 server->acdirmin = server->acdirmax = 0;
7506 + /* FIXME: needs fsinfo
7507 + if (server->flags & NFS_MOUNT_TAGGED)
7508 + sb->s_flags |= MS_TAGGED; */
7510 server->maxfilesize = fsinfo->maxfilesize;
7512 /* We're airborne Set socket buffersize */
7513 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/dir.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/dir.c
7514 --- linux-2.6.22.10/fs/nfs/dir.c 2007-07-09 13:19:27 +0200
7515 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/dir.c 2007-08-05 20:53:13 +0200
7517 #include <linux/namei.h>
7518 #include <linux/mount.h>
7519 #include <linux/sched.h>
7520 +#include <linux/vs_tag.h>
7522 #include "nfs4_fs.h"
7523 #include "delegation.h"
7524 @@ -956,6 +957,7 @@ static struct dentry *nfs_lookup(struct
7528 + dx_propagate_tag(nd, inode);
7530 res = d_materialise_unique(dentry, inode);
7532 @@ -998,7 +1000,8 @@ static int is_atomic_open(struct inode *
7533 if (nd->flags & LOOKUP_DIRECTORY)
7535 /* Are we trying to write to a read only partition? */
7536 - if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7537 + if ((IS_RDONLY(dir) || MNT_IS_RDONLY(nd->mnt)) &&
7538 + (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7542 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/inode.c
7543 --- linux-2.6.22.10/fs/nfs/inode.c 2007-07-09 13:19:27 +0200
7544 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/inode.c 2007-08-05 20:53:13 +0200
7546 #include <linux/vfs.h>
7547 #include <linux/inet.h>
7548 #include <linux/nfs_xdr.h>
7549 +#include <linux/vs_tag.h>
7551 #include <asm/system.h>
7552 #include <asm/uaccess.h>
7553 @@ -285,8 +286,10 @@ nfs_fhget(struct super_block *sb, struct
7554 nfsi->change_attr = fattr->change_attr;
7555 inode->i_size = nfs_size_to_loff_t(fattr->size);
7556 inode->i_nlink = fattr->nlink;
7557 - inode->i_uid = fattr->uid;
7558 - inode->i_gid = fattr->gid;
7559 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7560 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7561 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7562 + /* maybe fattr->xid someday */
7563 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7565 * report the blocks in 512byte units
7566 @@ -377,6 +380,8 @@ void nfs_setattr_update_inode(struct ino
7567 inode->i_uid = attr->ia_uid;
7568 if ((attr->ia_valid & ATTR_GID) != 0)
7569 inode->i_gid = attr->ia_gid;
7570 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7571 + inode->i_tag = attr->ia_tag;
7572 spin_lock(&inode->i_lock);
7573 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7574 spin_unlock(&inode->i_lock);
7575 @@ -825,6 +830,9 @@ static int nfs_check_inode_attributes(st
7576 struct nfs_inode *nfsi = NFS_I(inode);
7577 loff_t cur_size, new_isize;
7584 /* Has the inode gone and changed behind our back? */
7585 @@ -852,10 +860,15 @@ static int nfs_check_inode_attributes(st
7586 if (cur_size != new_isize && nfsi->npages == 0)
7587 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7589 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7590 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7591 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7593 /* Have any file permissions changed? */
7594 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
7595 - || inode->i_uid != fattr->uid
7596 - || inode->i_gid != fattr->gid)
7597 + || inode->i_uid != uid
7598 + || inode->i_gid != gid
7599 + || inode->i_tag != tag)
7600 nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7602 /* Has the link count changed? */
7603 @@ -946,6 +959,9 @@ static int nfs_update_inode(struct inode
7604 unsigned int invalid = 0;
7605 unsigned long now = jiffies;
7611 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7612 __FUNCTION__, inode->i_sb->s_id, inode->i_ino,
7613 @@ -1022,15 +1038,21 @@ static int nfs_update_inode(struct inode
7615 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7617 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7618 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7619 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7621 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
7622 - inode->i_uid != fattr->uid ||
7623 - inode->i_gid != fattr->gid)
7624 + inode->i_uid != uid ||
7625 + inode->i_gid != gid ||
7626 + inode->i_tag != tag)
7627 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7629 inode->i_mode = fattr->mode;
7630 inode->i_nlink = fattr->nlink;
7631 - inode->i_uid = fattr->uid;
7632 - inode->i_gid = fattr->gid;
7633 + inode->i_uid = uid;
7634 + inode->i_gid = gid;
7635 + inode->i_tag = tag;
7637 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7639 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/nfs3xdr.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/nfs3xdr.c
7640 --- linux-2.6.22.10/fs/nfs/nfs3xdr.c 2007-07-09 13:19:27 +0200
7641 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/nfs3xdr.c 2007-08-05 20:53:13 +0200
7643 #include <linux/nfs3.h>
7644 #include <linux/nfs_fs.h>
7645 #include <linux/nfsacl.h>
7646 +#include <linux/vs_tag.h>
7647 #include "internal.h"
7649 #define NFSDBG_FACILITY NFSDBG_XDR
7650 @@ -178,7 +179,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7653 static inline __be32 *
7654 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7655 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7657 if (attr->ia_valid & ATTR_MODE) {
7659 @@ -186,15 +187,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7663 - if (attr->ia_valid & ATTR_UID) {
7664 + if (attr->ia_valid & ATTR_UID ||
7665 + (tag && (attr->ia_valid & ATTR_TAG))) {
7667 - *p++ = htonl(attr->ia_uid);
7668 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7672 - if (attr->ia_valid & ATTR_GID) {
7673 + if (attr->ia_valid & ATTR_GID ||
7674 + (tag && (attr->ia_valid & ATTR_TAG))) {
7676 - *p++ = htonl(attr->ia_gid);
7677 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7681 @@ -279,7 +282,8 @@ static int
7682 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7684 p = xdr_encode_fhandle(p, args->fh);
7685 - p = xdr_encode_sattr(p, args->sattr);
7686 + p = xdr_encode_sattr(p, args->sattr,
7687 + req->rq_task->tk_client->cl_tag);
7688 *p++ = htonl(args->guard);
7690 p = xdr_encode_time3(p, &args->guardtime);
7691 @@ -370,7 +374,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7692 *p++ = args->verifier[0];
7693 *p++ = args->verifier[1];
7695 - p = xdr_encode_sattr(p, args->sattr);
7696 + p = xdr_encode_sattr(p, args->sattr,
7697 + req->rq_task->tk_client->cl_tag);
7699 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7701 @@ -384,7 +389,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7703 p = xdr_encode_fhandle(p, args->fh);
7704 p = xdr_encode_array(p, args->name, args->len);
7705 - p = xdr_encode_sattr(p, args->sattr);
7706 + p = xdr_encode_sattr(p, args->sattr,
7707 + req->rq_task->tk_client->cl_tag);
7708 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7711 @@ -397,7 +403,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7713 p = xdr_encode_fhandle(p, args->fromfh);
7714 p = xdr_encode_array(p, args->fromname, args->fromlen);
7715 - p = xdr_encode_sattr(p, args->sattr);
7716 + p = xdr_encode_sattr(p, args->sattr,
7717 + req->rq_task->tk_client->cl_tag);
7718 *p++ = htonl(args->pathlen);
7719 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7721 @@ -415,7 +422,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7722 p = xdr_encode_fhandle(p, args->fh);
7723 p = xdr_encode_array(p, args->name, args->len);
7724 *p++ = htonl(args->type);
7725 - p = xdr_encode_sattr(p, args->sattr);
7726 + p = xdr_encode_sattr(p, args->sattr,
7727 + req->rq_task->tk_client->cl_tag);
7728 if (args->type == NF3CHR || args->type == NF3BLK) {
7729 *p++ = htonl(MAJOR(args->rdev));
7730 *p++ = htonl(MINOR(args->rdev));
7731 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/nfsroot.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/nfsroot.c
7732 --- linux-2.6.22.10/fs/nfs/nfsroot.c 2007-07-09 13:19:27 +0200
7733 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/nfsroot.c 2007-08-05 20:53:13 +0200
7734 @@ -118,12 +118,12 @@ static int mount_port __initdata = 0; /
7736 /* Options that take integer arguments */
7737 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7738 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7739 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7740 /* Options that take no arguments */
7741 Opt_soft, Opt_hard, Opt_intr,
7742 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
7743 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7744 - Opt_acl, Opt_noacl,
7745 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7749 @@ -160,6 +160,9 @@ static match_table_t __initdata tokens =
7752 {Opt_noacl, "noacl"},
7754 + {Opt_notag, "notag"},
7755 + {Opt_tagid, "tagid=%u"},
7759 @@ -274,6 +277,20 @@ static int __init root_nfs_parse(char *n
7761 nfs_data.flags |= NFS_MOUNT_NOACL;
7763 +#ifndef CONFIG_TAGGING_NONE
7765 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7768 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7771 +#ifdef CONFIG_PROPAGATE
7774 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7778 printk(KERN_WARNING "Root-NFS: unknown "
7780 diff -NurpP --minimal linux-2.6.22.10/fs/nfs/super.c linux-2.6.22.10-vs2.3.0.29/fs/nfs/super.c
7781 --- linux-2.6.22.10/fs/nfs/super.c 2007-10-30 01:57:14 +0100
7782 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/super.c 2007-09-30 14:58:01 +0200
7784 #include <linux/inet.h>
7785 #include <linux/nfs_xdr.h>
7786 #include <linux/magic.h>
7787 +#include <linux/vs_tag.h>
7789 #include <asm/system.h>
7790 #include <asm/uaccess.h>
7791 @@ -291,6 +292,7 @@ static void nfs_show_mount_options(struc
7792 { NFS_MOUNT_NONLM, ",nolock", "" },
7793 { NFS_MOUNT_NOACL, ",noacl", "" },
7794 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7795 + { NFS_MOUNT_TAGGED, ",tag", "" },
7798 const struct proc_nfs_info *nfs_infop;
7799 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/auth.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/auth.c
7800 --- linux-2.6.22.10/fs/nfsd/auth.c 2006-06-18 04:54:42 +0200
7801 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/auth.c 2007-08-05 20:53:13 +0200
7803 #include <linux/sunrpc/svc.h>
7804 #include <linux/sunrpc/svcauth.h>
7805 #include <linux/nfsd/nfsd.h>
7806 +#include <linux/vs_tag.h>
7808 #define CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
7810 @@ -41,19 +42,22 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7811 get_group_info(cred.cr_group_info);
7813 if (cred.cr_uid != (uid_t) -1)
7814 - current->fsuid = cred.cr_uid;
7815 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7817 current->fsuid = exp->ex_anon_uid;
7818 if (cred.cr_gid != (gid_t) -1)
7819 - current->fsgid = cred.cr_gid;
7820 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7822 current->fsgid = exp->ex_anon_gid;
7824 + /* this desperately needs a tag :) */
7825 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7827 if (!cred.cr_group_info)
7829 ret = set_current_groups(cred.cr_group_info);
7830 put_group_info(cred.cr_group_info);
7831 - if ((cred.cr_uid)) {
7832 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
7833 cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
7835 cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
7836 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfs3xdr.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs3xdr.c
7837 --- linux-2.6.22.10/fs/nfsd/nfs3xdr.c 2007-07-09 13:19:27 +0200
7838 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs3xdr.c 2007-08-05 20:53:13 +0200
7840 #include <linux/sunrpc/svc.h>
7841 #include <linux/nfsd/nfsd.h>
7842 #include <linux/nfsd/xdr3.h>
7843 +#include <linux/vs_tag.h>
7845 #define NFSDDBG_FACILITY NFSDDBG_XDR
7847 @@ -107,6 +108,8 @@ static __be32 *
7848 decode_sattr3(__be32 *p, struct iattr *iap)
7856 @@ -116,12 +119,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7859 iap->ia_valid |= ATTR_UID;
7860 - iap->ia_uid = ntohl(*p++);
7861 + uid = ntohl(*p++);
7864 iap->ia_valid |= ATTR_GID;
7865 - iap->ia_gid = ntohl(*p++);
7866 + gid = ntohl(*p++);
7868 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7869 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7870 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7874 @@ -180,8 +186,10 @@ encode_fattr3(struct svc_rqst *rqstp, __
7875 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7876 *p++ = htonl((u32) stat->mode);
7877 *p++ = htonl((u32) stat->nlink);
7878 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7879 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7880 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7881 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7882 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7883 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7884 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7885 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7887 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfs4recover.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs4recover.c
7888 --- linux-2.6.22.10/fs/nfsd/nfs4recover.c 2007-07-09 13:19:27 +0200
7889 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs4recover.c 2007-08-05 20:53:13 +0200
7890 @@ -156,7 +156,7 @@ nfsd4_create_clid_dir(struct nfs4_client
7891 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n");
7894 - status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU);
7895 + status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU, NULL);
7899 @@ -260,7 +260,7 @@ nfsd4_remove_clid_file(struct dentry *di
7902 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7903 - status = vfs_unlink(dir->d_inode, dentry);
7904 + status = vfs_unlink(dir->d_inode, dentry, NULL);
7905 mutex_unlock(&dir->d_inode->i_mutex);
7908 @@ -275,7 +275,7 @@ nfsd4_clear_clid_dir(struct dentry *dir,
7909 * a kernel from the future.... */
7910 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
7911 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7912 - status = vfs_rmdir(dir->d_inode, dentry);
7913 + status = vfs_rmdir(dir->d_inode, dentry, NULL);
7914 mutex_unlock(&dir->d_inode->i_mutex);
7917 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfs4xdr.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs4xdr.c
7918 --- linux-2.6.22.10/fs/nfsd/nfs4xdr.c 2007-07-09 13:19:27 +0200
7919 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs4xdr.c 2007-08-05 20:53:13 +0200
7921 #include <linux/nfsd_idmap.h>
7922 #include <linux/nfs4.h>
7923 #include <linux/nfs4_acl.h>
7924 +#include <linux/vs_tag.h>
7926 #define NFSDDBG_FACILITY NFSDDBG_XDR
7928 @@ -1727,14 +1728,18 @@ out_acl:
7929 WRITE32(stat.nlink);
7931 if (bmval1 & FATTR4_WORD1_OWNER) {
7932 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7933 + status = nfsd4_encode_user(rqstp,
7934 + TAGINO_UID(DX_TAG(dentry->d_inode),
7935 + stat.uid, stat.tag), &p, &buflen);
7936 if (status == nfserr_resource)
7941 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7942 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7943 + status = nfsd4_encode_group(rqstp,
7944 + TAGINO_GID(DX_TAG(dentry->d_inode),
7945 + stat.gid, stat.tag), &p, &buflen);
7946 if (status == nfserr_resource)
7949 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/nfsxdr.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfsxdr.c
7950 --- linux-2.6.22.10/fs/nfsd/nfsxdr.c 2007-07-09 13:19:27 +0200
7951 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfsxdr.c 2007-08-05 20:53:13 +0200
7953 #include <linux/nfsd/nfsd.h>
7954 #include <linux/nfsd/xdr.h>
7955 #include <linux/mm.h>
7956 +#include <linux/vs_tag.h>
7958 #define NFSDDBG_FACILITY NFSDDBG_XDR
7960 @@ -97,6 +98,8 @@ static __be32 *
7961 decode_sattr(__be32 *p, struct iattr *iap)
7969 @@ -110,12 +113,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7971 if ((tmp = ntohl(*p++)) != (u32)-1) {
7972 iap->ia_valid |= ATTR_UID;
7973 - iap->ia_uid = tmp;
7976 if ((tmp = ntohl(*p++)) != (u32)-1) {
7977 iap->ia_valid |= ATTR_GID;
7978 - iap->ia_gid = tmp;
7981 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7982 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7983 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7984 if ((tmp = ntohl(*p++)) != (u32)-1) {
7985 iap->ia_valid |= ATTR_SIZE;
7987 @@ -160,8 +166,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7988 *p++ = htonl(nfs_ftypes[type >> 12]);
7989 *p++ = htonl((u32) stat->mode);
7990 *p++ = htonl((u32) stat->nlink);
7991 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7992 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7993 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7994 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7995 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7996 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7998 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7999 *p++ = htonl(NFS_MAXPATHLEN);
8000 diff -NurpP --minimal linux-2.6.22.10/fs/nfsd/vfs.c linux-2.6.22.10-vs2.3.0.29/fs/nfsd/vfs.c
8001 --- linux-2.6.22.10/fs/nfsd/vfs.c 2007-10-30 01:57:14 +0100
8002 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/vfs.c 2007-08-11 22:41:51 +0200
8003 @@ -1186,13 +1186,13 @@ nfsd_create(struct svc_rqst *rqstp, stru
8004 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
8007 - host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
8008 + host_err = vfs_mkdir(dirp, dchild, iap->ia_mode, NULL);
8014 - host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
8015 + host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev, NULL);
8018 printk("nfsd: bad file type %o in nfsd_create\n", type);
8019 @@ -1466,11 +1466,13 @@ nfsd_symlink(struct svc_rqst *rqstp, str
8021 strncpy(path_alloced, path, plen);
8022 path_alloced[plen] = 0;
8023 - host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
8024 + host_err = vfs_symlink(dentry->d_inode, dnew,
8025 + path_alloced, mode, NULL);
8026 kfree(path_alloced);
8029 - host_err = vfs_symlink(dentry->d_inode, dnew, path, mode);
8030 + host_err = vfs_symlink(dentry->d_inode, dnew,
8031 + path, mode, NULL);
8034 if (EX_ISSYNC(fhp->fh_export))
8035 @@ -1529,7 +1531,7 @@ nfsd_link(struct svc_rqst *rqstp, struct
8036 dold = tfhp->fh_dentry;
8037 dest = dold->d_inode;
8039 - host_err = vfs_link(dold, dirp, dnew);
8040 + host_err = vfs_link(dold, dirp, dnew, NULL);
8042 if (EX_ISSYNC(ffhp->fh_export)) {
8043 err = nfserrno(nfsd_sync_dir(ddir));
8044 @@ -1694,9 +1696,9 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
8048 - host_err = vfs_unlink(dirp, rdentry);
8049 + host_err = vfs_unlink(dirp, rdentry, NULL);
8050 } else { /* It's RMDIR */
8051 - host_err = vfs_rmdir(dirp, rdentry);
8052 + host_err = vfs_rmdir(dirp, rdentry, NULL);
8056 @@ -1807,7 +1809,8 @@ nfsd_permission(struct svc_export *exp,
8058 if (!(acc & MAY_LOCAL_ACCESS))
8059 if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
8060 - if (EX_RDONLY(exp) || IS_RDONLY(inode))
8061 + if (EX_RDONLY(exp) || IS_RDONLY(inode)
8062 + || MNT_IS_RDONLY(exp->ex_mnt))
8064 if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
8066 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/dlm/dlmfs.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlm/dlmfs.c
8067 --- linux-2.6.22.10/fs/ocfs2/dlm/dlmfs.c 2007-07-09 13:19:28 +0200
8068 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlm/dlmfs.c 2007-08-05 20:53:13 +0200
8070 #include <linux/init.h>
8071 #include <linux/string.h>
8072 #include <linux/backing-dev.h>
8073 +#include <linux/vs_tag.h>
8075 #include <asm/uaccess.h>
8077 @@ -331,6 +332,7 @@ static struct inode *dlmfs_get_root_inod
8078 inode->i_mode = mode;
8079 inode->i_uid = current->fsuid;
8080 inode->i_gid = current->fsgid;
8081 + inode->i_tag = dx_current_fstag(sb);
8082 inode->i_blocks = 0;
8083 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
8084 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
8085 @@ -357,6 +359,7 @@ static struct inode *dlmfs_get_inode(str
8086 inode->i_mode = mode;
8087 inode->i_uid = current->fsuid;
8088 inode->i_gid = current->fsgid;
8089 + inode->i_tag = dx_current_fstag(sb);
8090 inode->i_blocks = 0;
8091 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
8092 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
8093 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/dlmglue.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlmglue.c
8094 --- linux-2.6.22.10/fs/ocfs2/dlmglue.c 2007-07-09 13:19:28 +0200
8095 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlmglue.c 2007-08-05 20:53:13 +0200
8096 @@ -1475,6 +1475,7 @@ static void __ocfs2_stuff_meta_lvb(struc
8097 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
8098 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
8099 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
8100 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
8101 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
8102 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
8103 lvb->lvb_iatime_packed =
8104 @@ -1527,6 +1528,7 @@ static void ocfs2_refresh_inode_from_lvb
8106 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
8107 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
8108 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
8109 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
8110 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
8111 ocfs2_unpack_timespec(&inode->i_atime,
8112 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/dlmglue.h linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlmglue.h
8113 --- linux-2.6.22.10/fs/ocfs2/dlmglue.h 2007-07-09 13:19:28 +0200
8114 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlmglue.h 2007-08-05 20:53:13 +0200
8116 struct ocfs2_meta_lvb {
8119 - __be16 lvb_reserved1;
8121 __be32 lvb_iclusters;
8124 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/file.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/file.c
8125 --- linux-2.6.22.10/fs/ocfs2/file.c 2007-10-30 01:57:14 +0100
8126 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/file.c 2007-09-05 03:06:11 +0200
8127 @@ -943,13 +943,15 @@ int ocfs2_setattr(struct dentry *dentry,
8128 mlog(0, "uid change: %d\n", attr->ia_uid);
8129 if (attr->ia_valid & ATTR_GID)
8130 mlog(0, "gid change: %d\n", attr->ia_gid);
8131 + if (attr->ia_valid & ATTR_TAG)
8132 + mlog(0, "tag change: %d\n", attr->ia_tag);
8133 if (attr->ia_valid & ATTR_SIZE)
8134 mlog(0, "size change...\n");
8135 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
8136 mlog(0, "time change...\n");
8138 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
8139 - | ATTR_GID | ATTR_UID | ATTR_MODE)
8140 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
8141 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
8142 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
8144 @@ -1805,6 +1807,7 @@ bail:
8145 const struct inode_operations ocfs2_file_iops = {
8146 .setattr = ocfs2_setattr,
8147 .getattr = ocfs2_getattr,
8148 + .sync_flags = ocfs2_sync_flags,
8149 .permission = ocfs2_permission,
8152 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/inode.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/inode.c
8153 --- linux-2.6.22.10/fs/ocfs2/inode.c 2007-07-09 13:19:28 +0200
8154 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/inode.c 2007-08-05 20:53:13 +0200
8156 #include <linux/slab.h>
8157 #include <linux/highmem.h>
8158 #include <linux/pagemap.h>
8159 +#include <linux/vs_tag.h>
8161 #include <asm/byteorder.h>
8165 #include "heartbeat.h"
8168 #include "journal.h"
8170 #include "suballoc.h"
8171 @@ -77,6 +79,10 @@ void ocfs2_set_inode_flags(struct inode
8173 if (flags & OCFS2_IMMUTABLE_FL)
8174 inode->i_flags |= S_IMMUTABLE;
8175 + if (flags & OCFS2_IUNLINK_FL)
8176 + inode->i_flags |= S_IUNLINK;
8177 + if (flags & OCFS2_BARRIER_FL)
8178 + inode->i_flags |= S_BARRIER;
8180 if (flags & OCFS2_SYNC_FL)
8181 inode->i_flags |= S_SYNC;
8182 @@ -107,6 +113,27 @@ void ocfs2_get_inode_flags(struct ocfs2_
8183 oi->ip_attr |= OCFS2_DIRSYNC_FL;
8186 +int ocfs2_sync_flags(struct inode *inode)
8188 + unsigned int oldflags, newflags;
8190 + oldflags = OCFS2_I(inode)->ip_flags;
8191 + newflags = oldflags & ~(OCFS2_IMMUTABLE_FL |
8192 + OCFS2_IUNLINK_FL | OCFS2_BARRIER_FL);
8194 + if (IS_IMMUTABLE(inode))
8195 + newflags |= OCFS2_IMMUTABLE_FL;
8196 + if (IS_IUNLINK(inode))
8197 + newflags |= OCFS2_IUNLINK_FL;
8198 + if (IS_BARRIER(inode))
8199 + newflags |= OCFS2_BARRIER_FL;
8201 + if (oldflags ^ newflags)
8202 + return ocfs2_set_inode_attr(inode,
8203 + newflags, OCFS2_FL_MASK);
8207 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags)
8209 struct inode *inode = NULL;
8210 @@ -212,6 +239,8 @@ int ocfs2_populate_inode(struct inode *i
8211 struct super_block *sb;
8212 struct ocfs2_super *osb;
8213 int status = -EINVAL;
8217 mlog_entry("(0x%p, size:%llu)\n", inode,
8218 (unsigned long long)le64_to_cpu(fe->i_size));
8219 @@ -246,8 +275,12 @@ int ocfs2_populate_inode(struct inode *i
8220 inode->i_generation = le32_to_cpu(fe->i_generation);
8221 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
8222 inode->i_mode = le16_to_cpu(fe->i_mode);
8223 - inode->i_uid = le32_to_cpu(fe->i_uid);
8224 - inode->i_gid = le32_to_cpu(fe->i_gid);
8225 + uid = le32_to_cpu(fe->i_uid);
8226 + gid = le32_to_cpu(fe->i_gid);
8227 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8228 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8229 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8230 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8232 /* Fast symlinks will have i_size but no allocated clusters. */
8233 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
8234 @@ -1224,8 +1257,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
8236 fe->i_size = cpu_to_le64(i_size_read(inode));
8237 fe->i_links_count = cpu_to_le16(inode->i_nlink);
8238 - fe->i_uid = cpu_to_le32(inode->i_uid);
8239 - fe->i_gid = cpu_to_le32(inode->i_gid);
8240 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
8241 + inode->i_uid, inode->i_tag));
8242 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
8243 + inode->i_gid, inode->i_tag));
8244 + /* i_tag = = cpu_to_le16(inode->i_tag); */
8245 fe->i_mode = cpu_to_le16(inode->i_mode);
8246 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
8247 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
8248 @@ -1253,15 +1289,24 @@ leave:
8249 void ocfs2_refresh_inode(struct inode *inode,
8250 struct ocfs2_dinode *fe)
8255 spin_lock(&OCFS2_I(inode)->ip_lock);
8257 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
8258 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
8259 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
8260 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
8261 ocfs2_set_inode_flags(inode);
8262 i_size_write(inode, le64_to_cpu(fe->i_size));
8263 inode->i_nlink = le16_to_cpu(fe->i_links_count);
8264 - inode->i_uid = le32_to_cpu(fe->i_uid);
8265 - inode->i_gid = le32_to_cpu(fe->i_gid);
8266 + uid = le32_to_cpu(fe->i_uid);
8267 + gid = le32_to_cpu(fe->i_gid);
8268 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8269 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8270 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8271 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8272 inode->i_mode = le16_to_cpu(fe->i_mode);
8273 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
8274 inode->i_blocks = 0;
8275 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/inode.h linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/inode.h
8276 --- linux-2.6.22.10/fs/ocfs2/inode.h 2007-07-09 13:19:28 +0200
8277 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/inode.h 2007-08-05 20:53:13 +0200
8278 @@ -142,6 +142,7 @@ int ocfs2_aio_write(struct file *file, s
8280 void ocfs2_set_inode_flags(struct inode *inode);
8281 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
8282 +int ocfs2_sync_flags(struct inode *inode);
8284 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
8286 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ioctl.c
8287 --- linux-2.6.22.10/fs/ocfs2/ioctl.c 2007-07-09 13:19:28 +0200
8288 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ioctl.c 2007-08-05 20:53:13 +0200
8289 @@ -39,7 +39,7 @@ static int ocfs2_get_inode_attr(struct i
8293 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8294 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8297 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
8298 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ioctl.h linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ioctl.h
8299 --- linux-2.6.22.10/fs/ocfs2/ioctl.h 2007-07-09 13:19:28 +0200
8300 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ioctl.h 2007-08-05 20:53:13 +0200
8302 #ifndef OCFS2_IOCTL_H
8303 #define OCFS2_IOCTL_H
8305 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8308 int ocfs2_ioctl(struct inode * inode, struct file * filp,
8309 unsigned int cmd, unsigned long arg);
8310 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
8311 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/namei.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/namei.c
8312 --- linux-2.6.22.10/fs/ocfs2/namei.c 2007-07-09 13:19:28 +0200
8313 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/namei.c 2007-08-05 20:53:13 +0200
8315 #include <linux/types.h>
8316 #include <linux/slab.h>
8317 #include <linux/highmem.h>
8318 +#include <linux/vs_tag.h>
8320 #define MLOG_MASK_PREFIX ML_NAMEI
8321 #include <cluster/masklog.h>
8322 @@ -483,6 +484,9 @@ static int ocfs2_mknod_locked(struct ocf
8325 struct inode *inode = NULL;
8330 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
8331 (unsigned long)dev, dentry->d_name.len,
8332 @@ -542,13 +546,19 @@ static int ocfs2_mknod_locked(struct ocf
8333 fe->i_blkno = cpu_to_le64(fe_blkno);
8334 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
8335 fe->i_suballoc_slot = cpu_to_le16(osb->slot_num);
8336 - fe->i_uid = cpu_to_le32(current->fsuid);
8338 + tag = dx_current_fstag(osb->sb);
8339 + uid = current->fsuid;
8340 if (dir->i_mode & S_ISGID) {
8341 - fe->i_gid = cpu_to_le32(dir->i_gid);
8346 - fe->i_gid = cpu_to_le32(current->fsgid);
8347 + gid = current->fsgid;
8349 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
8350 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
8351 + inode->i_tag = tag;
8352 fe->i_mode = cpu_to_le16(mode);
8353 if (S_ISCHR(mode) || S_ISBLK(mode))
8354 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
8355 @@ -2316,5 +2326,6 @@ const struct inode_operations ocfs2_dir_
8356 .rename = ocfs2_rename,
8357 .setattr = ocfs2_setattr,
8358 .getattr = ocfs2_getattr,
8359 + .sync_flags = ocfs2_sync_flags,
8360 .permission = ocfs2_permission,
8362 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ocfs2.h linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ocfs2.h
8363 --- linux-2.6.22.10/fs/ocfs2/ocfs2.h 2007-07-09 13:19:28 +0200
8364 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ocfs2.h 2007-08-05 20:53:13 +0200
8365 @@ -170,6 +170,7 @@ enum ocfs2_mount_options
8366 OCFS2_MOUNT_NOINTR = 1 << 2, /* Don't catch signals */
8367 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
8368 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
8369 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
8372 #define OCFS2_OSB_SOFT_RO 0x0001
8373 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/ocfs2_fs.h linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ocfs2_fs.h
8374 --- linux-2.6.22.10/fs/ocfs2/ocfs2_fs.h 2007-07-09 13:19:28 +0200
8375 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ocfs2_fs.h 2007-08-05 20:53:13 +0200
8376 @@ -152,8 +152,12 @@
8377 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
8378 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
8380 +#define OCFS2_BARRIER_FL (0x04000000) /* Barrier for chroot() */
8381 +#define OCFS2_IUNLINK_FL (0x08000000) /* Immutable unlink */
8383 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
8384 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
8385 +#define OCFS2_FL_MASK (0x0F0100FF)
8388 * Extent record flags (e_node.leaf.flags)
8389 diff -NurpP --minimal linux-2.6.22.10/fs/ocfs2/super.c linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/super.c
8390 --- linux-2.6.22.10/fs/ocfs2/super.c 2007-07-09 13:19:28 +0200
8391 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/super.c 2007-08-05 20:53:13 +0200
8392 @@ -140,6 +140,7 @@ enum {
8396 + Opt_tag, Opt_notag, Opt_tagid,
8400 @@ -154,6 +155,9 @@ static match_table_t tokens = {
8401 {Opt_data_ordered, "data=ordered"},
8402 {Opt_data_writeback, "data=writeback"},
8403 {Opt_atime_quantum, "atime_quantum=%u"},
8405 + {Opt_notag, "notag"},
8406 + {Opt_tagid, "tagid=%u"},
8410 @@ -362,6 +366,13 @@ static int ocfs2_remount(struct super_bl
8414 + if ((parsed_options & OCFS2_MOUNT_TAGGED) &&
8415 + !(sb->s_flags & MS_TAGGED)) {
8417 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
8421 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
8422 (parsed_options & OCFS2_MOUNT_HB_LOCAL)) {
8424 @@ -654,6 +665,9 @@ static int ocfs2_fill_super(struct super
8426 ocfs2_complete_mount_recovery(osb);
8428 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
8429 + sb->s_flags |= MS_TAGGED;
8431 if (ocfs2_mount_local(osb))
8432 snprintf(nodestr, sizeof(nodestr), "local");
8434 @@ -782,6 +796,20 @@ static int ocfs2_parse_options(struct su
8436 osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
8438 +#ifndef CONFIG_TAGGING_NONE
8440 + *mount_opt |= OCFS2_MOUNT_TAGGED;
8443 + *mount_opt &= ~OCFS2_MOUNT_TAGGED;
8446 +#ifdef CONFIG_PROPAGATE
8449 + *mount_opt |= OCFS2_MOUNT_TAGGED;
8454 "Unrecognized mount option \"%s\" "
8455 diff -NurpP --minimal linux-2.6.22.10/fs/open.c linux-2.6.22.10-vs2.3.0.29/fs/open.c
8456 --- linux-2.6.22.10/fs/open.c 2007-07-09 13:19:28 +0200
8457 +++ linux-2.6.22.10-vs2.3.0.29/fs/open.c 2007-08-05 20:53:13 +0200
8459 #include <linux/syscalls.h>
8460 #include <linux/rcupdate.h>
8461 #include <linux/audit.h>
8462 +#include <linux/vs_base.h>
8463 +#include <linux/vs_limit.h>
8464 +#include <linux/vs_dlimit.h>
8465 +#include <linux/vs_tag.h>
8466 +#include <linux/vs_cowbl.h>
8468 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
8470 int retval = -ENODEV;
8473 + struct super_block *sb = dentry->d_sb;
8476 - if (dentry->d_sb->s_op->statfs) {
8477 + if (sb->s_op->statfs) {
8478 memset(buf, 0, sizeof(*buf));
8479 retval = security_sb_statfs(dentry);
8482 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
8483 + retval = sb->s_op->statfs(dentry, buf);
8484 if (retval == 0 && buf->f_frsize == 0)
8485 buf->f_frsize = buf->f_bsize;
8487 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
8488 + vx_vsi_statfs(sb, buf);
8492 @@ -248,7 +257,7 @@ static long do_sys_truncate(const char _
8496 - if (IS_RDONLY(inode))
8497 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
8501 @@ -397,7 +406,7 @@ asmlinkage long sys_faccessat(int dfd, c
8502 special_file(nd.dentry->d_inode->i_mode))
8503 goto out_path_release;
8505 - if(IS_RDONLY(nd.dentry->d_inode))
8506 + if(IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
8510 @@ -511,7 +520,7 @@ asmlinkage long sys_fchmod(unsigned int
8511 audit_inode(NULL, inode);
8514 - if (IS_RDONLY(inode))
8515 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
8518 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8519 @@ -541,11 +550,11 @@ asmlinkage long sys_fchmodat(int dfd, co
8520 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
8523 - inode = nd.dentry->d_inode;
8526 - if (IS_RDONLY(inode))
8527 + error = cow_check_and_break(&nd);
8530 + inode = nd.dentry->d_inode;
8533 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8534 @@ -570,7 +579,8 @@ asmlinkage long sys_chmod(const char __u
8535 return sys_fchmodat(AT_FDCWD, filename, mode);
8538 -static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
8539 +static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
8540 + uid_t user, gid_t group)
8542 struct inode * inode;
8544 @@ -582,7 +592,7 @@ static int chown_common(struct dentry *
8548 - if (IS_RDONLY(inode))
8549 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
8552 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8553 @@ -590,11 +600,11 @@ static int chown_common(struct dentry *
8554 newattrs.ia_valid = ATTR_CTIME;
8555 if (user != (uid_t) -1) {
8556 newattrs.ia_valid |= ATTR_UID;
8557 - newattrs.ia_uid = user;
8558 + newattrs.ia_uid = dx_map_uid(user);
8560 if (group != (gid_t) -1) {
8561 newattrs.ia_valid |= ATTR_GID;
8562 - newattrs.ia_gid = group;
8563 + newattrs.ia_gid = dx_map_gid(group);
8565 if (!S_ISDIR(inode->i_mode))
8566 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
8567 @@ -613,7 +623,11 @@ asmlinkage long sys_chown(const char __u
8568 error = user_path_walk(filename, &nd);
8571 - error = chown_common(nd.dentry, user, group);
8572 +#ifdef CONFIG_VSERVER_COWBL
8573 + error = cow_check_and_break(&nd);
8576 + error = chown_common(nd.dentry, nd.mnt, user, group);
8580 @@ -633,7 +647,11 @@ asmlinkage long sys_fchownat(int dfd, co
8581 error = __user_walk_fd(dfd, filename, follow, &nd);
8584 - error = chown_common(nd.dentry, user, group);
8585 +#ifdef CONFIG_VSERVER_COWBL
8586 + error = cow_check_and_break(&nd);
8589 + error = chown_common(nd.dentry, nd.mnt, user, group);
8593 @@ -647,7 +665,11 @@ asmlinkage long sys_lchown(const char __
8594 error = user_path_walk_link(filename, &nd);
8597 - error = chown_common(nd.dentry, user, group);
8598 +#ifdef CONFIG_VSERVER_COWBL
8599 + error = cow_check_and_break(&nd);
8602 + error = chown_common(nd.dentry, nd.mnt, user, group);
8606 @@ -666,7 +688,7 @@ asmlinkage long sys_fchown(unsigned int
8608 dentry = file->f_path.dentry;
8609 audit_inode(NULL, dentry->d_inode);
8610 - error = chown_common(dentry, user, group);
8611 + error = chown_common(dentry, file->f_vfsmnt, user, group);
8615 @@ -893,6 +915,7 @@ repeat:
8616 FD_SET(fd, fdt->open_fds);
8617 FD_CLR(fd, fdt->close_on_exec);
8618 files->next_fd = fd + 1;
8619 + vx_openfd_inc(fd);
8622 if (fdt->fd[fd] != NULL) {
8623 @@ -915,6 +938,7 @@ static void __put_unused_fd(struct files
8624 __FD_CLR(fd, fdt->open_fds);
8625 if (fd < files->next_fd)
8626 files->next_fd = fd;
8627 + vx_openfd_dec(fd);
8630 void fastcall put_unused_fd(unsigned int fd)
8631 diff -NurpP --minimal linux-2.6.22.10/fs/proc/array.c linux-2.6.22.10-vs2.3.0.29/fs/proc/array.c
8632 --- linux-2.6.22.10/fs/proc/array.c 2007-07-09 13:19:28 +0200
8633 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/array.c 2007-10-05 15:07:22 +0200
8635 #include <linux/cpuset.h>
8636 #include <linux/rcupdate.h>
8637 #include <linux/delayacct.h>
8638 +#include <linux/vs_context.h>
8639 +#include <linux/vs_network.h>
8641 #include <asm/uaccess.h>
8642 #include <asm/pgtable.h>
8643 @@ -134,8 +136,9 @@ static const char *task_state_array[] =
8644 "D (disk sleep)", /* 2 */
8645 "T (stopped)", /* 4 */
8646 "T (tracing stop)", /* 8 */
8647 - "Z (zombie)", /* 16 */
8648 - "X (dead)" /* 32 */
8649 + "H (on hold)", /* 16 */
8650 + "Z (zombie)", /* 32 */
8651 + "X (dead)", /* 64 */
8654 static inline const char * get_task_state(struct task_struct *tsk)
8655 @@ -144,7 +147,8 @@ static inline const char * get_task_stat
8656 TASK_INTERRUPTIBLE |
8657 TASK_UNINTERRUPTIBLE |
8662 (tsk->exit_state & (EXIT_ZOMBIE |
8664 const char **p = &task_state_array[0];
8665 @@ -161,8 +165,16 @@ static inline char * task_state(struct t
8666 struct group_info *group_info;
8668 struct fdtable *fdt = NULL;
8669 + pid_t pid, ptgid, tppid, tgid;
8672 + tgid = vx_map_tgid(p->tgid);
8673 + pid = vx_map_pid(p->pid);
8674 + ptgid = vx_map_pid(pid_alive(p) ?
8675 + rcu_dereference(p->real_parent)->tgid : 0);
8676 + tppid = vx_map_pid(pid_alive(p) && p->ptrace ?
8677 + rcu_dereference(p->parent)->pid : 0);
8679 buffer += sprintf(buffer,
8681 "SleepAVG:\t%lu%%\n"
8682 @@ -174,9 +186,7 @@ static inline char * task_state(struct t
8683 "Gid:\t%d\t%d\t%d\t%d\n",
8685 (p->sleep_avg/1024)*100/(1020000000/1024),
8687 - pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0,
8688 - pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0,
8689 + tgid, pid, (pid > 1) ? ptgid : 0, tppid,
8690 p->uid, p->euid, p->suid, p->fsuid,
8691 p->gid, p->egid, p->sgid, p->fsgid);
8693 @@ -283,12 +293,15 @@ static inline char * task_sig(struct tas
8695 static inline char *task_cap(struct task_struct *p, char *buffer)
8697 - return buffer + sprintf(buffer, "CapInh:\t%016x\n"
8698 - "CapPrm:\t%016x\n"
8699 - "CapEff:\t%016x\n",
8700 - cap_t(p->cap_inheritable),
8701 - cap_t(p->cap_permitted),
8702 - cap_t(p->cap_effective));
8703 + struct vx_info *vxi = p->vx_info;
8705 + return buffer + sprintf(buffer,
8706 + "CapInh:\t%016x\n"
8707 + "CapPrm:\t%016x\n"
8708 + "CapEff:\t%016x\n",
8709 + (unsigned)vx_info_mbcap(vxi, p->cap_inheritable),
8710 + (unsigned)vx_info_mbcap(vxi, p->cap_permitted),
8711 + (unsigned)vx_info_mbcap(vxi, p->cap_effective));
8714 int proc_pid_status(struct task_struct *task, char * buffer)
8715 @@ -306,6 +319,12 @@ int proc_pid_status(struct task_struct *
8716 buffer = task_sig(task, buffer);
8717 buffer = task_cap(task, buffer);
8718 buffer = cpuset_task_status_allowed(task, buffer);
8720 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8722 + buffer += sprintf (buffer,"VxID: %d\n", vx_task_xid(task));
8723 + buffer += sprintf (buffer,"NxID: %d\n", nx_task_nid(task));
8725 #if defined(CONFIG_S390)
8726 buffer = task_show_regs(task, buffer);
8728 @@ -320,7 +339,7 @@ static int do_task_stat(struct task_stru
8729 sigset_t sigign, sigcatch;
8732 - pid_t ppid = 0, pgid = -1, sid = -1;
8733 + pid_t pid = 0, ppid = 0, pgid = -1, sid = -1;
8734 int num_threads = 0;
8735 struct mm_struct *mm;
8736 unsigned long long start_time;
8737 @@ -382,8 +401,10 @@ static int do_task_stat(struct task_stru
8740 sid = signal_session(sig);
8741 - pgid = process_group(task);
8742 - ppid = rcu_dereference(task->real_parent)->tgid;
8743 + pid = vx_info_map_pid(task->vx_info, task->pid);
8744 + pgid = vx_info_map_pid(task->vx_info, process_group(task));
8745 + ppid = (pid > 1) ? vx_info_map_tgid(task->vx_info,
8746 + rcu_dereference(task->real_parent)->tgid) : 0;
8748 unlock_task_sighand(task, &flags);
8750 @@ -410,10 +431,21 @@ static int do_task_stat(struct task_stru
8751 /* convert nsec -> ticks */
8752 start_time = nsec_to_clock_t(start_time);
8754 + /* fixup start time for virt uptime */
8755 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8756 + unsigned long long bias =
8757 + current->vx_info->cvirt.bias_clock;
8759 + if (start_time > bias)
8760 + start_time -= bias;
8765 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %u %lu \
8766 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8767 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n",
8773 diff -NurpP --minimal linux-2.6.22.10/fs/proc/base.c linux-2.6.22.10-vs2.3.0.29/fs/proc/base.c
8774 --- linux-2.6.22.10/fs/proc/base.c 2007-07-09 13:19:28 +0200
8775 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/base.c 2007-09-05 02:49:29 +0200
8777 #include <linux/poll.h>
8778 #include <linux/nsproxy.h>
8779 #include <linux/oom.h>
8780 +#include <linux/vs_context.h>
8781 +#include <linux/vs_network.h>
8783 #include "internal.h"
8786 @@ -1049,6 +1052,8 @@ static struct inode *proc_pid_make_inode
8787 inode->i_uid = task->euid;
8788 inode->i_gid = task->egid;
8790 + /* procfs is xid tagged */
8791 + inode->i_tag = (tag_t)vx_task_xid(task);
8792 security_task_to_inode(task, inode);
8795 @@ -1082,6 +1087,8 @@ static int pid_getattr(struct vfsmount *
8799 +static unsigned name_to_int(struct dentry *dentry);
8802 * Exceptional case: normally we are not allowed to unhash a busy
8803 * directory. In this case, however, we can do it - no aliasing problems
8804 @@ -1102,6 +1109,12 @@ static int pid_revalidate(struct dentry
8805 struct inode *inode = dentry->d_inode;
8806 struct task_struct *task = get_proc_task(inode);
8808 + unsigned pid = name_to_int(dentry);
8809 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
8810 + put_task_struct(task);
8814 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
8815 task_dumpable(task)) {
8816 inode->i_uid = task->euid;
8817 @@ -1115,6 +1128,7 @@ static int pid_revalidate(struct dentry
8818 put_task_struct(task);
8825 @@ -1595,6 +1609,13 @@ static struct dentry *proc_pident_lookup
8829 + /* TODO: maybe we can come up with a generic approach? */
8830 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8831 + (dentry->d_name.len == 5) &&
8832 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8833 + !memcmp(dentry->d_name.name, "ninfo", 5)))
8837 * Yes, it does not scale. And it should not. Don't add
8838 * new entries into /proc/<tgid>/ without very good reasons.
8839 @@ -1790,14 +1811,14 @@ static int proc_self_readlink(struct den
8842 char tmp[PROC_NUMBUF];
8843 - sprintf(tmp, "%d", current->tgid);
8844 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8845 return vfs_readlink(dentry,buffer,buflen,tmp);
8848 static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
8850 char tmp[PROC_NUMBUF];
8851 - sprintf(tmp, "%d", current->tgid);
8852 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8853 return ERR_PTR(vfs_follow_link(nd,tmp));
8856 @@ -1891,7 +1912,7 @@ out_iput:
8857 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8859 struct dentry *error;
8860 - struct task_struct *task = get_proc_task(dir);
8861 + struct task_struct *task = get_proc_task_real(dir);
8862 const struct pid_entry *p, *last;
8864 error = ERR_PTR(-ENOENT);
8865 @@ -1956,6 +1977,9 @@ static int proc_pid_io_accounting(struct
8866 static const struct file_operations proc_task_operations;
8867 static const struct inode_operations proc_task_inode_operations;
8869 +extern int proc_pid_vx_info(struct task_struct *, char *);
8870 +extern int proc_pid_nx_info(struct task_struct *, char *);
8872 static const struct pid_entry tgid_base_stuff[] = {
8873 DIR("task", S_IRUGO|S_IXUGO, task),
8874 DIR("fd", S_IRUSR|S_IXUSR, fd),
8875 @@ -1995,6 +2019,8 @@ static const struct pid_entry tgid_base_
8876 #ifdef CONFIG_CPUSETS
8877 REG("cpuset", S_IRUGO, cpuset),
8879 + INF("vinfo", S_IRUGO, pid_vx_info),
8880 + INF("ninfo", S_IRUGO, pid_nx_info),
8881 INF("oom_score", S_IRUGO, oom_score),
8882 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
8883 #ifdef CONFIG_AUDITSYSCALL
8884 @@ -2141,9 +2167,11 @@ struct dentry *proc_pid_lookup(struct in
8885 tgid = name_to_int(dentry);
8888 + if (vx_current_initpid(tgid))
8892 - task = find_task_by_pid(tgid);
8893 + task = vx_find_proc_task_by_pid(tgid);
8895 get_task_struct(task);
8897 @@ -2198,7 +2226,7 @@ static int proc_pid_fill_cache(struct fi
8898 struct task_struct *task, int tgid)
8900 char name[PROC_NUMBUF];
8901 - int len = snprintf(name, sizeof(name), "%d", tgid);
8902 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(tgid));
8903 return proc_fill_cache(filp, dirent, filldir, name, len,
8904 proc_pid_instantiate, task, NULL);
8906 @@ -2207,7 +2235,7 @@ static int proc_pid_fill_cache(struct fi
8907 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8909 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8910 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8911 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8912 struct task_struct *task;
8915 @@ -2226,6 +2254,8 @@ int proc_pid_readdir(struct file * filp,
8916 put_task_struct(task), task = next_tgid(tgid + 1)) {
8918 filp->f_pos = tgid + TGID_OFFSET;
8919 + if (!vx_proc_task_visible(task))
8921 if (proc_pid_fill_cache(filp, dirent, filldir, task, tgid) < 0) {
8922 put_task_struct(task);
8924 @@ -2352,9 +2382,11 @@ static struct dentry *proc_task_lookup(s
8925 tid = name_to_int(dentry);
8928 + if (vx_current_initpid(tid))
8932 - task = find_task_by_pid(tid);
8933 + task = vx_find_proc_task_by_pid(tid);
8935 get_task_struct(task);
8937 @@ -2499,7 +2531,7 @@ static int proc_task_readdir(struct file
8938 for (task = first_tid(leader, tid, pos - 2);
8940 task = next_tid(task), pos++) {
8942 + tid = vx_map_pid(task->pid);
8943 if (proc_task_fill_cache(filp, dirent, filldir, task, tid) < 0) {
8944 /* returning this tgid failed, save it as the first
8945 * pid for the next readir call */
8946 diff -NurpP --minimal linux-2.6.22.10/fs/proc/generic.c linux-2.6.22.10-vs2.3.0.29/fs/proc/generic.c
8947 --- linux-2.6.22.10/fs/proc/generic.c 2007-07-09 13:19:28 +0200
8948 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/generic.c 2007-08-05 20:53:13 +0200
8950 #include <linux/namei.h>
8951 #include <linux/bitops.h>
8952 #include <linux/spinlock.h>
8953 +#include <linux/vserver/inode.h>
8954 #include <asm/uaccess.h>
8956 #include "internal.h"
8957 @@ -395,6 +396,8 @@ struct dentry *proc_lookup(struct inode
8958 for (de = de->subdir; de ; de = de->next) {
8959 if (de->namelen != dentry->d_name.len)
8961 + if (!vx_hide_check(0, de->vx_flags))
8963 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8964 unsigned int ino = de->low_ino;
8966 @@ -402,6 +405,8 @@ struct dentry *proc_lookup(struct inode
8967 spin_unlock(&proc_subdir_lock);
8969 inode = proc_get_inode(dir->i_sb, ino, de);
8970 + /* generic proc entries belong to the host */
8972 spin_lock(&proc_subdir_lock);
8975 @@ -482,6 +487,8 @@ int proc_readdir(struct file * filp,
8977 /* filldir passes info to user space */
8979 + if (!vx_hide_check(0, de->vx_flags))
8981 spin_unlock(&proc_subdir_lock);
8982 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8983 de->low_ino, de->mode >> 12) < 0) {
8984 @@ -489,6 +496,7 @@ int proc_readdir(struct file * filp,
8987 spin_lock(&proc_subdir_lock);
8992 @@ -613,6 +621,7 @@ static struct proc_dir_entry *proc_creat
8996 + ent->vx_flags = IATTR_PROC_DEFAULT;
9000 @@ -633,7 +642,8 @@ struct proc_dir_entry *proc_symlink(cons
9006 + ent->vx_flags = IATTR_PROC_SYMLINK;
9010 diff -NurpP --minimal linux-2.6.22.10/fs/proc/inode.c linux-2.6.22.10-vs2.3.0.29/fs/proc/inode.c
9011 --- linux-2.6.22.10/fs/proc/inode.c 2007-07-09 13:19:28 +0200
9012 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/inode.c 2007-08-05 20:53:13 +0200
9013 @@ -160,6 +160,8 @@ struct inode *proc_get_inode(struct supe
9014 inode->i_uid = de->uid;
9015 inode->i_gid = de->gid;
9018 + PROC_I(inode)->vx_flags = de->vx_flags;
9020 inode->i_size = de->size;
9022 diff -NurpP --minimal linux-2.6.22.10/fs/proc/internal.h linux-2.6.22.10-vs2.3.0.29/fs/proc/internal.h
9023 --- linux-2.6.22.10/fs/proc/internal.h 2007-07-09 13:19:28 +0200
9024 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/internal.h 2007-08-05 20:53:13 +0200
9028 #include <linux/proc_fs.h>
9029 +#include <linux/vs_pid.h>
9031 #ifdef CONFIG_PROC_SYSCTL
9032 extern int proc_sys_init(void);
9033 @@ -64,11 +65,16 @@ static inline struct pid *proc_pid(struc
9034 return PROC_I(inode)->pid;
9037 -static inline struct task_struct *get_proc_task(struct inode *inode)
9038 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
9040 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
9043 +static inline struct task_struct *get_proc_task(struct inode *inode)
9045 + return vx_get_proc_task(inode, proc_pid(inode));
9048 static inline int proc_fd(struct inode *inode)
9050 return PROC_I(inode)->fd;
9051 diff -NurpP --minimal linux-2.6.22.10/fs/proc/proc_misc.c linux-2.6.22.10-vs2.3.0.29/fs/proc/proc_misc.c
9052 --- linux-2.6.22.10/fs/proc/proc_misc.c 2007-07-09 13:19:28 +0200
9053 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/proc_misc.c 2007-08-05 20:53:13 +0200
9055 #include <asm/div64.h>
9056 #include "internal.h"
9058 +#include <linux/vs_cvirt.h>
9060 #define LOAD_INT(x) ((x) >> FSHIFT)
9061 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
9063 @@ -82,17 +84,32 @@ static int proc_calc_metrics(char *page,
9064 static int loadavg_read_proc(char *page, char **start, off_t off,
9065 int count, int *eof, void *data)
9067 + unsigned int running, threads;
9071 - a = avenrun[0] + (FIXED_1/200);
9072 - b = avenrun[1] + (FIXED_1/200);
9073 - c = avenrun[2] + (FIXED_1/200);
9074 - len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
9075 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
9076 + struct vx_info *vxi = current->vx_info;
9078 + a = vxi->cvirt.load[0] + (FIXED_1/200);
9079 + b = vxi->cvirt.load[1] + (FIXED_1/200);
9080 + c = vxi->cvirt.load[2] + (FIXED_1/200);
9082 + running = atomic_read(&vxi->cvirt.nr_running);
9083 + threads = atomic_read(&vxi->cvirt.nr_threads);
9085 + a = avenrun[0] + (FIXED_1/200);
9086 + b = avenrun[1] + (FIXED_1/200);
9087 + c = avenrun[2] + (FIXED_1/200);
9089 + running = nr_running();
9090 + threads = nr_threads;
9092 + len = sprintf(page,"%d.%02d %d.%02d %d.%02d %d/%d %d\n",
9093 LOAD_INT(a), LOAD_FRAC(a),
9094 LOAD_INT(b), LOAD_FRAC(b),
9095 LOAD_INT(c), LOAD_FRAC(c),
9096 - nr_running(), nr_threads, current->nsproxy->pid_ns->last_pid);
9097 + running, threads, current->nsproxy->pid_ns->last_pid);
9098 return proc_calc_metrics(page, start, off, count, eof, len);
9101 @@ -106,6 +123,9 @@ static int uptime_read_proc(char *page,
9103 do_posix_clock_monotonic_gettime(&uptime);
9104 cputime_to_timespec(idletime, &idle);
9105 + if (vx_flags(VXF_VIRT_UPTIME, 0))
9106 + vx_vsi_uptime(&uptime, &idle);
9108 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
9109 (unsigned long) uptime.tv_sec,
9110 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
9111 @@ -137,7 +157,7 @@ static int meminfo_read_proc(char *page,
9113 cached = global_page_state(NR_FILE_PAGES) -
9114 total_swapcache_pages - i.bufferram;
9116 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
9119 get_vmalloc_info(&vmi);
9120 diff -NurpP --minimal linux-2.6.22.10/fs/proc/root.c linux-2.6.22.10-vs2.3.0.29/fs/proc/root.c
9121 --- linux-2.6.22.10/fs/proc/root.c 2007-05-02 19:25:21 +0200
9122 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/root.c 2007-08-05 20:53:13 +0200
9124 #include "internal.h"
9126 struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
9127 +struct proc_dir_entry *proc_virtual;
9129 +extern void proc_vx_init(void);
9131 static int proc_get_sb(struct file_system_type *fs_type,
9132 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
9133 @@ -79,6 +82,7 @@ void __init proc_root_init(void)
9134 proc_device_tree_init();
9136 proc_bus = proc_mkdir("bus", NULL);
9141 diff -NurpP --minimal linux-2.6.22.10/fs/quota.c linux-2.6.22.10-vs2.3.0.29/fs/quota.c
9142 --- linux-2.6.22.10/fs/quota.c 2007-07-09 13:19:28 +0200
9143 +++ linux-2.6.22.10-vs2.3.0.29/fs/quota.c 2007-08-05 20:53:13 +0200
9145 #include <linux/buffer_head.h>
9146 #include <linux/capability.h>
9147 #include <linux/quotaops.h>
9148 +#include <linux/vs_context.h>
9150 /* Check validity of generic quotactl commands */
9151 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
9152 @@ -80,11 +81,11 @@ static int generic_quotactl_valid(struct
9153 if (cmd == Q_GETQUOTA) {
9154 if (((type == USRQUOTA && current->euid != id) ||
9155 (type == GRPQUOTA && !in_egroup_p(id))) &&
9156 - !capable(CAP_SYS_ADMIN))
9157 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9160 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
9161 - if (!capable(CAP_SYS_ADMIN))
9162 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9166 @@ -131,10 +132,10 @@ static int xqm_quotactl_valid(struct sup
9167 if (cmd == Q_XGETQUOTA) {
9168 if (((type == XQM_USRQUOTA && current->euid != id) ||
9169 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
9170 - !capable(CAP_SYS_ADMIN))
9171 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9173 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
9174 - if (!capable(CAP_SYS_ADMIN))
9175 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9179 @@ -327,6 +328,46 @@ static int do_quotactl(struct super_bloc
9183 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
9185 +#include <linux/vroot.h>
9186 +#include <linux/major.h>
9187 +#include <linux/module.h>
9188 +#include <linux/kallsyms.h>
9189 +#include <linux/vserver/debug.h>
9191 +static vroot_grb_func *vroot_get_real_bdev = NULL;
9193 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
9195 +int register_vroot_grb(vroot_grb_func *func) {
9198 + spin_lock(&vroot_grb_lock);
9199 + if (!vroot_get_real_bdev) {
9200 + vroot_get_real_bdev = func;
9203 + spin_unlock(&vroot_grb_lock);
9206 +EXPORT_SYMBOL(register_vroot_grb);
9208 +int unregister_vroot_grb(vroot_grb_func *func) {
9209 + int ret = -EINVAL;
9211 + spin_lock(&vroot_grb_lock);
9212 + if (vroot_get_real_bdev) {
9213 + vroot_get_real_bdev = NULL;
9216 + spin_unlock(&vroot_grb_lock);
9219 +EXPORT_SYMBOL(unregister_vroot_grb);
9224 * look up a superblock on which quota ops will be performed
9225 * - use the name of a block device to find the superblock thereon
9226 @@ -344,6 +385,22 @@ static inline struct super_block *quotac
9229 return ERR_PTR(PTR_ERR(bdev));
9230 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
9231 + if (bdev && bdev->bd_inode &&
9232 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
9233 + struct block_device *bdnew = (void *)-EINVAL;
9235 + if (vroot_get_real_bdev)
9236 + bdnew = vroot_get_real_bdev(bdev);
9238 + vxdprintk(VXD_CBIT(misc, 0),
9239 + "vroot_get_real_bdev not set");
9241 + if (IS_ERR(bdnew))
9242 + return ERR_PTR(PTR_ERR(bdnew));
9246 sb = get_super(bdev);
9249 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/bitmap.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/bitmap.c
9250 --- linux-2.6.22.10/fs/reiserfs/bitmap.c 2007-02-06 03:01:29 +0100
9251 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/bitmap.c 2007-10-05 15:07:22 +0200
9253 #include <linux/reiserfs_fs_sb.h>
9254 #include <linux/reiserfs_fs_i.h>
9255 #include <linux/quotaops.h>
9256 +#include <linux/vs_dlimit.h>
9258 #define PREALLOCATION_SIZE 9
9260 @@ -425,8 +426,10 @@ static void _reiserfs_free_block(struct
9261 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
9263 journal_mark_dirty(th, s, sbh);
9264 - if (for_unformatted)
9265 + if (for_unformatted) {
9266 + DLIMIT_FREE_BLOCK(inode, 1);
9267 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
9271 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
9272 @@ -1034,6 +1037,7 @@ static inline int blocknrs_and_prealloc_
9273 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
9275 int nr_allocated = 0;
9278 determine_prealloc_size(hint);
9279 if (!hint->formatted_node) {
9280 @@ -1043,19 +1047,30 @@ static inline int blocknrs_and_prealloc_
9281 "reiserquota: allocating %d blocks id=%u",
9282 amount_needed, hint->inode->i_uid);
9285 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
9286 - if (quota_ret) /* Quota exceeded? */
9287 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
9290 return QUOTA_EXCEEDED;
9291 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
9292 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
9294 + return NO_DISK_SPACE;
9297 if (hint->preallocate && hint->prealloc_size) {
9298 #ifdef REISERQUOTA_DEBUG
9299 reiserfs_debug(s, REISERFS_DEBUG_CODE,
9300 "reiserquota: allocating (prealloc) %d blocks id=%u",
9301 hint->prealloc_size, hint->inode->i_uid);
9304 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
9305 - hint->prealloc_size);
9306 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
9307 + hint->prealloc_size);
9309 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
9310 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
9311 + hint->prealloc_size);
9315 hint->preallocate = hint->prealloc_size = 0;
9317 @@ -1087,7 +1102,10 @@ static inline int blocknrs_and_prealloc_
9319 hint->inode->i_uid);
9321 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
9322 + /* Free not allocated blocks */
9323 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
9324 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
9325 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
9327 while (nr_allocated--)
9328 reiserfs_free_block(hint->th, hint->inode,
9329 @@ -1118,10 +1136,10 @@ static inline int blocknrs_and_prealloc_
9330 REISERFS_I(hint->inode)->i_prealloc_count,
9331 hint->inode->i_uid);
9333 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
9334 - hint->prealloc_size - nr_allocated -
9335 - REISERFS_I(hint->inode)->
9336 - i_prealloc_count);
9337 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
9338 + REISERFS_I(hint->inode)->i_prealloc_count;
9339 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
9340 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
9344 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/file.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/file.c
9345 --- linux-2.6.22.10/fs/reiserfs/file.c 2007-07-09 13:19:28 +0200
9346 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/file.c 2007-09-12 20:04:16 +0200
9347 @@ -1546,4 +1546,5 @@ const struct inode_operations reiserfs_f
9348 .listxattr = reiserfs_listxattr,
9349 .removexattr = reiserfs_removexattr,
9350 .permission = reiserfs_permission,
9351 + .sync_flags = reiserfs_sync_flags,
9353 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/inode.c
9354 --- linux-2.6.22.10/fs/reiserfs/inode.c 2007-07-09 13:19:28 +0200
9355 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/inode.c 2007-08-05 20:53:13 +0200
9357 #include <linux/mpage.h>
9358 #include <linux/writeback.h>
9359 #include <linux/quotaops.h>
9360 +#include <linux/vs_dlimit.h>
9361 +#include <linux/vs_tag.h>
9363 static int reiserfs_commit_write(struct file *f, struct page *page,
9364 unsigned from, unsigned to);
9365 @@ -50,6 +52,7 @@ void reiserfs_delete_inode(struct inode
9366 * stat data deletion */
9368 DQUOT_FREE_INODE(inode);
9369 + DLIMIT_FREE_INODE(inode);
9371 if (journal_end(&th, inode->i_sb, jbegin_count))
9373 @@ -1112,6 +1115,8 @@ static void init_inode(struct inode *ino
9374 struct buffer_head *bh;
9375 struct item_head *ih;
9379 //int version = ITEM_VERSION_1;
9381 bh = PATH_PLAST_BUFFER(path);
9382 @@ -1135,12 +1140,13 @@ static void init_inode(struct inode *ino
9383 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
9384 unsigned long blocks;
9386 + uid = sd_v1_uid(sd);
9387 + gid = sd_v1_gid(sd);
9389 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
9390 set_inode_sd_version(inode, STAT_DATA_V1);
9391 inode->i_mode = sd_v1_mode(sd);
9392 inode->i_nlink = sd_v1_nlink(sd);
9393 - inode->i_uid = sd_v1_uid(sd);
9394 - inode->i_gid = sd_v1_gid(sd);
9395 inode->i_size = sd_v1_size(sd);
9396 inode->i_atime.tv_sec = sd_v1_atime(sd);
9397 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
9398 @@ -1182,11 +1188,12 @@ static void init_inode(struct inode *ino
9399 // (directories and symlinks)
9400 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
9402 + uid = sd_v2_uid(sd);
9403 + gid = sd_v2_gid(sd);
9405 inode->i_mode = sd_v2_mode(sd);
9406 inode->i_nlink = sd_v2_nlink(sd);
9407 - inode->i_uid = sd_v2_uid(sd);
9408 inode->i_size = sd_v2_size(sd);
9409 - inode->i_gid = sd_v2_gid(sd);
9410 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
9411 inode->i_atime.tv_sec = sd_v2_atime(sd);
9412 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
9413 @@ -1216,6 +1223,10 @@ static void init_inode(struct inode *ino
9414 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
9417 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
9418 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
9419 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
9422 if (S_ISREG(inode->i_mode)) {
9423 inode->i_op = &reiserfs_file_inode_operations;
9424 @@ -1238,13 +1249,15 @@ static void init_inode(struct inode *ino
9425 static void inode2sd(void *sd, struct inode *inode, loff_t size)
9427 struct stat_data *sd_v2 = (struct stat_data *)sd;
9428 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
9429 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
9432 + set_sd_v2_uid(sd_v2, uid);
9433 + set_sd_v2_gid(sd_v2, gid);
9434 set_sd_v2_mode(sd_v2, inode->i_mode);
9435 set_sd_v2_nlink(sd_v2, inode->i_nlink);
9436 - set_sd_v2_uid(sd_v2, inode->i_uid);
9437 set_sd_v2_size(sd_v2, size);
9438 - set_sd_v2_gid(sd_v2, inode->i_gid);
9439 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
9440 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
9441 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
9442 @@ -1775,6 +1788,10 @@ int reiserfs_new_inode(struct reiserfs_t
9444 BUG_ON(!th->t_trans_id);
9446 + if (DLIMIT_ALLOC_INODE(inode)) {
9448 + goto out_bad_dlimit;
9450 if (DQUOT_ALLOC_INODE(inode)) {
9453 @@ -1960,6 +1977,9 @@ int reiserfs_new_inode(struct reiserfs_t
9454 DQUOT_FREE_INODE(inode);
9457 + DLIMIT_FREE_INODE(inode);
9460 journal_end(th, th->t_super, th->t_blocks_allocated);
9461 /* Drop can be outside and it needs more credits so it's better to have it outside */
9463 @@ -2690,6 +2710,14 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
9464 inode->i_flags |= S_IMMUTABLE;
9466 inode->i_flags &= ~S_IMMUTABLE;
9467 + if (sd_attrs & REISERFS_IUNLINK_FL)
9468 + inode->i_flags |= S_IUNLINK;
9470 + inode->i_flags &= ~S_IUNLINK;
9471 + if (sd_attrs & REISERFS_BARRIER_FL)
9472 + inode->i_flags |= S_BARRIER;
9474 + inode->i_flags &= ~S_BARRIER;
9475 if (sd_attrs & REISERFS_APPEND_FL)
9476 inode->i_flags |= S_APPEND;
9478 @@ -2712,6 +2740,14 @@ void i_attrs_to_sd_attrs(struct inode *i
9479 *sd_attrs |= REISERFS_IMMUTABLE_FL;
9481 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
9482 + if (inode->i_flags & S_IUNLINK)
9483 + *sd_attrs |= REISERFS_IUNLINK_FL;
9485 + *sd_attrs &= ~REISERFS_IUNLINK_FL;
9486 + if (inode->i_flags & S_BARRIER)
9487 + *sd_attrs |= REISERFS_BARRIER_FL;
9489 + *sd_attrs &= ~REISERFS_BARRIER_FL;
9490 if (inode->i_flags & S_SYNC)
9491 *sd_attrs |= REISERFS_SYNC_FL;
9493 @@ -2891,6 +2927,22 @@ static ssize_t reiserfs_direct_IO(int rw
9494 reiserfs_get_blocks_direct_io, NULL);
9497 +int reiserfs_sync_flags(struct inode *inode)
9499 + u16 oldflags, newflags;
9501 + oldflags = REISERFS_I(inode)->i_attrs;
9502 + newflags = oldflags;
9503 + i_attrs_to_sd_attrs(inode, &newflags);
9505 + if (oldflags ^ newflags) {
9506 + REISERFS_I(inode)->i_attrs = newflags;
9507 + inode->i_ctime = CURRENT_TIME_SEC;
9508 + mark_inode_dirty(inode);
9513 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
9515 struct inode *inode = dentry->d_inode;
9516 @@ -2940,9 +2992,11 @@ int reiserfs_setattr(struct dentry *dent
9519 error = inode_change_ok(inode, attr);
9522 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
9523 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
9524 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
9525 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
9526 error = reiserfs_chown_xattrs(inode, attr);
9529 @@ -2972,6 +3026,9 @@ int reiserfs_setattr(struct dentry *dent
9530 inode->i_uid = attr->ia_uid;
9531 if (attr->ia_valid & ATTR_GID)
9532 inode->i_gid = attr->ia_gid;
9533 + if ((attr->ia_valid & ATTR_TAG) &&
9535 + inode->i_tag = attr->ia_tag;
9536 mark_inode_dirty(inode);
9538 journal_end(&th, inode->i_sb, jbegin_count);
9539 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/ioctl.c
9540 --- linux-2.6.22.10/fs/reiserfs/ioctl.c 2007-02-06 03:01:29 +0100
9541 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/ioctl.c 2007-08-05 20:53:13 +0200
9543 #include <linux/fs.h>
9544 #include <linux/reiserfs_fs.h>
9545 #include <linux/time.h>
9546 +#include <linux/mount.h>
9547 #include <asm/uaccess.h>
9548 #include <linux/pagemap.h>
9549 #include <linux/smp_lock.h>
9550 @@ -24,7 +25,7 @@ static int reiserfs_unpack(struct inode
9551 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
9554 - unsigned int flags;
9555 + unsigned int flags, oldflags;
9558 case REISERFS_IOC_UNPACK:
9559 @@ -43,12 +44,14 @@ int reiserfs_ioctl(struct inode *inode,
9561 flags = REISERFS_I(inode)->i_attrs;
9562 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
9563 + flags &= REISERFS_FL_USER_VISIBLE;
9564 return put_user(flags, (int __user *)arg);
9565 case REISERFS_IOC_SETFLAGS:{
9566 if (!reiserfs_attrs(inode->i_sb))
9569 - if (IS_RDONLY(inode))
9570 + if (IS_RDONLY(inode) ||
9571 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9574 if ((current->fsuid != inode->i_uid)
9575 @@ -58,10 +61,12 @@ int reiserfs_ioctl(struct inode *inode,
9576 if (get_user(flags, (int __user *)arg))
9579 - if (((flags ^ REISERFS_I(inode)->
9580 - i_attrs) & (REISERFS_IMMUTABLE_FL |
9581 - REISERFS_APPEND_FL))
9582 - && !capable(CAP_LINUX_IMMUTABLE))
9583 + oldflags = REISERFS_I(inode) -> i_attrs;
9584 + if (((oldflags & REISERFS_IMMUTABLE_FL) ||
9585 + ((flags ^ oldflags) &
9586 + (REISERFS_IMMUTABLE_FL | REISERFS_IUNLINK_FL |
9587 + REISERFS_APPEND_FL))) &&
9588 + !capable(CAP_LINUX_IMMUTABLE))
9591 if ((flags & REISERFS_NOTAIL_FL) &&
9592 @@ -72,6 +77,9 @@ int reiserfs_ioctl(struct inode *inode,
9597 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
9598 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
9599 sd_attrs_to_i_attrs(flags, inode);
9600 REISERFS_I(inode)->i_attrs = flags;
9601 inode->i_ctime = CURRENT_TIME_SEC;
9602 @@ -83,7 +91,8 @@ int reiserfs_ioctl(struct inode *inode,
9603 case REISERFS_IOC_SETVERSION:
9604 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
9606 - if (IS_RDONLY(inode))
9607 + if (IS_RDONLY(inode) ||
9608 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9610 if (get_user(inode->i_generation, (int __user *)arg))
9612 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/namei.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/namei.c
9613 --- linux-2.6.22.10/fs/reiserfs/namei.c 2007-07-09 13:19:28 +0200
9614 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/namei.c 2007-08-05 20:53:13 +0200
9616 #include <linux/reiserfs_acl.h>
9617 #include <linux/reiserfs_xattr.h>
9618 #include <linux/quotaops.h>
9619 +#include <linux/vs_tag.h>
9621 #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; }
9622 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
9623 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
9624 reiserfs_write_unlock(dir->i_sb);
9625 return ERR_PTR(-EACCES);
9627 + dx_propagate_tag(nd, inode);
9629 /* Propogate the priv_object flag so we know we're in the priv tree */
9630 if (is_reiserfs_priv_object(dir))
9631 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
9633 inode->i_gid = current->fsgid;
9635 + inode->i_tag = dx_current_fstag(inode->i_sb);
9639 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
9640 .listxattr = reiserfs_listxattr,
9641 .removexattr = reiserfs_removexattr,
9642 .permission = reiserfs_permission,
9643 + .sync_flags = reiserfs_sync_flags,
9647 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
9648 .listxattr = reiserfs_listxattr,
9649 .removexattr = reiserfs_removexattr,
9650 .permission = reiserfs_permission,
9651 + .sync_flags = reiserfs_sync_flags,
9655 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
9656 .listxattr = reiserfs_listxattr,
9657 .removexattr = reiserfs_removexattr,
9658 .permission = reiserfs_permission,
9659 + .sync_flags = reiserfs_sync_flags,
9662 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/stree.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/stree.c
9663 --- linux-2.6.22.10/fs/reiserfs/stree.c 2007-07-09 13:19:28 +0200
9664 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/stree.c 2007-08-05 20:53:13 +0200
9666 #include <linux/reiserfs_fs.h>
9667 #include <linux/buffer_head.h>
9668 #include <linux/quotaops.h>
9669 +#include <linux/vs_dlimit.h>
9671 /* Does the buffer contain a disk block which is in the tree. */
9672 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
9673 @@ -1296,6 +1297,7 @@ int reiserfs_delete_item(struct reiserfs
9674 "reiserquota delete_item(): freeing %u, id=%u type=%c",
9675 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
9677 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9678 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9680 /* Return deleted body length */
9681 @@ -1384,6 +1386,7 @@ void reiserfs_delete_solid_item(struct r
9683 DQUOT_FREE_SPACE_NODIRTY(inode,
9685 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
9689 @@ -1737,6 +1740,7 @@ int reiserfs_cut_from_item(struct reiser
9690 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
9691 quota_cut_bytes, p_s_inode->i_uid, '?');
9693 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9694 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9697 @@ -1978,6 +1982,11 @@ int reiserfs_paste_into_item(struct reis
9698 pathrelse(p_s_search_path);
9701 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
9702 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9703 + pathrelse(p_s_search_path);
9706 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
9708 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
9709 @@ -2030,6 +2039,7 @@ int reiserfs_paste_into_item(struct reis
9710 n_pasted_size, inode->i_uid,
9711 key2type(&(p_s_key->on_disk_key)));
9713 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
9714 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9717 @@ -2067,6 +2077,11 @@ int reiserfs_insert_item(struct reiserfs
9718 pathrelse(p_s_path);
9721 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
9722 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9723 + pathrelse(p_s_path);
9727 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
9728 IH_SIZE + ih_item_len(p_s_ih));
9729 @@ -2114,7 +2129,9 @@ int reiserfs_insert_item(struct reiserfs
9730 "reiserquota insert_item(): freeing %u id=%u type=%c",
9731 quota_bytes, inode->i_uid, head2type(p_s_ih));
9735 + DLIMIT_FREE_SPACE(inode, quota_bytes);
9736 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9740 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/super.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/super.c
9741 --- linux-2.6.22.10/fs/reiserfs/super.c 2007-07-09 13:19:28 +0200
9742 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/super.c 2007-08-05 20:53:13 +0200
9743 @@ -882,6 +882,14 @@ static int reiserfs_parse_options(struct
9744 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9745 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9747 +#ifndef CONFIG_TAGGING_NONE
9748 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9749 + {"tag",.setmask = 1 << REISERFS_TAGGED},
9750 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
9752 +#ifdef CONFIG_PROPAGATE
9753 + {"tag",.arg_required = 'T',.values = NULL},
9755 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9756 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9757 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9758 @@ -1143,6 +1151,12 @@ static int reiserfs_remount(struct super
9762 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
9763 + !(s->s_flags & MS_TAGGED)) {
9764 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
9770 /* Add options that are safe here */
9771 @@ -1591,6 +1605,10 @@ static int reiserfs_fill_super(struct su
9775 + /* map mount option tagxid */
9776 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9777 + s->s_flags |= MS_TAGGED;
9779 rs = SB_DISK_SUPER_BLOCK(s);
9780 /* Let's do basic sanity check to verify that underlying device is not
9781 smaller than the filesystem. If the check fails then abort and scream,
9782 diff -NurpP --minimal linux-2.6.22.10/fs/reiserfs/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/xattr.c
9783 --- linux-2.6.22.10/fs/reiserfs/xattr.c 2007-07-09 13:19:28 +0200
9784 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/xattr.c 2007-08-05 20:53:13 +0200
9786 #include <linux/namei.h>
9787 #include <linux/errno.h>
9788 #include <linux/fs.h>
9789 +#include <linux/mount.h>
9790 #include <linux/file.h>
9791 #include <linux/pagemap.h>
9792 #include <linux/xattr.h>
9793 @@ -775,7 +776,7 @@ int reiserfs_delete_xattrs(struct inode
9794 if (dir->d_inode->i_nlink <= 2) {
9795 root = get_xa_root(inode->i_sb, XATTR_REPLACE);
9796 reiserfs_write_lock_xattrs(inode->i_sb);
9797 - err = vfs_rmdir(root->d_inode, dir);
9798 + err = vfs_rmdir(root->d_inode, dir, NULL);
9799 reiserfs_write_unlock_xattrs(inode->i_sb);
9802 diff -NurpP --minimal linux-2.6.22.10/fs/stat.c linux-2.6.22.10-vs2.3.0.29/fs/stat.c
9803 --- linux-2.6.22.10/fs/stat.c 2007-07-09 13:19:28 +0200
9804 +++ linux-2.6.22.10-vs2.3.0.29/fs/stat.c 2007-08-05 20:53:13 +0200
9805 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9806 stat->nlink = inode->i_nlink;
9807 stat->uid = inode->i_uid;
9808 stat->gid = inode->i_gid;
9809 + stat->tag = inode->i_tag;
9810 stat->rdev = inode->i_rdev;
9811 stat->atime = inode->i_atime;
9812 stat->mtime = inode->i_mtime;
9813 diff -NurpP --minimal linux-2.6.22.10/fs/super.c linux-2.6.22.10-vs2.3.0.29/fs/super.c
9814 --- linux-2.6.22.10/fs/super.c 2007-07-09 13:19:28 +0200
9815 +++ linux-2.6.22.10-vs2.3.0.29/fs/super.c 2007-10-20 00:00:59 +0200
9817 #include <linux/idr.h>
9818 #include <linux/kobject.h>
9819 #include <linux/mutex.h>
9820 +#include <linux/devpts_fs.h>
9821 +#include <linux/proc_fs.h>
9822 +#include <linux/vs_context.h>
9823 #include <asm/uaccess.h>
9826 @@ -860,12 +863,18 @@ struct vfsmount *
9827 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9829 struct vfsmount *mnt;
9830 + struct super_block *sb;
9831 char *secdata = NULL;
9835 return ERR_PTR(-ENODEV);
9838 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9839 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9843 mnt = alloc_vfsmnt(name);
9845 @@ -885,7 +894,14 @@ vfs_kern_mount(struct file_system_type *
9847 goto out_free_secdata;
9849 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
9852 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9853 + (sb->s_magic != PROC_SUPER_MAGIC) &&
9854 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
9857 + error = security_sb_kern_mount(sb, secdata);
9861 diff -NurpP --minimal linux-2.6.22.10/fs/sysfs/mount.c linux-2.6.22.10-vs2.3.0.29/fs/sysfs/mount.c
9862 --- linux-2.6.22.10/fs/sysfs/mount.c 2007-07-09 13:19:28 +0200
9863 +++ linux-2.6.22.10-vs2.3.0.29/fs/sysfs/mount.c 2007-08-05 20:53:13 +0200
9868 -/* Random magic number */
9869 -#define SYSFS_MAGIC 0x62656572
9871 struct vfsmount *sysfs_mount;
9872 struct super_block * sysfs_sb = NULL;
9873 @@ -48,7 +46,7 @@ static int sysfs_fill_super(struct super
9875 sb->s_blocksize = PAGE_CACHE_SIZE;
9876 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9877 - sb->s_magic = SYSFS_MAGIC;
9878 + sb->s_magic = SYSFS_SUPER_MAGIC;
9879 sb->s_op = &sysfs_ops;
9880 sb->s_time_gran = 1;
9882 diff -NurpP --minimal linux-2.6.22.10/fs/utimes.c linux-2.6.22.10-vs2.3.0.29/fs/utimes.c
9883 --- linux-2.6.22.10/fs/utimes.c 2007-07-09 13:19:29 +0200
9884 +++ linux-2.6.22.10-vs2.3.0.29/fs/utimes.c 2007-08-05 20:53:13 +0200
9886 #include <linux/sched.h>
9887 #include <linux/stat.h>
9888 #include <linux/utime.h>
9889 +#include <linux/mount.h>
9890 +#include <linux/vs_cowbl.h>
9891 #include <asm/uaccess.h>
9892 #include <asm/unistd.h>
9894 @@ -70,11 +72,13 @@ long do_utimes(int dfd, char __user *fil
9898 + error = cow_check_and_break(&nd);
9900 + goto dput_and_out;
9904 inode = dentry->d_inode;
9907 if (IS_RDONLY(inode))
9909 diff -NurpP --minimal linux-2.6.22.10/fs/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/xattr.c
9910 --- linux-2.6.22.10/fs/xattr.c 2007-07-09 13:19:29 +0200
9911 +++ linux-2.6.22.10-vs2.3.0.29/fs/xattr.c 2007-08-05 20:53:13 +0200
9913 #include <linux/module.h>
9914 #include <linux/fsnotify.h>
9915 #include <linux/audit.h>
9916 +#include <linux/mount.h>
9917 #include <asm/uaccess.h>
9920 @@ -194,7 +195,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
9923 setxattr(struct dentry *d, char __user *name, void __user *value,
9924 - size_t size, int flags)
9925 + size_t size, int flags, struct vfsmount *mnt)
9928 void *kvalue = NULL;
9929 @@ -221,6 +222,9 @@ setxattr(struct dentry *d, char __user *
9933 + if (MNT_IS_RDONLY(mnt))
9936 error = vfs_setxattr(d, kname, kvalue, size, flags);
9939 @@ -236,7 +240,7 @@ sys_setxattr(char __user *path, char __u
9940 error = user_path_walk(path, &nd);
9943 - error = setxattr(nd.dentry, name, value, size, flags);
9944 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
9948 @@ -251,7 +255,7 @@ sys_lsetxattr(char __user *path, char __
9949 error = user_path_walk_link(path, &nd);
9952 - error = setxattr(nd.dentry, name, value, size, flags);
9953 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
9957 @@ -269,7 +273,7 @@ sys_fsetxattr(int fd, char __user *name,
9959 dentry = f->f_path.dentry;
9960 audit_inode(NULL, dentry->d_inode);
9961 - error = setxattr(dentry, name, value, size, flags);
9962 + error = setxattr(dentry, name, value, size, flags, f->f_vfsmnt);
9966 @@ -433,7 +437,7 @@ sys_flistxattr(int fd, char __user *list
9967 * Extended attribute REMOVE operations
9970 -removexattr(struct dentry *d, char __user *name)
9971 +removexattr(struct dentry *d, char __user *name, struct vfsmount *mnt)
9974 char kname[XATTR_NAME_MAX + 1];
9975 @@ -444,6 +448,9 @@ removexattr(struct dentry *d, char __use
9979 + if (MNT_IS_RDONLY(mnt))
9982 return vfs_removexattr(d, kname);
9985 @@ -456,7 +463,7 @@ sys_removexattr(char __user *path, char
9986 error = user_path_walk(path, &nd);
9989 - error = removexattr(nd.dentry, name);
9990 + error = removexattr(nd.dentry, name, nd.mnt);
9994 @@ -470,7 +477,7 @@ sys_lremovexattr(char __user *path, char
9995 error = user_path_walk_link(path, &nd);
9998 - error = removexattr(nd.dentry, name);
9999 + error = removexattr(nd.dentry, name, nd.mnt);
10003 @@ -487,7 +494,7 @@ sys_fremovexattr(int fd, char __user *na
10005 dentry = f->f_path.dentry;
10006 audit_inode(NULL, dentry->d_inode);
10007 - error = removexattr(dentry, name);
10008 + error = removexattr(dentry, name, f->f_vfsmnt);
10012 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_ioctl.c
10013 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_ioctl.c 2007-05-02 19:25:22 +0200
10014 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_ioctl.c 2007-08-05 20:53:13 +0200
10015 @@ -1128,6 +1128,10 @@ xfs_di2lxflags(
10017 if (di_flags & XFS_DIFLAG_IMMUTABLE)
10018 flags |= FS_IMMUTABLE_FL;
10019 + if (di_flags & XFS_DIFLAG_IUNLINK)
10020 + flags |= FS_IUNLINK_FL;
10021 + if (di_flags & XFS_DIFLAG_BARRIER)
10022 + flags |= FS_BARRIER_FL;
10023 if (di_flags & XFS_DIFLAG_APPEND)
10024 flags |= FS_APPEND_FL;
10025 if (di_flags & XFS_DIFLAG_SYNC)
10026 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_iops.c
10027 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_iops.c 2007-05-02 19:25:22 +0200
10028 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_iops.c 2007-08-05 20:53:13 +0200
10030 #include <linux/xattr.h>
10031 #include <linux/namei.h>
10032 #include <linux/security.h>
10033 +#include <linux/vs_tag.h>
10036 * Get a XFS inode from a given vnode.
10037 @@ -400,6 +401,7 @@ xfs_vn_lookup(
10038 d_add(dentry, NULL);
10041 + dx_propagate_tag(nd, vn_to_inode(cvp));
10043 return d_splice_alias(vn_to_inode(cvp), dentry);
10045 @@ -657,6 +659,10 @@ xfs_vn_setattr(
10049 + error = inode_change_ok(inode, attr);
10053 if (ia_valid & ATTR_UID) {
10054 vattr.va_mask |= XFS_AT_UID;
10055 vattr.va_uid = attr->ia_uid;
10056 @@ -665,6 +671,10 @@ xfs_vn_setattr(
10057 vattr.va_mask |= XFS_AT_GID;
10058 vattr.va_gid = attr->ia_gid;
10060 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode)) {
10061 + vattr.va_mask |= XFS_AT_TAG;
10062 + vattr.va_tag = attr->ia_tag;
10064 if (ia_valid & ATTR_SIZE) {
10065 vattr.va_mask |= XFS_AT_SIZE;
10066 vattr.va_size = attr->ia_size;
10067 @@ -710,6 +720,42 @@ xfs_vn_truncate(
10071 +xfs_vn_sync_flags(struct inode *inode)
10073 + unsigned int oldflags, newflags;
10076 + bhv_vattr_t vattr;
10077 + bhv_vnode_t *vp = vn_from_inode(inode);
10079 + memset(&vattr, 0, sizeof vattr);
10081 + vattr.va_mask = XFS_AT_XFLAGS;
10082 + error = bhv_vop_getattr(vp, &vattr, 0, NULL);
10086 + oldflags = vattr.va_xflags;
10087 + newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
10088 + XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
10090 + if (IS_IMMUTABLE(inode))
10091 + newflags |= XFS_XFLAG_IMMUTABLE;
10092 + if (IS_IUNLINK(inode))
10093 + newflags |= XFS_XFLAG_IUNLINK;
10094 + if (IS_BARRIER(inode))
10095 + newflags |= XFS_XFLAG_BARRIER;
10097 + if (oldflags ^ newflags) {
10098 + vattr.va_xflags = newflags;
10099 + vattr.va_mask |= XFS_AT_XFLAGS;
10100 + error = bhv_vop_setattr(vp, &vattr, flags, NULL);
10102 + vn_revalidate(vp);
10108 struct dentry *dentry,
10110 @@ -822,6 +868,7 @@ const struct inode_operations xfs_inode_
10111 .getxattr = xfs_vn_getxattr,
10112 .listxattr = xfs_vn_listxattr,
10113 .removexattr = xfs_vn_removexattr,
10114 + .sync_flags = xfs_vn_sync_flags,
10117 const struct inode_operations xfs_dir_inode_operations = {
10118 @@ -841,6 +888,7 @@ const struct inode_operations xfs_dir_in
10119 .getxattr = xfs_vn_getxattr,
10120 .listxattr = xfs_vn_listxattr,
10121 .removexattr = xfs_vn_removexattr,
10122 + .sync_flags = xfs_vn_sync_flags,
10125 const struct inode_operations xfs_symlink_inode_operations = {
10126 @@ -854,4 +902,5 @@ const struct inode_operations xfs_symlin
10127 .getxattr = xfs_vn_getxattr,
10128 .listxattr = xfs_vn_listxattr,
10129 .removexattr = xfs_vn_removexattr,
10130 + .sync_flags = xfs_vn_sync_flags,
10132 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_linux.h
10133 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_linux.h 2007-05-02 19:25:22 +0200
10134 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_linux.h 2007-08-05 20:53:13 +0200
10135 @@ -129,6 +129,7 @@
10136 #define current_pid() (current->pid)
10137 #define current_fsuid(cred) (current->fsuid)
10138 #define current_fsgid(cred) (current->fsgid)
10139 +#define current_fstag(cred,vp) (dx_current_fstag(vn_to_inode(vp)->i_sb))
10140 #define current_test_flags(f) (current->flags & (f))
10141 #define current_set_flags_nested(sp, f) \
10142 (*(sp) = current->flags, current->flags |= (f))
10143 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_super.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_super.c
10144 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_super.c 2007-07-09 13:19:29 +0200
10145 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_super.c 2007-08-05 20:53:13 +0200
10146 @@ -157,6 +157,7 @@ xfs_revalidate_inode(
10147 inode->i_nlink = ip->i_d.di_nlink;
10148 inode->i_uid = ip->i_d.di_uid;
10149 inode->i_gid = ip->i_d.di_gid;
10150 + inode->i_tag = ip->i_d.di_tag;
10152 switch (inode->i_mode & S_IFMT) {
10154 @@ -184,6 +185,14 @@ xfs_revalidate_inode(
10155 inode->i_flags |= S_IMMUTABLE;
10157 inode->i_flags &= ~S_IMMUTABLE;
10158 + if (ip->i_d.di_flags & XFS_DIFLAG_IUNLINK)
10159 + inode->i_flags |= S_IUNLINK;
10161 + inode->i_flags &= ~S_IUNLINK;
10162 + if (ip->i_d.di_flags & XFS_DIFLAG_BARRIER)
10163 + inode->i_flags |= S_BARRIER;
10165 + inode->i_flags &= ~S_BARRIER;
10166 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
10167 inode->i_flags |= S_APPEND;
10169 @@ -712,6 +721,12 @@ xfs_fs_remount(
10172 error = bhv_vfs_parseargs(vfsp, options, args, 1);
10173 + if ((args->flags2 & XFSMNT2_TAGGED) &&
10174 + !(sb->s_flags & MS_TAGGED)) {
10175 + printk("XFS: %s: tagging not permitted on remount.\n",
10180 error = bhv_vfs_mntupdate(vfsp, flags, args);
10181 kmem_free(args, sizeof(*args));
10182 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_vnode.c
10183 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.c 2007-05-02 19:25:22 +0200
10184 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_vnode.c 2007-08-05 20:53:13 +0200
10185 @@ -119,6 +119,7 @@ vn_revalidate_core(
10186 inode->i_nlink = vap->va_nlink;
10187 inode->i_uid = vap->va_uid;
10188 inode->i_gid = vap->va_gid;
10189 + inode->i_tag = vap->va_tag;
10190 inode->i_blocks = vap->va_nblocks;
10191 inode->i_mtime = vap->va_mtime;
10192 inode->i_ctime = vap->va_ctime;
10193 @@ -126,6 +127,14 @@ vn_revalidate_core(
10194 inode->i_flags |= S_IMMUTABLE;
10196 inode->i_flags &= ~S_IMMUTABLE;
10197 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10198 + inode->i_flags |= S_IUNLINK;
10200 + inode->i_flags &= ~S_IUNLINK;
10201 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10202 + inode->i_flags |= S_BARRIER;
10204 + inode->i_flags &= ~S_BARRIER;
10205 if (vap->va_xflags & XFS_XFLAG_APPEND)
10206 inode->i_flags |= S_APPEND;
10208 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_vnode.h
10209 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.h 2007-07-09 13:19:29 +0200
10210 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_vnode.h 2007-08-05 20:53:13 +0200
10211 @@ -350,6 +350,7 @@ typedef struct bhv_vattr {
10212 xfs_nlink_t va_nlink; /* number of references to file */
10213 uid_t va_uid; /* owner user id */
10214 gid_t va_gid; /* owner group id */
10215 + tag_t va_tag; /* owner group id */
10216 xfs_ino_t va_nodeid; /* file id */
10217 xfs_off_t va_size; /* file size in bytes */
10218 u_long va_blocksize; /* blocksize preferred for i/o */
10219 @@ -398,13 +399,15 @@ typedef struct bhv_vattr {
10220 #define XFS_AT_PROJID 0x04000000
10221 #define XFS_AT_SIZE_NOPERM 0x08000000
10222 #define XFS_AT_GENCOUNT 0x10000000
10223 +#define XFS_AT_TAG 0x20000000
10225 #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
10226 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
10227 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
10228 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
10229 XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
10230 - XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
10231 + XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT\
10234 #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
10235 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
10236 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/quota/xfs_qm_syscalls.c
10237 --- linux-2.6.22.10/fs/xfs/quota/xfs_qm_syscalls.c 2007-07-09 13:19:29 +0200
10238 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/quota/xfs_qm_syscalls.c 2007-08-05 20:53:13 +0200
10242 #include <linux/capability.h>
10243 +#include <linux/vs_context.h>
10246 #include "xfs_fs.h"
10247 @@ -211,7 +212,7 @@ xfs_qm_scall_quotaoff(
10248 xfs_qoff_logitem_t *qoffstart;
10251 - if (!force && !capable(CAP_SYS_ADMIN))
10252 + if (!force && !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10253 return XFS_ERROR(EPERM);
10255 * No file system can have quotas enabled on disk but not in core.
10256 @@ -380,7 +381,7 @@ xfs_qm_scall_trunc_qfiles(
10260 - if (!capable(CAP_SYS_ADMIN))
10261 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10262 return XFS_ERROR(EPERM);
10264 if (!XFS_SB_VERSION_HASQUOTA(&mp->m_sb) || flags == 0) {
10265 @@ -425,7 +426,7 @@ xfs_qm_scall_quotaon(
10269 - if (!capable(CAP_SYS_ADMIN))
10270 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10271 return XFS_ERROR(EPERM);
10273 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
10274 @@ -594,7 +595,7 @@ xfs_qm_scall_setqlim(
10276 xfs_qcnt_t hard, soft;
10278 - if (!capable(CAP_SYS_ADMIN))
10279 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10280 return XFS_ERROR(EPERM);
10282 if ((newlim->d_fieldmask &
10283 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_clnt.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_clnt.h
10284 --- linux-2.6.22.10/fs/xfs/xfs_clnt.h 2006-06-18 04:54:50 +0200
10285 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_clnt.h 2007-08-05 20:53:13 +0200
10286 @@ -99,5 +99,7 @@ struct xfs_mount_args {
10288 #define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred
10289 * I/O size in stat(2) */
10290 +#define XFSMNT2_TAGGED 0x80000000 /* context tagging */
10293 #endif /* __XFS_CLNT_H__ */
10294 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_dinode.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_dinode.h
10295 --- linux-2.6.22.10/fs/xfs/xfs_dinode.h 2006-09-20 16:58:40 +0200
10296 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_dinode.h 2007-08-05 20:53:13 +0200
10297 @@ -53,7 +53,8 @@ typedef struct xfs_dinode_core
10298 __uint32_t di_gid; /* owner's group id */
10299 __uint32_t di_nlink; /* number of links to file */
10300 __uint16_t di_projid; /* owner's project id */
10301 - __uint8_t di_pad[8]; /* unused, zeroed space */
10302 + __uint16_t di_tag; /* context tagging */
10303 + __uint8_t di_pad[6]; /* unused, zeroed space */
10304 __uint16_t di_flushiter; /* incremented on flush */
10305 xfs_timestamp_t di_atime; /* time last accessed */
10306 xfs_timestamp_t di_mtime; /* time last modified */
10307 @@ -257,6 +258,9 @@ typedef enum xfs_dinode_fmt
10308 #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */
10309 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
10310 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
10311 +#define XFS_DIFLAG_BARRIER_BIT 14 /* chroot() barrier */
10312 +#define XFS_DIFLAG_IUNLINK_BIT 15 /* immutable unlink */
10314 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
10315 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
10316 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
10317 @@ -271,12 +275,15 @@ typedef enum xfs_dinode_fmt
10318 #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT)
10319 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
10320 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
10321 +#define XFS_DIFLAG_BARRIER (1 << XFS_DIFLAG_BARRIER_BIT)
10322 +#define XFS_DIFLAG_IUNLINK (1 << XFS_DIFLAG_IUNLINK_BIT)
10324 #define XFS_DIFLAG_ANY \
10325 (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
10326 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
10327 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
10328 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
10329 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG)
10330 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_BARRIER | \
10331 + XFS_DIFLAG_IUNLINK)
10333 #endif /* __XFS_DINODE_H__ */
10334 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_fs.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_fs.h
10335 --- linux-2.6.22.10/fs/xfs/xfs_fs.h 2006-11-30 21:19:29 +0100
10336 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_fs.h 2007-08-05 20:53:13 +0200
10337 @@ -66,6 +66,8 @@ struct fsxattr {
10338 #define XFS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */
10339 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
10340 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
10341 +#define XFS_XFLAG_BARRIER 0x00004000 /* chroot() barrier */
10342 +#define XFS_XFLAG_IUNLINK 0x00008000 /* immutable unlink */
10343 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
10346 @@ -294,7 +296,8 @@ typedef struct xfs_bstat {
10347 __s32 bs_extents; /* number of extents */
10348 __u32 bs_gen; /* generation count */
10349 __u16 bs_projid; /* project id */
10350 - unsigned char bs_pad[14]; /* pad space, unused */
10351 + __u16 bs_tag; /* context tagging */
10352 + unsigned char bs_pad[12]; /* pad space, unused */
10353 __u32 bs_dmevmask; /* DMIG event mask */
10354 __u16 bs_dmstate; /* DMIG state info */
10355 __u16 bs_aextents; /* attribute number of extents */
10356 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_inode.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_inode.c
10357 --- linux-2.6.22.10/fs/xfs/xfs_inode.c 2007-07-09 13:19:34 +0200
10358 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_inode.c 2007-08-05 20:53:13 +0200
10360 #include "xfs_quota.h"
10361 #include "xfs_acl.h"
10363 +#include <linux/vs_tag.h>
10365 kmem_zone_t *xfs_ifork_zone;
10366 kmem_zone_t *xfs_inode_zone;
10367 @@ -736,20 +737,35 @@ xfs_xlate_dinode_core(
10368 xfs_dinode_core_t *buf_core = (xfs_dinode_core_t *)buf;
10369 xfs_dinode_core_t *mem_core = (xfs_dinode_core_t *)dip;
10370 xfs_arch_t arch = ARCH_CONVERT;
10371 + uint32_t uid = 0, gid = 0;
10372 + uint16_t tag = 0;
10377 + tag = mem_core->di_tag;
10378 + /* FIXME: supposed to use superblock flag */
10379 + uid = TAGINO_UID(1, mem_core->di_uid, tag);
10380 + gid = TAGINO_GID(1, mem_core->di_gid, tag);
10381 + tag = TAGINO_TAG(1, tag);
10384 INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch);
10385 INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch);
10386 INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch);
10387 INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch);
10388 INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch);
10389 - INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch);
10390 - INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch);
10391 + INT_XLATE(buf_core->di_uid, uid, dir, arch);
10392 + INT_XLATE(buf_core->di_gid, gid, dir, arch);
10393 + INT_XLATE(buf_core->di_tag, tag, dir, arch);
10394 INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch);
10395 INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch);
10398 + /* FIXME: supposed to use superblock flag */
10399 + mem_core->di_uid = INOTAG_UID(1, uid, gid);
10400 + mem_core->di_gid = INOTAG_GID(1, uid, gid);
10401 + mem_core->di_tag = INOTAG_TAG(1, uid, gid, tag);
10402 memcpy(mem_core->di_pad, buf_core->di_pad,
10403 sizeof(buf_core->di_pad));
10405 @@ -797,6 +813,10 @@ _xfs_dic2xflags(
10406 flags |= XFS_XFLAG_PREALLOC;
10407 if (di_flags & XFS_DIFLAG_IMMUTABLE)
10408 flags |= XFS_XFLAG_IMMUTABLE;
10409 + if (di_flags & XFS_DIFLAG_IUNLINK)
10410 + flags |= XFS_XFLAG_IUNLINK;
10411 + if (di_flags & XFS_DIFLAG_BARRIER)
10412 + flags |= XFS_XFLAG_BARRIER;
10413 if (di_flags & XFS_DIFLAG_APPEND)
10414 flags |= XFS_XFLAG_APPEND;
10415 if (di_flags & XFS_DIFLAG_SYNC)
10416 @@ -1129,6 +1149,7 @@ xfs_ialloc(
10417 ASSERT(ip->i_d.di_nlink == nlink);
10418 ip->i_d.di_uid = current_fsuid(cr);
10419 ip->i_d.di_gid = current_fsgid(cr);
10420 + ip->i_d.di_tag = current_fstag(cr, vp);
10421 ip->i_d.di_projid = prid;
10422 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
10424 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_itable.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_itable.c
10425 --- linux-2.6.22.10/fs/xfs/xfs_itable.c 2007-07-09 13:19:34 +0200
10426 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_itable.c 2007-08-05 20:53:13 +0200
10427 @@ -89,6 +89,7 @@ xfs_bulkstat_one_iget(
10428 buf->bs_mode = dic->di_mode;
10429 buf->bs_uid = dic->di_uid;
10430 buf->bs_gid = dic->di_gid;
10431 + buf->bs_tag = dic->di_tag;
10432 buf->bs_size = dic->di_size;
10433 vn_atime_to_bstime(vp, &buf->bs_atime);
10434 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
10435 @@ -163,6 +164,7 @@ xfs_bulkstat_one_dinode(
10436 buf->bs_mode = INT_GET(dic->di_mode, ARCH_CONVERT);
10437 buf->bs_uid = INT_GET(dic->di_uid, ARCH_CONVERT);
10438 buf->bs_gid = INT_GET(dic->di_gid, ARCH_CONVERT);
10439 + buf->bs_tag = INT_GET(dic->di_tag, ARCH_CONVERT);
10440 buf->bs_size = INT_GET(dic->di_size, ARCH_CONVERT);
10441 buf->bs_atime.tv_sec = INT_GET(dic->di_atime.t_sec, ARCH_CONVERT);
10442 buf->bs_atime.tv_nsec = INT_GET(dic->di_atime.t_nsec, ARCH_CONVERT);
10443 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_mount.h linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_mount.h
10444 --- linux-2.6.22.10/fs/xfs/xfs_mount.h 2007-05-02 19:25:23 +0200
10445 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_mount.h 2007-08-05 20:53:13 +0200
10446 @@ -464,6 +464,7 @@ typedef struct xfs_mount {
10447 #define XFS_MOUNT_NO_PERCPU_SB (1ULL << 23) /* don't use per-cpu superblock
10450 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
10453 * Default minimum read and write sizes.
10454 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_vfsops.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_vfsops.c
10455 --- linux-2.6.22.10/fs/xfs/xfs_vfsops.c 2007-07-09 13:19:34 +0200
10456 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_vfsops.c 2007-08-05 20:53:13 +0200
10457 @@ -300,6 +300,8 @@ xfs_start_flags(
10459 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
10460 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
10461 + if (ap->flags2 & XFSMNT2_TAGGED)
10462 + mp->m_flags |= XFS_MOUNT_TAGGED;
10465 * no recovery flag requires a read-only mount
10466 @@ -394,6 +396,8 @@ xfs_finish_flags(
10467 return XFS_ERROR(EINVAL);
10470 + if (ap->flags2 & XFSMNT2_TAGGED)
10471 + vfs->vfs_super->s_flags |= MS_TAGGED;
10475 @@ -1645,6 +1649,9 @@ xfs_vget(
10477 #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
10478 #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
10479 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
10480 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
10481 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
10483 STATIC unsigned long
10484 suffix_strtoul(char *s, char **endp, unsigned int base)
10485 @@ -1831,6 +1838,19 @@ xfs_parseargs(
10486 args->flags |= XFSMNT_ATTR2;
10487 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
10488 args->flags &= ~XFSMNT_ATTR2;
10489 +#ifndef CONFIG_TAGGING_NONE
10490 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
10491 + args->flags2 |= XFSMNT2_TAGGED;
10492 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
10493 + args->flags2 &= ~XFSMNT2_TAGGED;
10494 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
10495 + args->flags2 |= XFSMNT2_TAGGED;
10497 +#ifdef CONFIG_PROPAGATE
10498 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
10500 + args->flags2 |= XFSMNT2_TAGGED;
10502 } else if (!strcmp(this_char, "osyncisdsync")) {
10503 /* no-op, this is now the default */
10505 diff -NurpP --minimal linux-2.6.22.10/fs/xfs/xfs_vnodeops.c linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_vnodeops.c
10506 --- linux-2.6.22.10/fs/xfs/xfs_vnodeops.c 2007-07-09 13:19:34 +0200
10507 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_vnodeops.c 2007-08-05 20:53:13 +0200
10508 @@ -159,6 +159,7 @@ xfs_getattr(
10509 vap->va_mode = ip->i_d.di_mode;
10510 vap->va_uid = ip->i_d.di_uid;
10511 vap->va_gid = ip->i_d.di_gid;
10512 + vap->va_tag = ip->i_d.di_tag;
10513 vap->va_projid = ip->i_d.di_projid;
10516 @@ -259,6 +260,7 @@ xfs_setattr(
10517 uint commit_flags=0;
10518 uid_t uid=0, iuid=0;
10519 gid_t gid=0, igid=0;
10520 + tag_t tag=0, itag=0;
10523 xfs_prid_t projid=0, iprojid=0;
10524 @@ -315,6 +317,7 @@ xfs_setattr(
10525 (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID))) {
10528 + /* TODO: handle tagging? */
10529 if ((mask & XFS_AT_UID) && XFS_IS_UQUOTA_ON(mp)) {
10531 qflags |= XFS_QMOPT_UQUOTA;
10532 @@ -394,6 +397,8 @@ xfs_setattr(
10534 (XFS_AT_MODE|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_UID|
10535 XFS_AT_GID|XFS_AT_PROJID)) {
10536 + /* TODO: handle tagging? */
10539 * CAP_FOWNER overrides the following restrictions:
10541 @@ -442,7 +447,7 @@ xfs_setattr(
10542 * and can change the group id only to a group of which he
10543 * or she is a member.
10545 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10546 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10548 * These IDs could have changed since we last looked at them.
10549 * But, we're assured that if the ownership did change
10550 @@ -450,10 +455,12 @@ xfs_setattr(
10551 * would have changed also.
10553 iuid = ip->i_d.di_uid;
10554 - iprojid = ip->i_d.di_projid;
10555 igid = ip->i_d.di_gid;
10556 - gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10557 + itag = ip->i_d.di_tag;
10558 + iprojid = ip->i_d.di_projid;
10559 uid = (mask & XFS_AT_UID) ? vap->va_uid : iuid;
10560 + gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10561 + tag = (mask & XFS_AT_TAG) ? vap->va_tag : itag;
10562 projid = (mask & XFS_AT_PROJID) ? (xfs_prid_t)vap->va_projid :
10565 @@ -481,6 +488,7 @@ xfs_setattr(
10566 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
10567 (XFS_IS_PQUOTA_ON(mp) && iprojid != projid) ||
10568 (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
10569 + /* TODO: handle tagging? */
10571 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
10572 capable(CAP_FOWNER) ?
10573 @@ -706,7 +714,7 @@ xfs_setattr(
10574 * and can change the group id only to a group of which he
10575 * or she is a member.
10577 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10578 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10580 * CAP_FSETID overrides the following restrictions:
10582 @@ -722,6 +730,9 @@ xfs_setattr(
10583 * Change the ownerships and register quota modifications
10584 * in the transaction.
10586 + if (itag != tag) {
10587 + ip->i_d.di_tag = tag;
10590 if (XFS_IS_UQUOTA_ON(mp)) {
10591 ASSERT(mask & XFS_AT_UID);
10592 @@ -802,6 +813,10 @@ xfs_setattr(
10593 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
10594 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
10595 di_flags |= XFS_DIFLAG_IMMUTABLE;
10596 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10597 + di_flags |= XFS_DIFLAG_IUNLINK;
10598 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10599 + di_flags |= XFS_DIFLAG_BARRIER;
10600 if (vap->va_xflags & XFS_XFLAG_APPEND)
10601 di_flags |= XFS_DIFLAG_APPEND;
10602 if (vap->va_xflags & XFS_XFLAG_SYNC)
10603 diff -NurpP --minimal linux-2.6.22.10/include/asm-alpha/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-alpha/socket.h
10604 --- linux-2.6.22.10/include/asm-alpha/socket.h 2007-07-09 13:19:35 +0200
10605 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-alpha/socket.h 2007-08-05 20:53:13 +0200
10607 #define SO_TIMESTAMPNS 35
10608 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10610 +#define SO_PEERTAG 36
10612 /* Security levels - as per NRL IPv6 - don't actually do anything */
10613 #define SO_SECURITY_AUTHENTICATION 19
10614 #define SO_SECURITY_ENCRYPTION_TRANSPORT 20
10615 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-arm/socket.h
10616 --- linux-2.6.22.10/include/asm-arm/socket.h 2007-07-09 13:19:39 +0200
10617 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm/socket.h 2007-08-05 20:53:13 +0200
10619 #define SO_TIMESTAMPNS 35
10620 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10622 +#define SO_PEERTAG 36
10624 #endif /* _ASM_SOCKET_H */
10625 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm/tlb.h linux-2.6.22.10-vs2.3.0.29/include/asm-arm/tlb.h
10626 --- linux-2.6.22.10/include/asm-arm/tlb.h 2006-06-18 04:54:58 +0200
10627 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm/tlb.h 2007-08-05 20:53:13 +0200
10629 #else /* !CONFIG_MMU */
10631 #include <asm/pgalloc.h>
10632 +#include <linux/vs_memory.h>
10635 * TLB handling. This allows us to remove pages from the page
10636 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm26/tlb.h linux-2.6.22.10-vs2.3.0.29/include/asm-arm26/tlb.h
10637 --- linux-2.6.22.10/include/asm-arm26/tlb.h 2006-01-03 17:30:02 +0100
10638 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm26/tlb.h 2007-08-05 20:53:13 +0200
10641 #include <asm/pgalloc.h>
10642 #include <asm/tlbflush.h>
10643 +#include <linux/vs_memory.h>
10646 * TLB handling. This allows us to remove pages from the page
10647 diff -NurpP --minimal linux-2.6.22.10/include/asm-arm26/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-arm26/unistd.h
10648 --- linux-2.6.22.10/include/asm-arm26/unistd.h 2007-02-06 03:01:35 +0100
10649 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm26/unistd.h 2007-08-05 20:53:13 +0200
10650 @@ -302,6 +302,8 @@
10651 #define __NR_mq_getsetattr (__NR_SYSCALL_BASE+279)
10652 #define __NR_waitid (__NR_SYSCALL_BASE+280)
10654 +#define __NR_vserver (__NR_SYSCALL_BASE+313)
10657 * The following SWIs are ARM private. FIXME - make appropriate for arm26
10659 diff -NurpP --minimal linux-2.6.22.10/include/asm-cris/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-cris/socket.h
10660 --- linux-2.6.22.10/include/asm-cris/socket.h 2007-07-09 13:19:40 +0200
10661 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-cris/socket.h 2007-08-05 20:53:13 +0200
10663 #define SO_TIMESTAMPNS 35
10664 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10666 +#define SO_PEERTAG 36
10668 #endif /* _ASM_SOCKET_H */
10671 diff -NurpP --minimal linux-2.6.22.10/include/asm-frv/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-frv/socket.h
10672 --- linux-2.6.22.10/include/asm-frv/socket.h 2007-07-09 13:19:40 +0200
10673 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-frv/socket.h 2007-08-05 20:53:13 +0200
10675 #define SO_TIMESTAMPNS 35
10676 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10678 +#define SO_PEERTAG 36
10680 #endif /* _ASM_SOCKET_H */
10682 diff -NurpP --minimal linux-2.6.22.10/include/asm-generic/tlb.h linux-2.6.22.10-vs2.3.0.29/include/asm-generic/tlb.h
10683 --- linux-2.6.22.10/include/asm-generic/tlb.h 2006-11-30 21:19:31 +0100
10684 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-generic/tlb.h 2007-08-05 20:53:13 +0200
10686 #define _ASM_GENERIC__TLB_H
10688 #include <linux/swap.h>
10689 +#include <linux/vs_memory.h>
10690 #include <asm/pgalloc.h>
10691 #include <asm/tlbflush.h>
10693 diff -NurpP --minimal linux-2.6.22.10/include/asm-h8300/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-h8300/socket.h
10694 --- linux-2.6.22.10/include/asm-h8300/socket.h 2007-07-09 13:19:40 +0200
10695 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-h8300/socket.h 2007-08-05 20:53:13 +0200
10697 #define SO_TIMESTAMPNS 35
10698 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10700 +#define SO_PEERTAG 36
10702 #endif /* _ASM_SOCKET_H */
10703 diff -NurpP --minimal linux-2.6.22.10/include/asm-i386/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-i386/socket.h
10704 --- linux-2.6.22.10/include/asm-i386/socket.h 2007-07-09 13:19:42 +0200
10705 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-i386/socket.h 2007-08-05 20:53:13 +0200
10707 #define SO_TIMESTAMPNS 35
10708 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10710 +#define SO_PEERTAG 36
10712 #endif /* _ASM_SOCKET_H */
10713 diff -NurpP --minimal linux-2.6.22.10/include/asm-ia64/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-ia64/socket.h
10714 --- linux-2.6.22.10/include/asm-ia64/socket.h 2007-07-09 13:19:43 +0200
10715 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-ia64/socket.h 2007-08-05 20:53:13 +0200
10717 #define SO_TIMESTAMPNS 35
10718 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10720 +#define SO_PEERTAG 36
10722 #endif /* _ASM_IA64_SOCKET_H */
10723 diff -NurpP --minimal linux-2.6.22.10/include/asm-ia64/tlb.h linux-2.6.22.10-vs2.3.0.29/include/asm-ia64/tlb.h
10724 --- linux-2.6.22.10/include/asm-ia64/tlb.h 2006-09-20 16:58:40 +0200
10725 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-ia64/tlb.h 2007-08-05 20:53:13 +0200
10727 #include <linux/mm.h>
10728 #include <linux/pagemap.h>
10729 #include <linux/swap.h>
10730 +#include <linux/vs_memory.h>
10732 #include <asm/pgalloc.h>
10733 #include <asm/processor.h>
10734 diff -NurpP --minimal linux-2.6.22.10/include/asm-m32r/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-m32r/socket.h
10735 --- linux-2.6.22.10/include/asm-m32r/socket.h 2007-07-09 13:19:43 +0200
10736 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-m32r/socket.h 2007-08-05 20:53:13 +0200
10738 #define SO_TIMESTAMPNS 35
10739 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10741 +#define SO_PEERTAG 36
10743 #endif /* _ASM_M32R_SOCKET_H */
10744 diff -NurpP --minimal linux-2.6.22.10/include/asm-mips/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-mips/socket.h
10745 --- linux-2.6.22.10/include/asm-mips/socket.h 2007-07-09 13:19:44 +0200
10746 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-mips/socket.h 2007-08-05 20:53:13 +0200
10747 @@ -73,6 +73,8 @@ To add: #define SO_REUSEPORT 0x0200 /* A
10748 #define SO_TIMESTAMPNS 35
10749 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10751 +#define SO_PEERTAG 36
10755 /** sock_type - Socket types
10756 diff -NurpP --minimal linux-2.6.22.10/include/asm-parisc/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-parisc/socket.h
10757 --- linux-2.6.22.10/include/asm-parisc/socket.h 2007-07-09 13:19:44 +0200
10758 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-parisc/socket.h 2007-08-05 20:53:13 +0200
10761 #define SO_PEERSEC 0x401d
10762 #define SO_PASSSEC 0x401e
10763 +#define SO_PEERTAG 0x401f
10765 #endif /* _ASM_SOCKET_H */
10766 diff -NurpP --minimal linux-2.6.22.10/include/asm-powerpc/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/socket.h
10767 --- linux-2.6.22.10/include/asm-powerpc/socket.h 2007-07-09 13:19:44 +0200
10768 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/socket.h 2007-08-05 20:53:13 +0200
10770 #define SO_TIMESTAMPNS 35
10771 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10773 +#define SO_PEERTAG 36
10775 #endif /* _ASM_POWERPC_SOCKET_H */
10776 diff -NurpP --minimal linux-2.6.22.10/include/asm-powerpc/systbl.h linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/systbl.h
10777 --- linux-2.6.22.10/include/asm-powerpc/systbl.h 2007-07-09 13:19:44 +0200
10778 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/systbl.h 2007-08-05 20:53:13 +0200
10779 @@ -260,7 +260,7 @@ COMPAT_SYS_SPU(fstatfs64)
10780 SYSX(sys_ni_syscall, ppc_fadvise64_64, ppc_fadvise64_64)
10782 OLDSYS(debug_setcontext)
10783 -SYSCALL(ni_syscall)
10784 +SYSX(sys_vserver, sys32_vserver, sys_vserver)
10785 COMPAT_SYS(migrate_pages)
10787 COMPAT_SYS(get_mempolicy)
10788 diff -NurpP --minimal linux-2.6.22.10/include/asm-powerpc/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/unistd.h
10789 --- linux-2.6.22.10/include/asm-powerpc/unistd.h 2007-07-09 13:19:45 +0200
10790 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/unistd.h 2007-08-05 20:53:13 +0200
10791 @@ -275,7 +275,7 @@
10793 #define __NR_rtas 255
10794 #define __NR_sys_debug_setcontext 256
10795 -/* Number 257 is reserved for vserver */
10796 +#define __NR_vserver 257
10797 #define __NR_migrate_pages 258
10798 #define __NR_mbind 259
10799 #define __NR_get_mempolicy 260
10800 diff -NurpP --minimal linux-2.6.22.10/include/asm-s390/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-s390/socket.h
10801 --- linux-2.6.22.10/include/asm-s390/socket.h 2007-07-09 13:19:45 +0200
10802 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-s390/socket.h 2007-08-05 20:53:13 +0200
10804 #define SO_TIMESTAMPNS 35
10805 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10807 +#define SO_PEERTAG 36
10809 #endif /* _ASM_SOCKET_H */
10810 diff -NurpP --minimal linux-2.6.22.10/include/asm-s390/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-s390/unistd.h
10811 --- linux-2.6.22.10/include/asm-s390/unistd.h 2007-07-09 13:19:45 +0200
10812 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-s390/unistd.h 2007-08-05 20:53:13 +0200
10813 @@ -202,7 +202,7 @@
10814 #define __NR_clock_gettime (__NR_timer_create+6)
10815 #define __NR_clock_getres (__NR_timer_create+7)
10816 #define __NR_clock_nanosleep (__NR_timer_create+8)
10817 -/* Number 263 is reserved for vserver */
10818 +#define __NR_vserver 263
10819 #define __NR_statfs64 265
10820 #define __NR_fstatfs64 266
10821 #define __NR_remap_file_pages 267
10822 diff -NurpP --minimal linux-2.6.22.10/include/asm-sh/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-sh/socket.h
10823 --- linux-2.6.22.10/include/asm-sh/socket.h 2007-07-09 13:19:45 +0200
10824 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sh/socket.h 2007-08-05 20:53:13 +0200
10826 #define SO_TIMESTAMPNS 35
10827 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10829 +#define SO_PEERTAG 36
10831 #endif /* __ASM_SH_SOCKET_H */
10832 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-sparc/socket.h
10833 --- linux-2.6.22.10/include/asm-sparc/socket.h 2007-07-09 13:19:54 +0200
10834 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc/socket.h 2007-08-05 20:53:13 +0200
10836 #define SO_TIMESTAMPNS 0x0021
10837 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10839 +#define SO_PEERTAG 36
10841 /* Security levels - as per NRL IPv6 - don't actually do anything */
10842 #define SO_SECURITY_AUTHENTICATION 0x5001
10843 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
10844 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-sparc/unistd.h
10845 --- linux-2.6.22.10/include/asm-sparc/unistd.h 2007-07-09 13:19:54 +0200
10846 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc/unistd.h 2007-08-05 20:53:13 +0200
10847 @@ -283,7 +283,7 @@
10848 #define __NR_timer_getoverrun 264
10849 #define __NR_timer_delete 265
10850 #define __NR_timer_create 266
10851 -/* #define __NR_vserver 267 Reserved for VSERVER */
10852 +#define __NR_vserver 267
10853 #define __NR_io_setup 268
10854 #define __NR_io_destroy 269
10855 #define __NR_io_submit 270
10856 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc64/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/socket.h
10857 --- linux-2.6.22.10/include/asm-sparc64/socket.h 2007-07-09 13:19:54 +0200
10858 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/socket.h 2007-08-05 20:53:13 +0200
10860 #define SO_TIMESTAMPNS 0x0021
10861 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10863 +#define SO_PEERTAG 0x0022
10865 /* Security levels - as per NRL IPv6 - don't actually do anything */
10866 #define SO_SECURITY_AUTHENTICATION 0x5001
10867 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
10868 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc64/tlb.h linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/tlb.h
10869 --- linux-2.6.22.10/include/asm-sparc64/tlb.h 2007-07-09 13:19:54 +0200
10870 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/tlb.h 2007-08-05 20:53:13 +0200
10873 #include <linux/swap.h>
10874 #include <linux/pagemap.h>
10875 +#include <linux/vs_memory.h>
10876 #include <asm/pgalloc.h>
10877 #include <asm/tlbflush.h>
10878 #include <asm/mmu_context.h>
10879 diff -NurpP --minimal linux-2.6.22.10/include/asm-sparc64/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/unistd.h
10880 --- linux-2.6.22.10/include/asm-sparc64/unistd.h 2007-07-09 13:19:54 +0200
10881 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/unistd.h 2007-08-05 20:53:13 +0200
10882 @@ -285,7 +285,7 @@
10883 #define __NR_timer_getoverrun 264
10884 #define __NR_timer_delete 265
10885 #define __NR_timer_create 266
10886 -/* #define __NR_vserver 267 Reserved for VSERVER */
10887 +#define __NR_vserver 267
10888 #define __NR_io_setup 268
10889 #define __NR_io_destroy 269
10890 #define __NR_io_submit 270
10891 diff -NurpP --minimal linux-2.6.22.10/include/asm-v850/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-v850/socket.h
10892 --- linux-2.6.22.10/include/asm-v850/socket.h 2007-07-09 13:19:55 +0200
10893 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-v850/socket.h 2007-08-05 20:53:13 +0200
10895 #define SO_TIMESTAMPNS 35
10896 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10898 +#define SO_PEERTAG 36
10900 #endif /* __V850_SOCKET_H__ */
10901 diff -NurpP --minimal linux-2.6.22.10/include/asm-x86_64/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-x86_64/socket.h
10902 --- linux-2.6.22.10/include/asm-x86_64/socket.h 2007-07-09 13:19:55 +0200
10903 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-x86_64/socket.h 2007-08-05 20:53:13 +0200
10905 #define SO_TIMESTAMPNS 35
10906 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10908 +#define SO_PEERTAG 36
10910 #endif /* _ASM_SOCKET_H */
10911 diff -NurpP --minimal linux-2.6.22.10/include/asm-x86_64/unistd.h linux-2.6.22.10-vs2.3.0.29/include/asm-x86_64/unistd.h
10912 --- linux-2.6.22.10/include/asm-x86_64/unistd.h 2007-07-09 13:19:55 +0200
10913 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-x86_64/unistd.h 2007-08-05 20:53:13 +0200
10914 @@ -532,7 +532,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
10915 #define __NR_utimes 235
10916 __SYSCALL(__NR_utimes, sys_utimes)
10917 #define __NR_vserver 236
10918 -__SYSCALL(__NR_vserver, sys_ni_syscall)
10919 +__SYSCALL(__NR_vserver, sys_vserver)
10920 #define __NR_mbind 237
10921 __SYSCALL(__NR_mbind, sys_mbind)
10922 #define __NR_set_mempolicy 238
10923 diff -NurpP --minimal linux-2.6.22.10/include/asm-xtensa/socket.h linux-2.6.22.10-vs2.3.0.29/include/asm-xtensa/socket.h
10924 --- linux-2.6.22.10/include/asm-xtensa/socket.h 2007-07-09 13:19:55 +0200
10925 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-xtensa/socket.h 2007-08-05 20:53:13 +0200
10927 #define SO_TIMESTAMPNS 35
10928 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10930 +#define SO_PEERTAG 36
10932 #endif /* _XTENSA_SOCKET_H */
10933 diff -NurpP --minimal linux-2.6.22.10/include/linux/Kbuild linux-2.6.22.10-vs2.3.0.29/include/linux/Kbuild
10934 --- linux-2.6.22.10/include/linux/Kbuild 2007-10-30 01:57:14 +0100
10935 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/Kbuild 2007-09-30 14:58:01 +0200
10936 @@ -351,3 +351,6 @@ unifdef-y += xattr.h
10937 unifdef-y += xfrm.h
10939 objhdr-y += version.h
10941 +header-y += vserver/
10943 diff -NurpP --minimal linux-2.6.22.10/include/linux/capability.h linux-2.6.22.10-vs2.3.0.29/include/linux/capability.h
10944 --- linux-2.6.22.10/include/linux/capability.h 2007-07-09 13:19:55 +0200
10945 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/capability.h 2007-08-05 20:53:13 +0200
10946 @@ -237,6 +237,7 @@ typedef __u32 kernel_cap_t;
10947 arbitrary SCSI commands */
10948 /* Allow setting encryption key on loopback filesystem */
10949 /* Allow setting zone reclaim policy */
10950 +/* Allow the selection of a security context */
10952 #define CAP_SYS_ADMIN 21
10954 @@ -290,6 +291,11 @@ typedef __u32 kernel_cap_t;
10956 #define CAP_AUDIT_CONTROL 30
10958 +/* Allow context manipulations */
10959 +/* Allow changing context info on files */
10961 +#define CAP_CONTEXT 31
10966 diff -NurpP --minimal linux-2.6.22.10/include/linux/devpts_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/devpts_fs.h
10967 --- linux-2.6.22.10/include/linux/devpts_fs.h 2004-08-14 12:55:59 +0200
10968 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/devpts_fs.h 2007-10-06 18:19:52 +0200
10969 @@ -30,5 +30,4 @@ static inline void devpts_pty_kill(int n
10974 #endif /* _LINUX_DEVPTS_FS_H */
10975 diff -NurpP --minimal linux-2.6.22.10/include/linux/ext2_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/ext2_fs.h
10976 --- linux-2.6.22.10/include/linux/ext2_fs.h 2006-11-30 21:19:37 +0100
10977 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ext2_fs.h 2007-10-05 15:07:22 +0200
10978 @@ -188,6 +188,8 @@ struct ext2_group_desc
10979 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
10980 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
10981 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
10982 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
10983 +#define EXT2_IUNLINK_FL FS_IUNLINK_FL /* Immutable unlink */
10984 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
10986 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
10987 @@ -244,7 +246,7 @@ struct ext2_inode {
10989 __u8 l_i_frag; /* Fragment number */
10990 __u8 l_i_fsize; /* Fragment size */
10992 + __u16 l_i_tag; /* Context Tag */
10993 __le16 l_i_uid_high; /* these 2 fields */
10994 __le16 l_i_gid_high; /* were reserved2[0] */
10995 __u32 l_i_reserved2;
10996 @@ -276,6 +278,7 @@ struct ext2_inode {
10997 #define i_gid_low i_gid
10998 #define i_uid_high osd2.linux2.l_i_uid_high
10999 #define i_gid_high osd2.linux2.l_i_gid_high
11000 +#define i_raw_tag osd2.linux2.l_i_tag
11001 #define i_reserved2 osd2.linux2.l_i_reserved2
11004 @@ -317,8 +320,9 @@ struct ext2_inode {
11005 #define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */
11006 #define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */
11007 #define EXT2_MOUNT_XIP 0x010000 /* Execute in place */
11008 -#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
11009 -#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
11010 +#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
11011 +#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
11012 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11015 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
11016 diff -NurpP --minimal linux-2.6.22.10/include/linux/ext3_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/ext3_fs.h
11017 --- linux-2.6.22.10/include/linux/ext3_fs.h 2007-07-09 13:19:56 +0200
11018 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ext3_fs.h 2007-08-05 20:53:13 +0200
11019 @@ -177,6 +177,8 @@ struct ext3_group_desc
11020 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
11021 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
11022 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11023 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11024 +#define EXT3_IUNLINK_FL 0x08000000 /* Immutable unlink */
11025 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
11027 #define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
11028 @@ -296,7 +298,7 @@ struct ext3_inode {
11030 __u8 l_i_frag; /* Fragment number */
11031 __u8 l_i_fsize; /* Fragment size */
11033 + __u16 l_i_tag; /* Context Tag */
11034 __le16 l_i_uid_high; /* these 2 fields */
11035 __le16 l_i_gid_high; /* were reserved2[0] */
11036 __u32 l_i_reserved2;
11037 @@ -330,6 +332,7 @@ struct ext3_inode {
11038 #define i_gid_low i_gid
11039 #define i_uid_high osd2.linux2.l_i_uid_high
11040 #define i_gid_high osd2.linux2.l_i_gid_high
11041 +#define i_raw_tag osd2.linux2.l_i_tag
11042 #define i_reserved2 osd2.linux2.l_i_reserved2
11044 #elif defined(__GNU__)
11045 @@ -384,6 +387,7 @@ struct ext3_inode {
11046 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
11047 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
11048 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
11049 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11051 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
11052 #ifndef _LINUX_EXT2_FS_H
11053 @@ -812,6 +816,7 @@ struct buffer_head * ext3_bread (handle_
11054 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
11055 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
11056 int create, int extend_disksize);
11057 +extern int ext3_sync_flags(struct inode *inode);
11059 extern void ext3_read_inode (struct inode *);
11060 extern int ext3_write_inode (struct inode *, int);
11061 diff -NurpP --minimal linux-2.6.22.10/include/linux/ext4_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/ext4_fs.h
11062 --- linux-2.6.22.10/include/linux/ext4_fs.h 2007-07-09 13:19:56 +0200
11063 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ext4_fs.h 2007-08-05 20:53:13 +0200
11064 @@ -189,8 +189,10 @@ struct ext4_group_desc
11065 #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
11066 #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
11067 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11068 -#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
11069 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
11070 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11071 +#define EXT4_IUNLINK_FL 0x08000000 /* Immutable unlink */
11072 +#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
11074 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
11075 #define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
11076 @@ -312,7 +314,8 @@ struct ext4_inode {
11077 __le16 l_i_file_acl_high;
11078 __le16 l_i_uid_high; /* these 2 fields */
11079 __le16 l_i_gid_high; /* were reserved2[0] */
11080 - __u32 l_i_reserved2;
11081 + __u16 l_i_tag; /* Context Tag */
11082 + __u16 l_i_reserved2;
11085 __u8 h_i_frag; /* Fragment number */
11086 @@ -344,6 +347,7 @@ struct ext4_inode {
11087 #define i_gid_low i_gid
11088 #define i_uid_high osd2.linux2.l_i_uid_high
11089 #define i_gid_high osd2.linux2.l_i_gid_high
11090 +#define i_raw_tag osd2.linux2.l_i_tag
11091 #define i_reserved2 osd2.linux2.l_i_reserved2
11093 #elif defined(__GNU__)
11094 @@ -400,6 +404,7 @@ struct ext4_inode {
11095 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
11096 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
11097 #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
11098 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11100 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
11101 #ifndef _LINUX_EXT2_FS_H
11102 @@ -850,6 +855,7 @@ struct buffer_head * ext4_bread (handle_
11103 int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
11104 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
11105 int create, int extend_disksize);
11106 +extern int ext4_sync_flags(struct inode *inode);
11108 extern void ext4_read_inode (struct inode *);
11109 extern int ext4_write_inode (struct inode *, int);
11110 diff -NurpP --minimal linux-2.6.22.10/include/linux/fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/fs.h
11111 --- linux-2.6.22.10/include/linux/fs.h 2007-07-09 13:19:56 +0200
11112 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/fs.h 2007-10-20 00:01:05 +0200
11113 @@ -123,6 +123,8 @@ extern int dir_notify_enable;
11114 #define MS_SLAVE (1<<19) /* change to slave */
11115 #define MS_SHARED (1<<20) /* change to shared */
11116 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
11117 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
11118 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
11119 #define MS_ACTIVE (1<<30)
11120 #define MS_NOUSER (1<<31)
11122 @@ -149,6 +151,8 @@ extern int dir_notify_enable;
11123 #define S_NOCMTIME 128 /* Do not update file c/mtime */
11124 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
11125 #define S_PRIVATE 512 /* Inode is fs-internal */
11126 +#define S_BARRIER 1024 /* Barrier for chroot() */
11127 +#define S_IUNLINK 2048 /* Immutable unlink */
11130 * Note that nosuid etc flags are inode-specific: setting some file-system
11131 @@ -165,24 +169,36 @@ extern int dir_notify_enable;
11133 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
11135 -#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
11136 +#define IS_RDONLY(inode) __IS_FLG(inode, MS_RDONLY)
11137 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
11138 ((inode)->i_flags & S_SYNC))
11139 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
11140 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
11141 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
11142 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
11143 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
11144 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
11146 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
11147 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
11148 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
11149 +#define IS_IUNLINK(inode) ((inode)->i_flags & S_IUNLINK)
11150 +#define IS_IXORUNLINK(inode) ((IS_IUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
11151 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
11153 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_flags & S_BARRIER))
11154 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
11155 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
11156 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
11157 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
11159 +#ifdef CONFIG_VSERVER_COWBL
11160 +# define IS_COW(inode) (IS_IUNLINK(inode) && IS_IMMUTABLE(inode))
11161 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
11163 +# define IS_COW(inode) (0)
11164 +# define IS_COW_LINK(inode) (0)
11167 /* the read-only stuff doesn't really belong here, but any other place is
11168 probably as bad and I don't want to create yet another include file. */
11170 @@ -256,12 +272,13 @@ extern int dir_notify_enable;
11171 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11172 #define FS_EXTENT_FL 0x00080000 /* Extents */
11173 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
11174 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11175 +#define FS_IUNLINK_FL 0x08000000 /* Immutable unlink */
11176 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
11178 #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
11179 #define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
11182 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
11183 #define SYNC_FILE_RANGE_WRITE 2
11184 #define SYNC_FILE_RANGE_WAIT_AFTER 4
11185 @@ -327,6 +344,7 @@ typedef void (dio_iodone_t)(struct kiocb
11186 #define ATTR_KILL_SUID 2048
11187 #define ATTR_KILL_SGID 4096
11188 #define ATTR_FILE 8192
11189 +#define ATTR_TAG 16384
11192 * This is the Inode Attributes structure, used for notify_change(). It
11193 @@ -342,6 +360,7 @@ struct iattr {
11199 struct timespec ia_atime;
11200 struct timespec ia_mtime;
11201 @@ -355,6 +374,9 @@ struct iattr {
11202 struct file *ia_file;
11205 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
11206 +#define ATTR_FLAG_IUNLINK 1024 /* Immutable unlink */
11209 * Includes for diskquotas.
11211 @@ -537,7 +559,9 @@ struct inode {
11212 unsigned int i_nlink;
11218 unsigned long i_version;
11220 #ifdef __NEED_I_SIZE_ORDERED
11221 @@ -672,12 +696,12 @@ static inline void i_size_write(struct i
11223 static inline unsigned iminor(const struct inode *inode)
11225 - return MINOR(inode->i_rdev);
11226 + return MINOR(inode->i_mdev);
11229 static inline unsigned imajor(const struct inode *inode)
11231 - return MAJOR(inode->i_rdev);
11232 + return MAJOR(inode->i_mdev);
11235 extern struct block_device *I_BDEV(struct inode *inode);
11236 @@ -728,6 +752,7 @@ struct file {
11238 struct fown_struct f_owner;
11239 unsigned int f_uid, f_gid;
11241 struct file_ra_state f_ra;
11243 unsigned long f_version;
11244 @@ -811,6 +836,7 @@ struct file_lock {
11245 unsigned char fl_type;
11250 struct fasync_struct * fl_fasync; /* for lease break notifications */
11251 unsigned long fl_break_time; /* for nonblocking lease breaks */
11252 @@ -993,12 +1019,12 @@ extern void unlock_super(struct super_bl
11254 extern int vfs_permission(struct nameidata *, int);
11255 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
11256 -extern int vfs_mkdir(struct inode *, struct dentry *, int);
11257 -extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
11258 -extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
11259 -extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
11260 -extern int vfs_rmdir(struct inode *, struct dentry *);
11261 -extern int vfs_unlink(struct inode *, struct dentry *);
11262 +extern int vfs_mkdir(struct inode *, struct dentry *, int, struct nameidata *);
11263 +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t, struct nameidata *);
11264 +extern int vfs_symlink(struct inode *, struct dentry *, const char *, int, struct nameidata *);
11265 +extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct nameidata *);
11266 +extern int vfs_rmdir(struct inode *, struct dentry *, struct nameidata *);
11267 +extern int vfs_unlink(struct inode *, struct dentry *, struct nameidata *);
11268 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
11271 @@ -1138,6 +1164,7 @@ struct inode_operations {
11272 ssize_t (*listxattr) (struct dentry *, char *, size_t);
11273 int (*removexattr) (struct dentry *, const char *);
11274 void (*truncate_range)(struct inode *, loff_t, loff_t);
11275 + int (*sync_flags) (struct inode *);
11279 @@ -1153,6 +1180,7 @@ extern ssize_t vfs_readv(struct file *,
11280 unsigned long, loff_t *);
11281 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
11282 unsigned long, loff_t *);
11283 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
11286 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
11287 @@ -1898,6 +1926,7 @@ extern int dcache_dir_open(struct inode
11288 extern int dcache_dir_close(struct inode *, struct file *);
11289 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
11290 extern int dcache_readdir(struct file *, void *, filldir_t);
11291 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
11292 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
11293 extern int simple_statfs(struct dentry *, struct kstatfs *);
11294 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
11295 diff -NurpP --minimal linux-2.6.22.10/include/linux/init_task.h linux-2.6.22.10-vs2.3.0.29/include/linux/init_task.h
11296 --- linux-2.6.22.10/include/linux/init_task.h 2007-07-09 13:19:56 +0200
11297 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/init_task.h 2007-08-05 20:53:13 +0200
11298 @@ -169,6 +169,10 @@ extern struct group_info init_groups;
11300 INIT_TRACE_IRQFLAGS \
11303 + .vx_info = NULL, \
11305 + .nx_info = NULL, \
11309 diff -NurpP --minimal linux-2.6.22.10/include/linux/ipc.h linux-2.6.22.10-vs2.3.0.29/include/linux/ipc.h
11310 --- linux-2.6.22.10/include/linux/ipc.h 2007-07-09 13:19:56 +0200
11311 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ipc.h 2007-08-05 20:53:13 +0200
11312 @@ -63,6 +63,7 @@ struct kern_ipc_perm
11320 diff -NurpP --minimal linux-2.6.22.10/include/linux/jffs2.h linux-2.6.22.10-vs2.3.0.29/include/linux/jffs2.h
11321 --- linux-2.6.22.10/include/linux/jffs2.h 2006-11-30 21:19:38 +0100
11322 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/jffs2.h 2007-10-05 15:07:22 +0200
11323 @@ -82,12 +82,36 @@
11324 //#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
11327 -#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
11328 +#define JFFS2_INO_FLAG_PREREAD 0x01 /* Do read_inode() for this one at
11329 mount time, don't wait for it to
11331 -#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
11332 +#define JFFS2_INO_FLAG_USERCOMPR 0x02 /* User has requested a specific
11333 compression type */
11335 +#define JFFS2_INO_FLAG_IMMUTABLE 0x10 /* immutable node */
11336 +#define JFFS2_INO_FLAG_IUNLINK 0x20 /* immutable unlink */
11337 +#define JFFS2_INO_FLAG_BARRIER 0x40 /* barrier */
11339 +#define JFFS2_USER_VISIBLE 0x10
11340 +#define JFFS2_USER_MODIFIABLE 0x10
11345 +#define JFFS2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11347 +#define clear_opt(o, opt) o &= ~JFFS2_MOUNT_##opt
11348 +#define set_opt(o, opt) o |= JFFS2_MOUNT_##opt
11351 + * Maximal mount counts between two filesystem checks
11353 +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
11354 +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
11357 + * Behaviour when detecting errors
11360 /* These can go once we've made sure we've caught all uses without
11362 @@ -97,7 +121,7 @@ typedef struct {
11363 } __attribute__((packed)) jint32_t;
11368 } __attribute__((packed)) jmode_t;
11371 @@ -145,7 +169,8 @@ struct jffs2_raw_inode
11373 jint32_t ino; /* Inode number. */
11374 jint32_t version; /* Version number. */
11375 - jmode_t mode; /* The file's type or mode. */
11376 + jmode_t mode; /* The file's type or mode. */
11377 + jint16_t tag; /* context tagging */
11378 jint16_t uid; /* The file's owner. */
11379 jint16_t gid; /* The file's group. */
11380 jint32_t isize; /* Total resultant size of this inode (used for truncations) */
11381 diff -NurpP --minimal linux-2.6.22.10/include/linux/loop.h linux-2.6.22.10-vs2.3.0.29/include/linux/loop.h
11382 --- linux-2.6.22.10/include/linux/loop.h 2007-07-09 13:19:56 +0200
11383 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/loop.h 2007-08-05 20:53:13 +0200
11384 @@ -45,6 +45,7 @@ struct loop_device {
11385 struct loop_func_table *lo_encryption;
11387 uid_t lo_key_owner; /* Who set the key */
11389 int (*ioctl)(struct loop_device *, int cmd,
11390 unsigned long arg);
11392 diff -NurpP --minimal linux-2.6.22.10/include/linux/magic.h linux-2.6.22.10-vs2.3.0.29/include/linux/magic.h
11393 --- linux-2.6.22.10/include/linux/magic.h 2007-07-09 13:19:56 +0200
11394 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/magic.h 2007-10-06 18:19:33 +0200
11397 #define ADFS_SUPER_MAGIC 0xadf5
11398 #define AFFS_SUPER_MAGIC 0xadff
11399 -#define AFS_SUPER_MAGIC 0x5346414F
11400 +#define AFS_SUPER_MAGIC 0x5346414F
11401 #define AUTOFS_SUPER_MAGIC 0x0187
11402 #define CODA_SUPER_MAGIC 0x73757245
11403 #define EFS_SUPER_MAGIC 0x414A53
11405 #define NFS_SUPER_MAGIC 0x6969
11406 #define OPENPROM_SUPER_MAGIC 0x9fa1
11407 #define PROC_SUPER_MAGIC 0x9fa0
11408 +#define DEVPTS_SUPER_MAGIC 0x1cd1
11409 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
11411 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
11412 diff -NurpP --minimal linux-2.6.22.10/include/linux/major.h linux-2.6.22.10-vs2.3.0.29/include/linux/major.h
11413 --- linux-2.6.22.10/include/linux/major.h 2007-07-09 13:19:56 +0200
11414 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/major.h 2007-08-05 20:53:13 +0200
11416 #define HD_MAJOR IDE0_MAJOR
11417 #define PTY_SLAVE_MAJOR 3
11418 #define TTY_MAJOR 4
11419 +#define VROOT_MAJOR 4
11420 #define TTYAUX_MAJOR 5
11422 #define VCS_MAJOR 7
11423 diff -NurpP --minimal linux-2.6.22.10/include/linux/mount.h linux-2.6.22.10-vs2.3.0.29/include/linux/mount.h
11424 --- linux-2.6.22.10/include/linux/mount.h 2007-07-09 13:19:56 +0200
11425 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/mount.h 2007-09-05 02:29:04 +0200
11426 @@ -28,6 +28,9 @@ struct mnt_namespace;
11427 #define MNT_NOATIME 0x08
11428 #define MNT_NODIRATIME 0x10
11429 #define MNT_RELATIME 0x20
11430 +#define MNT_RDONLY 0x40
11432 +#define MNT_IS_RDONLY(m) ((m) && ((m)->mnt_flags & MNT_RDONLY))
11434 #define MNT_SHRINKABLE 0x100
11436 @@ -35,6 +38,10 @@ struct mnt_namespace;
11437 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
11438 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
11440 +#define MNT_TAGID 0x10000
11441 +#define MNT_NOTAG 0x20000
11442 +#define MNT_NOTAGCHECK 0x40000
11445 struct list_head mnt_hash;
11446 struct vfsmount *mnt_parent; /* fs we are mounted on */
11447 @@ -61,6 +68,7 @@ struct vfsmount {
11448 atomic_t mnt_count;
11449 int mnt_expiry_mark; /* true if marked for expiry */
11451 + tag_t mnt_tag; /* tagging used for vfsmount */
11454 static inline struct vfsmount *mntget(struct vfsmount *mnt)
11455 diff -NurpP --minimal linux-2.6.22.10/include/linux/net.h linux-2.6.22.10-vs2.3.0.29/include/linux/net.h
11456 --- linux-2.6.22.10/include/linux/net.h 2007-07-09 13:19:56 +0200
11457 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/net.h 2007-08-05 20:53:13 +0200
11458 @@ -63,6 +63,7 @@ typedef enum {
11459 #define SOCK_NOSPACE 2
11460 #define SOCK_PASSCRED 3
11461 #define SOCK_PASSSEC 4
11462 +#define SOCK_USER_SOCKET 5
11464 #ifndef ARCH_HAS_SOCKET_TYPES
11466 diff -NurpP --minimal linux-2.6.22.10/include/linux/nfs_mount.h linux-2.6.22.10-vs2.3.0.29/include/linux/nfs_mount.h
11467 --- linux-2.6.22.10/include/linux/nfs_mount.h 2007-07-09 13:20:00 +0200
11468 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/nfs_mount.h 2007-08-05 20:53:13 +0200
11469 @@ -62,6 +62,7 @@ struct nfs_mount_data {
11470 #define NFS_MOUNT_STRICTLOCK 0x1000 /* reserved for NFSv4 */
11471 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
11472 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
11473 +#define NFS_MOUNT_TAGGED 0x8000 /* context tagging */
11474 #define NFS_MOUNT_FLAGMASK 0xFFFF
11477 diff -NurpP --minimal linux-2.6.22.10/include/linux/nsproxy.h linux-2.6.22.10-vs2.3.0.29/include/linux/nsproxy.h
11478 --- linux-2.6.22.10/include/linux/nsproxy.h 2007-07-09 13:20:00 +0200
11479 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/nsproxy.h 2007-08-05 20:53:13 +0200
11482 #include <linux/spinlock.h>
11483 #include <linux/sched.h>
11484 +#include <linux/vserver/debug.h>
11486 struct mnt_namespace;
11487 struct uts_namespace;
11488 @@ -32,26 +33,46 @@ struct nsproxy {
11489 extern struct nsproxy init_nsproxy;
11491 int copy_namespaces(int flags, struct task_struct *tsk);
11492 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
11493 void get_task_namespaces(struct task_struct *tsk);
11494 void free_nsproxy(struct nsproxy *ns);
11495 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
11496 struct fs_struct *);
11498 -static inline void put_nsproxy(struct nsproxy *ns)
11499 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
11501 +static inline void __get_nsproxy(struct nsproxy *ns,
11502 + const char *_file, int _line)
11504 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
11505 + ns, atomic_read(&ns->count), _file, _line);
11506 + atomic_inc(&ns->count);
11509 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
11511 +static inline void __put_nsproxy(struct nsproxy *ns,
11512 + const char *_file, int _line)
11514 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
11515 + ns, atomic_read(&ns->count), _file, _line);
11516 if (atomic_dec_and_test(&ns->count)) {
11521 -static inline void exit_task_namespaces(struct task_struct *p)
11522 +#define exit_task_namespaces(p) __exit_task_namespaces(p, __FILE__, __LINE__)
11524 +static inline void __exit_task_namespaces(struct task_struct *p,
11525 + const char *_file, int _line)
11527 struct nsproxy *ns = p->nsproxy;
11533 + __put_nsproxy(ns, _file, _line);
11538 diff -NurpP --minimal linux-2.6.22.10/include/linux/pid.h linux-2.6.22.10-vs2.3.0.29/include/linux/pid.h
11539 --- linux-2.6.22.10/include/linux/pid.h 2007-07-09 13:20:00 +0200
11540 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/pid.h 2007-08-05 20:53:13 +0200
11541 @@ -8,7 +8,8 @@ enum pid_type
11551 diff -NurpP --minimal linux-2.6.22.10/include/linux/proc_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/proc_fs.h
11552 --- linux-2.6.22.10/include/linux/proc_fs.h 2007-07-09 13:20:00 +0200
11553 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/proc_fs.h 2007-08-05 20:53:13 +0200
11554 @@ -54,6 +54,7 @@ struct proc_dir_entry {
11560 const struct inode_operations *proc_iops;
11561 const struct file_operations *proc_fops;
11562 @@ -246,13 +247,20 @@ static inline void kclist_add(struct kco
11563 extern void kclist_add(struct kcore_list *, void *, size_t);
11570 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
11571 int (*proc_read)(struct task_struct *task, char *page);
11572 + int (*proc_vs_read)(char *page);
11573 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
11574 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
11577 struct proc_inode {
11582 struct proc_dir_entry *pde;
11583 diff -NurpP --minimal linux-2.6.22.10/include/linux/reiserfs_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/reiserfs_fs.h
11584 --- linux-2.6.22.10/include/linux/reiserfs_fs.h 2007-05-02 19:25:34 +0200
11585 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/reiserfs_fs.h 2007-08-05 20:53:13 +0200
11586 @@ -821,6 +821,10 @@ struct stat_data_v1 {
11587 #define REISERFS_COMPR_FL FS_COMPR_FL
11588 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
11590 +/* unfortunately reiserfs sdattr is only 16 bit */
11591 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
11592 +#define REISERFS_IUNLINK_FL (FS_IUNLINK_FL >> 16)
11594 /* persistent flags that file inherits from the parent directory */
11595 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
11596 REISERFS_SYNC_FL | \
11597 @@ -830,6 +834,9 @@ struct stat_data_v1 {
11598 REISERFS_COMPR_FL | \
11599 REISERFS_NOTAIL_FL )
11601 +#define REISERFS_FL_USER_VISIBLE 0x80FF
11602 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
11604 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
11607 @@ -1901,6 +1908,7 @@ static inline void reiserfs_update_sd(st
11608 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
11609 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
11610 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
11611 +int reiserfs_sync_flags(struct inode *inode);
11614 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
11615 diff -NurpP --minimal linux-2.6.22.10/include/linux/reiserfs_fs_sb.h linux-2.6.22.10-vs2.3.0.29/include/linux/reiserfs_fs_sb.h
11616 --- linux-2.6.22.10/include/linux/reiserfs_fs_sb.h 2007-07-09 13:20:00 +0200
11617 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/reiserfs_fs_sb.h 2007-08-05 20:53:13 +0200
11618 @@ -458,6 +458,7 @@ enum reiserfs_mount_options {
11620 REISERFS_BARRIER_NONE,
11621 REISERFS_BARRIER_FLUSH,
11624 /* Actions on error */
11625 REISERFS_ERROR_PANIC,
11626 diff -NurpP --minimal linux-2.6.22.10/include/linux/sched.h linux-2.6.22.10-vs2.3.0.29/include/linux/sched.h
11627 --- linux-2.6.22.10/include/linux/sched.h 2007-07-09 13:20:01 +0200
11628 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sched.h 2007-10-04 23:47:06 +0200
11630 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
11631 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
11632 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
11633 +#define CLONE_KTHREAD 0x10000000 /* clone a kernel thread */
11636 * Scheduling policies
11637 @@ -94,7 +95,7 @@ struct bio;
11638 * List of flags we want to share for kernel threads,
11639 * if only because they are not used by them anyway.
11641 -#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
11642 +#define CLONE_KERNEL (CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_KTHREAD)
11645 * These are the constant used to fake the fixed-point load-average
11646 @@ -146,12 +147,13 @@ extern unsigned long weighted_cpuload(co
11647 #define TASK_UNINTERRUPTIBLE 2
11648 #define TASK_STOPPED 4
11649 #define TASK_TRACED 8
11650 +#define TASK_ONHOLD 16
11651 /* in tsk->exit_state */
11652 -#define EXIT_ZOMBIE 16
11653 -#define EXIT_DEAD 32
11654 +#define EXIT_ZOMBIE 32
11655 +#define EXIT_DEAD 64
11656 /* in tsk->state again */
11657 -#define TASK_NONINTERACTIVE 64
11658 -#define TASK_DEAD 128
11659 +#define TASK_NONINTERACTIVE 128
11660 +#define TASK_DEAD 256
11662 #define __set_task_state(tsk, state_value) \
11663 do { (tsk)->state = (state_value); } while (0)
11664 @@ -287,27 +289,30 @@ extern void arch_unmap_area_topdown(stru
11665 * The mm counters are not protected by its page_table_lock,
11666 * so must be incremented atomically.
11668 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
11669 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
11670 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
11671 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
11672 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
11673 typedef atomic_long_t mm_counter_t;
11674 +#define __set_mm_counter(mm, member, value) \
11675 + atomic_long_set(&(mm)->_##member, value)
11676 +#define get_mm_counter(mm, member) \
11677 + ((unsigned long)atomic_long_read(&(mm)->_##member))
11679 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11681 * The mm counters are protected by its page_table_lock,
11682 * so can be incremented directly.
11684 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
11685 -#define get_mm_counter(mm, member) ((mm)->_##member)
11686 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
11687 -#define inc_mm_counter(mm, member) (mm)->_##member++
11688 -#define dec_mm_counter(mm, member) (mm)->_##member--
11689 typedef unsigned long mm_counter_t;
11690 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
11691 +#define get_mm_counter(mm, member) ((mm)->_##member)
11693 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11695 +#define set_mm_counter(mm, member, value) \
11696 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
11697 +#define add_mm_counter(mm, member, value) \
11698 + vx_ ## member ## pages_add((mm), (value))
11699 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
11700 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
11702 #define get_mm_rss(mm) \
11703 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
11704 #define update_hiwater_rss(mm) do { \
11705 @@ -365,6 +370,7 @@ struct mm_struct {
11707 /* Architecture-specific MM context */
11708 mm_context_t context;
11709 + struct vx_info *mm_vx_info;
11711 /* Swap token stuff */
11713 @@ -570,9 +576,10 @@ struct user_struct {
11714 /* Hash table maintenance information */
11715 struct list_head uidhash_list;
11720 -extern struct user_struct *find_user(uid_t);
11721 +extern struct user_struct *find_user(xid_t, uid_t);
11723 extern struct user_struct root_user;
11724 #define INIT_USER (&root_user)
11725 @@ -969,6 +976,15 @@ struct task_struct {
11728 struct audit_context *audit_context;
11730 +/* vserver context data */
11731 + struct vx_info *vx_info;
11732 + struct nx_info *nx_info;
11740 /* Thread group tracking */
11741 @@ -1290,12 +1306,16 @@ extern struct task_struct init_task;
11743 extern struct mm_struct init_mm;
11745 -#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr)
11746 +#define find_task_by_real_pid(nr) \
11747 + find_task_by_pid_type(PIDTYPE_REALPID, nr)
11748 +#define find_task_by_pid(nr) \
11749 + find_task_by_pid_type(PIDTYPE_PID, nr)
11751 extern struct task_struct *find_task_by_pid_type(int type, int pid);
11752 extern void __set_special_pids(pid_t session, pid_t pgrp);
11754 /* per-UID process charging. */
11755 -extern struct user_struct * alloc_uid(uid_t);
11756 +extern struct user_struct * alloc_uid(xid_t, uid_t);
11757 static inline struct user_struct *get_uid(struct user_struct *u)
11759 atomic_inc(&u->__count);
11760 diff -NurpP --minimal linux-2.6.22.10/include/linux/shmem_fs.h linux-2.6.22.10-vs2.3.0.29/include/linux/shmem_fs.h
11761 --- linux-2.6.22.10/include/linux/shmem_fs.h 2006-11-30 21:19:39 +0100
11762 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/shmem_fs.h 2007-08-05 20:53:13 +0200
11765 #define SHMEM_NR_DIRECT 16
11767 +#define TMPFS_SUPER_MAGIC 0x01021994
11770 struct shmem_inode_info {
11772 unsigned long flags;
11773 diff -NurpP --minimal linux-2.6.22.10/include/linux/stat.h linux-2.6.22.10-vs2.3.0.29/include/linux/stat.h
11774 --- linux-2.6.22.10/include/linux/stat.h 2007-07-09 13:20:01 +0200
11775 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/stat.h 2007-08-05 20:53:13 +0200
11776 @@ -66,6 +66,7 @@ struct kstat {
11777 unsigned int nlink;
11783 struct timespec atime;
11784 diff -NurpP --minimal linux-2.6.22.10/include/linux/sunrpc/auth.h linux-2.6.22.10-vs2.3.0.29/include/linux/sunrpc/auth.h
11785 --- linux-2.6.22.10/include/linux/sunrpc/auth.h 2006-11-30 21:19:40 +0100
11786 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sunrpc/auth.h 2007-08-05 20:53:13 +0200
11792 struct group_info *group_info;
11795 diff -NurpP --minimal linux-2.6.22.10/include/linux/sunrpc/clnt.h linux-2.6.22.10-vs2.3.0.29/include/linux/sunrpc/clnt.h
11796 --- linux-2.6.22.10/include/linux/sunrpc/clnt.h 2007-07-09 13:20:01 +0200
11797 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sunrpc/clnt.h 2007-08-05 20:53:13 +0200
11798 @@ -43,7 +43,8 @@ struct rpc_clnt {
11799 cl_discrtry : 1,/* disconnect before retry */
11800 cl_autobind : 1,/* use getport() */
11801 cl_oneshot : 1,/* dispose after use */
11802 - cl_dead : 1;/* abandoned */
11803 + cl_dead : 1,/* abandoned */
11804 + cl_tag : 1;/* context tagging */
11806 struct rpc_rtt * cl_rtt; /* RTO estimator data */
11808 diff -NurpP --minimal linux-2.6.22.10/include/linux/syscalls.h linux-2.6.22.10-vs2.3.0.29/include/linux/syscalls.h
11809 --- linux-2.6.22.10/include/linux/syscalls.h 2007-07-09 13:20:01 +0200
11810 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/syscalls.h 2007-08-05 20:53:13 +0200
11811 @@ -294,6 +294,8 @@ asmlinkage long sys_symlink(const char _
11812 asmlinkage long sys_unlink(const char __user *pathname);
11813 asmlinkage long sys_rename(const char __user *oldname,
11814 const char __user *newname);
11815 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
11817 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
11818 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
11820 diff -NurpP --minimal linux-2.6.22.10/include/linux/sysctl.h linux-2.6.22.10-vs2.3.0.29/include/linux/sysctl.h
11821 --- linux-2.6.22.10/include/linux/sysctl.h 2007-07-09 13:20:01 +0200
11822 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sysctl.h 2007-08-05 20:53:13 +0200
11823 @@ -106,6 +106,7 @@ enum
11824 KERN_CAP_BSET=14, /* int: capability bounding set */
11825 KERN_PANIC=15, /* int: panic timeout */
11826 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
11827 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
11829 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
11830 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
11831 diff -NurpP --minimal linux-2.6.22.10/include/linux/sysfs.h linux-2.6.22.10-vs2.3.0.29/include/linux/sysfs.h
11832 --- linux-2.6.22.10/include/linux/sysfs.h 2007-07-09 13:20:01 +0200
11833 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sysfs.h 2007-08-05 20:53:13 +0200
11835 #include <linux/list.h>
11836 #include <asm/atomic.h>
11838 +#define SYSFS_SUPER_MAGIC 0x62656572
11843 diff -NurpP --minimal linux-2.6.22.10/include/linux/time.h linux-2.6.22.10-vs2.3.0.29/include/linux/time.h
11844 --- linux-2.6.22.10/include/linux/time.h 2007-07-09 13:20:01 +0200
11845 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/time.h 2007-08-05 20:53:13 +0200
11846 @@ -176,6 +176,9 @@ static inline void timespec_add_ns(struc
11851 +#include <linux/vs_time.h>
11853 #endif /* __KERNEL__ */
11855 #define NFDBITS __NFDBITS
11856 diff -NurpP --minimal linux-2.6.22.10/include/linux/types.h linux-2.6.22.10-vs2.3.0.29/include/linux/types.h
11857 --- linux-2.6.22.10/include/linux/types.h 2007-02-06 03:01:52 +0100
11858 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/types.h 2007-08-05 20:53:13 +0200
11859 @@ -39,6 +39,9 @@ typedef __kernel_uid32_t uid_t;
11860 typedef __kernel_gid32_t gid_t;
11861 typedef __kernel_uid16_t uid16_t;
11862 typedef __kernel_gid16_t gid16_t;
11863 +typedef unsigned int xid_t;
11864 +typedef unsigned int nid_t;
11865 +typedef unsigned int tag_t;
11867 #ifdef CONFIG_UID16
11868 /* This is defined by include/asm-{arch}/posix_types.h */
11869 diff -NurpP --minimal linux-2.6.22.10/include/linux/vroot.h linux-2.6.22.10-vs2.3.0.29/include/linux/vroot.h
11870 --- linux-2.6.22.10/include/linux/vroot.h 1970-01-01 01:00:00 +0100
11871 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vroot.h 2007-08-05 20:53:13 +0200
11875 + * include/linux/vroot.h
11877 + * written by Herbert Pötzl, 9/11/2002
11878 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
11880 + * Copyright (C) 2002-2007 by Herbert Pötzl.
11881 + * Redistribution of this file is permitted under the
11882 + * GNU General Public License.
11885 +#ifndef _LINUX_VROOT_H
11886 +#define _LINUX_VROOT_H
11891 +/* Possible states of device */
11897 +struct vroot_device {
11901 + struct semaphore vr_ctl_mutex;
11902 + struct block_device *vr_device;
11907 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
11909 +extern int register_vroot_grb(vroot_grb_func *);
11910 +extern int unregister_vroot_grb(vroot_grb_func *);
11912 +#endif /* __KERNEL__ */
11914 +#define MAX_VROOT_DEFAULT 8
11917 + * IOCTL commands --- we will commandeer 0x56 ('V')
11920 +#define VROOT_SET_DEV 0x5600
11921 +#define VROOT_CLR_DEV 0x5601
11923 +#endif /* _LINUX_VROOT_H */
11924 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_base.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_base.h
11925 --- linux-2.6.22.10/include/linux/vs_base.h 1970-01-01 01:00:00 +0100
11926 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_base.h 2007-08-05 20:53:13 +0200
11928 +#ifndef _VS_BASE_H
11929 +#define _VS_BASE_H
11931 +#include "vserver/base.h"
11932 +#include "vserver/debug.h"
11935 +#warning duplicate inclusion
11937 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_context.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_context.h
11938 --- linux-2.6.22.10/include/linux/vs_context.h 1970-01-01 01:00:00 +0100
11939 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_context.h 2007-10-01 14:57:41 +0200
11941 +#ifndef _VS_CONTEXT_H
11942 +#define _VS_CONTEXT_H
11944 +#include "vserver/base.h"
11945 +#include "vserver/context.h"
11946 +#include "vserver/history.h"
11947 +#include "vserver/debug.h"
11950 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
11952 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
11953 + const char *_file, int _line, void *_here)
11958 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
11959 + vxi, vxi ? vxi->vx_id : 0,
11960 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11962 + __vxh_get_vx_info(vxi, _here);
11964 + atomic_inc(&vxi->vx_usecnt);
11969 +extern void free_vx_info(struct vx_info *);
11971 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
11973 +static inline void __put_vx_info(struct vx_info *vxi,
11974 + const char *_file, int _line, void *_here)
11979 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
11980 + vxi, vxi ? vxi->vx_id : 0,
11981 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11983 + __vxh_put_vx_info(vxi, _here);
11985 + if (atomic_dec_and_test(&vxi->vx_usecnt))
11986 + free_vx_info(vxi);
11990 +#define init_vx_info(p, i) \
11991 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11993 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11994 + const char *_file, int _line, void *_here)
11997 + vxlprintk(VXD_CBIT(xid, 3),
11998 + "init_vx_info(%p[#%d.%d])",
11999 + vxi, vxi ? vxi->vx_id : 0,
12000 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12002 + __vxh_init_vx_info(vxi, vxp, _here);
12004 + atomic_inc(&vxi->vx_usecnt);
12010 +#define set_vx_info(p, i) \
12011 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
12013 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
12014 + const char *_file, int _line, void *_here)
12016 + struct vx_info *vxo;
12021 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
12022 + vxi, vxi ? vxi->vx_id : 0,
12023 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12025 + __vxh_set_vx_info(vxi, vxp, _here);
12027 + atomic_inc(&vxi->vx_usecnt);
12028 + vxo = xchg(vxp, vxi);
12033 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
12035 +static inline void __clr_vx_info(struct vx_info **vxp,
12036 + const char *_file, int _line, void *_here)
12038 + struct vx_info *vxo;
12040 + vxo = xchg(vxp, NULL);
12044 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
12045 + vxo, vxo ? vxo->vx_id : 0,
12046 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
12048 + __vxh_clr_vx_info(vxo, vxp, _here);
12050 + if (atomic_dec_and_test(&vxo->vx_usecnt))
12051 + free_vx_info(vxo);
12055 +#define claim_vx_info(v, p) \
12056 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
12058 +static inline void __claim_vx_info(struct vx_info *vxi,
12059 + struct task_struct *task,
12060 + const char *_file, int _line, void *_here)
12062 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
12063 + vxi, vxi ? vxi->vx_id : 0,
12064 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12065 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
12066 + task, _file, _line);
12067 + __vxh_claim_vx_info(vxi, task, _here);
12069 + atomic_inc(&vxi->vx_tasks);
12073 +extern void unhash_vx_info(struct vx_info *);
12075 +#define release_vx_info(v, p) \
12076 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
12078 +static inline void __release_vx_info(struct vx_info *vxi,
12079 + struct task_struct *task,
12080 + const char *_file, int _line, void *_here)
12082 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
12083 + vxi, vxi ? vxi->vx_id : 0,
12084 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12085 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
12086 + task, _file, _line);
12087 + __vxh_release_vx_info(vxi, task, _here);
12091 + if (atomic_dec_and_test(&vxi->vx_tasks))
12092 + unhash_vx_info(vxi);
12096 +#define task_get_vx_info(p) \
12097 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
12099 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
12100 + const char *_file, int _line, void *_here)
12102 + struct vx_info *vxi;
12105 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
12106 + p, _file, _line);
12107 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
12113 +static inline void __wakeup_vx_info(struct vx_info *vxi)
12115 + if (waitqueue_active(&vxi->vx_wait))
12116 + wake_up_interruptible(&vxi->vx_wait);
12120 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
12122 +static inline void __enter_vx_info(struct vx_info *vxi,
12123 + struct vx_info_save *vxis, const char *_file, int _line)
12125 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
12126 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
12127 + current->xid, current->vx_info, _file, _line);
12128 + vxis->vxi = xchg(¤t->vx_info, vxi);
12129 + vxis->xid = current->xid;
12130 + current->xid = vxi ? vxi->vx_id : 0;
12133 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
12135 +static inline void __leave_vx_info(struct vx_info_save *vxis,
12136 + const char *_file, int _line)
12138 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
12139 + vxis, vxis->xid, vxis->vxi, current,
12140 + current->xid, current->vx_info, _file, _line);
12141 + (void)xchg(¤t->vx_info, vxis->vxi);
12142 + current->xid = vxis->xid;
12146 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
12148 + vxis->vxi = xchg(¤t->vx_info, NULL);
12149 + vxis->xid = xchg(¤t->xid, (xid_t)0);
12152 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
12154 + (void)xchg(¤t->xid, vxis->xid);
12155 + (void)xchg(¤t->vx_info, vxis->vxi);
12158 +extern void exit_vx_info(struct task_struct *, int);
12159 +extern void exit_vx_info_early(struct task_struct *, int);
12163 +#warning duplicate inclusion
12165 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_cowbl.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_cowbl.h
12166 --- linux-2.6.22.10/include/linux/vs_cowbl.h 1970-01-01 01:00:00 +0100
12167 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_cowbl.h 2007-08-05 20:53:13 +0200
12169 +#ifndef _VS_COWBL_H
12170 +#define _VS_COWBL_H
12172 +#include <linux/fs.h>
12173 +#include <linux/dcache.h>
12174 +#include <linux/namei.h>
12176 +extern struct dentry *cow_break_link(const char *pathname);
12178 +static inline int cow_check_and_break(struct nameidata *nd)
12180 + struct inode *inode = nd->dentry->d_inode;
12182 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
12184 + if (IS_COW(inode)) {
12185 + if (IS_COW_LINK(inode)) {
12186 + struct dentry *new_dentry, *old_dentry = nd->dentry;
12187 + char *path, *buf;
12189 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
12193 + path = d_path(nd->dentry, nd->mnt, buf, PATH_MAX);
12194 + new_dentry = cow_break_link(path);
12196 + if (!IS_ERR(new_dentry)) {
12197 + nd->dentry = new_dentry;
12198 + dput(old_dentry);
12200 + error = PTR_ERR(new_dentry);
12202 + inode->i_flags &= ~(S_IUNLINK | S_IMMUTABLE);
12203 + inode->i_ctime = CURRENT_TIME;
12204 + mark_inode_dirty(inode);
12211 +#warning duplicate inclusion
12213 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_cvirt.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_cvirt.h
12214 --- linux-2.6.22.10/include/linux/vs_cvirt.h 1970-01-01 01:00:00 +0100
12215 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_cvirt.h 2007-08-05 20:53:13 +0200
12217 +#ifndef _VS_CVIRT_H
12218 +#define _VS_CVIRT_H
12220 +#include "vserver/cvirt.h"
12221 +#include "vserver/context.h"
12222 +#include "vserver/base.h"
12223 +#include "vserver/debug.h"
12226 +static inline void vx_activate_task(struct task_struct *p)
12228 + struct vx_info *vxi;
12230 + if ((vxi = p->vx_info)) {
12231 + vx_update_load(vxi);
12232 + atomic_inc(&vxi->cvirt.nr_running);
12236 +static inline void vx_deactivate_task(struct task_struct *p)
12238 + struct vx_info *vxi;
12240 + if ((vxi = p->vx_info)) {
12241 + vx_update_load(vxi);
12242 + atomic_dec(&vxi->cvirt.nr_running);
12246 +static inline void vx_uninterruptible_inc(struct task_struct *p)
12248 + struct vx_info *vxi;
12250 + if ((vxi = p->vx_info))
12251 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
12254 +static inline void vx_uninterruptible_dec(struct task_struct *p)
12256 + struct vx_info *vxi;
12258 + if ((vxi = p->vx_info))
12259 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
12264 +#warning duplicate inclusion
12266 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_device.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_device.h
12267 --- linux-2.6.22.10/include/linux/vs_device.h 1970-01-01 01:00:00 +0100
12268 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_device.h 2007-10-11 01:10:22 +0200
12270 +#ifndef _VS_DEVICE_H
12271 +#define _VS_DEVICE_H
12273 +#include "vserver/base.h"
12274 +#include "vserver/device.h"
12275 +#include "vserver/debug.h"
12278 +#ifdef CONFIG_VSERVER_DEVICE
12280 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
12282 +#define vs_device_perm(v, d, m, p) \
12283 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
12288 +int vs_map_device(struct vx_info *vxi,
12289 + dev_t device, dev_t *target, umode_t mode)
12292 + *target = device;
12296 +#define vs_device_perm(v, d, m, p) ((p) == (p))
12301 +#define vs_map_chrdev(d, t, p) \
12302 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
12303 +#define vs_map_blkdev(d, t, p) \
12304 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
12306 +#define vs_chrdev_perm(d, p) \
12307 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
12308 +#define vs_blkdev_perm(d, p) \
12309 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
12313 +#warning duplicate inclusion
12315 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_dlimit.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_dlimit.h
12316 --- linux-2.6.22.10/include/linux/vs_dlimit.h 1970-01-01 01:00:00 +0100
12317 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_dlimit.h 2007-08-15 22:04:43 +0200
12319 +#ifndef _VS_DLIMIT_H
12320 +#define _VS_DLIMIT_H
12322 +#include <linux/fs.h>
12324 +#include "vserver/dlimit.h"
12325 +#include "vserver/base.h"
12326 +#include "vserver/debug.h"
12329 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
12331 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
12332 + const char *_file, int _line)
12336 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
12337 + dli, dli ? dli->dl_tag : 0,
12338 + dli ? atomic_read(&dli->dl_usecnt) : 0,
12340 + atomic_inc(&dli->dl_usecnt);
12345 +#define free_dl_info(i) \
12346 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
12348 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
12350 +static inline void __put_dl_info(struct dl_info *dli,
12351 + const char *_file, int _line)
12355 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
12356 + dli, dli ? dli->dl_tag : 0,
12357 + dli ? atomic_read(&dli->dl_usecnt) : 0,
12359 + if (atomic_dec_and_test(&dli->dl_usecnt))
12360 + free_dl_info(dli);
12364 +#define __dlimit_char(d) ((d) ? '*' : ' ')
12366 +static inline int __dl_alloc_space(struct super_block *sb,
12367 + tag_t tag, dlsize_t nr, const char *file, int line)
12369 + struct dl_info *dli = NULL;
12374 + dli = locate_dl_info(sb, tag);
12378 + spin_lock(&dli->dl_lock);
12379 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
12381 + dli->dl_space_used += nr;
12382 + spin_unlock(&dli->dl_lock);
12383 + put_dl_info(dli);
12385 + vxlprintk(VXD_CBIT(dlim, 1),
12386 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
12387 + sb, tag, __dlimit_char(dli), (long long)nr,
12388 + ret, file, line);
12392 +static inline void __dl_free_space(struct super_block *sb,
12393 + tag_t tag, dlsize_t nr, const char *_file, int _line)
12395 + struct dl_info *dli = NULL;
12399 + dli = locate_dl_info(sb, tag);
12403 + spin_lock(&dli->dl_lock);
12404 + if (dli->dl_space_used > nr)
12405 + dli->dl_space_used -= nr;
12407 + dli->dl_space_used = 0;
12408 + spin_unlock(&dli->dl_lock);
12409 + put_dl_info(dli);
12411 + vxlprintk(VXD_CBIT(dlim, 1),
12412 + "FREE (%p,#%d)%c %lld bytes",
12413 + sb, tag, __dlimit_char(dli), (long long)nr,
12417 +static inline int __dl_alloc_inode(struct super_block *sb,
12418 + tag_t tag, const char *_file, int _line)
12420 + struct dl_info *dli;
12423 + dli = locate_dl_info(sb, tag);
12427 + spin_lock(&dli->dl_lock);
12428 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
12430 + dli->dl_inodes_used++;
12431 + spin_unlock(&dli->dl_lock);
12432 + put_dl_info(dli);
12434 + vxlprintk(VXD_CBIT(dlim, 0),
12435 + "ALLOC (%p,#%d)%c inode (%d)",
12436 + sb, tag, __dlimit_char(dli), ret, _file, _line);
12440 +static inline void __dl_free_inode(struct super_block *sb,
12441 + tag_t tag, const char *_file, int _line)
12443 + struct dl_info *dli;
12445 + dli = locate_dl_info(sb, tag);
12449 + spin_lock(&dli->dl_lock);
12450 + if (dli->dl_inodes_used > 1)
12451 + dli->dl_inodes_used--;
12453 + dli->dl_inodes_used = 0;
12454 + spin_unlock(&dli->dl_lock);
12455 + put_dl_info(dli);
12457 + vxlprintk(VXD_CBIT(dlim, 0),
12458 + "FREE (%p,#%d)%c inode",
12459 + sb, tag, __dlimit_char(dli), _file, _line);
12462 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
12463 + unsigned long long *free_blocks, unsigned long long *root_blocks,
12464 + const char *_file, int _line)
12466 + struct dl_info *dli;
12467 + uint64_t broot, bfree;
12469 + dli = locate_dl_info(sb, tag);
12473 + spin_lock(&dli->dl_lock);
12474 + broot = (dli->dl_space_total -
12475 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
12476 + >> sb->s_blocksize_bits;
12477 + bfree = (dli->dl_space_total - dli->dl_space_used)
12478 + >> sb->s_blocksize_bits;
12479 + spin_unlock(&dli->dl_lock);
12481 + vxlprintk(VXD_CBIT(dlim, 2),
12482 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
12483 + (long long)bfree, (long long)broot,
12484 + *free_blocks, *root_blocks, dli->dl_nrlmult,
12486 + if (free_blocks) {
12487 + if (*free_blocks > bfree)
12488 + *free_blocks = bfree;
12490 + if (root_blocks) {
12491 + if (*root_blocks > broot)
12492 + *root_blocks = broot;
12494 + put_dl_info(dli);
12497 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
12498 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
12499 + __FILE__, __LINE__ )
12501 +#define DLIMIT_FREE_SPACE(in, bytes) \
12502 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
12503 + __FILE__, __LINE__ )
12505 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
12506 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
12507 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
12508 + __FILE__, __LINE__ )
12510 +#define DLIMIT_FREE_BLOCK(in, nr) \
12511 + __dl_free_space((in)->i_sb, (in)->i_tag, \
12512 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
12513 + __FILE__, __LINE__ )
12516 +#define DLIMIT_ALLOC_INODE(in) \
12517 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
12519 +#define DLIMIT_FREE_INODE(in) \
12520 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
12523 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
12524 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
12528 +#warning duplicate inclusion
12530 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_inet.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_inet.h
12531 --- linux-2.6.22.10/include/linux/vs_inet.h 1970-01-01 01:00:00 +0100
12532 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_inet.h 2007-10-05 15:07:22 +0200
12534 +#ifndef _VS_INET_H
12535 +#define _VS_INET_H
12537 +#include "vserver/base.h"
12538 +#include "vserver/network.h"
12539 +#include "vserver/debug.h"
12541 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
12543 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
12544 + NIPQUAD((a)->mask), (a)->type
12545 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
12549 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
12551 + __be32 ip = nxa->ip[0].s_addr;
12552 + __be32 mask = nxa->mask.s_addr;
12553 + __be32 bcast = ip | ~mask;
12556 + switch (nxa->type & tmask) {
12557 + case NXA_TYPE_MASK:
12558 + ret = (ip == (addr & mask));
12560 + case NXA_TYPE_ADDR:
12564 + /* fall through to broadcast */
12565 + case NXA_MOD_BCAST:
12566 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
12568 + case NXA_TYPE_RANGE:
12569 + ret = ((nxa->ip[0].s_addr <= addr) &&
12570 + (nxa->ip[1].s_addr > addr));
12572 + case NXA_TYPE_ANY:
12577 + vxdprintk(VXD_CBIT(net, 0),
12578 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
12579 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
12584 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
12586 + struct nx_addr_v4 *nxa;
12593 + /* allow 127.0.0.1 when remapping lback */
12594 + if ((tmask & NXA_LOOPBACK) &&
12595 + (addr == IPI_LOOPBACK) &&
12596 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12599 + /* check for lback address */
12600 + if ((tmask & NXA_MOD_LBACK) &&
12601 + (nxi->v4_lback.s_addr == addr))
12604 + /* check for broadcast address */
12605 + if ((tmask & NXA_MOD_BCAST) &&
12606 + (nxi->v4_bcast.s_addr == addr))
12609 + /* check for v4 addresses */
12610 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
12611 + if (v4_addr_match(nxa, addr, tmask))
12615 + vxdprintk(VXD_CBIT(net, 0),
12616 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
12617 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
12622 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
12624 + /* FIXME: needs full range checks */
12625 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
12629 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
12631 + struct nx_addr_v4 *ptr;
12633 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
12634 + if (v4_nx_addr_match(ptr, nxa, mask))
12639 +#include <net/inet_sock.h>
12642 + * Check if a given address matches for a socket
12644 + * nxi: the socket's nx_info if any
12645 + * addr: to be verified address
12648 +int v4_sock_addr_match (
12649 + struct nx_info *nxi,
12650 + struct inet_sock *inet,
12653 + __be32 saddr = inet->rcv_saddr;
12654 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
12656 + if (addr && (saddr == addr || bcast == addr))
12659 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
12664 +/* inet related checks and helpers */
12668 +struct net_device;
12671 +#ifdef CONFIG_INET
12673 +#include <linux/netdevice.h>
12674 +#include <linux/inetdevice.h>
12675 +#include <net/inet_timewait_sock.h>
12678 +int dev_in_nx_info(struct net_device *, struct nx_info *);
12679 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
12680 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
12684 + * check if address is covered by socket
12686 + * sk: the socket to check against
12687 + * addr: the address in question (must be != 0)
12691 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
12693 + struct nx_info *nxi = sk->sk_nx_info;
12694 + __be32 saddr = inet_rcv_saddr(sk);
12696 + vxdprintk(VXD_CBIT(net, 5),
12697 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
12698 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
12699 + (sk->sk_socket?sk->sk_socket->flags:0));
12701 + if (saddr) { /* direct address match */
12702 + return v4_addr_match(nxa, saddr, -1);
12703 + } else if (nxi) { /* match against nx_info */
12704 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
12705 + } else { /* unrestricted any socket */
12713 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
12715 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
12716 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
12717 + nxi ? dev_in_nx_info(dev, nxi) : 0);
12719 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
12721 + if (dev_in_nx_info(dev, nxi))
12728 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
12734 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
12738 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
12740 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
12741 + nxi, nxi ? nxi->nx_id : 0, ifa,
12742 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
12744 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
12746 + if (v4_ifa_in_nx_info(ifa, nxi))
12752 +struct nx_v4_sock_addr {
12753 + __be32 saddr; /* Address used for validation */
12754 + __be32 baddr; /* Address used for socket bind */
12758 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
12759 + struct nx_v4_sock_addr *nsa)
12761 + struct sock *sk = &inet->sk;
12762 + struct nx_info *nxi = sk->sk_nx_info;
12763 + __be32 saddr = addr->sin_addr.s_addr;
12764 + __be32 baddr = saddr;
12766 + vxdprintk(VXD_CBIT(net, 3),
12767 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
12768 + sk, sk->sk_nx_info, sk->sk_socket,
12769 + (sk->sk_socket ? sk->sk_socket->flags : 0),
12773 + if (saddr == INADDR_ANY) {
12774 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
12775 + baddr = nxi->v4.ip[0].s_addr;
12776 + } else if (saddr == IPI_LOOPBACK) {
12777 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12778 + baddr = nxi->v4_lback.s_addr;
12779 + } else { /* normal address bind */
12780 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
12781 + return -EADDRNOTAVAIL;
12785 + vxdprintk(VXD_CBIT(net, 3),
12786 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
12787 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
12789 + nsa->saddr = saddr;
12790 + nsa->baddr = baddr;
12795 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
12797 + inet->saddr = nsa->baddr;
12798 + inet->rcv_saddr = nsa->baddr;
12803 + * helper to simplify inet_lookup_listener
12805 + * nxi: the socket's nx_info if any
12806 + * addr: to be verified address
12807 + * saddr: socket address
12809 +static inline int v4_inet_addr_match (
12810 + struct nx_info *nxi,
12814 + if (addr && (saddr == addr))
12817 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
12821 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
12823 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
12824 + (addr == nxi->v4_lback.s_addr))
12825 + return IPI_LOOPBACK;
12830 +int nx_info_has_v4(struct nx_info *nxi)
12834 + if (NX_IPV4(nxi))
12836 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12841 +#else /* CONFIG_INET */
12844 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
12850 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
12856 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
12862 +int nx_info_has_v4(struct nx_info *nxi)
12867 +#endif /* CONFIG_INET */
12869 +#define current_nx_info_has_v4() \
12870 + nx_info_has_v4(current_nx_info())
12873 +#warning duplicate inclusion
12875 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_inet6.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_inet6.h
12876 --- linux-2.6.22.10/include/linux/vs_inet6.h 1970-01-01 01:00:00 +0100
12877 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_inet6.h 2007-10-05 14:54:36 +0200
12879 +#ifndef _VS_INET6_H
12880 +#define _VS_INET6_H
12882 +#include <net/ipv6.h>
12883 +#include "vserver/base.h"
12884 +#include "vserver/network.h"
12885 +#include "vserver/debug.h"
12887 +#define NXAV6(a) NIP6((a)->ip), NIP6((a)->mask), (a)->prefix, (a)->type
12888 +#define NXAV6_FMT "[" NIP6_FMT "/" NIP6_FMT "/%d:%04x]"
12891 +#ifdef CONFIG_IPV6
12894 +int v6_addr_match(struct nx_addr_v6 *nxa,
12895 + const struct in6_addr *addr, uint16_t mask)
12897 + switch (nxa->type & mask) {
12898 + case NXA_TYPE_MASK:
12899 + return ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
12900 + case NXA_TYPE_ADDR:
12901 + return ipv6_addr_equal(&nxa->ip, addr);
12902 + case NXA_TYPE_ANY:
12910 +int v6_addr_in_nx_info(struct nx_info *nxi,
12911 + const struct in6_addr *addr, uint16_t mask)
12913 + struct nx_addr_v6 *nxa;
12917 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
12918 + if (v6_addr_match(nxa, addr, mask))
12924 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
12926 + /* FIXME: needs full range checks */
12927 + return v6_addr_match(nxa, &addr->ip, mask);
12931 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
12933 + struct nx_addr_v6 *ptr;
12935 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
12936 + if (v6_nx_addr_match(ptr, nxa, mask))
12943 + * Check if a given address matches for a socket
12945 + * nxi: the socket's nx_info if any
12946 + * addr: to be verified address
12949 +int v6_sock_addr_match (
12950 + struct nx_info *nxi,
12951 + struct inet_sock *inet,
12952 + struct in6_addr *addr)
12954 + struct sock *sk = &inet->sk;
12955 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
12957 + if (!ipv6_addr_any(addr) &&
12958 + ipv6_addr_equal(saddr, addr))
12960 + if (ipv6_addr_any(saddr))
12961 + return v6_addr_in_nx_info(nxi, addr, -1);
12966 + * check if address is covered by socket
12968 + * sk: the socket to check against
12969 + * addr: the address in question (must be != 0)
12973 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
12975 + struct nx_info *nxi = sk->sk_nx_info;
12976 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
12978 + vxdprintk(VXD_CBIT(net, 5),
12979 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:" NIP6_FMT " %p;%lx",
12980 + sk, NXAV6(nxa), nxi, NIP6(*saddr), sk->sk_socket,
12981 + (sk->sk_socket?sk->sk_socket->flags:0));
12983 + if (!ipv6_addr_any(saddr)) { /* direct address match */
12984 + return v6_addr_match(nxa, saddr, -1);
12985 + } else if (nxi) { /* match against nx_info */
12986 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
12987 + } else { /* unrestricted any socket */
12993 +/* inet related checks and helpers */
12997 +struct net_device;
13001 +#include <linux/netdevice.h>
13002 +#include <linux/inetdevice.h>
13003 +#include <net/inet_timewait_sock.h>
13006 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13007 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13008 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13013 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13019 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13023 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13025 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13027 + if (v6_ifa_in_nx_info(ifa, nxi))
13033 +struct nx_v6_sock_addr {
13034 + struct in6_addr saddr; /* Address used for validation */
13035 + struct in6_addr baddr; /* Address used for socket bind */
13039 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13040 + struct nx_v6_sock_addr *nsa)
13042 + // struct sock *sk = &inet->sk;
13043 + // struct nx_info *nxi = sk->sk_nx_info;
13044 + struct in6_addr saddr = addr->sin6_addr;
13045 + struct in6_addr baddr = saddr;
13047 + nsa->saddr = saddr;
13048 + nsa->baddr = baddr;
13053 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13055 + // struct sock *sk = &inet->sk;
13056 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13058 + // *saddr = nsa->baddr;
13059 + // inet->saddr = nsa->baddr;
13063 +int nx_info_has_v6(struct nx_info *nxi)
13067 + if (NX_IPV6(nxi))
13072 +#else /* CONFIG_IPV6 */
13075 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13082 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13088 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13094 +int nx_info_has_v6(struct nx_info *nxi)
13099 +#endif /* CONFIG_IPV6 */
13101 +#define current_nx_info_has_v6() \
13102 + nx_info_has_v6(current_nx_info())
13105 +#warning duplicate inclusion
13107 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_limit.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_limit.h
13108 --- linux-2.6.22.10/include/linux/vs_limit.h 1970-01-01 01:00:00 +0100
13109 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_limit.h 2007-08-05 20:53:13 +0200
13111 +#ifndef _VS_LIMIT_H
13112 +#define _VS_LIMIT_H
13114 +#include "vserver/limit.h"
13115 +#include "vserver/base.h"
13116 +#include "vserver/context.h"
13117 +#include "vserver/debug.h"
13118 +#include "vserver/context.h"
13119 +#include "vserver/limit_int.h"
13122 +#define vx_acc_cres(v, d, p, r) \
13123 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13125 +#define vx_acc_cres_cond(x, d, p, r) \
13126 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13127 + r, d, p, __FILE__, __LINE__)
13130 +#define vx_add_cres(v, a, p, r) \
13131 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13132 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13134 +#define vx_add_cres_cond(x, a, p, r) \
13135 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13136 + r, a, p, __FILE__, __LINE__)
13137 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13140 +/* process and file limits */
13142 +#define vx_nproc_inc(p) \
13143 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13145 +#define vx_nproc_dec(p) \
13146 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13148 +#define vx_files_inc(f) \
13149 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13151 +#define vx_files_dec(f) \
13152 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13154 +#define vx_locks_inc(l) \
13155 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13157 +#define vx_locks_dec(l) \
13158 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13160 +#define vx_openfd_inc(f) \
13161 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
13163 +#define vx_openfd_dec(f) \
13164 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
13167 +#define vx_cres_avail(v, n, r) \
13168 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13171 +#define vx_nproc_avail(n) \
13172 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
13174 +#define vx_files_avail(n) \
13175 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
13177 +#define vx_locks_avail(n) \
13178 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
13180 +#define vx_openfd_avail(n) \
13181 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
13184 +/* dentry limits */
13186 +#define vx_dentry_inc(d) do { \
13187 + if (atomic_read(&d->d_count) == 1) \
13188 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
13191 +#define vx_dentry_dec(d) do { \
13192 + if (atomic_read(&d->d_count) == 0) \
13193 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
13196 +#define vx_dentry_avail(n) \
13197 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
13200 +/* socket limits */
13202 +#define vx_sock_inc(s) \
13203 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
13205 +#define vx_sock_dec(s) \
13206 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
13208 +#define vx_sock_avail(n) \
13209 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
13212 +/* ipc resource limits */
13214 +#define vx_ipcmsg_add(v, u, a) \
13215 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
13217 +#define vx_ipcmsg_sub(v, u, a) \
13218 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
13220 +#define vx_ipcmsg_avail(v, a) \
13221 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
13224 +#define vx_ipcshm_add(v, k, a) \
13225 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13227 +#define vx_ipcshm_sub(v, k, a) \
13228 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13230 +#define vx_ipcshm_avail(v, a) \
13231 + vx_cres_avail(v, a, VLIMIT_SHMEM)
13234 +#define vx_semary_inc(a) \
13235 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
13237 +#define vx_semary_dec(a) \
13238 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
13241 +#define vx_nsems_add(a,n) \
13242 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13244 +#define vx_nsems_sub(a,n) \
13245 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13249 +#warning duplicate inclusion
13251 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_memory.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_memory.h
13252 --- linux-2.6.22.10/include/linux/vs_memory.h 1970-01-01 01:00:00 +0100
13253 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_memory.h 2007-08-05 20:53:13 +0200
13255 +#ifndef _VS_MEMORY_H
13256 +#define _VS_MEMORY_H
13258 +#include "vserver/limit.h"
13259 +#include "vserver/base.h"
13260 +#include "vserver/context.h"
13261 +#include "vserver/debug.h"
13262 +#include "vserver/context.h"
13263 +#include "vserver/limit_int.h"
13266 +#define __acc_add_long(a, v) (*(v) += (a))
13267 +#define __acc_inc_long(v) (++*(v))
13268 +#define __acc_dec_long(v) (--*(v))
13270 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
13271 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
13272 +#define __acc_inc_atomic(v) atomic_long_inc(v)
13273 +#define __acc_dec_atomic(v) atomic_long_dec(v)
13274 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13275 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
13276 +#define __acc_inc_atomic(v) __acc_inc_long(v)
13277 +#define __acc_dec_atomic(v) __acc_dec_long(v)
13278 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13281 +#define vx_acc_page(m, d, v, r) do { \
13283 + __acc_inc_long(&(m)->v); \
13285 + __acc_dec_long(&(m)->v); \
13286 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13289 +#define vx_acc_page_atomic(m, d, v, r) do { \
13291 + __acc_inc_atomic(&(m)->v); \
13293 + __acc_dec_atomic(&(m)->v); \
13294 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13298 +#define vx_acc_pages(m, p, v, r) do { \
13299 + unsigned long __p = (p); \
13300 + __acc_add_long(__p, &(m)->v); \
13301 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13304 +#define vx_acc_pages_atomic(m, p, v, r) do { \
13305 + unsigned long __p = (p); \
13306 + __acc_add_atomic(__p, &(m)->v); \
13307 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13312 +#define vx_acc_vmpage(m, d) \
13313 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
13314 +#define vx_acc_vmlpage(m, d) \
13315 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
13316 +#define vx_acc_file_rsspage(m, d) \
13317 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
13318 +#define vx_acc_anon_rsspage(m, d) \
13319 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
13321 +#define vx_acc_vmpages(m, p) \
13322 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
13323 +#define vx_acc_vmlpages(m, p) \
13324 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
13325 +#define vx_acc_file_rsspages(m, p) \
13326 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
13327 +#define vx_acc_anon_rsspages(m, p) \
13328 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
13330 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
13331 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
13333 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
13334 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
13335 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
13336 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
13338 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
13339 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
13340 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
13341 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
13343 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
13344 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
13345 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
13346 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
13348 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
13349 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
13350 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
13351 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
13354 +#define vx_pages_avail(m, p, r) \
13355 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
13357 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
13358 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
13359 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
13360 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
13362 +#define vx_rss_avail(m, p) \
13363 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
13367 + VXPT_UNKNOWN = 0,
13376 +#define vx_page_fault(mm, vma, type, ret)
13380 +void __vx_page_fault(struct mm_struct *mm,
13381 + struct vm_area_struct *vma, int type, int ret)
13383 + struct vx_info *vxi = mm->mm_vx_info;
13386 + static char *page_type[6] =
13387 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
13388 + static char *page_what[4] =
13389 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
13395 + what = (ret & 0x3);
13397 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
13398 + type, what, ret, page_type[type], page_what[what]);
13400 + if (ret & VM_FAULT_WRITE)
13402 + atomic_inc(&vxi->cacct.page[type][what]);
13405 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
13409 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
13412 +#warning duplicate inclusion
13414 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_network.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_network.h
13415 --- linux-2.6.22.10/include/linux/vs_network.h 1970-01-01 01:00:00 +0100
13416 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_network.h 2007-08-05 20:53:13 +0200
13418 +#ifndef _NX_VS_NETWORK_H
13419 +#define _NX_VS_NETWORK_H
13421 +#include "vserver/context.h"
13422 +#include "vserver/network.h"
13423 +#include "vserver/base.h"
13424 +#include "vserver/debug.h"
13427 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
13429 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
13430 + const char *_file, int _line)
13435 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
13436 + nxi, nxi ? nxi->nx_id : 0,
13437 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13440 + atomic_inc(&nxi->nx_usecnt);
13445 +extern void free_nx_info(struct nx_info *);
13447 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
13449 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
13454 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
13455 + nxi, nxi ? nxi->nx_id : 0,
13456 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13459 + if (atomic_dec_and_test(&nxi->nx_usecnt))
13460 + free_nx_info(nxi);
13464 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
13466 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
13467 + const char *_file, int _line)
13470 + vxlprintk(VXD_CBIT(nid, 3),
13471 + "init_nx_info(%p[#%d.%d])",
13472 + nxi, nxi ? nxi->nx_id : 0,
13473 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13476 + atomic_inc(&nxi->nx_usecnt);
13482 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
13484 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
13485 + const char *_file, int _line)
13487 + struct nx_info *nxo;
13492 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
13493 + nxi, nxi ? nxi->nx_id : 0,
13494 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13497 + atomic_inc(&nxi->nx_usecnt);
13498 + nxo = xchg(nxp, nxi);
13502 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
13504 +static inline void __clr_nx_info(struct nx_info **nxp,
13505 + const char *_file, int _line)
13507 + struct nx_info *nxo;
13509 + nxo = xchg(nxp, NULL);
13513 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
13514 + nxo, nxo ? nxo->nx_id : 0,
13515 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
13518 + if (atomic_dec_and_test(&nxo->nx_usecnt))
13519 + free_nx_info(nxo);
13523 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
13525 +static inline void __claim_nx_info(struct nx_info *nxi,
13526 + struct task_struct *task, const char *_file, int _line)
13528 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
13529 + nxi, nxi ? nxi->nx_id : 0,
13530 + nxi?atomic_read(&nxi->nx_usecnt):0,
13531 + nxi?atomic_read(&nxi->nx_tasks):0,
13532 + task, _file, _line);
13534 + atomic_inc(&nxi->nx_tasks);
13538 +extern void unhash_nx_info(struct nx_info *);
13540 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
13542 +static inline void __release_nx_info(struct nx_info *nxi,
13543 + struct task_struct *task, const char *_file, int _line)
13545 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
13546 + nxi, nxi ? nxi->nx_id : 0,
13547 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13548 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
13549 + task, _file, _line);
13553 + if (atomic_dec_and_test(&nxi->nx_tasks))
13554 + unhash_nx_info(nxi);
13558 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
13560 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
13561 + const char *_file, int _line)
13563 + struct nx_info *nxi;
13566 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
13567 + p, _file, _line);
13568 + nxi = __get_nx_info(p->nx_info, _file, _line);
13574 +static inline void exit_nx_info(struct task_struct *p)
13577 + release_nx_info(p->nx_info, p);
13582 +#warning duplicate inclusion
13584 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_pid.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_pid.h
13585 --- linux-2.6.22.10/include/linux/vs_pid.h 1970-01-01 01:00:00 +0100
13586 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_pid.h 2007-09-05 02:49:29 +0200
13591 +#include "vserver/base.h"
13592 +#include "vserver/context.h"
13593 +#include "vserver/debug.h"
13594 +#include <linux/pid_namespace.h>
13597 +/* pid faking stuff */
13600 +#define vx_info_map_pid(v, p) \
13601 + __vx_info_map_pid((v), (p), __FUNC__, __FILE__, __LINE__)
13602 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13603 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
13604 +#define vx_map_tgid(p) vx_map_pid(p)
13606 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13607 + const char *func, const char *file, int line)
13609 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13610 + vxfprintk(VXD_CBIT(cvirt, 2),
13611 + "vx_map_tgid: %p/%llx: %d -> %d",
13612 + vxi, (long long)vxi->vx_flags, pid,
13613 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13614 + func, file, line);
13617 + if (pid == vxi->vx_initpid)
13623 +#define vx_info_rmap_pid(v, p) \
13624 + __vx_info_rmap_pid((v), (p), __FUNC__, __FILE__, __LINE__)
13625 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
13626 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13628 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13629 + const char *func, const char *file, int line)
13631 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13632 + vxfprintk(VXD_CBIT(cvirt, 2),
13633 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13634 + vxi, (long long)vxi->vx_flags, pid,
13635 + (pid == 1) ? vxi->vx_initpid : pid,
13636 + func, file, line);
13637 + if ((pid == 1) && vxi->vx_initpid)
13638 + return vxi->vx_initpid;
13639 + if (pid == vxi->vx_initpid)
13646 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
13649 +int vx_proc_task_visible(struct task_struct *task)
13651 + if ((task->pid == 1) &&
13652 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
13653 + /* show a blend through init */
13655 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
13663 +struct task_struct *vx_find_proc_task_by_pid(int pid)
13665 + struct task_struct *task = find_task_by_pid(pid);
13667 + if (task && !vx_proc_task_visible(task)) {
13668 + vxdprintk(VXD_CBIT(misc, 6),
13669 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
13670 + task, task->xid, task->pid,
13671 + current, current->xid, current->pid);
13678 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
13680 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
13682 + if (task && !vx_proc_task_visible(task)) {
13683 + vxdprintk(VXD_CBIT(misc, 6),
13684 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
13685 + task, task->xid, task->pid,
13686 + current, current->xid, current->pid);
13687 + put_task_struct(task);
13695 +struct task_struct *vx_child_reaper(struct task_struct *p)
13697 + struct vx_info *vxi = p->vx_info;
13698 + struct task_struct *reaper = child_reaper(p);
13703 + BUG_ON(!p->vx_info->vx_reaper);
13705 + /* child reaper for the guest reaper */
13706 + if (vxi->vx_reaper == p)
13709 + reaper = vxi->vx_reaper;
13711 + vxdprintk(VXD_CBIT(xid, 7),
13712 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
13713 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
13719 +#warning duplicate inclusion
13721 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_sched.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_sched.h
13722 --- linux-2.6.22.10/include/linux/vs_sched.h 1970-01-01 01:00:00 +0100
13723 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_sched.h 2007-08-05 20:53:13 +0200
13725 +#ifndef _VS_SCHED_H
13726 +#define _VS_SCHED_H
13728 +#include "vserver/base.h"
13729 +#include "vserver/context.h"
13730 +#include "vserver/sched.h"
13733 +#define VAVAVOOM_RATIO 50
13735 +#define MAX_PRIO_BIAS 20
13736 +#define MIN_PRIO_BIAS -20
13739 +#ifdef CONFIG_VSERVER_HARDCPU
13742 + * effective_prio - return the priority that is based on the static
13743 + * priority but is modified by bonuses/penalties.
13745 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
13746 + * into a -4 ... 0 ... +4 bonus/penalty range.
13748 + * Additionally, we scale another amount based on the number of
13749 + * CPU tokens currently held by the context, if the process is
13750 + * part of a context (and the appropriate SCHED flag is set).
13751 + * This ranges from -5 ... 0 ... +15, quadratically.
13753 + * So, the total bonus is -9 .. 0 .. +19
13754 + * We use ~50% of the full 0...39 priority range so that:
13756 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
13757 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
13758 + * unless that context is far exceeding its CPU allocation.
13760 + * Both properties are important to certain workloads.
13763 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
13765 + int vavavoom, max;
13767 + /* lots of tokens = lots of vavavoom
13768 + * no tokens = no vavavoom */
13769 + if ((vavavoom = sched_pc->tokens) >= 0) {
13770 + max = sched_pc->tokens_max;
13771 + vavavoom = max - vavavoom;
13773 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
13774 + * (vavavoom*vavavoom - (max >> 2)) / max;
13782 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
13784 + struct vx_info *vxi = p->vx_info;
13785 + struct _vx_sched_pc *sched_pc;
13790 + sched_pc = &vx_cpu(vxi, sched_pc);
13791 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
13792 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
13794 + sched_pc->vavavoom = vavavoom;
13795 + prio += vavavoom;
13797 + prio += sched_pc->prio_bias;
13801 +#else /* !CONFIG_VSERVER_HARDCPU */
13804 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
13806 + struct vx_info *vxi = p->vx_info;
13809 + prio += vx_cpu(vxi, sched_pc).prio_bias;
13813 +#endif /* CONFIG_VSERVER_HARDCPU */
13816 +static inline void vx_account_user(struct vx_info *vxi,
13817 + cputime_t cputime, int nice)
13821 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
13824 +static inline void vx_account_system(struct vx_info *vxi,
13825 + cputime_t cputime, int idle)
13829 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
13833 +#warning duplicate inclusion
13835 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_socket.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_socket.h
13836 --- linux-2.6.22.10/include/linux/vs_socket.h 1970-01-01 01:00:00 +0100
13837 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_socket.h 2007-08-05 20:53:13 +0200
13839 +#ifndef _VS_SOCKET_H
13840 +#define _VS_SOCKET_H
13842 +#include "vserver/debug.h"
13843 +#include "vserver/base.h"
13844 +#include "vserver/cacct.h"
13845 +#include "vserver/context.h"
13846 +#include "vserver/tag.h"
13849 +/* socket accounting */
13851 +#include <linux/socket.h>
13853 +static inline int vx_sock_type(int family)
13855 + switch (family) {
13857 + return VXA_SOCK_UNSPEC;
13859 + return VXA_SOCK_UNIX;
13861 + return VXA_SOCK_INET;
13863 + return VXA_SOCK_INET6;
13865 + return VXA_SOCK_PACKET;
13867 + return VXA_SOCK_OTHER;
13871 +#define vx_acc_sock(v, f, p, s) \
13872 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
13874 +static inline void __vx_acc_sock(struct vx_info *vxi,
13875 + int family, int pos, int size, char *file, int line)
13878 + int type = vx_sock_type(family);
13880 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
13881 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
13885 +#define vx_sock_recv(sk, s) \
13886 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
13887 +#define vx_sock_send(sk, s) \
13888 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
13889 +#define vx_sock_fail(sk, s) \
13890 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
13893 +#define sock_vx_init(s) do { \
13894 + (s)->sk_xid = 0; \
13895 + (s)->sk_vx_info = NULL; \
13898 +#define sock_nx_init(s) do { \
13899 + (s)->sk_nid = 0; \
13900 + (s)->sk_nx_info = NULL; \
13904 +int vx_socket_peer_tag(struct socket *sock, int level,
13905 + char __user *optval, int __user *optlen, int len)
13907 + struct peer_tag tag;
13909 + tag.xid = sock->sk->sk_xid;
13910 + tag.nid = sock->sk->sk_nid;
13911 + if (copy_to_user(optval, &tag, sizeof(tag)))
13917 +#warning duplicate inclusion
13919 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_tag.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_tag.h
13920 --- linux-2.6.22.10/include/linux/vs_tag.h 1970-01-01 01:00:00 +0100
13921 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_tag.h 2007-08-15 19:11:32 +0200
13926 +#include <linux/vserver/tag.h>
13928 +/* check conditions */
13930 +#define DX_ADMIN 0x0001
13931 +#define DX_WATCH 0x0002
13932 +#define DX_HOSTID 0x0008
13934 +#define DX_IDENT 0x0010
13936 +#define DX_ARG_MASK 0x0010
13939 +#define dx_task_tag(t) ((t)->tag)
13941 +#define dx_current_tag() dx_task_tag(current)
13943 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
13945 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
13949 + * check current context for ADMIN/WATCH and
13950 + * optionally against supplied argument
13952 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
13954 + if (mode & DX_ARG_MASK) {
13955 + if ((mode & DX_IDENT) && (id == cid))
13958 + return (((mode & DX_ADMIN) && (cid == 0)) ||
13959 + ((mode & DX_WATCH) && (cid == 1)) ||
13960 + ((mode & DX_HOSTID) && (id == 0)));
13964 +#warning duplicate inclusion
13966 diff -NurpP --minimal linux-2.6.22.10/include/linux/vs_time.h linux-2.6.22.10-vs2.3.0.29/include/linux/vs_time.h
13967 --- linux-2.6.22.10/include/linux/vs_time.h 1970-01-01 01:00:00 +0100
13968 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_time.h 2007-08-05 20:53:13 +0200
13970 +#ifndef _VS_TIME_H
13971 +#define _VS_TIME_H
13974 +/* time faking stuff */
13976 +#ifdef CONFIG_VSERVER_VTIME
13978 +extern void vx_gettimeofday(struct timeval *tv);
13979 +extern int vx_settimeofday(struct timespec *ts);
13982 +#define vx_gettimeofday(t) do_gettimeofday(t)
13983 +#define vx_settimeofday(t) do_settimeofday(t)
13987 +#warning duplicate inclusion
13989 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/Kbuild linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/Kbuild
13990 --- linux-2.6.22.10/include/linux/vserver/Kbuild 1970-01-01 01:00:00 +0100
13991 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/Kbuild 2007-10-11 01:10:22 +0200
13994 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
13995 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
13996 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
13997 + debug_cmd.h device_cmd.h
13999 +unifdef-y += switch.h network.h monitor.h inode.h device.h
14001 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/base.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/base.h
14002 --- linux-2.6.22.10/include/linux/vserver/base.h 1970-01-01 01:00:00 +0100
14003 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/base.h 2007-09-17 14:07:30 +0200
14005 +#ifndef _VX_BASE_H
14006 +#define _VX_BASE_H
14009 +/* context state changes */
14020 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
14022 +/* check conditions */
14024 +#define VS_ADMIN 0x0001
14025 +#define VS_WATCH 0x0002
14026 +#define VS_HIDE 0x0004
14027 +#define VS_HOSTID 0x0008
14029 +#define VS_IDENT 0x0010
14030 +#define VS_EQUIV 0x0020
14031 +#define VS_PARENT 0x0040
14032 +#define VS_CHILD 0x0080
14034 +#define VS_ARG_MASK 0x00F0
14036 +#ifdef CONFIG_VSERVER_PRIVACY
14037 +#define VS_ADMIN_P (0)
14038 +#define VS_WATCH_P (0)
14040 +#define VS_ADMIN_P VS_ADMIN
14041 +#define VS_WATCH_P VS_WATCH
14044 +#define VS_HARDIRQ 0x1000
14045 +#define VS_SOFTIRQ 0x2000
14046 +#define VS_IRQ 0x4000
14048 +#define VS_IRQ_MASK 0xF000
14050 +#include <linux/hardirq.h>
14053 + * check current context for ADMIN/WATCH and
14054 + * optionally against supplied argument
14056 +static inline int __vs_check(int cid, int id, unsigned int mode)
14058 + if (mode & VS_ARG_MASK) {
14059 + if ((mode & VS_IDENT) && (id == cid))
14062 + if (mode & VS_IRQ_MASK) {
14063 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
14065 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
14067 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
14070 + return (((mode & VS_ADMIN) && (cid == 0)) ||
14071 + ((mode & VS_WATCH) && (cid == 1)) ||
14072 + ((mode & VS_HOSTID) && (id == 0)));
14075 +#define vx_task_xid(t) ((t)->xid)
14077 +#define vx_current_xid() vx_task_xid(current)
14079 +#define current_vx_info() (current->vx_info)
14082 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
14084 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
14087 +#define nx_task_nid(t) ((t)->nid)
14089 +#define nx_current_nid() nx_task_nid(current)
14091 +#define current_nx_info() (current->nx_info)
14094 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
14096 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
14100 +/* generic flag merging */
14102 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
14104 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
14106 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
14108 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
14111 +/* context flags */
14113 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
14115 +#define vx_current_flags() __vx_flags(current->vx_info)
14117 +#define vx_info_flags(v, m, f) \
14118 + vs_check_flags(__vx_flags(v), m, f)
14120 +#define task_vx_flags(t, m, f) \
14121 + ((t) && vx_info_flags((t)->vx_info, m, f))
14123 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
14126 +/* context caps */
14128 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
14130 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
14132 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
14134 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
14138 +/* network flags */
14140 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
14142 +#define nx_current_flags() __nx_flags(current->nx_info)
14144 +#define nx_info_flags(n, m, f) \
14145 + vs_check_flags(__nx_flags(n), m, f)
14147 +#define task_nx_flags(t, m, f) \
14148 + ((t) && nx_info_flags((t)->nx_info, m, f))
14150 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
14153 +/* network caps */
14155 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
14157 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
14159 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
14161 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
14164 +/* context mask capabilities */
14166 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
14168 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
14170 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
14173 +/* context bcap mask */
14175 +#define __vx_bcaps(v) ((v) ? (v)->vx_bcaps : ~0 )
14177 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
14179 +#define vx_info_bcaps(v, c) (__vx_bcaps(v) & (c))
14181 +#define vx_bcaps(c) vx_info_bcaps(current->vx_info, c)
14184 +#define vx_info_cap_bset(v) ((v) ? (v)->vx_cap_bset : cap_bset)
14186 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
14189 +#define __vx_info_mbcap(v, b) \
14190 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
14191 + vx_info_bcaps(v, b) : (b))
14193 +#define vx_info_mbcap(v, b) __vx_info_mbcap(v, cap_t(b))
14195 +#define task_vx_mbcap(t, b) \
14196 + vx_info_mbcap((t)->vx_info, (t)->b)
14198 +#define vx_mbcap(b) task_vx_mbcap(current, b)
14200 +#define vx_cap_raised(v, c, f) (vx_info_mbcap(v, c) & CAP_TO_MASK(f))
14202 +#define vx_capable(b, c) (capable(b) || \
14203 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
14205 +#define nx_capable(b, c) (capable(b) || \
14206 + (cap_raised(current->cap_effective, b) && nx_ncaps(c)))
14208 +#define vx_current_initpid(n) \
14209 + (current->vx_info && \
14210 + (current->vx_info->vx_initpid == (n)))
14213 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
14215 +#define vx_info_state(v, m) (__vx_state(v) & (m))
14218 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
14220 +#define nx_info_state(n, m) (__nx_state(n) & (m))
14223 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct.h
14224 --- linux-2.6.22.10/include/linux/vserver/cacct.h 1970-01-01 01:00:00 +0100
14225 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct.h 2007-08-05 20:53:13 +0200
14227 +#ifndef _VX_CACCT_H
14228 +#define _VX_CACCT_H
14231 +enum sock_acc_field {
14232 + VXA_SOCK_UNSPEC = 0,
14238 + VXA_SOCK_SIZE /* array size */
14241 +#endif /* _VX_CACCT_H */
14242 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_cmd.h
14243 --- linux-2.6.22.10/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00 +0100
14244 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_cmd.h 2007-08-05 20:53:13 +0200
14246 +#ifndef _VX_CACCT_CMD_H
14247 +#define _VX_CACCT_CMD_H
14250 +/* virtual host info name commands */
14252 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
14254 +struct vcmd_sock_stat_v0 {
14256 + uint32_t count[3];
14257 + uint64_t total[3];
14263 +#include <linux/compiler.h>
14265 +extern int vc_sock_stat(struct vx_info *, void __user *);
14267 +#endif /* __KERNEL__ */
14268 +#endif /* _VX_CACCT_CMD_H */
14269 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct_def.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_def.h
14270 --- linux-2.6.22.10/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00 +0100
14271 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_def.h 2007-08-05 20:53:13 +0200
14273 +#ifndef _VX_CACCT_DEF_H
14274 +#define _VX_CACCT_DEF_H
14276 +#include <asm/atomic.h>
14277 +#include <linux/vserver/cacct.h>
14280 +struct _vx_sock_acc {
14281 + atomic_long_t count;
14282 + atomic_long_t total;
14285 +/* context sub struct */
14287 +struct _vx_cacct {
14288 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
14289 + atomic_t slab[8];
14290 + atomic_t page[6][8];
14293 +#ifdef CONFIG_VSERVER_DEBUG
14295 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
14299 + printk("\t_vx_cacct:");
14300 + for (i = 0; i < 6; i++) {
14301 + struct _vx_sock_acc *ptr = cacct->sock[i];
14303 + printk("\t [%d] =", i);
14304 + for (j = 0; j < 3; j++) {
14305 + printk(" [%d] = %8lu, %8lu", j,
14306 + atomic_long_read(&ptr[j].count),
14307 + atomic_long_read(&ptr[j].total));
14315 +#endif /* _VX_CACCT_DEF_H */
14316 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cacct_int.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_int.h
14317 --- linux-2.6.22.10/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00 +0100
14318 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_int.h 2007-08-05 20:53:13 +0200
14320 +#ifndef _VX_CACCT_INT_H
14321 +#define _VX_CACCT_INT_H
14327 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
14329 + return atomic_long_read(&cacct->sock[type][pos].count);
14334 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
14336 + return atomic_long_read(&cacct->sock[type][pos].total);
14339 +#endif /* __KERNEL__ */
14340 +#endif /* _VX_CACCT_INT_H */
14341 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/context.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/context.h
14342 --- linux-2.6.22.10/include/linux/vserver/context.h 1970-01-01 01:00:00 +0100
14343 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/context.h 2007-10-11 01:10:22 +0200
14345 +#ifndef _VX_CONTEXT_H
14346 +#define _VX_CONTEXT_H
14348 +#include <linux/types.h>
14349 +#include <linux/capability.h>
14352 +/* context flags */
14354 +#define VXF_INFO_SCHED 0x00000002
14355 +#define VXF_INFO_NPROC 0x00000004
14356 +#define VXF_INFO_PRIVATE 0x00000008
14358 +#define VXF_INFO_INIT 0x00000010
14359 +#define VXF_INFO_HIDE 0x00000020
14360 +#define VXF_INFO_ULIMIT 0x00000040
14361 +#define VXF_INFO_NSPACE 0x00000080
14363 +#define VXF_SCHED_HARD 0x00000100
14364 +#define VXF_SCHED_PRIO 0x00000200
14365 +#define VXF_SCHED_PAUSE 0x00000400
14367 +#define VXF_VIRT_MEM 0x00010000
14368 +#define VXF_VIRT_UPTIME 0x00020000
14369 +#define VXF_VIRT_CPU 0x00040000
14370 +#define VXF_VIRT_LOAD 0x00080000
14371 +#define VXF_VIRT_TIME 0x00100000
14373 +#define VXF_HIDE_MOUNT 0x01000000
14374 +/* was VXF_HIDE_NETIF 0x02000000 */
14375 +#define VXF_HIDE_VINFO 0x04000000
14377 +#define VXF_STATE_SETUP (1ULL << 32)
14378 +#define VXF_STATE_INIT (1ULL << 33)
14379 +#define VXF_STATE_ADMIN (1ULL << 34)
14381 +#define VXF_SC_HELPER (1ULL << 36)
14382 +#define VXF_REBOOT_KILL (1ULL << 37)
14383 +#define VXF_PERSISTENT (1ULL << 38)
14385 +#define VXF_FORK_RSS (1ULL << 48)
14386 +#define VXF_PROLIFIC (1ULL << 49)
14388 +#define VXF_IGNEG_NICE (1ULL << 52)
14390 +#define VXF_ONE_TIME (0x0007ULL << 32)
14392 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
14395 +/* context migration */
14397 +#define VXM_SET_INIT 0x00000001
14398 +#define VXM_SET_REAPER 0x00000002
14400 +/* context caps */
14402 +#define VXC_CAP_MASK 0x00000000
14404 +#define VXC_SET_UTSNAME 0x00000001
14405 +#define VXC_SET_RLIMIT 0x00000002
14407 +/* was VXC_RAW_ICMP 0x00000100 */
14408 +#define VXC_SYSLOG 0x00001000
14410 +#define VXC_SECURE_MOUNT 0x00010000
14411 +#define VXC_SECURE_REMOUNT 0x00020000
14412 +#define VXC_BINARY_MOUNT 0x00040000
14414 +#define VXC_QUOTA_CTL 0x00100000
14415 +#define VXC_ADMIN_MAPPER 0x00200000
14416 +#define VXC_ADMIN_CLOOP 0x00400000
14418 +#define VXC_KTHREAD 0x01000000
14423 +#include <linux/list.h>
14424 +#include <linux/spinlock.h>
14425 +#include <linux/rcupdate.h>
14427 +#include "limit_def.h"
14428 +#include "sched_def.h"
14429 +#include "cvirt_def.h"
14430 +#include "cacct_def.h"
14431 +#include "device_def.h"
14433 +struct _vx_info_pc {
14434 + struct _vx_sched_pc sched_pc;
14435 + struct _vx_cvirt_pc cvirt_pc;
14439 + struct hlist_node vx_hlist; /* linked list of contexts */
14440 + xid_t vx_id; /* context id */
14441 + atomic_t vx_usecnt; /* usage count */
14442 + atomic_t vx_tasks; /* tasks count */
14443 + struct vx_info *vx_parent; /* parent context */
14444 + int vx_state; /* context state */
14446 + unsigned long vx_nsmask; /* assignment mask */
14447 + struct nsproxy *vx_nsproxy; /* private namespace */
14448 + struct fs_struct *vx_fs; /* private namespace fs */
14450 + uint64_t vx_flags; /* context flags */
14451 + uint64_t vx_bcaps; /* bounding caps (system) */
14452 + uint64_t vx_ccaps; /* context caps (vserver) */
14453 + kernel_cap_t vx_cap_bset; /* the guest's bset */
14455 + struct task_struct *vx_reaper; /* guest reaper process */
14456 + pid_t vx_initpid; /* PID of guest init */
14457 + int64_t vx_badness_bias; /* OOM points bias */
14459 + struct _vx_limit limit; /* vserver limits */
14460 + struct _vx_sched sched; /* vserver scheduler */
14461 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
14462 + struct _vx_cacct cacct; /* context accounting */
14464 + struct _vx_device dmap; /* default device map targets */
14466 +#ifndef CONFIG_SMP
14467 + struct _vx_info_pc info_pc; /* per cpu data */
14469 + struct _vx_info_pc *ptr_pc; /* per cpu array */
14472 + wait_queue_head_t vx_wait; /* context exit waitqueue */
14473 + int reboot_cmd; /* last sys_reboot() cmd */
14474 + int exit_code; /* last process exit code */
14476 + char vx_name[65]; /* vserver name */
14479 +#ifndef CONFIG_SMP
14480 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
14481 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
14483 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
14484 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
14487 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
14490 +struct vx_info_save {
14491 + struct vx_info *vxi;
14496 +/* status flags */
14498 +#define VXS_HASHED 0x0001
14499 +#define VXS_PAUSED 0x0010
14500 +#define VXS_SHUTDOWN 0x0100
14501 +#define VXS_HELPER 0x1000
14502 +#define VXS_RELEASED 0x8000
14505 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
14506 +extern void release_vx_info(struct vx_info *, struct task_struct *);
14508 +extern struct vx_info *lookup_vx_info(int);
14509 +extern struct vx_info *lookup_or_create_vx_info(int);
14511 +extern int get_xid_list(int, unsigned int *, int);
14512 +extern int xid_is_hashed(xid_t);
14514 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
14516 +extern long vs_state_change(struct vx_info *, unsigned int);
14519 +#endif /* __KERNEL__ */
14520 +#endif /* _VX_CONTEXT_H */
14521 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/context_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/context_cmd.h
14522 --- linux-2.6.22.10/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00 +0100
14523 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/context_cmd.h 2007-08-19 00:40:28 +0200
14525 +#ifndef _VX_CONTEXT_CMD_H
14526 +#define _VX_CONTEXT_CMD_H
14529 +/* vinfo commands */
14531 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
14534 +extern int vc_task_xid(uint32_t);
14536 +#endif /* __KERNEL__ */
14538 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
14540 +struct vcmd_vx_info_v0 {
14542 + uint32_t initpid;
14543 + /* more to come */
14547 +extern int vc_vx_info(struct vx_info *, void __user *);
14549 +#endif /* __KERNEL__ */
14551 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
14553 +struct vcmd_ctx_stat_v0 {
14556 + /* more to come */
14560 +extern int vc_ctx_stat(struct vx_info *, void __user *);
14562 +#endif /* __KERNEL__ */
14564 +/* context commands */
14566 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
14567 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
14569 +struct vcmd_ctx_create {
14570 + uint64_t flagword;
14573 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
14574 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
14576 +struct vcmd_ctx_migrate {
14577 + uint64_t flagword;
14581 +extern int vc_ctx_create(uint32_t, void __user *);
14582 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
14584 +#endif /* __KERNEL__ */
14587 +/* flag commands */
14589 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
14590 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
14592 +struct vcmd_ctx_flags_v0 {
14593 + uint64_t flagword;
14598 +extern int vc_get_cflags(struct vx_info *, void __user *);
14599 +extern int vc_set_cflags(struct vx_info *, void __user *);
14601 +#endif /* __KERNEL__ */
14604 +/* context caps commands */
14606 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
14607 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
14609 +struct vcmd_ctx_caps_v1 {
14615 +extern int vc_get_ccaps(struct vx_info *, void __user *);
14616 +extern int vc_set_ccaps(struct vx_info *, void __user *);
14618 +#endif /* __KERNEL__ */
14621 +/* bcaps commands */
14623 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
14624 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
14626 +struct vcmd_bcaps {
14632 +extern int vc_get_bcaps(struct vx_info *, void __user *);
14633 +extern int vc_set_bcaps(struct vx_info *, void __user *);
14635 +#endif /* __KERNEL__ */
14640 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
14641 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
14643 +struct vcmd_badness_v0 {
14648 +extern int vc_get_badness(struct vx_info *, void __user *);
14649 +extern int vc_set_badness(struct vx_info *, void __user *);
14651 +#endif /* __KERNEL__ */
14652 +#endif /* _VX_CONTEXT_CMD_H */
14653 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cvirt.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt.h
14654 --- linux-2.6.22.10/include/linux/vserver/cvirt.h 1970-01-01 01:00:00 +0100
14655 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt.h 2007-08-05 20:53:13 +0200
14657 +#ifndef _VX_CVIRT_H
14658 +#define _VX_CVIRT_H
14665 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14670 +void vx_update_load(struct vx_info *);
14673 +int vx_do_syslog(int, char __user *, int);
14675 +#endif /* __KERNEL__ */
14676 +#endif /* _VX_CVIRT_H */
14677 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cvirt_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt_cmd.h
14678 --- linux-2.6.22.10/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00 +0100
14679 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt_cmd.h 2007-08-05 20:53:13 +0200
14681 +#ifndef _VX_CVIRT_CMD_H
14682 +#define _VX_CVIRT_CMD_H
14685 +/* virtual host info name commands */
14687 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
14688 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
14690 +struct vcmd_vhi_name_v0 {
14696 +enum vhi_name_field {
14697 + VHIN_CONTEXT = 0,
14709 +#include <linux/compiler.h>
14711 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
14712 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
14714 +#endif /* __KERNEL__ */
14716 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
14718 +struct vcmd_virt_stat_v0 {
14721 + uint32_t nr_threads;
14722 + uint32_t nr_running;
14723 + uint32_t nr_uninterruptible;
14724 + uint32_t nr_onhold;
14725 + uint32_t nr_forks;
14726 + uint32_t load[3];
14730 +extern int vc_virt_stat(struct vx_info *, void __user *);
14732 +#endif /* __KERNEL__ */
14733 +#endif /* _VX_CVIRT_CMD_H */
14734 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/cvirt_def.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt_def.h
14735 --- linux-2.6.22.10/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00 +0100
14736 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt_def.h 2007-08-05 20:53:13 +0200
14738 +#ifndef _VX_CVIRT_DEF_H
14739 +#define _VX_CVIRT_DEF_H
14741 +#include <linux/jiffies.h>
14742 +#include <linux/spinlock.h>
14743 +#include <linux/wait.h>
14744 +#include <linux/time.h>
14745 +#include <linux/utsname.h>
14746 +#include <asm/atomic.h>
14749 +struct _vx_usage_stat {
14753 + uint64_t softirq;
14759 +struct _vx_syslog {
14760 + wait_queue_head_t log_wait;
14761 + spinlock_t logbuf_lock; /* lock for the log buffer */
14763 + unsigned long log_start; /* next char to be read by syslog() */
14764 + unsigned long con_start; /* next char to be sent to consoles */
14765 + unsigned long log_end; /* most-recently-written-char + 1 */
14766 + unsigned long logged_chars; /* #chars since last read+clear operation */
14768 + char log_buf[1024];
14772 +/* context sub struct */
14774 +struct _vx_cvirt {
14775 + atomic_t nr_threads; /* number of current threads */
14776 + atomic_t nr_running; /* number of running threads */
14777 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
14779 + atomic_t nr_onhold; /* processes on hold */
14780 + uint32_t onhold_last; /* jiffies when put on hold */
14782 + struct timeval bias_tv; /* time offset to the host */
14783 + struct timespec bias_idle;
14784 + struct timespec bias_uptime; /* context creation point */
14785 + uint64_t bias_clock; /* offset in clock_t */
14787 + spinlock_t load_lock; /* lock for the load averages */
14788 + atomic_t load_updates; /* nr of load updates done so far */
14789 + uint32_t load_last; /* last time load was calculated */
14790 + uint32_t load[3]; /* load averages 1,5,15 */
14792 + atomic_t total_forks; /* number of forks so far */
14794 + struct _vx_syslog syslog;
14797 +struct _vx_cvirt_pc {
14798 + struct _vx_usage_stat cpustat;
14802 +#ifdef CONFIG_VSERVER_DEBUG
14804 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
14806 + printk("\t_vx_cvirt:\n");
14807 + printk("\t threads: %4d, %4d, %4d, %4d\n",
14808 + atomic_read(&cvirt->nr_threads),
14809 + atomic_read(&cvirt->nr_running),
14810 + atomic_read(&cvirt->nr_uninterruptible),
14811 + atomic_read(&cvirt->nr_onhold));
14812 + /* add rest here */
14813 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
14818 +#endif /* _VX_CVIRT_DEF_H */
14819 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/debug.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/debug.h
14820 --- linux-2.6.22.10/include/linux/vserver/debug.h 1970-01-01 01:00:00 +0100
14821 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/debug.h 2007-10-25 17:05:55 +0200
14823 +#ifndef _VX_DEBUG_H
14824 +#define _VX_DEBUG_H
14827 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
14828 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
14829 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
14831 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
14832 + imajor((d)->bd_inode), iminor((d)->bd_inode)
14833 +#define VXF_DEV "%p[%lu,%d:%d]"
14836 +#define __FUNC__ __func__
14839 +#define vxd_path(d, m) \
14840 + ({ static char _buffer[PATH_MAX]; \
14841 + d_path(d, m, _buffer, sizeof(_buffer)); })
14843 +#define vxd_cond_path(n) \
14844 + ((n) ? vxd_path((n)->dentry, (n)->mnt) : "<null>" )
14847 +#ifdef CONFIG_VSERVER_DEBUG
14849 +extern unsigned int vx_debug_switch;
14850 +extern unsigned int vx_debug_xid;
14851 +extern unsigned int vx_debug_nid;
14852 +extern unsigned int vx_debug_tag;
14853 +extern unsigned int vx_debug_net;
14854 +extern unsigned int vx_debug_limit;
14855 +extern unsigned int vx_debug_cres;
14856 +extern unsigned int vx_debug_dlim;
14857 +extern unsigned int vx_debug_quota;
14858 +extern unsigned int vx_debug_cvirt;
14859 +extern unsigned int vx_debug_space;
14860 +extern unsigned int vx_debug_misc;
14863 +#define VX_LOGLEVEL "vxD: "
14864 +#define VX_PROC_FMT "%p: "
14865 +#define VX_PROCESS current
14867 +#define vxdprintk(c, f, x...) \
14870 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
14871 + VX_PROCESS , ##x); \
14874 +#define vxlprintk(c, f, x...) \
14877 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
14880 +#define vxfprintk(c, f, x...) \
14883 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
14889 +void dump_vx_info(struct vx_info *, int);
14890 +void dump_vx_info_inactive(int);
14892 +#else /* CONFIG_VSERVER_DEBUG */
14894 +#define vx_debug_switch 0
14895 +#define vx_debug_xid 0
14896 +#define vx_debug_nid 0
14897 +#define vx_debug_tag 0
14898 +#define vx_debug_net 0
14899 +#define vx_debug_limit 0
14900 +#define vx_debug_cres 0
14901 +#define vx_debug_dlim 0
14902 +#define vx_debug_cvirt 0
14904 +#define vxdprintk(x...) do { } while (0)
14905 +#define vxlprintk(x...) do { } while (0)
14906 +#define vxfprintk(x...) do { } while (0)
14908 +#endif /* CONFIG_VSERVER_DEBUG */
14911 +#ifdef CONFIG_VSERVER_WARN
14913 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
14914 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
14915 +#define VX_WARN_XID "[xid #%u] "
14916 +#define VX_WARN_NID "[nid #%u] "
14917 +#define VX_WARN_TAG "[tag #%u] "
14919 +#define vxwprintk(c, f, x...) \
14922 + printk(VX_WARNLEVEL f "\n", ##x); \
14925 +#else /* CONFIG_VSERVER_WARN */
14927 +#define vxwprintk(x...) do { } while (0)
14929 +#endif /* CONFIG_VSERVER_WARN */
14931 +#define vxwprintk_task(c, f, x...) \
14932 + vxwprintk(c, VX_WARN_TASK f, \
14933 + current->comm, current->pid, \
14934 + current->xid, current->nid, current->tag, ##x)
14935 +#define vxwprintk_xid(c, f, x...) \
14936 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
14937 +#define vxwprintk_nid(c, f, x...) \
14938 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
14939 +#define vxwprintk_tag(c, f, x...) \
14940 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
14942 +#ifdef CONFIG_VSERVER_DEBUG
14943 +#define vxd_assert_lock(l) assert_spin_locked(l)
14944 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
14945 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
14947 +#define vxd_assert_lock(l) do { } while (0)
14948 +#define vxd_assert(c, f, x...) do { } while (0)
14952 +#endif /* _VX_DEBUG_H */
14953 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/debug_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/debug_cmd.h
14954 --- linux-2.6.22.10/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00 +0100
14955 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/debug_cmd.h 2007-08-05 20:53:13 +0200
14957 +#ifndef _VX_DEBUG_CMD_H
14958 +#define _VX_DEBUG_CMD_H
14961 +/* debug commands */
14963 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
14965 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
14966 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
14968 +struct vcmd_read_history_v0 {
14971 + char __user *data;
14974 +struct vcmd_read_monitor_v0 {
14977 + char __user *data;
14983 +#ifdef CONFIG_COMPAT
14985 +#include <asm/compat.h>
14987 +struct vcmd_read_history_v0_x32 {
14990 + compat_uptr_t data_ptr;
14993 +struct vcmd_read_monitor_v0_x32 {
14996 + compat_uptr_t data_ptr;
14999 +#endif /* CONFIG_COMPAT */
15001 +extern int vc_dump_history(uint32_t);
15003 +extern int vc_read_history(uint32_t, void __user *);
15004 +extern int vc_read_monitor(uint32_t, void __user *);
15006 +#ifdef CONFIG_COMPAT
15008 +extern int vc_read_history_x32(uint32_t, void __user *);
15009 +extern int vc_read_monitor_x32(uint32_t, void __user *);
15011 +#endif /* CONFIG_COMPAT */
15013 +#endif /* __KERNEL__ */
15014 +#endif /* _VX_DEBUG_CMD_H */
15015 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/device.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device.h
15016 --- linux-2.6.22.10/include/linux/vserver/device.h 1970-01-01 01:00:00 +0100
15017 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device.h 2007-10-11 01:10:22 +0200
15019 +#ifndef _VX_DEVICE_H
15020 +#define _VX_DEVICE_H
15023 +#define DATTR_CREATE 0x00000001
15024 +#define DATTR_OPEN 0x00000002
15026 +#define DATTR_REMAP 0x00000010
15028 +#define DATTR_MASK 0x00000013
15031 +#else /* _VX_DEVICE_H */
15032 +#warning duplicate inclusion
15033 +#endif /* _VX_DEVICE_H */
15034 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/device_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device_cmd.h
15035 --- linux-2.6.22.10/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00 +0100
15036 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device_cmd.h 2007-10-11 01:10:22 +0200
15038 +#ifndef _VX_DEVICE_CMD_H
15039 +#define _VX_DEVICE_CMD_H
15042 +/* device vserver commands */
15044 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
15045 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
15047 +struct vcmd_set_mapping_v0 {
15048 + const char __user *device;
15049 + const char __user *target;
15056 +#ifdef CONFIG_COMPAT
15058 +#include <asm/compat.h>
15060 +struct vcmd_set_mapping_v0_x32 {
15061 + compat_uptr_t device_ptr;
15062 + compat_uptr_t target_ptr;
15066 +#endif /* CONFIG_COMPAT */
15068 +#include <linux/compiler.h>
15070 +extern int vc_set_mapping(struct vx_info *, void __user *);
15071 +extern int vc_unset_mapping(struct vx_info *, void __user *);
15073 +#ifdef CONFIG_COMPAT
15075 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
15076 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
15078 +#endif /* CONFIG_COMPAT */
15080 +#endif /* __KERNEL__ */
15081 +#endif /* _VX_DEVICE_CMD_H */
15082 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/device_def.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device_def.h
15083 --- linux-2.6.22.10/include/linux/vserver/device_def.h 1970-01-01 01:00:00 +0100
15084 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device_def.h 2007-10-11 01:10:22 +0200
15086 +#ifndef _VX_DEVICE_DEF_H
15087 +#define _VX_DEVICE_DEF_H
15089 +#include <linux/types.h>
15091 +struct vx_dmap_target {
15096 +struct _vx_device {
15097 +#ifdef CONFIG_VSERVER_DEVICE
15098 + struct vx_dmap_target targets[2];
15102 +#endif /* _VX_DEVICE_DEF_H */
15103 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/dlimit.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/dlimit.h
15104 --- linux-2.6.22.10/include/linux/vserver/dlimit.h 1970-01-01 01:00:00 +0100
15105 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/dlimit.h 2007-08-15 22:03:58 +0200
15107 +#ifndef _VX_DLIMIT_H
15108 +#define _VX_DLIMIT_H
15110 +#include "switch.h"
15115 +/* keep in sync with CDLIM_INFINITY */
15117 +#define DLIM_INFINITY (~0ULL)
15119 +#include <linux/spinlock.h>
15120 +#include <linux/rcupdate.h>
15122 +struct super_block;
15125 + struct hlist_node dl_hlist; /* linked list of contexts */
15126 + struct rcu_head dl_rcu; /* the rcu head */
15127 + tag_t dl_tag; /* context tag */
15128 + atomic_t dl_usecnt; /* usage count */
15129 + atomic_t dl_refcnt; /* reference count */
15131 + struct super_block *dl_sb; /* associated superblock */
15133 + spinlock_t dl_lock; /* protect the values */
15135 + unsigned long long dl_space_used; /* used space in bytes */
15136 + unsigned long long dl_space_total; /* maximum space in bytes */
15137 + unsigned long dl_inodes_used; /* used inodes */
15138 + unsigned long dl_inodes_total; /* maximum inodes */
15140 + unsigned int dl_nrlmult; /* non root limit mult */
15145 +extern void rcu_free_dl_info(struct rcu_head *);
15146 +extern void unhash_dl_info(struct dl_info *);
15148 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
15153 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
15155 +typedef uint64_t dlsize_t;
15157 +#endif /* __KERNEL__ */
15158 +#else /* _VX_DLIMIT_H */
15159 +#warning duplicate inclusion
15160 +#endif /* _VX_DLIMIT_H */
15161 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/dlimit_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/dlimit_cmd.h
15162 --- linux-2.6.22.10/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00 +0100
15163 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/dlimit_cmd.h 2007-08-05 20:53:13 +0200
15165 +#ifndef _VX_DLIMIT_CMD_H
15166 +#define _VX_DLIMIT_CMD_H
15169 +/* dlimit vserver commands */
15171 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
15172 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
15174 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
15175 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
15177 +struct vcmd_ctx_dlimit_base_v0 {
15178 + const char __user *name;
15182 +struct vcmd_ctx_dlimit_v0 {
15183 + const char __user *name;
15184 + uint32_t space_used; /* used space in kbytes */
15185 + uint32_t space_total; /* maximum space in kbytes */
15186 + uint32_t inodes_used; /* used inodes */
15187 + uint32_t inodes_total; /* maximum inodes */
15188 + uint32_t reserved; /* reserved for root in % */
15192 +#define CDLIM_UNSET ((uint32_t)0UL)
15193 +#define CDLIM_INFINITY ((uint32_t)~0UL)
15194 +#define CDLIM_KEEP ((uint32_t)~1UL)
15198 +#ifdef CONFIG_COMPAT
15200 +#include <asm/compat.h>
15202 +struct vcmd_ctx_dlimit_base_v0_x32 {
15203 + compat_uptr_t name_ptr;
15207 +struct vcmd_ctx_dlimit_v0_x32 {
15208 + compat_uptr_t name_ptr;
15209 + uint32_t space_used; /* used space in kbytes */
15210 + uint32_t space_total; /* maximum space in kbytes */
15211 + uint32_t inodes_used; /* used inodes */
15212 + uint32_t inodes_total; /* maximum inodes */
15213 + uint32_t reserved; /* reserved for root in % */
15217 +#endif /* CONFIG_COMPAT */
15219 +#include <linux/compiler.h>
15221 +extern int vc_add_dlimit(uint32_t, void __user *);
15222 +extern int vc_rem_dlimit(uint32_t, void __user *);
15224 +extern int vc_set_dlimit(uint32_t, void __user *);
15225 +extern int vc_get_dlimit(uint32_t, void __user *);
15227 +#ifdef CONFIG_COMPAT
15229 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
15230 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
15232 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
15233 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
15235 +#endif /* CONFIG_COMPAT */
15237 +#endif /* __KERNEL__ */
15238 +#endif /* _VX_DLIMIT_CMD_H */
15239 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/global.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/global.h
15240 --- linux-2.6.22.10/include/linux/vserver/global.h 1970-01-01 01:00:00 +0100
15241 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/global.h 2007-08-05 20:53:13 +0200
15243 +#ifndef _VX_GLOBAL_H
15244 +#define _VX_GLOBAL_H
15247 +extern atomic_t vx_global_ctotal;
15248 +extern atomic_t vx_global_cactive;
15250 +extern atomic_t nx_global_ctotal;
15251 +extern atomic_t nx_global_cactive;
15253 +extern atomic_t vs_global_nsproxy;
15254 +extern atomic_t vs_global_fs;
15255 +extern atomic_t vs_global_mnt_ns;
15256 +extern atomic_t vs_global_uts_ns;
15257 +extern atomic_t vs_global_ipc_ns;
15260 +#endif /* _VX_GLOBAL_H */
15261 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/history.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/history.h
15262 --- linux-2.6.22.10/include/linux/vserver/history.h 1970-01-01 01:00:00 +0100
15263 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/history.h 2007-08-05 20:53:13 +0200
15265 +#ifndef _VX_HISTORY_H
15266 +#define _VX_HISTORY_H
15271 + VXH_THROW_OOPS = 1,
15275 + VXH_INIT_VX_INFO,
15278 + VXH_CLAIM_VX_INFO,
15279 + VXH_RELEASE_VX_INFO,
15280 + VXH_ALLOC_VX_INFO,
15281 + VXH_DEALLOC_VX_INFO,
15282 + VXH_HASH_VX_INFO,
15283 + VXH_UNHASH_VX_INFO,
15285 + VXH_LOOKUP_VX_INFO,
15286 + VXH_CREATE_VX_INFO,
15289 +struct _vxhe_vxi {
15290 + struct vx_info *ptr;
15296 +struct _vxhe_set_clr {
15300 +struct _vxhe_loc_lookup {
15304 +struct _vx_hist_entry {
15306 + unsigned short seq;
15307 + unsigned short type;
15308 + struct _vxhe_vxi vxi;
15310 + struct _vxhe_set_clr sc;
15311 + struct _vxhe_loc_lookup ll;
15315 +#ifdef CONFIG_VSERVER_HISTORY
15317 +extern unsigned volatile int vxh_active;
15319 +struct _vx_hist_entry *vxh_advance(void *loc);
15323 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
15325 + entry->vxi.ptr = vxi;
15327 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
15328 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
15329 + entry->vxi.xid = vxi->vx_id;
15334 +#define __HERE__ current_text_addr()
15336 +#define __VXH_BODY(__type, __data, __here) \
15337 + struct _vx_hist_entry *entry; \
15339 + preempt_disable(); \
15340 + entry = vxh_advance(__here); \
15342 + entry->type = __type; \
15343 + preempt_enable();
15346 + /* pass vxi only */
15348 +#define __VXH_SMPL \
15349 + __vxh_copy_vxi(entry, vxi)
15352 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
15354 + __VXH_BODY(__type, __VXH_SMPL, __here)
15357 + /* pass vxi and data (void *) */
15359 +#define __VXH_DATA \
15360 + __vxh_copy_vxi(entry, vxi); \
15361 + entry->sc.data = data
15364 +void __vxh_data(struct vx_info *vxi, void *data,
15365 + int __type, void *__here)
15367 + __VXH_BODY(__type, __VXH_DATA, __here)
15370 + /* pass vxi and arg (long) */
15372 +#define __VXH_LONG \
15373 + __vxh_copy_vxi(entry, vxi); \
15374 + entry->ll.arg = arg
15377 +void __vxh_long(struct vx_info *vxi, long arg,
15378 + int __type, void *__here)
15380 + __VXH_BODY(__type, __VXH_LONG, __here)
15385 +void __vxh_throw_oops(void *__here)
15387 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
15388 + /* prevent further acquisition */
15393 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
15395 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
15396 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
15398 +#define __vxh_init_vx_info(v, d, h) \
15399 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
15400 +#define __vxh_set_vx_info(v, d, h) \
15401 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
15402 +#define __vxh_clr_vx_info(v, d, h) \
15403 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
15405 +#define __vxh_claim_vx_info(v, d, h) \
15406 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
15407 +#define __vxh_release_vx_info(v, d, h) \
15408 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
15410 +#define vxh_alloc_vx_info(v) \
15411 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
15412 +#define vxh_dealloc_vx_info(v) \
15413 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
15415 +#define vxh_hash_vx_info(v) \
15416 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
15417 +#define vxh_unhash_vx_info(v) \
15418 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
15420 +#define vxh_loc_vx_info(v, l) \
15421 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
15422 +#define vxh_lookup_vx_info(v, l) \
15423 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
15424 +#define vxh_create_vx_info(v, l) \
15425 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
15427 +extern void vxh_dump_history(void);
15430 +#else /* CONFIG_VSERVER_HISTORY */
15432 +#define __HERE__ 0
15434 +#define vxh_throw_oops() do { } while (0)
15436 +#define __vxh_get_vx_info(v, h) do { } while (0)
15437 +#define __vxh_put_vx_info(v, h) do { } while (0)
15439 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
15440 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
15441 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
15443 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
15444 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
15446 +#define vxh_alloc_vx_info(v) do { } while (0)
15447 +#define vxh_dealloc_vx_info(v) do { } while (0)
15449 +#define vxh_hash_vx_info(v) do { } while (0)
15450 +#define vxh_unhash_vx_info(v) do { } while (0)
15452 +#define vxh_loc_vx_info(v, l) do { } while (0)
15453 +#define vxh_lookup_vx_info(v, l) do { } while (0)
15454 +#define vxh_create_vx_info(v, l) do { } while (0)
15456 +#define vxh_dump_history() do { } while (0)
15459 +#endif /* CONFIG_VSERVER_HISTORY */
15461 +#endif /* _VX_HISTORY_H */
15462 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/inode.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/inode.h
15463 --- linux-2.6.22.10/include/linux/vserver/inode.h 1970-01-01 01:00:00 +0100
15464 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/inode.h 2007-08-05 20:53:13 +0200
15466 +#ifndef _VX_INODE_H
15467 +#define _VX_INODE_H
15470 +#define IATTR_TAG 0x01000000
15472 +#define IATTR_ADMIN 0x00000001
15473 +#define IATTR_WATCH 0x00000002
15474 +#define IATTR_HIDE 0x00000004
15475 +#define IATTR_FLAGS 0x00000007
15477 +#define IATTR_BARRIER 0x00010000
15478 +#define IATTR_IUNLINK 0x00020000
15479 +#define IATTR_IMMUTABLE 0x00040000
15484 +#ifdef CONFIG_VSERVER_PROC_SECURE
15485 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
15486 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
15488 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
15489 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
15492 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
15494 +#endif /* __KERNEL__ */
15496 +/* inode ioctls */
15498 +#define FIOC_GETXFLG _IOR('x', 5, long)
15499 +#define FIOC_SETXFLG _IOW('x', 6, long)
15501 +#else /* _VX_INODE_H */
15502 +#warning duplicate inclusion
15503 +#endif /* _VX_INODE_H */
15504 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/inode_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/inode_cmd.h
15505 --- linux-2.6.22.10/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00 +0100
15506 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/inode_cmd.h 2007-08-15 18:08:31 +0200
15508 +#ifndef _VX_INODE_CMD_H
15509 +#define _VX_INODE_CMD_H
15512 +/* inode vserver commands */
15514 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
15515 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
15517 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
15518 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
15520 +struct vcmd_ctx_iattr_v1 {
15521 + const char __user *name;
15527 +struct vcmd_ctx_fiattr_v0 {
15537 +#ifdef CONFIG_COMPAT
15539 +#include <asm/compat.h>
15541 +struct vcmd_ctx_iattr_v1_x32 {
15542 + compat_uptr_t name_ptr;
15548 +#endif /* CONFIG_COMPAT */
15550 +#include <linux/compiler.h>
15552 +extern int vc_get_iattr(void __user *);
15553 +extern int vc_set_iattr(void __user *);
15555 +extern int vc_fget_iattr(uint32_t, void __user *);
15556 +extern int vc_fset_iattr(uint32_t, void __user *);
15558 +#ifdef CONFIG_COMPAT
15560 +extern int vc_get_iattr_x32(void __user *);
15561 +extern int vc_set_iattr_x32(void __user *);
15563 +#endif /* CONFIG_COMPAT */
15565 +#endif /* __KERNEL__ */
15566 +#endif /* _VX_INODE_CMD_H */
15567 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit.h
15568 --- linux-2.6.22.10/include/linux/vserver/limit.h 1970-01-01 01:00:00 +0100
15569 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit.h 2007-08-15 22:27:29 +0200
15571 +#ifndef _VX_LIMIT_H
15572 +#define _VX_LIMIT_H
15574 +#define VLIMIT_NSOCK 16
15575 +#define VLIMIT_OPENFD 17
15576 +#define VLIMIT_ANON 18
15577 +#define VLIMIT_SHMEM 19
15578 +#define VLIMIT_SEMARY 20
15579 +#define VLIMIT_NSEMS 21
15580 +#define VLIMIT_DENTRY 22
15581 +#define VLIMIT_MAPPED 23
15586 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
15588 +/* keep in sync with CRLIM_INFINITY */
15590 +#define VLIM_INFINITY (~0ULL)
15592 +#include <asm/atomic.h>
15593 +#include <asm/resource.h>
15595 +#ifndef RLIM_INFINITY
15596 +#warning RLIM_INFINITY is undefined
15599 +#define __rlim_val(l, r, v) ((l)->res[r].v)
15601 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
15602 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
15604 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
15605 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
15606 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
15608 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
15609 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
15611 +typedef atomic_long_t rlim_atomic_t;
15612 +typedef unsigned long rlim_t;
15614 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
15615 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
15616 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
15617 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
15618 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
15619 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
15622 +#if (RLIM_INFINITY == VLIM_INFINITY)
15623 +#define VX_VLIM(r) ((long long)(long)(r))
15624 +#define VX_RLIM(v) ((rlim_t)(v))
15626 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
15627 + ? VLIM_INFINITY : (long long)(r))
15628 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
15629 + ? RLIM_INFINITY : (rlim_t)(v))
15634 +void vx_vsi_meminfo(struct sysinfo *);
15635 +void vx_vsi_swapinfo(struct sysinfo *);
15637 +#define NUM_LIMITS 24
15639 +#endif /* __KERNEL__ */
15640 +#endif /* _VX_LIMIT_H */
15641 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_cmd.h
15642 --- linux-2.6.22.10/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00 +0100
15643 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_cmd.h 2007-08-05 20:53:13 +0200
15645 +#ifndef _VX_LIMIT_CMD_H
15646 +#define _VX_LIMIT_CMD_H
15649 +/* rlimit vserver commands */
15651 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
15652 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
15653 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
15654 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
15656 +struct vcmd_ctx_rlimit_v0 {
15658 + uint64_t minimum;
15659 + uint64_t softlimit;
15660 + uint64_t maximum;
15663 +struct vcmd_ctx_rlimit_mask_v0 {
15664 + uint32_t minimum;
15665 + uint32_t softlimit;
15666 + uint32_t maximum;
15669 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
15671 +struct vcmd_rlimit_stat_v0 {
15675 + uint64_t minimum;
15676 + uint64_t maximum;
15679 +#define CRLIM_UNSET (0ULL)
15680 +#define CRLIM_INFINITY (~0ULL)
15681 +#define CRLIM_KEEP (~1ULL)
15685 +#ifdef CONFIG_IA32_EMULATION
15687 +struct vcmd_ctx_rlimit_v0_x32 {
15689 + uint64_t minimum;
15690 + uint64_t softlimit;
15691 + uint64_t maximum;
15692 +} __attribute__ ((aligned (4)));
15694 +#endif /* CONFIG_IA32_EMULATION */
15696 +#include <linux/compiler.h>
15698 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
15699 +extern int vc_get_rlimit(struct vx_info *, void __user *);
15700 +extern int vc_set_rlimit(struct vx_info *, void __user *);
15701 +extern int vc_reset_minmax(struct vx_info *, void __user *);
15703 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
15705 +#ifdef CONFIG_IA32_EMULATION
15707 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
15708 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
15710 +#endif /* CONFIG_IA32_EMULATION */
15712 +#endif /* __KERNEL__ */
15713 +#endif /* _VX_LIMIT_CMD_H */
15714 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit_def.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_def.h
15715 --- linux-2.6.22.10/include/linux/vserver/limit_def.h 1970-01-01 01:00:00 +0100
15716 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_def.h 2007-08-05 20:53:13 +0200
15718 +#ifndef _VX_LIMIT_DEF_H
15719 +#define _VX_LIMIT_DEF_H
15721 +#include <asm/atomic.h>
15722 +#include <asm/resource.h>
15724 +#include "limit.h"
15727 +struct _vx_res_limit {
15728 + rlim_t soft; /* Context soft limit */
15729 + rlim_t hard; /* Context hard limit */
15731 + rlim_atomic_t rcur; /* Current value */
15732 + rlim_t rmin; /* Context minimum */
15733 + rlim_t rmax; /* Context maximum */
15735 + atomic_t lhit; /* Limit hits */
15738 +/* context sub struct */
15740 +struct _vx_limit {
15741 + struct _vx_res_limit res[NUM_LIMITS];
15744 +#ifdef CONFIG_VSERVER_DEBUG
15746 +static inline void __dump_vx_limit(struct _vx_limit *limit)
15750 + printk("\t_vx_limit:");
15751 + for (i = 0; i < NUM_LIMITS; i++) {
15752 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
15753 + i, (unsigned long)__rlim_get(limit, i),
15754 + (unsigned long)__rlim_rmin(limit, i),
15755 + (unsigned long)__rlim_rmax(limit, i),
15756 + (long)__rlim_soft(limit, i),
15757 + (long)__rlim_hard(limit, i),
15758 + atomic_read(&__rlim_lhit(limit, i)));
15764 +#endif /* _VX_LIMIT_DEF_H */
15765 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/limit_int.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_int.h
15766 --- linux-2.6.22.10/include/linux/vserver/limit_int.h 1970-01-01 01:00:00 +0100
15767 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_int.h 2007-08-05 20:53:13 +0200
15769 +#ifndef _VX_LIMIT_INT_H
15770 +#define _VX_LIMIT_INT_H
15772 +#include "context.h"
15776 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
15777 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
15779 +extern const char *vlimit_name[NUM_LIMITS];
15781 +static inline void __vx_acc_cres(struct vx_info *vxi,
15782 + int res, int dir, void *_data, char *_file, int _line)
15784 + if (VXD_RCRES_COND(res))
15785 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
15786 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
15787 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
15788 + (dir > 0) ? "++" : "--", _data, _file, _line);
15793 + __rlim_inc(&vxi->limit, res);
15795 + __rlim_dec(&vxi->limit, res);
15798 +static inline void __vx_add_cres(struct vx_info *vxi,
15799 + int res, int amount, void *_data, char *_file, int _line)
15801 + if (VXD_RCRES_COND(res))
15802 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
15803 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
15804 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
15805 + amount, _data, _file, _line);
15810 + __rlim_add(&vxi->limit, res, amount);
15814 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
15816 + int cond = (value > __rlim_rmax(limit, res));
15819 + __rlim_rmax(limit, res) = value;
15824 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
15826 + int cond = (value < __rlim_rmin(limit, res));
15829 + __rlim_rmin(limit, res) = value;
15834 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
15836 + if (!__vx_cres_adjust_max(limit, res, value))
15837 + __vx_cres_adjust_min(limit, res, value);
15842 + +1 ... no limit hit
15843 + -1 ... over soft limit
15844 + 0 ... over hard limit */
15846 +static inline int __vx_cres_avail(struct vx_info *vxi,
15847 + int res, int num, char *_file, int _line)
15849 + struct _vx_limit *limit;
15852 + if (VXD_RLIMIT_COND(res))
15853 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
15854 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
15855 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
15856 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
15857 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
15858 + num, _file, _line);
15862 + limit = &vxi->limit;
15863 + value = __rlim_get(limit, res);
15865 + if (!__vx_cres_adjust_max(limit, res, value))
15866 + __vx_cres_adjust_min(limit, res, value);
15871 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
15873 + if (value + num <= __rlim_soft(limit, res))
15876 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
15878 + if (value + num <= __rlim_hard(limit, res))
15881 + __rlim_hit(limit, res);
15886 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
15889 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
15891 + rlim_t value, sum = 0;
15894 + while ((res = *array++)) {
15895 + value = __rlim_get(limit, res);
15896 + __vx_cres_fixup(limit, res, value);
15903 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
15905 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
15906 + int res = *array;
15908 + if (value == __rlim_get(limit, res))
15911 + __rlim_set(limit, res, value);
15912 + /* now adjust min/max */
15913 + if (!__vx_cres_adjust_max(limit, res, value))
15914 + __vx_cres_adjust_min(limit, res, value);
15919 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
15920 + const int *array, int num, char *_file, int _line)
15922 + struct _vx_limit *limit;
15923 + rlim_t value = 0;
15931 + limit = &vxi->limit;
15933 + value = __vx_cres_array_sum(limit, array + 1);
15935 + __rlim_set(limit, res, value);
15936 + __vx_cres_fixup(limit, res, value);
15938 + return __vx_cres_avail(vxi, res, num, _file, _line);
15942 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
15947 + /* complex resources first */
15948 + if ((id < 0) || (id == RLIMIT_RSS))
15949 + __vx_cres_array_fixup(limit, VLA_RSS);
15951 + for (res = 0; res < NUM_LIMITS; res++) {
15952 + if ((id > 0) && (res != id))
15955 + value = __rlim_get(limit, res);
15956 + __vx_cres_fixup(limit, res, value);
15958 + /* not supposed to happen, maybe warn? */
15959 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
15960 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
15965 +#endif /* __KERNEL__ */
15966 +#endif /* _VX_LIMIT_INT_H */
15967 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/monitor.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/monitor.h
15968 --- linux-2.6.22.10/include/linux/vserver/monitor.h 1970-01-01 01:00:00 +0100
15969 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/monitor.h 2007-08-15 23:16:12 +0200
15971 +#ifndef _VX_MONITOR_H
15972 +#define _VX_MONITOR_H
15974 +#include <linux/types.h>
15981 + VXM_UPDATE = 0x20,
15985 + VXM_RQINFO_1 = 0x24,
15988 + VXM_ACTIVATE = 0x40,
15995 + VXM_MIGRATE = 0x48,
15998 + /* all other bits are flags */
15999 + VXM_SCHED = 0x80,
16002 +struct _vxm_update_1 {
16003 + uint32_t tokens_max;
16004 + uint32_t fill_rate;
16005 + uint32_t interval;
16008 +struct _vxm_update_2 {
16009 + uint32_t tokens_min;
16010 + uint32_t fill_rate;
16011 + uint32_t interval;
16014 +struct _vxm_rqinfo_1 {
16015 + uint16_t running;
16019 + uint32_t idle_tokens;
16022 +struct _vxm_rqinfo_2 {
16023 + uint32_t norm_time;
16024 + uint32_t idle_time;
16025 + uint32_t idle_skip;
16028 +struct _vxm_sched {
16030 + uint32_t norm_time;
16031 + uint32_t idle_time;
16034 +struct _vxm_task {
16039 +struct _vxm_event {
16048 + struct _vxm_task tsk;
16052 +struct _vx_mon_entry {
16056 + struct _vxm_event ev;
16057 + struct _vxm_sched sd;
16058 + struct _vxm_update_1 u1;
16059 + struct _vxm_update_2 u2;
16060 + struct _vxm_rqinfo_1 q1;
16061 + struct _vxm_rqinfo_2 q2;
16066 +#endif /* _VX_MONITOR_H */
16067 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/network.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/network.h
16068 --- linux-2.6.22.10/include/linux/vserver/network.h 1970-01-01 01:00:00 +0100
16069 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/network.h 2007-10-05 12:29:05 +0200
16071 +#ifndef _VX_NETWORK_H
16072 +#define _VX_NETWORK_H
16074 +#include <linux/types.h>
16077 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
16080 +/* network flags */
16082 +#define NXF_INFO_PRIVATE 0x00000008
16084 +#define NXF_SINGLE_IP 0x00000100
16085 +#define NXF_LBACK_REMAP 0x00000200
16087 +#define NXF_HIDE_NETIF 0x02000000
16088 +#define NXF_HIDE_LBACK 0x04000000
16090 +#define NXF_STATE_SETUP (1ULL << 32)
16091 +#define NXF_STATE_ADMIN (1ULL << 34)
16093 +#define NXF_SC_HELPER (1ULL << 36)
16094 +#define NXF_PERSISTENT (1ULL << 38)
16096 +#define NXF_ONE_TIME (0x0005ULL << 32)
16099 +#define NXF_INIT_SET (__nxf_init_set())
16101 +static inline uint64_t __nxf_init_set(void) {
16102 + return NXF_STATE_ADMIN
16103 +#ifdef CONFIG_VSERVER_AUTO_LBACK
16104 + | NXF_LBACK_REMAP
16107 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
16110 + | NXF_HIDE_NETIF;
16114 +/* network caps */
16116 +#define NXC_RAW_ICMP 0x00000100
16119 +/* address types */
16121 +#define NXA_TYPE_IPV4 0x0001
16122 +#define NXA_TYPE_IPV6 0x0002
16124 +#define NXA_TYPE_NONE 0x0000
16125 +#define NXA_TYPE_ANY 0x00FF
16127 +#define NXA_TYPE_ADDR 0x0010
16128 +#define NXA_TYPE_MASK 0x0020
16129 +#define NXA_TYPE_RANGE 0x0040
16131 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
16133 +#define NXA_MOD_BCAST 0x0100
16134 +#define NXA_MOD_LBACK 0x0200
16136 +#define NXA_LOOPBACK 0x1000
16138 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
16139 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
16143 +#include <linux/list.h>
16144 +#include <linux/spinlock.h>
16145 +#include <linux/rcupdate.h>
16146 +#include <linux/in.h>
16147 +#include <linux/in6.h>
16148 +#include <asm/atomic.h>
16150 +struct nx_addr_v4 {
16151 + struct nx_addr_v4 *next;
16152 + struct in_addr ip[2];
16153 + struct in_addr mask;
16158 +struct nx_addr_v6 {
16159 + struct nx_addr_v6 *next;
16160 + struct in6_addr ip;
16161 + struct in6_addr mask;
16168 + struct hlist_node nx_hlist; /* linked list of nxinfos */
16169 + nid_t nx_id; /* vnet id */
16170 + atomic_t nx_usecnt; /* usage count */
16171 + atomic_t nx_tasks; /* tasks count */
16172 + int nx_state; /* context state */
16174 + uint64_t nx_flags; /* network flag word */
16175 + uint64_t nx_ncaps; /* network capabilities */
16177 + struct in_addr v4_lback; /* Loopback address */
16178 + struct in_addr v4_bcast; /* Broadcast address */
16179 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
16180 +#ifdef CONFIG_IPV6
16181 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
16183 + char nx_name[65]; /* network context name */
16187 +/* status flags */
16189 +#define NXS_HASHED 0x0001
16190 +#define NXS_SHUTDOWN 0x0100
16191 +#define NXS_RELEASED 0x8000
16193 +extern struct nx_info *lookup_nx_info(int);
16195 +extern int get_nid_list(int, unsigned int *, int);
16196 +extern int nid_is_hashed(nid_t);
16198 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
16200 +extern long vs_net_change(struct nx_info *, unsigned int);
16205 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
16206 +#ifdef CONFIG_IPV6
16207 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
16209 +#define NX_IPV6(n) (0)
16212 +#endif /* __KERNEL__ */
16213 +#endif /* _VX_NETWORK_H */
16214 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/network_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/network_cmd.h
16215 --- linux-2.6.22.10/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00 +0100
16216 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/network_cmd.h 2007-08-15 20:08:10 +0200
16218 +#ifndef _VX_NETWORK_CMD_H
16219 +#define _VX_NETWORK_CMD_H
16222 +/* vinfo commands */
16224 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
16227 +extern int vc_task_nid(uint32_t);
16229 +#endif /* __KERNEL__ */
16231 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
16233 +struct vcmd_nx_info_v0 {
16235 + /* more to come */
16239 +extern int vc_nx_info(struct nx_info *, void __user *);
16241 +#endif /* __KERNEL__ */
16243 +#include <linux/in.h>
16244 +#include <linux/in6.h>
16246 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
16247 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
16249 +struct vcmd_net_create {
16250 + uint64_t flagword;
16253 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
16255 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
16256 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
16258 +struct vcmd_net_addr_v0 {
16261 + struct in_addr ip[4];
16262 + struct in_addr mask[4];
16265 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
16266 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
16268 +struct vcmd_net_addr_ipv4_v1 {
16271 + struct in_addr ip;
16272 + struct in_addr mask;
16275 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
16276 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
16278 +struct vcmd_net_addr_ipv6_v1 {
16282 + struct in6_addr ip;
16283 + struct in6_addr mask;
16286 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
16287 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
16289 +struct vcmd_match_ipv4_v0 {
16294 + struct in_addr ip;
16295 + struct in_addr ip2;
16296 + struct in_addr mask;
16299 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
16300 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
16302 +struct vcmd_match_ipv6_v0 {
16307 + struct in6_addr ip;
16308 + struct in6_addr ip2;
16309 + struct in6_addr mask;
16314 +extern int vc_net_create(uint32_t, void __user *);
16315 +extern int vc_net_migrate(struct nx_info *, void __user *);
16317 +extern int vc_net_add(struct nx_info *, void __user *);
16318 +extern int vc_net_remove(struct nx_info *, void __user *);
16320 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
16321 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
16323 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
16324 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
16326 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
16327 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
16329 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
16330 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
16332 +#endif /* __KERNEL__ */
16335 +/* flag commands */
16337 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
16338 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
16340 +struct vcmd_net_flags_v0 {
16341 + uint64_t flagword;
16346 +extern int vc_get_nflags(struct nx_info *, void __user *);
16347 +extern int vc_set_nflags(struct nx_info *, void __user *);
16349 +#endif /* __KERNEL__ */
16352 +/* network caps commands */
16354 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
16355 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
16357 +struct vcmd_net_caps_v0 {
16363 +extern int vc_get_ncaps(struct nx_info *, void __user *);
16364 +extern int vc_set_ncaps(struct nx_info *, void __user *);
16366 +#endif /* __KERNEL__ */
16367 +#endif /* _VX_CONTEXT_CMD_H */
16368 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/percpu.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/percpu.h
16369 --- linux-2.6.22.10/include/linux/vserver/percpu.h 1970-01-01 01:00:00 +0100
16370 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/percpu.h 2007-08-05 20:53:13 +0200
16372 +#ifndef _VX_PERCPU_H
16373 +#define _VX_PERCPU_H
16375 +#include "cvirt_def.h"
16376 +#include "sched_def.h"
16378 +struct _vx_percpu {
16379 + struct _vx_cvirt_pc cvirt;
16380 + struct _vx_sched_pc sched;
16383 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
16385 +#endif /* _VX_PERCPU_H */
16386 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/sched.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched.h
16387 --- linux-2.6.22.10/include/linux/vserver/sched.h 1970-01-01 01:00:00 +0100
16388 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched.h 2007-08-05 20:53:13 +0200
16390 +#ifndef _VX_SCHED_H
16391 +#define _VX_SCHED_H
16398 +void vx_vsi_uptime(struct timespec *, struct timespec *);
16403 +void vx_update_load(struct vx_info *);
16406 +int vx_tokens_recalc(struct _vx_sched_pc *,
16407 + unsigned long *, unsigned long *, int [2]);
16409 +void vx_update_sched_param(struct _vx_sched *sched,
16410 + struct _vx_sched_pc *sched_pc);
16412 +#endif /* __KERNEL__ */
16413 +#else /* _VX_SCHED_H */
16414 +#warning duplicate inclusion
16415 +#endif /* _VX_SCHED_H */
16416 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/sched_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched_cmd.h
16417 --- linux-2.6.22.10/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00 +0100
16418 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched_cmd.h 2007-08-05 20:53:13 +0200
16420 +#ifndef _VX_SCHED_CMD_H
16421 +#define _VX_SCHED_CMD_H
16424 +/* sched vserver commands */
16426 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
16427 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
16428 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
16430 +struct vcmd_set_sched_v2 {
16431 + int32_t fill_rate;
16432 + int32_t interval;
16434 + int32_t tokens_min;
16435 + int32_t tokens_max;
16436 + uint64_t cpu_mask;
16439 +struct vcmd_set_sched_v3 {
16440 + uint32_t set_mask;
16441 + int32_t fill_rate;
16442 + int32_t interval;
16444 + int32_t tokens_min;
16445 + int32_t tokens_max;
16446 + int32_t priority_bias;
16449 +struct vcmd_set_sched_v4 {
16450 + uint32_t set_mask;
16451 + int32_t fill_rate;
16452 + int32_t interval;
16454 + int32_t tokens_min;
16455 + int32_t tokens_max;
16456 + int32_t prio_bias;
16458 + int32_t bucket_id;
16461 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
16462 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
16464 +struct vcmd_sched_v5 {
16467 + int32_t bucket_id;
16468 + int32_t fill_rate[2];
16469 + int32_t interval[2];
16471 + int32_t tokens_min;
16472 + int32_t tokens_max;
16473 + int32_t prio_bias;
16476 +#define VXSM_FILL_RATE 0x0001
16477 +#define VXSM_INTERVAL 0x0002
16478 +#define VXSM_FILL_RATE2 0x0004
16479 +#define VXSM_INTERVAL2 0x0008
16480 +#define VXSM_TOKENS 0x0010
16481 +#define VXSM_TOKENS_MIN 0x0020
16482 +#define VXSM_TOKENS_MAX 0x0040
16483 +#define VXSM_PRIO_BIAS 0x0100
16485 +#define VXSM_IDLE_TIME 0x0200
16486 +#define VXSM_FORCE 0x0400
16488 +#define VXSM_V3_MASK 0x0173
16489 +#define VXSM_SET_MASK 0x01FF
16491 +#define VXSM_CPU_ID 0x1000
16492 +#define VXSM_BUCKET_ID 0x2000
16494 +#define VXSM_MSEC 0x4000
16496 +#define SCHED_KEEP (-2) /* only for v2 */
16500 +#include <linux/compiler.h>
16502 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
16503 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
16504 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
16505 +extern int vc_set_sched(struct vx_info *, void __user *);
16506 +extern int vc_get_sched(struct vx_info *, void __user *);
16508 +#endif /* __KERNEL__ */
16510 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
16512 +struct vcmd_sched_info {
16514 + int32_t bucket_id;
16515 + uint64_t user_msec;
16516 + uint64_t sys_msec;
16517 + uint64_t hold_msec;
16518 + uint32_t token_usec;
16519 + int32_t vavavoom;
16524 +extern int vc_sched_info(struct vx_info *, void __user *);
16526 +#endif /* __KERNEL__ */
16527 +#endif /* _VX_SCHED_CMD_H */
16528 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/sched_def.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched_def.h
16529 --- linux-2.6.22.10/include/linux/vserver/sched_def.h 1970-01-01 01:00:00 +0100
16530 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched_def.h 2007-08-05 20:53:13 +0200
16532 +#ifndef _VX_SCHED_DEF_H
16533 +#define _VX_SCHED_DEF_H
16535 +#include <linux/spinlock.h>
16536 +#include <linux/jiffies.h>
16537 +#include <linux/cpumask.h>
16538 +#include <asm/atomic.h>
16539 +#include <asm/param.h>
16542 +/* context sub struct */
16544 +struct _vx_sched {
16545 + spinlock_t tokens_lock; /* lock for token bucket */
16547 + int tokens; /* number of CPU tokens */
16548 + int fill_rate[2]; /* Fill rate: add X tokens... */
16549 + int interval[2]; /* Divisor: per Y jiffies */
16550 + int tokens_min; /* Limit: minimum for unhold */
16551 + int tokens_max; /* Limit: no more than N tokens */
16553 + int prio_bias; /* bias offset for priority */
16555 + unsigned update_mask; /* which features should be updated */
16556 + cpumask_t update; /* CPUs which should update */
16559 +struct _vx_sched_pc {
16560 + int tokens; /* number of CPU tokens */
16561 + int flags; /* bucket flags */
16563 + int fill_rate[2]; /* Fill rate: add X tokens... */
16564 + int interval[2]; /* Divisor: per Y jiffies */
16565 + int tokens_min; /* Limit: minimum for unhold */
16566 + int tokens_max; /* Limit: no more than N tokens */
16568 + int prio_bias; /* bias offset for priority */
16569 + int vavavoom; /* last calculated vavavoom */
16571 + unsigned long norm_time; /* last time accounted */
16572 + unsigned long idle_time; /* non linear time for fair sched */
16573 + unsigned long token_time; /* token time for accounting */
16574 + unsigned long onhold; /* jiffies when put on hold */
16576 + uint64_t user_ticks; /* token tick events */
16577 + uint64_t sys_ticks; /* token tick events */
16578 + uint64_t hold_ticks; /* token ticks paused */
16582 +#define VXSF_ONHOLD 0x0001
16583 +#define VXSF_IDLE_TIME 0x0100
16585 +#ifdef CONFIG_VSERVER_DEBUG
16587 +static inline void __dump_vx_sched(struct _vx_sched *sched)
16589 + printk("\t_vx_sched:\n");
16590 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
16591 + sched->fill_rate[0], sched->interval[0],
16592 + sched->fill_rate[1], sched->interval[1],
16593 + sched->tokens_min, sched->tokens_max);
16594 + printk("\t priority = %4d\n", sched->prio_bias);
16599 +#endif /* _VX_SCHED_DEF_H */
16600 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/signal.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/signal.h
16601 --- linux-2.6.22.10/include/linux/vserver/signal.h 1970-01-01 01:00:00 +0100
16602 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/signal.h 2007-08-05 20:53:13 +0200
16604 +#ifndef _VX_SIGNAL_H
16605 +#define _VX_SIGNAL_H
16612 +int vx_info_kill(struct vx_info *, int, int);
16614 +#endif /* __KERNEL__ */
16615 +#else /* _VX_SIGNAL_H */
16616 +#warning duplicate inclusion
16617 +#endif /* _VX_SIGNAL_H */
16618 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/signal_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/signal_cmd.h
16619 --- linux-2.6.22.10/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00 +0100
16620 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/signal_cmd.h 2007-08-05 20:53:13 +0200
16622 +#ifndef _VX_SIGNAL_CMD_H
16623 +#define _VX_SIGNAL_CMD_H
16626 +/* signalling vserver commands */
16628 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
16629 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
16631 +struct vcmd_ctx_kill_v0 {
16636 +struct vcmd_wait_exit_v0 {
16637 + int32_t reboot_cmd;
16638 + int32_t exit_code;
16643 +extern int vc_ctx_kill(struct vx_info *, void __user *);
16644 +extern int vc_wait_exit(struct vx_info *, void __user *);
16646 +#endif /* __KERNEL__ */
16648 +/* process alteration commands */
16650 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
16651 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
16653 +struct vcmd_pflags_v0 {
16654 + uint32_t flagword;
16660 +extern int vc_get_pflags(uint32_t pid, void __user *);
16661 +extern int vc_set_pflags(uint32_t pid, void __user *);
16663 +#endif /* __KERNEL__ */
16664 +#endif /* _VX_SIGNAL_CMD_H */
16665 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/space.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/space.h
16666 --- linux-2.6.22.10/include/linux/vserver/space.h 1970-01-01 01:00:00 +0100
16667 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/space.h 2007-08-05 20:53:13 +0200
16669 +#ifndef _VX_SPACE_H
16670 +#define _VX_SPACE_H
16673 +#include <linux/types.h>
16677 +int vx_set_space(struct vx_info *vxi, unsigned long mask);
16679 +#else /* _VX_SPACE_H */
16680 +#warning duplicate inclusion
16681 +#endif /* _VX_SPACE_H */
16682 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/space_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/space_cmd.h
16683 --- linux-2.6.22.10/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00 +0100
16684 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/space_cmd.h 2007-08-05 20:53:13 +0200
16686 +#ifndef _VX_SPACE_CMD_H
16687 +#define _VX_SPACE_CMD_H
16690 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
16691 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 1)
16693 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
16694 +#define VCMD_set_space VC_CMD(PROCALT, 3, 1)
16696 +#define VCMD_get_space_mask VC_CMD(PROCALT, 4, 0)
16699 +struct vcmd_space_mask {
16706 +extern int vc_enter_space(struct vx_info *, void __user *);
16707 +extern int vc_set_space(struct vx_info *, void __user *);
16708 +extern int vc_get_space_mask(struct vx_info *, void __user *);
16710 +#endif /* __KERNEL__ */
16711 +#endif /* _VX_SPACE_CMD_H */
16712 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/switch.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/switch.h
16713 --- linux-2.6.22.10/include/linux/vserver/switch.h 1970-01-01 01:00:00 +0100
16714 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/switch.h 2007-10-11 01:10:22 +0200
16716 +#ifndef _VX_SWITCH_H
16717 +#define _VX_SWITCH_H
16719 +#include <linux/types.h>
16722 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
16723 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
16724 +#define VC_VERSION(c) ((c) & 0xFFF)
16726 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
16727 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
16731 + Syscall Matrix V2.8
16733 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
16734 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
16735 + |INFO |SETUP | |MOVE | | | | | |
16736 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16737 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
16738 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
16739 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16740 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
16741 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
16742 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16743 + MEMORY | | | | |MEMCTRL| | |SWAP | |
16744 + | 16| 17| 18| 19| 20| 21| | 22| 23|
16745 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16746 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
16747 + | 24| 25| 26| 27| 28| 29| | 30| 31|
16748 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16749 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
16750 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
16751 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16752 + OTHER |VSTAT | | | | | | |VINFO | |
16753 + | 40| 41| 42| 43| 44| 45| | 46| 47|
16754 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
16755 + SPECIAL|EVENT | | | |FLAGS | | | | |
16756 + | 48| 49| 50| 51| 52| 53| | 54| 55|
16757 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16758 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
16759 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
16760 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16764 +#define VC_CAT_VERSION 0
16766 +#define VC_CAT_VSETUP 1
16767 +#define VC_CAT_VHOST 2
16769 +#define VC_CAT_DEVICE 6
16771 +#define VC_CAT_VPROC 9
16772 +#define VC_CAT_PROCALT 10
16773 +#define VC_CAT_PROCMIG 11
16774 +#define VC_CAT_PROCTRL 12
16776 +#define VC_CAT_SCHED 14
16777 +#define VC_CAT_MEMCTRL 20
16779 +#define VC_CAT_VNET 25
16780 +#define VC_CAT_NETALT 26
16781 +#define VC_CAT_NETMIG 27
16782 +#define VC_CAT_NETCTRL 28
16784 +#define VC_CAT_TAGMIG 35
16785 +#define VC_CAT_DLIMIT 36
16786 +#define VC_CAT_INODE 38
16788 +#define VC_CAT_VSTAT 40
16789 +#define VC_CAT_VINFO 46
16790 +#define VC_CAT_EVENT 48
16792 +#define VC_CAT_FLAGS 52
16793 +#define VC_CAT_DEBUG 56
16794 +#define VC_CAT_RLIMIT 60
16796 +#define VC_CAT_SYSTEST 61
16797 +#define VC_CAT_COMPAT 63
16799 +/* query version */
16801 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
16802 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
16807 +#include <linux/errno.h>
16810 +#else /* __KERNEL__ */
16812 +#endif /* __KERNEL__ */
16814 +#endif /* _VX_SWITCH_H */
16815 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/tag.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/tag.h
16816 --- linux-2.6.22.10/include/linux/vserver/tag.h 1970-01-01 01:00:00 +0100
16817 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/tag.h 2007-10-10 19:05:04 +0200
16822 +#include <linux/types.h>
16825 +#define DX_TAG(in) (IS_TAGGED(in))
16828 +#ifdef CONFIG_DX_TAG_NFSD
16829 +#define DX_TAG_NFSD 1
16831 +#define DX_TAG_NFSD 0
16835 +#ifdef CONFIG_TAGGING_NONE
16837 +#define MAX_UID 0xFFFFFFFF
16838 +#define MAX_GID 0xFFFFFFFF
16840 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
16842 +#define TAGINO_UID(cond, uid, tag) (uid)
16843 +#define TAGINO_GID(cond, gid, tag) (gid)
16848 +#ifdef CONFIG_TAGGING_GID16
16850 +#define MAX_UID 0xFFFFFFFF
16851 +#define MAX_GID 0x0000FFFF
16853 +#define INOTAG_TAG(cond, uid, gid, tag) \
16854 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
16856 +#define TAGINO_UID(cond, uid, tag) (uid)
16857 +#define TAGINO_GID(cond, gid, tag) \
16858 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
16863 +#ifdef CONFIG_TAGGING_ID24
16865 +#define MAX_UID 0x00FFFFFF
16866 +#define MAX_GID 0x00FFFFFF
16868 +#define INOTAG_TAG(cond, uid, gid, tag) \
16869 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
16871 +#define TAGINO_UID(cond, uid, tag) \
16872 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
16873 +#define TAGINO_GID(cond, gid, tag) \
16874 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
16879 +#ifdef CONFIG_TAGGING_UID16
16881 +#define MAX_UID 0x0000FFFF
16882 +#define MAX_GID 0xFFFFFFFF
16884 +#define INOTAG_TAG(cond, uid, gid, tag) \
16885 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
16887 +#define TAGINO_UID(cond, uid, tag) \
16888 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
16889 +#define TAGINO_GID(cond, gid, tag) (gid)
16894 +#ifdef CONFIG_TAGGING_INTERN
16896 +#define MAX_UID 0xFFFFFFFF
16897 +#define MAX_GID 0xFFFFFFFF
16899 +#define INOTAG_TAG(cond, uid, gid, tag) \
16900 + ((cond) ? (tag) : 0)
16902 +#define TAGINO_UID(cond, uid, tag) (uid)
16903 +#define TAGINO_GID(cond, gid, tag) (gid)
16908 +#ifndef CONFIG_TAGGING_NONE
16909 +#define dx_current_fstag(sb) \
16910 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
16912 +#define dx_current_fstag(sb) (0)
16915 +#ifndef CONFIG_TAGGING_INTERN
16916 +#define TAGINO_TAG(cond, tag) (0)
16918 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
16921 +#define INOTAG_UID(cond, uid, gid) \
16922 + ((cond) ? ((uid) & MAX_UID) : (uid))
16923 +#define INOTAG_GID(cond, uid, gid) \
16924 + ((cond) ? ((gid) & MAX_GID) : (gid))
16927 +static inline uid_t dx_map_uid(uid_t uid)
16929 + if ((uid > MAX_UID) && (uid != -1))
16931 + return (uid & MAX_UID);
16934 +static inline gid_t dx_map_gid(gid_t gid)
16936 + if ((gid > MAX_GID) && (gid != -1))
16938 + return (gid & MAX_GID);
16946 +#define dx_notagcheck(nd) \
16947 + ((nd) && (nd)->mnt && ((nd)->mnt->mnt_flags & MNT_NOTAGCHECK))
16949 +int dx_parse_tag(char *string, tag_t *tag, int remove);
16951 +#ifdef CONFIG_PROPAGATE
16953 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
16955 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
16958 +#define dx_propagate_tag(n, i) do { } while (0)
16961 +#endif /* _DX_TAG_H */
16962 diff -NurpP --minimal linux-2.6.22.10/include/linux/vserver/tag_cmd.h linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/tag_cmd.h
16963 --- linux-2.6.22.10/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00 +0100
16964 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/tag_cmd.h 2007-08-15 20:16:43 +0200
16966 +#ifndef _VX_TAG_CMD_H
16967 +#define _VX_TAG_CMD_H
16970 +/* vinfo commands */
16972 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
16975 +extern int vc_task_tag(uint32_t);
16977 +#endif /* __KERNEL__ */
16979 +/* context commands */
16981 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
16984 +extern int vc_tag_migrate(uint32_t);
16986 +#endif /* __KERNEL__ */
16987 +#endif /* _VX_TAG_CMD_H */
16988 diff -NurpP --minimal linux-2.6.22.10/include/net/addrconf.h linux-2.6.22.10-vs2.3.0.29/include/net/addrconf.h
16989 --- linux-2.6.22.10/include/net/addrconf.h 2007-07-09 13:20:01 +0200
16990 +++ linux-2.6.22.10-vs2.3.0.29/include/net/addrconf.h 2007-08-12 00:22:19 +0200
16991 @@ -69,10 +69,12 @@ extern struct inet6_ifaddr * ipv6_get_if
16993 extern int ipv6_get_saddr(struct dst_entry *dst,
16994 struct in6_addr *daddr,
16995 - struct in6_addr *saddr);
16996 + struct in6_addr *saddr,
16997 + struct nx_info *nxi);
16998 extern int ipv6_dev_get_saddr(struct net_device *dev,
16999 struct in6_addr *daddr,
17000 - struct in6_addr *saddr);
17001 + struct in6_addr *saddr,
17002 + struct nx_info *nxi);
17003 extern int ipv6_get_lladdr(struct net_device *dev,
17004 struct in6_addr *addr,
17005 unsigned char banned_flags);
17006 diff -NurpP --minimal linux-2.6.22.10/include/net/af_unix.h linux-2.6.22.10-vs2.3.0.29/include/net/af_unix.h
17007 --- linux-2.6.22.10/include/net/af_unix.h 2007-07-09 13:20:01 +0200
17008 +++ linux-2.6.22.10-vs2.3.0.29/include/net/af_unix.h 2007-08-05 20:53:13 +0200
17010 #include <linux/socket.h>
17011 #include <linux/un.h>
17012 #include <linux/mutex.h>
17013 +#include <linux/vs_base.h>
17014 #include <net/sock.h>
17016 extern void unix_inflight(struct file *fp);
17017 @@ -17,9 +18,9 @@ extern spinlock_t unix_table_lock;
17019 extern atomic_t unix_tot_inflight;
17021 -static inline struct sock *first_unix_socket(int *i)
17022 +static inline struct sock *next_unix_socket_table(int *i)
17024 - for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
17025 + for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
17026 if (!hlist_empty(&unix_socket_table[*i]))
17027 return __sk_head(&unix_socket_table[*i]);
17029 @@ -28,16 +29,19 @@ static inline struct sock *first_unix_so
17031 static inline struct sock *next_unix_socket(int *i, struct sock *s)
17033 - struct sock *next = sk_next(s);
17034 - /* More in this chain? */
17037 - /* Look for next non-empty chain. */
17038 - for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
17039 - if (!hlist_empty(&unix_socket_table[*i]))
17040 - return __sk_head(&unix_socket_table[*i]);
17047 + s = next_unix_socket_table(i);
17048 + } while (s && !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT));
17052 +static inline struct sock *first_unix_socket(int *i)
17055 + return next_unix_socket(i, NULL);
17058 #define forall_unix_sockets(i, s) \
17059 diff -NurpP --minimal linux-2.6.22.10/include/net/inet_timewait_sock.h linux-2.6.22.10-vs2.3.0.29/include/net/inet_timewait_sock.h
17060 --- linux-2.6.22.10/include/net/inet_timewait_sock.h 2007-05-02 19:25:35 +0200
17061 +++ linux-2.6.22.10-vs2.3.0.29/include/net/inet_timewait_sock.h 2007-08-05 20:53:13 +0200
17062 @@ -115,6 +115,10 @@ struct inet_timewait_sock {
17063 #define tw_refcnt __tw_common.skc_refcnt
17064 #define tw_hash __tw_common.skc_hash
17065 #define tw_prot __tw_common.skc_prot
17066 +#define tw_xid __tw_common.skc_xid
17067 +#define tw_vx_info __tw_common.skc_vx_info
17068 +#define tw_nid __tw_common.skc_nid
17069 +#define tw_nx_info __tw_common.skc_nx_info
17070 volatile unsigned char tw_substate;
17071 /* 3 bits hole, try to pack */
17072 unsigned char tw_rcv_wscale;
17073 diff -NurpP --minimal linux-2.6.22.10/include/net/route.h linux-2.6.22.10-vs2.3.0.29/include/net/route.h
17074 --- linux-2.6.22.10/include/net/route.h 2007-05-02 19:25:35 +0200
17075 +++ linux-2.6.22.10-vs2.3.0.29/include/net/route.h 2007-09-18 03:52:05 +0200
17076 @@ -27,12 +27,16 @@
17077 #include <net/dst.h>
17078 #include <net/inetpeer.h>
17079 #include <net/flow.h>
17080 +#include <net/inet_sock.h>
17081 #include <linux/in_route.h>
17082 #include <linux/rtnetlink.h>
17083 #include <linux/route.h>
17084 #include <linux/ip.h>
17085 #include <linux/cache.h>
17086 #include <linux/security.h>
17087 +#include <linux/vs_base.h>
17088 +#include <linux/vs_inet.h>
17089 +#include <linux/in.h>
17092 #warning This file is not supposed to be used outside of kernel.
17093 @@ -143,6 +147,8 @@ static inline char rt_tos2priority(u8 to
17094 return ip_tos2prio[IPTOS_TOS(tos)>>1];
17097 +extern int ip_v4_find_src(struct nx_info *, struct rtable **, struct flowi *);
17099 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
17100 __be32 src, u32 tos, int oif, u8 protocol,
17101 __be16 sport, __be16 dport, struct sock *sk,
17102 @@ -158,7 +164,21 @@ static inline int ip_route_connect(struc
17103 .dport = dport } } };
17106 - if (!dst || !src) {
17107 + struct nx_info *nx_info = current->nx_info;
17110 + nx_info = sk->sk_nx_info;
17112 + vxdprintk(VXD_CBIT(net, 4),
17113 + "ip_route_connect(%p) %p,%p;%lx",
17114 + sk, nx_info, sk->sk_socket,
17115 + (sk->sk_socket?sk->sk_socket->flags:0));
17117 + err = ip_v4_find_src(nx_info, rp, &fl);
17121 + if (!fl.fl4_dst || !fl.fl4_src) {
17122 err = __ip_route_output_key(rp, &fl);
17125 diff -NurpP --minimal linux-2.6.22.10/include/net/sock.h linux-2.6.22.10-vs2.3.0.29/include/net/sock.h
17126 --- linux-2.6.22.10/include/net/sock.h 2007-07-09 13:20:02 +0200
17127 +++ linux-2.6.22.10-vs2.3.0.29/include/net/sock.h 2007-08-05 20:53:13 +0200
17128 @@ -119,6 +119,10 @@ struct sock_common {
17129 atomic_t skc_refcnt;
17130 unsigned int skc_hash;
17131 struct proto *skc_prot;
17133 + struct vx_info *skc_vx_info;
17135 + struct nx_info *skc_nx_info;
17139 @@ -195,6 +199,10 @@ struct sock {
17140 #define sk_refcnt __sk_common.skc_refcnt
17141 #define sk_hash __sk_common.skc_hash
17142 #define sk_prot __sk_common.skc_prot
17143 +#define sk_xid __sk_common.skc_xid
17144 +#define sk_vx_info __sk_common.skc_vx_info
17145 +#define sk_nid __sk_common.skc_nid
17146 +#define sk_nx_info __sk_common.skc_nx_info
17147 unsigned char sk_shutdown : 2,
17150 diff -NurpP --minimal linux-2.6.22.10/init/main.c linux-2.6.22.10-vs2.3.0.29/init/main.c
17151 --- linux-2.6.22.10/init/main.c 2007-07-09 13:20:03 +0200
17152 +++ linux-2.6.22.10-vs2.3.0.29/init/main.c 2007-08-05 20:53:13 +0200
17154 #include <linux/pid_namespace.h>
17155 #include <linux/device.h>
17156 #include <linux/kthread.h>
17157 +#include <linux/vserver/percpu.h>
17159 #include <asm/io.h>
17160 #include <asm/bugs.h>
17161 @@ -364,12 +365,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
17163 static void __init setup_per_cpu_areas(void)
17165 - unsigned long size, i;
17166 + unsigned long size, vspc, i;
17168 unsigned long nr_possible_cpus = num_possible_cpus();
17170 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
17172 /* Copy section for each CPU (we discard the original) */
17173 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
17174 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
17175 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
17177 for_each_possible_cpu(i) {
17178 diff -NurpP --minimal linux-2.6.22.10/ipc/mqueue.c linux-2.6.22.10-vs2.3.0.29/ipc/mqueue.c
17179 --- linux-2.6.22.10/ipc/mqueue.c 2007-07-09 13:20:03 +0200
17180 +++ linux-2.6.22.10-vs2.3.0.29/ipc/mqueue.c 2007-10-01 14:57:41 +0200
17182 #include <linux/audit.h>
17183 #include <linux/signal.h>
17184 #include <linux/mutex.h>
17185 +#include <linux/vs_context.h>
17186 +#include <linux/vs_limit.h>
17188 #include <net/sock.h>
17190 @@ -151,17 +153,20 @@ static struct inode *mqueue_get_inode(st
17191 spin_lock(&mq_lock);
17192 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
17193 u->mq_bytes + mq_bytes >
17194 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
17195 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
17196 + !vx_ipcmsg_avail(p->vx_info, mq_bytes)) {
17197 spin_unlock(&mq_lock);
17200 u->mq_bytes += mq_bytes;
17201 + vx_ipcmsg_add(p->vx_info, u, mq_bytes);
17202 spin_unlock(&mq_lock);
17204 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
17205 if (!info->messages) {
17206 spin_lock(&mq_lock);
17207 u->mq_bytes -= mq_bytes;
17208 + vx_ipcmsg_sub(p->vx_info, u, mq_bytes);
17209 spin_unlock(&mq_lock);
17212 @@ -257,10 +262,14 @@ static void mqueue_delete_inode(struct i
17213 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
17216 + struct vx_info *vxi = lookup_vx_info(user->xid);
17218 spin_lock(&mq_lock);
17219 user->mq_bytes -= mq_bytes;
17220 + vx_ipcmsg_sub(vxi, user, mq_bytes);
17222 spin_unlock(&mq_lock);
17223 + put_vx_info(vxi);
17227 @@ -748,7 +757,7 @@ asmlinkage long sys_mq_unlink(const char
17229 atomic_inc(&inode->i_count);
17231 - err = vfs_unlink(dentry->d_parent->d_inode, dentry);
17232 + err = vfs_unlink(dentry->d_parent->d_inode, dentry, NULL);
17236 diff -NurpP --minimal linux-2.6.22.10/ipc/msg.c linux-2.6.22.10-vs2.3.0.29/ipc/msg.c
17237 --- linux-2.6.22.10/ipc/msg.c 2007-02-06 03:01:55 +0100
17238 +++ linux-2.6.22.10-vs2.3.0.29/ipc/msg.c 2007-08-05 20:53:13 +0200
17240 #include <linux/seq_file.h>
17241 #include <linux/mutex.h>
17242 #include <linux/nsproxy.h>
17243 +#include <linux/vs_base.h>
17245 #include <asm/current.h>
17246 #include <asm/uaccess.h>
17247 @@ -149,6 +150,7 @@ static int newque (struct ipc_namespace
17249 msq->q_perm.mode = msgflg & S_IRWXUGO;
17250 msq->q_perm.key = key;
17251 + msq->q_perm.xid = vx_current_xid();
17253 msq->q_perm.security = NULL;
17254 retval = security_msg_queue_alloc(msq);
17255 diff -NurpP --minimal linux-2.6.22.10/ipc/sem.c linux-2.6.22.10-vs2.3.0.29/ipc/sem.c
17256 --- linux-2.6.22.10/ipc/sem.c 2007-07-09 13:20:03 +0200
17257 +++ linux-2.6.22.10-vs2.3.0.29/ipc/sem.c 2007-08-05 20:53:13 +0200
17259 #include <linux/seq_file.h>
17260 #include <linux/mutex.h>
17261 #include <linux/nsproxy.h>
17262 +#include <linux/vs_base.h>
17263 +#include <linux/vs_limit.h>
17265 #include <asm/uaccess.h>
17267 @@ -229,6 +231,7 @@ static int newary (struct ipc_namespace
17269 sma->sem_perm.mode = (semflg & S_IRWXUGO);
17270 sma->sem_perm.key = key;
17271 + sma->sem_perm.xid = vx_current_xid();
17273 sma->sem_perm.security = NULL;
17274 retval = security_sem_alloc(sma);
17275 @@ -244,6 +247,9 @@ static int newary (struct ipc_namespace
17278 ns->used_sems += nsems;
17279 + /* FIXME: obsoleted? */
17280 + vx_semary_inc(sma);
17281 + vx_nsems_add(sma, nsems);
17283 sma->sem_id = sem_buildid(ns, id, sma->sem_perm.seq);
17284 sma->sem_base = (struct sem *) &sma[1];
17285 @@ -525,6 +531,9 @@ static void freeary (struct ipc_namespac
17288 ns->used_sems -= sma->sem_nsems;
17289 + /* FIXME: obsoleted? */
17290 + vx_nsems_sub(sma, sma->sem_nsems);
17291 + vx_semary_dec(sma);
17292 size = sizeof (*sma) + sma->sem_nsems * sizeof (struct sem);
17293 security_sem_free(sma);
17294 ipc_rcu_putref(sma);
17295 diff -NurpP --minimal linux-2.6.22.10/ipc/shm.c linux-2.6.22.10-vs2.3.0.29/ipc/shm.c
17296 --- linux-2.6.22.10/ipc/shm.c 2007-10-30 01:57:14 +0100
17297 +++ linux-2.6.22.10-vs2.3.0.29/ipc/shm.c 2007-10-01 14:57:41 +0200
17299 #include <linux/mutex.h>
17300 #include <linux/nsproxy.h>
17301 #include <linux/mount.h>
17302 +#include <linux/vs_context.h>
17303 +#include <linux/vs_limit.h>
17305 #include <asm/uaccess.h>
17307 @@ -185,7 +187,12 @@ static void shm_open(struct vm_area_stru
17309 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
17311 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
17312 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
17313 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
17315 + vx_ipcshm_sub(vxi, shp, numpages);
17316 + ns->shm_tot -= numpages;
17318 shm_rmid(ns, shp->id);
17320 if (!is_file_hugepages(shp->shm_file))
17321 @@ -195,6 +202,7 @@ static void shm_destroy(struct ipc_names
17323 fput (shp->shm_file);
17324 security_shm_free(shp);
17325 + put_vx_info(vxi);
17326 ipc_rcu_putref(shp);
17329 @@ -351,11 +359,15 @@ static int newseg (struct ipc_namespace
17330 if (ns->shm_tot + numpages > ns->shm_ctlall)
17333 + if (!vx_ipcshm_avail(current->vx_info, numpages))
17336 shp = ipc_rcu_alloc(sizeof(*shp));
17340 shp->shm_perm.key = key;
17341 + shp->shm_perm.xid = vx_current_xid();
17342 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
17343 shp->mlock_user = NULL;
17345 @@ -406,6 +418,7 @@ static int newseg (struct ipc_namespace
17346 file->f_dentry->d_inode->i_ino = shp->id;
17348 ns->shm_tot += numpages;
17349 + vx_ipcshm_add(current->vx_info, key, numpages);
17353 diff -NurpP --minimal linux-2.6.22.10/ipc/util.c linux-2.6.22.10-vs2.3.0.29/ipc/util.c
17354 --- linux-2.6.22.10/ipc/util.c 2007-07-09 13:20:03 +0200
17355 +++ linux-2.6.22.10-vs2.3.0.29/ipc/util.c 2007-08-05 20:53:13 +0200
17357 #include <linux/proc_fs.h>
17358 #include <linux/audit.h>
17359 #include <linux/nsproxy.h>
17360 +#include <linux/vs_base.h>
17361 +#include <linux/vserver/global.h>
17363 #include <asm/unistd.h>
17365 @@ -72,6 +74,7 @@ static struct ipc_namespace *clone_ipc_n
17368 kref_init(&ns->kref);
17369 + atomic_inc(&vs_global_ipc_ns);
17373 @@ -108,6 +111,7 @@ void free_ipc_ns(struct kref *kref)
17377 + atomic_dec(&vs_global_ipc_ns);
17381 diff -NurpP --minimal linux-2.6.22.10/kernel/Makefile linux-2.6.22.10-vs2.3.0.29/kernel/Makefile
17382 --- linux-2.6.22.10/kernel/Makefile 2007-07-09 13:20:03 +0200
17383 +++ linux-2.6.22.10-vs2.3.0.29/kernel/Makefile 2007-08-05 20:53:13 +0200
17384 @@ -10,6 +10,8 @@ obj-y = sched.o fork.o exec_domain.o
17385 kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
17386 hrtimer.o rwsem.o latency.o nsproxy.o srcu.o die_notifier.o
17390 obj-$(CONFIG_STACKTRACE) += stacktrace.o
17392 obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
17393 diff -NurpP --minimal linux-2.6.22.10/kernel/capability.c linux-2.6.22.10-vs2.3.0.29/kernel/capability.c
17394 --- linux-2.6.22.10/kernel/capability.c 2007-05-02 19:25:37 +0200
17395 +++ linux-2.6.22.10-vs2.3.0.29/kernel/capability.c 2007-08-05 20:53:13 +0200
17397 #include <linux/module.h>
17398 #include <linux/security.h>
17399 #include <linux/syscalls.h>
17400 +#include <linux/vs_context.h>
17401 #include <asm/uaccess.h>
17403 unsigned securebits = SECUREBITS_DEFAULT; /* systemwide security settings */
17404 @@ -103,6 +104,8 @@ static inline int cap_set_pg(int pgrp_nr
17406 pgrp = find_pid(pgrp_nr);
17407 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
17408 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
17411 while_each_thread(g, target) {
17412 if (!security_capset_check(target, effective,
17413 @@ -246,8 +249,12 @@ int __capable(struct task_struct *t, int
17415 EXPORT_SYMBOL(__capable);
17417 +#include <linux/vserver/base.h>
17418 int capable(int cap)
17420 + /* here for now so we don't require task locking */
17421 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
17423 return __capable(current, cap);
17425 EXPORT_SYMBOL(capable);
17426 diff -NurpP --minimal linux-2.6.22.10/kernel/compat.c linux-2.6.22.10-vs2.3.0.29/kernel/compat.c
17427 --- linux-2.6.22.10/kernel/compat.c 2007-07-09 13:20:03 +0200
17428 +++ linux-2.6.22.10-vs2.3.0.29/kernel/compat.c 2007-08-05 20:53:13 +0200
17429 @@ -846,7 +846,7 @@ asmlinkage long compat_sys_time(compat_t
17433 - do_gettimeofday(&tv);
17434 + vx_gettimeofday(&tv);
17438 @@ -870,7 +870,7 @@ asmlinkage long compat_sys_stime(compat_
17442 - do_settimeofday(&tv);
17443 + vx_settimeofday(&tv);
17447 diff -NurpP --minimal linux-2.6.22.10/kernel/exit.c linux-2.6.22.10-vs2.3.0.29/kernel/exit.c
17448 --- linux-2.6.22.10/kernel/exit.c 2007-07-09 13:20:03 +0200
17449 +++ linux-2.6.22.10-vs2.3.0.29/kernel/exit.c 2007-10-01 18:31:46 +0200
17451 #include <linux/resource.h>
17452 #include <linux/blkdev.h>
17453 #include <linux/task_io_accounting_ops.h>
17454 +#include <linux/vs_limit.h>
17455 +#include <linux/vs_context.h>
17456 +#include <linux/vs_network.h>
17457 +#include <linux/vs_pid.h>
17458 +#include <linux/vserver/global.h>
17460 #include <asm/uaccess.h>
17461 #include <asm/unistd.h>
17462 @@ -443,9 +448,11 @@ static void close_files(struct files_str
17463 filp_close(file, files);
17466 + vx_openfd_dec(i);
17474 @@ -525,6 +532,7 @@ static inline void __put_fs_struct(struc
17476 mntput(fs->altrootmnt);
17478 + atomic_dec(&vs_global_fs);
17479 kmem_cache_free(fs_cachep, fs);
17482 @@ -596,6 +604,14 @@ static void exit_mm(struct task_struct *
17484 choose_new_parent(struct task_struct *p, struct task_struct *reaper)
17486 + /* check for reaper context */
17487 + vxwprintk((p->xid != reaper->xid) && (reaper != child_reaper(p)),
17488 + "rogue reaper: %p[%d,#%u] <> %p[%d,#%u]",
17489 + p, p->pid, p->xid, reaper, reaper->pid, reaper->xid);
17492 + reaper = vx_child_reaper(p);
17495 * Make sure we're not reparenting to ourselves and that
17496 * the parent is not a zombie.
17497 @@ -687,7 +703,7 @@ forget_original_parent(struct task_struc
17499 reaper = next_thread(reaper);
17500 if (reaper == father) {
17501 - reaper = child_reaper(father);
17502 + reaper = vx_child_reaper(father);
17505 } while (reaper->exit_state);
17506 @@ -964,6 +980,8 @@ fastcall NORET_TYPE void do_exit(long co
17507 tsk->exit_code = code;
17508 proc_exit_connector(tsk);
17509 exit_task_namespaces(tsk);
17510 + /* needs to stay before exit_notify() */
17511 + exit_vx_info_early(tsk, code);
17514 mpol_free(tsk->mempolicy);
17515 @@ -994,6 +1012,10 @@ fastcall NORET_TYPE void do_exit(long co
17516 if (tsk->splice_pipe)
17517 __free_pipe_info(tsk->splice_pipe);
17519 + /* needs to stay after exit_notify() */
17520 + exit_vx_info(tsk, code);
17521 + exit_nx_info(tsk);
17524 /* causes final put_task_struct in finish_task_switch(). */
17525 tsk->state = TASK_DEAD;
17526 diff -NurpP --minimal linux-2.6.22.10/kernel/fork.c linux-2.6.22.10-vs2.3.0.29/kernel/fork.c
17527 --- linux-2.6.22.10/kernel/fork.c 2007-07-09 13:20:03 +0200
17528 +++ linux-2.6.22.10-vs2.3.0.29/kernel/fork.c 2007-10-25 17:05:55 +0200
17530 #include <linux/delayacct.h>
17531 #include <linux/taskstats_kern.h>
17532 #include <linux/random.h>
17533 +#include <linux/vs_context.h>
17534 +#include <linux/vs_network.h>
17535 +#include <linux/vs_limit.h>
17536 +#include <linux/vs_memory.h>
17537 +#include <linux/vserver/global.h>
17539 #include <asm/pgtable.h>
17540 #include <asm/pgalloc.h>
17541 @@ -108,6 +113,8 @@ void free_task(struct task_struct *tsk)
17543 free_thread_info(tsk->stack);
17544 rt_mutex_debug_task_free(tsk);
17545 + clr_vx_info(&tsk->vx_info);
17546 + clr_nx_info(&tsk->nx_info);
17547 free_task_struct(tsk);
17549 EXPORT_SYMBOL(free_task);
17550 @@ -215,6 +222,8 @@ static inline int dup_mmap(struct mm_str
17551 mm->free_area_cache = oldmm->mmap_base;
17552 mm->cached_hole_size = ~0UL;
17554 + __set_mm_counter(mm, file_rss, 0);
17555 + __set_mm_counter(mm, anon_rss, 0);
17556 cpus_clear(mm->cpu_vm_mask);
17557 mm->mm_rb = RB_ROOT;
17558 rb_link = &mm->mm_rb.rb_node;
17559 @@ -226,7 +235,7 @@ static inline int dup_mmap(struct mm_str
17561 if (mpnt->vm_flags & VM_DONTCOPY) {
17562 long pages = vma_pages(mpnt);
17563 - mm->total_vm -= pages;
17564 + vx_vmpages_sub(mm, pages);
17565 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
17568 @@ -327,7 +336,7 @@ static inline void mm_free_pgd(struct mm
17570 #include <linux/init_task.h>
17572 -static struct mm_struct * mm_init(struct mm_struct * mm)
17573 +static struct mm_struct * mm_init(struct mm_struct * mm, struct vx_info *vxi)
17575 atomic_set(&mm->mm_users, 1);
17576 atomic_set(&mm->mm_count, 1);
17577 @@ -335,8 +344,8 @@ static struct mm_struct * mm_init(struct
17578 INIT_LIST_HEAD(&mm->mmlist);
17579 mm->core_waiters = 0;
17581 - set_mm_counter(mm, file_rss, 0);
17582 - set_mm_counter(mm, anon_rss, 0);
17583 + __set_mm_counter(mm, file_rss, 0);
17584 + __set_mm_counter(mm, anon_rss, 0);
17585 spin_lock_init(&mm->page_table_lock);
17586 rwlock_init(&mm->ioctx_list_lock);
17587 mm->ioctx_list = NULL;
17588 @@ -345,6 +354,7 @@ static struct mm_struct * mm_init(struct
17590 if (likely(!mm_alloc_pgd(mm))) {
17592 + set_vx_info(&mm->mm_vx_info, vxi);
17596 @@ -361,7 +371,7 @@ struct mm_struct * mm_alloc(void)
17597 mm = allocate_mm();
17599 memset(mm, 0, sizeof(*mm));
17600 - mm = mm_init(mm);
17601 + mm = mm_init(mm, current->vx_info);
17605 @@ -376,6 +386,7 @@ void fastcall __mmdrop(struct mm_struct
17606 BUG_ON(mm == &init_mm);
17608 destroy_context(mm);
17609 + clr_vx_info(&mm->mm_vx_info);
17613 @@ -490,12 +501,13 @@ static struct mm_struct *dup_mm(struct t
17616 memcpy(mm, oldmm, sizeof(*mm));
17617 + mm->mm_vx_info = NULL;
17619 /* Initializing for Swap token stuff */
17620 mm->token_priority = 0;
17621 mm->last_interval = 0;
17623 - if (!mm_init(mm))
17624 + if (!mm_init(mm, oldmm->mm_vx_info))
17627 if (init_new_context(tsk, mm))
17628 @@ -521,6 +533,7 @@ fail_nocontext:
17629 * If init_new_context() failed, we cannot use mmput() to free the mm
17630 * because it calls destroy_context()
17632 + clr_vx_info(&mm->mm_vx_info);
17636 @@ -591,6 +604,7 @@ static inline struct fs_struct *__copy_f
17637 fs->altroot = NULL;
17639 read_unlock(&old->lock);
17640 + atomic_inc(&vs_global_fs);
17644 @@ -709,6 +723,8 @@ static struct files_struct *dup_fd(struc
17645 struct file *f = *old_fds++;
17648 + /* TODO: sum it first for check and performance */
17649 + vx_openfd_inc(open_files - i);
17652 * The fd may be claimed in the fd bitmap but not yet
17653 @@ -961,6 +977,8 @@ static struct task_struct *copy_process(
17656 struct task_struct *p = NULL;
17657 + struct vx_info *vxi;
17658 + struct nx_info *nxi;
17660 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
17661 return ERR_PTR(-EINVAL);
17662 @@ -995,12 +1013,30 @@ static struct task_struct *copy_process(
17663 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
17664 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
17666 + init_vx_info(&p->vx_info, current->vx_info);
17667 + init_nx_info(&p->nx_info, current->nx_info);
17669 + /* check vserver memory */
17670 + if (p->mm && !(clone_flags & CLONE_VM)) {
17671 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
17672 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17674 + goto bad_fork_free;
17676 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
17677 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
17678 + goto bad_fork_cleanup_vm;
17682 + if (!vx_nproc_avail(1))
17683 + goto bad_fork_cleanup_vm;
17685 if (atomic_read(&p->user->processes) >=
17686 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
17687 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
17688 p->user != &root_user)
17689 - goto bad_fork_free;
17690 + goto bad_fork_cleanup_vm;
17693 atomic_inc(&p->user->__count);
17694 @@ -1265,6 +1301,18 @@ static struct task_struct *copy_process(
17697 spin_unlock(¤t->sighand->siglock);
17699 + /* p is copy of current */
17700 + vxi = p->vx_info;
17702 + claim_vx_info(vxi, p);
17703 + atomic_inc(&vxi->cvirt.nr_threads);
17704 + atomic_inc(&vxi->cvirt.total_forks);
17707 + nxi = p->nx_info;
17709 + claim_nx_info(nxi, p);
17710 write_unlock_irq(&tasklist_lock);
17711 proc_fork_connector(p);
17713 @@ -1306,6 +1354,9 @@ bad_fork_cleanup_count:
17714 put_group_info(p->group_info);
17715 atomic_dec(&p->user->processes);
17717 +bad_fork_cleanup_vm:
17718 + if (p->mm && !(clone_flags & CLONE_VM))
17719 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17723 @@ -1367,6 +1418,15 @@ long do_fork(unsigned long clone_flags,
17728 + /* kernel threads are host only */
17729 + if ((clone_flags & CLONE_KTHREAD) &&
17730 + !vx_capable(CAP_SYS_ADMIN, VXC_KTHREAD)) {
17731 + vxwprintk_task(1, "tried to spawn a kernel thread.");
17737 if (unlikely(current->ptrace)) {
17738 trace = fork_traceflag (clone_flags);
17739 diff -NurpP --minimal linux-2.6.22.10/kernel/kthread.c linux-2.6.22.10-vs2.3.0.29/kernel/kthread.c
17740 --- linux-2.6.22.10/kernel/kthread.c 2007-07-09 13:20:03 +0200
17741 +++ linux-2.6.22.10-vs2.3.0.29/kernel/kthread.c 2007-08-05 20:53:13 +0200
17742 @@ -96,7 +96,7 @@ static void create_kthread(struct kthrea
17744 wait_for_completion(&create->started);
17745 read_lock(&tasklist_lock);
17746 - create->result = find_task_by_pid(pid);
17747 + create->result = find_task_by_real_pid(pid);
17748 read_unlock(&tasklist_lock);
17750 complete(&create->done);
17751 diff -NurpP --minimal linux-2.6.22.10/kernel/nsproxy.c linux-2.6.22.10-vs2.3.0.29/kernel/nsproxy.c
17752 --- linux-2.6.22.10/kernel/nsproxy.c 2007-07-09 13:20:03 +0200
17753 +++ linux-2.6.22.10-vs2.3.0.29/kernel/nsproxy.c 2007-08-05 20:53:13 +0200
17754 @@ -20,14 +20,11 @@
17755 #include <linux/mnt_namespace.h>
17756 #include <linux/utsname.h>
17757 #include <linux/pid_namespace.h>
17758 +#include <linux/vserver/global.h>
17759 +#include <linux/vserver/debug.h>
17761 struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
17763 -static inline void get_nsproxy(struct nsproxy *ns)
17765 - atomic_inc(&ns->count);
17768 void get_task_namespaces(struct task_struct *tsk)
17770 struct nsproxy *ns = tsk->nsproxy;
17771 @@ -46,6 +43,9 @@ static inline struct nsproxy *clone_nspr
17772 ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL);
17774 atomic_set(&ns->count, 1);
17775 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
17776 + orig, atomic_read(&orig->count), ns);
17777 + atomic_inc(&vs_global_nsproxy);
17781 @@ -54,28 +54,32 @@ static inline struct nsproxy *clone_nspr
17782 * Return the newly created nsproxy. Do not attach this to the task,
17783 * leave it to the caller to do proper locking and attach it to task.
17785 -static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17786 +static struct nsproxy *unshare_namespaces(int flags, struct nsproxy *orig,
17787 struct fs_struct *new_fs)
17789 struct nsproxy *new_nsp;
17791 - new_nsp = clone_nsproxy(tsk->nsproxy);
17792 + vxdprintk(VXD_CBIT(space, 4),
17793 + "unshare_namespaces(0x%08x,%p,%p)",
17794 + flags, orig, new_fs);
17796 + new_nsp = clone_nsproxy(orig);
17798 return ERR_PTR(-ENOMEM);
17800 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
17801 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
17802 if (IS_ERR(new_nsp->mnt_ns))
17805 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
17806 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
17807 if (IS_ERR(new_nsp->uts_ns))
17810 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
17811 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
17812 if (IS_ERR(new_nsp->ipc_ns))
17815 - new_nsp->pid_ns = copy_pid_ns(flags, tsk->nsproxy->pid_ns);
17816 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
17817 if (IS_ERR(new_nsp->pid_ns))
17820 @@ -95,6 +99,33 @@ out_ns:
17821 return ERR_PTR(-ENOMEM);
17824 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17825 + struct fs_struct *new_fs)
17827 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
17831 + * copies the nsproxy, setting refcount to 1, and grabbing a
17832 + * reference to all contained namespaces.
17834 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
17836 + struct nsproxy *ns = clone_nsproxy(orig);
17840 + get_mnt_ns(ns->mnt_ns);
17842 + get_uts_ns(ns->uts_ns);
17844 + get_ipc_ns(ns->ipc_ns);
17846 + get_pid_ns(ns->pid_ns);
17852 * called from clone. This now handles copy for nsproxy and all
17853 * namespaces therein.
17854 @@ -102,9 +133,12 @@ out_ns:
17855 int copy_namespaces(int flags, struct task_struct *tsk)
17857 struct nsproxy *old_ns = tsk->nsproxy;
17858 - struct nsproxy *new_ns;
17859 + struct nsproxy *new_ns = NULL;
17862 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08x,%p[%p])",
17863 + flags, tsk, old_ns);
17868 @@ -127,6 +161,9 @@ int copy_namespaces(int flags, struct ta
17869 tsk->nsproxy = new_ns;
17871 put_nsproxy(old_ns);
17872 + vxdprintk(VXD_CBIT(space, 3),
17873 + "copy_namespaces(0x%08x,%p[%p]) = %d [%p]",
17874 + flags, tsk, old_ns, err, new_ns);
17878 @@ -140,6 +177,7 @@ void free_nsproxy(struct nsproxy *ns)
17879 put_ipc_ns(ns->ipc_ns);
17881 put_pid_ns(ns->pid_ns);
17882 + atomic_dec(&vs_global_nsproxy);
17886 @@ -152,6 +190,10 @@ int unshare_nsproxy_namespaces(unsigned
17890 + vxdprintk(VXD_CBIT(space, 4),
17891 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
17892 + unshare_flags, current->nsproxy);
17894 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC)))
17897 diff -NurpP --minimal linux-2.6.22.10/kernel/pid.c linux-2.6.22.10-vs2.3.0.29/kernel/pid.c
17898 --- linux-2.6.22.10/kernel/pid.c 2007-07-09 13:20:03 +0200
17899 +++ linux-2.6.22.10-vs2.3.0.29/kernel/pid.c 2007-08-05 20:53:13 +0200
17901 #include <linux/hash.h>
17902 #include <linux/pid_namespace.h>
17903 #include <linux/init_task.h>
17904 +#include <linux/vs_pid.h>
17906 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
17907 static struct hlist_head *pid_hash;
17908 @@ -295,6 +296,9 @@ void fastcall transfer_pid(struct task_s
17909 struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
17911 struct task_struct *result = NULL;
17913 + if (type == PIDTYPE_REALPID)
17914 + type = PIDTYPE_PID;
17916 struct hlist_node *first;
17917 first = rcu_dereference(pid->tasks[type].first);
17918 @@ -309,7 +313,17 @@ struct task_struct * fastcall pid_task(s
17920 struct task_struct *find_task_by_pid_type(int type, int nr)
17922 - return pid_task(find_pid(nr), type);
17923 + struct task_struct *task;
17925 + if (type == PIDTYPE_PID)
17926 + nr = vx_rmap_pid(nr);
17928 + task = pid_task(find_pid(nr), type);
17929 + if (task && (type != PIDTYPE_REALPID) &&
17930 + /* maybe VS_WATCH_P in the future? */
17931 + !vx_check(task->xid, VS_WATCH|VS_IDENT))
17936 EXPORT_SYMBOL(find_task_by_pid_type);
17937 diff -NurpP --minimal linux-2.6.22.10/kernel/posix-timers.c linux-2.6.22.10-vs2.3.0.29/kernel/posix-timers.c
17938 --- linux-2.6.22.10/kernel/posix-timers.c 2007-07-09 13:20:03 +0200
17939 +++ linux-2.6.22.10-vs2.3.0.29/kernel/posix-timers.c 2007-10-01 15:41:45 +0200
17941 #include <linux/wait.h>
17942 #include <linux/workqueue.h>
17943 #include <linux/module.h>
17944 +#include <linux/vs_context.h>
17947 * Management arrays for POSIX timers. Timers are kept in slab memory
17948 @@ -297,6 +298,12 @@ void do_schedule_next_timer(struct sigin
17950 int posix_timer_event(struct k_itimer *timr,int si_private)
17952 + struct vx_info_save vxis;
17953 + struct vx_info *vxi;
17956 + vxi = task_get_vx_info(timr->it_process);
17957 + enter_vx_info(vxi, &vxis);
17958 memset(&timr->sigq->info, 0, sizeof(siginfo_t));
17959 timr->sigq->info.si_sys_private = si_private;
17960 /* Send signal to the process that owns this timer.*/
17961 @@ -309,11 +316,11 @@ int posix_timer_event(struct k_itimer *t
17963 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
17964 struct task_struct *leader;
17965 - int ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
17966 - timr->it_process);
17968 + ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
17969 + timr->it_process);
17970 if (likely(ret >= 0))
17974 timr->it_sigev_notify = SIGEV_SIGNAL;
17975 leader = timr->it_process->group_leader;
17976 @@ -321,8 +328,12 @@ int posix_timer_event(struct k_itimer *t
17977 timr->it_process = leader;
17980 - return send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
17981 + ret = send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
17984 + leave_vx_info(&vxis);
17985 + put_vx_info(vxi);
17988 EXPORT_SYMBOL_GPL(posix_timer_event);
17990 @@ -402,7 +413,7 @@ static struct task_struct * good_sigeven
17991 struct task_struct *rtn = current->group_leader;
17993 if ((event->sigev_notify & SIGEV_THREAD_ID ) &&
17994 - (!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) ||
17995 + (!(rtn = find_task_by_real_pid(event->sigev_notify_thread_id)) ||
17996 rtn->tgid != current->tgid ||
17997 (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))
17999 diff -NurpP --minimal linux-2.6.22.10/kernel/printk.c linux-2.6.22.10-vs2.3.0.29/kernel/printk.c
18000 --- linux-2.6.22.10/kernel/printk.c 2007-07-09 13:20:03 +0200
18001 +++ linux-2.6.22.10-vs2.3.0.29/kernel/printk.c 2007-08-05 20:53:13 +0200
18003 #include <linux/bootmem.h>
18004 #include <linux/syscalls.h>
18005 #include <linux/jiffies.h>
18006 +#include <linux/vs_cvirt.h>
18008 #include <asm/uaccess.h>
18010 @@ -182,18 +183,13 @@ int do_syslog(int type, char __user *buf
18011 unsigned long i, j, limit, count;
18017 error = security_syslog(type);
18022 - case 0: /* Close log */
18024 - case 1: /* Open log */
18026 - case 2: /* Read from log */
18027 + if ((type >= 2) && (type <= 4)) {
18029 if (!buf || len < 0)
18031 @@ -204,6 +200,16 @@ int do_syslog(int type, char __user *buf
18036 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
18037 + return vx_do_syslog(type, buf, len);
18040 + case 0: /* Close log */
18042 + case 1: /* Open log */
18044 + case 2: /* Read from log */
18045 error = wait_event_interruptible(log_wait,
18046 (log_start - log_end));
18048 @@ -228,16 +234,6 @@ int do_syslog(int type, char __user *buf
18051 case 3: /* Read last kernel messages */
18053 - if (!buf || len < 0)
18058 - if (!access_ok(VERIFY_WRITE, buf, len)) {
18063 if (count > log_buf_len)
18064 count = log_buf_len;
18065 diff -NurpP --minimal linux-2.6.22.10/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/kernel/ptrace.c
18066 --- linux-2.6.22.10/kernel/ptrace.c 2007-07-09 13:20:03 +0200
18067 +++ linux-2.6.22.10-vs2.3.0.29/kernel/ptrace.c 2007-08-05 20:53:13 +0200
18069 #include <linux/security.h>
18070 #include <linux/signal.h>
18071 #include <linux/audit.h>
18072 +#include <linux/vs_context.h>
18074 #include <asm/pgtable.h>
18075 #include <asm/uaccess.h>
18076 @@ -145,6 +146,11 @@ static int may_attach(struct task_struct
18077 dumpable = task->mm->dumpable;
18078 if (!dumpable && !capable(CAP_SYS_PTRACE))
18080 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
18082 + if (!vx_check(task->xid, VS_IDENT) &&
18083 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
18086 return security_ptrace(current, task);
18088 @@ -471,6 +477,10 @@ asmlinkage long sys_ptrace(long request,
18093 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
18094 + goto out_put_task_struct;
18096 if (request == PTRACE_ATTACH) {
18097 ret = ptrace_attach(child);
18098 goto out_put_task_struct;
18099 diff -NurpP --minimal linux-2.6.22.10/kernel/sched.c linux-2.6.22.10-vs2.3.0.29/kernel/sched.c
18100 --- linux-2.6.22.10/kernel/sched.c 2007-07-09 13:20:03 +0200
18101 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sched.c 2007-08-05 20:53:13 +0200
18104 #include <asm/tlb.h>
18105 #include <asm/unistd.h>
18106 +#include <linux/vs_sched.h>
18107 +#include <linux/vs_cvirt.h>
18110 * Scheduler clock - returns current time in nanosec units.
18111 @@ -281,6 +283,16 @@ struct rq {
18112 struct task_struct *migration_thread;
18113 struct list_head migration_queue;
18115 + unsigned long norm_time;
18116 + unsigned long idle_time;
18117 +#ifdef CONFIG_VSERVER_IDLETIME
18120 +#ifdef CONFIG_VSERVER_HARDCPU
18121 + struct list_head hold_queue;
18122 + unsigned long nr_onhold;
18126 #ifdef CONFIG_SCHEDSTATS
18127 /* latency stats */
18128 @@ -714,6 +726,7 @@ sched_info_switch(struct task_struct *pr
18130 static void dequeue_task(struct task_struct *p, struct prio_array *array)
18132 + BUG_ON(p->state & TASK_ONHOLD);
18133 array->nr_active--;
18134 list_del(&p->run_list);
18135 if (list_empty(array->queue + p->prio))
18136 @@ -722,6 +735,7 @@ static void dequeue_task(struct task_str
18138 static void enqueue_task(struct task_struct *p, struct prio_array *array)
18140 + BUG_ON(p->state & TASK_ONHOLD);
18141 sched_info_queued(p);
18142 list_add_tail(&p->run_list, array->queue + p->prio);
18143 __set_bit(p->prio, array->bitmap);
18144 @@ -735,12 +749,14 @@ static void enqueue_task(struct task_str
18146 static void requeue_task(struct task_struct *p, struct prio_array *array)
18148 + BUG_ON(p->state & TASK_ONHOLD);
18149 list_move_tail(&p->run_list, array->queue + p->prio);
18153 enqueue_task_head(struct task_struct *p, struct prio_array *array)
18155 + BUG_ON(p->state & TASK_ONHOLD);
18156 list_add(&p->run_list, array->queue + p->prio);
18157 __set_bit(p->prio, array->bitmap);
18158 array->nr_active++;
18159 @@ -769,6 +785,10 @@ static inline int __normal_prio(struct t
18160 bonus = CURRENT_BONUS(p) - MAX_BONUS / 2;
18162 prio = p->static_prio - bonus;
18164 + /* adjust effective priority */
18165 + prio = vx_adjust_prio(p, prio, MAX_USER_PRIO);
18167 if (prio < MAX_RT_PRIO)
18168 prio = MAX_RT_PRIO;
18169 if (prio > MAX_PRIO-1)
18170 @@ -878,6 +898,9 @@ static int effective_prio(struct task_st
18174 +#include "sched_mon.h"
18178 * __activate_task - move a task to the runqueue.
18180 @@ -887,6 +910,7 @@ static void __activate_task(struct task_
18183 target = rq->expired;
18184 + vxm_activate_task(p, rq);
18185 enqueue_task(p, target);
18186 inc_nr_running(p, rq);
18188 @@ -896,6 +920,7 @@ static void __activate_task(struct task_
18190 static inline void __activate_idle_task(struct task_struct *p, struct rq *rq)
18192 + vxm_activate_idle(p, rq);
18193 enqueue_task_head(p, rq->active);
18194 inc_nr_running(p, rq);
18196 @@ -1030,19 +1055,30 @@ static void activate_task(struct task_st
18198 p->timestamp = now;
18200 + vx_activate_task(p);
18201 __activate_task(p, rq);
18205 - * deactivate_task - remove a task from the runqueue.
18206 + * __deactivate_task - remove a task from the runqueue.
18208 -static void deactivate_task(struct task_struct *p, struct rq *rq)
18209 +static void __deactivate_task(struct task_struct *p, struct rq *rq)
18211 dec_nr_running(p, rq);
18212 dequeue_task(p, p->array);
18213 + vxm_deactivate_task(p, rq);
18218 +void deactivate_task(struct task_struct *p, struct rq *rq)
18220 + vx_deactivate_task(p);
18221 + __deactivate_task(p, rq);
18224 +#include "sched_hard.h"
18227 * resched_task - mark a task 'to be rescheduled now'.
18229 @@ -1129,6 +1165,7 @@ migrate_task(struct task_struct *p, int
18231 struct rq *rq = task_rq(p);
18233 + vxm_migrate_task(p, rq, dest_cpu);
18235 * If the task is not on a runqueue (and not running), then
18236 * it is sufficient to simply update the task's cpu field.
18237 @@ -1518,6 +1555,12 @@ static int try_to_wake_up(struct task_st
18239 rq = task_rq_lock(p, &flags);
18240 old_state = p->state;
18242 + /* we need to unhold suspended tasks */
18243 + if (old_state & TASK_ONHOLD) {
18244 + vx_unhold_task(p, rq);
18245 + old_state = p->state;
18247 if (!(old_state & state))
18250 @@ -1625,6 +1668,7 @@ out_activate:
18251 #endif /* CONFIG_SMP */
18252 if (old_state == TASK_UNINTERRUPTIBLE) {
18253 rq->nr_uninterruptible--;
18254 + vx_uninterruptible_dec(p);
18256 * Tasks on involuntary sleep don't earn
18257 * sleep_avg beyond just interactive state.
18258 @@ -1676,7 +1720,7 @@ int fastcall wake_up_state(struct task_s
18259 return try_to_wake_up(p, state, 0);
18262 -static void task_running_tick(struct rq *rq, struct task_struct *p);
18263 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu);
18265 * Perform scheduler related setup for a newly forked process p.
18266 * p is forked by current.
18267 @@ -1737,7 +1781,7 @@ void fastcall sched_fork(struct task_str
18268 * runqueue lock is not a problem.
18270 current->time_slice = 1;
18271 - task_running_tick(cpu_rq(cpu), current);
18272 + task_running_tick(cpu_rq(cpu), current, cpu);
18274 local_irq_enable();
18276 @@ -1772,6 +1816,7 @@ void fastcall wake_up_new_task(struct ta
18278 p->prio = effective_prio(p);
18280 + vx_activate_task(p);
18281 if (likely(cpu == this_cpu)) {
18282 if (!(clone_flags & CLONE_VM)) {
18284 @@ -1783,6 +1828,7 @@ void fastcall wake_up_new_task(struct ta
18285 __activate_task(p, rq);
18287 p->prio = current->prio;
18288 + BUG_ON(p->state & TASK_ONHOLD);
18289 p->normal_prio = current->normal_prio;
18290 list_add_tail(&p->run_list, ¤t->run_list);
18291 p->array = current->array;
18292 @@ -3351,13 +3397,16 @@ static inline int expired_starving(struc
18293 void account_user_time(struct task_struct *p, cputime_t cputime)
18295 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
18296 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
18298 + int nice = (TASK_NICE(p) > 0);
18300 p->utime = cputime_add(p->utime, cputime);
18301 + vx_account_user(vxi, cputime, nice);
18303 /* Add user time to cpustat. */
18304 tmp = cputime_to_cputime64(cputime);
18305 - if (TASK_NICE(p) > 0)
18307 cpustat->nice = cputime64_add(cpustat->nice, tmp);
18309 cpustat->user = cputime64_add(cpustat->user, tmp);
18310 @@ -3373,10 +3422,12 @@ void account_system_time(struct task_str
18313 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
18314 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
18315 struct rq *rq = this_rq();
18318 p->stime = cputime_add(p->stime, cputime);
18319 + vx_account_system(vxi, cputime, (p == rq->idle));
18321 /* Add system time to cpustat. */
18322 tmp = cputime_to_cputime64(cputime);
18323 @@ -3415,7 +3466,7 @@ void account_steal_time(struct task_stru
18324 cpustat->steal = cputime64_add(cpustat->steal, tmp);
18327 -static void task_running_tick(struct rq *rq, struct task_struct *p)
18328 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu)
18330 if (p->array != rq->active) {
18331 /* Task has expired but was not scheduled yet */
18332 @@ -3445,7 +3496,7 @@ static void task_running_tick(struct rq
18336 - if (!--p->time_slice) {
18337 + if (vx_need_resched(p, --p->time_slice, cpu)) {
18338 dequeue_task(p, rq->active);
18339 set_tsk_need_resched(p);
18340 p->prio = effective_prio(p);
18341 @@ -3506,9 +3557,12 @@ void scheduler_tick(void)
18342 struct rq *rq = cpu_rq(cpu);
18344 update_cpu_clock(p, rq, now);
18345 + vxm_sync(now, cpu);
18347 - if (!idle_at_tick)
18348 - task_running_tick(rq, p);
18349 + if (idle_at_tick)
18350 + vx_idle_resched(rq);
18352 + task_running_tick(rq, p, cpu);
18355 rq->idle_at_tick = idle_at_tick;
18356 @@ -3630,14 +3684,25 @@ need_resched_nonpreemptible:
18357 unlikely(signal_pending(prev))))
18358 prev->state = TASK_RUNNING;
18360 - if (prev->state == TASK_UNINTERRUPTIBLE)
18361 + if (prev->state == TASK_UNINTERRUPTIBLE) {
18362 rq->nr_uninterruptible++;
18363 + vx_uninterruptible_inc(prev);
18365 deactivate_task(prev, rq);
18369 cpu = smp_processor_id();
18370 + vx_set_rq_time(rq, jiffies);
18372 + vx_try_unhold(rq, cpu);
18375 if (unlikely(!rq->nr_running)) {
18376 + /* can we skip idle time? */
18377 + if (vx_try_skip(rq, cpu))
18380 idle_balance(cpu, rq);
18381 if (!rq->nr_running) {
18383 @@ -3663,6 +3728,10 @@ need_resched_nonpreemptible:
18384 queue = array->queue + idx;
18385 next = list_entry(queue->next, struct task_struct, run_list);
18387 + /* check before we schedule this context */
18388 + if (!vx_schedule(next, rq, cpu))
18391 if (!rt_task(next) && interactive_sleep(next->sleep_type)) {
18392 unsigned long long delta = now - next->timestamp;
18393 if (unlikely((long long)(now - next->timestamp) < 0))
18394 @@ -4263,7 +4332,7 @@ asmlinkage long sys_nice(int increment)
18397 if (increment < 0 && !can_nice(current, nice))
18399 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
18401 retval = security_task_setnice(current, nice);
18403 @@ -4435,6 +4504,7 @@ recheck:
18405 __setscheduler(p, policy, param->sched_priority);
18407 + vx_activate_task(p);
18408 __activate_task(p, rq);
18410 * Reschedule if we are currently running on this runqueue and
18411 @@ -5188,6 +5258,7 @@ static int __migrate_task(struct task_st
18412 p->timestamp = p->timestamp - rq_src->most_recent_timestamp
18413 + rq_dest->most_recent_timestamp;
18414 deactivate_task(p, rq_src);
18415 + vx_activate_task(p);
18416 __activate_task(p, rq_dest);
18417 if (TASK_PREEMPTS_CURR(p, rq_dest))
18418 resched_task(rq_dest->curr);
18419 @@ -7058,7 +7129,10 @@ void __init sched_init(void)
18420 INIT_LIST_HEAD(&rq->migration_queue);
18422 atomic_set(&rq->nr_iowait, 0);
18424 +#ifdef CONFIG_VSERVER_HARDCPU
18425 + INIT_LIST_HEAD(&rq->hold_queue);
18426 + rq->nr_onhold = 0;
18428 for (j = 0; j < 2; j++) {
18429 array = rq->arrays + j;
18430 for (k = 0; k < MAX_PRIO; k++) {
18431 @@ -7144,6 +7218,7 @@ void normalize_rt_tasks(void)
18432 deactivate_task(p, task_rq(p));
18433 __setscheduler(p, SCHED_NORMAL, 0);
18435 + vx_activate_task(p);
18436 __activate_task(p, task_rq(p));
18437 resched_task(rq->curr);
18439 diff -NurpP --minimal linux-2.6.22.10/kernel/sched_hard.h linux-2.6.22.10-vs2.3.0.29/kernel/sched_hard.h
18440 --- linux-2.6.22.10/kernel/sched_hard.h 1970-01-01 01:00:00 +0100
18441 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sched_hard.h 2007-08-05 20:53:13 +0200
18444 +#ifdef CONFIG_VSERVER_IDLELIMIT
18447 + * vx_idle_resched - reschedule after maxidle
18450 +void vx_idle_resched(struct rq *rq)
18452 + /* maybe have a better criterion for paused */
18453 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
18454 + set_need_resched();
18457 +#else /* !CONFIG_VSERVER_IDLELIMIT */
18459 +#define vx_idle_resched(rq)
18461 +#endif /* CONFIG_VSERVER_IDLELIMIT */
18465 +#ifdef CONFIG_VSERVER_IDLETIME
18467 +#define vx_set_rq_min_skip(rq, min) \
18468 + (rq)->idle_skip = (min)
18470 +#define vx_save_min_skip(ret, min, val) \
18471 + __vx_save_min_skip(ret, min, val)
18474 +void __vx_save_min_skip(int ret, int *min, int val)
18478 + if ((*min > val) || !*min)
18483 +int vx_try_skip(struct rq *rq, int cpu)
18485 + /* artificially advance time */
18486 + if (rq->idle_skip > 0) {
18487 + vxdprintk(list_empty(&rq->hold_queue),
18488 + "hold queue empty on cpu %d", cpu);
18489 + rq->idle_time += rq->idle_skip;
18490 + vxm_idle_skip(rq, cpu);
18496 +#else /* !CONFIG_VSERVER_IDLETIME */
18498 +#define vx_set_rq_min_skip(rq, min) \
18499 + ({ int dummy = (min); dummy; })
18501 +#define vx_save_min_skip(ret, min, val)
18504 +int vx_try_skip(struct rq *rq, int cpu)
18509 +#endif /* CONFIG_VSERVER_IDLETIME */
18513 +#ifdef CONFIG_VSERVER_HARDCPU
18515 +#define vx_set_rq_max_idle(rq, max) \
18516 + (rq)->idle_tokens = (max)
18518 +#define vx_save_max_idle(ret, min, val) \
18519 + __vx_save_max_idle(ret, min, val)
18522 +void __vx_save_max_idle(int ret, int *min, int val)
18530 + * vx_hold_task - put a task on the hold queue
18533 +void vx_hold_task(struct task_struct *p, struct rq *rq)
18535 + __deactivate_task(p, rq);
18536 + p->state |= TASK_ONHOLD;
18537 + /* a new one on hold */
18539 + vxm_hold_task(p, rq);
18540 + list_add_tail(&p->run_list, &rq->hold_queue);
18544 + * vx_unhold_task - put a task back to the runqueue
18547 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
18549 + list_del(&p->run_list);
18550 + /* one less waiting */
18552 + p->state &= ~TASK_ONHOLD;
18553 + enqueue_task(p, rq->expired);
18554 + inc_nr_running(p, rq);
18555 + vxm_unhold_task(p, rq);
18557 + if (p->static_prio < rq->best_expired_prio)
18558 + rq->best_expired_prio = p->static_prio;
18561 +unsigned long nr_onhold(void)
18563 + unsigned long i, sum = 0;
18565 + for_each_online_cpu(i)
18566 + sum += cpu_rq(i)->nr_onhold;
18574 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
18576 + return sched_pc->tokens;
18580 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
18582 + sched_pc->tokens--;
18586 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
18588 + struct vx_info *vxi = p->vx_info;
18590 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
18591 + struct _vx_sched_pc *sched_pc =
18592 + &vx_per_cpu(vxi, sched_pc, cpu);
18595 + /* maybe we can simplify that to decrement
18596 + the token counter unconditional? */
18598 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
18599 + __vx_consume_token(sched_pc);
18601 + /* for tokens > 0, one token was consumed */
18605 + vxm_need_resched(p, slice, cpu);
18606 + return (slice == 0);
18610 +#define vx_set_rq_time(rq, time) do { \
18611 + rq->norm_time = time; \
18616 +void vx_try_unhold(struct rq *rq, int cpu)
18618 + struct vx_info *vxi = NULL;
18619 + struct list_head *l, *n;
18620 + int maxidle = HZ;
18623 + /* nothing to do? what about pause? */
18624 + if (list_empty(&rq->hold_queue))
18627 + list_for_each_safe(l, n, &rq->hold_queue) {
18628 + int ret, delta_min[2];
18629 + struct _vx_sched_pc *sched_pc;
18630 + struct task_struct *p;
18632 + p = list_entry(l, struct task_struct, run_list);
18633 + /* don't bother with same context */
18634 + if (vxi == p->vx_info)
18637 + vxi = p->vx_info;
18638 + /* ignore paused contexts */
18639 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
18642 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18644 + /* recalc tokens */
18645 + vxm_sched_info(sched_pc, vxi, cpu);
18646 + ret = vx_tokens_recalc(sched_pc,
18647 + &rq->norm_time, &rq->idle_time, delta_min);
18648 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18651 + /* we found a runable context */
18652 + vx_unhold_task(p, rq);
18655 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
18656 + vx_save_min_skip(ret, &minskip, delta_min[1]);
18658 + vx_set_rq_max_idle(rq, maxidle);
18659 + vx_set_rq_min_skip(rq, minskip);
18660 + vxm_rq_max_min(rq, cpu);
18665 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
18667 + struct vx_info *vxi = next->vx_info;
18668 + struct _vx_sched_pc *sched_pc;
18669 + int delta_min[2];
18675 + flags = vxi->vx_flags;
18677 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
18678 + goto put_on_hold;
18679 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
18682 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18684 + /* update scheduler params */
18685 + if (cpu_isset(cpu, vxi->sched.update)) {
18686 + vx_update_sched_param(&vxi->sched, sched_pc);
18687 + vxm_update_sched(sched_pc, vxi, cpu);
18688 + cpu_clear(cpu, vxi->sched.update);
18691 + vxm_sched_info(sched_pc, vxi, cpu);
18692 + ret = vx_tokens_recalc(sched_pc,
18693 + &rq->norm_time, &rq->idle_time, delta_min);
18694 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18696 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
18699 + if (unlikely(ret < 0)) {
18700 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
18701 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
18702 + vxm_rq_max_min(rq, cpu);
18704 + vx_hold_task(next, rq);
18711 +#else /* CONFIG_VSERVER_HARDCPU */
18714 +void vx_hold_task(struct task_struct *p, struct rq *rq)
18720 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
18725 +unsigned long nr_onhold(void)
18732 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
18734 + return (slice == 0);
18738 +#define vx_set_rq_time(rq, time)
18741 +void vx_try_unhold(struct rq *rq, int cpu)
18747 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
18749 + struct vx_info *vxi = next->vx_info;
18750 + struct _vx_sched_pc *sched_pc;
18751 + int delta_min[2];
18754 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
18757 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18758 + vxm_sched_info(sched_pc, vxi, cpu);
18759 + ret = vx_tokens_recalc(sched_pc,
18760 + &rq->norm_time, &rq->idle_time, delta_min);
18761 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18765 +#endif /* CONFIG_VSERVER_HARDCPU */
18767 diff -NurpP --minimal linux-2.6.22.10/kernel/sched_mon.h linux-2.6.22.10-vs2.3.0.29/kernel/sched_mon.h
18768 --- linux-2.6.22.10/kernel/sched_mon.h 1970-01-01 01:00:00 +0100
18769 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sched_mon.h 2007-08-05 20:53:13 +0200
18772 +#include <linux/vserver/monitor.h>
18774 +#ifdef CONFIG_VSERVER_MONITOR
18776 +#ifdef CONFIG_VSERVER_HARDCPU
18777 +#define HARDCPU(x) (x)
18779 +#define HARDCPU(x) (0)
18782 +#ifdef CONFIG_VSERVER_IDLETIME
18783 +#define IDLETIME(x) (x)
18785 +#define IDLETIME(x) (0)
18788 +struct _vx_mon_entry *vxm_advance(int cpu);
18792 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
18794 + entry->type = type;
18795 + entry->xid = xid;
18799 +void __vxm_sync(int cpu)
18801 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18803 + __vxm_basic(entry, 0, VXM_SYNC);
18804 + entry->ev.sec = xtime.tv_sec;
18805 + entry->ev.nsec = xtime.tv_nsec;
18809 +void __vxm_task(struct task_struct *p, int type)
18811 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
18813 + __vxm_basic(entry, p->xid, type);
18814 + entry->ev.tsk.pid = p->pid;
18815 + entry->ev.tsk.state = p->state;
18819 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18821 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18823 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
18824 + entry->sd.tokens = s->tokens;
18825 + entry->sd.norm_time = s->norm_time;
18826 + entry->sd.idle_time = s->idle_time;
18830 +void __vxm_rqinfo1(struct rq *q, int cpu)
18832 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18834 + entry->type = VXM_RQINFO_1;
18835 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
18836 + entry->q1.running = q->nr_running;
18837 + entry->q1.onhold = HARDCPU(q->nr_onhold);
18838 + entry->q1.iowait = atomic_read(&q->nr_iowait);
18839 + entry->q1.uintr = q->nr_uninterruptible;
18840 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
18844 +void __vxm_rqinfo2(struct rq *q, int cpu)
18846 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18848 + entry->type = VXM_RQINFO_2;
18849 + entry->xid = (unsigned long)q & 0xffff;
18850 + entry->q2.norm_time = q->norm_time;
18851 + entry->q2.idle_time = q->idle_time;
18852 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
18856 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18858 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18860 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
18861 + entry->ev.tokens = s->tokens;
18865 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18867 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18869 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
18870 + entry->u1.tokens_max = s->tokens_max;
18871 + entry->u1.fill_rate = s->fill_rate[0];
18872 + entry->u1.interval = s->interval[0];
18876 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18878 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18880 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
18881 + entry->u2.tokens_min = s->tokens_min;
18882 + entry->u2.fill_rate = s->fill_rate[1];
18883 + entry->u2.interval = s->interval[1];
18887 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
18888 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
18889 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
18890 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
18891 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
18894 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
18896 + __vxm_task(p, VXM_MIGRATE);
18897 + __vxm_rqinfo1(rq, task_cpu(p));
18898 + __vxm_rqinfo2(rq, task_cpu(p));
18902 +void vxm_idle_skip(struct rq *rq, int cpu)
18904 + __vxm_rqinfo1(rq, cpu);
18905 + __vxm_rqinfo2(rq, cpu);
18909 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
18914 + __vxm_task(p, VXM_RESCHED);
18918 +void vxm_sync(unsigned long now, int cpu)
18920 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
18921 + (now % CONFIG_VSERVER_MONITOR_SYNC))
18927 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
18930 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
18931 + struct vx_info *vxi, int cpu)
18933 + __vxm_sched(s, vxi, cpu);
18934 + __vxm_rqinfo2(rq, cpu);
18938 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18940 + __vxm_sched(s, vxi, cpu);
18941 + __vxm_update(s, vxi, cpu);
18942 + __vxm_update1(s, vxi, cpu);
18943 + __vxm_update2(s, vxi, cpu);
18947 +void vxm_rq_max_min(struct rq *rq, int cpu)
18949 + __vxm_rqinfo1(rq, cpu);
18950 + __vxm_rqinfo2(rq, cpu);
18953 +#else /* CONFIG_VSERVER_MONITOR */
18955 +#define vxm_activate_task(t,q) do { } while (0)
18956 +#define vxm_activate_idle(t,q) do { } while (0)
18957 +#define vxm_deactivate_task(t,q) do { } while (0)
18958 +#define vxm_hold_task(t,q) do { } while (0)
18959 +#define vxm_unhold_task(t,q) do { } while (0)
18960 +#define vxm_migrate_task(t,q,d) do { } while (0)
18961 +#define vxm_idle_skip(q,c) do { } while (0)
18962 +#define vxm_need_resched(t,s,c) do { } while (0)
18963 +#define vxm_sync(s,c) do { } while (0)
18964 +#define vxm_sched_info(s,v,c) do { } while (0)
18965 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
18966 +#define vxm_update_sched(s,v,c) do { } while (0)
18967 +#define vxm_rq_max_min(q,c) do { } while (0)
18969 +#endif /* CONFIG_VSERVER_MONITOR */
18971 diff -NurpP --minimal linux-2.6.22.10/kernel/signal.c linux-2.6.22.10-vs2.3.0.29/kernel/signal.c
18972 --- linux-2.6.22.10/kernel/signal.c 2007-10-30 01:57:15 +0100
18973 +++ linux-2.6.22.10-vs2.3.0.29/kernel/signal.c 2007-09-30 14:58:01 +0200
18975 #include <linux/freezer.h>
18976 #include <linux/pid_namespace.h>
18977 #include <linux/nsproxy.h>
18978 +#include <linux/vs_context.h>
18979 +#include <linux/vs_pid.h>
18981 #include <asm/param.h>
18982 #include <asm/uaccess.h>
18983 @@ -523,19 +525,34 @@ static int check_kill_permission(int sig
18984 if (!valid_signal(sig))
18987 + if ((info != SEND_SIG_NOINFO) &&
18988 + (is_si_special(info) || !SI_FROMUSER(info)))
18991 + vxdprintk(VXD_CBIT(misc, 7),
18992 + "check_kill_permission(%d,%p,%p[#%u,%u])",
18993 + sig, info, t, vx_task_xid(t), t->pid);
18995 error = audit_signal_info(sig, t); /* Let audit system see the signal */
19000 - if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
19001 - && ((sig != SIGCONT) ||
19002 + if (((sig != SIGCONT) ||
19003 (process_session(current) != process_session(t)))
19004 && (current->euid ^ t->suid) && (current->euid ^ t->uid)
19005 && (current->uid ^ t->suid) && (current->uid ^ t->uid)
19006 && !capable(CAP_KILL))
19010 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
19011 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
19012 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
19013 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
19017 return security_task_kill(t, info, sig, 0);
19020 @@ -1043,7 +1060,7 @@ int kill_pid_info(int sig, struct siginf
19022 p = pid_task(pid, PIDTYPE_PID);
19025 + if (p && vx_check(vx_task_xid(p), VS_IDENT))
19026 error = group_send_sig_info(sig, info, p);
19028 if (unlikely(sig_needs_tasklist(sig)))
19029 @@ -1057,7 +1074,7 @@ kill_proc_info(int sig, struct siginfo *
19033 - error = kill_pid_info(sig, info, find_pid(pid));
19034 + error = kill_pid_info(sig, info, find_pid(vx_rmap_pid(pid)));
19038 @@ -1118,7 +1135,8 @@ static int kill_something_info(int sig,
19040 read_lock(&tasklist_lock);
19041 for_each_process(p) {
19042 - if (p->pid > 1 && p->tgid != current->tgid) {
19043 + if (vx_check(vx_task_xid(p), VS_ADMIN_P|VS_IDENT) &&
19044 + p->pid > 1 && p->tgid != current->tgid) {
19045 int err = group_send_sig_info(sig, info, p);
19048 @@ -1814,6 +1832,11 @@ relock:
19049 if (current == child_reaper(current))
19052 + /* virtual init is protected against user signals */
19053 + if ((info->si_code == SI_USER) &&
19054 + vx_current_initpid(current->pid))
19057 if (sig_kernel_stop(signr)) {
19059 * The default action is to stop all threads in
19060 diff -NurpP --minimal linux-2.6.22.10/kernel/softirq.c linux-2.6.22.10-vs2.3.0.29/kernel/softirq.c
19061 --- linux-2.6.22.10/kernel/softirq.c 2007-07-09 13:20:03 +0200
19062 +++ linux-2.6.22.10-vs2.3.0.29/kernel/softirq.c 2007-08-05 20:53:13 +0200
19064 #include <linux/rcupdate.h>
19065 #include <linux/smp.h>
19066 #include <linux/tick.h>
19067 +#include <linux/vs_context.h>
19069 #include <asm/irq.h>
19071 diff -NurpP --minimal linux-2.6.22.10/kernel/sys.c linux-2.6.22.10-vs2.3.0.29/kernel/sys.c
19072 --- linux-2.6.22.10/kernel/sys.c 2007-10-30 01:57:15 +0100
19073 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sys.c 2007-10-30 01:21:54 +0100
19075 #include <linux/compat.h>
19076 #include <linux/syscalls.h>
19077 #include <linux/kprobes.h>
19078 +#include <linux/vs_pid.h>
19080 #include <asm/uaccess.h>
19081 #include <asm/io.h>
19082 @@ -639,7 +640,10 @@ static int set_one_prio(struct task_stru
19085 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
19087 + if (vx_flags(VXF_IGNEG_NICE, 0))
19093 no_nice = security_task_setnice(p, niceval);
19094 @@ -687,6 +691,8 @@ asmlinkage long sys_setpriority(int whic
19096 pgrp = task_pgrp(current);
19097 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
19098 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
19100 error = set_one_prio(p, niceval, error);
19101 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
19103 @@ -695,7 +701,8 @@ asmlinkage long sys_setpriority(int whic
19105 who = current->uid;
19107 - if ((who != current->uid) && !(user = find_user(who)))
19108 + if ((who != current->uid) &&
19109 + !(user = find_user(vx_current_xid(), who)))
19110 goto out_unlock; /* No processes for this user */
19112 do_each_thread(g, p)
19113 @@ -747,6 +754,8 @@ asmlinkage long sys_getpriority(int whic
19115 pgrp = task_pgrp(current);
19116 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
19117 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
19119 niceval = 20 - task_nice(p);
19120 if (niceval > retval)
19122 @@ -757,7 +766,8 @@ asmlinkage long sys_getpriority(int whic
19124 who = current->uid;
19126 - if ((who != current->uid) && !(user = find_user(who)))
19127 + if ((who != current->uid) &&
19128 + !(user = find_user(vx_current_xid(), who)))
19129 goto out_unlock; /* No processes for this user */
19131 do_each_thread(g, p)
19132 @@ -871,6 +881,9 @@ void kernel_power_off(void)
19133 machine_power_off();
19135 EXPORT_SYMBOL_GPL(kernel_power_off);
19137 +long vs_reboot(unsigned int, void __user *);
19140 * Reboot system call: for obvious reasons only root may call it,
19141 * and even root needs to set up some magic numbers in the registers
19142 @@ -901,6 +914,9 @@ asmlinkage long sys_reboot(int magic1, i
19143 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
19144 cmd = LINUX_REBOOT_CMD_HALT;
19146 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
19147 + return vs_reboot(cmd, arg);
19151 case LINUX_REBOOT_CMD_RESTART:
19152 @@ -1080,7 +1096,7 @@ static int set_user(uid_t new_ruid, int
19154 struct user_struct *new_user;
19156 - new_user = alloc_uid(new_ruid);
19157 + new_user = alloc_uid(vx_current_xid(), new_ruid);
19161 @@ -1434,15 +1450,18 @@ asmlinkage long sys_setpgid(pid_t pid, p
19163 struct task_struct *p;
19164 struct task_struct *group_leader = current->group_leader;
19169 - pid = group_leader->pid;
19170 + pid = vx_map_pid(group_leader->pid);
19176 + rpgid = vx_rmap_pid(pgid);
19178 /* From this point forward we keep holding onto the tasklist lock
19179 * so that our parent does not change from under us. -DaveM
19181 @@ -1476,20 +1495,20 @@ asmlinkage long sys_setpgid(pid_t pid, p
19184 struct task_struct *g =
19185 - find_task_by_pid_type(PIDTYPE_PGID, pgid);
19186 + find_task_by_pid_type(PIDTYPE_PGID, rpgid);
19188 if (!g || task_session(g) != task_session(group_leader))
19192 - err = security_task_setpgid(p, pgid);
19193 + err = security_task_setpgid(p, rpgid);
19197 - if (process_group(p) != pgid) {
19198 + if (process_group(p) != rpgid) {
19199 detach_pid(p, PIDTYPE_PGID);
19200 - p->signal->pgrp = pgid;
19201 - attach_pid(p, PIDTYPE_PGID, find_pid(pgid));
19202 + p->signal->pgrp = rpgid;
19203 + attach_pid(p, PIDTYPE_PGID, find_pid(rpgid));
19207 @@ -1502,7 +1521,7 @@ out:
19208 asmlinkage long sys_getpgid(pid_t pid)
19211 - return process_group(current);
19212 + return vx_rmap_pid(process_group(current));
19215 struct task_struct *p;
19216 @@ -1514,7 +1533,7 @@ asmlinkage long sys_getpgid(pid_t pid)
19218 retval = security_task_getpgid(p);
19220 - retval = process_group(p);
19221 + retval = vx_rmap_pid(process_group(p));
19223 read_unlock(&tasklist_lock);
19225 @@ -1865,7 +1884,7 @@ asmlinkage long sys_sethostname(char __u
19227 char tmp[__NEW_UTS_LEN];
19229 - if (!capable(CAP_SYS_ADMIN))
19230 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
19232 if (len < 0 || len > __NEW_UTS_LEN)
19234 @@ -1910,7 +1929,7 @@ asmlinkage long sys_setdomainname(char _
19236 char tmp[__NEW_UTS_LEN];
19238 - if (!capable(CAP_SYS_ADMIN))
19239 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
19241 if (len < 0 || len > __NEW_UTS_LEN)
19243 @@ -1977,7 +1996,7 @@ asmlinkage long sys_setrlimit(unsigned i
19245 old_rlim = current->signal->rlim + resource;
19246 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
19247 - !capable(CAP_SYS_RESOURCE))
19248 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
19250 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
19252 diff -NurpP --minimal linux-2.6.22.10/kernel/sysctl.c linux-2.6.22.10-vs2.3.0.29/kernel/sysctl.c
19253 --- linux-2.6.22.10/kernel/sysctl.c 2007-07-09 13:20:03 +0200
19254 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sysctl.c 2007-08-05 20:53:13 +0200
19255 @@ -89,6 +89,7 @@ static int ngroups_max = NGROUPS_MAX;
19257 extern char modprobe_path[];
19259 +extern char vshelper_path[];
19260 #ifdef CONFIG_CHR_DEV_SG
19261 extern int sg_big_buff;
19263 @@ -343,6 +344,15 @@ static ctl_table kern_table[] = {
19264 .strategy = &sysctl_string,
19268 + .ctl_name = KERN_VSHELPER,
19269 + .procname = "vshelper",
19270 + .data = &vshelper_path,
19273 + .proc_handler = &proc_dostring,
19274 + .strategy = &sysctl_string,
19276 #ifdef CONFIG_CHR_DEV_SG
19278 .ctl_name = KERN_SG_BIG_BUFF,
19279 diff -NurpP --minimal linux-2.6.22.10/kernel/time.c linux-2.6.22.10-vs2.3.0.29/kernel/time.c
19280 --- linux-2.6.22.10/kernel/time.c 2007-07-09 13:20:03 +0200
19281 +++ linux-2.6.22.10-vs2.3.0.29/kernel/time.c 2007-08-05 20:53:13 +0200
19282 @@ -60,7 +60,7 @@ asmlinkage long sys_time(time_t __user *
19286 - do_gettimeofday(&tv);
19287 + vx_gettimeofday(&tv);
19291 @@ -91,7 +91,7 @@ asmlinkage long sys_stime(time_t __user
19295 - do_settimeofday(&tv);
19296 + vx_settimeofday(&tv);
19300 @@ -101,7 +101,7 @@ asmlinkage long sys_gettimeofday(struct
19302 if (likely(tv != NULL)) {
19303 struct timeval ktv;
19304 - do_gettimeofday(&ktv);
19305 + vx_gettimeofday(&ktv);
19306 if (copy_to_user(tv, &ktv, sizeof(ktv)))
19309 @@ -175,7 +175,7 @@ int do_sys_settimeofday(struct timespec
19310 /* SMP safe, again the code in arch/foo/time.c should
19311 * globally block out interrupts when it runs.
19313 - return do_settimeofday(tv);
19314 + return vx_settimeofday(tv);
19318 @@ -388,7 +388,7 @@ void getnstimeofday(struct timespec *tv)
19322 - do_gettimeofday(&x);
19323 + vx_gettimeofday(&x);
19324 tv->tv_sec = x.tv_sec;
19325 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
19327 diff -NurpP --minimal linux-2.6.22.10/kernel/timer.c linux-2.6.22.10-vs2.3.0.29/kernel/timer.c
19328 --- linux-2.6.22.10/kernel/timer.c 2007-07-09 13:20:04 +0200
19329 +++ linux-2.6.22.10-vs2.3.0.29/kernel/timer.c 2007-08-05 20:53:13 +0200
19331 #include <linux/delay.h>
19332 #include <linux/tick.h>
19333 #include <linux/kallsyms.h>
19334 +#include <linux/vs_base.h>
19335 +#include <linux/vs_cvirt.h>
19336 +#include <linux/vs_pid.h>
19337 +#include <linux/vserver/sched.h>
19339 #include <asm/uaccess.h>
19340 #include <asm/unistd.h>
19341 @@ -921,12 +925,6 @@ asmlinkage unsigned long sys_alarm(unsig
19348 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
19349 - * should be moved into arch/i386 instead?
19353 * sys_getpid - return the thread group id of the current process
19354 @@ -939,7 +937,7 @@ asmlinkage unsigned long sys_alarm(unsig
19356 asmlinkage long sys_getpid(void)
19358 - return current->tgid;
19359 + return vx_map_tgid(current->tgid);
19363 @@ -955,10 +953,23 @@ asmlinkage long sys_getppid(void)
19365 pid = rcu_dereference(current->real_parent)->tgid;
19367 + return vx_map_pid(pid);
19374 + * The Alpha uses getxpid, getxuid, and getxgid instead.
19377 +asmlinkage long do_getxpid(long *ppid)
19379 + *ppid = sys_getppid();
19380 + return sys_getpid();
19383 +#else /* _alpha_ */
19385 asmlinkage long sys_getuid(void)
19387 /* Only we change this so SMP safe */
19388 @@ -1118,6 +1129,8 @@ int do_sysinfo(struct sysinfo *info)
19389 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
19392 + if (vx_flags(VXF_VIRT_UPTIME, 0))
19393 + vx_vsi_uptime(&tp, NULL);
19394 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
19396 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
19397 diff -NurpP --minimal linux-2.6.22.10/kernel/user.c linux-2.6.22.10-vs2.3.0.29/kernel/user.c
19398 --- linux-2.6.22.10/kernel/user.c 2007-02-06 03:01:56 +0100
19399 +++ linux-2.6.22.10-vs2.3.0.29/kernel/user.c 2007-08-05 20:53:13 +0200
19401 #define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8)
19402 #define UIDHASH_SZ (1 << UIDHASH_BITS)
19403 #define UIDHASH_MASK (UIDHASH_SZ - 1)
19404 -#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
19405 -#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid)))
19406 +#define __uidhashfn(xid,uid) ((((uid) >> UIDHASH_BITS) + ((uid)^(xid))) & UIDHASH_MASK)
19407 +#define uidhashentry(xid,uid) (uidhash_table + __uidhashfn((xid),(uid)))
19409 static struct kmem_cache *uid_cachep;
19410 static struct list_head uidhash_table[UIDHASH_SZ];
19411 @@ -66,7 +66,7 @@ static inline void uid_hash_remove(struc
19412 list_del(&up->uidhash_list);
19415 -static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
19416 +static inline struct user_struct *uid_hash_find(xid_t xid, uid_t uid, struct list_head *hashent)
19418 struct list_head *up;
19420 @@ -75,7 +75,7 @@ static inline struct user_struct *uid_ha
19422 user = list_entry(up, struct user_struct, uidhash_list);
19424 - if(user->uid == uid) {
19425 + if(user->uid == uid && user->xid == xid) {
19426 atomic_inc(&user->__count);
19429 @@ -90,13 +90,13 @@ static inline struct user_struct *uid_ha
19431 * If the user_struct could not be found, return NULL.
19433 -struct user_struct *find_user(uid_t uid)
19434 +struct user_struct *find_user(xid_t xid, uid_t uid)
19436 struct user_struct *ret;
19437 unsigned long flags;
19439 spin_lock_irqsave(&uidhash_lock, flags);
19440 - ret = uid_hash_find(uid, uidhashentry(uid));
19441 + ret = uid_hash_find(xid, uid, uidhashentry(xid, uid));
19442 spin_unlock_irqrestore(&uidhash_lock, flags);
19445 @@ -120,13 +120,13 @@ void free_uid(struct user_struct *up)
19449 -struct user_struct * alloc_uid(uid_t uid)
19450 +struct user_struct * alloc_uid(xid_t xid, uid_t uid)
19452 - struct list_head *hashent = uidhashentry(uid);
19453 + struct list_head *hashent = uidhashentry(xid, uid);
19454 struct user_struct *up;
19456 spin_lock_irq(&uidhash_lock);
19457 - up = uid_hash_find(uid, hashent);
19458 + up = uid_hash_find(xid, uid, hashent);
19459 spin_unlock_irq(&uidhash_lock);
19462 @@ -136,6 +136,7 @@ struct user_struct * alloc_uid(uid_t uid
19467 atomic_set(&new->__count, 1);
19468 atomic_set(&new->processes, 0);
19469 atomic_set(&new->files, 0);
19470 @@ -158,7 +159,7 @@ struct user_struct * alloc_uid(uid_t uid
19471 * on adding the same user already..
19473 spin_lock_irq(&uidhash_lock);
19474 - up = uid_hash_find(uid, hashent);
19475 + up = uid_hash_find(xid, uid, hashent);
19477 key_put(new->uid_keyring);
19478 key_put(new->session_keyring);
19479 @@ -215,7 +216,7 @@ static int __init uid_cache_init(void)
19481 /* Insert the root user immediately (init already runs as root) */
19482 spin_lock_irq(&uidhash_lock);
19483 - uid_hash_insert(&root_user, uidhashentry(0));
19484 + uid_hash_insert(&root_user, uidhashentry(0,0));
19485 spin_unlock_irq(&uidhash_lock);
19488 diff -NurpP --minimal linux-2.6.22.10/kernel/utsname.c linux-2.6.22.10-vs2.3.0.29/kernel/utsname.c
19489 --- linux-2.6.22.10/kernel/utsname.c 2007-07-09 13:20:04 +0200
19490 +++ linux-2.6.22.10-vs2.3.0.29/kernel/utsname.c 2007-08-05 20:53:13 +0200
19492 #include <linux/uts.h>
19493 #include <linux/utsname.h>
19494 #include <linux/version.h>
19495 +#include <linux/vserver/global.h>
19498 * Clone a new ns copying an original utsname, setting refcount to 1
19499 @@ -27,6 +28,7 @@ static struct uts_namespace *clone_uts_n
19501 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
19502 kref_init(&ns->kref);
19503 + atomic_inc(&vs_global_uts_ns);
19507 @@ -58,5 +60,6 @@ void free_uts_ns(struct kref *kref)
19508 struct uts_namespace *ns;
19510 ns = container_of(kref, struct uts_namespace, kref);
19511 + atomic_dec(&vs_global_uts_ns);
19514 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/Kconfig linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Kconfig
19515 --- linux-2.6.22.10/kernel/vserver/Kconfig 1970-01-01 01:00:00 +0100
19516 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Kconfig 2007-10-11 01:10:22 +0200
19519 +# Linux VServer configuration
19522 +menu "Linux VServer"
19524 +config VSERVER_AUTO_LBACK
19525 + bool "Automatically Assign Loopback IP"
19528 + Automatically assign a guest specific loopback
19529 + IP and add it to the kernel network stack on
19532 +config VSERVER_AUTO_SINGLE
19533 + bool "Automatic Single IP Special Casing"
19534 + depends on EXPERIMENTAL
19537 + This allows network contexts with a single IP to
19538 + automatically remap 0.0.0.0 bindings to that IP,
19539 + avoiding further network checks and improving
19542 + (note: such guests do not allow to change the ip
19543 + on the fly and do not show loopback addresses)
19545 +config VSERVER_COWBL
19546 + bool "Enable COW Immutable Link Breaking"
19549 + This enables the COW (Copy-On-Write) link break code.
19550 + It allows you to treat unified files like normal files
19551 + when writing to them (which will implicitely break the
19552 + link and create a copy of the unified file)
19554 +config VSERVER_VTIME
19555 + bool "Enable Virtualized Guest Time"
19556 + depends on EXPERIMENTAL
19559 + This enables per guest time offsets to allow for
19560 + adjusting the system clock individually per guest.
19561 + this adds some overhead to the time functions and
19562 + therefore should not be enabled without good reason.
19564 +config VSERVER_DEVICE
19565 + bool "Enable Guest Device Mapping"
19566 + depends on EXPERIMENTAL
19569 + This enables generic device remapping.
19571 +config VSERVER_PROC_SECURE
19572 + bool "Enable Proc Security"
19573 + depends on PROC_FS
19576 + This configures ProcFS security to initially hide
19577 + non-process entries for all contexts except the main and
19578 + spectator context (i.e. for all guests), which is a secure
19581 + (note: on 1.2x the entries were visible by default)
19583 +config VSERVER_HARDCPU
19584 + bool "Enable Hard CPU Limits"
19587 + Activate the Hard CPU Limits
19589 + This will compile in code that allows the Token Bucket
19590 + Scheduler to put processes on hold when a context's
19591 + tokens are depleted (provided that its per-context
19592 + sched_hard flag is set).
19594 + Processes belonging to that context will not be able
19595 + to consume CPU resources again until a per-context
19596 + configured minimum of tokens has been reached.
19598 +config VSERVER_IDLETIME
19599 + bool "Avoid idle CPUs by skipping Time"
19600 + depends on VSERVER_HARDCPU
19603 + This option allows the scheduler to artificially
19604 + advance time (per cpu) when otherwise the idle
19605 + task would be scheduled, thus keeping the cpu
19606 + busy and sharing the available resources among
19607 + certain contexts.
19609 +config VSERVER_IDLELIMIT
19610 + bool "Limit the IDLE task"
19611 + depends on VSERVER_HARDCPU
19614 + Limit the idle slices, so the the next context
19615 + will be scheduled as soon as possible.
19617 + This might improve interactivity and latency, but
19618 + will also marginally increase scheduling overhead.
19621 + prompt "Persistent Inode Tagging"
19622 + default TAGGING_ID24
19624 + This adds persistent context information to filesystems
19625 + mounted with the tagxid option. Tagging is a requirement
19626 + for per-context disk limits and per-context quota.
19629 +config TAGGING_NONE
19632 + do not store per-context information in inodes.
19634 +config TAGGING_UID16
19635 + bool "UID16/GID32"
19637 + reduces UID to 16 bit, but leaves GID at 32 bit.
19639 +config TAGGING_GID16
19640 + bool "UID32/GID16"
19642 + reduces GID to 16 bit, but leaves UID at 32 bit.
19644 +config TAGGING_ID24
19645 + bool "UID24/GID24"
19647 + uses the upper 8bit from UID and GID for XID tagging
19648 + which leaves 24bit for UID/GID each, which should be
19649 + more than sufficient for normal use.
19651 +config TAGGING_INTERN
19652 + bool "UID32/GID32"
19654 + this uses otherwise reserved inode fields in the on
19655 + disk representation, which limits the use to a few
19656 + filesystems (currently ext2 and ext3)
19661 + bool "Tag NFSD User Auth and Files"
19664 + Enable this if you do want the in-kernel NFS
19665 + Server to use the tagging specified above.
19666 + (will require patched clients too)
19668 +config VSERVER_PRIVACY
19669 + bool "Honor Privacy Aspects of Guests"
19672 + When enabled, most context checks will disallow
19673 + access to structures assigned to a specific context,
19674 + like ptys or loop devices.
19676 +config VSERVER_CONTEXTS
19677 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
19679 + default "768" if 64BIT
19682 + This setting will optimize certain data structures
19683 + and memory allocations according to the expected
19686 + note: this is not a strict upper limit.
19688 +config VSERVER_WARN
19689 + bool "VServer Warnings"
19692 + This enables various runtime warnings, which will
19693 + notify about potential manipulation attempts or
19694 + resource shortage. It is generally considered to
19695 + be a good idea to have that enabled.
19697 +config VSERVER_DEBUG
19698 + bool "VServer Debugging Code"
19701 + Set this to yes if you want to be able to activate
19702 + debugging output at runtime. It adds a very small
19703 + overhead to all vserver related functions and
19704 + increases the kernel size by about 20k.
19706 +config VSERVER_HISTORY
19707 + bool "VServer History Tracing"
19708 + depends on VSERVER_DEBUG
19711 + Set this to yes if you want to record the history of
19712 + linux-vserver activities, so they can be replayed in
19713 + the event of a kernel panic or oops.
19715 +config VSERVER_HISTORY_SIZE
19716 + int "Per-CPU History Size (32-65536)"
19717 + depends on VSERVER_HISTORY
19721 + This allows you to specify the number of entries in
19722 + the per-CPU history buffer.
19724 +config VSERVER_MONITOR
19725 + bool "VServer Scheduling Monitor"
19726 + depends on VSERVER_DEBUG
19729 + Set this to yes if you want to record the scheduling
19730 + decisions, so that they can be relayed to userspace
19731 + for detailed analysis.
19733 +config VSERVER_MONITOR_SIZE
19734 + int "Per-CPU Monitor Queue Size (32-65536)"
19735 + depends on VSERVER_MONITOR
19739 + This allows you to specify the number of entries in
19740 + the per-CPU scheduling monitor buffer.
19742 +config VSERVER_MONITOR_SYNC
19743 + int "Per-CPU Monitor Sync Interval (0-65536)"
19744 + depends on VSERVER_MONITOR
19748 + This allows you to specify the interval in ticks
19749 + when a time sync entry is inserted.
19761 +config VSERVER_SECURITY
19763 + depends on SECURITY
19765 + select SECURITY_CAPABILITIES
19767 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/Makefile linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Makefile
19768 --- linux-2.6.22.10/kernel/vserver/Makefile 1970-01-01 01:00:00 +0100
19769 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Makefile 2007-10-11 01:10:22 +0200
19772 +# Makefile for the Linux vserver routines.
19776 +obj-y += vserver.o
19778 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
19779 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
19782 +vserver-$(CONFIG_INET) += inet.o
19783 +vserver-$(CONFIG_PROC_FS) += proc.o
19784 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
19785 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
19786 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
19787 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
19789 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cacct.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct.c
19790 --- linux-2.6.22.10/kernel/vserver/cacct.c 1970-01-01 01:00:00 +0100
19791 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct.c 2007-08-15 21:54:31 +0200
19794 + * linux/kernel/vserver/cacct.c
19796 + * Virtual Server: Context Accounting
19798 + * Copyright (C) 2006-2007 Herbert Pötzl
19800 + * V0.01 added accounting stats
19804 +#include <linux/types.h>
19805 +#include <linux/vs_context.h>
19806 +#include <linux/vserver/cacct_cmd.h>
19807 +#include <linux/vserver/cacct_int.h>
19809 +#include <asm/errno.h>
19810 +#include <asm/uaccess.h>
19813 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
19815 + struct vcmd_sock_stat_v0 vc_data;
19818 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19821 + field = vc_data.field;
19822 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
19825 + for (j = 0; j < 3; j++) {
19826 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
19827 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
19830 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19835 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cacct_init.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct_init.h
19836 --- linux-2.6.22.10/kernel/vserver/cacct_init.h 1970-01-01 01:00:00 +0100
19837 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct_init.h 2007-08-05 20:53:13 +0200
19841 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
19846 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
19847 + for (j = 0; j < 3; j++) {
19848 + atomic_set(&cacct->sock[i][j].count, 0);
19849 + atomic_set(&cacct->sock[i][j].total, 0);
19852 + for (i = 0; i < 8; i++)
19853 + atomic_set(&cacct->slab[i], 0);
19854 + for (i = 0; i < 5; i++)
19855 + for (j = 0; j < 4; j++)
19856 + atomic_set(&cacct->page[i][j], 0);
19859 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
19864 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cacct_proc.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct_proc.h
19865 --- linux-2.6.22.10/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00 +0100
19866 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct_proc.h 2007-08-05 20:53:13 +0200
19868 +#ifndef _VX_CACCT_PROC_H
19869 +#define _VX_CACCT_PROC_H
19871 +#include <linux/vserver/cacct_int.h>
19874 +#define VX_SOCKA_TOP \
19875 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
19877 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
19879 + int i, j, length = 0;
19880 + static char *type[VXA_SOCK_SIZE] = {
19881 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
19884 + length += sprintf(buffer + length, VX_SOCKA_TOP);
19885 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
19886 + length += sprintf(buffer + length, "%s:", type[i]);
19887 + for (j = 0; j < 3; j++) {
19888 + length += sprintf(buffer + length,
19889 + "\t%10lu/%-10lu",
19890 + vx_sock_count(cacct, i, j),
19891 + vx_sock_total(cacct, i, j));
19893 + buffer[length++] = '\n';
19896 + length += sprintf(buffer + length, "\n");
19897 + length += sprintf(buffer + length,
19898 + "slab:\t %8u %8u %8u %8u\n",
19899 + atomic_read(&cacct->slab[1]),
19900 + atomic_read(&cacct->slab[4]),
19901 + atomic_read(&cacct->slab[0]),
19902 + atomic_read(&cacct->slab[2]));
19904 + length += sprintf(buffer + length, "\n");
19905 + for (i = 0; i < 5; i++) {
19906 + length += sprintf(buffer + length,
19907 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
19908 + atomic_read(&cacct->page[i][0]),
19909 + atomic_read(&cacct->page[i][1]),
19910 + atomic_read(&cacct->page[i][2]),
19911 + atomic_read(&cacct->page[i][3]),
19912 + atomic_read(&cacct->page[i][4]),
19913 + atomic_read(&cacct->page[i][5]),
19914 + atomic_read(&cacct->page[i][6]),
19915 + atomic_read(&cacct->page[i][7]));
19920 +#endif /* _VX_CACCT_PROC_H */
19921 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/context.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/context.c
19922 --- linux-2.6.22.10/kernel/vserver/context.c 1970-01-01 01:00:00 +0100
19923 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/context.c 2007-10-05 14:54:36 +0200
19926 + * linux/kernel/vserver/context.c
19928 + * Virtual Server: Context Support
19930 + * Copyright (C) 2003-2007 Herbert Pötzl
19932 + * V0.01 context helper
19933 + * V0.02 vx_ctx_kill syscall command
19934 + * V0.03 replaced context_info calls
19935 + * V0.04 redesign of struct (de)alloc
19936 + * V0.05 rlimit basic implementation
19937 + * V0.06 task_xid and info commands
19938 + * V0.07 context flags and caps
19939 + * V0.08 switch to RCU based hash
19940 + * V0.09 revert to non RCU for now
19941 + * V0.10 and back to working RCU hash
19942 + * V0.11 and back to locking again
19943 + * V0.12 referenced context store
19944 + * V0.13 separate per cpu data
19945 + * V0.14 changed vcmds to vxi arg
19946 + * V0.15 added context stat
19947 + * V0.16 have __create claim() the vxi
19948 + * V0.17 removed older and legacy stuff
19952 +#include <linux/slab.h>
19953 +#include <linux/types.h>
19954 +#include <linux/pid_namespace.h>
19956 +#include <linux/vserver/context.h>
19957 +#include <linux/vserver/network.h>
19958 +#include <linux/vserver/debug.h>
19959 +#include <linux/vserver/limit.h>
19960 +#include <linux/vserver/limit_int.h>
19961 +#include <linux/vserver/space.h>
19963 +#include <linux/vs_context.h>
19964 +#include <linux/vs_limit.h>
19965 +#include <linux/vserver/context_cmd.h>
19967 +#include "cvirt_init.h"
19968 +#include "cacct_init.h"
19969 +#include "limit_init.h"
19970 +#include "sched_init.h"
19973 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
19974 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
19977 +/* now inactive context structures */
19979 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
19981 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
19984 +/* __alloc_vx_info()
19986 + * allocate an initialized vx_info struct
19987 + * doesn't make it visible (hash) */
19989 +static struct vx_info *__alloc_vx_info(xid_t xid)
19991 + struct vx_info *new = NULL;
19994 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
19996 + /* would this benefit from a slab cache? */
19997 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
20001 + memset(new, 0, sizeof(struct vx_info));
20003 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
20004 + if (!new->ptr_pc)
20007 + new->vx_id = xid;
20008 + INIT_HLIST_NODE(&new->vx_hlist);
20009 + atomic_set(&new->vx_usecnt, 0);
20010 + atomic_set(&new->vx_tasks, 0);
20011 + new->vx_parent = NULL;
20012 + new->vx_state = 0;
20013 + init_waitqueue_head(&new->vx_wait);
20015 + /* prepare reaper */
20016 + get_task_struct(init_pid_ns.child_reaper);
20017 + new->vx_reaper = init_pid_ns.child_reaper;
20018 + new->vx_badness_bias = 0;
20020 + /* rest of init goes here */
20021 + vx_info_init_limit(&new->limit);
20022 + vx_info_init_sched(&new->sched);
20023 + vx_info_init_cvirt(&new->cvirt);
20024 + vx_info_init_cacct(&new->cacct);
20026 + /* per cpu data structures */
20027 + for_each_possible_cpu(cpu) {
20028 + vx_info_init_sched_pc(
20029 + &vx_per_cpu(new, sched_pc, cpu), cpu);
20030 + vx_info_init_cvirt_pc(
20031 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
20034 + new->vx_flags = VXF_INIT_SET;
20035 + new->vx_bcaps = CAP_INIT_EFF_SET;
20036 + new->vx_ccaps = 0;
20037 + new->vx_cap_bset = cap_bset;
20039 + new->reboot_cmd = 0;
20040 + new->exit_code = 0;
20042 + new->vx_nsproxy = copy_nsproxy(current->nsproxy);
20044 + vxdprintk(VXD_CBIT(xid, 0),
20045 + "alloc_vx_info(%d) = %p", xid, new);
20046 + vxh_alloc_vx_info(new);
20047 + atomic_inc(&vx_global_ctotal);
20056 +/* __dealloc_vx_info()
20058 + * final disposal of vx_info */
20060 +static void __dealloc_vx_info(struct vx_info *vxi)
20064 + vxdprintk(VXD_CBIT(xid, 0),
20065 + "dealloc_vx_info(%p)", vxi);
20066 + vxh_dealloc_vx_info(vxi);
20070 + vx_info_exit_limit(&vxi->limit);
20071 + vx_info_exit_sched(&vxi->sched);
20072 + vx_info_exit_cvirt(&vxi->cvirt);
20073 + vx_info_exit_cacct(&vxi->cacct);
20075 + for_each_possible_cpu(cpu) {
20076 + vx_info_exit_sched_pc(
20077 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
20078 + vx_info_exit_cvirt_pc(
20079 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
20082 + vxi->vx_state |= VXS_RELEASED;
20085 + free_percpu(vxi->ptr_pc);
20088 + atomic_dec(&vx_global_ctotal);
20091 +static void __shutdown_vx_info(struct vx_info *vxi)
20093 + struct nsproxy *nsproxy;
20094 + struct fs_struct *fs;
20098 + vxi->vx_state |= VXS_SHUTDOWN;
20099 + vs_state_change(vxi, VSC_SHUTDOWN);
20101 + nsproxy = xchg(&vxi->vx_nsproxy, NULL);
20102 + fs = xchg(&vxi->vx_fs, NULL);
20105 + put_nsproxy(nsproxy);
20107 + put_fs_struct(fs);
20110 +/* exported stuff */
20112 +void free_vx_info(struct vx_info *vxi)
20114 + unsigned long flags;
20116 + /* check for reference counts first */
20117 + BUG_ON(atomic_read(&vxi->vx_usecnt));
20118 + BUG_ON(atomic_read(&vxi->vx_tasks));
20120 + /* context must not be hashed */
20121 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
20123 + /* context shutdown is mandatory */
20124 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
20126 + BUG_ON(vxi->vx_nsproxy);
20127 + BUG_ON(vxi->vx_fs);
20129 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
20130 + hlist_del(&vxi->vx_hlist);
20131 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
20133 + __dealloc_vx_info(vxi);
20137 +/* hash table for vx_info hash */
20139 +#define VX_HASH_SIZE 13
20141 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
20142 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
20144 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
20147 +static inline unsigned int __hashval(xid_t xid)
20149 + return (xid % VX_HASH_SIZE);
20154 +/* __hash_vx_info()
20156 + * add the vxi to the global hash table
20157 + * requires the hash_lock to be held */
20159 +static inline void __hash_vx_info(struct vx_info *vxi)
20161 + struct hlist_head *head;
20163 + vxd_assert_lock(&vx_info_hash_lock);
20164 + vxdprintk(VXD_CBIT(xid, 4),
20165 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
20166 + vxh_hash_vx_info(vxi);
20168 + /* context must not be hashed */
20169 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
20171 + vxi->vx_state |= VXS_HASHED;
20172 + head = &vx_info_hash[__hashval(vxi->vx_id)];
20173 + hlist_add_head(&vxi->vx_hlist, head);
20174 + atomic_inc(&vx_global_cactive);
20177 +/* __unhash_vx_info()
20179 + * remove the vxi from the global hash table
20180 + * requires the hash_lock to be held */
20182 +static inline void __unhash_vx_info(struct vx_info *vxi)
20184 + unsigned long flags;
20186 + vxd_assert_lock(&vx_info_hash_lock);
20187 + vxdprintk(VXD_CBIT(xid, 4),
20188 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
20189 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
20190 + vxh_unhash_vx_info(vxi);
20192 + /* context must be hashed */
20193 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
20194 + /* but without tasks */
20195 + BUG_ON(atomic_read(&vxi->vx_tasks));
20197 + vxi->vx_state &= ~VXS_HASHED;
20198 + hlist_del_init(&vxi->vx_hlist);
20199 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
20200 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
20201 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
20202 + atomic_dec(&vx_global_cactive);
20206 +/* __lookup_vx_info()
20208 + * requires the hash_lock to be held
20209 + * doesn't increment the vx_refcnt */
20211 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
20213 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
20214 + struct hlist_node *pos;
20215 + struct vx_info *vxi;
20217 + vxd_assert_lock(&vx_info_hash_lock);
20218 + hlist_for_each(pos, head) {
20219 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
20221 + if (vxi->vx_id == xid)
20226 + vxdprintk(VXD_CBIT(xid, 0),
20227 + "__lookup_vx_info(#%u): %p[#%u]",
20228 + xid, vxi, vxi ? vxi->vx_id : 0);
20229 + vxh_lookup_vx_info(vxi, xid);
20234 +/* __create_vx_info()
20236 + * create the requested context
20237 + * get(), claim() and hash it */
20239 +static struct vx_info *__create_vx_info(int id)
20241 + struct vx_info *new, *vxi = NULL;
20243 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
20245 + if (!(new = __alloc_vx_info(id)))
20246 + return ERR_PTR(-ENOMEM);
20248 + /* required to make dynamic xids unique */
20249 + spin_lock(&vx_info_hash_lock);
20251 + /* static context requested */
20252 + if ((vxi = __lookup_vx_info(id))) {
20253 + vxdprintk(VXD_CBIT(xid, 0),
20254 + "create_vx_info(%d) = %p (already there)", id, vxi);
20255 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
20256 + vxi = ERR_PTR(-EBUSY);
20258 + vxi = ERR_PTR(-EEXIST);
20261 + /* new context */
20262 + vxdprintk(VXD_CBIT(xid, 0),
20263 + "create_vx_info(%d) = %p (new)", id, new);
20264 + claim_vx_info(new, NULL);
20265 + __hash_vx_info(get_vx_info(new));
20266 + vxi = new, new = NULL;
20269 + spin_unlock(&vx_info_hash_lock);
20270 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
20272 + __dealloc_vx_info(new);
20277 +/* exported stuff */
20280 +void unhash_vx_info(struct vx_info *vxi)
20282 + __shutdown_vx_info(vxi);
20283 + spin_lock(&vx_info_hash_lock);
20284 + __unhash_vx_info(vxi);
20285 + spin_unlock(&vx_info_hash_lock);
20286 + __wakeup_vx_info(vxi);
20290 +/* lookup_vx_info()
20292 + * search for a vx_info and get() it
20293 + * negative id means current */
20295 +struct vx_info *lookup_vx_info(int id)
20297 + struct vx_info *vxi = NULL;
20300 + vxi = get_vx_info(current->vx_info);
20301 + } else if (id > 1) {
20302 + spin_lock(&vx_info_hash_lock);
20303 + vxi = get_vx_info(__lookup_vx_info(id));
20304 + spin_unlock(&vx_info_hash_lock);
20309 +/* xid_is_hashed()
20311 + * verify that xid is still hashed */
20313 +int xid_is_hashed(xid_t xid)
20317 + spin_lock(&vx_info_hash_lock);
20318 + hashed = (__lookup_vx_info(xid) != NULL);
20319 + spin_unlock(&vx_info_hash_lock);
20323 +#ifdef CONFIG_PROC_FS
20327 + * get a subset of hashed xids for proc
20328 + * assumes size is at least one */
20330 +int get_xid_list(int index, unsigned int *xids, int size)
20332 + int hindex, nr_xids = 0;
20334 + /* only show current and children */
20335 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
20338 + xids[nr_xids] = vx_current_xid();
20342 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
20343 + struct hlist_head *head = &vx_info_hash[hindex];
20344 + struct hlist_node *pos;
20346 + spin_lock(&vx_info_hash_lock);
20347 + hlist_for_each(pos, head) {
20348 + struct vx_info *vxi;
20353 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
20354 + xids[nr_xids] = vxi->vx_id;
20355 + if (++nr_xids >= size) {
20356 + spin_unlock(&vx_info_hash_lock);
20360 + /* keep the lock time short */
20361 + spin_unlock(&vx_info_hash_lock);
20368 +#ifdef CONFIG_VSERVER_DEBUG
20370 +void dump_vx_info_inactive(int level)
20372 + struct hlist_node *entry, *next;
20374 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
20375 + struct vx_info *vxi =
20376 + list_entry(entry, struct vx_info, vx_hlist);
20378 + dump_vx_info(vxi, level);
20384 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
20386 + struct user_struct *new_user, *old_user;
20391 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
20394 + new_user = alloc_uid(vxi->vx_id, p->uid);
20398 + old_user = p->user;
20399 + if (new_user != old_user) {
20400 + atomic_inc(&new_user->processes);
20401 + atomic_dec(&old_user->processes);
20402 + p->user = new_user;
20404 + free_uid(old_user);
20408 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
20410 + p->cap_effective &= vxi->vx_cap_bset;
20411 + p->cap_inheritable &= vxi->vx_cap_bset;
20412 + p->cap_permitted &= vxi->vx_cap_bset;
20416 +#include <linux/file.h>
20418 +static int vx_openfd_task(struct task_struct *tsk)
20420 + struct files_struct *files = tsk->files;
20421 + struct fdtable *fdt;
20422 + const unsigned long *bptr;
20423 + int count, total;
20425 + /* no rcu_read_lock() because of spin_lock() */
20426 + spin_lock(&files->file_lock);
20427 + fdt = files_fdtable(files);
20428 + bptr = fdt->open_fds->fds_bits;
20429 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
20430 + for (total = 0; count > 0; count--) {
20432 + total += hweight_long(*bptr);
20435 + spin_unlock(&files->file_lock);
20440 +/* for *space compatibility */
20442 +asmlinkage long sys_unshare(unsigned long);
20445 + * migrate task to new context
20446 + * gets vxi, puts old_vxi on change
20447 + * optionally unshares namespaces (hack)
20450 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
20452 + struct vx_info *old_vxi;
20458 + vxdprintk(VXD_CBIT(xid, 5),
20459 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
20460 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
20462 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
20463 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
20466 + if (vx_info_state(vxi, VXS_SHUTDOWN))
20469 + old_vxi = task_get_vx_info(p);
20470 + if (old_vxi == vxi)
20473 + if (!(ret = vx_migrate_user(p, vxi))) {
20477 + openfd = vx_openfd_task(p);
20480 + atomic_dec(&old_vxi->cvirt.nr_threads);
20481 + atomic_dec(&old_vxi->cvirt.nr_running);
20482 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
20483 + /* FIXME: what about the struct files here? */
20484 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
20485 + /* account for the executable */
20486 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
20488 + atomic_inc(&vxi->cvirt.nr_threads);
20489 + atomic_inc(&vxi->cvirt.nr_running);
20490 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
20491 + /* FIXME: what about the struct files here? */
20492 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
20493 + /* account for the executable */
20494 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
20497 + release_vx_info(old_vxi, p);
20498 + clr_vx_info(&p->vx_info);
20500 + claim_vx_info(vxi, p);
20501 + set_vx_info(&p->vx_info, vxi);
20502 + p->xid = vxi->vx_id;
20504 + vxdprintk(VXD_CBIT(xid, 5),
20505 + "moved task %p into vxi:%p[#%d]",
20506 + p, vxi, vxi->vx_id);
20508 + vx_mask_cap_bset(vxi, p);
20511 + /* hack for *spaces to provide compatibility */
20513 + struct nsproxy *old_nsp, *new_nsp;
20515 + ret = unshare_nsproxy_namespaces(
20516 + CLONE_NEWUTS | CLONE_NEWIPC,
20521 + old_nsp = xchg(&p->nsproxy, new_nsp);
20522 + vx_set_space(vxi, CLONE_NEWUTS | CLONE_NEWIPC);
20523 + put_nsproxy(old_nsp);
20527 + put_vx_info(old_vxi);
20531 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
20533 + struct task_struct *old_reaper;
20538 + vxdprintk(VXD_CBIT(xid, 6),
20539 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
20540 + vxi, vxi->vx_id, p, p->xid, p->pid);
20542 + old_reaper = vxi->vx_reaper;
20543 + if (old_reaper == p)
20546 + /* set new child reaper */
20547 + get_task_struct(p);
20548 + vxi->vx_reaper = p;
20549 + put_task_struct(old_reaper);
20553 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
20558 + vxdprintk(VXD_CBIT(xid, 6),
20559 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
20560 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
20562 + vxi->vx_flags &= ~VXF_STATE_INIT;
20563 + vxi->vx_initpid = p->tgid;
20567 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
20569 + vxdprintk(VXD_CBIT(xid, 6),
20570 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
20571 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
20573 + vxi->exit_code = code;
20574 + vxi->vx_initpid = 0;
20578 +void vx_set_persistent(struct vx_info *vxi)
20580 + vxdprintk(VXD_CBIT(xid, 6),
20581 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
20583 + get_vx_info(vxi);
20584 + claim_vx_info(vxi, NULL);
20587 +void vx_clear_persistent(struct vx_info *vxi)
20589 + vxdprintk(VXD_CBIT(xid, 6),
20590 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
20592 + release_vx_info(vxi, NULL);
20593 + put_vx_info(vxi);
20596 +void vx_update_persistent(struct vx_info *vxi)
20598 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
20599 + vx_set_persistent(vxi);
20601 + vx_clear_persistent(vxi);
20605 +/* task must be current or locked */
20607 +void exit_vx_info(struct task_struct *p, int code)
20609 + struct vx_info *vxi = p->vx_info;
20612 + atomic_dec(&vxi->cvirt.nr_threads);
20615 + vxi->exit_code = code;
20616 + release_vx_info(vxi, p);
20620 +void exit_vx_info_early(struct task_struct *p, int code)
20622 + struct vx_info *vxi = p->vx_info;
20625 + if (vxi->vx_initpid == p->tgid)
20626 + vx_exit_init(vxi, p, code);
20627 + if (vxi->vx_reaper == p)
20628 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
20633 +/* vserver syscall commands below here */
20635 +/* taks xid and vx_info functions */
20637 +#include <asm/uaccess.h>
20640 +int vc_task_xid(uint32_t id)
20645 + struct task_struct *tsk;
20647 + read_lock(&tasklist_lock);
20648 + tsk = find_task_by_real_pid(id);
20649 + xid = (tsk) ? tsk->xid : -ESRCH;
20650 + read_unlock(&tasklist_lock);
20652 + xid = vx_current_xid();
20657 +int vc_vx_info(struct vx_info *vxi, void __user *data)
20659 + struct vcmd_vx_info_v0 vc_data;
20661 + vc_data.xid = vxi->vx_id;
20662 + vc_data.initpid = vxi->vx_initpid;
20664 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20670 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
20672 + struct vcmd_ctx_stat_v0 vc_data;
20674 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
20675 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
20677 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20683 +/* context functions */
20685 +int vc_ctx_create(uint32_t xid, void __user *data)
20687 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
20688 + struct vx_info *new_vxi;
20691 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20694 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
20697 + new_vxi = __create_vx_info(xid);
20698 + if (IS_ERR(new_vxi))
20699 + return PTR_ERR(new_vxi);
20701 + /* initial flags */
20702 + new_vxi->vx_flags = vc_data.flagword;
20705 + if (vs_state_change(new_vxi, VSC_STARTUP))
20708 + ret = vx_migrate_task(current, new_vxi, (!data));
20712 + /* return context id on success */
20713 + ret = new_vxi->vx_id;
20715 + /* get a reference for persistent contexts */
20716 + if ((vc_data.flagword & VXF_PERSISTENT))
20717 + vx_set_persistent(new_vxi);
20719 + release_vx_info(new_vxi, NULL);
20720 + put_vx_info(new_vxi);
20725 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
20727 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
20730 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20733 + ret = vx_migrate_task(current, vxi, 0);
20736 + if (vc_data.flagword & VXM_SET_INIT)
20737 + ret = vx_set_init(vxi, current);
20740 + if (vc_data.flagword & VXM_SET_REAPER)
20741 + ret = vx_set_reaper(vxi, current);
20746 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
20748 + struct vcmd_ctx_flags_v0 vc_data;
20750 + vc_data.flagword = vxi->vx_flags;
20752 + /* special STATE flag handling */
20753 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
20755 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20760 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
20762 + struct vcmd_ctx_flags_v0 vc_data;
20763 + uint64_t mask, trigger;
20765 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20768 + /* special STATE flag handling */
20769 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
20770 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
20772 + if (vxi == current->vx_info) {
20773 + if (trigger & VXF_STATE_SETUP)
20774 + vx_mask_cap_bset(vxi, current);
20775 + if (trigger & VXF_STATE_INIT) {
20778 + ret = vx_set_init(vxi, current);
20781 + ret = vx_set_reaper(vxi, current);
20787 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
20788 + vc_data.flagword, mask);
20789 + if (trigger & VXF_PERSISTENT)
20790 + vx_update_persistent(vxi);
20795 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
20798 + *bcaps = vxi->vx_bcaps;
20800 + *ccaps = vxi->vx_ccaps;
20805 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
20807 + struct vcmd_ctx_caps_v1 vc_data;
20810 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
20813 + vc_data.cmask = ~0ULL;
20815 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20820 +static int do_set_caps(struct vx_info *vxi,
20821 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
20823 + vxi->vx_bcaps = vs_mask_flags(vxi->vx_bcaps, bcaps, bmask);
20824 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
20829 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
20831 + struct vcmd_ctx_caps_v1 vc_data;
20833 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20836 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
20839 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
20841 + struct vcmd_bcaps vc_data;
20844 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
20847 + vc_data.bmask = ~0ULL;
20849 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20854 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
20856 + struct vcmd_bcaps vc_data;
20858 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20861 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
20865 +int vc_get_badness(struct vx_info *vxi, void __user *data)
20867 + struct vcmd_badness_v0 vc_data;
20869 + vc_data.bias = vxi->vx_badness_bias;
20871 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20876 +int vc_set_badness(struct vx_info *vxi, void __user *data)
20878 + struct vcmd_badness_v0 vc_data;
20880 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20883 + vxi->vx_badness_bias = vc_data.bias;
20887 +#include <linux/module.h>
20889 +EXPORT_SYMBOL_GPL(free_vx_info);
20891 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cvirt.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt.c
20892 --- linux-2.6.22.10/kernel/vserver/cvirt.c 1970-01-01 01:00:00 +0100
20893 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt.c 2007-08-15 22:00:34 +0200
20896 + * linux/kernel/vserver/cvirt.c
20898 + * Virtual Server: Context Virtualization
20900 + * Copyright (C) 2004-2007 Herbert Pötzl
20902 + * V0.01 broken out from limit.c
20903 + * V0.02 added utsname stuff
20904 + * V0.03 changed vcmds to vxi arg
20908 +#include <linux/types.h>
20909 +#include <linux/vs_cvirt.h>
20910 +#include <linux/vserver/switch.h>
20911 +#include <linux/vserver/cvirt_cmd.h>
20913 +#include <asm/uaccess.h>
20916 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
20918 + struct vx_info *vxi = current->vx_info;
20920 + set_normalized_timespec(uptime,
20921 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
20922 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
20925 + set_normalized_timespec(idle,
20926 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
20927 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
20931 +uint64_t vx_idle_jiffies(void)
20933 + return init_task.utime + init_task.stime;
20938 +static inline uint32_t __update_loadavg(uint32_t load,
20939 + int wsize, int delta, int n)
20941 + unsigned long long calc, prev;
20943 + /* just set it to n */
20944 + if (unlikely(delta >= wsize))
20945 + return (n << FSHIFT);
20947 + calc = delta * n;
20949 + prev = (wsize - delta);
20952 + do_div(calc, wsize);
20957 +void vx_update_load(struct vx_info *vxi)
20959 + uint32_t now, last, delta;
20960 + unsigned int nr_running, nr_uninterruptible;
20961 + unsigned int total;
20962 + unsigned long flags;
20964 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
20967 + last = vxi->cvirt.load_last;
20968 + delta = now - last;
20970 + if (delta < 5*HZ)
20973 + nr_running = atomic_read(&vxi->cvirt.nr_running);
20974 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
20975 + total = nr_running + nr_uninterruptible;
20977 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
20978 + 60*HZ, delta, total);
20979 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
20980 + 5*60*HZ, delta, total);
20981 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
20982 + 15*60*HZ, delta, total);
20984 + vxi->cvirt.load_last = now;
20986 + atomic_inc(&vxi->cvirt.load_updates);
20987 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
20992 + * Commands to do_syslog:
20994 + * 0 -- Close the log. Currently a NOP.
20995 + * 1 -- Open the log. Currently a NOP.
20996 + * 2 -- Read from the log.
20997 + * 3 -- Read all messages remaining in the ring buffer.
20998 + * 4 -- Read and clear all messages remaining in the ring buffer
20999 + * 5 -- Clear ring buffer.
21000 + * 6 -- Disable printk's to console
21001 + * 7 -- Enable printk's to console
21002 + * 8 -- Set level of messages printed to console
21003 + * 9 -- Return number of unread characters in the log buffer
21004 + * 10 -- Return size of the log buffer
21006 +int vx_do_syslog(int type, char __user *buf, int len)
21009 + int do_clear = 0;
21010 + struct vx_info *vxi = current->vx_info;
21011 + struct _vx_syslog *log;
21015 + log = &vxi->cvirt.syslog;
21018 + case 0: /* Close log */
21019 + case 1: /* Open log */
21021 + case 2: /* Read from log */
21022 + error = wait_event_interruptible(log->log_wait,
21023 + (log->log_start - log->log_end));
21026 + spin_lock_irq(&log->logbuf_lock);
21027 + spin_unlock_irq(&log->logbuf_lock);
21029 + case 4: /* Read/clear last kernel messages */
21031 + /* fall through */
21032 + case 3: /* Read last kernel messages */
21035 + case 5: /* Clear ring buffer */
21038 + case 6: /* Disable logging to console */
21039 + case 7: /* Enable logging to console */
21040 + case 8: /* Set level of messages printed to console */
21043 + case 9: /* Number of chars in the log buffer */
21045 + case 10: /* Size of the log buffer */
21055 +/* virtual host info names */
21057 +static char *vx_vhi_name(struct vx_info *vxi, int id)
21059 + struct nsproxy *nsproxy;
21060 + struct uts_namespace *uts;
21063 + if (id == VHIN_CONTEXT)
21064 + return vxi->vx_name;
21066 + nsproxy = vxi->vx_nsproxy;
21070 + uts = nsproxy->uts_ns;
21075 + case VHIN_SYSNAME:
21076 + return uts->name.sysname;
21077 + case VHIN_NODENAME:
21078 + return uts->name.nodename;
21079 + case VHIN_RELEASE:
21080 + return uts->name.release;
21081 + case VHIN_VERSION:
21082 + return uts->name.version;
21083 + case VHIN_MACHINE:
21084 + return uts->name.machine;
21085 + case VHIN_DOMAINNAME:
21086 + return uts->name.domainname;
21093 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
21095 + struct vcmd_vhi_name_v0 vc_data;
21098 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21101 + name = vx_vhi_name(vxi, vc_data.field);
21105 + memcpy(name, vc_data.name, 65);
21109 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
21111 + struct vcmd_vhi_name_v0 vc_data;
21114 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21117 + name = vx_vhi_name(vxi, vc_data.field);
21121 + memcpy(vc_data.name, name, 65);
21122 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21128 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
21130 + struct vcmd_virt_stat_v0 vc_data;
21131 + struct _vx_cvirt *cvirt = &vxi->cvirt;
21132 + struct timespec uptime;
21134 + do_posix_clock_monotonic_gettime(&uptime);
21135 + set_normalized_timespec(&uptime,
21136 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
21137 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
21139 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
21140 + vc_data.uptime = timespec_to_ns(&uptime);
21141 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
21142 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
21143 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
21144 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
21145 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
21146 + vc_data.load[0] = cvirt->load[0];
21147 + vc_data.load[1] = cvirt->load[1];
21148 + vc_data.load[2] = cvirt->load[2];
21150 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21156 +#ifdef CONFIG_VSERVER_VTIME
21158 +/* virtualized time base */
21160 +void vx_gettimeofday(struct timeval *tv)
21162 + do_gettimeofday(tv);
21163 + if (!vx_flags(VXF_VIRT_TIME, 0))
21166 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
21167 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
21169 + if (tv->tv_usec >= USEC_PER_SEC) {
21171 + tv->tv_usec -= USEC_PER_SEC;
21172 + } else if (tv->tv_usec < 0) {
21174 + tv->tv_usec += USEC_PER_SEC;
21178 +int vx_settimeofday(struct timespec *ts)
21180 + struct timeval tv;
21182 + if (!vx_flags(VXF_VIRT_TIME, 0))
21183 + return do_settimeofday(ts);
21185 + do_gettimeofday(&tv);
21186 + current->vx_info->cvirt.bias_tv.tv_sec =
21187 + ts->tv_sec - tv.tv_sec;
21188 + current->vx_info->cvirt.bias_tv.tv_usec =
21189 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
21195 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cvirt_init.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt_init.h
21196 --- linux-2.6.22.10/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00 +0100
21197 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt_init.h 2007-10-25 17:05:55 +0200
21201 +extern uint64_t vx_idle_jiffies(void);
21203 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
21205 + uint64_t idle_jiffies = vx_idle_jiffies();
21206 + uint64_t nsuptime;
21208 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
21209 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
21210 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
21211 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
21212 + cvirt->bias_tv.tv_sec = 0;
21213 + cvirt->bias_tv.tv_usec = 0;
21215 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
21216 + atomic_set(&cvirt->nr_threads, 0);
21217 + atomic_set(&cvirt->nr_running, 0);
21218 + atomic_set(&cvirt->nr_uninterruptible, 0);
21219 + atomic_set(&cvirt->nr_onhold, 0);
21221 + spin_lock_init(&cvirt->load_lock);
21222 + cvirt->load_last = jiffies;
21223 + atomic_set(&cvirt->load_updates, 0);
21224 + cvirt->load[0] = 0;
21225 + cvirt->load[1] = 0;
21226 + cvirt->load[2] = 0;
21227 + atomic_set(&cvirt->total_forks, 0);
21229 + spin_lock_init(&cvirt->syslog.logbuf_lock);
21230 + init_waitqueue_head(&cvirt->syslog.log_wait);
21231 + cvirt->syslog.log_start = 0;
21232 + cvirt->syslog.log_end = 0;
21233 + cvirt->syslog.con_start = 0;
21234 + cvirt->syslog.logged_chars = 0;
21238 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
21240 + // cvirt_pc->cpustat = { 0 };
21243 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
21247 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
21248 + "!!! cvirt: %p[nr_threads] = %d on exit.",
21250 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
21251 + "!!! cvirt: %p[nr_running] = %d on exit.",
21253 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
21254 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
21256 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
21257 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
21263 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
21268 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/cvirt_proc.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt_proc.h
21269 --- linux-2.6.22.10/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00 +0100
21270 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt_proc.h 2007-08-05 20:53:13 +0200
21272 +#ifndef _VX_CVIRT_PROC_H
21273 +#define _VX_CVIRT_PROC_H
21275 +#include <linux/nsproxy.h>
21276 +#include <linux/mnt_namespace.h>
21277 +#include <linux/utsname.h>
21278 +#include <linux/ipc.h>
21282 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
21284 + struct mnt_namespace *ns;
21285 + struct uts_namespace *uts;
21286 + struct ipc_namespace *ipc;
21287 + struct vfsmount *mnt;
21288 + char *path, *root;
21294 + length += sprintf(buffer + length,
21295 + "NSProxy:\t%p [%p,%p,%p]\n",
21296 + nsproxy, nsproxy->mnt_ns,
21297 + nsproxy->uts_ns, nsproxy->ipc_ns);
21299 + ns = nsproxy->mnt_ns;
21303 + path = kmalloc(PATH_MAX, GFP_KERNEL);
21308 + root = d_path(mnt->mnt_root, mnt->mnt_parent, path, PATH_MAX - 2);
21309 + length += sprintf(buffer + length,
21310 + "Namespace:\t%p [#%u]\n"
21311 + "RootPath:\t%s\n",
21312 + ns, atomic_read(&ns->count),
21317 + uts = nsproxy->uts_ns;
21321 + length += sprintf(buffer + length,
21322 + "SysName:\t%.*s\n"
21323 + "NodeName:\t%.*s\n"
21324 + "Release:\t%.*s\n"
21325 + "Version:\t%.*s\n"
21326 + "Machine:\t%.*s\n"
21327 + "DomainName:\t%.*s\n",
21328 + __NEW_UTS_LEN, uts->name.sysname,
21329 + __NEW_UTS_LEN, uts->name.nodename,
21330 + __NEW_UTS_LEN, uts->name.release,
21331 + __NEW_UTS_LEN, uts->name.version,
21332 + __NEW_UTS_LEN, uts->name.machine,
21333 + __NEW_UTS_LEN, uts->name.domainname);
21336 + ipc = nsproxy->ipc_ns;
21340 + length += sprintf(buffer + length,
21341 + "SEMS:\t\t%d %d %d %d %d\n"
21342 + "MSG:\t\t%d %d %d\n"
21343 + "SHM:\t\t%lu %lu %d %d\n",
21344 + ipc->sem_ctls[0], ipc->sem_ctls[1],
21345 + ipc->sem_ctls[2], ipc->sem_ctls[3],
21347 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
21348 + (unsigned long)ipc->shm_ctlmax,
21349 + (unsigned long)ipc->shm_ctlall,
21350 + ipc->shm_ctlmni, ipc->shm_tot);
21357 +#include <linux/sched.h>
21359 +#define LOAD_INT(x) ((x) >> FSHIFT)
21360 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
21363 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
21368 + length += sprintf(buffer + length,
21369 + "BiasUptime:\t%lu.%02lu\n",
21370 + (unsigned long)cvirt->bias_uptime.tv_sec,
21371 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
21373 + a = cvirt->load[0] + (FIXED_1 / 200);
21374 + b = cvirt->load[1] + (FIXED_1 / 200);
21375 + c = cvirt->load[2] + (FIXED_1 / 200);
21376 + length += sprintf(buffer + length,
21377 + "nr_threads:\t%d\n"
21378 + "nr_running:\t%d\n"
21379 + "nr_unintr:\t%d\n"
21380 + "nr_onhold:\t%d\n"
21381 + "load_updates:\t%d\n"
21382 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
21383 + "total_forks:\t%d\n",
21384 + atomic_read(&cvirt->nr_threads),
21385 + atomic_read(&cvirt->nr_running),
21386 + atomic_read(&cvirt->nr_uninterruptible),
21387 + atomic_read(&cvirt->nr_onhold),
21388 + atomic_read(&cvirt->load_updates),
21389 + LOAD_INT(a), LOAD_FRAC(a),
21390 + LOAD_INT(b), LOAD_FRAC(b),
21391 + LOAD_INT(c), LOAD_FRAC(c),
21392 + atomic_read(&cvirt->total_forks));
21397 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
21398 + char *buffer, int cpu)
21404 +#endif /* _VX_CVIRT_PROC_H */
21405 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/debug.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/debug.c
21406 --- linux-2.6.22.10/kernel/vserver/debug.c 1970-01-01 01:00:00 +0100
21407 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/debug.c 2007-10-01 14:57:41 +0200
21410 + * kernel/vserver/debug.c
21412 + * Copyright (C) 2005-2007 Herbert Pötzl
21414 + * V0.01 vx_info dump support
21418 +#include <linux/module.h>
21420 +#include <linux/vserver/context.h>
21423 +void dump_vx_info(struct vx_info *vxi, int level)
21425 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
21426 + atomic_read(&vxi->vx_usecnt),
21427 + atomic_read(&vxi->vx_tasks),
21430 + __dump_vx_limit(&vxi->limit);
21431 + __dump_vx_sched(&vxi->sched);
21432 + __dump_vx_cvirt(&vxi->cvirt);
21433 + __dump_vx_cacct(&vxi->cacct);
21439 +EXPORT_SYMBOL_GPL(dump_vx_info);
21441 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/device.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/device.c
21442 --- linux-2.6.22.10/kernel/vserver/device.c 1970-01-01 01:00:00 +0100
21443 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/device.c 2007-10-11 01:10:22 +0200
21446 + * linux/kernel/vserver/device.c
21448 + * Linux-VServer: Device Support
21450 + * Copyright (C) 2006 Herbert Pötzl
21451 + * Copyright (C) 2007 Daniel Hokka Zakrisson
21453 + * V0.01 device mapping basics
21454 + * V0.02 added defaults
21458 +#include <linux/slab.h>
21459 +#include <linux/rcupdate.h>
21460 +#include <linux/fs.h>
21461 +#include <linux/namei.h>
21462 +#include <linux/hash.h>
21464 +#include <asm/errno.h>
21465 +#include <asm/uaccess.h>
21466 +#include <linux/vserver/base.h>
21467 +#include <linux/vserver/debug.h>
21468 +#include <linux/vserver/context.h>
21469 +#include <linux/vserver/device.h>
21470 +#include <linux/vserver/device_cmd.h>
21473 +#define DMAP_HASH_BITS 4
21476 +struct vs_mapping {
21478 + struct hlist_node hlist;
21479 + struct list_head list;
21481 +#define dm_hlist u.hlist
21482 +#define dm_list u.list
21485 + struct vx_dmap_target target;
21489 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
21491 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
21493 +static struct vx_dmap_target dmap_defaults[2] = {
21494 + { .flags = DATTR_OPEN },
21495 + { .flags = DATTR_OPEN },
21499 +struct kmem_cache *dmap_cachep __read_mostly;
21501 +int __init dmap_cache_init(void)
21503 + dmap_cachep = kmem_cache_create("dmap_cache",
21504 + sizeof(struct vs_mapping), 0,
21505 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
21509 +__initcall(dmap_cache_init);
21512 +static inline unsigned int __hashval(dev_t dev, int bits)
21514 + return hash_long((unsigned long)dev, bits);
21518 +/* __hash_mapping()
21519 + * add the mapping to the hash table
21521 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
21523 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21524 + struct hlist_head *head, *hash = dmap_main_hash;
21525 + int device = vdm->device;
21527 + spin_lock(hash_lock);
21528 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
21529 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
21531 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
21532 + hlist_add_head(&vdm->dm_hlist, head);
21533 + spin_unlock(hash_lock);
21537 +static inline int __mode_to_default(umode_t mode)
21550 +/* __set_default()
21553 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
21554 + struct vx_dmap_target *vdmt)
21556 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21557 + spin_lock(hash_lock);
21560 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
21562 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
21565 + spin_unlock(hash_lock);
21567 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
21568 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
21572 +/* __remove_default()
21573 + * remove a default
21575 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
21577 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21578 + spin_lock(hash_lock);
21581 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
21582 + else /* remove == reset */
21583 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
21585 + spin_unlock(hash_lock);
21590 +/* __find_mapping()
21591 + * find a mapping in the hash table
21593 + * caller must hold hash_lock
21595 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
21596 + struct vs_mapping **local, struct vs_mapping **global)
21598 + struct hlist_head *hash = dmap_main_hash;
21599 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
21600 + struct hlist_node *pos;
21601 + struct vs_mapping *vdm;
21607 + hlist_for_each(pos, head) {
21608 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
21610 + if ((vdm->device == device) &&
21611 + !((vdm->target.flags ^ mode) & S_IFMT)) {
21612 + if (vdm->xid == xid) {
21615 + } else if (global && vdm->xid == 0)
21620 + if (global && *global)
21627 +/* __lookup_mapping()
21628 + * find a mapping and store the result in target and flags
21630 +static inline int __lookup_mapping(struct vx_info *vxi,
21631 + dev_t device, dev_t *target, int *flags, umode_t mode)
21633 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21634 + struct vs_mapping *vdm, *global;
21635 + struct vx_dmap_target *vdmt;
21637 + xid_t xid = vxi->vx_id;
21640 + spin_lock(hash_lock);
21641 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
21643 + vdmt = &vdm->target;
21647 + index = __mode_to_default(mode);
21648 + if (vxi && vxi->dmap.targets[index].flags) {
21650 + vdmt = &vxi->dmap.targets[index];
21651 + } else if (global) {
21653 + vdmt = &global->target;
21657 + vdmt = &dmap_defaults[index];
21661 + if (target && (vdmt->flags & DATTR_REMAP))
21662 + *target = vdmt->target;
21664 + *target = device;
21666 + *flags = vdmt->flags;
21668 + spin_unlock(hash_lock);
21674 +/* __remove_mapping()
21675 + * remove a mapping from the hash table
21677 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
21680 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21681 + struct vs_mapping *vdm = NULL;
21684 + spin_lock(hash_lock);
21686 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
21688 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
21689 + vxi, vxi ? vxi->vx_id : 0, device, mode);
21692 + hlist_del(&vdm->dm_hlist);
21695 + spin_unlock(hash_lock);
21697 + kmem_cache_free(dmap_cachep, vdm);
21703 +int vs_map_device(struct vx_info *vxi,
21704 + dev_t device, dev_t *target, umode_t mode)
21706 + int ret, flags = DATTR_MASK;
21710 + *target = device;
21713 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
21714 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
21715 + device, target ? *target : 0, flags, mode, ret);
21717 + return (flags & DATTR_MASK);
21722 +static int do_set_mapping(struct vx_info *vxi,
21723 + dev_t device, dev_t target, int flags, umode_t mode)
21726 + struct vs_mapping *new;
21728 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
21732 + INIT_HLIST_NODE(&new->dm_hlist);
21733 + new->device = device;
21734 + new->target.target = target;
21735 + new->target.flags = flags | mode;
21736 + new->xid = (vxi ? vxi->vx_id : 0);
21738 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
21739 + __hash_mapping(vxi, new);
21741 + struct vx_dmap_target new = {
21742 + .target = target,
21743 + .flags = flags | mode,
21745 + __set_default(vxi, mode, &new);
21751 +static int do_unset_mapping(struct vx_info *vxi,
21752 + dev_t device, dev_t target, int flags, umode_t mode)
21754 + int ret = -EINVAL;
21757 + ret = __remove_mapping(vxi, device, mode);
21761 + ret = __remove_default(vxi, mode);
21771 +static inline int __user_device(const char __user *name, dev_t *dev,
21774 + struct nameidata nd;
21781 + ret = user_path_walk_link(name, &nd);
21784 + if (nd.dentry->d_inode) {
21785 + *dev = nd.dentry->d_inode->i_rdev;
21786 + *mode = nd.dentry->d_inode->i_mode;
21788 + path_release(&nd);
21792 +static inline int __mapping_mode(dev_t device, dev_t target,
21793 + umode_t device_mode, umode_t target_mode, umode_t *mode)
21796 + *mode = device_mode & S_IFMT;
21798 + *mode = target_mode & S_IFMT;
21802 + /* if both given, device and target mode have to match */
21803 + if (device && target &&
21804 + ((device_mode ^ target_mode) & S_IFMT))
21810 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
21811 + const char __user *target_path, int flags, int set)
21813 + dev_t device = ~0, target = ~0;
21814 + umode_t device_mode = 0, target_mode = 0, mode;
21817 + ret = __user_device(device_path, &device, &device_mode);
21820 + ret = __user_device(target_path, &target, &target_mode);
21824 + ret = __mapping_mode(device, target,
21825 + device_mode, target_mode, &mode);
21830 + return do_set_mapping(vxi, device, target,
21833 + return do_unset_mapping(vxi, device, target,
21838 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
21840 + struct vcmd_set_mapping_v0 vc_data;
21842 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21845 + return do_mapping(vxi, vc_data.device, vc_data.target,
21846 + vc_data.flags, 1);
21849 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
21851 + struct vcmd_set_mapping_v0 vc_data;
21853 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21856 + return do_mapping(vxi, vc_data.device, vc_data.target,
21857 + vc_data.flags, 0);
21861 +#ifdef CONFIG_COMPAT
21863 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
21865 + struct vcmd_set_mapping_v0_x32 vc_data;
21867 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21870 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
21871 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
21874 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
21876 + struct vcmd_set_mapping_v0_x32 vc_data;
21878 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21881 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
21882 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
21885 +#endif /* CONFIG_COMPAT */
21888 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/dlimit.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/dlimit.c
21889 --- linux-2.6.22.10/kernel/vserver/dlimit.c 1970-01-01 01:00:00 +0100
21890 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/dlimit.c 2007-08-15 22:07:58 +0200
21893 + * linux/kernel/vserver/dlimit.c
21895 + * Virtual Server: Context Disk Limits
21897 + * Copyright (C) 2004-2007 Herbert Pötzl
21899 + * V0.01 initial version
21900 + * V0.02 compat32 splitup
21904 +#include <linux/statfs.h>
21905 +#include <linux/vs_tag.h>
21906 +#include <linux/vs_dlimit.h>
21907 +#include <linux/vserver/dlimit_cmd.h>
21909 +#include <asm/uaccess.h>
21911 +/* __alloc_dl_info()
21913 + * allocate an initialized dl_info struct
21914 + * doesn't make it visible (hash) */
21916 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
21918 + struct dl_info *new = NULL;
21920 + vxdprintk(VXD_CBIT(dlim, 5),
21921 + "alloc_dl_info(%p,%d)*", sb, tag);
21923 + /* would this benefit from a slab cache? */
21924 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
21928 + memset(new, 0, sizeof(struct dl_info));
21929 + new->dl_tag = tag;
21931 + INIT_RCU_HEAD(&new->dl_rcu);
21932 + INIT_HLIST_NODE(&new->dl_hlist);
21933 + spin_lock_init(&new->dl_lock);
21934 + atomic_set(&new->dl_refcnt, 0);
21935 + atomic_set(&new->dl_usecnt, 0);
21937 + /* rest of init goes here */
21939 + vxdprintk(VXD_CBIT(dlim, 4),
21940 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
21944 +/* __dealloc_dl_info()
21946 + * final disposal of dl_info */
21948 +static void __dealloc_dl_info(struct dl_info *dli)
21950 + vxdprintk(VXD_CBIT(dlim, 4),
21951 + "dealloc_dl_info(%p)", dli);
21953 + dli->dl_hlist.next = LIST_POISON1;
21954 + dli->dl_tag = -1;
21957 + BUG_ON(atomic_read(&dli->dl_usecnt));
21958 + BUG_ON(atomic_read(&dli->dl_refcnt));
21964 +/* hash table for dl_info hash */
21966 +#define DL_HASH_SIZE 13
21968 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
21970 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
21973 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
21975 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
21980 +/* __hash_dl_info()
21982 + * add the dli to the global hash table
21983 + * requires the hash_lock to be held */
21985 +static inline void __hash_dl_info(struct dl_info *dli)
21987 + struct hlist_head *head;
21989 + vxdprintk(VXD_CBIT(dlim, 6),
21990 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
21991 + get_dl_info(dli);
21992 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
21993 + hlist_add_head_rcu(&dli->dl_hlist, head);
21996 +/* __unhash_dl_info()
21998 + * remove the dli from the global hash table
21999 + * requires the hash_lock to be held */
22001 +static inline void __unhash_dl_info(struct dl_info *dli)
22003 + vxdprintk(VXD_CBIT(dlim, 6),
22004 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
22005 + hlist_del_rcu(&dli->dl_hlist);
22006 + put_dl_info(dli);
22010 +/* __lookup_dl_info()
22012 + * requires the rcu_read_lock()
22013 + * doesn't increment the dl_refcnt */
22015 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
22017 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
22018 + struct hlist_node *pos;
22019 + struct dl_info *dli;
22021 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
22023 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
22031 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
22033 + struct dl_info *dli;
22036 + dli = get_dl_info(__lookup_dl_info(sb, tag));
22037 + vxdprintk(VXD_CBIT(dlim, 7),
22038 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
22039 + rcu_read_unlock();
22043 +void rcu_free_dl_info(struct rcu_head *head)
22045 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
22046 + int usecnt, refcnt;
22048 + BUG_ON(!dli || !head);
22050 + usecnt = atomic_read(&dli->dl_usecnt);
22051 + BUG_ON(usecnt < 0);
22053 + refcnt = atomic_read(&dli->dl_refcnt);
22054 + BUG_ON(refcnt < 0);
22056 + vxdprintk(VXD_CBIT(dlim, 3),
22057 + "rcu_free_dl_info(%p)", dli);
22059 + __dealloc_dl_info(dli);
22061 + printk("!!! rcu didn't free\n");
22067 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
22068 + uint32_t flags, int add)
22070 + struct nameidata nd;
22073 + ret = user_path_walk_link(name, &nd);
22075 + struct super_block *sb;
22076 + struct dl_info *dli;
22079 + if (!nd.dentry->d_inode)
22080 + goto out_release;
22081 + if (!(sb = nd.dentry->d_inode->i_sb))
22082 + goto out_release;
22085 + dli = __alloc_dl_info(sb, id);
22086 + spin_lock(&dl_info_hash_lock);
22089 + if (__lookup_dl_info(sb, id))
22091 + __hash_dl_info(dli);
22094 + spin_lock(&dl_info_hash_lock);
22095 + dli = __lookup_dl_info(sb, id);
22100 + __unhash_dl_info(dli);
22104 + spin_unlock(&dl_info_hash_lock);
22106 + __dealloc_dl_info(dli);
22108 + path_release(&nd);
22113 +int vc_add_dlimit(uint32_t id, void __user *data)
22115 + struct vcmd_ctx_dlimit_base_v0 vc_data;
22117 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22120 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
22123 +int vc_rem_dlimit(uint32_t id, void __user *data)
22125 + struct vcmd_ctx_dlimit_base_v0 vc_data;
22127 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22130 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
22133 +#ifdef CONFIG_COMPAT
22135 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
22137 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
22139 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22142 + return do_addrem_dlimit(id,
22143 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
22146 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
22148 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
22150 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22153 + return do_addrem_dlimit(id,
22154 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
22157 +#endif /* CONFIG_COMPAT */
22161 +int do_set_dlimit(uint32_t id, const char __user *name,
22162 + uint32_t space_used, uint32_t space_total,
22163 + uint32_t inodes_used, uint32_t inodes_total,
22164 + uint32_t reserved, uint32_t flags)
22166 + struct nameidata nd;
22169 + ret = user_path_walk_link(name, &nd);
22171 + struct super_block *sb;
22172 + struct dl_info *dli;
22175 + if (!nd.dentry->d_inode)
22176 + goto out_release;
22177 + if (!(sb = nd.dentry->d_inode->i_sb))
22178 + goto out_release;
22179 + if ((reserved != CDLIM_KEEP &&
22180 + reserved > 100) ||
22181 + (inodes_used != CDLIM_KEEP &&
22182 + inodes_used > inodes_total) ||
22183 + (space_used != CDLIM_KEEP &&
22184 + space_used > space_total))
22185 + goto out_release;
22188 + dli = locate_dl_info(sb, id);
22190 + goto out_release;
22192 + spin_lock(&dli->dl_lock);
22194 + if (inodes_used != CDLIM_KEEP)
22195 + dli->dl_inodes_used = inodes_used;
22196 + if (inodes_total != CDLIM_KEEP)
22197 + dli->dl_inodes_total = inodes_total;
22198 + if (space_used != CDLIM_KEEP) {
22199 + dli->dl_space_used = space_used;
22200 + dli->dl_space_used <<= 10;
22202 + if (space_total == CDLIM_INFINITY)
22203 + dli->dl_space_total = DLIM_INFINITY;
22204 + else if (space_total != CDLIM_KEEP) {
22205 + dli->dl_space_total = space_total;
22206 + dli->dl_space_total <<= 10;
22208 + if (reserved != CDLIM_KEEP)
22209 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
22211 + spin_unlock(&dli->dl_lock);
22213 + put_dl_info(dli);
22217 + path_release(&nd);
22222 +int vc_set_dlimit(uint32_t id, void __user *data)
22224 + struct vcmd_ctx_dlimit_v0 vc_data;
22226 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22229 + return do_set_dlimit(id, vc_data.name,
22230 + vc_data.space_used, vc_data.space_total,
22231 + vc_data.inodes_used, vc_data.inodes_total,
22232 + vc_data.reserved, vc_data.flags);
22235 +#ifdef CONFIG_COMPAT
22237 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
22239 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
22241 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22244 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
22245 + vc_data.space_used, vc_data.space_total,
22246 + vc_data.inodes_used, vc_data.inodes_total,
22247 + vc_data.reserved, vc_data.flags);
22250 +#endif /* CONFIG_COMPAT */
22254 +int do_get_dlimit(uint32_t id, const char __user *name,
22255 + uint32_t *space_used, uint32_t *space_total,
22256 + uint32_t *inodes_used, uint32_t *inodes_total,
22257 + uint32_t *reserved, uint32_t *flags)
22259 + struct nameidata nd;
22262 + ret = user_path_walk_link(name, &nd);
22264 + struct super_block *sb;
22265 + struct dl_info *dli;
22268 + if (!nd.dentry->d_inode)
22269 + goto out_release;
22270 + if (!(sb = nd.dentry->d_inode->i_sb))
22271 + goto out_release;
22274 + dli = locate_dl_info(sb, id);
22276 + goto out_release;
22278 + spin_lock(&dli->dl_lock);
22279 + *inodes_used = dli->dl_inodes_used;
22280 + *inodes_total = dli->dl_inodes_total;
22281 + *space_used = dli->dl_space_used >> 10;
22282 + if (dli->dl_space_total == DLIM_INFINITY)
22283 + *space_total = CDLIM_INFINITY;
22285 + *space_total = dli->dl_space_total >> 10;
22287 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
22288 + spin_unlock(&dli->dl_lock);
22290 + put_dl_info(dli);
22295 + path_release(&nd);
22301 +int vc_get_dlimit(uint32_t id, void __user *data)
22303 + struct vcmd_ctx_dlimit_v0 vc_data;
22306 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22309 + ret = do_get_dlimit(id, vc_data.name,
22310 + &vc_data.space_used, &vc_data.space_total,
22311 + &vc_data.inodes_used, &vc_data.inodes_total,
22312 + &vc_data.reserved, &vc_data.flags);
22316 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22321 +#ifdef CONFIG_COMPAT
22323 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
22325 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
22328 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22331 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
22332 + &vc_data.space_used, &vc_data.space_total,
22333 + &vc_data.inodes_used, &vc_data.inodes_total,
22334 + &vc_data.reserved, &vc_data.flags);
22338 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22343 +#endif /* CONFIG_COMPAT */
22346 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
22348 + struct dl_info *dli;
22349 + __u64 blimit, bfree, bavail;
22352 + dli = locate_dl_info(sb, dx_current_tag());
22356 + spin_lock(&dli->dl_lock);
22357 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
22360 + /* reduce max inodes available to limit */
22361 + if (buf->f_files > dli->dl_inodes_total)
22362 + buf->f_files = dli->dl_inodes_total;
22364 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
22365 + /* reduce free inodes to min */
22366 + if (ifree < buf->f_ffree)
22367 + buf->f_ffree = ifree;
22370 + if (dli->dl_space_total == DLIM_INFINITY)
22373 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
22375 + if (dli->dl_space_total < dli->dl_space_used)
22378 + bfree = (dli->dl_space_total - dli->dl_space_used)
22379 + >> sb->s_blocksize_bits;
22381 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
22382 + if (bavail < dli->dl_space_used)
22385 + bavail = (bavail - dli->dl_space_used)
22386 + >> sb->s_blocksize_bits;
22388 + /* reduce max space available to limit */
22389 + if (buf->f_blocks > blimit)
22390 + buf->f_blocks = blimit;
22392 + /* reduce free space to min */
22393 + if (bfree < buf->f_bfree)
22394 + buf->f_bfree = bfree;
22396 + /* reduce avail space to min */
22397 + if (bavail < buf->f_bavail)
22398 + buf->f_bavail = bavail;
22401 + spin_unlock(&dli->dl_lock);
22402 + put_dl_info(dli);
22407 +#include <linux/module.h>
22409 +EXPORT_SYMBOL_GPL(locate_dl_info);
22410 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
22412 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/helper.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/helper.c
22413 --- linux-2.6.22.10/kernel/vserver/helper.c 1970-01-01 01:00:00 +0100
22414 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/helper.c 2007-08-15 22:12:01 +0200
22417 + * linux/kernel/vserver/helper.c
22419 + * Virtual Context Support
22421 + * Copyright (C) 2004-2007 Herbert Pötzl
22423 + * V0.01 basic helper
22427 +#include <linux/kmod.h>
22428 +#include <linux/reboot.h>
22429 +#include <linux/vs_context.h>
22430 +#include <linux/vs_network.h>
22431 +#include <linux/vserver/signal.h>
22434 +char vshelper_path[255] = "/sbin/vshelper";
22437 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
22441 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
22442 + printk( KERN_WARNING
22443 + "%s: (%s %s) returned %s with %d\n",
22444 + name, argv[1], argv[2],
22445 + sync ? "sync" : "async", ret);
22447 + vxdprintk(VXD_CBIT(switch, 4),
22448 + "%s: (%s %s) returned %s with %d",
22449 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
22454 + * vshelper path is set via /proc/sys
22455 + * invoked by vserver sys_reboot(), with
22456 + * the following arguments
22458 + * argv [0] = vshelper_path;
22459 + * argv [1] = action: "restart", "halt", "poweroff", ...
22460 + * argv [2] = context identifier
22462 + * envp [*] = type-specific parameters
22465 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
22467 + char id_buf[8], cmd_buf[16];
22468 + char uid_buf[16], pid_buf[16];
22471 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22472 + char *envp[] = {"HOME=/", "TERM=linux",
22473 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
22474 + uid_buf, pid_buf, cmd_buf, 0};
22476 + if (vx_info_state(vxi, VXS_HELPER))
22478 + vxi->vx_state |= VXS_HELPER;
22480 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
22482 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22483 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
22484 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
22487 + case LINUX_REBOOT_CMD_RESTART:
22488 + argv[1] = "restart";
22491 + case LINUX_REBOOT_CMD_HALT:
22492 + argv[1] = "halt";
22495 + case LINUX_REBOOT_CMD_POWER_OFF:
22496 + argv[1] = "poweroff";
22499 + case LINUX_REBOOT_CMD_SW_SUSPEND:
22500 + argv[1] = "swsusp";
22504 + vxi->vx_state &= ~VXS_HELPER;
22508 + ret = do_vshelper(vshelper_path, argv, envp, 0);
22509 + vxi->vx_state &= ~VXS_HELPER;
22510 + __wakeup_vx_info(vxi);
22511 + return (ret) ? -EPERM : 0;
22515 +long vs_reboot(unsigned int cmd, void __user *arg)
22517 + struct vx_info *vxi = current->vx_info;
22520 + vxdprintk(VXD_CBIT(misc, 5),
22521 + "vs_reboot(%p[#%d],%d)",
22522 + vxi, vxi ? vxi->vx_id : 0, cmd);
22524 + ret = vs_reboot_helper(vxi, cmd, arg);
22528 + vxi->reboot_cmd = cmd;
22529 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
22531 + case LINUX_REBOOT_CMD_RESTART:
22532 + case LINUX_REBOOT_CMD_HALT:
22533 + case LINUX_REBOOT_CMD_POWER_OFF:
22534 + vx_info_kill(vxi, 0, SIGKILL);
22535 + vx_info_kill(vxi, 1, SIGKILL);
22545 + * argv [0] = vshelper_path;
22546 + * argv [1] = action: "startup", "shutdown"
22547 + * argv [2] = context identifier
22549 + * envp [*] = type-specific parameters
22552 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
22554 + char id_buf[8], cmd_buf[16];
22555 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22556 + char *envp[] = {"HOME=/", "TERM=linux",
22557 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
22559 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
22562 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
22563 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22566 + case VSC_STARTUP:
22567 + argv[1] = "startup";
22569 + case VSC_SHUTDOWN:
22570 + argv[1] = "shutdown";
22576 + return do_vshelper(vshelper_path, argv, envp, 1);
22581 + * argv [0] = vshelper_path;
22582 + * argv [1] = action: "netup", "netdown"
22583 + * argv [2] = context identifier
22585 + * envp [*] = type-specific parameters
22588 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
22590 + char id_buf[8], cmd_buf[16];
22591 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22592 + char *envp[] = {"HOME=/", "TERM=linux",
22593 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
22595 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
22598 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
22599 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22603 + argv[1] = "netup";
22605 + case VSC_NETDOWN:
22606 + argv[1] = "netdown";
22612 + return do_vshelper(vshelper_path, argv, envp, 1);
22615 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/history.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/history.c
22616 --- linux-2.6.22.10/kernel/vserver/history.c 1970-01-01 01:00:00 +0100
22617 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/history.c 2007-08-15 22:13:54 +0200
22620 + * kernel/vserver/history.c
22622 + * Virtual Context History Backtrace
22624 + * Copyright (C) 2004-2007 Herbert Pötzl
22626 + * V0.01 basic structure
22627 + * V0.02 hash/unhash and trace
22628 + * V0.03 preemption fixes
22632 +#include <linux/module.h>
22633 +#include <asm/uaccess.h>
22635 +#include <linux/vserver/context.h>
22636 +#include <linux/vserver/debug.h>
22637 +#include <linux/vserver/debug_cmd.h>
22638 +#include <linux/vserver/history.h>
22641 +#ifdef CONFIG_VSERVER_HISTORY
22642 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
22644 +#define VXH_SIZE 64
22647 +struct _vx_history {
22648 + unsigned int counter;
22650 + struct _vx_hist_entry entry[VXH_SIZE + 1];
22654 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
22656 +unsigned volatile int vxh_active = 1;
22658 +static atomic_t sequence = ATOMIC_INIT(0);
22663 + * requires disabled preemption */
22665 +struct _vx_hist_entry *vxh_advance(void *loc)
22667 + unsigned int cpu = smp_processor_id();
22668 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
22669 + struct _vx_hist_entry *entry;
22670 + unsigned int index;
22672 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
22673 + entry = &hist->entry[index];
22675 + entry->seq = atomic_inc_return(&sequence);
22676 + entry->loc = loc;
22680 +EXPORT_SYMBOL_GPL(vxh_advance);
22683 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
22685 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
22688 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
22690 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
22691 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
22692 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
22693 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
22695 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
22697 + switch (e->type) {
22698 + case VXH_THROW_OOPS:
22699 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
22702 + case VXH_GET_VX_INFO:
22703 + case VXH_PUT_VX_INFO:
22704 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
22706 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
22707 + VXH_VXI_ARGS(e));
22710 + case VXH_INIT_VX_INFO:
22711 + case VXH_SET_VX_INFO:
22712 + case VXH_CLR_VX_INFO:
22713 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
22715 + (e->type == VXH_INIT_VX_INFO) ? "init" :
22716 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
22717 + VXH_VXI_ARGS(e), e->sc.data);
22720 + case VXH_CLAIM_VX_INFO:
22721 + case VXH_RELEASE_VX_INFO:
22722 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
22724 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
22725 + VXH_VXI_ARGS(e), e->sc.data);
22728 + case VXH_ALLOC_VX_INFO:
22729 + case VXH_DEALLOC_VX_INFO:
22730 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
22732 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
22733 + VXH_VXI_ARGS(e));
22736 + case VXH_HASH_VX_INFO:
22737 + case VXH_UNHASH_VX_INFO:
22738 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
22740 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
22741 + VXH_VXI_ARGS(e));
22744 + case VXH_LOC_VX_INFO:
22745 + case VXH_LOOKUP_VX_INFO:
22746 + case VXH_CREATE_VX_INFO:
22747 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
22749 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
22750 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
22751 + e->ll.arg, VXH_VXI_ARGS(e));
22756 +static void __vxh_dump_history(void)
22758 + unsigned int i, cpu;
22760 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
22761 + atomic_read(&sequence), NR_CPUS);
22763 + for (i = 0; i < VXH_SIZE; i++) {
22764 + for_each_online_cpu(cpu) {
22765 + struct _vx_history *hist =
22766 + &per_cpu(vx_history_buffer, cpu);
22767 + unsigned int index = (hist->counter - i) % VXH_SIZE;
22768 + struct _vx_hist_entry *entry = &hist->entry[index];
22770 + vxh_dump_entry(entry, cpu);
22775 +void vxh_dump_history(void)
22779 + local_irq_enable();
22781 + local_irq_disable();
22783 + __vxh_dump_history();
22787 +/* vserver syscall commands below here */
22790 +int vc_dump_history(uint32_t id)
22793 + __vxh_dump_history();
22800 +int do_read_history(struct __user _vx_hist_entry *data,
22801 + int cpu, uint32_t *index, uint32_t *count)
22803 + int pos, ret = 0;
22804 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
22805 + int end = hist->counter;
22806 + int start = end - VXH_SIZE + 2;
22807 + int idx = *index;
22809 + /* special case: get current pos */
22815 + /* have we lost some data? */
22819 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22820 + struct _vx_hist_entry *entry =
22821 + &hist->entry[idx % VXH_SIZE];
22823 + /* send entry to userspace */
22824 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22828 + /* save new index and count */
22831 + return ret ? ret : (*index < end);
22834 +int vc_read_history(uint32_t id, void __user *data)
22836 + struct vcmd_read_history_v0 vc_data;
22839 + if (id >= NR_CPUS)
22842 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22845 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
22846 + id, &vc_data.index, &vc_data.count);
22848 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22853 +#ifdef CONFIG_COMPAT
22855 +int vc_read_history_x32(uint32_t id, void __user *data)
22857 + struct vcmd_read_history_v0_x32 vc_data;
22860 + if (id >= NR_CPUS)
22863 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22866 + ret = do_read_history((struct __user _vx_hist_entry *)
22867 + compat_ptr(vc_data.data_ptr),
22868 + id, &vc_data.index, &vc_data.count);
22870 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22875 +#endif /* CONFIG_COMPAT */
22877 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/inet.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/inet.c
22878 --- linux-2.6.22.10/kernel/vserver/inet.c 1970-01-01 01:00:00 +0100
22879 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/inet.c 2007-10-10 23:55:30 +0200
22882 +#include <linux/in.h>
22883 +#include <linux/inetdevice.h>
22884 +#include <linux/vs_inet6.h>
22885 +#include <linux/vserver/debug.h>
22886 +#include <net/route.h>
22887 +#include <net/addrconf.h>
22890 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
22894 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
22897 + struct nx_addr_v4 *ptr;
22899 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
22900 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
22907 + vxdprintk(VXD_CBIT(net, 2),
22908 + "nx_v4_addr_conflict(%p,%p): %d",
22909 + nxi1, nxi2, ret);
22915 +#ifdef CONFIG_IPV6
22917 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
22921 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
22924 + struct nx_addr_v6 *ptr;
22926 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
22927 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
22934 + vxdprintk(VXD_CBIT(net, 2),
22935 + "nx_v6_addr_conflict(%p,%p): %d",
22936 + nxi1, nxi2, ret);
22943 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22945 + struct in_device *in_dev;
22946 + struct in_ifaddr **ifap;
22947 + struct in_ifaddr *ifa;
22952 + in_dev = in_dev_get(dev);
22956 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
22957 + ifap = &ifa->ifa_next) {
22958 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
22963 + in_dev_put(in_dev);
22969 +#ifdef CONFIG_IPV6
22971 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22973 + struct inet6_dev *in_dev;
22974 + struct inet6_ifaddr **ifap;
22975 + struct inet6_ifaddr *ifa;
22980 + in_dev = in6_dev_get(dev);
22984 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
22985 + ifap = &ifa->if_next) {
22986 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
22991 + in6_dev_put(in_dev);
22998 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
23004 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
23006 +#ifdef CONFIG_IPV6
23008 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
23013 + vxdprintk(VXD_CBIT(net, 3),
23014 + "dev_in_nx_info(%p,%p[#%d]) = %d",
23015 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
23019 +int ip_v4_find_src(struct nx_info *nxi, struct rtable **rp, struct flowi *fl)
23024 + /* FIXME: handle lback only case */
23025 + if (!NX_IPV4(nxi))
23028 + vxdprintk(VXD_CBIT(net, 4),
23029 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
23030 + nxi, nxi ? nxi->nx_id : 0,
23031 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
23033 + /* single IP is unconditional */
23034 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
23035 + (fl->fl4_src == INADDR_ANY))
23036 + fl->fl4_src = nxi->v4.ip[0].s_addr;
23038 + if (fl->fl4_src == INADDR_ANY) {
23039 + struct nx_addr_v4 *ptr;
23043 + err = __ip_route_output_key(rp, fl);
23045 + found = (*rp)->rt_src;
23047 + vxdprintk(VXD_CBIT(net, 4),
23048 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
23049 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
23050 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
23054 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
23055 + __be32 primary = ptr->ip[0].s_addr;
23056 + __be32 mask = ptr->mask.s_addr;
23057 + __be32 net = primary & mask;
23059 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
23060 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
23061 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
23062 + NIPQUAD(mask), NIPQUAD(net));
23063 + if ((found & mask) != net)
23066 + fl->fl4_src = primary;
23067 + err = __ip_route_output_key(rp, fl);
23068 + vxdprintk(VXD_CBIT(net, 4),
23069 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
23070 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
23072 + found = (*rp)->rt_src;
23074 + if (found == primary)
23078 + /* still no source ip? */
23079 + found = LOOPBACK(fl->fl4_dst)
23080 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
23082 + /* assign src ip to flow */
23083 + fl->fl4_src = found;
23086 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
23090 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
23091 + if (LOOPBACK(fl->fl4_dst))
23092 + fl->fl4_dst = nxi->v4_lback.s_addr;
23093 + if (LOOPBACK(fl->fl4_src))
23094 + fl->fl4_src = nxi->v4_lback.s_addr;
23095 + } else if (LOOPBACK(fl->fl4_dst))
23101 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
23103 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/init.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/init.c
23104 --- linux-2.6.22.10/kernel/vserver/init.c 1970-01-01 01:00:00 +0100
23105 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/init.c 2007-08-15 22:15:36 +0200
23108 + * linux/kernel/init.c
23110 + * Virtual Server Init
23112 + * Copyright (C) 2004-2007 Herbert Pötzl
23114 + * V0.01 basic structure
23118 +#include <linux/init.h>
23120 +int vserver_register_sysctl(void);
23121 +void vserver_unregister_sysctl(void);
23124 +static int __init init_vserver(void)
23128 +#ifdef CONFIG_VSERVER_DEBUG
23129 + vserver_register_sysctl();
23135 +static void __exit exit_vserver(void)
23138 +#ifdef CONFIG_VSERVER_DEBUG
23139 + vserver_unregister_sysctl();
23144 +/* FIXME: GFP_ZONETYPES gone
23145 +long vx_slab[GFP_ZONETYPES]; */
23149 +module_init(init_vserver);
23150 +module_exit(exit_vserver);
23152 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/inode.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/inode.c
23153 --- linux-2.6.22.10/kernel/vserver/inode.c 1970-01-01 01:00:00 +0100
23154 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/inode.c 2007-09-11 17:57:41 +0200
23157 + * linux/kernel/vserver/inode.c
23159 + * Virtual Server: File System Support
23161 + * Copyright (C) 2004-2007 Herbert Pötzl
23163 + * V0.01 separated from vcontext V0.05
23164 + * V0.02 moved to tag (instead of xid)
23168 +#include <linux/tty.h>
23169 +#include <linux/proc_fs.h>
23170 +#include <linux/devpts_fs.h>
23171 +#include <linux/fs.h>
23172 +#include <linux/file.h>
23173 +#include <linux/mount.h>
23174 +#include <linux/parser.h>
23175 +#include <linux/vserver/inode.h>
23176 +#include <linux/vserver/inode_cmd.h>
23177 +#include <linux/vs_base.h>
23178 +#include <linux/vs_tag.h>
23180 +#include <asm/uaccess.h>
23183 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
23185 + struct proc_dir_entry *entry;
23187 + if (!in || !in->i_sb)
23190 + *flags = IATTR_TAG
23191 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
23192 + | (IS_IUNLINK(in) ? IATTR_IUNLINK : 0)
23193 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
23194 + *mask = IATTR_IUNLINK | IATTR_IMMUTABLE;
23196 + if (S_ISDIR(in->i_mode))
23197 + *mask |= IATTR_BARRIER;
23199 + if (IS_TAGGED(in)) {
23200 + *tag = in->i_tag;
23201 + *mask |= IATTR_TAG;
23204 + switch (in->i_sb->s_magic) {
23205 + case PROC_SUPER_MAGIC:
23206 + entry = PROC_I(in)->pde;
23208 + /* check for specific inodes? */
23210 + *mask |= IATTR_FLAGS;
23212 + *flags |= (entry->vx_flags & IATTR_FLAGS);
23214 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
23217 + case DEVPTS_SUPER_MAGIC:
23218 + *tag = in->i_tag;
23219 + *mask |= IATTR_TAG;
23228 +int vc_get_iattr(void __user *data)
23230 + struct nameidata nd;
23231 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
23234 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23237 + ret = user_path_walk_link(vc_data.name, &nd);
23239 + ret = __vc_get_iattr(nd.dentry->d_inode,
23240 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23241 + path_release(&nd);
23246 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23251 +#ifdef CONFIG_COMPAT
23253 +int vc_get_iattr_x32(void __user *data)
23255 + struct nameidata nd;
23256 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
23259 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23262 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
23264 + ret = __vc_get_iattr(nd.dentry->d_inode,
23265 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23266 + path_release(&nd);
23271 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23276 +#endif /* CONFIG_COMPAT */
23279 +int vc_fget_iattr(uint32_t fd, void __user *data)
23281 + struct file *filp;
23282 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
23285 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23289 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
23292 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
23293 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23297 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23303 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
23305 + struct inode *in = de->d_inode;
23306 + int error = 0, is_proc = 0, has_tag = 0;
23307 + struct iattr attr = { 0 };
23309 + if (!in || !in->i_sb)
23312 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
23313 + if ((*mask & IATTR_FLAGS) && !is_proc)
23316 + has_tag = IS_TAGGED(in) ||
23317 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
23318 + if ((*mask & IATTR_TAG) && !has_tag)
23321 + mutex_lock(&in->i_mutex);
23322 + if (*mask & IATTR_TAG) {
23323 + attr.ia_tag = *tag;
23324 + attr.ia_valid |= ATTR_TAG;
23327 + if (*mask & IATTR_FLAGS) {
23328 + struct proc_dir_entry *entry = PROC_I(in)->pde;
23329 + unsigned int iflags = PROC_I(in)->vx_flags;
23331 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
23332 + | (*flags & IATTR_FLAGS);
23333 + PROC_I(in)->vx_flags = iflags;
23335 + entry->vx_flags = iflags;
23338 + if (*mask & (IATTR_BARRIER | IATTR_IUNLINK | IATTR_IMMUTABLE)) {
23339 + if (*mask & IATTR_IMMUTABLE) {
23340 + if (*flags & IATTR_IMMUTABLE)
23341 + in->i_flags |= S_IMMUTABLE;
23343 + in->i_flags &= ~S_IMMUTABLE;
23345 + if (*mask & IATTR_IUNLINK) {
23346 + if (*flags & IATTR_IUNLINK)
23347 + in->i_flags |= S_IUNLINK;
23349 + in->i_flags &= ~S_IUNLINK;
23351 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
23352 + if (*flags & IATTR_BARRIER)
23353 + in->i_flags |= S_BARRIER;
23355 + in->i_flags &= ~S_BARRIER;
23357 + if (in->i_op && in->i_op->sync_flags) {
23358 + error = in->i_op->sync_flags(in);
23364 + if (attr.ia_valid) {
23365 + if (in->i_op && in->i_op->setattr)
23366 + error = in->i_op->setattr(de, &attr);
23368 + error = inode_change_ok(in, &attr);
23370 + error = inode_setattr(in, &attr);
23375 + mutex_unlock(&in->i_mutex);
23379 +int vc_set_iattr(void __user *data)
23381 + struct nameidata nd;
23382 + struct vcmd_ctx_iattr_v1 vc_data;
23385 + if (!capable(CAP_LINUX_IMMUTABLE))
23387 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23390 + ret = user_path_walk_link(vc_data.name, &nd);
23392 + ret = __vc_set_iattr(nd.dentry,
23393 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23394 + path_release(&nd);
23397 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23402 +#ifdef CONFIG_COMPAT
23404 +int vc_set_iattr_x32(void __user *data)
23406 + struct nameidata nd;
23407 + struct vcmd_ctx_iattr_v1_x32 vc_data;
23410 + if (!capable(CAP_LINUX_IMMUTABLE))
23412 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23415 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
23417 + ret = __vc_set_iattr(nd.dentry,
23418 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23419 + path_release(&nd);
23422 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23427 +#endif /* CONFIG_COMPAT */
23429 +int vc_fset_iattr(uint32_t fd, void __user *data)
23431 + struct file *filp;
23432 + struct vcmd_ctx_fiattr_v0 vc_data;
23435 + if (!capable(CAP_LINUX_IMMUTABLE))
23437 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23441 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
23444 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
23445 + &vc_data.flags, &vc_data.mask);
23449 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23455 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
23457 +static match_table_t tokens = {
23458 + {Opt_notagcheck, "notagcheck"},
23459 +#ifdef CONFIG_PROPAGATE
23460 + {Opt_notag, "notag"},
23461 + {Opt_tag, "tag"},
23462 + {Opt_tagid, "tagid=%u"},
23468 +static void __dx_parse_remove(char *string, char *opt)
23470 + char *p = strstr(string, opt);
23474 + while (*q != '\0' && *q != ',')
23484 +int __dx_parse_tag(char *string, tag_t *tag, int remove)
23486 + substring_t args[MAX_OPT_ARGS];
23487 + int token, option = 0;
23492 + token = match_token(string, tokens, args);
23494 + vxdprintk(VXD_CBIT(tag, 7),
23495 + "dx_parse_tag(»%s«): %d:#%d",
23496 + string, token, option);
23503 + __dx_parse_remove(string, "tag");
23504 + return MNT_TAGID;
23507 + __dx_parse_remove(string, "notag");
23508 + return MNT_NOTAG;
23509 + case Opt_notagcheck:
23511 + __dx_parse_remove(string, "notagcheck");
23512 + return MNT_NOTAGCHECK;
23514 + if (tag && !match_int(args, &option))
23517 + __dx_parse_remove(string, "tagid");
23518 + return MNT_TAGID;
23523 +int dx_parse_tag(char *string, tag_t *tag, int remove)
23525 + int retval, flags = 0;
23527 + while ((retval = __dx_parse_tag(string, tag, remove)))
23532 +#ifdef CONFIG_PROPAGATE
23534 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
23536 + tag_t new_tag = 0;
23537 + struct vfsmount *mnt;
23546 + propagate = (mnt->mnt_flags & MNT_TAGID);
23548 + new_tag = mnt->mnt_tag;
23550 + vxdprintk(VXD_CBIT(tag, 7),
23551 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
23552 + inode, inode->i_ino, inode->i_tag,
23553 + new_tag, (propagate) ? 1 : 0);
23556 + inode->i_tag = new_tag;
23559 +#include <linux/module.h>
23561 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
23563 +#endif /* CONFIG_PROPAGATE */
23565 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/limit.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit.c
23566 --- linux-2.6.22.10/kernel/vserver/limit.c 1970-01-01 01:00:00 +0100
23567 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit.c 2007-08-19 00:08:19 +0200
23570 + * linux/kernel/vserver/limit.c
23572 + * Virtual Server: Context Limits
23574 + * Copyright (C) 2004-2007 Herbert Pötzl
23576 + * V0.01 broken out from vcontext V0.05
23577 + * V0.02 changed vcmds to vxi arg
23581 +#include <linux/module.h>
23582 +#include <linux/vs_limit.h>
23583 +#include <linux/vserver/limit.h>
23584 +#include <linux/vserver/limit_cmd.h>
23586 +#include <asm/uaccess.h>
23589 +const char *vlimit_name[NUM_LIMITS] = {
23590 + [RLIMIT_CPU] = "CPU",
23591 + [RLIMIT_RSS] = "RSS",
23592 + [RLIMIT_NPROC] = "NPROC",
23593 + [RLIMIT_NOFILE] = "NOFILE",
23594 + [RLIMIT_MEMLOCK] = "VML",
23595 + [RLIMIT_AS] = "VM",
23596 + [RLIMIT_LOCKS] = "LOCKS",
23597 + [RLIMIT_SIGPENDING] = "SIGP",
23598 + [RLIMIT_MSGQUEUE] = "MSGQ",
23600 + [VLIMIT_NSOCK] = "NSOCK",
23601 + [VLIMIT_OPENFD] = "OPENFD",
23602 + [VLIMIT_ANON] = "ANON",
23603 + [VLIMIT_SHMEM] = "SHMEM",
23604 + [VLIMIT_DENTRY] = "DENTRY",
23607 +EXPORT_SYMBOL_GPL(vlimit_name);
23609 +#define MASK_ENTRY(x) (1 << (x))
23611 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
23614 + , /* softlimit */
23615 + MASK_ENTRY( RLIMIT_RSS ) |
23616 + MASK_ENTRY( VLIMIT_ANON ) |
23619 + MASK_ENTRY( RLIMIT_RSS ) |
23620 + MASK_ENTRY( RLIMIT_NPROC ) |
23621 + MASK_ENTRY( RLIMIT_NOFILE ) |
23622 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
23623 + MASK_ENTRY( RLIMIT_AS ) |
23624 + MASK_ENTRY( RLIMIT_LOCKS ) |
23625 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
23627 + MASK_ENTRY( VLIMIT_NSOCK ) |
23628 + MASK_ENTRY( VLIMIT_OPENFD ) |
23629 + MASK_ENTRY( VLIMIT_ANON ) |
23630 + MASK_ENTRY( VLIMIT_SHMEM ) |
23631 + MASK_ENTRY( VLIMIT_DENTRY ) |
23634 + /* accounting only */
23635 +uint32_t account_mask =
23636 + MASK_ENTRY( VLIMIT_SEMARY ) |
23637 + MASK_ENTRY( VLIMIT_NSEMS ) |
23638 + MASK_ENTRY( VLIMIT_MAPPED ) |
23642 +static int is_valid_vlimit(int id)
23644 + uint32_t mask = vlimit_mask.minimum |
23645 + vlimit_mask.softlimit | vlimit_mask.maximum;
23646 + return mask & (1 << id);
23649 +static int is_accounted_vlimit(int id)
23651 + if (is_valid_vlimit(id))
23653 + return account_mask & (1 << id);
23657 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
23659 + rlim_t limit = __rlim_soft(&vxi->limit, id);
23660 + return VX_VLIM(limit);
23663 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
23665 + rlim_t limit = __rlim_hard(&vxi->limit, id);
23666 + return VX_VLIM(limit);
23669 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
23670 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
23672 + if (!is_valid_vlimit(id))
23676 + *minimum = CRLIM_UNSET;
23678 + *softlimit = vc_get_soft(vxi, id);
23680 + *maximum = vc_get_hard(vxi, id);
23684 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
23686 + struct vcmd_ctx_rlimit_v0 vc_data;
23689 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23692 + ret = do_get_rlimit(vxi, vc_data.id,
23693 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
23697 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23702 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
23703 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
23705 + if (!is_valid_vlimit(id))
23708 + if (maximum != CRLIM_KEEP)
23709 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
23710 + if (softlimit != CRLIM_KEEP)
23711 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
23713 + /* clamp soft limit */
23714 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
23715 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
23720 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
23722 + struct vcmd_ctx_rlimit_v0 vc_data;
23724 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23727 + return do_set_rlimit(vxi, vc_data.id,
23728 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
23731 +#ifdef CONFIG_IA32_EMULATION
23733 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
23735 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
23737 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23740 + return do_set_rlimit(vxi, vc_data.id,
23741 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
23744 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
23746 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
23749 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23752 + ret = do_get_rlimit(vxi, vc_data.id,
23753 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
23757 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23762 +#endif /* CONFIG_IA32_EMULATION */
23765 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
23767 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
23773 +static inline void vx_reset_minmax(struct _vx_limit *limit)
23778 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23779 + value = __rlim_get(limit, lim);
23780 + __rlim_rmax(limit, lim) = value;
23781 + __rlim_rmin(limit, lim) = value;
23786 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
23788 + vx_reset_minmax(&vxi->limit);
23793 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
23795 + struct vcmd_rlimit_stat_v0 vc_data;
23796 + struct _vx_limit *limit = &vxi->limit;
23799 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23803 + if (!is_accounted_vlimit(id))
23806 + vx_limit_fixup(limit, id);
23807 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
23808 + vc_data.value = __rlim_get(limit, id);
23809 + vc_data.minimum = __rlim_rmin(limit, id);
23810 + vc_data.maximum = __rlim_rmax(limit, id);
23812 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23818 +void vx_vsi_meminfo(struct sysinfo *val)
23820 + struct vx_info *vxi = current->vx_info;
23821 + unsigned long totalram, freeram;
23824 + /* we blindly accept the max */
23825 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23826 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
23828 + /* total minus used equals free */
23829 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23830 + freeram = (v < totalram) ? totalram - v : 0;
23832 + val->totalram = totalram;
23833 + val->freeram = freeram;
23834 + val->bufferram = 0;
23835 + val->totalhigh = 0;
23836 + val->freehigh = 0;
23840 +void vx_vsi_swapinfo(struct sysinfo *val)
23842 + struct vx_info *vxi = current->vx_info;
23843 + unsigned long totalswap, freeswap;
23846 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23847 + if (v == RLIM_INFINITY) {
23848 + val->freeswap = val->totalswap;
23852 + /* we blindly accept the max */
23853 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
23854 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
23856 + /* currently 'used' swap */
23857 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23858 + w -= (w > v) ? v : w;
23860 + /* total minus used equals free */
23861 + freeswap = (w < totalswap) ? totalswap - w : 0;
23863 + val->totalswap = totalswap;
23864 + val->freeswap = freeswap;
23869 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
23871 + struct vx_info *vxi = mm->mm_vx_info;
23872 + unsigned long points;
23878 + points = vxi->vx_badness_bias;
23880 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23881 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23882 + points += (v > w) ? (v - w) : 0;
23887 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/limit_init.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit_init.h
23888 --- linux-2.6.22.10/kernel/vserver/limit_init.h 1970-01-01 01:00:00 +0100
23889 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit_init.h 2007-10-25 17:05:55 +0200
23893 +static inline void vx_info_init_limit(struct _vx_limit *limit)
23897 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23898 + __rlim_soft(limit, lim) = RLIM_INFINITY;
23899 + __rlim_hard(limit, lim) = RLIM_INFINITY;
23900 + __rlim_set(limit, lim, 0);
23901 + atomic_set(&__rlim_lhit(limit, lim), 0);
23902 + __rlim_rmin(limit, lim) = 0;
23903 + __rlim_rmax(limit, lim) = 0;
23907 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
23909 +#ifdef CONFIG_VSERVER_WARN
23913 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23914 + if ((1 << lim) & VLIM_NOCHECK)
23916 + value = __rlim_get(limit, lim);
23917 + vxwprintk_xid(value,
23918 + "!!! limit: %p[%s,%d] = %ld on exit.",
23919 + limit, vlimit_name[lim], lim, (long)value);
23924 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/limit_proc.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit_proc.h
23925 --- linux-2.6.22.10/kernel/vserver/limit_proc.h 1970-01-01 01:00:00 +0100
23926 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit_proc.h 2007-08-05 20:53:13 +0200
23928 +#ifndef _VX_LIMIT_PROC_H
23929 +#define _VX_LIMIT_PROC_H
23931 +#include <linux/vserver/limit_int.h>
23934 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
23935 +#define VX_LIMIT_TOP \
23936 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
23938 +#define VX_LIMIT_ARG(r) \
23939 + (unsigned long)__rlim_get(limit, r), \
23940 + (unsigned long)__rlim_rmin(limit, r), \
23941 + (unsigned long)__rlim_rmax(limit, r), \
23942 + VX_VLIM(__rlim_soft(limit, r)), \
23943 + VX_VLIM(__rlim_hard(limit, r)), \
23944 + atomic_read(&__rlim_lhit(limit, r))
23946 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
23948 + vx_limit_fixup(limit, -1);
23949 + return sprintf(buffer, VX_LIMIT_TOP
23950 + "PROC" VX_LIMIT_FMT
23951 + "VM" VX_LIMIT_FMT
23952 + "VML" VX_LIMIT_FMT
23953 + "RSS" VX_LIMIT_FMT
23954 + "ANON" VX_LIMIT_FMT
23955 + "RMAP" VX_LIMIT_FMT
23956 + "FILES" VX_LIMIT_FMT
23957 + "OFD" VX_LIMIT_FMT
23958 + "LOCKS" VX_LIMIT_FMT
23959 + "SOCK" VX_LIMIT_FMT
23960 + "MSGQ" VX_LIMIT_FMT
23961 + "SHM" VX_LIMIT_FMT
23962 + "SEMA" VX_LIMIT_FMT
23963 + "SEMS" VX_LIMIT_FMT
23964 + "DENT" VX_LIMIT_FMT,
23965 + VX_LIMIT_ARG(RLIMIT_NPROC),
23966 + VX_LIMIT_ARG(RLIMIT_AS),
23967 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
23968 + VX_LIMIT_ARG(RLIMIT_RSS),
23969 + VX_LIMIT_ARG(VLIMIT_ANON),
23970 + VX_LIMIT_ARG(VLIMIT_MAPPED),
23971 + VX_LIMIT_ARG(RLIMIT_NOFILE),
23972 + VX_LIMIT_ARG(VLIMIT_OPENFD),
23973 + VX_LIMIT_ARG(RLIMIT_LOCKS),
23974 + VX_LIMIT_ARG(VLIMIT_NSOCK),
23975 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
23976 + VX_LIMIT_ARG(VLIMIT_SHMEM),
23977 + VX_LIMIT_ARG(VLIMIT_SEMARY),
23978 + VX_LIMIT_ARG(VLIMIT_NSEMS),
23979 + VX_LIMIT_ARG(VLIMIT_DENTRY));
23982 +#endif /* _VX_LIMIT_PROC_H */
23985 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/monitor.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/monitor.c
23986 --- linux-2.6.22.10/kernel/vserver/monitor.c 1970-01-01 01:00:00 +0100
23987 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/monitor.c 2007-08-15 23:18:20 +0200
23990 + * kernel/vserver/monitor.c
23992 + * Virtual Context Scheduler Monitor
23994 + * Copyright (C) 2006-2007 Herbert Pötzl
23996 + * V0.01 basic design
24000 +#include <linux/module.h>
24001 +#include <linux/jiffies.h>
24002 +#include <asm/uaccess.h>
24003 +#include <asm/atomic.h>
24005 +#include <linux/vserver/monitor.h>
24006 +#include <linux/vserver/debug_cmd.h>
24009 +#ifdef CONFIG_VSERVER_MONITOR
24010 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
24012 +#define VXM_SIZE 64
24015 +struct _vx_monitor {
24016 + unsigned int counter;
24018 + struct _vx_mon_entry entry[VXM_SIZE+1];
24022 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
24024 +unsigned volatile int vxm_active = 1;
24026 +static atomic_t sequence = ATOMIC_INIT(0);
24031 + * requires disabled preemption */
24033 +struct _vx_mon_entry *vxm_advance(int cpu)
24035 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
24036 + struct _vx_mon_entry *entry;
24037 + unsigned int index;
24039 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
24040 + entry = &mon->entry[index];
24042 + entry->ev.seq = atomic_inc_return(&sequence);
24043 + entry->ev.jif = jiffies;
24047 +EXPORT_SYMBOL_GPL(vxm_advance);
24050 +int do_read_monitor(struct __user _vx_mon_entry *data,
24051 + int cpu, uint32_t *index, uint32_t *count)
24053 + int pos, ret = 0;
24054 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
24055 + int end = mon->counter;
24056 + int start = end - VXM_SIZE + 2;
24057 + int idx = *index;
24059 + /* special case: get current pos */
24065 + /* have we lost some data? */
24069 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
24070 + struct _vx_mon_entry *entry =
24071 + &mon->entry[idx % VXM_SIZE];
24073 + /* send entry to userspace */
24074 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
24078 + /* save new index and count */
24081 + return ret ? ret : (*index < end);
24084 +int vc_read_monitor(uint32_t id, void __user *data)
24086 + struct vcmd_read_monitor_v0 vc_data;
24089 + if (id >= NR_CPUS)
24092 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24095 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
24096 + id, &vc_data.index, &vc_data.count);
24098 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24103 +#ifdef CONFIG_COMPAT
24105 +int vc_read_monitor_x32(uint32_t id, void __user *data)
24107 + struct vcmd_read_monitor_v0_x32 vc_data;
24110 + if (id >= NR_CPUS)
24113 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24116 + ret = do_read_monitor((struct __user _vx_mon_entry *)
24117 + compat_ptr(vc_data.data_ptr),
24118 + id, &vc_data.index, &vc_data.count);
24120 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24125 +#endif /* CONFIG_COMPAT */
24127 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/network.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/network.c
24128 --- linux-2.6.22.10/kernel/vserver/network.c 1970-01-01 01:00:00 +0100
24129 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/network.c 2007-10-05 14:54:36 +0200
24132 + * linux/kernel/vserver/network.c
24134 + * Virtual Server: Network Support
24136 + * Copyright (C) 2003-2007 Herbert Pötzl
24138 + * V0.01 broken out from vcontext V0.05
24139 + * V0.02 cleaned up implementation
24140 + * V0.03 added equiv nx commands
24141 + * V0.04 switch to RCU based hash
24142 + * V0.05 and back to locking again
24143 + * V0.06 changed vcmds to nxi arg
24144 + * V0.07 have __create claim() the nxi
24148 +#include <linux/err.h>
24149 +#include <linux/slab.h>
24150 +#include <linux/rcupdate.h>
24152 +#include <linux/vs_network.h>
24153 +#include <linux/vserver/network_cmd.h>
24156 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
24157 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
24159 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
24160 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
24163 +static int __init init_network(void)
24165 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
24166 + sizeof(struct nx_addr_v4), 0, SLAB_PANIC, NULL, NULL);
24167 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
24168 + sizeof(struct nx_addr_v6), 0, SLAB_PANIC, NULL, NULL);
24173 +/* __alloc_nx_addr_v4() */
24175 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
24177 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
24178 + nx_addr_v4_cachep, GFP_KERNEL);
24180 + if (!IS_ERR(nxa))
24181 + memset(nxa, 0, sizeof(*nxa));
24185 +/* __dealloc_nx_addr_v4() */
24187 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
24189 + kmem_cache_free(nx_addr_v4_cachep, nxa);
24192 +/* __dealloc_nx_addr_v4_all() */
24194 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
24197 + struct nx_addr_v4 *next = nxa->next;
24199 + __dealloc_nx_addr_v4(nxa);
24205 +#ifdef CONFIG_IPV6
24207 +/* __alloc_nx_addr_v6() */
24209 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
24211 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
24212 + nx_addr_v6_cachep, GFP_KERNEL);
24214 + if (!IS_ERR(nxa))
24215 + memset(nxa, 0, sizeof(*nxa));
24219 +/* __dealloc_nx_addr_v6() */
24221 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
24223 + kmem_cache_free(nx_addr_v6_cachep, nxa);
24226 +/* __dealloc_nx_addr_v6_all() */
24228 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
24231 + struct nx_addr_v6 *next = nxa->next;
24233 + __dealloc_nx_addr_v6(nxa);
24238 +#endif /* CONFIG_IPV6 */
24241 +/* __alloc_nx_info()
24243 + * allocate an initialized nx_info struct
24244 + * doesn't make it visible (hash) */
24246 +static struct nx_info *__alloc_nx_info(nid_t nid)
24248 + struct nx_info *new = NULL;
24250 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
24252 + /* would this benefit from a slab cache? */
24253 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
24257 + memset(new, 0, sizeof(struct nx_info));
24258 + new->nx_id = nid;
24259 + INIT_HLIST_NODE(&new->nx_hlist);
24260 + atomic_set(&new->nx_usecnt, 0);
24261 + atomic_set(&new->nx_tasks, 0);
24262 + new->nx_state = 0;
24264 + new->nx_flags = NXF_INIT_SET;
24266 + /* rest of init goes here */
24268 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
24269 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
24271 + vxdprintk(VXD_CBIT(nid, 0),
24272 + "alloc_nx_info(%d) = %p", nid, new);
24273 + atomic_inc(&nx_global_ctotal);
24277 +/* __dealloc_nx_info()
24279 + * final disposal of nx_info */
24281 +static void __dealloc_nx_info(struct nx_info *nxi)
24283 + vxdprintk(VXD_CBIT(nid, 0),
24284 + "dealloc_nx_info(%p)", nxi);
24286 + nxi->nx_hlist.next = LIST_POISON1;
24289 + BUG_ON(atomic_read(&nxi->nx_usecnt));
24290 + BUG_ON(atomic_read(&nxi->nx_tasks));
24292 + __dealloc_nx_addr_v4_all(nxi->v4.next);
24294 + nxi->nx_state |= NXS_RELEASED;
24296 + atomic_dec(&nx_global_ctotal);
24299 +static void __shutdown_nx_info(struct nx_info *nxi)
24301 + nxi->nx_state |= NXS_SHUTDOWN;
24302 + vs_net_change(nxi, VSC_NETDOWN);
24305 +/* exported stuff */
24307 +void free_nx_info(struct nx_info *nxi)
24309 + /* context shutdown is mandatory */
24310 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
24312 + /* context must not be hashed */
24313 + BUG_ON(nxi->nx_state & NXS_HASHED);
24315 + BUG_ON(atomic_read(&nxi->nx_usecnt));
24316 + BUG_ON(atomic_read(&nxi->nx_tasks));
24318 + __dealloc_nx_info(nxi);
24322 +void __nx_set_lback(struct nx_info *nxi)
24324 + int nid = nxi->nx_id;
24325 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
24327 + nxi->v4_lback.s_addr = lback;
24330 +extern int __nx_inet_add_lback(__be32 addr);
24331 +extern int __nx_inet_del_lback(__be32 addr);
24334 +/* hash table for nx_info hash */
24336 +#define NX_HASH_SIZE 13
24338 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
24340 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
24343 +static inline unsigned int __hashval(nid_t nid)
24345 + return (nid % NX_HASH_SIZE);
24350 +/* __hash_nx_info()
24352 + * add the nxi to the global hash table
24353 + * requires the hash_lock to be held */
24355 +static inline void __hash_nx_info(struct nx_info *nxi)
24357 + struct hlist_head *head;
24359 + vxd_assert_lock(&nx_info_hash_lock);
24360 + vxdprintk(VXD_CBIT(nid, 4),
24361 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
24363 + /* context must not be hashed */
24364 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
24366 + nxi->nx_state |= NXS_HASHED;
24367 + head = &nx_info_hash[__hashval(nxi->nx_id)];
24368 + hlist_add_head(&nxi->nx_hlist, head);
24369 + atomic_inc(&nx_global_cactive);
24372 +/* __unhash_nx_info()
24374 + * remove the nxi from the global hash table
24375 + * requires the hash_lock to be held */
24377 +static inline void __unhash_nx_info(struct nx_info *nxi)
24379 + vxd_assert_lock(&nx_info_hash_lock);
24380 + vxdprintk(VXD_CBIT(nid, 4),
24381 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
24382 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
24384 + /* context must be hashed */
24385 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
24386 + /* but without tasks */
24387 + BUG_ON(atomic_read(&nxi->nx_tasks));
24389 + nxi->nx_state &= ~NXS_HASHED;
24390 + hlist_del(&nxi->nx_hlist);
24391 + atomic_dec(&nx_global_cactive);
24395 +/* __lookup_nx_info()
24397 + * requires the hash_lock to be held
24398 + * doesn't increment the nx_refcnt */
24400 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
24402 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
24403 + struct hlist_node *pos;
24404 + struct nx_info *nxi;
24406 + vxd_assert_lock(&nx_info_hash_lock);
24407 + hlist_for_each(pos, head) {
24408 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
24410 + if (nxi->nx_id == nid)
24415 + vxdprintk(VXD_CBIT(nid, 0),
24416 + "__lookup_nx_info(#%u): %p[#%u]",
24417 + nid, nxi, nxi ? nxi->nx_id : 0);
24422 +/* __create_nx_info()
24424 + * create the requested context
24425 + * get(), claim() and hash it */
24427 +static struct nx_info *__create_nx_info(int id)
24429 + struct nx_info *new, *nxi = NULL;
24431 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
24433 + if (!(new = __alloc_nx_info(id)))
24434 + return ERR_PTR(-ENOMEM);
24436 + /* required to make dynamic xids unique */
24437 + spin_lock(&nx_info_hash_lock);
24439 + /* static context requested */
24440 + if ((nxi = __lookup_nx_info(id))) {
24441 + vxdprintk(VXD_CBIT(nid, 0),
24442 + "create_nx_info(%d) = %p (already there)", id, nxi);
24443 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
24444 + nxi = ERR_PTR(-EBUSY);
24446 + nxi = ERR_PTR(-EEXIST);
24449 + /* new context */
24450 + vxdprintk(VXD_CBIT(nid, 0),
24451 + "create_nx_info(%d) = %p (new)", id, new);
24452 + claim_nx_info(new, NULL);
24453 + __nx_set_lback(new);
24454 + __hash_nx_info(get_nx_info(new));
24455 + nxi = new, new = NULL;
24458 + spin_unlock(&nx_info_hash_lock);
24460 + __dealloc_nx_info(new);
24466 +/* exported stuff */
24469 +void unhash_nx_info(struct nx_info *nxi)
24471 + __shutdown_nx_info(nxi);
24472 + spin_lock(&nx_info_hash_lock);
24473 + __unhash_nx_info(nxi);
24474 + spin_unlock(&nx_info_hash_lock);
24477 +/* lookup_nx_info()
24479 + * search for a nx_info and get() it
24480 + * negative id means current */
24482 +struct nx_info *lookup_nx_info(int id)
24484 + struct nx_info *nxi = NULL;
24487 + nxi = get_nx_info(current->nx_info);
24488 + } else if (id > 1) {
24489 + spin_lock(&nx_info_hash_lock);
24490 + nxi = get_nx_info(__lookup_nx_info(id));
24491 + spin_unlock(&nx_info_hash_lock);
24496 +/* nid_is_hashed()
24498 + * verify that nid is still hashed */
24500 +int nid_is_hashed(nid_t nid)
24504 + spin_lock(&nx_info_hash_lock);
24505 + hashed = (__lookup_nx_info(nid) != NULL);
24506 + spin_unlock(&nx_info_hash_lock);
24511 +#ifdef CONFIG_PROC_FS
24515 + * get a subset of hashed nids for proc
24516 + * assumes size is at least one */
24518 +int get_nid_list(int index, unsigned int *nids, int size)
24520 + int hindex, nr_nids = 0;
24522 + /* only show current and children */
24523 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
24526 + nids[nr_nids] = nx_current_nid();
24530 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
24531 + struct hlist_head *head = &nx_info_hash[hindex];
24532 + struct hlist_node *pos;
24534 + spin_lock(&nx_info_hash_lock);
24535 + hlist_for_each(pos, head) {
24536 + struct nx_info *nxi;
24541 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
24542 + nids[nr_nids] = nxi->nx_id;
24543 + if (++nr_nids >= size) {
24544 + spin_unlock(&nx_info_hash_lock);
24548 + /* keep the lock time short */
24549 + spin_unlock(&nx_info_hash_lock);
24558 + * migrate task to new network
24559 + * gets nxi, puts old_nxi on change
24562 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
24564 + struct nx_info *old_nxi;
24570 + vxdprintk(VXD_CBIT(nid, 5),
24571 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
24572 + p, nxi, nxi->nx_id,
24573 + atomic_read(&nxi->nx_usecnt),
24574 + atomic_read(&nxi->nx_tasks));
24576 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
24577 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
24580 + if (nx_info_state(nxi, NXS_SHUTDOWN))
24583 + /* maybe disallow this completely? */
24584 + old_nxi = task_get_nx_info(p);
24585 + if (old_nxi == nxi)
24590 + clr_nx_info(&p->nx_info);
24591 + claim_nx_info(nxi, p);
24592 + set_nx_info(&p->nx_info, nxi);
24593 + p->nid = nxi->nx_id;
24596 + vxdprintk(VXD_CBIT(nid, 5),
24597 + "moved task %p into nxi:%p[#%d]",
24598 + p, nxi, nxi->nx_id);
24601 + release_nx_info(old_nxi, p);
24604 + put_nx_info(old_nxi);
24609 +void nx_set_persistent(struct nx_info *nxi)
24611 + vxdprintk(VXD_CBIT(nid, 6),
24612 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
24614 + get_nx_info(nxi);
24615 + claim_nx_info(nxi, NULL);
24618 +void nx_clear_persistent(struct nx_info *nxi)
24620 + vxdprintk(VXD_CBIT(nid, 6),
24621 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
24623 + release_nx_info(nxi, NULL);
24624 + put_nx_info(nxi);
24627 +void nx_update_persistent(struct nx_info *nxi)
24629 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
24630 + nx_set_persistent(nxi);
24632 + nx_clear_persistent(nxi);
24635 +/* vserver syscall commands below here */
24637 +/* taks nid and nx_info functions */
24639 +#include <asm/uaccess.h>
24642 +int vc_task_nid(uint32_t id)
24647 + struct task_struct *tsk;
24649 + read_lock(&tasklist_lock);
24650 + tsk = find_task_by_real_pid(id);
24651 + nid = (tsk) ? tsk->nid : -ESRCH;
24652 + read_unlock(&tasklist_lock);
24654 + nid = nx_current_nid();
24659 +int vc_nx_info(struct nx_info *nxi, void __user *data)
24661 + struct vcmd_nx_info_v0 vc_data;
24663 + vc_data.nid = nxi->nx_id;
24665 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24671 +/* network functions */
24673 +int vc_net_create(uint32_t nid, void __user *data)
24675 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
24676 + struct nx_info *new_nxi;
24679 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24682 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
24685 + new_nxi = __create_nx_info(nid);
24686 + if (IS_ERR(new_nxi))
24687 + return PTR_ERR(new_nxi);
24689 + /* initial flags */
24690 + new_nxi->nx_flags = vc_data.flagword;
24693 + if (vs_net_change(new_nxi, VSC_NETUP))
24696 + ret = nx_migrate_task(current, new_nxi);
24700 + /* return context id on success */
24701 + ret = new_nxi->nx_id;
24703 + /* get a reference for persistent contexts */
24704 + if ((vc_data.flagword & NXF_PERSISTENT))
24705 + nx_set_persistent(new_nxi);
24707 + release_nx_info(new_nxi, NULL);
24708 + put_nx_info(new_nxi);
24713 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
24715 + return nx_migrate_task(current, nxi);
24720 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
24721 + uint16_t type, uint16_t flags)
24723 + struct nx_addr_v4 *nxa = &nxi->v4;
24725 + if (NX_IPV4(nxi)) {
24726 + /* locate last entry */
24727 + for (; nxa->next; nxa = nxa->next);
24728 + nxa->next = __alloc_nx_addr_v4();
24732 + return PTR_ERR(nxa);
24735 + if (nxi->v4.next)
24736 + /* remove single ip for ip list */
24737 + nxi->nx_flags &= ~NXF_SINGLE_IP;
24739 + nxa->ip[0].s_addr = ip;
24740 + nxa->ip[1].s_addr = ip2;
24741 + nxa->mask.s_addr = mask;
24742 + nxa->type = type;
24743 + nxa->flags = flags;
24748 +int vc_net_add(struct nx_info *nxi, void __user *data)
24750 + struct vcmd_net_addr_v0 vc_data;
24751 + int index, ret = 0;
24753 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24756 + switch (vc_data.type) {
24757 + case NXA_TYPE_IPV4:
24758 + if ((vc_data.count < 1) || (vc_data.count > 4))
24762 + while (index < vc_data.count) {
24763 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
24764 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
24772 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
24773 + nxi->v4_bcast = vc_data.ip[0];
24777 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
24778 + nxi->v4_lback = vc_data.ip[0];
24789 +int vc_net_remove(struct nx_info *nxi, void __user *data)
24791 + struct vcmd_net_addr_v0 vc_data;
24793 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24796 + switch (vc_data.type) {
24797 + case NXA_TYPE_ANY:
24798 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24799 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24809 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
24811 + struct vcmd_net_addr_ipv4_v1 vc_data;
24813 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24816 + switch (vc_data.type) {
24817 + case NXA_TYPE_ADDR:
24818 + case NXA_TYPE_RANGE:
24819 + case NXA_TYPE_MASK:
24820 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
24821 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
24823 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
24824 + nxi->v4_bcast = vc_data.ip;
24827 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
24828 + nxi->v4_lback = vc_data.ip;
24837 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
24839 + struct vcmd_net_addr_ipv4_v1 vc_data;
24841 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24844 + switch (vc_data.type) {
24845 +/* case NXA_TYPE_ADDR:
24848 + case NXA_TYPE_ANY:
24849 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24850 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24860 +#ifdef CONFIG_IPV6
24862 +int do_add_v6_addr(struct nx_info *nxi,
24863 + struct in6_addr *ip, struct in6_addr *mask,
24864 + uint32_t prefix, uint16_t type, uint16_t flags)
24866 + struct nx_addr_v6 *nxa = &nxi->v6;
24868 + if (NX_IPV6(nxi)) {
24869 + /* locate last entry */
24870 + for (; nxa->next; nxa = nxa->next);
24871 + nxa->next = __alloc_nx_addr_v6();
24875 + return PTR_ERR(nxa);
24879 + nxa->mask = *mask;
24880 + nxa->prefix = prefix;
24881 + nxa->type = type;
24882 + nxa->flags = flags;
24887 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
24889 + struct vcmd_net_addr_ipv6_v1 vc_data;
24891 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24894 + switch (vc_data.type) {
24895 + case NXA_TYPE_ADDR:
24896 + case NXA_TYPE_MASK:
24897 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
24898 + vc_data.prefix, vc_data.type, vc_data.flags);
24905 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
24907 + struct vcmd_net_addr_ipv6_v1 vc_data;
24909 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24912 + switch (vc_data.type) {
24913 + case NXA_TYPE_ANY:
24914 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
24915 + memset(&nxi->v6, 0, sizeof(nxi->v6));
24924 +#endif /* CONFIG_IPV6 */
24927 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
24929 + struct vcmd_net_flags_v0 vc_data;
24931 + vc_data.flagword = nxi->nx_flags;
24933 + /* special STATE flag handling */
24934 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
24936 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24941 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
24943 + struct vcmd_net_flags_v0 vc_data;
24944 + uint64_t mask, trigger;
24946 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24949 + /* special STATE flag handling */
24950 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
24951 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
24953 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
24954 + vc_data.flagword, mask);
24955 + if (trigger & NXF_PERSISTENT)
24956 + nx_update_persistent(nxi);
24961 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
24963 + struct vcmd_net_caps_v0 vc_data;
24965 + vc_data.ncaps = nxi->nx_ncaps;
24966 + vc_data.cmask = ~0ULL;
24968 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24973 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
24975 + struct vcmd_net_caps_v0 vc_data;
24977 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24980 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
24981 + vc_data.ncaps, vc_data.cmask);
24986 +#include <linux/module.h>
24988 +module_init(init_network);
24990 +EXPORT_SYMBOL_GPL(free_nx_info);
24991 +EXPORT_SYMBOL_GPL(unhash_nx_info);
24993 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/proc.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/proc.c
24994 --- linux-2.6.22.10/kernel/vserver/proc.c 1970-01-01 01:00:00 +0100
24995 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/proc.c 2007-10-05 14:54:36 +0200
24998 + * linux/kernel/vserver/proc.c
25000 + * Virtual Context Support
25002 + * Copyright (C) 2003-2007 Herbert Pötzl
25004 + * V0.01 basic structure
25005 + * V0.02 adaptation vs1.3.0
25006 + * V0.03 proc permissions
25007 + * V0.04 locking/generic
25008 + * V0.05 next generation procfs
25009 + * V0.06 inode validation
25010 + * V0.07 generic rewrite vid
25011 + * V0.08 remove inode type
25015 +#include <linux/proc_fs.h>
25016 +#include <asm/unistd.h>
25018 +#include <linux/vs_context.h>
25019 +#include <linux/vs_network.h>
25020 +#include <linux/vs_cvirt.h>
25021 +#include <linux/vs_inet.h>
25022 +#include <linux/vs_inet6.h>
25024 +#include <linux/vserver/global.h>
25026 +#include "cvirt_proc.h"
25027 +#include "cacct_proc.h"
25028 +#include "limit_proc.h"
25029 +#include "sched_proc.h"
25030 +#include "vci_config.h"
25032 +static struct proc_dir_entry *proc_virtual;
25034 +static struct proc_dir_entry *proc_virtnet;
25037 +/* first the actual feeds */
25040 +static int proc_vci(char *buffer)
25042 + return sprintf(buffer,
25043 + "VCIVersion:\t%04x:%04x\n"
25044 + "VCISyscall:\t%d\n"
25045 + "VCIKernel:\t%08x\n",
25046 + VCI_VERSION >> 16,
25047 + VCI_VERSION & 0xFFFF,
25049 + vci_kernel_config());
25052 +static int proc_virtual_info(char *buffer)
25054 + return proc_vci(buffer);
25057 +static int proc_virtual_status(char *buffer)
25059 + return sprintf(buffer,
25061 + "#CActive:\t%d\n"
25062 + "#NSProxy:\t%d\t%d %d %d %d\n",
25063 + atomic_read(&vx_global_ctotal),
25064 + atomic_read(&vx_global_cactive),
25065 + atomic_read(&vs_global_nsproxy),
25066 + atomic_read(&vs_global_fs),
25067 + atomic_read(&vs_global_mnt_ns),
25068 + atomic_read(&vs_global_uts_ns),
25069 + atomic_read(&vs_global_ipc_ns));
25073 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
25077 + length = sprintf(buffer,
25085 + vxi->vx_badness_bias);
25089 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
25093 + length = sprintf(buffer,
25096 + "Flags:\t%016llx\n"
25097 + "BCaps:\t%016llx\n"
25098 + "CCaps:\t%016llx\n"
25099 + "Spaces:\t%08lx\n",
25100 + atomic_read(&vxi->vx_usecnt),
25101 + atomic_read(&vxi->vx_tasks),
25102 + (unsigned long long)vxi->vx_flags,
25103 + (unsigned long long)vxi->vx_bcaps,
25104 + (unsigned long long)vxi->vx_ccaps,
25109 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
25111 + return vx_info_proc_limit(&vxi->limit, buffer);
25114 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
25118 + length = vx_info_proc_sched(&vxi->sched, buffer);
25119 + for_each_online_cpu(cpu) {
25120 + length += vx_info_proc_sched_pc(
25121 + &vx_per_cpu(vxi, sched_pc, cpu),
25122 + buffer + length, cpu);
25127 +int proc_vxi_nsproxy(struct vx_info *vxi, char *buffer)
25129 + return vx_info_proc_nsproxy(vxi->vx_nsproxy, buffer);
25132 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
25136 + vx_update_load(vxi);
25137 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
25138 + for_each_online_cpu(cpu) {
25139 + length += vx_info_proc_cvirt_pc(
25140 + &vx_per_cpu(vxi, cvirt_pc, cpu),
25141 + buffer + length, cpu);
25146 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
25148 + return vx_info_proc_cacct(&vxi->cacct, buffer);
25152 +static int proc_virtnet_info(char *buffer)
25154 + return proc_vci(buffer);
25157 +static int proc_virtnet_status(char *buffer)
25159 + return sprintf(buffer,
25161 + "#CActive:\t%d\n",
25162 + atomic_read(&nx_global_ctotal),
25163 + atomic_read(&nx_global_cactive));
25166 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
25168 + struct nx_addr_v4 *v4a;
25169 +#ifdef CONFIG_IPV6
25170 + struct nx_addr_v6 *v6a;
25174 + length = sprintf(buffer,
25177 + "Bcast:\t" NIPQUAD_FMT "\n"
25178 + "Lback:\t" NIPQUAD_FMT "\n",
25181 + NIPQUAD(nxi->v4_bcast.s_addr),
25182 + NIPQUAD(nxi->v4_lback.s_addr));
25184 + if (!NX_IPV4(nxi))
25186 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
25187 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
25190 +#ifdef CONFIG_IPV6
25191 + if (!NX_IPV6(nxi))
25193 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
25194 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
25201 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
25205 + length = sprintf(buffer,
25208 + "Flags:\t%016llx\n"
25209 + "NCaps:\t%016llx\n",
25210 + atomic_read(&nxi->nx_usecnt),
25211 + atomic_read(&nxi->nx_tasks),
25212 + (unsigned long long)nxi->nx_flags,
25213 + (unsigned long long)nxi->nx_ncaps);
25219 +/* here the inode helpers */
25225 + struct inode_operations *iop;
25226 + struct file_operations *fop;
25227 + union proc_op op;
25230 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
25232 + struct inode *inode = new_inode(sb);
25237 + inode->i_mode = p->mode;
25239 + inode->i_op = p->iop;
25241 + inode->i_fop = p->fop;
25243 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
25244 + inode->i_flags |= S_IMMUTABLE;
25246 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
25248 + inode->i_uid = 0;
25249 + inode->i_gid = 0;
25250 + inode->i_tag = 0;
25255 +static struct dentry *vs_proc_instantiate(struct inode *dir,
25256 + struct dentry *dentry, int id, void *ptr)
25258 + struct vs_entry *p = ptr;
25259 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
25260 + struct dentry *error = ERR_PTR(-EINVAL);
25265 + PROC_I(inode)->op = p->op;
25266 + PROC_I(inode)->fd = id;
25267 + d_add(dentry, inode);
25275 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
25278 + * Fill a directory entry.
25280 + * If possible create the dcache entry and derive our inode number and
25281 + * file type from dcache entry.
25283 + * Since all of the proc inode numbers are dynamically generated, the inode
25284 + * numbers do not exist until the inode is cache. This means creating the
25285 + * the dcache entry in readdir is necessary to keep the inode numbers
25286 + * reported by readdir in sync with the inode numbers reported
25289 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
25290 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
25292 + struct dentry *child, *dir = filp->f_dentry;
25293 + struct inode *inode;
25294 + struct qstr qname;
25296 + unsigned type = DT_UNKNOWN;
25298 + qname.name = name;
25300 + qname.hash = full_name_hash(name, len);
25302 + child = d_lookup(dir, &qname);
25304 + struct dentry *new;
25305 + new = d_alloc(dir, &qname);
25307 + child = instantiate(dir->d_inode, new, id, ptr);
25314 + if (!child || IS_ERR(child) || !child->d_inode)
25315 + goto end_instantiate;
25316 + inode = child->d_inode;
25318 + ino = inode->i_ino;
25319 + type = inode->i_mode >> 12;
25324 + ino = find_inode_number(dir, &qname);
25327 + return filldir(dirent, name, len, filp->f_pos, ino, type);
25332 +/* get and revalidate vx_info/xid */
25335 +struct vx_info *get_proc_vx_info(struct inode *inode)
25337 + return lookup_vx_info(PROC_I(inode)->fd);
25340 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
25342 + struct inode *inode = dentry->d_inode;
25343 + xid_t xid = PROC_I(inode)->fd;
25345 + if (!xid || xid_is_hashed(xid))
25352 +/* get and revalidate nx_info/nid */
25354 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
25356 + struct inode *inode = dentry->d_inode;
25357 + nid_t nid = PROC_I(inode)->fd;
25359 + if (!nid || nid_is_hashed(nid))
25367 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
25369 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
25370 + size_t count, loff_t *ppos)
25372 + struct inode *inode = file->f_dentry->d_inode;
25373 + unsigned long page;
25374 + ssize_t length = 0;
25376 + if (count > PROC_BLOCK_SIZE)
25377 + count = PROC_BLOCK_SIZE;
25379 + /* fade that out as soon as stable */
25380 + WARN_ON(PROC_I(inode)->fd);
25382 + if (!(page = __get_free_page(GFP_KERNEL)))
25385 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
25386 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
25389 + length = simple_read_from_buffer(buf, count, ppos,
25390 + (char *)page, length);
25396 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
25397 + size_t count, loff_t *ppos)
25399 + struct inode *inode = file->f_dentry->d_inode;
25400 + struct vx_info *vxi = NULL;
25401 + xid_t xid = PROC_I(inode)->fd;
25402 + unsigned long page;
25403 + ssize_t length = 0;
25405 + if (count > PROC_BLOCK_SIZE)
25406 + count = PROC_BLOCK_SIZE;
25408 + /* fade that out as soon as stable */
25410 + vxi = lookup_vx_info(xid);
25414 + length = -ENOMEM;
25415 + if (!(page = __get_free_page(GFP_KERNEL)))
25418 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
25419 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
25422 + length = simple_read_from_buffer(buf, count, ppos,
25423 + (char *)page, length);
25427 + put_vx_info(vxi);
25432 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
25433 + size_t count, loff_t *ppos)
25435 + struct inode *inode = file->f_dentry->d_inode;
25436 + struct nx_info *nxi = NULL;
25437 + nid_t nid = PROC_I(inode)->fd;
25438 + unsigned long page;
25439 + ssize_t length = 0;
25441 + if (count > PROC_BLOCK_SIZE)
25442 + count = PROC_BLOCK_SIZE;
25444 + /* fade that out as soon as stable */
25446 + nxi = lookup_nx_info(nid);
25450 + length = -ENOMEM;
25451 + if (!(page = __get_free_page(GFP_KERNEL)))
25454 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
25455 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
25458 + length = simple_read_from_buffer(buf, count, ppos,
25459 + (char *)page, length);
25463 + put_nx_info(nxi);
25470 +/* here comes the lower level */
25473 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
25474 + .len = sizeof(NAME) - 1, \
25475 + .name = (NAME), \
25483 +#define DIR(NAME, MODE, OTYPE) \
25484 + NOD(NAME, (S_IFDIR | (MODE)), \
25485 + &proc_ ## OTYPE ## _inode_operations, \
25486 + &proc_ ## OTYPE ## _file_operations, { } )
25488 +#define INF(NAME, MODE, OTYPE) \
25489 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25490 + &proc_vs_info_file_operations, \
25491 + { .proc_vs_read = &proc_##OTYPE } )
25493 +#define VINF(NAME, MODE, OTYPE) \
25494 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25495 + &proc_vx_info_file_operations, \
25496 + { .proc_vxi_read = &proc_##OTYPE } )
25498 +#define NINF(NAME, MODE, OTYPE) \
25499 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25500 + &proc_nx_info_file_operations, \
25501 + { .proc_nxi_read = &proc_##OTYPE } )
25504 +static struct file_operations proc_vs_info_file_operations = {
25505 + .read = proc_vs_info_read,
25508 +static struct file_operations proc_vx_info_file_operations = {
25509 + .read = proc_vx_info_read,
25512 +static struct dentry_operations proc_xid_dentry_operations = {
25513 + .d_revalidate = proc_xid_revalidate,
25516 +static struct vs_entry vx_base_stuff[] = {
25517 + VINF("info", S_IRUGO, vxi_info),
25518 + VINF("status", S_IRUGO, vxi_status),
25519 + VINF("limit", S_IRUGO, vxi_limit),
25520 + VINF("sched", S_IRUGO, vxi_sched),
25521 + VINF("nsproxy", S_IRUGO, vxi_nsproxy),
25522 + VINF("cvirt", S_IRUGO, vxi_cvirt),
25523 + VINF("cacct", S_IRUGO, vxi_cacct),
25530 +static struct dentry *proc_xid_instantiate(struct inode *dir,
25531 + struct dentry *dentry, int id, void *ptr)
25533 + dentry->d_op = &proc_xid_dentry_operations;
25534 + return vs_proc_instantiate(dir, dentry, id, ptr);
25537 +static struct dentry *proc_xid_lookup(struct inode *dir,
25538 + struct dentry *dentry, struct nameidata *nd)
25540 + struct vs_entry *p = vx_base_stuff;
25541 + struct dentry *error = ERR_PTR(-ENOENT);
25543 + for (; p->name; p++) {
25544 + if (p->len != dentry->d_name.len)
25546 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25552 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
25557 +static int proc_xid_readdir(struct file *filp,
25558 + void *dirent, filldir_t filldir)
25560 + struct dentry *dentry = filp->f_dentry;
25561 + struct inode *inode = dentry->d_inode;
25562 + struct vs_entry *p = vx_base_stuff;
25563 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
25567 + pos = filp->f_pos;
25570 + ino = inode->i_ino;
25571 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25574 + /* fall through */
25576 + ino = parent_ino(dentry);
25577 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25580 + /* fall through */
25583 + if (index >= size)
25585 + for (p += index; p->name; p++) {
25586 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25587 + vs_proc_instantiate, PROC_I(inode)->fd, p))
25593 + filp->f_pos = pos;
25599 +static struct file_operations proc_nx_info_file_operations = {
25600 + .read = proc_nx_info_read,
25603 +static struct dentry_operations proc_nid_dentry_operations = {
25604 + .d_revalidate = proc_nid_revalidate,
25607 +static struct vs_entry nx_base_stuff[] = {
25608 + NINF("info", S_IRUGO, nxi_info),
25609 + NINF("status", S_IRUGO, nxi_status),
25614 +static struct dentry *proc_nid_instantiate(struct inode *dir,
25615 + struct dentry *dentry, int id, void *ptr)
25617 + dentry->d_op = &proc_nid_dentry_operations;
25618 + return vs_proc_instantiate(dir, dentry, id, ptr);
25621 +static struct dentry *proc_nid_lookup(struct inode *dir,
25622 + struct dentry *dentry, struct nameidata *nd)
25624 + struct vs_entry *p = nx_base_stuff;
25625 + struct dentry *error = ERR_PTR(-ENOENT);
25627 + for (; p->name; p++) {
25628 + if (p->len != dentry->d_name.len)
25630 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25636 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
25641 +static int proc_nid_readdir(struct file *filp,
25642 + void *dirent, filldir_t filldir)
25644 + struct dentry *dentry = filp->f_dentry;
25645 + struct inode *inode = dentry->d_inode;
25646 + struct vs_entry *p = nx_base_stuff;
25647 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
25651 + pos = filp->f_pos;
25654 + ino = inode->i_ino;
25655 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25658 + /* fall through */
25660 + ino = parent_ino(dentry);
25661 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25664 + /* fall through */
25667 + if (index >= size)
25669 + for (p += index; p->name; p++) {
25670 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25671 + vs_proc_instantiate, PROC_I(inode)->fd, p))
25677 + filp->f_pos = pos;
25682 +#define MAX_MULBY10 ((~0U - 9) / 10)
25684 +static inline int atovid(const char *str, int len)
25689 + while (len-- > 0) {
25694 + if (vid >= MAX_MULBY10)
25704 +/* now the upper level (virtual) */
25707 +static struct file_operations proc_xid_file_operations = {
25708 + .read = generic_read_dir,
25709 + .readdir = proc_xid_readdir,
25712 +static struct inode_operations proc_xid_inode_operations = {
25713 + .lookup = proc_xid_lookup,
25716 +static struct vs_entry vx_virtual_stuff[] = {
25717 + INF("info", S_IRUGO, virtual_info),
25718 + INF("status", S_IRUGO, virtual_status),
25719 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
25723 +static struct dentry *proc_virtual_lookup(struct inode *dir,
25724 + struct dentry *dentry, struct nameidata *nd)
25726 + struct vs_entry *p = vx_virtual_stuff;
25727 + struct dentry *error = ERR_PTR(-ENOENT);
25730 + for (; p->name; p++) {
25731 + if (p->len != dentry->d_name.len)
25733 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25737 + goto instantiate;
25739 + id = atovid(dentry->d_name.name, dentry->d_name.len);
25740 + if ((id < 0) || !xid_is_hashed(id))
25744 + error = proc_xid_instantiate(dir, dentry, id, p);
25749 +static struct file_operations proc_nid_file_operations = {
25750 + .read = generic_read_dir,
25751 + .readdir = proc_nid_readdir,
25754 +static struct inode_operations proc_nid_inode_operations = {
25755 + .lookup = proc_nid_lookup,
25758 +static struct vs_entry nx_virtnet_stuff[] = {
25759 + INF("info", S_IRUGO, virtnet_info),
25760 + INF("status", S_IRUGO, virtnet_status),
25761 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
25765 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
25766 + struct dentry *dentry, struct nameidata *nd)
25768 + struct vs_entry *p = nx_virtnet_stuff;
25769 + struct dentry *error = ERR_PTR(-ENOENT);
25772 + for (; p->name; p++) {
25773 + if (p->len != dentry->d_name.len)
25775 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25779 + goto instantiate;
25781 + id = atovid(dentry->d_name.name, dentry->d_name.len);
25782 + if ((id < 0) || !nid_is_hashed(id))
25786 + error = proc_nid_instantiate(dir, dentry, id, p);
25793 +#define PROC_NUMBUF 10
25794 +#define PROC_MAXVIDS 32
25796 +int proc_virtual_readdir(struct file *filp,
25797 + void *dirent, filldir_t filldir)
25799 + struct dentry *dentry = filp->f_dentry;
25800 + struct inode *inode = dentry->d_inode;
25801 + struct vs_entry *p = vx_virtual_stuff;
25802 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
25804 + unsigned int xid_array[PROC_MAXVIDS];
25805 + char buf[PROC_NUMBUF];
25806 + unsigned int nr_xids, i;
25809 + pos = filp->f_pos;
25812 + ino = inode->i_ino;
25813 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25816 + /* fall through */
25818 + ino = parent_ino(dentry);
25819 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25822 + /* fall through */
25825 + if (index >= size)
25827 + for (p += index; p->name; p++) {
25828 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25829 + vs_proc_instantiate, 0, p))
25834 + index = pos - size;
25835 + p = &vx_virtual_stuff[size - 1];
25836 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
25837 + for (i = 0; i < nr_xids; i++) {
25838 + int n, xid = xid_array[i];
25839 + unsigned int j = PROC_NUMBUF;
25843 + buf[--j] = '0' + (n % 10);
25846 + if (proc_fill_cache(filp, dirent, filldir,
25847 + buf + j, PROC_NUMBUF - j,
25848 + vs_proc_instantiate, xid, p))
25854 + filp->f_pos = pos;
25858 +static int proc_virtual_getattr(struct vfsmount *mnt,
25859 + struct dentry *dentry, struct kstat *stat)
25861 + struct inode *inode = dentry->d_inode;
25863 + generic_fillattr(inode, stat);
25864 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
25868 +static struct file_operations proc_virtual_dir_operations = {
25869 + .read = generic_read_dir,
25870 + .readdir = proc_virtual_readdir,
25873 +static struct inode_operations proc_virtual_dir_inode_operations = {
25874 + .getattr = proc_virtual_getattr,
25875 + .lookup = proc_virtual_lookup,
25882 +int proc_virtnet_readdir(struct file *filp,
25883 + void *dirent, filldir_t filldir)
25885 + struct dentry *dentry = filp->f_dentry;
25886 + struct inode *inode = dentry->d_inode;
25887 + struct vs_entry *p = nx_virtnet_stuff;
25888 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
25890 + unsigned int nid_array[PROC_MAXVIDS];
25891 + char buf[PROC_NUMBUF];
25892 + unsigned int nr_nids, i;
25895 + pos = filp->f_pos;
25898 + ino = inode->i_ino;
25899 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25902 + /* fall through */
25904 + ino = parent_ino(dentry);
25905 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25908 + /* fall through */
25911 + if (index >= size)
25913 + for (p += index; p->name; p++) {
25914 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25915 + vs_proc_instantiate, 0, p))
25920 + index = pos - size;
25921 + p = &nx_virtnet_stuff[size - 1];
25922 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
25923 + for (i = 0; i < nr_nids; i++) {
25924 + int n, nid = nid_array[i];
25925 + unsigned int j = PROC_NUMBUF;
25929 + buf[--j] = '0' + (n % 10);
25932 + if (proc_fill_cache(filp, dirent, filldir,
25933 + buf + j, PROC_NUMBUF - j,
25934 + vs_proc_instantiate, nid, p))
25940 + filp->f_pos = pos;
25944 +static int proc_virtnet_getattr(struct vfsmount *mnt,
25945 + struct dentry *dentry, struct kstat *stat)
25947 + struct inode *inode = dentry->d_inode;
25949 + generic_fillattr(inode, stat);
25950 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
25954 +static struct file_operations proc_virtnet_dir_operations = {
25955 + .read = generic_read_dir,
25956 + .readdir = proc_virtnet_readdir,
25959 +static struct inode_operations proc_virtnet_dir_inode_operations = {
25960 + .getattr = proc_virtnet_getattr,
25961 + .lookup = proc_virtnet_lookup,
25966 +void proc_vx_init(void)
25968 + struct proc_dir_entry *ent;
25970 + ent = proc_mkdir("virtual", 0);
25972 + ent->proc_fops = &proc_virtual_dir_operations;
25973 + ent->proc_iops = &proc_virtual_dir_inode_operations;
25975 + proc_virtual = ent;
25977 + ent = proc_mkdir("virtnet", 0);
25979 + ent->proc_fops = &proc_virtnet_dir_operations;
25980 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
25982 + proc_virtnet = ent;
25988 +/* per pid info */
25991 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
25993 + struct vx_info *vxi;
25994 + char *orig = buffer;
25996 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
25998 + vxi = task_get_vx_info(p);
26002 + buffer += sprintf(buffer, "BCaps:\t%016llx\n",
26003 + (unsigned long long)vxi->vx_bcaps);
26004 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
26005 + (unsigned long long)vxi->vx_ccaps);
26006 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
26007 + (unsigned long long)vxi->vx_flags);
26008 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
26010 + put_vx_info(vxi);
26012 + return buffer - orig;
26016 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
26018 + struct nx_info *nxi;
26019 + struct nx_addr_v4 *v4a;
26020 +#ifdef CONFIG_IPV6
26021 + struct nx_addr_v6 *v6a;
26023 + char *orig = buffer;
26026 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
26028 + nxi = task_get_nx_info(p);
26032 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
26033 + (unsigned long long)nxi->nx_ncaps);
26034 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
26035 + (unsigned long long)nxi->nx_flags);
26037 + buffer += sprintf(buffer,
26038 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
26039 + NIPQUAD(nxi->v4_bcast.s_addr));
26040 + buffer += sprintf (buffer,
26041 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
26042 + NIPQUAD(nxi->v4_lback.s_addr));
26043 + if (!NX_IPV4(nxi))
26045 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
26046 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
26049 +#ifdef CONFIG_IPV6
26050 + if (!NX_IPV6(nxi))
26052 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
26053 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
26057 + put_nx_info(nxi);
26059 + return buffer - orig;
26062 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sched.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched.c
26063 --- linux-2.6.22.10/kernel/vserver/sched.c 1970-01-01 01:00:00 +0100
26064 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched.c 2007-08-15 23:32:49 +0200
26067 + * linux/kernel/vserver/sched.c
26069 + * Virtual Server: Scheduler Support
26071 + * Copyright (C) 2004-2007 Herbert Pötzl
26073 + * V0.01 adapted Sam Vilains version to 2.6.3
26074 + * V0.02 removed legacy interface
26075 + * V0.03 changed vcmds to vxi arg
26076 + * V0.04 removed older and legacy interfaces
26080 +#include <linux/vs_context.h>
26081 +#include <linux/vs_sched.h>
26082 +#include <linux/vserver/sched_cmd.h>
26084 +#include <asm/uaccess.h>
26087 +#define vxd_check_range(val, min, max) do { \
26088 + vxlprintk((val < min) || (val > max), \
26089 + "check_range(%ld,%ld,%ld)", \
26090 + (long)val, (long)min, (long)max, \
26091 + __FILE__, __LINE__); \
26095 +void vx_update_sched_param(struct _vx_sched *sched,
26096 + struct _vx_sched_pc *sched_pc)
26098 + unsigned int set_mask = sched->update_mask;
26100 + if (set_mask & VXSM_FILL_RATE)
26101 + sched_pc->fill_rate[0] = sched->fill_rate[0];
26102 + if (set_mask & VXSM_INTERVAL)
26103 + sched_pc->interval[0] = sched->interval[0];
26104 + if (set_mask & VXSM_FILL_RATE2)
26105 + sched_pc->fill_rate[1] = sched->fill_rate[1];
26106 + if (set_mask & VXSM_INTERVAL2)
26107 + sched_pc->interval[1] = sched->interval[1];
26108 + if (set_mask & VXSM_TOKENS)
26109 + sched_pc->tokens = sched->tokens;
26110 + if (set_mask & VXSM_TOKENS_MIN)
26111 + sched_pc->tokens_min = sched->tokens_min;
26112 + if (set_mask & VXSM_TOKENS_MAX)
26113 + sched_pc->tokens_max = sched->tokens_max;
26114 + if (set_mask & VXSM_PRIO_BIAS)
26115 + sched_pc->prio_bias = sched->prio_bias;
26117 + if (set_mask & VXSM_IDLE_TIME)
26118 + sched_pc->flags |= VXSF_IDLE_TIME;
26120 + sched_pc->flags &= ~VXSF_IDLE_TIME;
26123 + sched_pc->norm_time = jiffies;
26128 + * recalculate the context's scheduling tokens
26130 + * ret > 0 : number of tokens available
26131 + * ret < 0 : on hold, check delta_min[]
26132 + * -1 only jiffies
26133 + * -2 also idle time
26136 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
26137 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
26141 + int flags = sched_pc->flags;
26143 + /* how much time did pass? */
26144 + delta = *norm_time - sched_pc->norm_time;
26145 + vxd_check_range(delta, 0, INT_MAX);
26147 + if (delta >= sched_pc->interval[0]) {
26148 + long tokens, integral;
26150 + /* calc integral token part */
26151 + tokens = delta / sched_pc->interval[0];
26152 + integral = tokens * sched_pc->interval[0];
26153 + tokens *= sched_pc->fill_rate[0];
26154 +#ifdef CONFIG_VSERVER_HARDCPU
26155 + delta_min[0] = delta - integral;
26156 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
26158 + /* advance time */
26159 + sched_pc->norm_time += delta;
26162 + sched_pc->tokens += tokens;
26163 + sched_pc->token_time += tokens;
26165 + delta_min[0] = delta;
26167 +#ifdef CONFIG_VSERVER_IDLETIME
26168 + if (!(flags & VXSF_IDLE_TIME))
26171 + /* how much was the idle skip? */
26172 + delta = *idle_time - sched_pc->idle_time;
26173 + vxd_check_range(delta, 0, INT_MAX);
26175 + if (delta >= sched_pc->interval[1]) {
26176 + long tokens, integral;
26178 + /* calc fair share token part */
26179 + tokens = delta / sched_pc->interval[1];
26180 + integral = tokens * sched_pc->interval[1];
26181 + tokens *= sched_pc->fill_rate[1];
26182 + delta_min[1] = delta - integral;
26183 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
26185 + /* advance idle time */
26186 + sched_pc->idle_time += integral;
26189 + sched_pc->tokens += tokens;
26190 + sched_pc->token_time += tokens;
26192 + delta_min[1] = delta;
26196 + /* clip at maximum */
26197 + if (sched_pc->tokens > sched_pc->tokens_max)
26198 + sched_pc->tokens = sched_pc->tokens_max;
26199 + tokens = sched_pc->tokens;
26201 + if ((flags & VXSF_ONHOLD)) {
26202 + /* can we unhold? */
26203 + if (tokens >= sched_pc->tokens_min) {
26204 + flags &= ~VXSF_ONHOLD;
26205 + sched_pc->hold_ticks +=
26206 + *norm_time - sched_pc->onhold;
26210 + /* put on hold? */
26211 + if (tokens <= 0) {
26212 + flags |= VXSF_ONHOLD;
26213 + sched_pc->onhold = *norm_time;
26217 + sched_pc->flags = flags;
26221 + tokens = sched_pc->tokens_min - tokens;
26222 + sched_pc->flags = flags;
26223 + BUG_ON(tokens < 0);
26225 +#ifdef CONFIG_VSERVER_HARDCPU
26226 + /* next interval? */
26227 + if (!sched_pc->fill_rate[0])
26228 + delta_min[0] = HZ;
26229 + else if (tokens > sched_pc->fill_rate[0])
26230 + delta_min[0] += sched_pc->interval[0] *
26231 + tokens / sched_pc->fill_rate[0];
26233 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
26234 + vxd_check_range(delta_min[0], 0, INT_MAX);
26236 +#ifdef CONFIG_VSERVER_IDLETIME
26237 + if (!(flags & VXSF_IDLE_TIME))
26240 + /* next interval? */
26241 + if (!sched_pc->fill_rate[1])
26242 + delta_min[1] = HZ;
26243 + else if (tokens > sched_pc->fill_rate[1])
26244 + delta_min[1] += sched_pc->interval[1] *
26245 + tokens / sched_pc->fill_rate[1];
26247 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
26248 + vxd_check_range(delta_min[1], 0, INT_MAX);
26253 +#endif /* CONFIG_VSERVER_IDLETIME */
26256 +#endif /* CONFIG_VSERVER_HARDCPU */
26259 +static inline unsigned long msec_to_ticks(unsigned long msec)
26261 + return msecs_to_jiffies(msec);
26264 +static inline unsigned long ticks_to_msec(unsigned long ticks)
26266 + return jiffies_to_msecs(ticks);
26269 +static inline unsigned long ticks_to_usec(unsigned long ticks)
26271 + return jiffies_to_usecs(ticks);
26275 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
26277 + unsigned int set_mask = data->mask;
26278 + unsigned int update_mask;
26281 + /* Sanity check data values */
26282 + if (data->tokens_max <= 0)
26283 + data->tokens_max = HZ;
26284 + if (data->tokens_min < 0)
26285 + data->tokens_min = HZ / 3;
26286 + if (data->tokens_min >= data->tokens_max)
26287 + data->tokens_min = data->tokens_max;
26289 + if (data->prio_bias > MAX_PRIO_BIAS)
26290 + data->prio_bias = MAX_PRIO_BIAS;
26291 + if (data->prio_bias < MIN_PRIO_BIAS)
26292 + data->prio_bias = MIN_PRIO_BIAS;
26294 + spin_lock(&vxi->sched.tokens_lock);
26296 + /* sync up on delayed updates */
26297 + for_each_cpu_mask(cpu, vxi->sched.update)
26298 + vx_update_sched_param(&vxi->sched,
26299 + &vx_per_cpu(vxi, sched_pc, cpu));
26301 + if (set_mask & VXSM_FILL_RATE)
26302 + vxi->sched.fill_rate[0] = data->fill_rate[0];
26303 + if (set_mask & VXSM_FILL_RATE2)
26304 + vxi->sched.fill_rate[1] = data->fill_rate[1];
26305 + if (set_mask & VXSM_INTERVAL)
26306 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
26307 + msec_to_ticks(data->interval[0]) : data->interval[0];
26308 + if (set_mask & VXSM_INTERVAL2)
26309 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
26310 + msec_to_ticks(data->interval[1]) : data->interval[1];
26311 + if (set_mask & VXSM_TOKENS)
26312 + vxi->sched.tokens = data->tokens;
26313 + if (set_mask & VXSM_TOKENS_MIN)
26314 + vxi->sched.tokens_min = data->tokens_min;
26315 + if (set_mask & VXSM_TOKENS_MAX)
26316 + vxi->sched.tokens_max = data->tokens_max;
26317 + if (set_mask & VXSM_PRIO_BIAS)
26318 + vxi->sched.prio_bias = data->prio_bias;
26320 + /* Sanity check rate/interval */
26321 + for (i = 0; i < 2; i++) {
26322 + if (data->fill_rate[i] < 0)
26323 + data->fill_rate[i] = 0;
26324 + if (data->interval[i] <= 0)
26325 + data->interval[i] = HZ;
26328 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
26329 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
26330 + vxi->sched.update_mask = update_mask;
26334 + if (set_mask & VXSM_CPU_ID) {
26335 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
26336 + cpus_and(vxi->sched.update, cpu_online_map,
26337 + vxi->sched.update);
26339 + vxi->sched.update = cpu_online_map;
26341 + /* forced reload? */
26342 + if (set_mask & VXSM_FORCE) {
26343 + for_each_cpu_mask(cpu, vxi->sched.update)
26344 + vx_update_sched_param(&vxi->sched,
26345 + &vx_per_cpu(vxi, sched_pc, cpu));
26346 + vxi->sched.update = CPU_MASK_NONE;
26349 + /* on UP we update immediately */
26350 + vx_update_sched_param(&vxi->sched,
26351 + &vx_per_cpu(vxi, sched_pc, 0));
26354 + spin_unlock(&vxi->sched.tokens_lock);
26359 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
26360 +#define COPY_PRI(C) C(prio_bias)
26361 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
26362 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
26363 + C(fill_rate[1]); C(interval[1]);
26365 +#define COPY_VALUE(name) vc_data.name = data->name
26367 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
26369 + struct vcmd_sched_v5 vc_data;
26371 + vc_data.mask = data->set_mask;
26372 + COPY_IDS(COPY_VALUE);
26373 + COPY_PRI(COPY_VALUE);
26374 + COPY_TOK(COPY_VALUE);
26375 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
26376 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
26377 + return do_set_sched(vxi, &vc_data);
26380 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
26382 + struct vcmd_set_sched_v4 vc_data;
26384 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26387 + return do_set_sched_v4(vxi, &vc_data);
26390 + /* latest interface is v5 */
26392 +int vc_set_sched(struct vx_info *vxi, void __user *data)
26394 + struct vcmd_sched_v5 vc_data;
26396 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26399 + return do_set_sched(vxi, &vc_data);
26403 +#define COPY_PRI(C) C(prio_bias)
26404 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
26405 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
26406 + C(fill_rate[1]); C(interval[1]);
26408 +#define COPY_VALUE(name) vc_data.name = data->name
26411 +int vc_get_sched(struct vx_info *vxi, void __user *data)
26413 + struct vcmd_sched_v5 vc_data;
26415 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26418 + if (vc_data.mask & VXSM_CPU_ID) {
26419 + int cpu = vc_data.cpu_id;
26420 + struct _vx_sched_pc *data;
26422 + if (!cpu_possible(cpu))
26425 + data = &vx_per_cpu(vxi, sched_pc, cpu);
26426 + COPY_TOK(COPY_VALUE);
26427 + COPY_PRI(COPY_VALUE);
26428 + COPY_FRI(COPY_VALUE);
26430 + if (data->flags & VXSF_IDLE_TIME)
26431 + vc_data.mask |= VXSM_IDLE_TIME;
26433 + struct _vx_sched *data = &vxi->sched;
26435 + COPY_TOK(COPY_VALUE);
26436 + COPY_PRI(COPY_VALUE);
26437 + COPY_FRI(COPY_VALUE);
26440 + if (vc_data.mask & VXSM_MSEC) {
26441 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
26442 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
26445 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26451 +int vc_sched_info(struct vx_info *vxi, void __user *data)
26453 + struct vcmd_sched_info vc_data;
26456 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26459 + cpu = vc_data.cpu_id;
26460 + if (!cpu_possible(cpu))
26464 + struct _vx_sched_pc *sched_pc =
26465 + &vx_per_cpu(vxi, sched_pc, cpu);
26467 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
26468 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
26469 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
26470 + vc_data.vavavoom = sched_pc->vavavoom;
26472 + vc_data.token_usec = ticks_to_usec(1);
26474 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26479 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sched_init.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched_init.h
26480 --- linux-2.6.22.10/kernel/vserver/sched_init.h 1970-01-01 01:00:00 +0100
26481 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched_init.h 2007-08-05 20:53:13 +0200
26484 +static inline void vx_info_init_sched(struct _vx_sched *sched)
26486 + static struct lock_class_key tokens_lock_key;
26488 + /* scheduling; hard code starting values as constants */
26489 + sched->fill_rate[0] = 1;
26490 + sched->interval[0] = 4;
26491 + sched->fill_rate[1] = 1;
26492 + sched->interval[1] = 8;
26493 + sched->tokens = HZ >> 2;
26494 + sched->tokens_min = HZ >> 4;
26495 + sched->tokens_max = HZ >> 1;
26496 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
26497 + sched->prio_bias = 0;
26499 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
26503 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
26505 + sched_pc->fill_rate[0] = 1;
26506 + sched_pc->interval[0] = 4;
26507 + sched_pc->fill_rate[1] = 1;
26508 + sched_pc->interval[1] = 8;
26509 + sched_pc->tokens = HZ >> 2;
26510 + sched_pc->tokens_min = HZ >> 4;
26511 + sched_pc->tokens_max = HZ >> 1;
26512 + sched_pc->prio_bias = 0;
26513 + sched_pc->vavavoom = 0;
26514 + sched_pc->token_time = 0;
26515 + sched_pc->idle_time = 0;
26516 + sched_pc->norm_time = jiffies;
26518 + sched_pc->user_ticks = 0;
26519 + sched_pc->sys_ticks = 0;
26520 + sched_pc->hold_ticks = 0;
26523 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
26529 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
26533 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sched_proc.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched_proc.h
26534 --- linux-2.6.22.10/kernel/vserver/sched_proc.h 1970-01-01 01:00:00 +0100
26535 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched_proc.h 2007-08-05 20:53:13 +0200
26537 +#ifndef _VX_SCHED_PROC_H
26538 +#define _VX_SCHED_PROC_H
26542 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
26546 + length += sprintf(buffer,
26547 + "FillRate:\t%8d,%d\n"
26548 + "Interval:\t%8d,%d\n"
26549 + "TokensMin:\t%8d\n"
26550 + "TokensMax:\t%8d\n"
26551 + "PrioBias:\t%8d\n",
26552 + sched->fill_rate[0],
26553 + sched->fill_rate[1],
26554 + sched->interval[0],
26555 + sched->interval[1],
26556 + sched->tokens_min,
26557 + sched->tokens_max,
26558 + sched->prio_bias);
26563 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
26564 + char *buffer, int cpu)
26568 + length += sprintf(buffer + length,
26569 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
26570 + (unsigned long long)sched_pc->user_ticks,
26571 + (unsigned long long)sched_pc->sys_ticks,
26572 + (unsigned long long)sched_pc->hold_ticks,
26573 + sched_pc->token_time,
26574 + sched_pc->idle_time);
26575 + length += sprintf(buffer + length,
26576 + " %c%c %d %d %d %d/%d %d/%d",
26577 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
26578 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
26579 + sched_pc->tokens,
26580 + sched_pc->tokens_min,
26581 + sched_pc->tokens_max,
26582 + sched_pc->fill_rate[0],
26583 + sched_pc->interval[0],
26584 + sched_pc->fill_rate[1],
26585 + sched_pc->interval[1]);
26586 + length += sprintf(buffer + length,
26588 + sched_pc->prio_bias,
26589 + sched_pc->vavavoom);
26593 +#endif /* _VX_SCHED_PROC_H */
26594 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/signal.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/signal.c
26595 --- linux-2.6.22.10/kernel/vserver/signal.c 1970-01-01 01:00:00 +0100
26596 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/signal.c 2007-08-15 23:34:41 +0200
26599 + * linux/kernel/vserver/signal.c
26601 + * Virtual Server: Signal Support
26603 + * Copyright (C) 2003-2007 Herbert Pötzl
26605 + * V0.01 broken out from vcontext V0.05
26606 + * V0.02 changed vcmds to vxi arg
26607 + * V0.03 adjusted siginfo for kill
26611 +#include <asm/uaccess.h>
26613 +#include <linux/vs_context.h>
26614 +#include <linux/vserver/signal_cmd.h>
26617 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
26619 + int retval, count = 0;
26620 + struct task_struct *p;
26621 + struct siginfo *sip = SEND_SIG_PRIV;
26624 + vxdprintk(VXD_CBIT(misc, 4),
26625 + "vx_info_kill(%p[#%d],%d,%d)*",
26626 + vxi, vxi->vx_id, pid, sig);
26627 + read_lock(&tasklist_lock);
26631 + for_each_process(p) {
26634 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
26635 + (pid && vxi->vx_initpid == p->pid))
26638 + err = group_send_sig_info(sig, sip, p);
26640 + if (err != -EPERM)
26646 + if (vxi->vx_initpid) {
26647 + pid = vxi->vx_initpid;
26648 + /* for now, only SIGINT to private init ... */
26649 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
26650 + /* ... as long as there are tasks left */
26651 + (atomic_read(&vxi->vx_tasks) > 1))
26654 + /* fallthrough */
26656 + p = find_task_by_real_pid(pid);
26658 + if (vx_task_xid(p) == vxi->vx_id)
26659 + retval = group_send_sig_info(sig, sip, p);
26663 + read_unlock(&tasklist_lock);
26664 + vxdprintk(VXD_CBIT(misc, 4),
26665 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
26666 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
26670 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
26672 + struct vcmd_ctx_kill_v0 vc_data;
26674 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26677 + /* special check to allow guest shutdown */
26678 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
26679 + /* forbid killall pid=0 when init is present */
26680 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
26681 + (vc_data.pid > 1)))
26684 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
26688 +static int __wait_exit(struct vx_info *vxi)
26690 + DECLARE_WAITQUEUE(wait, current);
26693 + add_wait_queue(&vxi->vx_wait, &wait);
26694 + set_current_state(TASK_INTERRUPTIBLE);
26697 + if (vx_info_state(vxi,
26698 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
26700 + if (signal_pending(current)) {
26701 + ret = -ERESTARTSYS;
26708 + set_current_state(TASK_RUNNING);
26709 + remove_wait_queue(&vxi->vx_wait, &wait);
26715 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
26717 + struct vcmd_wait_exit_v0 vc_data;
26720 + ret = __wait_exit(vxi);
26721 + vc_data.reboot_cmd = vxi->reboot_cmd;
26722 + vc_data.exit_code = vxi->exit_code;
26724 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26729 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/space.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/space.c
26730 --- linux-2.6.22.10/kernel/vserver/space.c 1970-01-01 01:00:00 +0100
26731 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/space.c 2007-08-15 23:39:13 +0200
26734 + * linux/kernel/vserver/space.c
26736 + * Virtual Server: Context Space Support
26738 + * Copyright (C) 2003-2007 Herbert Pötzl
26740 + * V0.01 broken out from context.c 0.07
26741 + * V0.02 added task locking for namespace
26742 + * V0.03 broken out vx_enter_namespace
26743 + * V0.04 added *space support and commands
26747 +#include <linux/utsname.h>
26748 +#include <linux/nsproxy.h>
26749 +#include <linux/err.h>
26750 +#include <asm/uaccess.h>
26752 +#include <linux/vs_context.h>
26753 +#include <linux/vserver/space.h>
26754 +#include <linux/vserver/space_cmd.h>
26757 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
26758 +atomic_t vs_global_fs = ATOMIC_INIT(0);
26759 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
26760 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
26761 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
26764 +/* namespace functions */
26766 +#include <linux/mnt_namespace.h>
26768 +const struct vcmd_space_mask space_mask = {
26769 + .mask = CLONE_NEWNS |
26777 + * build a new nsproxy mix
26778 + * assumes that both proxies are 'const'
26779 + * does not touch nsproxy refcounts
26780 + * will hold a reference on the result.
26783 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
26784 + struct nsproxy *new_nsproxy, unsigned long mask)
26786 + struct mnt_namespace *old_ns;
26787 + struct uts_namespace *old_uts;
26788 + struct ipc_namespace *old_ipc;
26789 + struct nsproxy *nsproxy;
26791 + nsproxy = copy_nsproxy(old_nsproxy);
26795 + if (mask & CLONE_NEWNS) {
26796 + old_ns = nsproxy->mnt_ns;
26797 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
26798 + if (nsproxy->mnt_ns)
26799 + get_mnt_ns(nsproxy->mnt_ns);
26803 + if (mask & CLONE_NEWUTS) {
26804 + old_uts = nsproxy->uts_ns;
26805 + nsproxy->uts_ns = new_nsproxy->uts_ns;
26806 + if (nsproxy->uts_ns)
26807 + get_uts_ns(nsproxy->uts_ns);
26811 + if (mask & CLONE_NEWIPC) {
26812 + old_ipc = nsproxy->ipc_ns;
26813 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
26814 + if (nsproxy->ipc_ns)
26815 + get_ipc_ns(nsproxy->ipc_ns);
26820 + put_mnt_ns(old_ns);
26822 + put_uts_ns(old_uts);
26824 + put_ipc_ns(old_ipc);
26831 + * merge two nsproxy structs into a new one.
26832 + * will hold a reference on the result.
26836 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
26837 + struct nsproxy *proxy, unsigned long mask)
26839 + struct nsproxy null_proxy = { .mnt_ns = NULL };
26845 + /* vs_mix_nsproxy returns with reference */
26846 + return vs_mix_nsproxy(old ? old : &null_proxy,
26849 + get_nsproxy(proxy);
26854 + * merge two fs structs into a new one.
26855 + * will take a reference on the result.
26859 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
26860 + struct fs_struct *fs, unsigned long mask)
26862 + if (!(mask & CLONE_FS)) {
26864 + atomic_inc(&old->count);
26871 + return copy_fs_struct(fs);
26875 +int vx_enter_space(struct vx_info *vxi, unsigned long mask)
26877 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
26878 + struct fs_struct *fs, *fs_cur, *fs_new;
26881 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
26885 + mask = vxi->vx_nsmask;
26887 + if ((mask & vxi->vx_nsmask) != mask)
26890 + proxy = vxi->vx_nsproxy;
26893 + task_lock(current);
26894 + fs_cur = current->fs;
26895 + atomic_inc(&fs_cur->count);
26896 + proxy_cur = current->nsproxy;
26897 + get_nsproxy(proxy_cur);
26898 + task_unlock(current);
26900 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
26901 + if (IS_ERR(fs_new)) {
26902 + ret = PTR_ERR(fs_new);
26906 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
26907 + if (IS_ERR(proxy_new)) {
26908 + ret = PTR_ERR(proxy_new);
26912 + fs_new = xchg(¤t->fs, fs_new);
26913 + proxy_new = xchg(¤t->nsproxy, proxy_new);
26917 + put_nsproxy(proxy_new);
26920 + put_fs_struct(fs_new);
26923 + put_nsproxy(proxy_cur);
26925 + put_fs_struct(fs_cur);
26930 +int vx_set_space(struct vx_info *vxi, unsigned long mask)
26932 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
26933 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
26937 + mask = space_mask.mask;
26939 + if ((mask & space_mask.mask) != mask)
26942 + proxy_vxi = vxi->vx_nsproxy;
26943 + fs_vxi = vxi->vx_fs;
26945 + task_lock(current);
26946 + fs_cur = current->fs;
26947 + atomic_inc(&fs_cur->count);
26948 + proxy_cur = current->nsproxy;
26949 + get_nsproxy(proxy_cur);
26950 + task_unlock(current);
26952 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
26953 + if (IS_ERR(fs_new)) {
26954 + ret = PTR_ERR(fs_new);
26958 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
26959 + if (IS_ERR(proxy_new)) {
26960 + ret = PTR_ERR(proxy_new);
26964 + fs_new = xchg(&vxi->vx_fs, fs_new);
26965 + proxy_new = xchg(&vxi->vx_nsproxy, proxy_new);
26966 + vxi->vx_nsmask |= mask;
26970 + put_nsproxy(proxy_new);
26973 + put_fs_struct(fs_new);
26976 + put_nsproxy(proxy_cur);
26978 + put_fs_struct(fs_cur);
26983 +int vc_enter_space(struct vx_info *vxi, void __user *data)
26985 + struct vcmd_space_mask vc_data = { .mask = 0 };
26987 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
26990 + return vx_enter_space(vxi, vc_data.mask);
26993 +int vc_set_space(struct vx_info *vxi, void __user *data)
26995 + struct vcmd_space_mask vc_data = { .mask = 0 };
26997 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
27000 + return vx_set_space(vxi, vc_data.mask);
27003 +int vc_get_space_mask(struct vx_info *vxi, void __user *data)
27005 + if (copy_to_user(data, &space_mask, sizeof(space_mask)))
27010 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/switch.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/switch.c
27011 --- linux-2.6.22.10/kernel/vserver/switch.c 1970-01-01 01:00:00 +0100
27012 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/switch.c 2007-10-25 17:05:55 +0200
27015 + * linux/kernel/vserver/switch.c
27017 + * Virtual Server: Syscall Switch
27019 + * Copyright (C) 2003-2007 Herbert Pötzl
27021 + * V0.01 syscall switch
27022 + * V0.02 added signal to context
27023 + * V0.03 added rlimit functions
27024 + * V0.04 added iattr, task/xid functions
27025 + * V0.05 added debug/history stuff
27026 + * V0.06 added compat32 layer
27027 + * V0.07 vcmd args and perms
27028 + * V0.08 added status commands
27029 + * V0.09 added tag commands
27030 + * V0.10 added oom bias
27031 + * V0.11 added device commands
27035 +#include <linux/vs_context.h>
27036 +#include <linux/vs_network.h>
27037 +#include <linux/vserver/switch.h>
27039 +#include "vci_config.h"
27043 +int vc_get_version(uint32_t id)
27045 + return VCI_VERSION;
27049 +int vc_get_vci(uint32_t id)
27051 + return vci_kernel_config();
27054 +#include <linux/vserver/context_cmd.h>
27055 +#include <linux/vserver/cvirt_cmd.h>
27056 +#include <linux/vserver/cacct_cmd.h>
27057 +#include <linux/vserver/limit_cmd.h>
27058 +#include <linux/vserver/network_cmd.h>
27059 +#include <linux/vserver/sched_cmd.h>
27060 +#include <linux/vserver/debug_cmd.h>
27061 +#include <linux/vserver/inode_cmd.h>
27062 +#include <linux/vserver/dlimit_cmd.h>
27063 +#include <linux/vserver/signal_cmd.h>
27064 +#include <linux/vserver/space_cmd.h>
27065 +#include <linux/vserver/tag_cmd.h>
27066 +#include <linux/vserver/device_cmd.h>
27068 +#include <linux/vserver/inode.h>
27069 +#include <linux/vserver/dlimit.h>
27072 +#ifdef CONFIG_COMPAT
27073 +#define __COMPAT(name, id, data, compat) \
27074 + (compat) ? name ## _x32(id, data) : name(id, data)
27075 +#define __COMPAT_NO_ID(name, data, compat) \
27076 + (compat) ? name ## _x32(data) : name(data)
27078 +#define __COMPAT(name, id, data, compat) \
27080 +#define __COMPAT_NO_ID(name, data, compat) \
27086 +long do_vcmd(uint32_t cmd, uint32_t id,
27087 + struct vx_info *vxi, struct nx_info *nxi,
27088 + void __user *data, int compat)
27092 + case VCMD_get_version:
27093 + return vc_get_version(id);
27094 + case VCMD_get_vci:
27095 + return vc_get_vci(id);
27097 + case VCMD_task_xid:
27098 + return vc_task_xid(id);
27099 + case VCMD_vx_info:
27100 + return vc_vx_info(vxi, data);
27102 + case VCMD_task_nid:
27103 + return vc_task_nid(id);
27104 + case VCMD_nx_info:
27105 + return vc_nx_info(nxi, data);
27107 + case VCMD_task_tag:
27108 + return vc_task_tag(id);
27110 + /* this is version 1 */
27111 + case VCMD_set_space:
27112 + return vc_set_space(vxi, data);
27114 + case VCMD_get_space_mask:
27115 + return vc_get_space_mask(vxi, data);
27117 +#ifdef CONFIG_IA32_EMULATION
27118 + case VCMD_get_rlimit:
27119 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
27120 + case VCMD_set_rlimit:
27121 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
27123 + case VCMD_get_rlimit:
27124 + return vc_get_rlimit(vxi, data);
27125 + case VCMD_set_rlimit:
27126 + return vc_set_rlimit(vxi, data);
27128 + case VCMD_get_rlimit_mask:
27129 + return vc_get_rlimit_mask(id, data);
27130 + case VCMD_reset_minmax:
27131 + return vc_reset_minmax(vxi, data);
27133 + case VCMD_get_vhi_name:
27134 + return vc_get_vhi_name(vxi, data);
27135 + case VCMD_set_vhi_name:
27136 + return vc_set_vhi_name(vxi, data);
27138 + case VCMD_ctx_stat:
27139 + return vc_ctx_stat(vxi, data);
27140 + case VCMD_virt_stat:
27141 + return vc_virt_stat(vxi, data);
27142 + case VCMD_sock_stat:
27143 + return vc_sock_stat(vxi, data);
27144 + case VCMD_rlimit_stat:
27145 + return vc_rlimit_stat(vxi, data);
27147 + case VCMD_set_cflags:
27148 + return vc_set_cflags(vxi, data);
27149 + case VCMD_get_cflags:
27150 + return vc_get_cflags(vxi, data);
27152 + /* this is version 1 */
27153 + case VCMD_set_ccaps:
27154 + return vc_set_ccaps(vxi, data);
27155 + /* this is version 1 */
27156 + case VCMD_get_ccaps:
27157 + return vc_get_ccaps(vxi, data);
27158 + case VCMD_set_bcaps:
27159 + return vc_set_bcaps(vxi, data);
27160 + case VCMD_get_bcaps:
27161 + return vc_get_bcaps(vxi, data);
27163 + case VCMD_set_badness:
27164 + return vc_set_badness(vxi, data);
27165 + case VCMD_get_badness:
27166 + return vc_get_badness(vxi, data);
27168 + case VCMD_set_nflags:
27169 + return vc_set_nflags(nxi, data);
27170 + case VCMD_get_nflags:
27171 + return vc_get_nflags(nxi, data);
27173 + case VCMD_set_ncaps:
27174 + return vc_set_ncaps(nxi, data);
27175 + case VCMD_get_ncaps:
27176 + return vc_get_ncaps(nxi, data);
27178 + case VCMD_set_sched_v4:
27179 + return vc_set_sched_v4(vxi, data);
27180 + /* this is version 5 */
27181 + case VCMD_set_sched:
27182 + return vc_set_sched(vxi, data);
27183 + case VCMD_get_sched:
27184 + return vc_get_sched(vxi, data);
27185 + case VCMD_sched_info:
27186 + return vc_sched_info(vxi, data);
27188 + case VCMD_add_dlimit:
27189 + return __COMPAT(vc_add_dlimit, id, data, compat);
27190 + case VCMD_rem_dlimit:
27191 + return __COMPAT(vc_rem_dlimit, id, data, compat);
27192 + case VCMD_set_dlimit:
27193 + return __COMPAT(vc_set_dlimit, id, data, compat);
27194 + case VCMD_get_dlimit:
27195 + return __COMPAT(vc_get_dlimit, id, data, compat);
27197 + case VCMD_ctx_kill:
27198 + return vc_ctx_kill(vxi, data);
27200 + case VCMD_wait_exit:
27201 + return vc_wait_exit(vxi, data);
27203 + case VCMD_get_iattr:
27204 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
27205 + case VCMD_set_iattr:
27206 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
27208 + case VCMD_fget_iattr:
27209 + return vc_fget_iattr(id, data);
27210 + case VCMD_fset_iattr:
27211 + return vc_fset_iattr(id, data);
27213 + case VCMD_enter_space_v0:
27214 + return vc_enter_space(vxi, NULL);
27215 + /* this is version 1 */
27216 + case VCMD_enter_space:
27217 + return vc_enter_space(vxi, data);
27219 + case VCMD_ctx_create_v0:
27220 + return vc_ctx_create(id, NULL);
27221 + case VCMD_ctx_create:
27222 + return vc_ctx_create(id, data);
27223 + case VCMD_ctx_migrate_v0:
27224 + return vc_ctx_migrate(vxi, NULL);
27225 + case VCMD_ctx_migrate:
27226 + return vc_ctx_migrate(vxi, data);
27228 + case VCMD_net_create_v0:
27229 + return vc_net_create(id, NULL);
27230 + case VCMD_net_create:
27231 + return vc_net_create(id, data);
27232 + case VCMD_net_migrate:
27233 + return vc_net_migrate(nxi, data);
27235 + case VCMD_tag_migrate:
27236 + return vc_tag_migrate(id);
27238 + case VCMD_net_add:
27239 + return vc_net_add(nxi, data);
27240 + case VCMD_net_remove:
27241 + return vc_net_remove(nxi, data);
27243 + case VCMD_net_add_ipv4:
27244 + return vc_net_add_ipv4(nxi, data);
27245 + case VCMD_net_remove_ipv4:
27246 + return vc_net_remove_ipv4(nxi, data);
27247 +#ifdef CONFIG_IPV6
27248 + case VCMD_net_add_ipv6:
27249 + return vc_net_add_ipv6(nxi, data);
27250 + case VCMD_net_remove_ipv6:
27251 + return vc_net_remove_ipv6(nxi, data);
27253 +/* case VCMD_add_match_ipv4:
27254 + return vc_add_match_ipv4(nxi, data);
27255 + case VCMD_get_match_ipv4:
27256 + return vc_get_match_ipv4(nxi, data);
27257 +#ifdef CONFIG_IPV6
27258 + case VCMD_add_match_ipv6:
27259 + return vc_add_match_ipv6(nxi, data);
27260 + case VCMD_get_match_ipv6:
27261 + return vc_get_match_ipv6(nxi, data);
27264 +#ifdef CONFIG_VSERVER_DEVICE
27265 + case VCMD_set_mapping:
27266 + return __COMPAT(vc_set_mapping, vxi, data, compat);
27267 + case VCMD_unset_mapping:
27268 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
27270 +#ifdef CONFIG_VSERVER_HISTORY
27271 + case VCMD_dump_history:
27272 + return vc_dump_history(id);
27273 + case VCMD_read_history:
27274 + return __COMPAT(vc_read_history, id, data, compat);
27276 +#ifdef CONFIG_VSERVER_MONITOR
27277 + case VCMD_read_monitor:
27278 + return __COMPAT(vc_read_monitor, id, data, compat);
27281 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
27282 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
27288 +#define __VCMD(vcmd, _perm, _args, _flags) \
27289 + case VCMD_ ## vcmd: perm = _perm; \
27290 + args = _args; flags = _flags; break
27293 +#define VCA_NONE 0x00
27294 +#define VCA_VXI 0x01
27295 +#define VCA_NXI 0x02
27297 +#define VCF_NONE 0x00
27298 +#define VCF_INFO 0x01
27299 +#define VCF_ADMIN 0x02
27300 +#define VCF_ARES 0x06 /* includes admin */
27301 +#define VCF_SETUP 0x08
27303 +#define VCF_ZIDOK 0x10 /* zero id okay */
27307 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
27310 + int permit = -1, state = 0;
27311 + int perm = -1, args = 0, flags = 0;
27312 + struct vx_info *vxi = NULL;
27313 + struct nx_info *nxi = NULL;
27316 + /* unpriviledged commands */
27317 + __VCMD(get_version, 0, VCA_NONE, 0);
27318 + __VCMD(get_vci, 0, VCA_NONE, 0);
27319 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
27320 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
27322 + /* info commands */
27323 + __VCMD(task_xid, 2, VCA_NONE, 0);
27324 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
27325 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
27326 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
27327 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
27328 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
27329 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
27330 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
27331 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
27333 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
27334 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
27335 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
27336 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
27338 + __VCMD(task_nid, 2, VCA_NONE, 0);
27339 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
27340 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
27341 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
27343 + __VCMD(task_tag, 2, VCA_NONE, 0);
27345 + __VCMD(get_iattr, 2, VCA_NONE, 0);
27346 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
27347 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
27348 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
27349 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
27351 + /* lower admin commands */
27352 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
27353 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
27354 + __VCMD(ctx_create, 5, VCA_NONE, 0);
27355 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
27356 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
27357 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
27358 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
27360 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
27361 + __VCMD(net_create, 5, VCA_NONE, 0);
27362 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
27364 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
27366 + /* higher admin commands */
27367 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
27368 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27370 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27371 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27372 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27373 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27375 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27376 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27377 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27378 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27380 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
27381 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
27382 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27383 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27384 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27385 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27386 +#ifdef CONFIG_IPV6
27387 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27388 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27390 + __VCMD(set_iattr, 7, VCA_NONE, 0);
27391 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
27392 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
27393 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
27394 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
27396 +#ifdef CONFIG_VSERVER_DEVICE
27397 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
27398 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
27400 + /* debug level admin commands */
27401 +#ifdef CONFIG_VSERVER_HISTORY
27402 + __VCMD(dump_history, 9, VCA_NONE, 0);
27403 + __VCMD(read_history, 9, VCA_NONE, 0);
27405 +#ifdef CONFIG_VSERVER_MONITOR
27406 + __VCMD(read_monitor, 9, VCA_NONE, 0);
27413 + vxdprintk(VXD_CBIT(switch, 0),
27414 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
27415 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
27416 + VC_VERSION(cmd), id, data, compat,
27417 + perm, args, flags);
27424 + if (!capable(CAP_CONTEXT))
27428 + /* moved here from the individual commands */
27430 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
27434 + /* vcmd involves resource management */
27436 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
27440 + /* various legacy exceptions */
27442 + /* will go away when spectator is a cap */
27443 + case VCMD_ctx_migrate_v0:
27444 + case VCMD_ctx_migrate:
27446 + current->xid = 1;
27452 + /* will go away when spectator is a cap */
27453 + case VCMD_net_migrate:
27455 + current->nid = 1;
27462 + /* vcmds are fine by default */
27465 + /* admin type vcmds require admin ... */
27466 + if (flags & VCF_ADMIN)
27467 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
27469 + /* ... but setup type vcmds override that */
27470 + if (!permit && (flags & VCF_SETUP))
27471 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
27479 + if (!id && (flags & VCF_ZIDOK))
27483 + if (args & VCA_VXI) {
27484 + vxi = lookup_vx_info(id);
27488 + if ((flags & VCF_ADMIN) &&
27489 + /* special case kill for shutdown */
27490 + (cmd != VCMD_ctx_kill) &&
27491 + /* can context be administrated? */
27492 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
27498 + if (args & VCA_NXI) {
27499 + nxi = lookup_nx_info(id);
27503 + if ((flags & VCF_ADMIN) &&
27504 + /* can context be administrated? */
27505 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
27512 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
27515 + if ((args & VCA_NXI) && nxi)
27516 + put_nx_info(nxi);
27518 + if ((args & VCA_VXI) && vxi)
27519 + put_vx_info(vxi);
27521 + vxdprintk(VXD_CBIT(switch, 1),
27522 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
27523 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
27524 + VC_VERSION(cmd), ret, ret, state, permit);
27529 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
27531 + return do_vserver(cmd, id, data, 0);
27534 +#ifdef CONFIG_COMPAT
27537 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
27539 + return do_vserver(cmd, id, data, 1);
27542 +#endif /* CONFIG_COMPAT */
27543 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/sysctl.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sysctl.c
27544 --- linux-2.6.22.10/kernel/vserver/sysctl.c 1970-01-01 01:00:00 +0100
27545 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sysctl.c 2007-08-15 23:42:57 +0200
27548 + * kernel/vserver/sysctl.c
27550 + * Virtual Context Support
27552 + * Copyright (C) 2004-2007 Herbert Pötzl
27554 + * V0.01 basic structure
27558 +#include <linux/module.h>
27559 +#include <linux/ctype.h>
27560 +#include <linux/sysctl.h>
27561 +#include <linux/parser.h>
27562 +#include <asm/uaccess.h>
27565 +#define CTL_VSERVER 4242 /* unused? */
27568 + CTL_DEBUG_ERROR = 0,
27569 + CTL_DEBUG_SWITCH = 1,
27584 +unsigned int vx_debug_switch = 0;
27585 +unsigned int vx_debug_xid = 0;
27586 +unsigned int vx_debug_nid = 0;
27587 +unsigned int vx_debug_tag = 0;
27588 +unsigned int vx_debug_net = 0;
27589 +unsigned int vx_debug_limit = 0;
27590 +unsigned int vx_debug_cres = 0;
27591 +unsigned int vx_debug_dlim = 0;
27592 +unsigned int vx_debug_quota = 0;
27593 +unsigned int vx_debug_cvirt = 0;
27594 +unsigned int vx_debug_space = 0;
27595 +unsigned int vx_debug_misc = 0;
27598 +static struct ctl_table_header *vserver_table_header;
27599 +static ctl_table vserver_table[];
27602 +void vserver_register_sysctl(void)
27604 + if (!vserver_table_header) {
27605 + vserver_table_header = register_sysctl_table(vserver_table);
27610 +void vserver_unregister_sysctl(void)
27612 + if (vserver_table_header) {
27613 + unregister_sysctl_table(vserver_table_header);
27614 + vserver_table_header = NULL;
27619 +static int proc_dodebug(ctl_table *table, int write,
27620 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
27622 + char tmpbuf[20], *p, c;
27623 + unsigned int value;
27624 + size_t left, len;
27626 + if ((*ppos && !write) || !*lenp) {
27634 + if (!access_ok(VERIFY_READ, buffer, left))
27636 + p = (char *)buffer;
27637 + while (left && __get_user(c, p) >= 0 && isspace(c))
27642 + if (left > sizeof(tmpbuf) - 1)
27644 + if (copy_from_user(tmpbuf, p, left))
27646 + tmpbuf[left] = '\0';
27648 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
27649 + value = 10 * value + (*p - '0');
27650 + if (*p && !isspace(*p))
27652 + while (left && isspace(*p))
27654 + *(unsigned int *)table->data = value;
27656 + if (!access_ok(VERIFY_WRITE, buffer, left))
27658 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
27661 + if (__copy_to_user(buffer, tmpbuf, len))
27663 + if ((left -= len) > 0) {
27664 + if (put_user('\n', (char *)buffer + len))
27677 +#define CTL_ENTRY(ctl, name) \
27679 + .ctl_name = ctl, \
27680 + .procname = #name, \
27681 + .data = &vx_ ## name, \
27682 + .maxlen = sizeof(int), \
27684 + .proc_handler = &proc_dodebug \
27687 +static ctl_table debug_table[] = {
27688 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
27689 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
27690 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
27691 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
27692 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
27693 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
27694 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
27695 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
27696 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
27697 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
27698 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
27699 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
27700 + { .ctl_name = 0 }
27703 +static ctl_table vserver_table[] = {
27705 + .ctl_name = CTL_VSERVER,
27706 + .procname = "vserver",
27708 + .child = debug_table
27710 + { .ctl_name = 0 }
27714 +static match_table_t tokens = {
27715 + { CTL_DEBUG_SWITCH, "switch=%x" },
27716 + { CTL_DEBUG_XID, "xid=%x" },
27717 + { CTL_DEBUG_NID, "nid=%x" },
27718 + { CTL_DEBUG_TAG, "tag=%x" },
27719 + { CTL_DEBUG_NET, "net=%x" },
27720 + { CTL_DEBUG_LIMIT, "limit=%x" },
27721 + { CTL_DEBUG_CRES, "cres=%x" },
27722 + { CTL_DEBUG_DLIM, "dlim=%x" },
27723 + { CTL_DEBUG_QUOTA, "quota=%x" },
27724 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
27725 + { CTL_DEBUG_SPACE, "space=%x" },
27726 + { CTL_DEBUG_MISC, "misc=%x" },
27727 + { CTL_DEBUG_ERROR, NULL }
27730 +#define HANDLE_CASE(id, name, val) \
27731 + case CTL_DEBUG_ ## id: \
27732 + vx_debug_ ## name = val; \
27733 + printk("vs_debug_" #name "=0x%x\n", val); \
27737 +static int __init vs_debug_setup(char *str)
27742 + printk("vs_debug_setup(%s)\n", str);
27743 + while ((p = strsep(&str, ",")) != NULL) {
27744 + substring_t args[MAX_OPT_ARGS];
27745 + unsigned int value;
27750 + token = match_token(p, tokens, args);
27751 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
27754 + HANDLE_CASE(SWITCH, switch, value);
27755 + HANDLE_CASE(XID, xid, value);
27756 + HANDLE_CASE(NID, nid, value);
27757 + HANDLE_CASE(TAG, tag, value);
27758 + HANDLE_CASE(NET, net, value);
27759 + HANDLE_CASE(LIMIT, limit, value);
27760 + HANDLE_CASE(CRES, cres, value);
27761 + HANDLE_CASE(DLIM, dlim, value);
27762 + HANDLE_CASE(QUOTA, quota, value);
27763 + HANDLE_CASE(CVIRT, cvirt, value);
27764 + HANDLE_CASE(SPACE, space, value);
27765 + HANDLE_CASE(MISC, misc, value);
27774 +__setup("vsdebug=", vs_debug_setup);
27778 +EXPORT_SYMBOL_GPL(vx_debug_switch);
27779 +EXPORT_SYMBOL_GPL(vx_debug_xid);
27780 +EXPORT_SYMBOL_GPL(vx_debug_nid);
27781 +EXPORT_SYMBOL_GPL(vx_debug_net);
27782 +EXPORT_SYMBOL_GPL(vx_debug_limit);
27783 +EXPORT_SYMBOL_GPL(vx_debug_cres);
27784 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
27785 +EXPORT_SYMBOL_GPL(vx_debug_quota);
27786 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
27787 +EXPORT_SYMBOL_GPL(vx_debug_space);
27788 +EXPORT_SYMBOL_GPL(vx_debug_misc);
27790 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/tag.c linux-2.6.22.10-vs2.3.0.29/kernel/vserver/tag.c
27791 --- linux-2.6.22.10/kernel/vserver/tag.c 1970-01-01 01:00:00 +0100
27792 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/tag.c 2007-10-05 14:54:36 +0200
27795 + * linux/kernel/vserver/tag.c
27797 + * Virtual Server: Shallow Tag Space
27799 + * Copyright (C) 2007 Herbert Pötzl
27801 + * V0.01 basic implementation
27805 +#include <linux/sched.h>
27806 +#include <linux/vserver/debug.h>
27807 +#include <linux/vs_tag.h>
27809 +#include <linux/vserver/tag_cmd.h>
27812 +int dx_migrate_task(struct task_struct *p, tag_t tag)
27817 + vxdprintk(VXD_CBIT(tag, 5),
27818 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
27824 + vxdprintk(VXD_CBIT(tag, 5),
27825 + "moved task %p into [#%d]", p, tag);
27829 +/* vserver syscall commands below here */
27831 +/* taks xid and vx_info functions */
27834 +int vc_task_tag(uint32_t id)
27839 + struct task_struct *tsk;
27840 + read_lock(&tasklist_lock);
27841 + tsk = find_task_by_real_pid(id);
27842 + tag = (tsk) ? tsk->tag : -ESRCH;
27843 + read_unlock(&tasklist_lock);
27845 + tag = dx_current_tag();
27850 +int vc_tag_migrate(uint32_t tag)
27852 + return dx_migrate_task(current, tag & 0xFFFF);
27856 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/vci_config.h linux-2.6.22.10-vs2.3.0.29/kernel/vserver/vci_config.h
27857 --- linux-2.6.22.10/kernel/vserver/vci_config.h 1970-01-01 01:00:00 +0100
27858 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/vci_config.h 2007-08-16 03:56:22 +0200
27861 +/* interface version */
27863 +#define VCI_VERSION 0x00020302
27867 + VCI_KCBIT_NO_DYNAMIC = 0,
27869 + VCI_KCBIT_PROC_SECURE = 4,
27870 + VCI_KCBIT_HARDCPU = 5,
27871 + VCI_KCBIT_IDLELIMIT = 6,
27872 + VCI_KCBIT_IDLETIME = 7,
27874 + VCI_KCBIT_COWBL = 8,
27875 + VCI_KCBIT_FULLCOWBL = 9,
27876 + VCI_KCBIT_SPACES = 10,
27877 + VCI_KCBIT_NETV2 = 11,
27879 + VCI_KCBIT_DEBUG = 16,
27880 + VCI_KCBIT_HISTORY = 20,
27881 + VCI_KCBIT_TAGGED = 24,
27882 + VCI_KCBIT_PPTAG = 28,
27884 + VCI_KCBIT_MORE = 31,
27888 +static inline uint32_t vci_kernel_config(void)
27891 + (1 << VCI_KCBIT_NO_DYNAMIC) |
27893 + /* configured features */
27894 +#ifdef CONFIG_VSERVER_PROC_SECURE
27895 + (1 << VCI_KCBIT_PROC_SECURE) |
27897 +#ifdef CONFIG_VSERVER_HARDCPU
27898 + (1 << VCI_KCBIT_HARDCPU) |
27900 +#ifdef CONFIG_VSERVER_IDLELIMIT
27901 + (1 << VCI_KCBIT_IDLELIMIT) |
27903 +#ifdef CONFIG_VSERVER_IDLETIME
27904 + (1 << VCI_KCBIT_IDLETIME) |
27906 +#ifdef CONFIG_VSERVER_COWBL
27907 + (1 << VCI_KCBIT_COWBL) |
27908 + (1 << VCI_KCBIT_FULLCOWBL) |
27910 + (1 << VCI_KCBIT_SPACES) |
27911 + (1 << VCI_KCBIT_NETV2) |
27913 + /* debug options */
27914 +#ifdef CONFIG_VSERVER_DEBUG
27915 + (1 << VCI_KCBIT_DEBUG) |
27917 +#ifdef CONFIG_VSERVER_HISTORY
27918 + (1 << VCI_KCBIT_HISTORY) |
27921 + /* inode context tagging */
27922 +#if defined(CONFIG_TAGGING_NONE)
27923 + (0 << VCI_KCBIT_TAGGED) |
27924 +#elif defined(CONFIG_TAGGING_UID16)
27925 + (1 << VCI_KCBIT_TAGGED) |
27926 +#elif defined(CONFIG_TAGGING_GID16)
27927 + (2 << VCI_KCBIT_TAGGED) |
27928 +#elif defined(CONFIG_TAGGING_ID24)
27929 + (3 << VCI_KCBIT_TAGGED) |
27930 +#elif defined(CONFIG_TAGGING_INTERN)
27931 + (4 << VCI_KCBIT_TAGGED) |
27932 +#elif defined(CONFIG_TAGGING_RUNTIME)
27933 + (5 << VCI_KCBIT_TAGGED) |
27935 + (7 << VCI_KCBIT_TAGGED) |
27937 + (1 << VCI_KCBIT_PPTAG) |
27941 diff -NurpP --minimal linux-2.6.22.10/mm/filemap_xip.c linux-2.6.22.10-vs2.3.0.29/mm/filemap_xip.c
27942 --- linux-2.6.22.10/mm/filemap_xip.c 2007-07-09 13:20:04 +0200
27943 +++ linux-2.6.22.10-vs2.3.0.29/mm/filemap_xip.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/fremap.c linux-2.6.22.10-vs2.3.0.29/mm/fremap.c
27953 --- linux-2.6.22.10/mm/fremap.c 2007-02-06 03:01:56 +0100
27954 +++ linux-2.6.22.10-vs2.3.0.29/mm/fremap.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/hugetlb.c linux-2.6.22.10-vs2.3.0.29/mm/hugetlb.c
27973 --- linux-2.6.22.10/mm/hugetlb.c 2007-10-30 01:57:15 +0100
27974 +++ linux-2.6.22.10-vs2.3.0.29/mm/hugetlb.c 2007-08-11 22:41:51 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/memory.c linux-2.6.22.10-vs2.3.0.29/mm/memory.c
27984 --- linux-2.6.22.10/mm/memory.c 2007-07-09 13:20:04 +0200
27985 +++ linux-2.6.22.10-vs2.3.0.29/mm/memory.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/mlock.c linux-2.6.22.10-vs2.3.0.29/mm/mlock.c
28063 --- linux-2.6.22.10/mm/mlock.c 2007-10-30 01:57:15 +0100
28064 +++ linux-2.6.22.10-vs2.3.0.29/mm/mlock.c 2007-08-11 22:41:51 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/mmap.c linux-2.6.22.10-vs2.3.0.29/mm/mmap.c
28122 --- linux-2.6.22.10/mm/mmap.c 2007-07-09 13:20:04 +0200
28123 +++ linux-2.6.22.10-vs2.3.0.29/mm/mmap.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/mremap.c linux-2.6.22.10-vs2.3.0.29/mm/mremap.c
28233 --- linux-2.6.22.10/mm/mremap.c 2007-02-06 03:01:56 +0100
28234 +++ linux-2.6.22.10-vs2.3.0.29/mm/mremap.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/nommu.c linux-2.6.22.10-vs2.3.0.29/mm/nommu.c
28285 --- linux-2.6.22.10/mm/nommu.c 2007-07-09 13:20:04 +0200
28286 +++ linux-2.6.22.10-vs2.3.0.29/mm/nommu.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/oom_kill.c linux-2.6.22.10-vs2.3.0.29/mm/oom_kill.c
28315 --- linux-2.6.22.10/mm/oom_kill.c 2007-07-09 13:20:04 +0200
28316 +++ linux-2.6.22.10-vs2.3.0.29/mm/oom_kill.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/page_alloc.c linux-2.6.22.10-vs2.3.0.29/mm/page_alloc.c
28371 --- linux-2.6.22.10/mm/page_alloc.c 2007-07-09 13:20:04 +0200
28372 +++ linux-2.6.22.10-vs2.3.0.29/mm/page_alloc.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/rmap.c linux-2.6.22.10-vs2.3.0.29/mm/rmap.c
28403 --- linux-2.6.22.10/mm/rmap.c 2007-07-09 13:20:04 +0200
28404 +++ linux-2.6.22.10-vs2.3.0.29/mm/rmap.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/shmem.c linux-2.6.22.10-vs2.3.0.29/mm/shmem.c
28414 --- linux-2.6.22.10/mm/shmem.c 2007-07-09 13:20:04 +0200
28415 +++ linux-2.6.22.10-vs2.3.0.29/mm/shmem.c 2007-08-05 20:53:13 +0200
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 @@ -1734,7 +1733,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 @@ -2308,7 +2307,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 -NurpP --minimal linux-2.6.22.10/mm/slab.c linux-2.6.22.10-vs2.3.0.29/mm/slab.c
28443 --- linux-2.6.22.10/mm/slab.c 2007-07-09 13:20:04 +0200
28444 +++ linux-2.6.22.10-vs2.3.0.29/mm/slab.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/slab_vs.h linux-2.6.22.10-vs2.3.0.29/mm/slab_vs.h
28479 --- linux-2.6.22.10/mm/slab_vs.h 1970-01-01 01:00:00 +0100
28480 +++ linux-2.6.22.10-vs2.3.0.29/mm/slab_vs.h 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/mm/swapfile.c linux-2.6.22.10-vs2.3.0.29/mm/swapfile.c
28510 --- linux-2.6.22.10/mm/swapfile.c 2007-07-09 13:20:04 +0200
28511 +++ linux-2.6.22.10-vs2.3.0.29/mm/swapfile.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/net/core/dev.c linux-2.6.22.10-vs2.3.0.29/net/core/dev.c
28531 --- linux-2.6.22.10/net/core/dev.c 2007-10-30 01:57:15 +0100
28532 +++ linux-2.6.22.10-vs2.3.0.29/net/core/dev.c 2007-09-05 03:06:12 +0200
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 -NurpP --minimal linux-2.6.22.10/net/core/rtnetlink.c linux-2.6.22.10-vs2.3.0.29/net/core/rtnetlink.c
28561 --- linux-2.6.22.10/net/core/rtnetlink.c 2007-07-09 13:20:05 +0200
28562 +++ linux-2.6.22.10-vs2.3.0.29/net/core/rtnetlink.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/net/core/sock.c linux-2.6.22.10-vs2.3.0.29/net/core/sock.c
28583 --- linux-2.6.22.10/net/core/sock.c 2007-07-09 13:20:05 +0200
28584 +++ linux-2.6.22.10-vs2.3.0.29/net/core/sock.c 2007-10-01 14:57:43 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv4/af_inet.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/af_inet.c
28662 --- linux-2.6.22.10/net/ipv4/af_inet.c 2007-10-30 01:57:15 +0100
28663 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/af_inet.c 2007-10-05 14:54:36 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv4/devinet.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/devinet.c
28741 --- linux-2.6.22.10/net/ipv4/devinet.c 2007-10-30 01:57:15 +0100
28742 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/devinet.c 2007-09-30 14:58:01 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv4/fib_hash.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/fib_hash.c
28810 --- linux-2.6.22.10/net/ipv4/fib_hash.c 2007-07-09 13:20:05 +0200
28811 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/fib_hash.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv4/inet_connection_sock.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_connection_sock.c
28822 --- linux-2.6.22.10/net/ipv4/inet_connection_sock.c 2007-07-09 13:20:05 +0200
28823 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_connection_sock.c 2007-10-18 01:28:12 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv4/inet_diag.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_diag.c
28878 --- linux-2.6.22.10/net/ipv4/inet_diag.c 2007-10-30 01:57:15 +0100
28879 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_diag.c 2007-10-30 02:36:32 +0100
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(sk->sk_nx_info, inet->rcv_saddr);
28887 + r->id.idiag_dst[0] = nx_map_sock_lback(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(tw->tw_nx_info, tw->tw_rcv_saddr);
28898 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_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(sk->sk_nx_info, ireq->loc_addr);
28933 + r->id.idiag_dst[0] = nx_map_sock_lback(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 -NurpP --minimal linux-2.6.22.10/net/ipv4/inet_hashtables.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_hashtables.c
28973 --- linux-2.6.22.10/net/ipv4/inet_hashtables.c 2007-05-02 19:25:40 +0200
28974 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_hashtables.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv4/raw.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/raw.c
29000 --- linux-2.6.22.10/net/ipv4/raw.c 2007-07-09 13:20:06 +0200
29001 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/raw.c 2007-10-05 12:29:05 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv4/tcp.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp.c
29111 --- linux-2.6.22.10/net/ipv4/tcp.c 2007-10-30 01:57:15 +0100
29112 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp.c 2007-09-05 03:06:12 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv4/tcp_ipv4.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp_ipv4.c
29122 --- linux-2.6.22.10/net/ipv4/tcp_ipv4.c 2007-10-30 01:57:15 +0100
29123 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp_ipv4.c 2007-09-05 03:06:12 +0200
29124 @@ -1975,6 +1975,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 @@ -1999,6 +2005,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 @@ -2050,18 +2060,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 @@ -2085,7 +2103,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 @@ -2109,6 +2128,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 @@ -2284,9 +2308,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 @@ -2328,7 +2352,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 @@ -2363,7 +2390,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 -NurpP --minimal linux-2.6.22.10/net/ipv4/tcp_minisocks.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp_minisocks.c
29238 --- linux-2.6.22.10/net/ipv4/tcp_minisocks.c 2007-07-09 13:20:06 +0200
29239 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp_minisocks.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv4/udp.c linux-2.6.22.10-vs2.3.0.29/net/ipv4/udp.c
29264 --- linux-2.6.22.10/net/ipv4/udp.c 2007-07-09 13:20:06 +0200
29265 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/udp.c 2007-10-09 14:09:19 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv6/Kconfig linux-2.6.22.10-vs2.3.0.29/net/ipv6/Kconfig
29380 --- linux-2.6.22.10/net/ipv6/Kconfig 2007-07-09 13:20:06 +0200
29381 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/Kconfig 2007-08-05 20:53:13 +0200
29384 # IPv6 as module will cause a CRASH if you try to unload it
29386 - tristate "The IPv6 protocol"
29388 + bool "The IPv6 protocol"
29391 This is complemental support for the IP version 6.
29392 You will still be able to do traditional IPv4 networking as well.
29393 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/addrconf.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/addrconf.c
29394 --- linux-2.6.22.10/net/ipv6/addrconf.c 2007-10-30 01:57:15 +0100
29395 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/addrconf.c 2007-10-05 14:54:36 +0200
29398 #include <linux/proc_fs.h>
29399 #include <linux/seq_file.h>
29400 +#include <linux/vs_inet6.h>
29402 /* Set to 3 to get tracing... */
29403 #define ACONF_DEBUG 2
29404 @@ -897,7 +898,8 @@ static inline int ipv6_saddr_label(const
29407 int ipv6_dev_get_saddr(struct net_device *daddr_dev,
29408 - struct in6_addr *daddr, struct in6_addr *saddr)
29409 + struct in6_addr *daddr, struct in6_addr *saddr,
29410 + struct nx_info *nxi)
29412 struct ipv6_saddr_score hiscore;
29413 struct inet6_ifaddr *ifa_result = NULL;
29414 @@ -942,6 +944,10 @@ int ipv6_dev_get_saddr(struct net_device
29416 score.addr_type = __ipv6_addr_type(&ifa->addr);
29418 + /* Use only addresses assigned to the context */
29419 + if (!v6_ifa_in_nx_info(ifa, nxi))
29423 * - Tentative Address (RFC2462 section 5.4)
29424 * - A tentative address is not considered
29425 @@ -1155,9 +1161,10 @@ record_it:
29428 int ipv6_get_saddr(struct dst_entry *dst,
29429 - struct in6_addr *daddr, struct in6_addr *saddr)
29430 + struct in6_addr *daddr, struct in6_addr *saddr,
29431 + struct nx_info *nxi)
29433 - return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr);
29434 + return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr, nxi);
29437 EXPORT_SYMBOL(ipv6_get_saddr);
29438 @@ -1253,35 +1260,46 @@ struct inet6_ifaddr * ipv6_get_ifaddr(st
29442 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
29444 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
29446 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
29447 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
29448 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
29449 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
29450 int sk_ipv6only = ipv6_only_sock(sk);
29451 int sk2_ipv6only = inet_v6_ipv6only(sk2);
29452 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
29453 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
29455 - if (!sk2_rcv_saddr && !sk_ipv6only)
29456 + /* FIXME: needs handling for v4 ANY */
29457 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
29460 if (addr_type2 == IPV6_ADDR_ANY &&
29461 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
29462 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
29463 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
29466 if (addr_type == IPV6_ADDR_ANY &&
29467 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
29468 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
29469 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
29472 + if (addr_type == IPV6_ADDR_ANY &&
29473 + addr_type2 == IPV6_ADDR_ANY &&
29474 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
29477 if (sk2_rcv_saddr6 &&
29478 + addr_type != IPV6_ADDR_ANY &&
29479 + addr_type != IPV6_ADDR_ANY &&
29480 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
29483 if (addr_type == IPV6_ADDR_MAPPED &&
29485 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
29486 + ipv4_rcv_saddr_equal(sk, sk2))
29490 @@ -2772,7 +2790,10 @@ static void if6_seq_stop(struct seq_file
29491 static int if6_seq_show(struct seq_file *seq, void *v)
29493 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
29496 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
29497 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
29499 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
29501 ifp->idev->dev->ifindex,
29502 @@ -3254,6 +3275,11 @@ static int inet6_dump_addr(struct sk_buf
29503 struct inet6_ifaddr *ifa;
29504 struct ifmcaddr6 *ifmca;
29505 struct ifacaddr6 *ifaca;
29506 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29508 + /* disable ipv6 on non v6 guests */
29509 + if (nxi && !nx_info_has_v6(nxi))
29512 s_idx = cb->args[0];
29513 s_ip_idx = ip_idx = cb->args[1];
29514 @@ -3275,6 +3301,8 @@ static int inet6_dump_addr(struct sk_buf
29515 ifa = ifa->if_next, ip_idx++) {
29516 if (ip_idx < s_ip_idx)
29518 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
29520 if ((err = inet6_fill_ifaddr(skb, ifa,
29521 NETLINK_CB(cb->skb).pid,
29522 cb->nlh->nlmsg_seq, RTM_NEWADDR,
29523 @@ -3288,6 +3316,8 @@ static int inet6_dump_addr(struct sk_buf
29524 ifmca = ifmca->next, ip_idx++) {
29525 if (ip_idx < s_ip_idx)
29527 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
29529 if ((err = inet6_fill_ifmcaddr(skb, ifmca,
29530 NETLINK_CB(cb->skb).pid,
29531 cb->nlh->nlmsg_seq, RTM_GETMULTICAST,
29532 @@ -3301,6 +3331,8 @@ static int inet6_dump_addr(struct sk_buf
29533 ifaca = ifaca->aca_next, ip_idx++) {
29534 if (ip_idx < s_ip_idx)
29536 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
29538 if ((err = inet6_fill_ifacaddr(skb, ifaca,
29539 NETLINK_CB(cb->skb).pid,
29540 cb->nlh->nlmsg_seq, RTM_GETANYCAST,
29541 @@ -3577,12 +3609,19 @@ static int inet6_dump_ifinfo(struct sk_b
29542 int s_idx = cb->args[0];
29543 struct net_device *dev;
29544 struct inet6_dev *idev;
29545 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29547 + /* FIXME: maybe disable ipv6 on non v6 guests?
29548 + if (skb->sk && skb->sk->sk_vx_info)
29549 + return skb->len; */
29551 read_lock(&dev_base_lock);
29553 for_each_netdev(dev) {
29556 + if (!v6_dev_in_nx_info(dev, nxi))
29558 if ((idev = in6_dev_get(dev)) == NULL)
29560 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
29561 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/af_inet6.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/af_inet6.c
29562 --- linux-2.6.22.10/net/ipv6/af_inet6.c 2007-10-30 01:57:15 +0100
29563 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/af_inet6.c 2007-10-05 12:29:05 +0200
29565 #include <linux/netdevice.h>
29566 #include <linux/icmpv6.h>
29567 #include <linux/netfilter_ipv6.h>
29568 +#include <linux/vs_inet6.h>
29570 #include <net/ip.h>
29571 #include <net/ipv6.h>
29572 @@ -150,9 +151,12 @@ lookup_protocol:
29576 + if ((protocol == IPPROTO_ICMPV6) &&
29577 + nx_capable(answer->capability, NXC_RAW_ICMP))
29579 if (answer->capability > 0 && !capable(answer->capability))
29580 goto out_rcu_unlock;
29583 sock->ops = answer->ops;
29584 answer_prot = answer->prot;
29585 answer_no_check = answer->no_check;
29586 @@ -250,6 +254,7 @@ int inet6_bind(struct socket *sock, stru
29587 struct sock *sk = sock->sk;
29588 struct inet_sock *inet = inet_sk(sk);
29589 struct ipv6_pinfo *np = inet6_sk(sk);
29590 + struct nx_v6_sock_addr nsa;
29592 unsigned short snum;
29594 @@ -261,6 +266,11 @@ int inet6_bind(struct socket *sock, stru
29596 if (addr_len < SIN6_LEN_RFC2133)
29599 + err = v6_map_sock_addr(inet, addr, &nsa);
29603 addr_type = ipv6_addr_type(&addr->sin6_addr);
29604 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
29606 @@ -284,6 +294,10 @@ int inet6_bind(struct socket *sock, stru
29607 err = -EADDRNOTAVAIL;
29610 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
29611 + err = -EADDRNOTAVAIL;
29615 if (addr_type != IPV6_ADDR_ANY) {
29616 struct net_device *dev = NULL;
29617 @@ -309,6 +323,11 @@ int inet6_bind(struct socket *sock, stru
29621 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
29622 + err = -EADDRNOTAVAIL;
29626 /* ipv4 addr of the socket is invalid. Only the
29627 * unspecified and mapped address have a v4 equivalent.
29629 @@ -326,6 +345,8 @@ int inet6_bind(struct socket *sock, stru
29633 + v6_set_sock_addr(inet, &nsa);
29635 inet->rcv_saddr = v4addr;
29636 inet->saddr = v4addr;
29638 @@ -420,9 +441,11 @@ int inet6_getname(struct socket *sock, s
29640 sin->sin6_port = inet->dport;
29641 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
29642 + /* FIXME: remap lback? */
29644 sin->sin6_flowinfo = np->flow_label;
29646 + /* FIXME: remap lback? */
29647 if (ipv6_addr_any(&np->rcv_saddr))
29648 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
29650 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/fib6_rules.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/fib6_rules.c
29651 --- linux-2.6.22.10/net/ipv6/fib6_rules.c 2007-07-09 13:20:06 +0200
29652 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/fib6_rules.c 2007-08-12 00:22:19 +0200
29653 @@ -107,7 +107,7 @@ static int fib6_rule_action(struct fib_r
29654 r->src.plen && !(flags & RT6_LOOKUP_F_HAS_SADDR)) {
29655 struct in6_addr saddr;
29656 if (ipv6_get_saddr(&rt->u.dst, &flp->fl6_dst,
29660 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
29662 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/inet6_hashtables.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/inet6_hashtables.c
29663 --- linux-2.6.22.10/net/ipv6/inet6_hashtables.c 2007-05-02 19:25:45 +0200
29664 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/inet6_hashtables.c 2007-08-05 20:53:13 +0200
29667 #include <linux/module.h>
29668 #include <linux/random.h>
29669 +#include <linux/vs_inet6.h>
29671 #include <net/inet_connection_sock.h>
29672 #include <net/inet_hashtables.h>
29673 @@ -121,6 +122,9 @@ struct sock *inet6_lookup_listener(struc
29674 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29678 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29681 if (sk->sk_bound_dev_if) {
29682 if (sk->sk_bound_dev_if != dif)
29683 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/ip6_output.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/ip6_output.c
29684 --- linux-2.6.22.10/net/ipv6/ip6_output.c 2007-10-30 01:57:15 +0100
29685 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/ip6_output.c 2007-09-30 14:58:01 +0200
29686 @@ -884,7 +884,7 @@ static int ip6_dst_lookup_tail(struct so
29687 goto out_err_release;
29689 if (ipv6_addr_any(&fl->fl6_src)) {
29690 - err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src);
29691 + err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src, sk->sk_nx_info);
29693 goto out_err_release;
29695 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/ndisc.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/ndisc.c
29696 --- linux-2.6.22.10/net/ipv6/ndisc.c 2007-10-30 01:57:15 +0100
29697 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/ndisc.c 2007-09-30 14:58:01 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv6/route.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/route.c
29708 --- linux-2.6.22.10/net/ipv6/route.c 2007-07-09 13:20:06 +0200
29709 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/route.c 2007-08-12 00:22:19 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv6/tcp_ipv6.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/tcp_ipv6.c
29720 --- linux-2.6.22.10/net/ipv6/tcp_ipv6.c 2007-10-30 01:57:15 +0100
29721 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/tcp_ipv6.c 2007-09-18 12:32:20 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv6/udp.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/udp.c
29749 --- linux-2.6.22.10/net/ipv6/udp.c 2007-07-09 13:20:06 +0200
29750 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/udp.c 2007-08-12 03:34:32 +0200
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 -NurpP --minimal linux-2.6.22.10/net/ipv6/xfrm6_policy.c linux-2.6.22.10-vs2.3.0.29/net/ipv6/xfrm6_policy.c
29771 --- linux-2.6.22.10/net/ipv6/xfrm6_policy.c 2007-07-09 13:20:06 +0200
29772 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/xfrm6_policy.c 2007-08-12 00:22:19 +0200
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 -NurpP --minimal linux-2.6.22.10/net/netlink/af_netlink.c linux-2.6.22.10-vs2.3.0.29/net/netlink/af_netlink.c
29783 --- linux-2.6.22.10/net/netlink/af_netlink.c 2007-07-09 13:20:07 +0200
29784 +++ linux-2.6.22.10-vs2.3.0.29/net/netlink/af_netlink.c 2007-08-05 20:53:13 +0200
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 -NurpP --minimal linux-2.6.22.10/net/sctp/ipv6.c linux-2.6.22.10-vs2.3.0.29/net/sctp/ipv6.c
29796 --- linux-2.6.22.10/net/sctp/ipv6.c 2007-10-30 01:57:15 +0100
29797 +++ linux-2.6.22.10-vs2.3.0.29/net/sctp/ipv6.c 2007-08-12 00:22:19 +0200
29798 @@ -303,7 +303,7 @@ static void sctp_v6_get_saddr(struct sct
29799 __FUNCTION__, asoc, dst, NIP6(daddr->v6.sin6_addr));
29802 - ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr);
29803 + ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr, asoc->base.sk->sk_nx_info);
29804 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n",
29805 NIP6(saddr->v6.sin6_addr));
29807 diff -NurpP --minimal linux-2.6.22.10/net/socket.c linux-2.6.22.10-vs2.3.0.29/net/socket.c
29808 --- linux-2.6.22.10/net/socket.c 2007-10-30 01:57:15 +0100
29809 +++ linux-2.6.22.10-vs2.3.0.29/net/socket.c 2007-09-05 03:06:12 +0200
29812 #include <net/sock.h>
29813 #include <linux/netfilter.h>
29814 +#include <linux/vs_base.h>
29815 +#include <linux/vs_socket.h>
29816 +#include <linux/vs_inet.h>
29817 +#include <linux/vs_inet6.h>
29819 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
29820 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
29821 @@ -543,7 +547,7 @@ static inline int __sock_sendmsg(struct
29822 struct msghdr *msg, size_t size)
29824 struct sock_iocb *si = kiocb_to_siocb(iocb);
29830 @@ -554,7 +558,22 @@ static inline int __sock_sendmsg(struct
29834 - return sock->ops->sendmsg(iocb, sock, msg, size);
29835 + len = sock->ops->sendmsg(iocb, sock, msg, size);
29838 + vx_sock_send(sock->sk, size);
29840 + vx_sock_fail(sock->sk, size);
29842 + vxdprintk(VXD_CBIT(net, 7),
29843 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29845 + (sock->sk)?sock->sk->sk_nx_info:0,
29846 + (sock->sk)?sock->sk->sk_vx_info:0,
29847 + (sock->sk)?sock->sk->sk_xid:0,
29848 + (sock->sk)?sock->sk->sk_nid:0,
29849 + (unsigned int)size, len);
29853 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
29854 @@ -623,7 +642,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
29855 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
29856 struct msghdr *msg, size_t size, int flags)
29860 struct sock_iocb *si = kiocb_to_siocb(iocb);
29863 @@ -636,7 +655,18 @@ static inline int __sock_recvmsg(struct
29867 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
29868 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
29869 + if ((len >= 0) && sock->sk)
29870 + vx_sock_recv(sock->sk, len);
29871 + vxdprintk(VXD_CBIT(net, 7),
29872 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29874 + (sock->sk)?sock->sk->sk_nx_info:0,
29875 + (sock->sk)?sock->sk->sk_vx_info:0,
29876 + (sock->sk)?sock->sk->sk_xid:0,
29877 + (sock->sk)?sock->sk->sk_nid:0,
29878 + (unsigned int)size, len);
29882 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
29883 @@ -1090,6 +1120,13 @@ static int __sock_create(int family, int
29884 if (type < 0 || type >= SOCK_MAX)
29887 + if (!nx_check(0, VS_ADMIN)) {
29888 + if (family == PF_INET && !current_nx_info_has_v4())
29889 + return -EAFNOSUPPORT;
29890 + if (family == PF_INET6 && !current_nx_info_has_v6())
29891 + return -EAFNOSUPPORT;
29896 This uglymoron is moved from INET layer to here to avoid
29897 @@ -1207,6 +1244,7 @@ asmlinkage long sys_socket(int family, i
29901 + set_bit(SOCK_USER_SOCKET, &sock->flags);
29902 retval = sock_map_fd(sock);
29905 @@ -1239,10 +1277,12 @@ asmlinkage long sys_socketpair(int famil
29906 err = sock_create(family, type, protocol, &sock1);
29909 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
29911 err = sock_create(family, type, protocol, &sock2);
29913 goto out_release_1;
29914 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
29916 err = sock1->ops->socketpair(sock1, sock2);
29918 diff -NurpP --minimal linux-2.6.22.10/net/sunrpc/auth.c linux-2.6.22.10-vs2.3.0.29/net/sunrpc/auth.c
29919 --- linux-2.6.22.10/net/sunrpc/auth.c 2007-05-02 19:25:48 +0200
29920 +++ linux-2.6.22.10-vs2.3.0.29/net/sunrpc/auth.c 2007-08-05 20:53:13 +0200
29922 #include <linux/errno.h>
29923 #include <linux/sunrpc/clnt.h>
29924 #include <linux/spinlock.h>
29925 +#include <linux/vs_tag.h>
29928 # define RPCDBG_FACILITY RPCDBG_AUTH
29929 @@ -263,6 +264,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
29930 struct auth_cred acred = {
29931 .uid = current->fsuid,
29932 .gid = current->fsgid,
29933 + .tag = dx_current_tag(),
29934 .group_info = current->group_info,
29936 struct rpc_cred *ret;
29937 @@ -282,6 +284,7 @@ rpcauth_bindcred(struct rpc_task *task)
29938 struct auth_cred acred = {
29939 .uid = current->fsuid,
29940 .gid = current->fsgid,
29941 + .tag = dx_current_tag(),
29942 .group_info = current->group_info,
29944 struct rpc_cred *ret;
29945 diff -NurpP --minimal linux-2.6.22.10/net/sunrpc/auth_unix.c linux-2.6.22.10-vs2.3.0.29/net/sunrpc/auth_unix.c
29946 --- linux-2.6.22.10/net/sunrpc/auth_unix.c 2007-05-02 19:25:48 +0200
29947 +++ linux-2.6.22.10-vs2.3.0.29/net/sunrpc/auth_unix.c 2007-08-05 20:53:13 +0200
29948 @@ -11,12 +11,14 @@
29949 #include <linux/module.h>
29950 #include <linux/sunrpc/clnt.h>
29951 #include <linux/sunrpc/auth.h>
29952 +#include <linux/vs_tag.h>
29954 #define NFS_NGROUPS 16
29957 struct rpc_cred uc_base;
29960 gid_t uc_gids[NFS_NGROUPS];
29962 #define uc_uid uc_base.cr_uid
29963 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
29964 if (flags & RPCAUTH_LOOKUP_ROOTCREDS) {
29967 + cred->uc_tag = dx_current_tag();
29968 cred->uc_gids[0] = NOGROUP;
29970 int groups = acred->group_info->ngroups;
29971 @@ -87,6 +90,7 @@ unx_create_cred(struct rpc_auth *auth, s
29973 cred->uc_uid = acred->uid;
29974 cred->uc_gid = acred->gid;
29975 + cred->uc_tag = acred->tag;
29976 for (i = 0; i < groups; i++)
29977 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
29978 if (i < NFS_NGROUPS)
29979 @@ -118,7 +122,8 @@ unx_match(struct auth_cred *acred, struc
29982 if (cred->uc_uid != acred->uid
29983 - || cred->uc_gid != acred->gid)
29984 + || cred->uc_gid != acred->gid
29985 + || cred->uc_tag != acred->tag)
29988 groups = acred->group_info->ngroups;
29989 @@ -144,7 +149,7 @@ unx_marshal(struct rpc_task *task, __be3
29990 struct rpc_clnt *clnt = task->tk_client;
29991 struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred;
29992 __be32 *base, *hold;
29996 *p++ = htonl(RPC_AUTH_UNIX);
29998 @@ -154,9 +159,12 @@ unx_marshal(struct rpc_task *task, __be3
29999 * Copy the UTS nodename captured when the client was created.
30001 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
30002 + tag = task->tk_client->cl_tag;
30004 - *p++ = htonl((u32) cred->uc_uid);
30005 - *p++ = htonl((u32) cred->uc_gid);
30006 + *p++ = htonl((u32) TAGINO_UID(tag,
30007 + cred->uc_uid, cred->uc_tag));
30008 + *p++ = htonl((u32) TAGINO_GID(tag,
30009 + cred->uc_gid, cred->uc_tag));
30011 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
30012 *p++ = htonl((u32) cred->uc_gids[i]);
30013 diff -NurpP --minimal linux-2.6.22.10/net/sunrpc/clnt.c linux-2.6.22.10-vs2.3.0.29/net/sunrpc/clnt.c
30014 --- linux-2.6.22.10/net/sunrpc/clnt.c 2007-07-09 13:20:13 +0200
30015 +++ linux-2.6.22.10-vs2.3.0.29/net/sunrpc/clnt.c 2007-08-05 20:53:13 +0200
30017 #include <linux/smp_lock.h>
30018 #include <linux/utsname.h>
30019 #include <linux/workqueue.h>
30020 +#include <linux/vs_cvirt.h>
30022 #include <linux/sunrpc/clnt.h>
30023 #include <linux/sunrpc/rpc_pipe_fs.h>
30024 @@ -249,7 +250,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
30025 clnt->cl_oneshot = 1;
30026 if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
30027 clnt->cl_discrtry = 1;
30029 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
30030 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
30031 + clnt->cl_tag = 1; */
30034 EXPORT_SYMBOL_GPL(rpc_create);
30035 diff -NurpP --minimal linux-2.6.22.10/net/unix/af_unix.c linux-2.6.22.10-vs2.3.0.29/net/unix/af_unix.c
30036 --- linux-2.6.22.10/net/unix/af_unix.c 2007-07-09 13:20:13 +0200
30037 +++ linux-2.6.22.10-vs2.3.0.29/net/unix/af_unix.c 2007-08-05 20:53:13 +0200
30038 @@ -115,6 +115,8 @@
30039 #include <linux/mount.h>
30040 #include <net/checksum.h>
30041 #include <linux/security.h>
30042 +#include <linux/vs_context.h>
30043 +#include <linux/vs_limit.h>
30045 int sysctl_unix_max_dgram_qlen __read_mostly = 10;
30047 @@ -252,6 +254,8 @@ static struct sock *__unix_find_socket_b
30048 sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
30049 struct unix_sock *u = unix_sk(s);
30051 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
30053 if (u->addr->len == len &&
30054 !memcmp(u->addr->name, sunname, len))
30056 @@ -807,7 +811,7 @@ static int unix_bind(struct socket *sock
30059 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
30060 - err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
30061 + err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0, NULL);
30063 goto out_mknod_dput;
30064 mutex_unlock(&nd.dentry->d_inode->i_mutex);
30065 diff -NurpP --minimal linux-2.6.22.10/net/x25/af_x25.c linux-2.6.22.10-vs2.3.0.29/net/x25/af_x25.c
30066 --- linux-2.6.22.10/net/x25/af_x25.c 2007-07-09 13:20:13 +0200
30067 +++ linux-2.6.22.10-vs2.3.0.29/net/x25/af_x25.c 2007-08-05 20:53:13 +0200
30068 @@ -500,7 +500,10 @@ static int x25_create(struct socket *soc
30072 - sock_init_data(sock, sk);
30073 + sk->sk_socket = sock;
30074 + sk->sk_type = sock->type;
30075 + sk->sk_sleep = &sock->wait;
30078 x25_init_timers(sk);
30080 diff -NurpP --minimal linux-2.6.22.10/security/Kconfig linux-2.6.22.10-vs2.3.0.29/security/Kconfig
30081 --- linux-2.6.22.10/security/Kconfig 2006-11-30 21:19:47 +0100
30082 +++ linux-2.6.22.10-vs2.3.0.29/security/Kconfig 2007-08-05 20:53:13 +0200
30083 @@ -6,6 +6,7 @@ menu "Security options"
30086 bool "Enable access key retention support"
30087 + depends on !VSERVER_SECURITY
30089 This option provides support for retaining authentication tokens and
30090 access keys in the kernel.
30091 diff -NurpP --minimal linux-2.6.22.10/security/commoncap.c linux-2.6.22.10-vs2.3.0.29/security/commoncap.c
30092 --- linux-2.6.22.10/security/commoncap.c 2007-07-09 13:20:14 +0200
30093 +++ linux-2.6.22.10-vs2.3.0.29/security/commoncap.c 2007-08-05 20:53:13 +0200
30094 @@ -22,10 +22,11 @@
30095 #include <linux/ptrace.h>
30096 #include <linux/xattr.h>
30097 #include <linux/hugetlb.h>
30098 +#include <linux/vs_context.h>
30100 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
30102 - NETLINK_CB(skb).eff_cap = current->cap_effective;
30103 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
30107 @@ -43,7 +44,7 @@ EXPORT_SYMBOL(cap_netlink_recv);
30108 int cap_capable (struct task_struct *tsk, int cap)
30110 /* Derived from include/linux/sched.h:capable. */
30111 - if (cap_raised(tsk->cap_effective, cap))
30112 + if (vx_cap_raised(tsk->vx_info, tsk->cap_effective, cap))
30116 @@ -141,7 +142,8 @@ void cap_bprm_apply_creds (struct linux_
30117 /* Derived from fs/exec.c:compute_creds. */
30118 kernel_cap_t new_permitted, working;
30120 - new_permitted = cap_intersect (bprm->cap_permitted, cap_bset);
30121 + new_permitted = cap_intersect (bprm->cap_permitted,
30122 + vx_current_cap_bset());
30123 working = cap_intersect (bprm->cap_inheritable,
30124 current->cap_inheritable);
30125 new_permitted = cap_combine (new_permitted, working);
30126 @@ -310,7 +312,8 @@ void cap_task_reparent_to_init (struct t
30128 int cap_syslog (int type)
30130 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
30131 + if ((type != 3 && type != 10) &&
30132 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
30136 diff -NurpP --minimal linux-2.6.22.10/security/dummy.c linux-2.6.22.10-vs2.3.0.29/security/dummy.c
30137 --- linux-2.6.22.10/security/dummy.c 2007-05-02 19:25:51 +0200
30138 +++ linux-2.6.22.10-vs2.3.0.29/security/dummy.c 2007-08-05 20:53:13 +0200
30140 #include <linux/hugetlb.h>
30141 #include <linux/ptrace.h>
30142 #include <linux/file.h>
30143 +#include <linux/vs_context.h>
30145 static int dummy_ptrace (struct task_struct *parent, struct task_struct *child)
30147 @@ -678,7 +679,7 @@ static int dummy_sem_semop (struct sem_a
30149 static int dummy_netlink_send (struct sock *sk, struct sk_buff *skb)
30151 - NETLINK_CB(skb).eff_cap = current->cap_effective;
30152 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
30156 diff -NurpP --minimal linux-2.6.22.10/security/selinux/hooks.c linux-2.6.22.10-vs2.3.0.29/security/selinux/hooks.c
30157 --- linux-2.6.22.10/security/selinux/hooks.c 2007-10-30 01:57:15 +0100
30158 +++ linux-2.6.22.10-vs2.3.0.29/security/selinux/hooks.c 2007-10-30 01:21:54 +0100
30160 #include <linux/dccp.h>
30161 #include <linux/quota.h>
30162 #include <linux/un.h> /* for Unix socket types */
30163 -#include <net/af_unix.h> /* for Unix socket types */
30164 #include <linux/parser.h>
30165 #include <linux/nfs_mount.h>
30166 #include <net/ipv6.h>