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.32
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.16/fs/Kconfig linux-2.6.22.16-vs2.3.0.32/fs/Kconfig
2791 --- linux-2.6.22.16/fs/Kconfig 2007-07-09 13:19:22 +0200
2792 +++ linux-2.6.22.16-vs2.3.0.32/fs/Kconfig 2008-01-18 14:44:53 +0100
2793 @@ -2026,7 +2026,7 @@ config CODA_FS_OLD_API
2796 tristate "Andrew File System support (AFS) (EXPERIMENTAL)"
2797 - depends on INET && EXPERIMENTAL
2798 + depends on INET && EXPERIMENTAL && !VSERVER_SECURITY
2801 If you say Y here, you will get an experimental Andrew File System
2802 diff -NurpP --minimal linux-2.6.22.10/fs/attr.c linux-2.6.22.10-vs2.3.0.29/fs/attr.c
2803 --- linux-2.6.22.10/fs/attr.c 2007-07-09 13:19:22 +0200
2804 +++ linux-2.6.22.10-vs2.3.0.29/fs/attr.c 2007-10-25 17:05:55 +0200
2806 #include <linux/fcntl.h>
2807 #include <linux/quotaops.h>
2808 #include <linux/security.h>
2809 +#include <linux/proc_fs.h>
2810 +#include <linux/devpts_fs.h>
2811 +#include <linux/vs_base.h>
2813 /* Taken over from the old code... */
2815 @@ -55,6 +58,27 @@ int inode_change_ok(struct inode *inode,
2816 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
2820 + /* Check for evil vserver activity */
2821 + if (vx_check(0, VS_ADMIN))
2824 + if (IS_BARRIER(inode)) {
2825 + vxwprintk_task(1, "messing with the barrier.");
2828 + switch (inode->i_sb->s_magic) {
2829 + case PROC_SUPER_MAGIC:
2830 + /* maybe allow that in the future? */
2831 + vxwprintk_task(1, "messing with the procfs.");
2833 + case DEVPTS_SUPER_MAGIC:
2834 + /* devpts is xid tagged */
2835 + if (vx_check((xid_t)inode->i_tag, VS_IDENT))
2837 + vxwprintk_task(1, "messing with the devpts.");
2843 @@ -78,6 +102,8 @@ int inode_setattr(struct inode * inode,
2844 inode->i_uid = attr->ia_uid;
2845 if (ia_valid & ATTR_GID)
2846 inode->i_gid = attr->ia_gid;
2847 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2848 + inode->i_tag = attr->ia_tag;
2849 if (ia_valid & ATTR_ATIME)
2850 inode->i_atime = timespec_trunc(attr->ia_atime,
2851 inode->i_sb->s_time_gran);
2852 @@ -152,7 +178,8 @@ int notify_change(struct dentry * dentry
2853 error = security_inode_setattr(dentry, attr);
2855 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2856 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2857 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2858 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2859 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
2861 error = inode_setattr(inode, attr);
2862 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
2863 --- linux-2.6.22.10/fs/binfmt_aout.c 2007-02-06 03:01:16 +0100
2864 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_aout.c 2007-08-05 20:53:12 +0200
2866 #include <linux/binfmts.h>
2867 #include <linux/personality.h>
2868 #include <linux/init.h>
2869 +#include <linux/vs_memory.h>
2871 #include <asm/system.h>
2872 #include <asm/uaccess.h>
2873 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
2874 --- linux-2.6.22.10/fs/binfmt_elf.c 2007-07-09 13:19:22 +0200
2875 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_elf.c 2007-08-05 20:53:12 +0200
2877 #include <linux/random.h>
2878 #include <linux/elf.h>
2879 #include <linux/utsname.h>
2880 +#include <linux/vs_memory.h>
2881 #include <asm/uaccess.h>
2882 #include <asm/param.h>
2883 #include <asm/page.h>
2884 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
2885 --- linux-2.6.22.10/fs/binfmt_flat.c 2007-07-09 13:19:22 +0200
2886 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_flat.c 2007-08-05 20:53:12 +0200
2888 #include <linux/init.h>
2889 #include <linux/flat.h>
2890 #include <linux/syscalls.h>
2891 +#include <linux/vs_memory.h>
2893 #include <asm/byteorder.h>
2894 #include <asm/system.h>
2895 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
2896 --- linux-2.6.22.10/fs/binfmt_som.c 2006-11-30 21:19:19 +0100
2897 +++ linux-2.6.22.10-vs2.3.0.29/fs/binfmt_som.c 2007-08-05 20:53:12 +0200
2899 #include <linux/shm.h>
2900 #include <linux/personality.h>
2901 #include <linux/init.h>
2902 +#include <linux/vs_memory.h>
2904 #include <asm/a.out.h>
2905 #include <asm/uaccess.h>
2906 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
2907 --- linux-2.6.22.10/fs/block_dev.c 2007-07-09 13:19:22 +0200
2908 +++ linux-2.6.22.10-vs2.3.0.29/fs/block_dev.c 2007-10-11 01:10:22 +0200
2910 #include <linux/uio.h>
2911 #include <linux/namei.h>
2912 #include <linux/log2.h>
2913 +#include <linux/vs_device.h>
2914 #include <asm/uaccess.h>
2915 #include "internal.h"
2917 @@ -572,6 +573,7 @@ struct block_device *bdget(dev_t dev)
2918 bdev->bd_invalidated = 0;
2919 inode->i_mode = S_IFBLK;
2920 inode->i_rdev = dev;
2921 + inode->i_mdev = dev;
2922 inode->i_bdev = bdev;
2923 inode->i_data.a_ops = &def_blk_aops;
2924 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
2925 @@ -610,6 +612,11 @@ EXPORT_SYMBOL(bdput);
2926 static struct block_device *bd_acquire(struct inode *inode)
2928 struct block_device *bdev;
2931 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
2933 + inode->i_mdev = mdev;
2935 spin_lock(&bdev_lock);
2936 bdev = inode->i_bdev;
2937 @@ -620,7 +627,7 @@ static struct block_device *bd_acquire(s
2939 spin_unlock(&bdev_lock);
2941 - bdev = bdget(inode->i_rdev);
2942 + bdev = bdget(mdev);
2944 spin_lock(&bdev_lock);
2945 if (!inode->i_bdev) {
2946 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
2947 --- linux-2.6.22.10/fs/char_dev.c 2007-05-02 19:25:16 +0200
2948 +++ linux-2.6.22.10-vs2.3.0.29/fs/char_dev.c 2007-10-11 01:10:22 +0200
2950 #include <linux/cdev.h>
2951 #include <linux/mutex.h>
2952 #include <linux/backing-dev.h>
2953 +#include <linux/vs_device.h>
2956 #include <linux/kmod.h>
2957 @@ -363,14 +364,21 @@ int chrdev_open(struct inode * inode, st
2959 struct cdev *new = NULL;
2963 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2965 + inode->i_mdev = mdev;
2967 spin_lock(&cdev_lock);
2970 struct kobject *kobj;
2973 spin_unlock(&cdev_lock);
2974 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2976 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2979 new = container_of(kobj, struct cdev, kobj);
2980 diff -NurpP --minimal linux-2.6.22.10/fs/dcache.c linux-2.6.22.10-vs2.3.0.29/fs/dcache.c
2981 --- linux-2.6.22.10/fs/dcache.c 2007-07-09 13:19:23 +0200
2982 +++ linux-2.6.22.10-vs2.3.0.29/fs/dcache.c 2007-08-05 20:53:12 +0200
2984 #include <linux/seqlock.h>
2985 #include <linux/swap.h>
2986 #include <linux/bootmem.h>
2987 +#include <linux/vs_limit.h>
2988 #include "internal.h"
2991 @@ -176,6 +177,7 @@ void dput(struct dentry *dentry)
2995 + vx_dentry_dec(dentry);
2997 if (atomic_read(&dentry->d_count) == 1)
2999 @@ -189,6 +191,8 @@ repeat:
3003 + vx_dentry_dec(dentry);
3006 * AV: ->d_delete() is _NOT_ allowed to block now.
3008 @@ -288,6 +292,7 @@ static inline struct dentry * __dget_loc
3009 if (!list_empty(&dentry->d_lru)) {
3010 dentry_stat.nr_unused--;
3011 list_del_init(&dentry->d_lru);
3012 + vx_dentry_inc(dentry);
3016 @@ -898,6 +903,9 @@ struct dentry *d_alloc(struct dentry * p
3017 struct dentry *dentry;
3020 + if (!vx_dentry_avail(1))
3023 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
3026 @@ -946,6 +954,7 @@ struct dentry *d_alloc(struct dentry * p
3028 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
3029 dentry_stat.nr_dentry++;
3030 + vx_dentry_inc(dentry);
3031 spin_unlock(&dcache_lock);
3034 @@ -1295,6 +1304,7 @@ struct dentry * __d_lookup(struct dentry
3036 if (!d_unhashed(dentry)) {
3037 atomic_inc(&dentry->d_count);
3038 + vx_dentry_inc(dentry);
3041 spin_unlock(&dentry->d_lock);
3042 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
3043 --- linux-2.6.22.10/fs/devpts/inode.c 2007-07-09 13:19:23 +0200
3044 +++ linux-2.6.22.10-vs2.3.0.29/fs/devpts/inode.c 2007-10-18 00:59:53 +0200
3046 #include <linux/namei.h>
3047 #include <linux/mount.h>
3048 #include <linux/tty.h>
3049 +#include <linux/magic.h>
3050 #include <linux/devpts_fs.h>
3051 #include <linux/parser.h>
3052 #include <linux/fsnotify.h>
3053 +#include <linux/vs_base.h>
3055 -#define DEVPTS_SUPER_MAGIC 0x1cd1
3057 +static int devpts_permission(struct inode *inode, int mask, struct nameidata *nd)
3059 + int ret = -EACCES;
3061 + /* devpts is xid tagged */
3062 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
3063 + ret = generic_permission(inode, mask, NULL);
3067 +static struct inode_operations devpts_file_inode_operations = {
3068 + .permission = devpts_permission,
3071 static struct vfsmount *devpts_mnt;
3072 static struct dentry *devpts_root;
3073 @@ -92,6 +107,25 @@ static int devpts_remount(struct super_b
3077 +static int devpts_filter(struct dentry *de)
3079 + /* devpts is xid tagged */
3080 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
3083 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
3085 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
3088 +static struct file_operations devpts_dir_operations = {
3089 + .open = dcache_dir_open,
3090 + .release = dcache_dir_close,
3091 + .llseek = dcache_dir_lseek,
3092 + .read = generic_read_dir,
3093 + .readdir = devpts_readdir,
3096 static const struct super_operations devpts_sops = {
3097 .statfs = simple_statfs,
3098 .remount_fs = devpts_remount,
3099 @@ -117,8 +151,10 @@ devpts_fill_super(struct super_block *s,
3100 inode->i_uid = inode->i_gid = 0;
3101 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
3102 inode->i_op = &simple_dir_inode_operations;
3103 - inode->i_fop = &simple_dir_operations;
3104 + inode->i_fop = &devpts_dir_operations;
3106 + /* devpts is xid tagged */
3107 + inode->i_tag = (tag_t)vx_current_xid();
3109 devpts_root = s->s_root = d_alloc_root(inode);
3111 @@ -176,6 +212,9 @@ int devpts_pty_new(struct tty_struct *tt
3112 inode->i_gid = config.setgid ? config.gid : current->fsgid;
3113 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
3114 init_special_inode(inode, S_IFCHR|config.mode, device);
3115 + /* devpts is xid tagged */
3116 + inode->i_tag = (tag_t)vx_current_xid();
3117 + inode->i_op = &devpts_file_inode_operations;
3118 inode->i_private = tty;
3120 dentry = get_node(number);
3121 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
3122 --- linux-2.6.22.10/fs/ecryptfs/inode.c 2007-10-30 01:57:14 +0100
3123 +++ linux-2.6.22.10-vs2.3.0.29/fs/ecryptfs/inode.c 2007-08-11 22:41:51 +0200
3124 @@ -423,7 +423,7 @@ static int ecryptfs_link(struct dentry *
3125 dget(lower_new_dentry);
3126 lower_dir_dentry = lock_parent(lower_new_dentry);
3127 rc = vfs_link(lower_old_dentry, lower_dir_dentry->d_inode,
3128 - lower_new_dentry);
3129 + lower_new_dentry, NULL);
3130 if (rc || !lower_new_dentry->d_inode)
3132 rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
3133 @@ -451,7 +451,7 @@ static int ecryptfs_unlink(struct inode
3134 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
3136 lock_parent(lower_dentry);
3137 - rc = vfs_unlink(lower_dir_inode, lower_dentry);
3138 + rc = vfs_unlink(lower_dir_inode, lower_dentry, NULL);
3140 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
3142 @@ -488,7 +488,7 @@ static int ecryptfs_symlink(struct inode
3145 rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry,
3146 - encoded_symname, mode);
3147 + encoded_symname, mode, NULL);
3148 kfree(encoded_symname);
3149 if (rc || !lower_dentry->d_inode)
3151 @@ -513,7 +513,7 @@ static int ecryptfs_mkdir(struct inode *
3153 lower_dentry = ecryptfs_dentry_to_lower(dentry);
3154 lower_dir_dentry = lock_parent(lower_dentry);
3155 - rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode);
3156 + rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode, NULL);
3157 if (rc || !lower_dentry->d_inode)
3159 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
3160 @@ -539,7 +539,7 @@ static int ecryptfs_rmdir(struct inode *
3162 lower_dir_dentry = lock_parent(lower_dentry);
3164 - rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry);
3165 + rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry, NULL);
3168 d_delete(lower_dentry);
3169 @@ -561,7 +561,7 @@ ecryptfs_mknod(struct inode *dir, struct
3171 lower_dentry = ecryptfs_dentry_to_lower(dentry);
3172 lower_dir_dentry = lock_parent(lower_dentry);
3173 - rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev);
3174 + rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev, NULL);
3175 if (rc || !lower_dentry->d_inode)
3177 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
3178 diff -NurpP --minimal linux-2.6.22.10/fs/exec.c linux-2.6.22.10-vs2.3.0.29/fs/exec.c
3179 --- linux-2.6.22.10/fs/exec.c 2007-10-30 01:57:14 +0100
3180 +++ linux-2.6.22.10-vs2.3.0.29/fs/exec.c 2007-10-04 23:47:06 +0200
3182 #include <linux/cn_proc.h>
3183 #include <linux/audit.h>
3184 #include <linux/signalfd.h>
3185 +#include <linux/vs_memory.h>
3187 #include <asm/uaccess.h>
3188 #include <asm/mmu_context.h>
3189 @@ -440,7 +441,8 @@ int setup_arg_pages(struct linux_binprm
3190 kmem_cache_free(vm_area_cachep, mpnt);
3193 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
3194 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
3195 + mm->stack_vm = mm->total_vm;
3198 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
3199 @@ -1336,7 +1338,7 @@ static int format_corename(char *corenam
3200 /* UNIX time of coredump */
3203 - do_gettimeofday(&tv);
3204 + vx_gettimeofday(&tv);
3205 rc = snprintf(out_ptr, out_end - out_ptr,
3207 if (rc > out_end - out_ptr)
3208 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
3209 --- linux-2.6.22.10/fs/ext2/balloc.c 2007-05-02 19:25:17 +0200
3210 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/balloc.c 2007-08-05 20:53:12 +0200
3212 #include <linux/sched.h>
3213 #include <linux/buffer_head.h>
3214 #include <linux/capability.h>
3215 +#include <linux/vs_dlimit.h>
3216 +#include <linux/vs_tag.h>
3219 * balloc.c contains the blocks allocation and deallocation routines
3220 @@ -102,12 +104,13 @@ static int reserve_blocks(struct super_b
3222 struct ext2_sb_info *sbi = EXT2_SB(sb);
3223 struct ext2_super_block *es = sbi->s_es;
3224 - unsigned free_blocks;
3225 - unsigned root_blocks;
3226 + unsigned long long free_blocks, root_blocks;
3228 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3229 root_blocks = le32_to_cpu(es->s_r_blocks_count);
3231 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3233 if (free_blocks < count)
3234 count = free_blocks;
3236 @@ -258,6 +261,7 @@ do_more:
3240 + DLIMIT_FREE_BLOCK(inode, freed);
3241 release_blocks(sb, freed);
3242 DQUOT_FREE_BLOCK(inode, freed);
3244 @@ -361,6 +365,10 @@ int ext2_new_block(struct inode *inode,
3248 + if (DLIMIT_ALLOC_BLOCK(inode, es_alloc)) {
3253 ext2_debug ("goal=%lu.\n", goal);
3255 @@ -508,6 +516,8 @@ got_block:
3258 group_release_blocks(sb, group_no, desc, gdp_bh, group_alloc);
3259 + DLIMIT_FREE_BLOCK(inode, es_alloc);
3261 release_blocks(sb, es_alloc);
3263 DQUOT_FREE_BLOCK(inode, dq_alloc);
3264 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
3265 --- linux-2.6.22.10/fs/ext2/ext2.h 2007-07-09 13:19:23 +0200
3266 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/ext2.h 2007-08-05 20:53:12 +0200
3267 @@ -167,6 +167,7 @@ extern const struct file_operations ext2
3268 extern const struct address_space_operations ext2_aops;
3269 extern const struct address_space_operations ext2_aops_xip;
3270 extern const struct address_space_operations ext2_nobh_aops;
3271 +extern int ext2_sync_flags(struct inode *inode);
3274 extern const struct inode_operations ext2_dir_inode_operations;
3275 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
3276 --- linux-2.6.22.10/fs/ext2/file.c 2007-05-02 19:25:17 +0200
3277 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/file.c 2007-09-12 20:04:16 +0200
3278 @@ -85,4 +85,5 @@ const struct inode_operations ext2_file_
3280 .setattr = ext2_setattr,
3281 .permission = ext2_permission,
3282 + .sync_flags = ext2_sync_flags,
3284 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
3285 --- linux-2.6.22.10/fs/ext2/ialloc.c 2006-11-30 21:19:19 +0100
3286 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/ialloc.c 2007-08-05 20:53:12 +0200
3288 #include <linux/backing-dev.h>
3289 #include <linux/buffer_head.h>
3290 #include <linux/random.h>
3291 +#include <linux/vs_dlimit.h>
3292 +#include <linux/vs_tag.h>
3296 @@ -125,6 +127,7 @@ void ext2_free_inode (struct inode * ino
3297 ext2_xattr_delete_inode(inode);
3298 DQUOT_FREE_INODE(inode);
3300 + DLIMIT_FREE_INODE(inode);
3303 es = EXT2_SB(sb)->s_es;
3304 @@ -464,6 +467,11 @@ struct inode *ext2_new_inode(struct inod
3306 return ERR_PTR(-ENOMEM);
3308 + inode->i_tag = dx_current_fstag(sb);
3309 + if (DLIMIT_ALLOC_INODE(inode)) {
3316 @@ -577,7 +585,8 @@ got:
3317 inode->i_blocks = 0;
3318 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
3319 memset(ei->i_data, 0, sizeof(ei->i_data));
3320 - ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
3321 + ei->i_flags = EXT2_I(dir)->i_flags &
3322 + ~(EXT2_BTREE_FL|EXT2_IUNLINK_FL|EXT2_BARRIER_FL);
3324 ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
3325 /* dirsync is only applied to directories */
3326 @@ -625,12 +634,15 @@ fail_free_drop:
3330 + DLIMIT_FREE_INODE(inode);
3331 inode->i_flags |= S_NOQUOTA;
3334 return ERR_PTR(err);
3337 + DLIMIT_FREE_INODE(inode);
3339 make_bad_inode(inode);
3341 return ERR_PTR(err);
3342 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
3343 --- linux-2.6.22.10/fs/ext2/inode.c 2007-07-09 13:19:23 +0200
3344 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/inode.c 2007-08-18 02:52:34 +0200
3346 #include <linux/writeback.h>
3347 #include <linux/buffer_head.h>
3348 #include <linux/mpage.h>
3349 +#include <linux/vs_tag.h>
3353 @@ -913,7 +914,7 @@ void ext2_truncate (struct inode * inode
3355 if (ext2_inode_is_fast_symlink(inode))
3357 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3358 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3361 ext2_discard_prealloc(inode);
3362 @@ -1042,13 +1043,20 @@ void ext2_set_inode_flags(struct inode *
3364 unsigned int flags = EXT2_I(inode)->i_flags;
3366 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3367 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3368 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3370 + if (flags & EXT2_IMMUTABLE_FL)
3371 + inode->i_flags |= S_IMMUTABLE;
3372 + if (flags & EXT2_IUNLINK_FL)
3373 + inode->i_flags |= S_IUNLINK;
3374 + if (flags & EXT2_BARRIER_FL)
3375 + inode->i_flags |= S_BARRIER;
3377 if (flags & EXT2_SYNC_FL)
3378 inode->i_flags |= S_SYNC;
3379 if (flags & EXT2_APPEND_FL)
3380 inode->i_flags |= S_APPEND;
3381 - if (flags & EXT2_IMMUTABLE_FL)
3382 - inode->i_flags |= S_IMMUTABLE;
3383 if (flags & EXT2_NOATIME_FL)
3384 inode->i_flags |= S_NOATIME;
3385 if (flags & EXT2_DIRSYNC_FL)
3386 @@ -1074,12 +1082,37 @@ void ext2_get_inode_flags(struct ext2_in
3387 ei->i_flags |= EXT2_DIRSYNC_FL;
3390 +int ext2_sync_flags(struct inode *inode)
3392 + unsigned int oldflags, newflags;
3394 + oldflags = EXT2_I(inode)->i_flags;
3395 + newflags = oldflags & ~(EXT2_IMMUTABLE_FL |
3396 + EXT2_IUNLINK_FL | EXT2_BARRIER_FL);
3398 + if (IS_IMMUTABLE(inode))
3399 + newflags |= EXT2_IMMUTABLE_FL;
3400 + if (IS_IUNLINK(inode))
3401 + newflags |= EXT2_IUNLINK_FL;
3402 + if (IS_BARRIER(inode))
3403 + newflags |= EXT2_BARRIER_FL;
3405 + if (oldflags ^ newflags) {
3406 + EXT2_I(inode)->i_flags = newflags;
3407 + inode->i_ctime = CURRENT_TIME;
3408 + mark_inode_dirty(inode);
3413 void ext2_read_inode (struct inode * inode)
3415 struct ext2_inode_info *ei = EXT2_I(inode);
3416 ino_t ino = inode->i_ino;
3417 struct buffer_head * bh;
3418 struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh);
3423 #ifdef CONFIG_EXT2_FS_POSIX_ACL
3424 @@ -1090,12 +1123,17 @@ void ext2_read_inode (struct inode * ino
3427 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3428 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3429 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3430 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3431 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3432 if (!(test_opt (inode->i_sb, NO_UID32))) {
3433 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3434 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3435 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3436 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3438 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3439 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3440 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3441 + le16_to_cpu(raw_inode->i_raw_tag));
3443 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3444 inode->i_size = le32_to_cpu(raw_inode->i_size);
3445 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3446 @@ -1192,8 +1230,8 @@ static int ext2_update_inode(struct inod
3447 struct ext2_inode_info *ei = EXT2_I(inode);
3448 struct super_block *sb = inode->i_sb;
3449 ino_t ino = inode->i_ino;
3450 - uid_t uid = inode->i_uid;
3451 - gid_t gid = inode->i_gid;
3452 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3453 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3454 struct buffer_head * bh;
3455 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
3457 @@ -1229,6 +1267,9 @@ static int ext2_update_inode(struct inod
3458 raw_inode->i_uid_high = 0;
3459 raw_inode->i_gid_high = 0;
3461 +#ifdef CONFIG_TAGGING_INTERN
3462 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3464 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3465 raw_inode->i_size = cpu_to_le32(inode->i_size);
3466 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3467 @@ -1315,7 +1356,8 @@ int ext2_setattr(struct dentry *dentry,
3470 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3471 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3472 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3473 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3474 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
3477 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
3478 --- linux-2.6.22.10/fs/ext2/ioctl.c 2007-07-09 13:19:23 +0200
3479 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/ioctl.c 2007-08-05 20:53:12 +0200
3481 #include <linux/sched.h>
3482 #include <linux/compat.h>
3483 #include <linux/smp_lock.h>
3484 +#include <linux/mount.h>
3485 #include <asm/current.h>
3486 #include <asm/uaccess.h>
3488 @@ -33,7 +34,8 @@ int ext2_ioctl (struct inode * inode, st
3489 case EXT2_IOC_SETFLAGS: {
3490 unsigned int oldflags;
3492 - if (IS_RDONLY(inode))
3493 + if (IS_RDONLY(inode) ||
3494 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3497 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3498 @@ -54,7 +56,9 @@ int ext2_ioctl (struct inode * inode, st
3500 * This test looks nicer. Thanks to Pauline Middelink
3502 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
3503 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3504 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3505 + EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL))) {
3506 if (!capable(CAP_LINUX_IMMUTABLE)) {
3507 mutex_unlock(&inode->i_mutex);
3509 @@ -76,7 +80,8 @@ int ext2_ioctl (struct inode * inode, st
3510 case EXT2_IOC_SETVERSION:
3511 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
3513 - if (IS_RDONLY(inode))
3514 + if (IS_RDONLY(inode) ||
3515 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3517 if (get_user(inode->i_generation, (int __user *) arg))
3519 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
3520 --- linux-2.6.22.10/fs/ext2/namei.c 2007-05-02 19:25:17 +0200
3521 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/namei.c 2007-08-05 20:53:12 +0200
3525 #include <linux/pagemap.h>
3526 +#include <linux/vs_tag.h>
3530 @@ -66,6 +67,7 @@ static struct dentry *ext2_lookup(struct
3531 inode = iget(dir->i_sb, ino);
3533 return ERR_PTR(-EACCES);
3534 + dx_propagate_tag(nd, inode);
3536 return d_splice_alias(inode, dentry);
3538 @@ -391,6 +393,7 @@ const struct inode_operations ext2_dir_i
3540 .setattr = ext2_setattr,
3541 .permission = ext2_permission,
3542 + .sync_flags = ext2_sync_flags,
3545 const struct inode_operations ext2_special_inode_operations = {
3546 @@ -402,4 +405,5 @@ const struct inode_operations ext2_speci
3548 .setattr = ext2_setattr,
3549 .permission = ext2_permission,
3550 + .sync_flags = ext2_sync_flags,
3552 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
3553 --- linux-2.6.22.10/fs/ext2/super.c 2007-07-09 13:19:23 +0200
3554 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/super.c 2007-08-05 20:53:12 +0200
3555 @@ -321,7 +321,7 @@ enum {
3556 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3557 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3558 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3559 - Opt_usrquota, Opt_grpquota
3560 + Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3563 static match_table_t tokens = {
3564 @@ -349,6 +349,9 @@ static match_table_t tokens = {
3566 {Opt_noacl, "noacl"},
3569 + {Opt_notag, "notag"},
3570 + {Opt_tagid, "tagid=%u"},
3571 {Opt_grpquota, "grpquota"},
3572 {Opt_ignore, "noquota"},
3573 {Opt_quota, "quota"},
3574 @@ -417,6 +420,20 @@ static int parse_options (char * options
3576 set_opt (sbi->s_mount_opt, NO_UID32);
3578 +#ifndef CONFIG_TAGGING_NONE
3580 + set_opt (sbi->s_mount_opt, TAGGED);
3583 + clear_opt (sbi->s_mount_opt, TAGGED);
3586 +#ifdef CONFIG_PROPAGATE
3589 + set_opt (sbi->s_mount_opt, TAGGED);
3593 clear_opt (sbi->s_mount_opt, CHECK);
3595 @@ -727,6 +744,8 @@ static int ext2_fill_super(struct super_
3596 if (!parse_options ((char *) data, sbi))
3599 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3600 + sb->s_flags |= MS_TAGGED;
3601 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3602 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3604 @@ -1035,6 +1054,13 @@ static int ext2_remount (struct super_bl
3608 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3609 + !(sb->s_flags & MS_TAGGED)) {
3610 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3615 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3616 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3618 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
3619 --- linux-2.6.22.10/fs/ext2/symlink.c 2007-05-02 19:25:17 +0200
3620 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/symlink.c 2007-08-05 20:53:12 +0200
3621 @@ -38,6 +38,7 @@ const struct inode_operations ext2_symli
3622 .listxattr = ext2_listxattr,
3623 .removexattr = generic_removexattr,
3625 + .sync_flags = ext2_sync_flags,
3628 const struct inode_operations ext2_fast_symlink_inode_operations = {
3629 @@ -49,4 +50,5 @@ const struct inode_operations ext2_fast_
3630 .listxattr = ext2_listxattr,
3631 .removexattr = generic_removexattr,
3633 + .sync_flags = ext2_sync_flags,
3635 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
3636 --- linux-2.6.22.10/fs/ext2/xattr.c 2007-02-06 03:01:18 +0100
3637 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext2/xattr.c 2007-08-05 20:53:12 +0200
3639 #include <linux/mbcache.h>
3640 #include <linux/quotaops.h>
3641 #include <linux/rwsem.h>
3642 +#include <linux/vs_dlimit.h>
3646 @@ -641,8 +642,12 @@ ext2_xattr_set2(struct inode *inode, str
3648 ea_bdebug(new_bh, "reusing block");
3651 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3654 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
3655 + DLIMIT_FREE_BLOCK(inode, 1);
3656 unlock_buffer(new_bh);
3659 @@ -736,6 +741,7 @@ ext2_xattr_set2(struct inode *inode, str
3660 le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
3662 mb_cache_entry_release(ce);
3663 + DLIMIT_FREE_BLOCK(inode, 1);
3664 DQUOT_FREE_BLOCK(inode, 1);
3665 mark_buffer_dirty(old_bh);
3666 ea_bdebug(old_bh, "refcount now=%d",
3667 @@ -800,6 +806,7 @@ ext2_xattr_delete_inode(struct inode *in
3668 mark_buffer_dirty(bh);
3670 sync_dirty_buffer(bh);
3671 + DLIMIT_FREE_BLOCK(inode, 1);
3672 DQUOT_FREE_BLOCK(inode, 1);
3674 EXT2_I(inode)->i_file_acl = 0;
3675 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
3676 --- linux-2.6.22.10/fs/ext3/balloc.c 2007-05-02 19:25:17 +0200
3677 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/balloc.c 2007-08-05 20:53:12 +0200
3679 #include <linux/ext3_jbd.h>
3680 #include <linux/quotaops.h>
3681 #include <linux/buffer_head.h>
3682 +#include <linux/vs_dlimit.h>
3683 +#include <linux/vs_tag.h>
3686 * balloc.c contains the blocks allocation and deallocation routines
3687 @@ -613,8 +615,10 @@ void ext3_free_blocks(handle_t *handle,
3690 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
3691 - if (dquot_freed_blocks)
3692 + if (dquot_freed_blocks) {
3693 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3694 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3699 @@ -1353,18 +1357,33 @@ out:
3701 * Check if filesystem has at least 1 free block available for allocation.
3703 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
3704 +static int ext3_has_free_blocks(struct super_block *sb)
3706 - ext3_fsblk_t free_blocks, root_blocks;
3707 + struct ext3_sb_info *sbi = EXT3_SB(sb);
3708 + unsigned long long free_blocks, root_blocks;
3711 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3712 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
3713 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
3715 + vxdprintk(VXD_CBIT(dlim, 3),
3716 + "ext3_has_free_blocks(%p): free=%llu, root=%llu",
3717 + sb, free_blocks, root_blocks);
3719 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3721 + cond = (free_blocks < root_blocks + 1 &&
3722 + !capable(CAP_SYS_RESOURCE) &&
3723 sbi->s_resuid != current->fsuid &&
3724 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
3728 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
3730 + vxdprintk(VXD_CBIT(dlim, 3),
3731 + "ext3_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
3732 + sb, free_blocks, root_blocks,
3733 + !capable(CAP_SYS_RESOURCE)?'1':'0',
3734 + sbi->s_resuid, current->fsuid, cond?0:1);
3736 + return (cond ? 0 : 1);
3740 @@ -1381,7 +1400,7 @@ static int ext3_has_free_blocks(struct e
3742 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
3744 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
3745 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
3748 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
3749 @@ -1444,6 +1463,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3753 + if (DLIMIT_ALLOC_BLOCK(inode, num))
3757 es = EXT3_SB(sb)->s_es;
3758 @@ -1460,7 +1481,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3759 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
3760 my_rsv = &block_i->rsv_window_node;
3762 - if (!ext3_has_free_blocks(sbi)) {
3763 + if (!ext3_has_free_blocks(sb)) {
3767 @@ -1647,12 +1668,16 @@ allocated:
3770 DQUOT_FREE_BLOCK(inode, *count-num);
3771 + DLIMIT_FREE_BLOCK(inode, *count-num);
3778 + if (!performed_allocation)
3779 + DLIMIT_FREE_BLOCK(inode, *count);
3783 ext3_std_error(sb, fatal);
3784 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
3785 --- linux-2.6.22.10/fs/ext3/file.c 2007-05-02 19:25:17 +0200
3786 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/file.c 2007-09-12 20:04:16 +0200
3787 @@ -135,5 +135,6 @@ const struct inode_operations ext3_file_
3788 .removexattr = generic_removexattr,
3790 .permission = ext3_permission,
3791 + .sync_flags = ext3_sync_flags,
3794 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
3795 --- linux-2.6.22.10/fs/ext3/ialloc.c 2006-11-30 21:19:19 +0100
3796 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/ialloc.c 2007-08-05 20:53:12 +0200
3798 #include <linux/buffer_head.h>
3799 #include <linux/random.h>
3800 #include <linux/bitops.h>
3801 +#include <linux/vs_dlimit.h>
3802 +#include <linux/vs_tag.h>
3804 #include <asm/byteorder.h>
3806 @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle,
3807 ext3_xattr_delete_inode(handle, inode);
3808 DQUOT_FREE_INODE(inode);
3810 + DLIMIT_FREE_INODE(inode);
3812 is_directory = S_ISDIR(inode->i_mode);
3814 @@ -445,6 +448,12 @@ struct inode *ext3_new_inode(handle_t *h
3815 inode = new_inode(sb);
3817 return ERR_PTR(-ENOMEM);
3819 + inode->i_tag = dx_current_fstag(sb);
3820 + if (DLIMIT_ALLOC_INODE(inode)) {
3827 @@ -566,7 +575,8 @@ got:
3828 ei->i_dir_start_lookup = 0;
3831 - ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
3832 + ei->i_flags = EXT3_I(dir)->i_flags &
3833 + ~(EXT3_INDEX_FL|EXT3_IUNLINK_FL|EXT3_BARRIER_FL);
3835 ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
3836 /* dirsync only applies to directories */
3837 @@ -621,6 +631,8 @@ got:
3839 ext3_std_error(sb, err);
3841 + DLIMIT_FREE_INODE(inode);
3846 @@ -632,6 +644,7 @@ fail_free_drop:
3850 + DLIMIT_FREE_INODE(inode);
3851 inode->i_flags |= S_NOQUOTA;
3854 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
3855 --- linux-2.6.22.10/fs/ext3/inode.c 2007-07-09 13:19:23 +0200
3856 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/inode.c 2007-08-18 02:52:34 +0200
3858 #include <linux/mpage.h>
3859 #include <linux/uio.h>
3860 #include <linux/bio.h>
3861 +#include <linux/vs_tag.h>
3865 @@ -2237,7 +2238,7 @@ void ext3_truncate(struct inode *inode)
3867 if (ext3_inode_is_fast_symlink(inode))
3869 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3870 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3874 @@ -2559,13 +2560,20 @@ void ext3_set_inode_flags(struct inode *
3876 unsigned int flags = EXT3_I(inode)->i_flags;
3878 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3879 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3880 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3882 + if (flags & EXT3_IMMUTABLE_FL)
3883 + inode->i_flags |= S_IMMUTABLE;
3884 + if (flags & EXT3_IUNLINK_FL)
3885 + inode->i_flags |= S_IUNLINK;
3886 + if (flags & EXT3_BARRIER_FL)
3887 + inode->i_flags |= S_BARRIER;
3889 if (flags & EXT3_SYNC_FL)
3890 inode->i_flags |= S_SYNC;
3891 if (flags & EXT3_APPEND_FL)
3892 inode->i_flags |= S_APPEND;
3893 - if (flags & EXT3_IMMUTABLE_FL)
3894 - inode->i_flags |= S_IMMUTABLE;
3895 if (flags & EXT3_NOATIME_FL)
3896 inode->i_flags |= S_NOATIME;
3897 if (flags & EXT3_DIRSYNC_FL)
3898 @@ -2591,6 +2599,45 @@ void ext3_get_inode_flags(struct ext3_in
3899 ei->i_flags |= EXT3_DIRSYNC_FL;
3902 +int ext3_sync_flags(struct inode *inode)
3904 + unsigned int oldflags, newflags;
3907 + oldflags = EXT3_I(inode)->i_flags;
3908 + newflags = oldflags & ~(EXT3_IMMUTABLE_FL |
3909 + EXT3_IUNLINK_FL | EXT3_BARRIER_FL);
3911 + if (IS_IMMUTABLE(inode))
3912 + newflags |= EXT3_IMMUTABLE_FL;
3913 + if (IS_IUNLINK(inode))
3914 + newflags |= EXT3_IUNLINK_FL;
3915 + if (IS_BARRIER(inode))
3916 + newflags |= EXT3_BARRIER_FL;
3918 + if (oldflags ^ newflags) {
3920 + struct ext3_iloc iloc;
3922 + handle = ext3_journal_start(inode, 1);
3923 + if (IS_ERR(handle))
3924 + return PTR_ERR(handle);
3925 + if (IS_SYNC(inode))
3926 + handle->h_sync = 1;
3927 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3931 + EXT3_I(inode)->i_flags = newflags;
3932 + inode->i_ctime = CURRENT_TIME;
3934 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3936 + ext3_journal_stop(handle);
3941 void ext3_read_inode(struct inode * inode)
3943 struct ext3_iloc iloc;
3944 @@ -2598,6 +2645,8 @@ void ext3_read_inode(struct inode * inod
3945 struct ext3_inode_info *ei = EXT3_I(inode);
3946 struct buffer_head *bh;
3951 #ifdef CONFIG_EXT3_FS_POSIX_ACL
3952 ei->i_acl = EXT3_ACL_NOT_CACHED;
3953 @@ -2610,12 +2659,17 @@ void ext3_read_inode(struct inode * inod
3955 raw_inode = ext3_raw_inode(&iloc);
3956 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3957 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3958 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3959 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3960 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3961 if(!(test_opt (inode->i_sb, NO_UID32))) {
3962 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3963 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3964 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3965 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3967 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3968 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3969 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3970 + le16_to_cpu(raw_inode->i_raw_tag));
3972 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3973 inode->i_size = le32_to_cpu(raw_inode->i_size);
3974 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3975 @@ -2741,6 +2795,8 @@ static int ext3_do_update_inode(handle_t
3976 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3977 struct ext3_inode_info *ei = EXT3_I(inode);
3978 struct buffer_head *bh = iloc->bh;
3979 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3980 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3981 int err = 0, rc, block;
3983 /* For fields not not tracking in the in-memory inode,
3984 @@ -2751,29 +2807,32 @@ static int ext3_do_update_inode(handle_t
3985 ext3_get_inode_flags(ei);
3986 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3987 if(!(test_opt(inode->i_sb, NO_UID32))) {
3988 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3989 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3990 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3991 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3993 * Fix up interoperability with old kernels. Otherwise, old inodes get
3994 * re-used with the upper 16 bits of the uid/gid intact
3997 raw_inode->i_uid_high =
3998 - cpu_to_le16(high_16_bits(inode->i_uid));
3999 + cpu_to_le16(high_16_bits(uid));
4000 raw_inode->i_gid_high =
4001 - cpu_to_le16(high_16_bits(inode->i_gid));
4002 + cpu_to_le16(high_16_bits(gid));
4004 raw_inode->i_uid_high = 0;
4005 raw_inode->i_gid_high = 0;
4008 raw_inode->i_uid_low =
4009 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4010 + cpu_to_le16(fs_high2lowuid(uid));
4011 raw_inode->i_gid_low =
4012 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4013 + cpu_to_le16(fs_high2lowgid(gid));
4014 raw_inode->i_uid_high = 0;
4015 raw_inode->i_gid_high = 0;
4017 +#ifdef CONFIG_TAGGING_INTERN
4018 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4020 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4021 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4022 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4023 @@ -2926,7 +2985,8 @@ int ext3_setattr(struct dentry *dentry,
4026 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4027 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4028 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4029 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4032 /* (user+group)*(old+new) structure, inode write (sb,
4033 @@ -2948,6 +3008,8 @@ int ext3_setattr(struct dentry *dentry,
4034 inode->i_uid = attr->ia_uid;
4035 if (attr->ia_valid & ATTR_GID)
4036 inode->i_gid = attr->ia_gid;
4037 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4038 + inode->i_tag = attr->ia_tag;
4039 error = ext3_mark_inode_dirty(handle, inode);
4040 ext3_journal_stop(handle);
4042 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
4043 --- linux-2.6.22.10/fs/ext3/ioctl.c 2007-07-09 13:19:23 +0200
4044 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/ioctl.c 2007-08-05 20:53:12 +0200
4048 #include <linux/fs.h>
4049 +#include <linux/mount.h>
4050 #include <linux/jbd.h>
4051 #include <linux/capability.h>
4052 #include <linux/ext3_fs.h>
4054 #include <linux/time.h>
4055 #include <linux/compat.h>
4056 #include <linux/smp_lock.h>
4057 +#include <linux/vs_tag.h>
4058 #include <asm/uaccess.h>
4060 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
4061 @@ -38,7 +40,8 @@ int ext3_ioctl (struct inode * inode, st
4062 unsigned int oldflags;
4065 - if (IS_RDONLY(inode))
4066 + if (IS_RDONLY(inode) ||
4067 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4070 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4071 @@ -62,7 +65,9 @@ int ext3_ioctl (struct inode * inode, st
4073 * This test looks nicer. Thanks to Pauline Middelink
4075 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
4076 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
4077 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
4078 + EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL))) {
4079 if (!capable(CAP_LINUX_IMMUTABLE)) {
4080 mutex_unlock(&inode->i_mutex);
4082 @@ -124,7 +129,8 @@ flags_err:
4084 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4086 - if (IS_RDONLY(inode))
4087 + if (IS_RDONLY(inode) ||
4088 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4090 if (get_user(generation, (int __user *) arg))
4092 @@ -178,7 +184,8 @@ flags_err:
4093 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
4096 - if (IS_RDONLY(inode))
4097 + if (IS_RDONLY(inode) ||
4098 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4101 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4102 @@ -213,7 +220,8 @@ flags_err:
4103 if (!capable(CAP_SYS_RESOURCE))
4106 - if (IS_RDONLY(inode))
4107 + if (IS_RDONLY(inode) ||
4108 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4111 if (get_user(n_blocks_count, (__u32 __user *)arg))
4112 @@ -234,7 +242,8 @@ flags_err:
4113 if (!capable(CAP_SYS_RESOURCE))
4116 - if (IS_RDONLY(inode))
4117 + if (IS_RDONLY(inode) ||
4118 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4121 if (copy_from_user(&input, (struct ext3_new_group_input __user *)arg,
4122 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
4123 --- linux-2.6.22.10/fs/ext3/namei.c 2007-10-30 01:57:14 +0100
4124 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/namei.c 2007-09-30 14:58:01 +0200
4126 #include <linux/quotaops.h>
4127 #include <linux/buffer_head.h>
4128 #include <linux/bio.h>
4129 +#include <linux/vs_tag.h>
4133 @@ -1052,6 +1053,7 @@ static struct dentry *ext3_lookup(struct
4136 return ERR_PTR(-EACCES);
4137 + dx_propagate_tag(nd, inode);
4139 return d_splice_alias(inode, dentry);
4141 @@ -2443,6 +2445,7 @@ const struct inode_operations ext3_dir_i
4142 .removexattr = generic_removexattr,
4144 .permission = ext3_permission,
4145 + .sync_flags = ext3_sync_flags,
4148 const struct inode_operations ext3_special_inode_operations = {
4149 @@ -2454,4 +2457,5 @@ const struct inode_operations ext3_speci
4150 .removexattr = generic_removexattr,
4152 .permission = ext3_permission,
4153 + .sync_flags = ext3_sync_flags,
4155 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
4156 --- linux-2.6.22.10/fs/ext3/super.c 2007-07-09 13:19:23 +0200
4157 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/super.c 2007-08-05 20:53:12 +0200
4158 @@ -674,7 +674,7 @@ enum {
4159 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4160 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4161 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4163 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
4166 static match_table_t tokens = {
4167 @@ -724,6 +724,9 @@ static match_table_t tokens = {
4168 {Opt_quota, "quota"},
4169 {Opt_usrquota, "usrquota"},
4170 {Opt_barrier, "barrier=%u"},
4172 + {Opt_notag, "notag"},
4173 + {Opt_tagid, "tagid=%u"},
4175 {Opt_resize, "resize"},
4177 @@ -817,6 +820,20 @@ static int parse_options (char *options,
4179 set_opt (sbi->s_mount_opt, NO_UID32);
4181 +#ifndef CONFIG_TAGGING_NONE
4183 + set_opt (sbi->s_mount_opt, TAGGED);
4186 + clear_opt (sbi->s_mount_opt, TAGGED);
4189 +#ifdef CONFIG_PROPAGATE
4192 + set_opt (sbi->s_mount_opt, TAGGED);
4196 clear_opt (sbi->s_mount_opt, CHECK);
4198 @@ -1487,6 +1504,9 @@ static int ext3_fill_super (struct super
4202 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
4203 + sb->s_flags |= MS_TAGGED;
4205 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4206 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4208 @@ -2302,6 +2322,12 @@ static int ext3_remount (struct super_bl
4210 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
4211 ext3_abort(sb, __FUNCTION__, "Abort forced by user");
4212 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
4213 + !(sb->s_flags & MS_TAGGED)) {
4214 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
4219 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4220 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4221 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
4222 --- linux-2.6.22.10/fs/ext3/symlink.c 2007-05-02 19:25:17 +0200
4223 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/symlink.c 2007-08-05 20:53:12 +0200
4224 @@ -40,6 +40,7 @@ const struct inode_operations ext3_symli
4225 .listxattr = ext3_listxattr,
4226 .removexattr = generic_removexattr,
4228 + .sync_flags = ext3_sync_flags,
4231 const struct inode_operations ext3_fast_symlink_inode_operations = {
4232 @@ -51,4 +52,5 @@ const struct inode_operations ext3_fast_
4233 .listxattr = ext3_listxattr,
4234 .removexattr = generic_removexattr,
4236 + .sync_flags = ext3_sync_flags,
4238 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
4239 --- linux-2.6.22.10/fs/ext3/xattr.c 2007-05-02 19:25:17 +0200
4240 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext3/xattr.c 2007-08-05 20:53:12 +0200
4242 #include <linux/mbcache.h>
4243 #include <linux/quotaops.h>
4244 #include <linux/rwsem.h>
4245 +#include <linux/vs_dlimit.h>
4249 @@ -497,6 +498,7 @@ ext3_xattr_release_block(handle_t *handl
4250 error = ext3_journal_dirty_metadata(handle, bh);
4253 + DLIMIT_FREE_BLOCK(inode, 1);
4254 DQUOT_FREE_BLOCK(inode, 1);
4255 ea_bdebug(bh, "refcount now=%d; releasing",
4256 le32_to_cpu(BHDR(bh)->h_refcount));
4257 @@ -771,11 +773,14 @@ inserted:
4258 if (new_bh == bs->bh)
4259 ea_bdebug(new_bh, "keeping");
4262 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4264 /* The old block is released after updating
4267 if (DQUOT_ALLOC_BLOCK(inode, 1))
4269 + goto cleanup_dlimit;
4270 error = ext3_journal_get_write_access(handle,
4273 @@ -852,6 +857,8 @@ cleanup:
4276 DQUOT_FREE_BLOCK(inode, 1);
4278 + DLIMIT_FREE_BLOCK(inode, 1);
4282 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
4283 --- linux-2.6.22.10/fs/ext4/balloc.c 2007-07-09 13:19:23 +0200
4284 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/balloc.c 2007-08-05 20:53:12 +0200
4286 #include <linux/ext4_jbd2.h>
4287 #include <linux/quotaops.h>
4288 #include <linux/buffer_head.h>
4289 +#include <linux/vs_dlimit.h>
4290 +#include <linux/vs_tag.h>
4293 * balloc.c contains the blocks allocation and deallocation routines
4294 @@ -630,8 +632,10 @@ void ext4_free_blocks(handle_t *handle,
4297 ext4_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
4298 - if (dquot_freed_blocks)
4299 + if (dquot_freed_blocks) {
4300 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
4301 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
4306 @@ -1370,18 +1374,33 @@ out:
4308 * Check if filesystem has at least 1 free block available for allocation.
4310 -static int ext4_has_free_blocks(struct ext4_sb_info *sbi)
4311 +static int ext4_has_free_blocks(struct super_block *sb)
4313 + struct ext4_sb_info *sbi = EXT4_SB(sb);
4314 ext4_fsblk_t free_blocks, root_blocks;
4317 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
4318 root_blocks = ext4_r_blocks_count(sbi->s_es);
4319 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
4321 + vxdprintk(VXD_CBIT(dlim, 3),
4322 + "ext4_has_free_blocks(%p): free=%llu, root=%llu",
4323 + sb, free_blocks, root_blocks);
4325 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
4327 + cond = (free_blocks < root_blocks + 1 &&
4328 + !capable(CAP_SYS_RESOURCE) &&
4329 sbi->s_resuid != current->fsuid &&
4330 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
4334 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
4336 + vxdprintk(VXD_CBIT(dlim, 3),
4337 + "ext4_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
4338 + sb, free_blocks, root_blocks,
4339 + !capable(CAP_SYS_RESOURCE)?'1':'0',
4340 + sbi->s_resuid, current->fsuid, cond?0:1);
4342 + return (cond ? 0 : 1);
4346 @@ -1398,7 +1417,7 @@ static int ext4_has_free_blocks(struct e
4348 int ext4_should_retry_alloc(struct super_block *sb, int *retries)
4350 - if (!ext4_has_free_blocks(EXT4_SB(sb)) || (*retries)++ > 3)
4351 + if (!ext4_has_free_blocks(sb) || (*retries)++ > 3)
4354 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
4355 @@ -1461,6 +1480,8 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
4359 + if (DLIMIT_ALLOC_BLOCK(inode, num))
4363 es = EXT4_SB(sb)->s_es;
4364 @@ -1477,7 +1498,7 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
4365 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
4366 my_rsv = &block_i->rsv_window_node;
4368 - if (!ext4_has_free_blocks(sbi)) {
4369 + if (!ext4_has_free_blocks(sb)) {
4373 @@ -1661,12 +1682,16 @@ allocated:
4376 DQUOT_FREE_BLOCK(inode, *count-num);
4377 + DLIMIT_FREE_BLOCK(inode, *count-num);
4384 + if (!performed_allocation)
4385 + DLIMIT_FREE_BLOCK(inode, *count);
4389 ext4_std_error(sb, fatal);
4390 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
4391 --- linux-2.6.22.10/fs/ext4/file.c 2007-05-02 19:25:17 +0200
4392 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/file.c 2007-09-12 20:04:16 +0200
4393 @@ -135,5 +135,6 @@ const struct inode_operations ext4_file_
4394 .removexattr = generic_removexattr,
4396 .permission = ext4_permission,
4397 + .sync_flags = ext4_sync_flags,
4400 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
4401 --- linux-2.6.22.10/fs/ext4/ialloc.c 2006-11-30 21:19:20 +0100
4402 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/ialloc.c 2007-08-05 20:53:12 +0200
4404 #include <linux/random.h>
4405 #include <linux/bitops.h>
4406 #include <linux/blkdev.h>
4407 +#include <linux/vs_dlimit.h>
4408 +#include <linux/vs_tag.h>
4409 #include <asm/byteorder.h>
4412 @@ -127,6 +129,7 @@ void ext4_free_inode (handle_t *handle,
4413 ext4_xattr_delete_inode(handle, inode);
4414 DQUOT_FREE_INODE(inode);
4416 + DLIMIT_FREE_INODE(inode);
4418 is_directory = S_ISDIR(inode->i_mode);
4420 @@ -448,6 +451,12 @@ struct inode *ext4_new_inode(handle_t *h
4421 inode = new_inode(sb);
4423 return ERR_PTR(-ENOMEM);
4425 + inode->i_tag = dx_current_fstag(sb);
4426 + if (DLIMIT_ALLOC_INODE(inode)) {
4433 @@ -569,7 +578,8 @@ got:
4434 ei->i_dir_start_lookup = 0;
4437 - ei->i_flags = EXT4_I(dir)->i_flags & ~EXT4_INDEX_FL;
4438 + ei->i_flags = EXT4_I(dir)->i_flags &
4439 + ~(EXT4_INDEX_FL|EXT4_IUNLINK_FL|EXT4_BARRIER_FL);
4441 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
4442 /* dirsync only applies to directories */
4443 @@ -635,6 +645,8 @@ got:
4445 ext4_std_error(sb, err);
4447 + DLIMIT_FREE_INODE(inode);
4452 @@ -646,6 +658,7 @@ fail_free_drop:
4456 + DLIMIT_FREE_INODE(inode);
4457 inode->i_flags |= S_NOQUOTA;
4460 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
4461 --- linux-2.6.22.10/fs/ext4/inode.c 2007-07-09 13:19:23 +0200
4462 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/inode.c 2007-08-18 02:52:34 +0200
4464 #include <linux/mpage.h>
4465 #include <linux/uio.h>
4466 #include <linux/bio.h>
4467 +#include <linux/vs_tag.h>
4471 @@ -2244,7 +2245,7 @@ void ext4_truncate(struct inode *inode)
4473 if (ext4_inode_is_fast_symlink(inode))
4475 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4476 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4480 @@ -2570,19 +2571,65 @@ void ext4_set_inode_flags(struct inode *
4482 unsigned int flags = EXT4_I(inode)->i_flags;
4484 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4485 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
4486 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4488 + if (flags & EXT4_IMMUTABLE_FL)
4489 + inode->i_flags |= S_IMMUTABLE;
4490 + if (flags & EXT4_IUNLINK_FL)
4491 + inode->i_flags |= S_IUNLINK;
4492 + if (flags & EXT4_BARRIER_FL)
4493 + inode->i_flags |= S_BARRIER;
4495 if (flags & EXT4_SYNC_FL)
4496 inode->i_flags |= S_SYNC;
4497 if (flags & EXT4_APPEND_FL)
4498 inode->i_flags |= S_APPEND;
4499 - if (flags & EXT4_IMMUTABLE_FL)
4500 - inode->i_flags |= S_IMMUTABLE;
4501 if (flags & EXT4_NOATIME_FL)
4502 inode->i_flags |= S_NOATIME;
4503 if (flags & EXT4_DIRSYNC_FL)
4504 inode->i_flags |= S_DIRSYNC;
4507 +int ext4_sync_flags(struct inode *inode)
4509 + unsigned int oldflags, newflags;
4512 + oldflags = EXT4_I(inode)->i_flags;
4513 + newflags = oldflags & ~(EXT4_IMMUTABLE_FL |
4514 + EXT4_IUNLINK_FL | EXT4_BARRIER_FL);
4516 + if (IS_IMMUTABLE(inode))
4517 + newflags |= EXT4_IMMUTABLE_FL;
4518 + if (IS_IUNLINK(inode))
4519 + newflags |= EXT4_IUNLINK_FL;
4520 + if (IS_BARRIER(inode))
4521 + newflags |= EXT4_BARRIER_FL;
4523 + if (oldflags ^ newflags) {
4525 + struct ext4_iloc iloc;
4527 + handle = ext4_journal_start(inode, 1);
4528 + if (IS_ERR(handle))
4529 + return PTR_ERR(handle);
4530 + if (IS_SYNC(inode))
4531 + handle->h_sync = 1;
4532 + err = ext4_reserve_inode_write(handle, inode, &iloc);
4536 + EXT4_I(inode)->i_flags = newflags;
4537 + inode->i_ctime = CURRENT_TIME;
4539 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
4541 + ext4_journal_stop(handle);
4546 void ext4_read_inode(struct inode * inode)
4548 struct ext4_iloc iloc;
4549 @@ -2590,6 +2637,8 @@ void ext4_read_inode(struct inode * inod
4550 struct ext4_inode_info *ei = EXT4_I(inode);
4551 struct buffer_head *bh;
4556 #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
4557 ei->i_acl = EXT4_ACL_NOT_CACHED;
4558 @@ -2602,12 +2651,17 @@ void ext4_read_inode(struct inode * inod
4560 raw_inode = ext4_raw_inode(&iloc);
4561 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4562 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4563 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4564 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4565 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4566 if(!(test_opt (inode->i_sb, NO_UID32))) {
4567 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4568 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4569 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4570 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4572 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4573 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4574 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4575 + le16_to_cpu(raw_inode->i_raw_tag));
4577 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4578 inode->i_size = le32_to_cpu(raw_inode->i_size);
4579 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4580 @@ -2737,6 +2791,8 @@ static int ext4_do_update_inode(handle_t
4581 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
4582 struct ext4_inode_info *ei = EXT4_I(inode);
4583 struct buffer_head *bh = iloc->bh;
4584 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4585 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4586 int err = 0, rc, block;
4588 /* For fields not not tracking in the in-memory inode,
4589 @@ -2746,29 +2802,32 @@ static int ext4_do_update_inode(handle_t
4591 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4592 if(!(test_opt(inode->i_sb, NO_UID32))) {
4593 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4594 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4595 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4596 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4598 * Fix up interoperability with old kernels. Otherwise, old inodes get
4599 * re-used with the upper 16 bits of the uid/gid intact
4602 raw_inode->i_uid_high =
4603 - cpu_to_le16(high_16_bits(inode->i_uid));
4604 + cpu_to_le16(high_16_bits(uid));
4605 raw_inode->i_gid_high =
4606 - cpu_to_le16(high_16_bits(inode->i_gid));
4607 + cpu_to_le16(high_16_bits(gid));
4609 raw_inode->i_uid_high = 0;
4610 raw_inode->i_gid_high = 0;
4613 raw_inode->i_uid_low =
4614 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4615 + cpu_to_le16(fs_high2lowuid(uid));
4616 raw_inode->i_gid_low =
4617 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4618 + cpu_to_le16(fs_high2lowgid(gid));
4619 raw_inode->i_uid_high = 0;
4620 raw_inode->i_gid_high = 0;
4622 +#ifdef CONFIG_TAGGING_INTERN
4623 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4625 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4626 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4627 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4628 @@ -2925,7 +2984,8 @@ int ext4_setattr(struct dentry *dentry,
4631 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4632 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4633 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4634 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4637 /* (user+group)*(old+new) structure, inode write (sb,
4638 @@ -2947,6 +3007,8 @@ int ext4_setattr(struct dentry *dentry,
4639 inode->i_uid = attr->ia_uid;
4640 if (attr->ia_valid & ATTR_GID)
4641 inode->i_gid = attr->ia_gid;
4642 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4643 + inode->i_tag = attr->ia_tag;
4644 error = ext4_mark_inode_dirty(handle, inode);
4645 ext4_journal_stop(handle);
4647 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
4648 --- linux-2.6.22.10/fs/ext4/ioctl.c 2007-02-06 03:01:18 +0100
4649 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/ioctl.c 2007-08-05 20:53:12 +0200
4653 #include <linux/fs.h>
4654 +#include <linux/mount.h>
4655 #include <linux/jbd2.h>
4656 #include <linux/capability.h>
4657 #include <linux/ext4_fs.h>
4659 #include <linux/time.h>
4660 #include <linux/compat.h>
4661 #include <linux/smp_lock.h>
4662 +#include <linux/vs_tag.h>
4663 #include <asm/uaccess.h>
4665 int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
4666 @@ -37,7 +39,8 @@ int ext4_ioctl (struct inode * inode, st
4667 unsigned int oldflags;
4670 - if (IS_RDONLY(inode))
4671 + if (IS_RDONLY(inode) ||
4672 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4675 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4676 @@ -61,7 +64,9 @@ int ext4_ioctl (struct inode * inode, st
4678 * This test looks nicer. Thanks to Pauline Middelink
4680 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
4681 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
4682 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
4683 + EXT4_IMMUTABLE_FL | EXT4_IUNLINK_FL))) {
4684 if (!capable(CAP_LINUX_IMMUTABLE)) {
4685 mutex_unlock(&inode->i_mutex);
4687 @@ -123,7 +128,8 @@ flags_err:
4689 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4691 - if (IS_RDONLY(inode))
4692 + if (IS_RDONLY(inode) ||
4693 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4695 if (get_user(generation, (int __user *) arg))
4697 @@ -177,7 +183,8 @@ flags_err:
4698 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
4701 - if (IS_RDONLY(inode))
4702 + if (IS_RDONLY(inode) ||
4703 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4706 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4707 @@ -212,7 +219,8 @@ flags_err:
4708 if (!capable(CAP_SYS_RESOURCE))
4711 - if (IS_RDONLY(inode))
4712 + if (IS_RDONLY(inode) ||
4713 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4716 if (get_user(n_blocks_count, (__u32 __user *)arg))
4717 @@ -233,7 +241,8 @@ flags_err:
4718 if (!capable(CAP_SYS_RESOURCE))
4721 - if (IS_RDONLY(inode))
4722 + if (IS_RDONLY(inode) ||
4723 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4726 if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg,
4727 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
4728 --- linux-2.6.22.10/fs/ext4/namei.c 2007-10-30 01:57:14 +0100
4729 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/namei.c 2007-09-30 14:58:01 +0200
4731 #include <linux/quotaops.h>
4732 #include <linux/buffer_head.h>
4733 #include <linux/bio.h>
4734 +#include <linux/vs_tag.h>
4738 @@ -1050,6 +1051,7 @@ static struct dentry *ext4_lookup(struct
4741 return ERR_PTR(-EACCES);
4742 + dx_propagate_tag(nd, inode);
4744 return d_splice_alias(inode, dentry);
4746 @@ -2441,6 +2443,7 @@ const struct inode_operations ext4_dir_i
4747 .removexattr = generic_removexattr,
4749 .permission = ext4_permission,
4750 + .sync_flags = ext4_sync_flags,
4753 const struct inode_operations ext4_special_inode_operations = {
4754 @@ -2452,4 +2455,5 @@ const struct inode_operations ext4_speci
4755 .removexattr = generic_removexattr,
4757 .permission = ext4_permission,
4758 + .sync_flags = ext4_sync_flags,
4760 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
4761 --- linux-2.6.22.10/fs/ext4/super.c 2007-07-09 13:19:23 +0200
4762 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/super.c 2007-08-05 20:53:12 +0200
4763 @@ -725,7 +725,7 @@ enum {
4764 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4765 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4766 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4767 - Opt_grpquota, Opt_extents,
4768 + Opt_grpquota, Opt_extents, Opt_tag, Opt_notag, Opt_tagid
4771 static match_table_t tokens = {
4772 @@ -776,6 +776,9 @@ static match_table_t tokens = {
4773 {Opt_usrquota, "usrquota"},
4774 {Opt_barrier, "barrier=%u"},
4775 {Opt_extents, "extents"},
4777 + {Opt_notag, "notag"},
4778 + {Opt_tagid, "tagid=%u"},
4780 {Opt_resize, "resize"},
4782 @@ -869,6 +872,20 @@ static int parse_options (char *options,
4784 set_opt (sbi->s_mount_opt, NO_UID32);
4786 +#ifndef CONFIG_TAGGING_NONE
4788 + set_opt (sbi->s_mount_opt, TAGGED);
4791 + clear_opt (sbi->s_mount_opt, TAGGED);
4794 +#ifdef CONFIG_PROPAGATE
4797 + set_opt (sbi->s_mount_opt, TAGGED);
4801 clear_opt (sbi->s_mount_opt, CHECK);
4803 @@ -1546,6 +1563,9 @@ static int ext4_fill_super (struct super
4807 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
4808 + sb->s_flags |= MS_TAGGED;
4810 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4811 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4813 @@ -2377,6 +2397,12 @@ static int ext4_remount (struct super_bl
4815 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
4816 ext4_abort(sb, __FUNCTION__, "Abort forced by user");
4817 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
4818 + !(sb->s_flags & MS_TAGGED)) {
4819 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
4824 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4825 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4826 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
4827 --- linux-2.6.22.10/fs/ext4/symlink.c 2007-05-02 19:25:17 +0200
4828 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/symlink.c 2007-08-05 20:53:12 +0200
4829 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
4830 .listxattr = ext4_listxattr,
4831 .removexattr = generic_removexattr,
4833 + .sync_flags = ext4_sync_flags,
4836 const struct inode_operations ext4_fast_symlink_inode_operations = {
4837 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
4838 .listxattr = ext4_listxattr,
4839 .removexattr = generic_removexattr,
4841 + .sync_flags = ext4_sync_flags,
4843 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
4844 --- linux-2.6.22.10/fs/ext4/xattr.c 2007-05-02 19:25:17 +0200
4845 +++ linux-2.6.22.10-vs2.3.0.29/fs/ext4/xattr.c 2007-08-05 20:53:12 +0200
4847 #include <linux/mbcache.h>
4848 #include <linux/quotaops.h>
4849 #include <linux/rwsem.h>
4850 +#include <linux/vs_dlimit.h>
4854 @@ -496,6 +497,7 @@ ext4_xattr_release_block(handle_t *handl
4855 error = ext4_journal_dirty_metadata(handle, bh);
4858 + DLIMIT_FREE_BLOCK(inode, 1);
4859 DQUOT_FREE_BLOCK(inode, 1);
4860 ea_bdebug(bh, "refcount now=%d; releasing",
4861 le32_to_cpu(BHDR(bh)->h_refcount));
4862 @@ -769,11 +771,14 @@ inserted:
4863 if (new_bh == bs->bh)
4864 ea_bdebug(new_bh, "keeping");
4867 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4869 /* The old block is released after updating
4872 if (DQUOT_ALLOC_BLOCK(inode, 1))
4874 + goto cleanup_dlimit;
4875 error = ext4_journal_get_write_access(handle,
4878 @@ -850,6 +855,8 @@ cleanup:
4881 DQUOT_FREE_BLOCK(inode, 1);
4883 + DLIMIT_FREE_BLOCK(inode, 1);
4887 diff -NurpP --minimal linux-2.6.22.10/fs/fcntl.c linux-2.6.22.10-vs2.3.0.29/fs/fcntl.c
4888 --- linux-2.6.22.10/fs/fcntl.c 2007-02-06 03:01:18 +0100
4889 +++ linux-2.6.22.10-vs2.3.0.29/fs/fcntl.c 2007-08-05 20:53:12 +0200
4891 #include <linux/ptrace.h>
4892 #include <linux/signal.h>
4893 #include <linux/rcupdate.h>
4894 +#include <linux/vs_limit.h>
4896 #include <asm/poll.h>
4897 #include <asm/siginfo.h>
4898 @@ -84,6 +85,8 @@ repeat:
4900 if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
4902 + if (!vx_files_avail(1))
4905 error = expand_files(files, newfd);
4907 @@ -124,6 +127,7 @@ static int dupfd(struct file *file, unsi
4908 FD_SET(fd, fdt->open_fds);
4909 FD_CLR(fd, fdt->close_on_exec);
4910 spin_unlock(&files->file_lock);
4911 + vx_openfd_inc(fd);
4912 fd_install(fd, file);
4914 spin_unlock(&files->file_lock);
4915 @@ -176,6 +180,9 @@ asmlinkage long sys_dup2(unsigned int ol
4918 filp_close(tofree, files);
4920 + vx_openfd_inc(newfd); /* fd was unused */
4925 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
4926 --- linux-2.6.22.10/fs/file_table.c 2007-07-09 13:19:23 +0200
4927 +++ linux-2.6.22.10-vs2.3.0.29/fs/file_table.c 2007-08-05 20:53:12 +0200
4929 #include <linux/fsnotify.h>
4930 #include <linux/sysctl.h>
4931 #include <linux/percpu_counter.h>
4932 +#include <linux/vs_limit.h>
4933 +#include <linux/vs_context.h>
4935 #include <asm/atomic.h>
4937 @@ -119,6 +121,8 @@ struct file *get_empty_filp(void)
4938 f->f_gid = tsk->fsgid;
4939 eventpoll_init_file(f);
4940 /* f->f_version: 0 */
4941 + f->f_xid = vx_current_xid();
4946 @@ -174,6 +178,8 @@ void fastcall __fput(struct file *file)
4947 if (file->f_mode & FMODE_WRITE)
4948 put_write_access(inode);
4949 put_pid(file->f_owner.pid);
4950 + vx_files_dec(file);
4953 file->f_path.dentry = NULL;
4954 file->f_path.mnt = NULL;
4955 @@ -239,6 +245,8 @@ void put_filp(struct file *file)
4957 if (atomic_dec_and_test(&file->f_count)) {
4958 security_file_free(file);
4959 + vx_files_dec(file);
4964 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
4965 --- linux-2.6.22.10/fs/hfsplus/ioctl.c 2006-11-30 21:19:25 +0100
4966 +++ linux-2.6.22.10-vs2.3.0.29/fs/hfsplus/ioctl.c 2007-08-05 20:53:12 +0200
4968 #include <linux/fs.h>
4969 #include <linux/sched.h>
4970 #include <linux/xattr.h>
4971 +#include <linux/mount.h>
4972 #include <asm/uaccess.h>
4973 #include "hfsplus_fs.h"
4975 @@ -35,7 +36,8 @@ int hfsplus_ioctl(struct inode *inode, s
4976 flags |= FS_NODUMP_FL; /* EXT2_NODUMP_FL */
4977 return put_user(flags, (int __user *)arg);
4978 case HFSPLUS_IOC_EXT2_SETFLAGS: {
4979 - if (IS_RDONLY(inode))
4980 + if (IS_RDONLY(inode) ||
4981 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4984 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
4985 diff -NurpP --minimal linux-2.6.22.10/fs/inode.c linux-2.6.22.10-vs2.3.0.29/fs/inode.c
4986 --- linux-2.6.22.10/fs/inode.c 2007-07-09 13:19:24 +0200
4987 +++ linux-2.6.22.10-vs2.3.0.29/fs/inode.c 2007-10-11 01:10:22 +0200
4988 @@ -115,6 +115,9 @@ static struct inode *alloc_inode(struct
4989 struct address_space * const mapping = &inode->i_data;
4993 + /* essential because of inode slab reuse */
4995 inode->i_blkbits = sb->s_blocksize_bits;
4997 atomic_set(&inode->i_count, 1);
4998 @@ -133,6 +136,7 @@ static struct inode *alloc_inode(struct
4999 inode->i_bdev = NULL;
5000 inode->i_cdev = NULL;
5002 + inode->i_mdev = 0;
5003 inode->dirtied_when = 0;
5004 if (security_inode_alloc(inode)) {
5005 if (inode->i_sb->s_op->destroy_inode)
5006 @@ -231,6 +235,8 @@ void __iget(struct inode * inode)
5007 inodes_stat.nr_unused--;
5010 +EXPORT_SYMBOL_GPL(__iget);
5013 * clear_inode - clear an inode
5014 * @inode: inode to clear
5015 @@ -1405,9 +1411,11 @@ void init_special_inode(struct inode *in
5016 if (S_ISCHR(mode)) {
5017 inode->i_fop = &def_chr_fops;
5018 inode->i_rdev = rdev;
5019 + inode->i_mdev = rdev;
5020 } else if (S_ISBLK(mode)) {
5021 inode->i_fop = &def_blk_fops;
5022 inode->i_rdev = rdev;
5023 + inode->i_mdev = rdev;
5024 } else if (S_ISFIFO(mode))
5025 inode->i_fop = &def_fifo_fops;
5026 else if (S_ISSOCK(mode))
5027 diff -NurpP --minimal linux-2.6.22.10/fs/ioctl.c linux-2.6.22.10-vs2.3.0.29/fs/ioctl.c
5028 --- linux-2.6.22.10/fs/ioctl.c 2007-07-09 13:19:24 +0200
5029 +++ linux-2.6.22.10-vs2.3.0.29/fs/ioctl.c 2007-08-05 20:53:12 +0200
5031 #include <linux/security.h>
5032 #include <linux/module.h>
5033 #include <linux/kallsyms.h>
5034 +#include <linux/proc_fs.h>
5035 +#include <linux/vserver/inode.h>
5036 +#include <linux/vs_tag.h>
5038 #include <asm/uaccess.h>
5039 #include <asm/ioctls.h>
5040 diff -NurpP --minimal linux-2.6.22.10/fs/ioprio.c linux-2.6.22.10-vs2.3.0.29/fs/ioprio.c
5041 --- linux-2.6.22.10/fs/ioprio.c 2007-05-02 19:25:18 +0200
5042 +++ linux-2.6.22.10-vs2.3.0.29/fs/ioprio.c 2007-08-05 20:53:12 +0200
5044 #include <linux/capability.h>
5045 #include <linux/syscalls.h>
5046 #include <linux/security.h>
5047 +#include <linux/vs_base.h>
5049 static int set_task_ioprio(struct task_struct *task, int ioprio)
5051 @@ -103,6 +104,8 @@ asmlinkage long sys_ioprio_set(int which
5053 pgrp = find_pid(who);
5054 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
5055 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5057 ret = set_task_ioprio(p, ioprio);
5060 @@ -112,7 +115,7 @@ asmlinkage long sys_ioprio_set(int which
5062 user = current->user;
5064 - user = find_user(who);
5065 + user = find_user(vx_current_xid(), who);
5069 @@ -190,6 +193,8 @@ asmlinkage long sys_ioprio_get(int which
5071 pgrp = find_pid(who);
5072 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
5073 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5075 tmpio = get_task_ioprio(p);
5078 @@ -203,7 +208,7 @@ asmlinkage long sys_ioprio_get(int which
5080 user = current->user;
5082 - user = find_user(who);
5083 + user = find_user(vx_current_xid(), who);
5087 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
5088 --- linux-2.6.22.10/fs/jffs2/dir.c 2007-07-09 13:19:26 +0200
5089 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/dir.c 2007-10-05 15:07:22 +0200
5090 @@ -32,7 +32,9 @@ static int jffs2_mkdir (struct inode *,s
5091 static int jffs2_rmdir (struct inode *,struct dentry *);
5092 static int jffs2_mknod (struct inode *,struct dentry *,int,dev_t);
5093 static int jffs2_rename (struct inode *, struct dentry *,
5094 - struct inode *, struct dentry *);
5095 + struct inode *, struct dentry *);
5097 +extern int jffs2_sync_flags(struct inode *);
5099 const struct file_operations jffs2_dir_operations =
5101 @@ -56,6 +58,7 @@ const struct inode_operations jffs2_dir_
5102 .rename = jffs2_rename,
5103 .permission = jffs2_permission,
5104 .setattr = jffs2_setattr,
5105 + .sync_flags = jffs2_sync_flags,
5106 .setxattr = jffs2_setxattr,
5107 .getxattr = jffs2_getxattr,
5108 .listxattr = jffs2_listxattr,
5109 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
5110 --- linux-2.6.22.10/fs/jffs2/file.c 2007-07-09 13:19:26 +0200
5111 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/file.c 2007-10-01 20:52:25 +0200
5113 #include <linux/highmem.h>
5114 #include <linux/crc32.h>
5115 #include <linux/jffs2.h>
5116 +#include <linux/vs_tag.h>
5117 #include "nodelist.h"
5119 static int jffs2_commit_write (struct file *filp, struct page *pg,
5120 @@ -25,6 +26,9 @@ static int jffs2_prepare_write (struct f
5121 unsigned start, unsigned end);
5122 static int jffs2_readpage (struct file *filp, struct page *pg);
5124 +extern int jffs2_sync_flags(struct inode *);
5127 int jffs2_fsync(struct file *filp, struct dentry *dentry, int datasync)
5129 struct inode *inode = dentry->d_inode;
5130 @@ -47,7 +51,9 @@ const struct file_operations jffs2_file_
5131 .ioctl = jffs2_ioctl,
5132 .mmap = generic_file_readonly_mmap,
5133 .fsync = jffs2_fsync,
5134 - .sendfile = generic_file_sendfile
5135 + .sendfile = generic_file_sendfile,
5136 + .splice_read = generic_file_splice_read,
5137 + .splice_write = generic_file_splice_write
5140 /* jffs2_file_inode_operations */
5141 @@ -56,6 +62,7 @@ const struct inode_operations jffs2_file
5143 .permission = jffs2_permission,
5144 .setattr = jffs2_setattr,
5145 + .sync_flags = jffs2_sync_flags,
5146 .setxattr = jffs2_setxattr,
5147 .getxattr = jffs2_getxattr,
5148 .listxattr = jffs2_listxattr,
5149 @@ -157,12 +164,14 @@ static int jffs2_prepare_write (struct f
5150 ri.mode = cpu_to_jemode(inode->i_mode);
5151 ri.uid = cpu_to_je16(inode->i_uid);
5152 ri.gid = cpu_to_je16(inode->i_gid);
5153 + ri.tag = cpu_to_je16(TAGINO_TAG(DX_TAG(inode), inode->i_tag));
5154 ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs));
5155 ri.atime = ri.ctime = ri.mtime = cpu_to_je32(get_seconds());
5156 ri.offset = cpu_to_je32(inode->i_size);
5157 ri.dsize = cpu_to_je32(pageofs - inode->i_size);
5158 ri.csize = cpu_to_je32(0);
5159 ri.compr = JFFS2_COMPR_ZERO;
5160 + ri.flags = cpu_to_je16(f->flags);
5161 ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
5162 ri.data_crc = cpu_to_je32(0);
5164 @@ -248,8 +257,10 @@ static int jffs2_commit_write (struct fi
5165 ri->mode = cpu_to_jemode(inode->i_mode);
5166 ri->uid = cpu_to_je16(inode->i_uid);
5167 ri->gid = cpu_to_je16(inode->i_gid);
5168 + ri->tag = cpu_to_je16(TAGINO_TAG(DX_TAG(inode), inode->i_tag));
5169 ri->isize = cpu_to_je32((uint32_t)inode->i_size);
5170 ri->atime = ri->ctime = ri->mtime = cpu_to_je32(get_seconds());
5171 + ri->flags = cpu_to_je16(f->flags);
5173 /* In 2.4, it was already kmapped by generic_file_write(). Doesn't
5174 hurt to do it again. The alternative is ifdefs, which are ugly. */
5175 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
5176 --- linux-2.6.22.10/fs/jffs2/fs.c 2007-10-30 01:57:14 +0100
5177 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/fs.c 2007-09-30 14:58:01 +0200
5179 #include <linux/vmalloc.h>
5180 #include <linux/vfs.h>
5181 #include <linux/crc32.h>
5182 +#include <linux/vs_tag.h>
5183 #include "nodelist.h"
5185 static int jffs2_flash_setup(struct jffs2_sb_info *c);
5186 @@ -97,6 +98,7 @@ static int jffs2_do_setattr (struct inod
5188 ri->uid = cpu_to_je16((ivalid & ATTR_UID)?iattr->ia_uid:inode->i_uid);
5189 ri->gid = cpu_to_je16((ivalid & ATTR_GID)?iattr->ia_gid:inode->i_gid);
5190 + ri->tag = cpu_to_je16((ivalid & ATTR_TAG)?iattr->ia_tag:inode->i_tag);
5192 if (ivalid & ATTR_MODE)
5193 if (iattr->ia_mode & S_ISGID &&
5194 @@ -116,6 +118,8 @@ static int jffs2_do_setattr (struct inod
5195 ri->offset = cpu_to_je32(0);
5196 ri->csize = ri->dsize = cpu_to_je32(mdatalen);
5197 ri->compr = JFFS2_COMPR_NONE;
5198 + ri->flags = cpu_to_je16(f->flags);
5200 if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
5201 /* It's an extension. Make it a hole node */
5202 ri->compr = JFFS2_COMPR_ZERO;
5203 @@ -145,6 +149,7 @@ static int jffs2_do_setattr (struct inod
5204 inode->i_mode = jemode_to_cpu(ri->mode);
5205 inode->i_uid = je16_to_cpu(ri->uid);
5206 inode->i_gid = je16_to_cpu(ri->gid);
5207 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0, je16_to_cpu(ri->tag));
5210 old_metadata = f->metadata;
5211 @@ -179,6 +184,48 @@ static int jffs2_do_setattr (struct inod
5215 +void jffs2_set_inode_flags(struct inode *inode)
5217 + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
5218 + unsigned int flags = f->flags;
5220 + inode->i_flags &= ~(JFFS2_INO_FLAG_IMMUTABLE |
5221 + JFFS2_INO_FLAG_IUNLINK | JFFS2_INO_FLAG_BARRIER);
5223 + if (flags & JFFS2_INO_FLAG_IMMUTABLE)
5224 + inode->i_flags |= S_IMMUTABLE;
5225 + if (flags & JFFS2_INO_FLAG_IUNLINK)
5226 + inode->i_flags |= S_IUNLINK;
5227 + if (flags & JFFS2_INO_FLAG_BARRIER)
5228 + inode->i_flags |= S_BARRIER;
5231 +int jffs2_sync_flags(struct inode *inode)
5233 + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
5234 + unsigned int oldflags, newflags;
5236 + oldflags = f->flags;
5237 + newflags = oldflags & ~(JFFS2_INO_FLAG_IMMUTABLE |
5238 + JFFS2_INO_FLAG_IUNLINK | JFFS2_INO_FLAG_BARRIER);
5240 + if (IS_IMMUTABLE(inode))
5241 + newflags |= JFFS2_INO_FLAG_IMMUTABLE;
5242 + if (IS_IUNLINK(inode))
5243 + newflags |= JFFS2_INO_FLAG_IUNLINK;
5244 + if (IS_BARRIER(inode))
5245 + newflags |= JFFS2_INO_FLAG_BARRIER;
5247 + if (oldflags ^ newflags) {
5248 + f->flags = newflags;
5249 + inode->i_ctime = CURRENT_TIME;
5250 + /* strange requirement, see jffs2_dirty_inode() */
5251 + inode->i_state |= I_DIRTY_DATASYNC;
5252 + mark_inode_dirty(inode);
5257 int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
5260 @@ -254,6 +301,8 @@ void jffs2_read_inode (struct inode *ino
5261 inode->i_mode = jemode_to_cpu(latest_node.mode);
5262 inode->i_uid = je16_to_cpu(latest_node.uid);
5263 inode->i_gid = je16_to_cpu(latest_node.gid);
5264 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0,
5265 + je16_to_cpu(latest_node.tag));
5266 inode->i_size = je32_to_cpu(latest_node.isize);
5267 inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
5268 inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
5269 @@ -285,6 +334,7 @@ void jffs2_read_inode (struct inode *ino
5271 inode->i_op = &jffs2_dir_inode_operations;
5272 inode->i_fop = &jffs2_dir_operations;
5273 + f->flags = je16_to_cpu(latest_node.flags);
5277 @@ -292,6 +342,7 @@ void jffs2_read_inode (struct inode *ino
5278 inode->i_fop = &jffs2_file_operations;
5279 inode->i_mapping->a_ops = &jffs2_file_address_operations;
5280 inode->i_mapping->nrpages = 0;
5281 + f->flags = je16_to_cpu(latest_node.flags);
5285 @@ -328,7 +379,7 @@ void jffs2_read_inode (struct inode *ino
5287 printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino);
5290 + jffs2_set_inode_flags(inode);
5293 D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n"));
5294 @@ -345,10 +396,11 @@ void jffs2_dirty_inode(struct inode *ino
5296 D1(printk(KERN_DEBUG "jffs2_dirty_inode() calling setattr() for ino #%lu\n", inode->i_ino));
5298 - iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME;
5299 + iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME|ATTR_TAG;
5300 iattr.ia_mode = inode->i_mode;
5301 iattr.ia_uid = inode->i_uid;
5302 iattr.ia_gid = inode->i_gid;
5303 + iattr.ia_tag = inode->i_tag;
5304 iattr.ia_atime = inode->i_atime;
5305 iattr.ia_mtime = inode->i_mtime;
5306 iattr.ia_ctime = inode->i_ctime;
5307 @@ -422,6 +474,7 @@ struct inode *jffs2_new_inode (struct in
5309 memset(ri, 0, sizeof(*ri));
5310 /* Set OS-specific defaults for new inodes */
5311 + ri->tag = cpu_to_je16(dx_current_tag());
5312 ri->uid = cpu_to_je16(current->fsuid);
5314 if (dir_i->i_mode & S_ISGID) {
5315 @@ -443,14 +496,16 @@ struct inode *jffs2_new_inode (struct in
5316 inode->i_mode = jemode_to_cpu(ri->mode);
5317 inode->i_gid = je16_to_cpu(ri->gid);
5318 inode->i_uid = je16_to_cpu(ri->uid);
5319 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), 0, 0, je16_to_cpu(ri->tag));
5320 inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
5321 ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
5323 inode->i_blocks = 0;
5326 + f->flags = je16_to_cpu(ri->flags);
5327 + jffs2_set_inode_flags(inode);
5328 insert_inode_hash(inode);
5333 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
5334 --- linux-2.6.22.10/fs/jffs2/gc.c 2007-07-09 13:19:26 +0200
5335 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/gc.c 2007-08-05 20:53:12 +0200
5336 @@ -735,6 +735,7 @@ static int jffs2_garbage_collect_metadat
5337 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5338 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5339 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5340 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5341 ri.isize = cpu_to_je32(ilen);
5342 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5343 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5344 @@ -998,6 +999,7 @@ static int jffs2_garbage_collect_hole(st
5345 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5346 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5347 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5348 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5349 ri.isize = cpu_to_je32(ilen);
5350 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5351 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5352 @@ -1256,6 +1258,7 @@ static int jffs2_garbage_collect_dnode(s
5353 ri.mode = cpu_to_jemode(JFFS2_F_I_MODE(f));
5354 ri.uid = cpu_to_je16(JFFS2_F_I_UID(f));
5355 ri.gid = cpu_to_je16(JFFS2_F_I_GID(f));
5356 + ri.tag = cpu_to_je16(JFFS2_F_I_TAG(f));
5357 ri.isize = cpu_to_je32(JFFS2_F_I_SIZE(f));
5358 ri.atime = cpu_to_je32(JFFS2_F_I_ATIME(f));
5359 ri.ctime = cpu_to_je32(JFFS2_F_I_CTIME(f));
5360 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
5361 --- linux-2.6.22.10/fs/jffs2/ioctl.c 2007-07-09 13:19:26 +0200
5362 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/ioctl.c 2007-08-05 20:53:12 +0200
5366 #include <linux/fs.h>
5367 +#include <linux/types.h>
5368 +#include <linux/mount.h>
5369 +#include <linux/jffs2.h>
5370 +#include <linux/uaccess.h>
5371 +#include <linux/vs_base.h>
5372 +#include "jffs2_fs_sb.h"
5373 +#include "jffs2_fs_i.h"
5375 +#include "os-linux.h"
5377 +extern void jffs2_set_inode_flags(struct inode *);
5379 int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
5382 - /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which
5383 - will include compression support etc. */
5385 + struct jffs2_inode_info *j = JFFS2_INODE_INFO(inode);
5386 + unsigned int flags, oldflags, newflags;
5389 + case JFFS2_IOC_GETFLAGS:
5390 + flags = j->flags & JFFS2_USER_VISIBLE;
5391 + return put_user(flags, (int __user *) arg);
5393 + case JFFS2_IOC_SETFLAGS:
5394 + if (IS_RDONLY(inode) ||
5395 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
5398 + if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
5401 + if (get_user(flags, (int __user *) arg))
5404 + oldflags = j->flags;
5405 + newflags = flags & JFFS2_USER_MODIFIABLE;
5406 + newflags |= oldflags & ~JFFS2_USER_MODIFIABLE;
5409 + * The IMMUTABLE flags can only be changed by
5410 + * the relevant capability.
5412 + if (((oldflags ^ newflags) &
5413 + (JFFS2_INO_FLAG_IMMUTABLE | JFFS2_INO_FLAG_IUNLINK)) ||
5414 + (oldflags & JFFS2_INO_FLAG_IMMUTABLE)) {
5415 + if (!capable(CAP_LINUX_IMMUTABLE))
5419 + if (oldflags ^ newflags) {
5420 + j->flags = newflags;
5421 + inode->i_ctime = CURRENT_TIME;
5422 + /* strange requirement, see jffs2_dirty_inode() */
5423 + inode->i_state |= I_DIRTY_DATASYNC;
5424 + mark_inode_dirty(inode);
5425 + jffs2_set_inode_flags(inode);
5434 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
5435 --- linux-2.6.22.10/fs/jffs2/jffs2_fs_sb.h 2007-07-09 13:19:26 +0200
5436 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/jffs2_fs_sb.h 2007-08-05 20:53:12 +0200
5437 @@ -39,6 +39,7 @@ struct jffs2_sb_info {
5438 uint32_t checked_ino;
5441 + unsigned int s_mount_opt;
5443 struct task_struct *gc_task; /* GC task struct */
5444 struct completion gc_thread_start; /* GC thread start completion */
5445 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
5446 --- linux-2.6.22.10/fs/jffs2/nodelist.h 2007-07-09 13:19:26 +0200
5447 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/nodelist.h 2007-08-05 20:53:12 +0200
5449 #elif defined(JFFS2_BIG_ENDIAN)
5450 #define cpu_to_je16(x) ((jint16_t){cpu_to_be16(x)})
5451 #define cpu_to_je32(x) ((jint32_t){cpu_to_be32(x)})
5452 -#define cpu_to_jemode(x) ((jmode_t){cpu_to_be32(os_to_jffs2_mode(x))})
5453 +#define cpu_to_jemode(x) ((jmode_t){cpu_to_be16(os_to_jffs2_mode(x))})
5455 #define constant_cpu_to_je16(x) ((jint16_t){__constant_cpu_to_be16(x)})
5456 #define constant_cpu_to_je32(x) ((jint32_t){__constant_cpu_to_be32(x)})
5458 #define je16_to_cpu(x) (be16_to_cpu(x.v16))
5459 #define je32_to_cpu(x) (be32_to_cpu(x.v32))
5460 -#define jemode_to_cpu(x) (be32_to_cpu(jffs2_to_os_mode((x).m)))
5461 +#define jemode_to_cpu(x) (be16_to_cpu(jffs2_to_os_mode((x).m)))
5462 #elif defined(JFFS2_LITTLE_ENDIAN)
5463 #define cpu_to_je16(x) ((jint16_t){cpu_to_le16(x)})
5464 #define cpu_to_je32(x) ((jint32_t){cpu_to_le32(x)})
5465 -#define cpu_to_jemode(x) ((jmode_t){cpu_to_le32(os_to_jffs2_mode(x))})
5466 +#define cpu_to_jemode(x) ((jmode_t){cpu_to_le16(os_to_jffs2_mode(x))})
5468 #define constant_cpu_to_je16(x) ((jint16_t){__constant_cpu_to_le16(x)})
5469 #define constant_cpu_to_je32(x) ((jint32_t){__constant_cpu_to_le32(x)})
5471 #define je16_to_cpu(x) (le16_to_cpu(x.v16))
5472 #define je32_to_cpu(x) (le32_to_cpu(x.v32))
5473 -#define jemode_to_cpu(x) (le32_to_cpu(jffs2_to_os_mode((x).m)))
5474 +#define jemode_to_cpu(x) (le16_to_cpu(jffs2_to_os_mode((x).m)))
5478 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
5479 --- linux-2.6.22.10/fs/jffs2/os-linux.h 2007-07-09 13:19:26 +0200
5480 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/os-linux.h 2007-08-05 20:53:12 +0200
5481 @@ -29,6 +29,7 @@ struct kvec;
5482 #define JFFS2_F_I_MODE(f) (OFNI_EDONI_2SFFJ(f)->i_mode)
5483 #define JFFS2_F_I_UID(f) (OFNI_EDONI_2SFFJ(f)->i_uid)
5484 #define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid)
5485 +#define JFFS2_F_I_TAG(f) (OFNI_EDONI_2SFFJ(f)->i_tag)
5486 #define JFFS2_F_I_RDEV(f) (OFNI_EDONI_2SFFJ(f)->i_rdev)
5488 #define ITIME(sec) ((struct timespec){sec, 0})
5489 @@ -204,6 +205,9 @@ int jffs2_flash_direct_writev(struct jff
5490 int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len,
5491 size_t *retlen, const u_char *buf);
5493 +#define JFFS2_IOC_GETFLAGS FS_IOC_GETFLAGS
5494 +#define JFFS2_IOC_SETFLAGS FS_IOC_SETFLAGS
5496 #endif /* __JFFS2_OS_LINUX_H__ */
5499 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
5500 --- linux-2.6.22.10/fs/jffs2/readinode.c 2007-07-09 13:19:26 +0200
5501 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/readinode.c 2007-08-05 20:53:12 +0200
5502 @@ -1182,6 +1182,8 @@ static int jffs2_do_read_inode_internal(
5503 latest_node->isize = cpu_to_je32(0);
5504 latest_node->gid = cpu_to_je16(0);
5505 latest_node->uid = cpu_to_je16(0);
5506 + latest_node->tag = cpu_to_je16(0);
5507 + latest_node->flags = cpu_to_je16(0);
5508 if (f->inocache->state == INO_STATE_READING)
5509 jffs2_set_inocache_state(c, f->inocache, INO_STATE_PRESENT);
5511 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
5512 --- linux-2.6.22.10/fs/jffs2/super.c 2007-07-09 13:19:26 +0200
5513 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/super.c 2007-08-05 20:53:12 +0200
5515 #include <linux/mtd/super.h>
5516 #include <linux/ctype.h>
5517 #include <linux/namei.h>
5518 +#include <linux/parser.h>
5520 #include "nodelist.h"
5522 @@ -75,6 +76,49 @@ static const struct super_operations jff
5523 .sync_fs = jffs2_sync_fs,
5527 + Opt_tag, Opt_notag, Opt_ignore, Opt_err
5530 +static match_table_t tokens = {
5532 + {Opt_notag, "notag"},
5536 +static int parse_options (char * options,
5537 + struct jffs2_sb_info *sbi)
5540 + substring_t args[MAX_OPT_ARGS];
5545 + while ((p = strsep (&options, ",")) != NULL) {
5550 + token = match_token(p, tokens, args);
5552 +#ifndef CONFIG_TAGGING_NONE
5554 + set_opt (sbi->s_mount_opt, TAGGED);
5557 + clear_opt (sbi->s_mount_opt, TAGGED);
5570 * fill in the superblock
5572 @@ -109,6 +153,12 @@ static int jffs2_fill_super(struct super
5573 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
5574 sb->s_flags |= MS_POSIXACL;
5576 + if (!parse_options ((char *) data, c))
5579 + if (c->s_mount_opt & JFFS2_MOUNT_TAGGED)
5580 + sb->s_flags |= MS_TAGGED;
5582 return jffs2_do_fill_super(sb, data, silent);
5585 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
5586 --- linux-2.6.22.10/fs/jffs2/write.c 2007-10-30 01:57:14 +0100
5587 +++ linux-2.6.22.10-vs2.3.0.29/fs/jffs2/write.c 2007-09-05 03:06:11 +0200
5588 @@ -44,6 +44,7 @@ int jffs2_do_new_inode(struct jffs2_sb_i
5589 ri->totlen = cpu_to_je32(PAD(sizeof(*ri)));
5590 ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));
5591 ri->mode = cpu_to_jemode(mode);
5592 + ri->flags = cpu_to_je16(0);
5594 f->highest_version = 1;
5595 ri->version = cpu_to_je32(f->highest_version);
5596 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
5597 --- linux-2.6.22.10/fs/jfs/acl.c 2006-11-30 21:19:25 +0100
5598 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/acl.c 2007-08-05 20:53:12 +0200
5599 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
5602 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5603 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5604 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5605 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5606 if (DQUOT_TRANSFER(inode, iattr))
5609 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
5610 --- linux-2.6.22.10/fs/jfs/file.c 2007-05-02 19:25:18 +0200
5611 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/file.c 2007-09-12 20:04:16 +0200
5612 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
5613 .setattr = jfs_setattr,
5614 .permission = jfs_permission,
5616 + .sync_flags = jfs_sync_flags,
5619 const struct file_operations jfs_file_operations = {
5620 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
5621 --- linux-2.6.22.10/fs/jfs/inode.c 2007-07-09 13:19:26 +0200
5622 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/inode.c 2007-08-05 20:53:12 +0200
5624 #include <linux/buffer_head.h>
5625 #include <linux/pagemap.h>
5626 #include <linux/quotaops.h>
5627 +#include <linux/vs_dlimit.h>
5628 #include "jfs_incore.h"
5629 #include "jfs_inode.h"
5630 #include "jfs_filsys.h"
5631 @@ -143,6 +144,7 @@ void jfs_delete_inode(struct inode *inod
5633 DQUOT_FREE_INODE(inode);
5635 + DLIMIT_FREE_INODE(inode);
5639 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
5640 --- linux-2.6.22.10/fs/jfs/ioctl.c 2007-07-09 13:19:27 +0200
5641 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/ioctl.c 2007-08-05 20:53:12 +0200
5643 #include <linux/capability.h>
5644 #include <linux/time.h>
5645 #include <linux/sched.h>
5646 +#include <linux/mount.h>
5647 #include <asm/current.h>
5648 #include <asm/uaccess.h>
5650 @@ -66,7 +67,8 @@ int jfs_ioctl(struct inode * inode, stru
5651 case JFS_IOC_SETFLAGS: {
5652 unsigned int oldflags;
5654 - if (IS_RDONLY(inode))
5655 + if (IS_RDONLY(inode) ||
5656 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
5659 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
5660 @@ -87,8 +89,8 @@ int jfs_ioctl(struct inode * inode, stru
5661 * the relevant capability.
5663 if ((oldflags & JFS_IMMUTABLE_FL) ||
5664 - ((flags ^ oldflags) &
5665 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5666 + ((flags ^ oldflags) & (JFS_APPEND_FL |
5667 + JFS_IMMUTABLE_FL | JFS_IUNLINK_FL))) {
5668 if (!capable(CAP_LINUX_IMMUTABLE))
5671 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
5672 --- linux-2.6.22.10/fs/jfs/jfs_dinode.h 2006-11-30 21:19:25 +0100
5673 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_dinode.h 2007-08-05 20:53:12 +0200
5674 @@ -162,9 +162,12 @@ struct dinode {
5675 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
5676 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
5678 -#define JFS_FL_USER_VISIBLE 0x03F80000
5679 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5680 +#define JFS_IUNLINK_FL 0x08000000 /* Immutable unlink */
5682 +#define JFS_FL_USER_VISIBLE 0x0FF80000
5683 #define JFS_FL_USER_MODIFIABLE 0x03F80000
5684 -#define JFS_FL_INHERIT 0x03C80000
5685 +#define JFS_FL_INHERIT 0x0BC80000
5687 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5688 #define JFS_IOC_GETFLAGS _IOR('f', 1, long)
5689 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
5690 --- linux-2.6.22.10/fs/jfs/jfs_dtree.c 2007-02-06 03:01:24 +0100
5691 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_dtree.c 2007-08-05 20:53:12 +0200
5694 #include <linux/fs.h>
5695 #include <linux/quotaops.h>
5696 +#include <linux/vs_dlimit.h>
5697 #include "jfs_incore.h"
5698 #include "jfs_superblock.h"
5699 #include "jfs_filsys.h"
5700 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
5702 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
5704 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
5705 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
5708 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
5709 + goto clean_up_dquot;
5710 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
5711 + goto clean_up_dlimit;
5714 * Save the table, we're going to overwrite it with the
5715 @@ -479,6 +480,12 @@ static u32 add_index(tid_t tid, struct i
5720 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
5723 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
5727 jfs_ip->next_index--;
5728 @@ -952,6 +959,7 @@ static int dtSplitUp(tid_t tid,
5731 int quota_allocation = 0;
5732 + int dlimit_allocation = 0;
5734 /* get split page */
5736 @@ -1036,6 +1044,12 @@ static int dtSplitUp(tid_t tid,
5738 quota_allocation += n;
5740 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
5744 + dlimit_allocation += n;
5746 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
5749 @@ -1309,6 +1323,9 @@ static int dtSplitUp(tid_t tid,
5753 + /* Rollback dlimit allocation */
5754 + if (rc && dlimit_allocation)
5755 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
5756 /* Rollback quota allocation */
5757 if (rc && quota_allocation)
5758 DQUOT_FREE_BLOCK(ip, quota_allocation);
5759 @@ -1376,6 +1393,12 @@ static int dtSplitPage(tid_t tid, struct
5760 release_metapage(rmp);
5763 + /* Allocate blocks to dlimit. */
5764 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5765 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5766 + release_metapage(rmp);
5770 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
5772 @@ -1926,6 +1949,12 @@ static int dtSplitRoot(tid_t tid,
5773 release_metapage(rmp);
5776 + /* Allocate blocks to dlimit. */
5777 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5778 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5779 + release_metapage(rmp);
5783 BT_MARK_DIRTY(rmp, ip);
5785 @@ -2292,6 +2321,8 @@ static int dtDeleteUp(tid_t tid, struct
5787 xlen = lengthPXD(&fp->header.self);
5789 + /* Free dlimit allocation. */
5790 + DLIMIT_FREE_BLOCK(ip, xlen);
5791 /* Free quota allocation. */
5792 DQUOT_FREE_BLOCK(ip, xlen);
5794 @@ -2368,6 +2399,8 @@ static int dtDeleteUp(tid_t tid, struct
5796 xlen = lengthPXD(&p->header.self);
5798 + /* Free dlimit allocation */
5799 + DLIMIT_FREE_BLOCK(ip, xlen);
5800 /* Free quota allocation */
5801 DQUOT_FREE_BLOCK(ip, xlen);
5803 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
5804 --- linux-2.6.22.10/fs/jfs/jfs_extent.c 2006-11-30 21:19:25 +0100
5805 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_extent.c 2007-08-05 20:53:12 +0200
5808 #include <linux/fs.h>
5809 #include <linux/quotaops.h>
5810 +#include <linux/vs_dlimit.h>
5811 #include "jfs_incore.h"
5812 #include "jfs_inode.h"
5813 #include "jfs_superblock.h"
5814 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
5818 + /* Allocate blocks to dlimit. */
5819 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
5820 + DQUOT_FREE_BLOCK(ip, nxlen);
5821 + dbFree(ip, nxaddr, (s64) nxlen);
5822 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
5826 /* determine the value of the extent flag */
5827 xflag = abnr ? XAD_NOTRECORDED : 0;
5829 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
5832 dbFree(ip, nxaddr, nxlen);
5833 + DLIMIT_FREE_BLOCK(ip, nxlen);
5834 DQUOT_FREE_BLOCK(ip, nxlen);
5835 mutex_unlock(&JFS_IP(ip)->commit_mutex);
5837 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
5838 mutex_unlock(&JFS_IP(ip)->commit_mutex);
5841 + /* Allocate blocks to dlimit. */
5842 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
5843 + DQUOT_FREE_BLOCK(ip, nxlen);
5844 + dbFree(ip, nxaddr, (s64) nxlen);
5845 + up(&JFS_IP(ip)->commit_sem);
5849 delta = nxlen - xlen;
5851 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
5852 /* extend the extent */
5853 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
5854 dbFree(ip, xaddr + xlen, delta);
5855 + DLIMIT_FREE_BLOCK(ip, nxlen);
5856 DQUOT_FREE_BLOCK(ip, nxlen);
5859 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
5861 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
5862 dbFree(ip, nxaddr, nxlen);
5863 + DLIMIT_FREE_BLOCK(ip, nxlen);
5864 DQUOT_FREE_BLOCK(ip, nxlen);
5867 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
5868 --- linux-2.6.22.10/fs/jfs/jfs_filsys.h 2007-02-06 03:01:24 +0100
5869 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_filsys.h 2007-08-05 20:53:12 +0200
5871 #define JFS_NAME_MAX 255
5872 #define JFS_PATH_MAX BPSIZE
5874 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
5877 * file system state (superblock state)
5878 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
5879 --- linux-2.6.22.10/fs/jfs/jfs_imap.c 2007-07-09 13:19:27 +0200
5880 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_imap.c 2007-08-05 20:53:12 +0200
5882 #include <linux/buffer_head.h>
5883 #include <linux/pagemap.h>
5884 #include <linux/quotaops.h>
5885 +#include <linux/vs_tag.h>
5887 #include "jfs_incore.h"
5888 #include "jfs_inode.h"
5889 @@ -3075,6 +3076,8 @@ static int copy_from_dinode(struct dinod
5891 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5892 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5896 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5897 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5898 @@ -3095,14 +3098,18 @@ static int copy_from_dinode(struct dinod
5900 ip->i_nlink = le32_to_cpu(dip->di_nlink);
5902 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
5903 + uid = le32_to_cpu(dip->di_uid);
5904 + gid = le32_to_cpu(dip->di_gid);
5905 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
5907 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
5909 ip->i_uid = jfs_ip->saved_uid;
5911 ip->i_uid = sbi->uid;
5914 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
5915 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
5917 ip->i_gid = jfs_ip->saved_gid;
5919 @@ -3167,14 +3174,12 @@ static void copy_to_dinode(struct dinode
5920 dip->di_size = cpu_to_le64(ip->i_size);
5921 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
5922 dip->di_nlink = cpu_to_le32(ip->i_nlink);
5923 - if (sbi->uid == -1)
5924 - dip->di_uid = cpu_to_le32(ip->i_uid);
5926 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
5927 - if (sbi->gid == -1)
5928 - dip->di_gid = cpu_to_le32(ip->i_gid);
5930 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
5932 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
5933 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
5934 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
5935 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
5937 jfs_get_inode_flags(jfs_ip);
5939 * mode2 is only needed for storing the higher order bits.
5940 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
5941 --- linux-2.6.22.10/fs/jfs/jfs_inode.c 2007-07-09 13:19:27 +0200
5942 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_inode.c 2007-08-05 20:53:12 +0200
5945 #include <linux/fs.h>
5946 #include <linux/quotaops.h>
5947 +#include <linux/vs_dlimit.h>
5948 +#include <linux/vs_tag.h>
5949 #include "jfs_incore.h"
5950 #include "jfs_inode.h"
5951 #include "jfs_filsys.h"
5952 @@ -30,19 +32,47 @@ void jfs_set_inode_flags(struct inode *i
5954 unsigned int flags = JFS_IP(inode)->mode2;
5956 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
5957 - S_NOATIME | S_DIRSYNC | S_SYNC);
5958 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
5959 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5961 if (flags & JFS_IMMUTABLE_FL)
5962 inode->i_flags |= S_IMMUTABLE;
5963 + if (flags & JFS_IUNLINK_FL)
5964 + inode->i_flags |= S_IUNLINK;
5965 + if (flags & JFS_BARRIER_FL)
5966 + inode->i_flags |= S_BARRIER;
5968 + if (flags & JFS_SYNC_FL)
5969 + inode->i_flags |= S_SYNC;
5970 if (flags & JFS_APPEND_FL)
5971 inode->i_flags |= S_APPEND;
5972 if (flags & JFS_NOATIME_FL)
5973 inode->i_flags |= S_NOATIME;
5974 if (flags & JFS_DIRSYNC_FL)
5975 inode->i_flags |= S_DIRSYNC;
5976 - if (flags & JFS_SYNC_FL)
5977 - inode->i_flags |= S_SYNC;
5980 +int jfs_sync_flags(struct inode *inode)
5982 + unsigned int oldflags, newflags;
5984 + oldflags = JFS_IP(inode)->mode2;
5985 + newflags = oldflags & ~(JFS_IMMUTABLE_FL |
5986 + JFS_IUNLINK_FL | JFS_BARRIER_FL);
5988 + if (IS_IMMUTABLE(inode))
5989 + newflags |= JFS_IMMUTABLE_FL;
5990 + if (IS_IUNLINK(inode))
5991 + newflags |= JFS_IUNLINK_FL;
5992 + if (IS_BARRIER(inode))
5993 + newflags |= JFS_BARRIER_FL;
5995 + if (oldflags ^ newflags) {
5996 + JFS_IP(inode)->mode2 = newflags;
5997 + inode->i_ctime = CURRENT_TIME;
5998 + mark_inode_dirty(inode);
6003 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
6004 @@ -108,10 +138,17 @@ struct inode *ialloc(struct inode *paren
6005 jfs_inode->saved_uid = inode->i_uid;
6006 jfs_inode->saved_gid = inode->i_gid;
6008 + inode->i_tag = dx_current_fstag(sb);
6009 + if (DLIMIT_ALLOC_INODE(inode)) {
6011 + return ERR_PTR(-ENOSPC);
6015 * Allocate inode to quota.
6017 if (DQUOT_ALLOC_INODE(inode)) {
6018 + DLIMIT_FREE_INODE(inode);
6020 inode->i_flags |= S_NOQUOTA;
6022 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
6023 --- linux-2.6.22.10/fs/jfs/jfs_inode.h 2007-07-09 13:19:27 +0200
6024 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_inode.h 2007-08-05 20:53:12 +0200
6025 @@ -33,6 +33,7 @@ extern void jfs_free_zero_link(struct in
6026 extern struct dentry *jfs_get_parent(struct dentry *dentry);
6027 extern void jfs_get_inode_flags(struct jfs_inode_info *);
6028 extern void jfs_set_inode_flags(struct inode *);
6029 +extern int jfs_sync_flags(struct inode *);
6030 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
6032 extern const struct address_space_operations jfs_aops;
6033 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
6034 --- linux-2.6.22.10/fs/jfs/jfs_xtree.c 2007-05-02 19:25:18 +0200
6035 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/jfs_xtree.c 2007-08-05 20:53:12 +0200
6038 #include <linux/fs.h>
6039 #include <linux/quotaops.h>
6040 +#include <linux/vs_dlimit.h>
6041 #include "jfs_incore.h"
6042 #include "jfs_filsys.h"
6043 #include "jfs_metapage.h"
6044 @@ -846,7 +847,12 @@ int xtInsert(tid_t tid, /* transaction
6046 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
6048 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
6049 + DQUOT_FREE_BLOCK(ip, xlen);
6052 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
6053 + DLIMIT_FREE_BLOCK(ip, xlen);
6054 DQUOT_FREE_BLOCK(ip, xlen);
6057 @@ -876,6 +882,7 @@ int xtInsert(tid_t tid, /* transaction
6058 /* undo data extent allocation */
6060 dbFree(ip, xaddr, (s64) xlen);
6061 + DLIMIT_FREE_BLOCK(ip, xlen);
6062 DQUOT_FREE_BLOCK(ip, xlen);
6065 @@ -1236,6 +1243,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
6067 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
6068 int quota_allocation = 0;
6069 + int dlimit_allocation = 0;
6072 sp = XT_PAGE(ip, smp);
6073 @@ -1255,6 +1263,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
6075 quota_allocation += lengthPXD(pxd);
6077 + /* Allocate blocks to dlimit. */
6078 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
6082 + dlimit_allocation += lengthPXD(pxd);
6085 * allocate the new right page for the split
6087 @@ -1456,6 +1471,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
6091 + /* Rollback dlimit allocation. */
6092 + if (dlimit_allocation)
6093 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
6094 /* Rollback quota allocation. */
6095 if (quota_allocation)
6096 DQUOT_FREE_BLOCK(ip, quota_allocation);
6097 @@ -1520,6 +1538,12 @@ xtSplitRoot(tid_t tid,
6098 release_metapage(rmp);
6101 + /* Allocate blocks to dlimit. */
6102 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
6103 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
6104 + release_metapage(rmp);
6108 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
6110 @@ -3951,6 +3975,8 @@ s64 xtTruncate(tid_t tid, struct inode *
6112 ip->i_size = newsize;
6114 + /* update dlimit allocation to reflect freed blocks */
6115 + DLIMIT_FREE_BLOCK(ip, nfreed);
6116 /* update quota allocation to reflect freed blocks */
6117 DQUOT_FREE_BLOCK(ip, nfreed);
6119 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
6120 --- linux-2.6.22.10/fs/jfs/namei.c 2007-05-02 19:25:18 +0200
6121 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/namei.c 2007-08-05 20:53:12 +0200
6123 #include <linux/fs.h>
6124 #include <linux/ctype.h>
6125 #include <linux/quotaops.h>
6126 +#include <linux/vs_tag.h>
6127 #include "jfs_incore.h"
6128 #include "jfs_superblock.h"
6129 #include "jfs_inode.h"
6130 @@ -1469,6 +1470,7 @@ static struct dentry *jfs_lookup(struct
6131 return ERR_PTR(-EACCES);
6134 + dx_propagate_tag(nd, ip);
6135 dentry = d_splice_alias(ip, dentry);
6137 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
6138 @@ -1521,6 +1523,7 @@ const struct inode_operations jfs_dir_in
6139 .setattr = jfs_setattr,
6140 .permission = jfs_permission,
6142 + .sync_flags = jfs_sync_flags,
6145 const struct file_operations jfs_dir_operations = {
6146 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
6147 --- linux-2.6.22.10/fs/jfs/super.c 2007-07-09 13:19:27 +0200
6148 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/super.c 2007-08-05 20:53:12 +0200
6149 @@ -194,7 +194,8 @@ static void jfs_put_super(struct super_b
6151 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
6152 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
6153 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
6154 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
6155 + Opt_tag, Opt_notag, Opt_tagid
6158 static match_table_t tokens = {
6159 @@ -204,6 +205,10 @@ static match_table_t tokens = {
6160 {Opt_resize, "resize=%u"},
6161 {Opt_resize_nosize, "resize"},
6162 {Opt_errors, "errors=%s"},
6164 + {Opt_notag, "notag"},
6165 + {Opt_tagid, "tagid=%u"},
6166 + {Opt_tag, "tagxid"},
6167 {Opt_ignore, "noquota"},
6168 {Opt_ignore, "quota"},
6169 {Opt_usrquota, "usrquota"},
6170 @@ -338,6 +343,20 @@ static int parse_options(char *options,
6174 +#ifndef CONFIG_TAGGING_NONE
6176 + *flag |= JFS_TAGGED;
6179 + *flag &= JFS_TAGGED;
6182 +#ifdef CONFIG_PROPAGATE
6185 + *flag |= JFS_TAGGED;
6189 printk("jfs: Unrecognized mount option \"%s\" "
6190 " or missing value\n", p);
6191 @@ -368,6 +387,13 @@ static int jfs_remount(struct super_bloc
6192 if (!parse_options(data, sb, &newLVSize, &flag)) {
6196 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
6197 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
6203 if (sb->s_flags & MS_RDONLY) {
6205 @@ -439,6 +465,9 @@ static int jfs_fill_super(struct super_b
6206 #ifdef CONFIG_JFS_POSIX_ACL
6207 sb->s_flags |= MS_POSIXACL;
6209 + /* map mount option tagxid */
6210 + if (sbi->flag & JFS_TAGGED)
6211 + sb->s_flags |= MS_TAGGED;
6214 printk(KERN_ERR "resize option for remount only\n");
6215 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
6216 --- linux-2.6.22.10/fs/jfs/xattr.c 2006-11-30 21:19:26 +0100
6217 +++ linux-2.6.22.10-vs2.3.0.29/fs/jfs/xattr.c 2007-08-05 20:53:12 +0200
6219 #include <linux/posix_acl_xattr.h>
6220 #include <linux/quotaops.h>
6221 #include <linux/security.h>
6222 +#include <linux/vs_dlimit.h>
6223 #include "jfs_incore.h"
6224 #include "jfs_superblock.h"
6225 #include "jfs_dmap.h"
6226 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
6227 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
6230 + /* Allocate new blocks to dlimit. */
6231 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
6232 + DQUOT_FREE_BLOCK(ip, nblocks);
6236 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
6238 + /*Rollback dlimit allocation. */
6239 + DLIMIT_FREE_BLOCK(ip, nblocks);
6240 /*Rollback quota allocation. */
6241 DQUOT_FREE_BLOCK(ip, nblocks);
6243 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
6246 /* Rollback quota allocation. */
6247 + DLIMIT_FREE_BLOCK(ip, nblocks);
6248 + /* Rollback quota allocation. */
6249 DQUOT_FREE_BLOCK(ip, nblocks);
6251 dbFree(ip, blkno, nblocks);
6252 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
6255 int quota_allocation = 0;
6256 + int dlimit_allocation = 0;
6258 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
6259 if (ji->ea.flag == 0)
6260 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
6262 quota_allocation = blocks_needed;
6264 + /* Allocate new blocks to dlimit. */
6266 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
6268 + dlimit_allocation = blocks_needed;
6270 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
6273 @@ -599,6 +616,9 @@ static int ea_get(struct inode *inode, s
6277 + /* Rollback dlimit allocation */
6278 + if (dlimit_allocation)
6279 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
6280 /* Rollback quota allocation */
6281 if (quota_allocation)
6282 DQUOT_FREE_BLOCK(inode, quota_allocation);
6283 @@ -675,8 +695,10 @@ static int ea_put(tid_t tid, struct inod
6286 /* If old blocks exist, they must be removed from quota allocation. */
6289 + DLIMIT_FREE_BLOCK(inode, old_blocks);
6290 DQUOT_FREE_BLOCK(inode, old_blocks);
6293 inode->i_ctime = CURRENT_TIME;
6295 diff -NurpP --minimal linux-2.6.22.10/fs/libfs.c linux-2.6.22.10-vs2.3.0.29/fs/libfs.c
6296 --- linux-2.6.22.10/fs/libfs.c 2007-07-09 13:19:27 +0200
6297 +++ linux-2.6.22.10-vs2.3.0.29/fs/libfs.c 2007-08-05 20:53:12 +0200
6298 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
6299 * both impossible due to the lock on directory.
6302 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6303 +static inline int do_dcache_readdir_filter(struct file *filp,
6304 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6306 struct dentry *dentry = filp->f_path.dentry;
6307 struct dentry *cursor = filp->private_data;
6308 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
6309 next = list_entry(p, struct dentry, d_u.d_child);
6310 if (d_unhashed(next) || !next->d_inode)
6312 + if (filter && !filter(next))
6315 spin_unlock(&dcache_lock);
6316 if (filldir(dirent, next->d_name.name,
6317 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
6321 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6323 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6326 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6327 + int (*filter)(struct dentry *))
6329 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6333 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6336 @@ -640,6 +655,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6337 EXPORT_SYMBOL(dcache_dir_lseek);
6338 EXPORT_SYMBOL(dcache_dir_open);
6339 EXPORT_SYMBOL(dcache_readdir);
6340 +EXPORT_SYMBOL(dcache_readdir_filter);
6341 EXPORT_SYMBOL(generic_read_dir);
6342 EXPORT_SYMBOL(get_sb_pseudo);
6343 EXPORT_SYMBOL(simple_commit_write);
6344 diff -NurpP --minimal linux-2.6.22.10/fs/locks.c linux-2.6.22.10-vs2.3.0.29/fs/locks.c
6345 --- linux-2.6.22.10/fs/locks.c 2007-10-30 01:57:14 +0100
6346 +++ linux-2.6.22.10-vs2.3.0.29/fs/locks.c 2007-10-05 15:07:22 +0200
6348 #include <linux/syscalls.h>
6349 #include <linux/time.h>
6350 #include <linux/rcupdate.h>
6351 +#include <linux/vs_base.h>
6352 +#include <linux/vs_limit.h>
6354 #include <asm/semaphore.h>
6355 #include <asm/uaccess.h>
6356 @@ -147,6 +149,8 @@ static struct kmem_cache *filelock_cache
6357 /* Allocate an empty lock structure. */
6358 static struct file_lock *locks_alloc_lock(void)
6360 + if (!vx_locks_avail(1))
6362 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6365 @@ -172,6 +176,7 @@ static void locks_free_lock(struct file_
6366 BUG_ON(!list_empty(&fl->fl_block));
6367 BUG_ON(!list_empty(&fl->fl_link));
6370 locks_release_private(fl);
6371 kmem_cache_free(filelock_cache, fl);
6373 @@ -191,6 +196,7 @@ void locks_init_lock(struct file_lock *f
6374 fl->fl_start = fl->fl_end = 0;
6376 fl->fl_lmops = NULL;
6380 EXPORT_SYMBOL(locks_init_lock);
6381 @@ -244,6 +250,7 @@ void locks_copy_lock(struct file_lock *n
6382 new->fl_file = fl->fl_file;
6383 new->fl_ops = fl->fl_ops;
6384 new->fl_lmops = fl->fl_lmops;
6385 + new->fl_xid = fl->fl_xid;
6387 locks_copy_private(new, fl);
6389 @@ -282,6 +289,11 @@ static int flock_make_lock(struct file *
6390 fl->fl_flags = FL_FLOCK;
6392 fl->fl_end = OFFSET_MAX;
6394 + vxd_assert(filp->f_xid == vx_current_xid(),
6395 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6396 + fl->fl_xid = filp->f_xid;
6401 @@ -447,6 +459,7 @@ static int lease_init(struct file *filp,
6403 fl->fl_owner = current->files;
6404 fl->fl_pid = current->tgid;
6405 + fl->fl_xid = vx_current_xid();
6408 fl->fl_flags = FL_LEASE;
6409 @@ -466,6 +479,11 @@ static int lease_alloc(struct file *filp
6413 + fl->fl_xid = vx_current_xid();
6415 + vxd_assert(filp->f_xid == fl->fl_xid,
6416 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6418 error = lease_init(filp, type, fl);
6420 locks_free_lock(fl);
6421 @@ -769,6 +787,7 @@ static int flock_lock_file(struct file *
6425 + new_fl->fl_xid = -1;
6427 for_each_lock(inode, before) {
6428 struct file_lock *fl = *before;
6429 @@ -787,6 +806,7 @@ find_conflict:
6431 locks_copy_lock(new_fl, request);
6432 locks_insert_lock(before, new_fl);
6433 + vx_locks_inc(new_fl);
6437 @@ -797,7 +817,8 @@ out:
6441 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6442 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6443 + struct file_lock *conflock, xid_t xid)
6445 struct file_lock *fl;
6446 struct file_lock *new_fl = NULL;
6447 @@ -807,6 +828,8 @@ static int __posix_lock_file(struct inod
6448 struct file_lock **before;
6449 int error, added = 0;
6451 + vxd_assert(xid == vx_current_xid(),
6452 + "xid(%d) == current(%d)", xid, vx_current_xid());
6454 * We may need two file_lock structures for this operation,
6455 * so we get them in advance to avoid races.
6456 @@ -817,7 +840,11 @@ static int __posix_lock_file(struct inod
6457 (request->fl_type != F_UNLCK ||
6458 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6459 new_fl = locks_alloc_lock();
6460 + new_fl->fl_xid = xid;
6461 + vx_locks_inc(new_fl);
6462 new_fl2 = locks_alloc_lock();
6463 + new_fl2->fl_xid = xid;
6464 + vx_locks_inc(new_fl2);
6468 @@ -1016,7 +1043,8 @@ static int __posix_lock_file(struct inod
6469 int posix_lock_file(struct file *filp, struct file_lock *fl,
6470 struct file_lock *conflock)
6472 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6473 + return __posix_lock_file(filp->f_path.dentry->d_inode,
6474 + fl, conflock, filp->f_xid);
6476 EXPORT_SYMBOL(posix_lock_file);
6478 @@ -1106,7 +1134,7 @@ int locks_mandatory_area(int read_write,
6479 fl.fl_end = offset + count - 1;
6482 - error = __posix_lock_file(inode, &fl, NULL);
6483 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6484 if (error != -EAGAIN)
6486 if (!(fl.fl_flags & FL_SLEEP))
6487 @@ -1410,8 +1438,8 @@ static int __setlease(struct file *filp,
6490 locks_copy_lock(fl, lease);
6492 locks_insert_lock(before, fl);
6497 @@ -1738,6 +1766,11 @@ int fcntl_setlk(unsigned int fd, struct
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 @@ -1864,6 +1897,11 @@ int fcntl_setlk64(unsigned int fd, struc
6510 if (file_lock == NULL)
6513 + vxd_assert(filp->f_xid == vx_current_xid(),
6514 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6515 + file_lock->fl_xid = filp->f_xid;
6516 + vx_locks_inc(file_lock);
6519 * This might block, so we do it before checking the inode.
6521 @@ -2168,6 +2206,10 @@ int get_locks_status(char *buffer, char
6522 list_for_each(tmp, &file_lock_list) {
6523 struct list_head *btmp;
6524 struct file_lock *fl = list_entry(tmp, struct file_lock, fl_link);
6526 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6529 lock_get_status(q, fl, ++i, "");
6530 move_lock_status(&q, &pos, offset);
6532 diff -NurpP --minimal linux-2.6.22.10/fs/namei.c linux-2.6.22.10-vs2.3.0.29/fs/namei.c
6533 --- linux-2.6.22.10/fs/namei.c 2007-07-09 13:19:27 +0200
6534 +++ linux-2.6.22.10-vs2.3.0.29/fs/namei.c 2007-10-29 23:41:56 +0100
6536 #include <linux/file.h>
6537 #include <linux/fcntl.h>
6538 #include <linux/namei.h>
6539 +#include <linux/proc_fs.h>
6540 +#include <linux/vserver/inode.h>
6541 +#include <linux/vs_base.h>
6542 +#include <linux/vs_tag.h>
6543 +#include <linux/vs_cowbl.h>
6544 +#include <linux/vs_device.h>
6545 +#include <linux/vs_context.h>
6546 #include <asm/namei.h>
6547 #include <asm/uaccess.h>
6549 @@ -224,6 +231,28 @@ int generic_permission(struct inode *ino
6553 +static inline int dx_barrier(struct inode *inode)
6555 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN)) {
6556 + vxwprintk_task(1, "did hit the barrier.");
6562 +static inline int dx_permission(struct inode *inode, int mask, struct nameidata *nd)
6564 + if (dx_barrier(inode))
6566 + if (dx_notagcheck(nd) ||
6567 + dx_check(inode->i_tag, DX_HOSTID|DX_ADMIN|DX_WATCH|DX_IDENT))
6570 + vxwprintk_task(1, "denied access to %p[#%d,%lu] »%s«.",
6571 + inode, inode->i_tag, inode->i_ino, vxd_cond_path(nd));
6575 int permission(struct inode *inode, int mask, struct nameidata *nd)
6577 umode_t mode = inode->i_mode;
6578 @@ -234,14 +263,14 @@ int permission(struct inode *inode, int
6580 * Nobody gets write access to a read-only fs.
6582 - if (IS_RDONLY(inode) &&
6583 + if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
6584 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
6588 * Nobody gets write access to an immutable file.
6590 - if (IS_IMMUTABLE(inode))
6591 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6595 @@ -257,6 +286,12 @@ int permission(struct inode *inode, int
6597 /* Ordinary permission routines do not understand MAY_APPEND. */
6598 submask = mask & ~MAY_APPEND;
6600 + if ((inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC) &&
6601 + (inode->i_sb->s_magic != PROC_SUPER_MAGIC) &&
6602 + (retval = dx_permission(inode, mask, nd)))
6605 if (inode->i_op && inode->i_op->permission)
6606 retval = inode->i_op->permission(inode, submask, nd);
6608 @@ -432,6 +467,8 @@ static int exec_permission_lite(struct i
6610 umode_t mode = inode->i_mode;
6612 + if (dx_barrier(inode))
6614 if (inode->i_op && inode->i_op->permission)
6617 @@ -732,7 +769,8 @@ static __always_inline void follow_dotdo
6618 if (nd->dentry == fs->root &&
6619 nd->mnt == fs->rootmnt) {
6620 read_unlock(&fs->lock);
6622 + /* for sane '/' avoid follow_mount() */
6625 read_unlock(&fs->lock);
6626 spin_lock(&dcache_lock);
6627 @@ -769,16 +807,39 @@ static int do_lookup(struct nameidata *n
6629 struct vfsmount *mnt = nd->mnt;
6630 struct dentry *dentry = __d_lookup(nd->dentry, name);
6631 + struct inode *inode;
6635 if (dentry->d_op && dentry->d_op->d_revalidate)
6636 goto need_revalidate;
6637 + inode = dentry->d_inode;
6641 + if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6642 + struct proc_dir_entry *de = PDE(inode);
6644 + if (de && !vx_hide_check(0, de->vx_flags))
6646 + } else if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6647 + if (!vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
6650 + if (!dx_notagcheck(nd) && !dx_check(inode->i_tag,
6651 + DX_WATCH | DX_ADMIN | DX_HOSTID | DX_IDENT))
6656 path->dentry = dentry;
6657 __follow_mount(path);
6660 + vxwprintk_task(1, "did lookup hidden %p[#%d,%lu] »%s«.",
6661 + inode, inode->i_tag, inode->i_ino, vxd_path(dentry, mnt));
6666 dentry = real_lookup(nd->dentry, name, nd);
6667 @@ -1399,7 +1460,8 @@ static inline int check_sticky(struct in
6668 * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
6669 * nfs_async_unlink().
6671 -static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
6672 +static int may_delete(struct inode *dir, struct dentry *victim,
6673 + int isdir, struct nameidata *nd)
6677 @@ -1409,13 +1471,13 @@ static int may_delete(struct inode *dir,
6678 BUG_ON(victim->d_parent->d_inode != dir);
6679 audit_inode_child(victim->d_name.name, victim->d_inode, dir);
6681 - error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
6682 + error = permission(dir,MAY_WRITE | MAY_EXEC, nd);
6687 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6688 - IS_IMMUTABLE(victim->d_inode))
6689 + IS_IXORUNLINK(victim->d_inode))
6692 if (!S_ISDIR(victim->d_inode->i_mode))
6693 @@ -1546,6 +1608,14 @@ int may_open(struct nameidata *nd, int a
6694 if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE))
6697 +#ifdef CONFIG_VSERVER_COWBL
6698 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
6699 + if (IS_COW_LINK(inode))
6701 + inode->i_flags &= ~(S_IUNLINK|S_IMMUTABLE);
6702 + mark_inode_dirty(inode);
6705 error = vfs_permission(nd, acc_mode);
6708 @@ -1562,7 +1632,8 @@ int may_open(struct nameidata *nd, int a
6712 - } else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
6713 + } else if ((IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
6714 + && (flag & FMODE_WRITE))
6717 * An append-only file must be opened in append mode for writing.
6718 @@ -1650,6 +1721,11 @@ int open_namei(int dfd, const char *path
6722 +#ifdef CONFIG_VSERVER_COWBL
6727 acc_mode = ACC_MODE(flag);
6729 /* O_TRUNC implies we need access checks for write permissions */
6730 @@ -1743,6 +1819,22 @@ do_last:
6733 error = may_open(nd, acc_mode, flag);
6734 +#ifdef CONFIG_VSERVER_COWBL
6735 + if (error == -EMLINK) {
6736 + struct dentry *dentry;
6737 + dentry = cow_break_link(pathname);
6738 + if (IS_ERR(dentry)) {
6739 + error = PTR_ERR(dentry);
6743 + release_open_intent(nd);
6753 @@ -1854,16 +1946,25 @@ fail:
6755 EXPORT_SYMBOL_GPL(lookup_create);
6757 -int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
6758 +int vfs_mknod(struct inode *dir, struct dentry *dentry,
6759 + int mode, dev_t dev, struct nameidata *nd)
6761 - int error = may_create(dir, dentry, NULL);
6762 + int error = may_create(dir, dentry, nd);
6767 - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
6768 + if (!(S_ISCHR(mode) || S_ISBLK(mode)))
6771 + if (!capable(CAP_MKNOD))
6774 + if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
6776 + if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
6779 if (!dir->i_op || !dir->i_op->mknod)
6782 @@ -1906,11 +2007,12 @@ asmlinkage long sys_mknodat(int dfd, con
6783 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
6785 case S_IFCHR: case S_IFBLK:
6786 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
6787 - new_decode_dev(dev));
6788 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6789 + new_decode_dev(dev), &nd);
6791 case S_IFIFO: case S_IFSOCK:
6792 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
6793 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
6798 @@ -1933,9 +2035,10 @@ asmlinkage long sys_mknod(const char __u
6799 return sys_mknodat(AT_FDCWD, filename, mode, dev);
6802 -int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
6803 +int vfs_mkdir(struct inode *dir, struct dentry *dentry,
6804 + int mode, struct nameidata *nd)
6806 - int error = may_create(dir, dentry, NULL);
6807 + int error = may_create(dir, dentry, nd);
6811 @@ -1977,7 +2080,7 @@ asmlinkage long sys_mkdirat(int dfd, con
6813 if (!IS_POSIXACL(nd.dentry->d_inode))
6814 mode &= ~current->fs->umask;
6815 - error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
6816 + error = vfs_mkdir(nd.dentry->d_inode, dentry, mode, &nd);
6819 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6820 @@ -2020,9 +2123,10 @@ void dentry_unhash(struct dentry *dentry
6821 spin_unlock(&dcache_lock);
6824 -int vfs_rmdir(struct inode *dir, struct dentry *dentry)
6825 +int vfs_rmdir(struct inode *dir, struct dentry *dentry,
6826 + struct nameidata *nd)
6828 - int error = may_delete(dir, dentry, 1);
6829 + int error = may_delete(dir, dentry, 1, nd);
6833 @@ -2084,7 +2188,7 @@ static long do_rmdir(int dfd, const char
6834 error = PTR_ERR(dentry);
6837 - error = vfs_rmdir(nd.dentry->d_inode, dentry);
6838 + error = vfs_rmdir(nd.dentry->d_inode, dentry, &nd);
6841 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6842 @@ -2100,9 +2204,10 @@ asmlinkage long sys_rmdir(const char __u
6843 return do_rmdir(AT_FDCWD, pathname);
6846 -int vfs_unlink(struct inode *dir, struct dentry *dentry)
6847 +int vfs_unlink(struct inode *dir, struct dentry *dentry,
6848 + struct nameidata *nd)
6850 - int error = may_delete(dir, dentry, 0);
6851 + int error = may_delete(dir, dentry, 0, nd);
6855 @@ -2164,7 +2269,7 @@ static long do_unlinkat(int dfd, const c
6856 inode = dentry->d_inode;
6858 atomic_inc(&inode->i_count);
6859 - error = vfs_unlink(nd.dentry->d_inode, dentry);
6860 + error = vfs_unlink(nd.dentry->d_inode, dentry, &nd);
6864 @@ -2199,9 +2304,10 @@ asmlinkage long sys_unlink(const char __
6865 return do_unlinkat(AT_FDCWD, pathname);
6868 -int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode)
6869 +int vfs_symlink(struct inode *dir, struct dentry *dentry,
6870 + const char *oldname, int mode, struct nameidata *nd)
6872 - int error = may_create(dir, dentry, NULL);
6873 + int error = may_create(dir, dentry, nd);
6877 @@ -2245,7 +2351,7 @@ asmlinkage long sys_symlinkat(const char
6881 - error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
6882 + error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO, &nd);
6885 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6886 @@ -2262,7 +2368,8 @@ asmlinkage long sys_symlink(const char _
6887 return sys_symlinkat(oldname, AT_FDCWD, newname);
6890 -int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
6891 +int vfs_link(struct dentry *old_dentry, struct inode *dir,
6892 + struct dentry *new_dentry, struct nameidata *nd)
6894 struct inode *inode = old_dentry->d_inode;
6896 @@ -2270,7 +2377,7 @@ int vfs_link(struct dentry *old_dentry,
6900 - error = may_create(dir, new_dentry, NULL);
6901 + error = may_create(dir, new_dentry, nd);
6905 @@ -2280,7 +2387,7 @@ int vfs_link(struct dentry *old_dentry,
6907 * A link to an append-only or immutable file cannot be created.
6909 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6910 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6912 if (!dir->i_op || !dir->i_op->link)
6914 @@ -2340,7 +2447,7 @@ asmlinkage long sys_linkat(int olddfd, c
6915 error = PTR_ERR(new_dentry);
6916 if (IS_ERR(new_dentry))
6918 - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
6919 + error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry, &nd);
6922 mutex_unlock(&nd.dentry->d_inode->i_mutex);
6923 @@ -2472,14 +2579,14 @@ int vfs_rename(struct inode *old_dir, st
6924 if (old_dentry->d_inode == new_dentry->d_inode)
6927 - error = may_delete(old_dir, old_dentry, is_dir);
6928 + error = may_delete(old_dir, old_dentry, is_dir, NULL);
6932 if (!new_dentry->d_inode)
6933 error = may_create(new_dir, new_dentry, NULL);
6935 - error = may_delete(new_dir, new_dentry, is_dir);
6936 + error = may_delete(new_dir, new_dentry, is_dir, NULL);
6940 @@ -2557,6 +2664,9 @@ static int do_rename(int olddfd, const c
6942 if (old_dentry == trap)
6945 + if (MNT_IS_RDONLY(newnd.mnt))
6947 new_dentry = lookup_hash(&newnd);
6948 error = PTR_ERR(new_dentry);
6949 if (IS_ERR(new_dentry))
6950 @@ -2650,6 +2760,216 @@ int vfs_follow_link(struct nameidata *nd
6951 return __vfs_follow_link(nd, link);
6955 +#ifdef CONFIG_VSERVER_COWBL
6957 +#include <linux/file.h>
6960 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6964 + return do_splice_direct(in, &ppos, out, len, 0);
6967 +struct dentry *cow_break_link(const char *pathname)
6969 + int ret, mode, pathlen, redo = 0;
6970 + struct nameidata old_nd, dir_nd;
6971 + struct dentry *old_dentry, *new_dentry;
6972 + struct dentry *dir, *res = NULL;
6973 + struct vfsmount *old_mnt, *new_mnt;
6974 + struct file *old_file;
6975 + struct file *new_file;
6976 + char *to, *path, pad='\251';
6979 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6980 + path = kmalloc(PATH_MAX, GFP_KERNEL);
6985 + /* old_nd will have refs to dentry and mnt */
6986 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6987 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6989 + goto out_free_path;
6991 + old_dentry = old_nd.dentry;
6992 + old_mnt = old_nd.mnt;
6993 + mode = old_dentry->d_inode->i_mode;
6995 + to = d_path(old_dentry, old_mnt, path, PATH_MAX-2);
6996 + pathlen = strlen(to);
6997 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
6998 + old_dentry->d_name.len, old_dentry->d_name.name,
6999 + old_dentry->d_name.len);
7001 + to[pathlen + 1] = 0;
7003 + to[pathlen] = pad--;
7005 + if (pad <= '\240')
7008 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
7009 + /* dir_nd will have refs to dentry and mnt */
7010 + ret = path_lookup(to,
7011 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
7012 + vxdprintk(VXD_CBIT(misc, 2),
7013 + "path_lookup(new): %d", ret);
7017 + /* this puppy downs the inode mutex */
7018 + new_dentry = lookup_create(&dir_nd, 0);
7019 + vxdprintk(VXD_CBIT(misc, 2),
7020 + "lookup_create(new): %p [»%.*s«:%d]", new_dentry,
7021 + new_dentry->d_name.len, new_dentry->d_name.name,
7022 + new_dentry->d_name.len);
7023 + if (!new_dentry || IS_ERR(new_dentry)) {
7024 + path_release(&dir_nd);
7027 + dir = dir_nd.dentry;
7029 + ret = vfs_create(dir_nd.dentry->d_inode, new_dentry, mode, &dir_nd);
7030 + vxdprintk(VXD_CBIT(misc, 2),
7031 + "vfs_create(new): %d", ret);
7032 + if (ret == -EEXIST) {
7033 + mutex_unlock(&dir->d_inode->i_mutex);
7035 + path_release(&dir_nd);
7039 + goto out_unlock_new;
7041 + /* drop out early, ret passes ENOENT */
7043 + if ((redo = d_unhashed(old_dentry)))
7044 + goto out_unlock_new;
7046 + new_mnt = dir_nd.mnt;
7049 + /* this one cleans up the dentry/mnt in case of failure */
7050 + old_file = dentry_open(old_dentry, old_mnt, O_RDONLY);
7051 + vxdprintk(VXD_CBIT(misc, 2),
7052 + "dentry_open(old): %p", old_file);
7053 + if (!old_file || IS_ERR(old_file)) {
7054 + res = IS_ERR(old_file) ? (void *) old_file : res;
7055 + goto out_unlock_new;
7060 + /* this one cleans up the dentry/mnt in case of failure */
7061 + new_file = dentry_open(new_dentry, new_mnt, O_WRONLY);
7062 + vxdprintk(VXD_CBIT(misc, 2),
7063 + "dentry_open(new): %p", new_file);
7065 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
7066 + if (!new_file || IS_ERR(new_file))
7067 + goto out_fput_old;
7069 + size = i_size_read(old_file->f_dentry->d_inode);
7070 + ret = do_cow_splice(old_file, new_file, size);
7071 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
7073 + goto out_fput_both;
7074 + } else if (ret < size) {
7076 + goto out_fput_both;
7078 + struct inode *old_inode = old_dentry->d_inode;
7079 + struct inode *new_inode = new_dentry->d_inode;
7080 + struct iattr attr = {
7081 + .ia_uid = old_inode->i_uid,
7082 + .ia_gid = old_inode->i_gid,
7083 + .ia_valid = ATTR_UID | ATTR_GID
7086 + ret = inode_setattr(new_inode, &attr);
7088 + goto out_fput_both;
7091 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
7093 + /* drop out late */
7095 + if ((redo = d_unhashed(old_dentry)))
7098 + vxdprintk(VXD_CBIT(misc, 2),
7099 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
7100 + new_dentry->d_name.len, new_dentry->d_name.name,
7101 + new_dentry->d_name.len,
7102 + old_dentry->d_name.len, old_dentry->d_name.name,
7103 + old_dentry->d_name.len);
7104 + ret = vfs_rename(dir_nd.dentry->d_inode, new_dentry,
7105 + old_nd.dentry->d_parent->d_inode, old_dentry);
7106 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
7110 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
7113 + vxdprintk(VXD_CBIT(misc, 3),
7114 + "fput(new_file=%p[#%d])", new_file,
7115 + atomic_read(&new_file->f_count));
7119 + vxdprintk(VXD_CBIT(misc, 3),
7120 + "fput(old_file=%p[#%d])", old_file,
7121 + atomic_read(&old_file->f_count));
7125 + mutex_unlock(&dir->d_inode->i_mutex);
7129 + /* error path cleanup */
7130 + vfs_unlink(dir->d_inode, new_dentry, &dir_nd);
7135 + goto out_rel_both;
7136 + /* lookup dentry once again */
7137 + path_release(&old_nd);
7138 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
7140 + goto out_rel_both;
7142 + new_dentry = old_nd.dentry;
7143 + vxdprintk(VXD_CBIT(misc, 2),
7144 + "path_lookup(redo): %p [»%.*s«:%d]", new_dentry,
7145 + new_dentry->d_name.len, new_dentry->d_name.name,
7146 + new_dentry->d_name.len);
7151 + path_release(&dir_nd);
7153 + path_release(&old_nd);
7158 + res = ERR_PTR(ret);
7164 /* get the link contents into pagecache */
7165 static char *page_getlink(struct dentry * dentry, struct page **ppage)
7167 diff -NurpP --minimal linux-2.6.22.10/fs/namespace.c linux-2.6.22.10-vs2.3.0.29/fs/namespace.c
7168 --- linux-2.6.22.10/fs/namespace.c 2007-07-09 13:19:27 +0200
7169 +++ linux-2.6.22.10-vs2.3.0.29/fs/namespace.c 2007-09-05 02:29:17 +0200
7171 #include <linux/security.h>
7172 #include <linux/mount.h>
7173 #include <linux/ramfs.h>
7174 +#include <linux/vs_base.h>
7175 +#include <linux/vs_context.h>
7176 +#include <linux/vs_tag.h>
7177 +#include <linux/vserver/space.h>
7178 +#include <linux/vserver/global.h>
7179 #include <asm/uaccess.h>
7180 #include <asm/unistd.h>
7182 @@ -240,6 +245,7 @@ static struct vfsmount *clone_mnt(struct
7183 mnt->mnt_root = dget(root);
7184 mnt->mnt_mountpoint = mnt->mnt_root;
7185 mnt->mnt_parent = mnt;
7186 + mnt->mnt_tag = old->mnt_tag;
7188 if (flag & CL_SLAVE) {
7189 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
7190 @@ -348,48 +354,91 @@ static inline void mangle(struct seq_fil
7191 seq_escape(m, s, " \t\n\\");
7194 +static int mnt_is_reachable(struct vfsmount *mnt)
7196 + struct vfsmount *root_mnt;
7197 + struct dentry *root, *point;
7200 + if (mnt == mnt->mnt_ns->root)
7203 + spin_lock(&vfsmount_lock);
7204 + root_mnt = current->fs->rootmnt;
7205 + root = current->fs->root;
7208 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
7209 + point = mnt->mnt_mountpoint;
7210 + mnt = mnt->mnt_parent;
7213 + ret = (mnt == root_mnt) && is_subdir(point, root);
7215 + spin_unlock(&vfsmount_lock);
7220 static int show_vfsmnt(struct seq_file *m, void *v)
7222 struct vfsmount *mnt = v;
7224 static struct proc_fs_info {
7232 - { MS_SYNCHRONOUS, ",sync" },
7233 - { MS_DIRSYNC, ",dirsync" },
7234 - { MS_MANDLOCK, ",mand" },
7237 - static struct proc_fs_info mnt_info[] = {
7238 - { MNT_NOSUID, ",nosuid" },
7239 - { MNT_NODEV, ",nodev" },
7240 - { MNT_NOEXEC, ",noexec" },
7241 - { MNT_NOATIME, ",noatime" },
7242 - { MNT_NODIRATIME, ",nodiratime" },
7243 - { MNT_RELATIME, ",relatime" },
7245 + { MS_RDONLY, MNT_RDONLY, "ro", "rw" },
7246 + { MS_SYNCHRONOUS, 0, ",sync", NULL },
7247 + { MS_DIRSYNC, 0, ",dirsync", NULL },
7248 + { MS_MANDLOCK, 0, ",mand", NULL },
7249 + { MS_TAGGED, 0, ",tag", NULL },
7250 + { MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
7251 + { MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
7252 + { MS_RELATIME, MNT_RELATIME, ",relatime", NULL },
7253 + { 0, MNT_NOSUID, ",nosuid", NULL },
7254 + { 0, MNT_NODEV, ",nodev", NULL },
7255 + { 0, MNT_NOEXEC, ",noexec", NULL },
7256 + { 0, 0, NULL, NULL }
7258 - struct proc_fs_info *fs_infop;
7259 + struct proc_fs_info *p;
7260 + unsigned long s_flags = mnt->mnt_sb->s_flags;
7261 + int mnt_flags = mnt->mnt_flags;
7263 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7265 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7267 - mangle(m, mnt->mnt_sb->s_type->name);
7268 - if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
7270 - mangle(m, mnt->mnt_sb->s_subtype);
7272 - seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
7273 - for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
7274 - if (mnt->mnt_sb->s_flags & fs_infop->flag)
7275 - seq_puts(m, fs_infop->str);
7276 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7278 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7281 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7282 + mnt == current->fs->rootmnt) {
7283 + seq_puts(m, "/dev/root / ");
7285 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7287 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7290 + if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
7292 + mangle(m, mnt->mnt_sb->s_subtype);
7295 - for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
7296 - if (mnt->mnt_flags & fs_infop->flag)
7297 - seq_puts(m, fs_infop->str);
7298 + mangle(m, mnt->mnt_sb->s_type->name);
7300 + for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
7301 + if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
7303 + seq_puts(m, p->set_str);
7306 + seq_puts(m, p->unset_str);
7309 + if (mnt->mnt_flags & MNT_TAGID)
7310 + seq_printf(m, ",tag=%d", mnt->mnt_tag);
7311 if (mnt->mnt_sb->s_op->show_options)
7312 err = mnt->mnt_sb->s_op->show_options(m, mnt);
7313 seq_puts(m, " 0 0\n");
7314 @@ -408,17 +457,27 @@ static int show_vfsstat(struct seq_file
7315 struct vfsmount *mnt = v;
7319 - if (mnt->mnt_devname) {
7320 - seq_puts(m, "device ");
7321 - mangle(m, mnt->mnt_devname);
7323 - seq_puts(m, "no device");
7324 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7326 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7330 - seq_puts(m, " mounted on ");
7331 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7333 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7334 + mnt == current->fs->rootmnt) {
7335 + seq_puts(m, "device /dev/root mounted on / ");
7338 + if (mnt->mnt_devname) {
7339 + seq_puts(m, "device ");
7340 + mangle(m, mnt->mnt_devname);
7342 + seq_puts(m, "no device");
7345 + seq_puts(m, " mounted on ");
7346 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
7350 /* file system type */
7351 seq_puts(m, "with fstype ");
7352 @@ -648,7 +707,7 @@ asmlinkage long sys_umount(char __user *
7356 - if (!capable(CAP_SYS_ADMIN))
7357 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7360 retval = do_umount(nd.mnt, flags);
7361 @@ -672,7 +731,7 @@ asmlinkage long sys_oldumount(char __use
7363 static int mount_is_safe(struct nameidata *nd)
7365 - if (capable(CAP_SYS_ADMIN))
7366 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7370 @@ -904,11 +963,13 @@ static int do_change_type(struct nameida
7372 * do loopback mount.
7374 -static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
7375 +static int do_loopback(struct nameidata *nd, char *old_name, tag_t tag,
7376 + unsigned long flags, int mnt_flags)
7378 struct nameidata old_nd;
7379 struct vfsmount *mnt = NULL;
7380 int err = mount_is_safe(nd);
7381 + int recurse = flags & MS_REC;
7384 if (!old_name || !*old_name)
7385 @@ -934,6 +995,12 @@ static int do_loopback(struct nameidata
7389 + mnt->mnt_flags = mnt_flags;
7390 + if (flags & MS_TAGID) {
7391 + mnt->mnt_tag = tag;
7392 + mnt->mnt_flags |= MNT_TAGID;
7395 err = graft_tree(mnt, nd);
7397 LIST_HEAD(umount_list);
7398 @@ -942,6 +1009,7 @@ static int do_loopback(struct nameidata
7399 spin_unlock(&vfsmount_lock);
7400 release_mounts(&umount_list);
7402 + mnt->mnt_flags = mnt_flags;
7405 up_write(&namespace_sem);
7406 @@ -955,12 +1023,12 @@ out:
7407 * on it - tough luck.
7409 static int do_remount(struct nameidata *nd, int flags, int mnt_flags,
7411 + void *data, xid_t xid)
7414 struct super_block *sb = nd->mnt->mnt_sb;
7416 - if (!capable(CAP_SYS_ADMIN))
7417 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7420 if (!check_mnt(nd->mnt))
7421 @@ -994,7 +1062,7 @@ static int do_move_mount(struct nameidat
7422 struct nameidata old_nd, parent_nd;
7425 - if (!capable(CAP_SYS_ADMIN))
7426 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7428 if (!old_name || !*old_name)
7430 @@ -1074,7 +1142,7 @@ static int do_new_mount(struct nameidata
7433 /* we need capabilities... */
7434 - if (!capable(CAP_SYS_ADMIN))
7435 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7438 mnt = do_kern_mount(type, flags, name, data);
7439 @@ -1386,6 +1454,7 @@ long do_mount(char *dev_name, char *dir_
7440 struct nameidata nd;
7446 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7447 @@ -1401,7 +1470,17 @@ long do_mount(char *dev_name, char *dir_
7449 ((char *)data_page)[PAGE_SIZE - 1] = 0;
7451 + retval = dx_parse_tag(data_page, &tag, 1);
7453 + mnt_flags |= retval;
7454 + /* FIXME: bind and re-mounts get the tag flag? */
7455 + if (flags & (MS_BIND|MS_REMOUNT))
7456 + flags |= MS_TAGID;
7459 /* Separate the per-mountpoint flags */
7460 + if (flags & MS_RDONLY)
7461 + mnt_flags |= MNT_RDONLY;
7462 if (flags & MS_NOSUID)
7463 mnt_flags |= MNT_NOSUID;
7464 if (flags & MS_NODEV)
7465 @@ -1415,6 +1494,8 @@ long do_mount(char *dev_name, char *dir_
7466 if (flags & MS_RELATIME)
7467 mnt_flags |= MNT_RELATIME;
7469 + if (!capable(CAP_SYS_ADMIN))
7470 + mnt_flags |= MNT_NODEV;
7471 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
7472 MS_NOATIME | MS_NODIRATIME | MS_RELATIME);
7474 @@ -1429,9 +1510,9 @@ long do_mount(char *dev_name, char *dir_
7476 if (flags & MS_REMOUNT)
7477 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
7480 else if (flags & MS_BIND)
7481 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
7482 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
7483 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7484 retval = do_change_type(&nd, flags);
7485 else if (flags & MS_MOVE)
7486 @@ -1504,6 +1585,7 @@ static struct mnt_namespace *dup_mnt_ns(
7487 q = next_mnt(q, new_ns->root);
7489 up_write(&namespace_sem);
7490 + atomic_inc(&vs_global_mnt_ns);
7494 @@ -1866,5 +1948,6 @@ void __put_mnt_ns(struct mnt_namespace *
7495 spin_unlock(&vfsmount_lock);
7496 up_write(&namespace_sem);
7497 release_mounts(&umount_list);
7498 + atomic_dec(&vs_global_mnt_ns);
7501 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
7502 --- linux-2.6.22.10/fs/nfs/client.c 2007-07-09 13:19:27 +0200
7503 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/client.c 2007-08-05 20:53:13 +0200
7504 @@ -521,6 +521,9 @@ static int nfs_init_server_rpcclient(str
7505 if (server->flags & NFS4_MOUNT_INTR)
7506 server->client->cl_intr = 1;
7508 + server->client->cl_tag = 0;
7509 + if (server->flags & NFS_MOUNT_TAGGED)
7510 + server->client->cl_tag = 1;
7514 @@ -678,6 +681,10 @@ static void nfs_server_set_fsinfo(struct
7515 server->acdirmin = server->acdirmax = 0;
7518 + /* FIXME: needs fsinfo
7519 + if (server->flags & NFS_MOUNT_TAGGED)
7520 + sb->s_flags |= MS_TAGGED; */
7522 server->maxfilesize = fsinfo->maxfilesize;
7524 /* We're airborne Set socket buffersize */
7525 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
7526 --- linux-2.6.22.10/fs/nfs/dir.c 2007-07-09 13:19:27 +0200
7527 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/dir.c 2007-08-05 20:53:13 +0200
7529 #include <linux/namei.h>
7530 #include <linux/mount.h>
7531 #include <linux/sched.h>
7532 +#include <linux/vs_tag.h>
7534 #include "nfs4_fs.h"
7535 #include "delegation.h"
7536 @@ -956,6 +957,7 @@ static struct dentry *nfs_lookup(struct
7540 + dx_propagate_tag(nd, inode);
7542 res = d_materialise_unique(dentry, inode);
7544 @@ -998,7 +1000,8 @@ static int is_atomic_open(struct inode *
7545 if (nd->flags & LOOKUP_DIRECTORY)
7547 /* Are we trying to write to a read only partition? */
7548 - if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7549 + if ((IS_RDONLY(dir) || MNT_IS_RDONLY(nd->mnt)) &&
7550 + (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
7554 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
7555 --- linux-2.6.22.10/fs/nfs/inode.c 2007-07-09 13:19:27 +0200
7556 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/inode.c 2007-08-05 20:53:13 +0200
7558 #include <linux/vfs.h>
7559 #include <linux/inet.h>
7560 #include <linux/nfs_xdr.h>
7561 +#include <linux/vs_tag.h>
7563 #include <asm/system.h>
7564 #include <asm/uaccess.h>
7565 @@ -285,8 +286,10 @@ nfs_fhget(struct super_block *sb, struct
7566 nfsi->change_attr = fattr->change_attr;
7567 inode->i_size = nfs_size_to_loff_t(fattr->size);
7568 inode->i_nlink = fattr->nlink;
7569 - inode->i_uid = fattr->uid;
7570 - inode->i_gid = fattr->gid;
7571 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7572 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7573 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7574 + /* maybe fattr->xid someday */
7575 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7577 * report the blocks in 512byte units
7578 @@ -377,6 +380,8 @@ void nfs_setattr_update_inode(struct ino
7579 inode->i_uid = attr->ia_uid;
7580 if ((attr->ia_valid & ATTR_GID) != 0)
7581 inode->i_gid = attr->ia_gid;
7582 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7583 + inode->i_tag = attr->ia_tag;
7584 spin_lock(&inode->i_lock);
7585 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7586 spin_unlock(&inode->i_lock);
7587 @@ -825,6 +830,9 @@ static int nfs_check_inode_attributes(st
7588 struct nfs_inode *nfsi = NFS_I(inode);
7589 loff_t cur_size, new_isize;
7596 /* Has the inode gone and changed behind our back? */
7597 @@ -852,10 +860,15 @@ static int nfs_check_inode_attributes(st
7598 if (cur_size != new_isize && nfsi->npages == 0)
7599 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7601 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7602 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7603 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7605 /* Have any file permissions changed? */
7606 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
7607 - || inode->i_uid != fattr->uid
7608 - || inode->i_gid != fattr->gid)
7609 + || inode->i_uid != uid
7610 + || inode->i_gid != gid
7611 + || inode->i_tag != tag)
7612 nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7614 /* Has the link count changed? */
7615 @@ -946,6 +959,9 @@ static int nfs_update_inode(struct inode
7616 unsigned int invalid = 0;
7617 unsigned long now = jiffies;
7623 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7624 __FUNCTION__, inode->i_sb->s_id, inode->i_ino,
7625 @@ -1022,15 +1038,21 @@ static int nfs_update_inode(struct inode
7627 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7629 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7630 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7631 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7633 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
7634 - inode->i_uid != fattr->uid ||
7635 - inode->i_gid != fattr->gid)
7636 + inode->i_uid != uid ||
7637 + inode->i_gid != gid ||
7638 + inode->i_tag != tag)
7639 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7641 inode->i_mode = fattr->mode;
7642 inode->i_nlink = fattr->nlink;
7643 - inode->i_uid = fattr->uid;
7644 - inode->i_gid = fattr->gid;
7645 + inode->i_uid = uid;
7646 + inode->i_gid = gid;
7647 + inode->i_tag = tag;
7649 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
7651 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
7652 --- linux-2.6.22.10/fs/nfs/nfs3xdr.c 2007-07-09 13:19:27 +0200
7653 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/nfs3xdr.c 2007-08-05 20:53:13 +0200
7655 #include <linux/nfs3.h>
7656 #include <linux/nfs_fs.h>
7657 #include <linux/nfsacl.h>
7658 +#include <linux/vs_tag.h>
7659 #include "internal.h"
7661 #define NFSDBG_FACILITY NFSDBG_XDR
7662 @@ -178,7 +179,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7665 static inline __be32 *
7666 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7667 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7669 if (attr->ia_valid & ATTR_MODE) {
7671 @@ -186,15 +187,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7675 - if (attr->ia_valid & ATTR_UID) {
7676 + if (attr->ia_valid & ATTR_UID ||
7677 + (tag && (attr->ia_valid & ATTR_TAG))) {
7679 - *p++ = htonl(attr->ia_uid);
7680 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7684 - if (attr->ia_valid & ATTR_GID) {
7685 + if (attr->ia_valid & ATTR_GID ||
7686 + (tag && (attr->ia_valid & ATTR_TAG))) {
7688 - *p++ = htonl(attr->ia_gid);
7689 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7693 @@ -279,7 +282,8 @@ static int
7694 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7696 p = xdr_encode_fhandle(p, args->fh);
7697 - p = xdr_encode_sattr(p, args->sattr);
7698 + p = xdr_encode_sattr(p, args->sattr,
7699 + req->rq_task->tk_client->cl_tag);
7700 *p++ = htonl(args->guard);
7702 p = xdr_encode_time3(p, &args->guardtime);
7703 @@ -370,7 +374,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7704 *p++ = args->verifier[0];
7705 *p++ = args->verifier[1];
7707 - p = xdr_encode_sattr(p, args->sattr);
7708 + p = xdr_encode_sattr(p, args->sattr,
7709 + req->rq_task->tk_client->cl_tag);
7711 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7713 @@ -384,7 +389,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7715 p = xdr_encode_fhandle(p, args->fh);
7716 p = xdr_encode_array(p, args->name, args->len);
7717 - p = xdr_encode_sattr(p, args->sattr);
7718 + p = xdr_encode_sattr(p, args->sattr,
7719 + req->rq_task->tk_client->cl_tag);
7720 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7723 @@ -397,7 +403,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7725 p = xdr_encode_fhandle(p, args->fromfh);
7726 p = xdr_encode_array(p, args->fromname, args->fromlen);
7727 - p = xdr_encode_sattr(p, args->sattr);
7728 + p = xdr_encode_sattr(p, args->sattr,
7729 + req->rq_task->tk_client->cl_tag);
7730 *p++ = htonl(args->pathlen);
7731 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7733 @@ -415,7 +422,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7734 p = xdr_encode_fhandle(p, args->fh);
7735 p = xdr_encode_array(p, args->name, args->len);
7736 *p++ = htonl(args->type);
7737 - p = xdr_encode_sattr(p, args->sattr);
7738 + p = xdr_encode_sattr(p, args->sattr,
7739 + req->rq_task->tk_client->cl_tag);
7740 if (args->type == NF3CHR || args->type == NF3BLK) {
7741 *p++ = htonl(MAJOR(args->rdev));
7742 *p++ = htonl(MINOR(args->rdev));
7743 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
7744 --- linux-2.6.22.10/fs/nfs/nfsroot.c 2007-07-09 13:19:27 +0200
7745 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/nfsroot.c 2007-08-05 20:53:13 +0200
7746 @@ -118,12 +118,12 @@ static int mount_port __initdata = 0; /
7748 /* Options that take integer arguments */
7749 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7750 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7751 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7752 /* Options that take no arguments */
7753 Opt_soft, Opt_hard, Opt_intr,
7754 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
7755 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7756 - Opt_acl, Opt_noacl,
7757 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7761 @@ -160,6 +160,9 @@ static match_table_t __initdata tokens =
7764 {Opt_noacl, "noacl"},
7766 + {Opt_notag, "notag"},
7767 + {Opt_tagid, "tagid=%u"},
7771 @@ -274,6 +277,20 @@ static int __init root_nfs_parse(char *n
7773 nfs_data.flags |= NFS_MOUNT_NOACL;
7775 +#ifndef CONFIG_TAGGING_NONE
7777 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7780 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7783 +#ifdef CONFIG_PROPAGATE
7786 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7790 printk(KERN_WARNING "Root-NFS: unknown "
7792 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
7793 --- linux-2.6.22.10/fs/nfs/super.c 2007-10-30 01:57:14 +0100
7794 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfs/super.c 2007-09-30 14:58:01 +0200
7796 #include <linux/inet.h>
7797 #include <linux/nfs_xdr.h>
7798 #include <linux/magic.h>
7799 +#include <linux/vs_tag.h>
7801 #include <asm/system.h>
7802 #include <asm/uaccess.h>
7803 @@ -291,6 +292,7 @@ static void nfs_show_mount_options(struc
7804 { NFS_MOUNT_NONLM, ",nolock", "" },
7805 { NFS_MOUNT_NOACL, ",noacl", "" },
7806 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7807 + { NFS_MOUNT_TAGGED, ",tag", "" },
7810 const struct proc_nfs_info *nfs_infop;
7811 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
7812 --- linux-2.6.22.10/fs/nfsd/auth.c 2006-06-18 04:54:42 +0200
7813 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/auth.c 2007-08-05 20:53:13 +0200
7815 #include <linux/sunrpc/svc.h>
7816 #include <linux/sunrpc/svcauth.h>
7817 #include <linux/nfsd/nfsd.h>
7818 +#include <linux/vs_tag.h>
7820 #define CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
7822 @@ -41,19 +42,22 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7823 get_group_info(cred.cr_group_info);
7825 if (cred.cr_uid != (uid_t) -1)
7826 - current->fsuid = cred.cr_uid;
7827 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7829 current->fsuid = exp->ex_anon_uid;
7830 if (cred.cr_gid != (gid_t) -1)
7831 - current->fsgid = cred.cr_gid;
7832 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
7834 current->fsgid = exp->ex_anon_gid;
7836 + /* this desperately needs a tag :) */
7837 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7839 if (!cred.cr_group_info)
7841 ret = set_current_groups(cred.cr_group_info);
7842 put_group_info(cred.cr_group_info);
7843 - if ((cred.cr_uid)) {
7844 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
7845 cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
7847 cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
7848 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
7849 --- linux-2.6.22.10/fs/nfsd/nfs3xdr.c 2007-07-09 13:19:27 +0200
7850 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs3xdr.c 2007-08-05 20:53:13 +0200
7852 #include <linux/sunrpc/svc.h>
7853 #include <linux/nfsd/nfsd.h>
7854 #include <linux/nfsd/xdr3.h>
7855 +#include <linux/vs_tag.h>
7857 #define NFSDDBG_FACILITY NFSDDBG_XDR
7859 @@ -107,6 +108,8 @@ static __be32 *
7860 decode_sattr3(__be32 *p, struct iattr *iap)
7868 @@ -116,12 +119,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7871 iap->ia_valid |= ATTR_UID;
7872 - iap->ia_uid = ntohl(*p++);
7873 + uid = ntohl(*p++);
7876 iap->ia_valid |= ATTR_GID;
7877 - iap->ia_gid = ntohl(*p++);
7878 + gid = ntohl(*p++);
7880 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7881 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7882 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7886 @@ -180,8 +186,10 @@ encode_fattr3(struct svc_rqst *rqstp, __
7887 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7888 *p++ = htonl((u32) stat->mode);
7889 *p++ = htonl((u32) stat->nlink);
7890 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7891 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7892 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7893 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7894 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7895 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7896 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7897 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7899 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
7900 --- linux-2.6.22.10/fs/nfsd/nfs4recover.c 2007-07-09 13:19:27 +0200
7901 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs4recover.c 2007-08-05 20:53:13 +0200
7902 @@ -156,7 +156,7 @@ nfsd4_create_clid_dir(struct nfs4_client
7903 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n");
7906 - status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU);
7907 + status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU, NULL);
7911 @@ -260,7 +260,7 @@ nfsd4_remove_clid_file(struct dentry *di
7914 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7915 - status = vfs_unlink(dir->d_inode, dentry);
7916 + status = vfs_unlink(dir->d_inode, dentry, NULL);
7917 mutex_unlock(&dir->d_inode->i_mutex);
7920 @@ -275,7 +275,7 @@ nfsd4_clear_clid_dir(struct dentry *dir,
7921 * a kernel from the future.... */
7922 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
7923 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
7924 - status = vfs_rmdir(dir->d_inode, dentry);
7925 + status = vfs_rmdir(dir->d_inode, dentry, NULL);
7926 mutex_unlock(&dir->d_inode->i_mutex);
7929 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
7930 --- linux-2.6.22.10/fs/nfsd/nfs4xdr.c 2007-07-09 13:19:27 +0200
7931 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfs4xdr.c 2007-08-05 20:53:13 +0200
7933 #include <linux/nfsd_idmap.h>
7934 #include <linux/nfs4.h>
7935 #include <linux/nfs4_acl.h>
7936 +#include <linux/vs_tag.h>
7938 #define NFSDDBG_FACILITY NFSDDBG_XDR
7940 @@ -1727,14 +1728,18 @@ out_acl:
7941 WRITE32(stat.nlink);
7943 if (bmval1 & FATTR4_WORD1_OWNER) {
7944 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7945 + status = nfsd4_encode_user(rqstp,
7946 + TAGINO_UID(DX_TAG(dentry->d_inode),
7947 + stat.uid, stat.tag), &p, &buflen);
7948 if (status == nfserr_resource)
7953 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7954 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7955 + status = nfsd4_encode_group(rqstp,
7956 + TAGINO_GID(DX_TAG(dentry->d_inode),
7957 + stat.gid, stat.tag), &p, &buflen);
7958 if (status == nfserr_resource)
7961 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
7962 --- linux-2.6.22.10/fs/nfsd/nfsxdr.c 2007-07-09 13:19:27 +0200
7963 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/nfsxdr.c 2007-08-05 20:53:13 +0200
7965 #include <linux/nfsd/nfsd.h>
7966 #include <linux/nfsd/xdr.h>
7967 #include <linux/mm.h>
7968 +#include <linux/vs_tag.h>
7970 #define NFSDDBG_FACILITY NFSDDBG_XDR
7972 @@ -97,6 +98,8 @@ static __be32 *
7973 decode_sattr(__be32 *p, struct iattr *iap)
7981 @@ -110,12 +113,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7983 if ((tmp = ntohl(*p++)) != (u32)-1) {
7984 iap->ia_valid |= ATTR_UID;
7985 - iap->ia_uid = tmp;
7988 if ((tmp = ntohl(*p++)) != (u32)-1) {
7989 iap->ia_valid |= ATTR_GID;
7990 - iap->ia_gid = tmp;
7993 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7994 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7995 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7996 if ((tmp = ntohl(*p++)) != (u32)-1) {
7997 iap->ia_valid |= ATTR_SIZE;
7999 @@ -160,8 +166,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
8000 *p++ = htonl(nfs_ftypes[type >> 12]);
8001 *p++ = htonl((u32) stat->mode);
8002 *p++ = htonl((u32) stat->nlink);
8003 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
8004 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
8005 + *p++ = htonl((u32) nfsd_ruid(rqstp,
8006 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
8007 + *p++ = htonl((u32) nfsd_rgid(rqstp,
8008 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
8010 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
8011 *p++ = htonl(NFS_MAXPATHLEN);
8012 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
8013 --- linux-2.6.22.10/fs/nfsd/vfs.c 2007-10-30 01:57:14 +0100
8014 +++ linux-2.6.22.10-vs2.3.0.29/fs/nfsd/vfs.c 2007-08-11 22:41:51 +0200
8015 @@ -1186,13 +1186,13 @@ nfsd_create(struct svc_rqst *rqstp, stru
8016 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
8019 - host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
8020 + host_err = vfs_mkdir(dirp, dchild, iap->ia_mode, NULL);
8026 - host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
8027 + host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev, NULL);
8030 printk("nfsd: bad file type %o in nfsd_create\n", type);
8031 @@ -1466,11 +1466,13 @@ nfsd_symlink(struct svc_rqst *rqstp, str
8033 strncpy(path_alloced, path, plen);
8034 path_alloced[plen] = 0;
8035 - host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
8036 + host_err = vfs_symlink(dentry->d_inode, dnew,
8037 + path_alloced, mode, NULL);
8038 kfree(path_alloced);
8041 - host_err = vfs_symlink(dentry->d_inode, dnew, path, mode);
8042 + host_err = vfs_symlink(dentry->d_inode, dnew,
8043 + path, mode, NULL);
8046 if (EX_ISSYNC(fhp->fh_export))
8047 @@ -1529,7 +1531,7 @@ nfsd_link(struct svc_rqst *rqstp, struct
8048 dold = tfhp->fh_dentry;
8049 dest = dold->d_inode;
8051 - host_err = vfs_link(dold, dirp, dnew);
8052 + host_err = vfs_link(dold, dirp, dnew, NULL);
8054 if (EX_ISSYNC(ffhp->fh_export)) {
8055 err = nfserrno(nfsd_sync_dir(ddir));
8056 @@ -1694,9 +1696,9 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
8060 - host_err = vfs_unlink(dirp, rdentry);
8061 + host_err = vfs_unlink(dirp, rdentry, NULL);
8062 } else { /* It's RMDIR */
8063 - host_err = vfs_rmdir(dirp, rdentry);
8064 + host_err = vfs_rmdir(dirp, rdentry, NULL);
8068 @@ -1807,7 +1809,8 @@ nfsd_permission(struct svc_export *exp,
8070 if (!(acc & MAY_LOCAL_ACCESS))
8071 if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
8072 - if (EX_RDONLY(exp) || IS_RDONLY(inode))
8073 + if (EX_RDONLY(exp) || IS_RDONLY(inode)
8074 + || MNT_IS_RDONLY(exp->ex_mnt))
8076 if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
8078 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
8079 --- linux-2.6.22.10/fs/ocfs2/dlm/dlmfs.c 2007-07-09 13:19:28 +0200
8080 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlm/dlmfs.c 2007-08-05 20:53:13 +0200
8082 #include <linux/init.h>
8083 #include <linux/string.h>
8084 #include <linux/backing-dev.h>
8085 +#include <linux/vs_tag.h>
8087 #include <asm/uaccess.h>
8089 @@ -331,6 +332,7 @@ static struct inode *dlmfs_get_root_inod
8090 inode->i_mode = mode;
8091 inode->i_uid = current->fsuid;
8092 inode->i_gid = current->fsgid;
8093 + inode->i_tag = dx_current_fstag(sb);
8094 inode->i_blocks = 0;
8095 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
8096 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
8097 @@ -357,6 +359,7 @@ static struct inode *dlmfs_get_inode(str
8098 inode->i_mode = mode;
8099 inode->i_uid = current->fsuid;
8100 inode->i_gid = current->fsgid;
8101 + inode->i_tag = dx_current_fstag(sb);
8102 inode->i_blocks = 0;
8103 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
8104 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
8105 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
8106 --- linux-2.6.22.10/fs/ocfs2/dlmglue.c 2007-07-09 13:19:28 +0200
8107 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlmglue.c 2007-08-05 20:53:13 +0200
8108 @@ -1475,6 +1475,7 @@ static void __ocfs2_stuff_meta_lvb(struc
8109 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
8110 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
8111 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
8112 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
8113 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
8114 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
8115 lvb->lvb_iatime_packed =
8116 @@ -1527,6 +1528,7 @@ static void ocfs2_refresh_inode_from_lvb
8118 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
8119 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
8120 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
8121 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
8122 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
8123 ocfs2_unpack_timespec(&inode->i_atime,
8124 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
8125 --- linux-2.6.22.10/fs/ocfs2/dlmglue.h 2007-07-09 13:19:28 +0200
8126 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/dlmglue.h 2007-08-05 20:53:13 +0200
8128 struct ocfs2_meta_lvb {
8131 - __be16 lvb_reserved1;
8133 __be32 lvb_iclusters;
8136 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
8137 --- linux-2.6.22.10/fs/ocfs2/file.c 2007-10-30 01:57:14 +0100
8138 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/file.c 2007-09-05 03:06:11 +0200
8139 @@ -943,13 +943,15 @@ int ocfs2_setattr(struct dentry *dentry,
8140 mlog(0, "uid change: %d\n", attr->ia_uid);
8141 if (attr->ia_valid & ATTR_GID)
8142 mlog(0, "gid change: %d\n", attr->ia_gid);
8143 + if (attr->ia_valid & ATTR_TAG)
8144 + mlog(0, "tag change: %d\n", attr->ia_tag);
8145 if (attr->ia_valid & ATTR_SIZE)
8146 mlog(0, "size change...\n");
8147 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
8148 mlog(0, "time change...\n");
8150 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
8151 - | ATTR_GID | ATTR_UID | ATTR_MODE)
8152 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
8153 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
8154 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
8156 @@ -1805,6 +1807,7 @@ bail:
8157 const struct inode_operations ocfs2_file_iops = {
8158 .setattr = ocfs2_setattr,
8159 .getattr = ocfs2_getattr,
8160 + .sync_flags = ocfs2_sync_flags,
8161 .permission = ocfs2_permission,
8164 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
8165 --- linux-2.6.22.10/fs/ocfs2/inode.c 2007-07-09 13:19:28 +0200
8166 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/inode.c 2007-08-05 20:53:13 +0200
8168 #include <linux/slab.h>
8169 #include <linux/highmem.h>
8170 #include <linux/pagemap.h>
8171 +#include <linux/vs_tag.h>
8173 #include <asm/byteorder.h>
8177 #include "heartbeat.h"
8180 #include "journal.h"
8182 #include "suballoc.h"
8183 @@ -77,6 +79,10 @@ void ocfs2_set_inode_flags(struct inode
8185 if (flags & OCFS2_IMMUTABLE_FL)
8186 inode->i_flags |= S_IMMUTABLE;
8187 + if (flags & OCFS2_IUNLINK_FL)
8188 + inode->i_flags |= S_IUNLINK;
8189 + if (flags & OCFS2_BARRIER_FL)
8190 + inode->i_flags |= S_BARRIER;
8192 if (flags & OCFS2_SYNC_FL)
8193 inode->i_flags |= S_SYNC;
8194 @@ -107,6 +113,27 @@ void ocfs2_get_inode_flags(struct ocfs2_
8195 oi->ip_attr |= OCFS2_DIRSYNC_FL;
8198 +int ocfs2_sync_flags(struct inode *inode)
8200 + unsigned int oldflags, newflags;
8202 + oldflags = OCFS2_I(inode)->ip_flags;
8203 + newflags = oldflags & ~(OCFS2_IMMUTABLE_FL |
8204 + OCFS2_IUNLINK_FL | OCFS2_BARRIER_FL);
8206 + if (IS_IMMUTABLE(inode))
8207 + newflags |= OCFS2_IMMUTABLE_FL;
8208 + if (IS_IUNLINK(inode))
8209 + newflags |= OCFS2_IUNLINK_FL;
8210 + if (IS_BARRIER(inode))
8211 + newflags |= OCFS2_BARRIER_FL;
8213 + if (oldflags ^ newflags)
8214 + return ocfs2_set_inode_attr(inode,
8215 + newflags, OCFS2_FL_MASK);
8219 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags)
8221 struct inode *inode = NULL;
8222 @@ -212,6 +239,8 @@ int ocfs2_populate_inode(struct inode *i
8223 struct super_block *sb;
8224 struct ocfs2_super *osb;
8225 int status = -EINVAL;
8229 mlog_entry("(0x%p, size:%llu)\n", inode,
8230 (unsigned long long)le64_to_cpu(fe->i_size));
8231 @@ -246,8 +275,12 @@ int ocfs2_populate_inode(struct inode *i
8232 inode->i_generation = le32_to_cpu(fe->i_generation);
8233 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
8234 inode->i_mode = le16_to_cpu(fe->i_mode);
8235 - inode->i_uid = le32_to_cpu(fe->i_uid);
8236 - inode->i_gid = le32_to_cpu(fe->i_gid);
8237 + uid = le32_to_cpu(fe->i_uid);
8238 + gid = le32_to_cpu(fe->i_gid);
8239 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8240 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8241 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8242 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8244 /* Fast symlinks will have i_size but no allocated clusters. */
8245 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
8246 @@ -1224,8 +1257,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
8248 fe->i_size = cpu_to_le64(i_size_read(inode));
8249 fe->i_links_count = cpu_to_le16(inode->i_nlink);
8250 - fe->i_uid = cpu_to_le32(inode->i_uid);
8251 - fe->i_gid = cpu_to_le32(inode->i_gid);
8252 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
8253 + inode->i_uid, inode->i_tag));
8254 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
8255 + inode->i_gid, inode->i_tag));
8256 + /* i_tag = = cpu_to_le16(inode->i_tag); */
8257 fe->i_mode = cpu_to_le16(inode->i_mode);
8258 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
8259 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
8260 @@ -1253,15 +1289,24 @@ leave:
8261 void ocfs2_refresh_inode(struct inode *inode,
8262 struct ocfs2_dinode *fe)
8267 spin_lock(&OCFS2_I(inode)->ip_lock);
8269 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
8270 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
8271 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
8272 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
8273 ocfs2_set_inode_flags(inode);
8274 i_size_write(inode, le64_to_cpu(fe->i_size));
8275 inode->i_nlink = le16_to_cpu(fe->i_links_count);
8276 - inode->i_uid = le32_to_cpu(fe->i_uid);
8277 - inode->i_gid = le32_to_cpu(fe->i_gid);
8278 + uid = le32_to_cpu(fe->i_uid);
8279 + gid = le32_to_cpu(fe->i_gid);
8280 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8281 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8282 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8283 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8284 inode->i_mode = le16_to_cpu(fe->i_mode);
8285 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
8286 inode->i_blocks = 0;
8287 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
8288 --- linux-2.6.22.10/fs/ocfs2/inode.h 2007-07-09 13:19:28 +0200
8289 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/inode.h 2007-08-05 20:53:13 +0200
8290 @@ -142,6 +142,7 @@ int ocfs2_aio_write(struct file *file, s
8292 void ocfs2_set_inode_flags(struct inode *inode);
8293 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
8294 +int ocfs2_sync_flags(struct inode *inode);
8296 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
8298 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
8299 --- linux-2.6.22.10/fs/ocfs2/ioctl.c 2007-07-09 13:19:28 +0200
8300 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ioctl.c 2007-08-05 20:53:13 +0200
8301 @@ -39,7 +39,8 @@ static int ocfs2_get_inode_attr(struct i
8305 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8306 +/* Called with inode->i_mutex locked */
8307 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8310 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
8311 @@ -49,8 +50,6 @@ static int ocfs2_set_inode_attr(struct i
8315 - mutex_lock(&inode->i_mutex);
8317 status = ocfs2_meta_lock(inode, &bh, 1);
8320 @@ -101,8 +100,6 @@ static int ocfs2_set_inode_attr(struct i
8322 ocfs2_meta_unlock(inode, 1);
8324 - mutex_unlock(&inode->i_mutex);
8329 @@ -110,6 +107,16 @@ bail:
8333 +static inline int ocfs2_set_inode_attr_lock(struct inode *inode,
8334 + unsigned flags, unsigned mask)
8337 + mutex_lock(&inode->i_mutex);
8338 + ret = ocfs2_set_inode_attr(inode, flags, mask);
8339 + mutex_unlock(&inode->i_mutex);
8343 int ocfs2_ioctl(struct inode * inode, struct file * filp,
8344 unsigned int cmd, unsigned long arg)
8346 @@ -128,7 +135,7 @@ int ocfs2_ioctl(struct inode * inode, st
8347 if (get_user(flags, (int __user *) arg))
8350 - return ocfs2_set_inode_attr(inode, flags,
8351 + return ocfs2_set_inode_attr_lock(inode, flags,
8352 OCFS2_FL_MODIFIABLE);
8355 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
8356 --- linux-2.6.22.10/fs/ocfs2/ioctl.h 2007-07-09 13:19:28 +0200
8357 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ioctl.h 2007-08-05 20:53:13 +0200
8359 #ifndef OCFS2_IOCTL_H
8360 #define OCFS2_IOCTL_H
8362 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8365 int ocfs2_ioctl(struct inode * inode, struct file * filp,
8366 unsigned int cmd, unsigned long arg);
8367 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
8368 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
8369 --- linux-2.6.22.10/fs/ocfs2/namei.c 2007-07-09 13:19:28 +0200
8370 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/namei.c 2007-08-05 20:53:13 +0200
8372 #include <linux/types.h>
8373 #include <linux/slab.h>
8374 #include <linux/highmem.h>
8375 +#include <linux/vs_tag.h>
8377 #define MLOG_MASK_PREFIX ML_NAMEI
8378 #include <cluster/masklog.h>
8379 @@ -483,6 +484,9 @@ static int ocfs2_mknod_locked(struct ocf
8382 struct inode *inode = NULL;
8387 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
8388 (unsigned long)dev, dentry->d_name.len,
8389 @@ -542,13 +546,19 @@ static int ocfs2_mknod_locked(struct ocf
8390 fe->i_blkno = cpu_to_le64(fe_blkno);
8391 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
8392 fe->i_suballoc_slot = cpu_to_le16(osb->slot_num);
8393 - fe->i_uid = cpu_to_le32(current->fsuid);
8395 + tag = dx_current_fstag(osb->sb);
8396 + uid = current->fsuid;
8397 if (dir->i_mode & S_ISGID) {
8398 - fe->i_gid = cpu_to_le32(dir->i_gid);
8403 - fe->i_gid = cpu_to_le32(current->fsgid);
8404 + gid = current->fsgid;
8406 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
8407 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
8408 + inode->i_tag = tag;
8409 fe->i_mode = cpu_to_le16(mode);
8410 if (S_ISCHR(mode) || S_ISBLK(mode))
8411 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
8412 @@ -2316,5 +2326,6 @@ const struct inode_operations ocfs2_dir_
8413 .rename = ocfs2_rename,
8414 .setattr = ocfs2_setattr,
8415 .getattr = ocfs2_getattr,
8416 + .sync_flags = ocfs2_sync_flags,
8417 .permission = ocfs2_permission,
8419 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
8420 --- linux-2.6.22.10/fs/ocfs2/ocfs2.h 2007-07-09 13:19:28 +0200
8421 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ocfs2.h 2007-08-05 20:53:13 +0200
8422 @@ -170,6 +170,7 @@ enum ocfs2_mount_options
8423 OCFS2_MOUNT_NOINTR = 1 << 2, /* Don't catch signals */
8424 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
8425 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
8426 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
8429 #define OCFS2_OSB_SOFT_RO 0x0001
8430 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
8431 --- linux-2.6.22.10/fs/ocfs2/ocfs2_fs.h 2007-07-09 13:19:28 +0200
8432 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/ocfs2_fs.h 2007-08-05 20:53:13 +0200
8433 @@ -152,8 +152,12 @@
8434 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
8435 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
8437 +#define OCFS2_BARRIER_FL (0x04000000) /* Barrier for chroot() */
8438 +#define OCFS2_IUNLINK_FL (0x08000000) /* Immutable unlink */
8440 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
8441 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
8442 +#define OCFS2_FL_MASK (0x0F0100FF)
8445 * Extent record flags (e_node.leaf.flags)
8446 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
8447 --- linux-2.6.22.10/fs/ocfs2/super.c 2007-07-09 13:19:28 +0200
8448 +++ linux-2.6.22.10-vs2.3.0.29/fs/ocfs2/super.c 2007-08-05 20:53:13 +0200
8449 @@ -140,6 +140,7 @@ enum {
8453 + Opt_tag, Opt_notag, Opt_tagid,
8457 @@ -154,6 +155,9 @@ static match_table_t tokens = {
8458 {Opt_data_ordered, "data=ordered"},
8459 {Opt_data_writeback, "data=writeback"},
8460 {Opt_atime_quantum, "atime_quantum=%u"},
8462 + {Opt_notag, "notag"},
8463 + {Opt_tagid, "tagid=%u"},
8467 @@ -362,6 +366,13 @@ static int ocfs2_remount(struct super_bl
8471 + if ((parsed_options & OCFS2_MOUNT_TAGGED) &&
8472 + !(sb->s_flags & MS_TAGGED)) {
8474 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
8478 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
8479 (parsed_options & OCFS2_MOUNT_HB_LOCAL)) {
8481 @@ -654,6 +665,9 @@ static int ocfs2_fill_super(struct super
8483 ocfs2_complete_mount_recovery(osb);
8485 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
8486 + sb->s_flags |= MS_TAGGED;
8488 if (ocfs2_mount_local(osb))
8489 snprintf(nodestr, sizeof(nodestr), "local");
8491 @@ -782,6 +796,20 @@ static int ocfs2_parse_options(struct su
8493 osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
8495 +#ifndef CONFIG_TAGGING_NONE
8497 + *mount_opt |= OCFS2_MOUNT_TAGGED;
8500 + *mount_opt &= ~OCFS2_MOUNT_TAGGED;
8503 +#ifdef CONFIG_PROPAGATE
8506 + *mount_opt |= OCFS2_MOUNT_TAGGED;
8511 "Unrecognized mount option \"%s\" "
8512 diff -NurpP --minimal linux-2.6.22.10/fs/open.c linux-2.6.22.10-vs2.3.0.29/fs/open.c
8513 --- linux-2.6.22.10/fs/open.c 2007-07-09 13:19:28 +0200
8514 +++ linux-2.6.22.10-vs2.3.0.29/fs/open.c 2007-08-05 20:53:13 +0200
8516 #include <linux/syscalls.h>
8517 #include <linux/rcupdate.h>
8518 #include <linux/audit.h>
8519 +#include <linux/vs_base.h>
8520 +#include <linux/vs_limit.h>
8521 +#include <linux/vs_dlimit.h>
8522 +#include <linux/vs_tag.h>
8523 +#include <linux/vs_cowbl.h>
8525 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
8527 int retval = -ENODEV;
8530 + struct super_block *sb = dentry->d_sb;
8533 - if (dentry->d_sb->s_op->statfs) {
8534 + if (sb->s_op->statfs) {
8535 memset(buf, 0, sizeof(*buf));
8536 retval = security_sb_statfs(dentry);
8539 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
8540 + retval = sb->s_op->statfs(dentry, buf);
8541 if (retval == 0 && buf->f_frsize == 0)
8542 buf->f_frsize = buf->f_bsize;
8544 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
8545 + vx_vsi_statfs(sb, buf);
8549 @@ -248,7 +257,7 @@ static long do_sys_truncate(const char _
8553 - if (IS_RDONLY(inode))
8554 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
8558 @@ -397,7 +406,7 @@ asmlinkage long sys_faccessat(int dfd, c
8559 special_file(nd.dentry->d_inode->i_mode))
8560 goto out_path_release;
8562 - if(IS_RDONLY(nd.dentry->d_inode))
8563 + if(IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
8567 @@ -511,7 +520,7 @@ asmlinkage long sys_fchmod(unsigned int
8568 audit_inode(NULL, inode);
8571 - if (IS_RDONLY(inode))
8572 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
8575 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8576 @@ -541,11 +550,11 @@ asmlinkage long sys_fchmodat(int dfd, co
8577 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
8580 - inode = nd.dentry->d_inode;
8583 - if (IS_RDONLY(inode))
8584 + error = cow_check_and_break(&nd);
8587 + inode = nd.dentry->d_inode;
8590 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8591 @@ -570,7 +579,8 @@ asmlinkage long sys_chmod(const char __u
8592 return sys_fchmodat(AT_FDCWD, filename, mode);
8595 -static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
8596 +static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
8597 + uid_t user, gid_t group)
8599 struct inode * inode;
8601 @@ -582,7 +592,7 @@ static int chown_common(struct dentry *
8605 - if (IS_RDONLY(inode))
8606 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
8609 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
8610 @@ -590,11 +600,11 @@ static int chown_common(struct dentry *
8611 newattrs.ia_valid = ATTR_CTIME;
8612 if (user != (uid_t) -1) {
8613 newattrs.ia_valid |= ATTR_UID;
8614 - newattrs.ia_uid = user;
8615 + newattrs.ia_uid = dx_map_uid(user);
8617 if (group != (gid_t) -1) {
8618 newattrs.ia_valid |= ATTR_GID;
8619 - newattrs.ia_gid = group;
8620 + newattrs.ia_gid = dx_map_gid(group);
8622 if (!S_ISDIR(inode->i_mode))
8623 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
8624 @@ -613,7 +623,11 @@ asmlinkage long sys_chown(const char __u
8625 error = user_path_walk(filename, &nd);
8628 - error = chown_common(nd.dentry, user, group);
8629 +#ifdef CONFIG_VSERVER_COWBL
8630 + error = cow_check_and_break(&nd);
8633 + error = chown_common(nd.dentry, nd.mnt, user, group);
8637 @@ -633,7 +647,11 @@ asmlinkage long sys_fchownat(int dfd, co
8638 error = __user_walk_fd(dfd, filename, follow, &nd);
8641 - error = chown_common(nd.dentry, user, group);
8642 +#ifdef CONFIG_VSERVER_COWBL
8643 + error = cow_check_and_break(&nd);
8646 + error = chown_common(nd.dentry, nd.mnt, user, group);
8650 @@ -647,7 +665,11 @@ asmlinkage long sys_lchown(const char __
8651 error = user_path_walk_link(filename, &nd);
8654 - error = chown_common(nd.dentry, user, group);
8655 +#ifdef CONFIG_VSERVER_COWBL
8656 + error = cow_check_and_break(&nd);
8659 + error = chown_common(nd.dentry, nd.mnt, user, group);
8663 @@ -666,7 +688,7 @@ asmlinkage long sys_fchown(unsigned int
8665 dentry = file->f_path.dentry;
8666 audit_inode(NULL, dentry->d_inode);
8667 - error = chown_common(dentry, user, group);
8668 + error = chown_common(dentry, file->f_vfsmnt, user, group);
8672 @@ -893,6 +915,7 @@ repeat:
8673 FD_SET(fd, fdt->open_fds);
8674 FD_CLR(fd, fdt->close_on_exec);
8675 files->next_fd = fd + 1;
8676 + vx_openfd_inc(fd);
8679 if (fdt->fd[fd] != NULL) {
8680 @@ -915,6 +938,7 @@ static void __put_unused_fd(struct files
8681 __FD_CLR(fd, fdt->open_fds);
8682 if (fd < files->next_fd)
8683 files->next_fd = fd;
8684 + vx_openfd_dec(fd);
8687 void fastcall put_unused_fd(unsigned int fd)
8688 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
8689 --- linux-2.6.22.10/fs/proc/array.c 2007-07-09 13:19:28 +0200
8690 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/array.c 2007-10-05 15:07:22 +0200
8692 #include <linux/cpuset.h>
8693 #include <linux/rcupdate.h>
8694 #include <linux/delayacct.h>
8695 +#include <linux/vs_context.h>
8696 +#include <linux/vs_network.h>
8698 #include <asm/uaccess.h>
8699 #include <asm/pgtable.h>
8700 @@ -134,8 +136,9 @@ static const char *task_state_array[] =
8701 "D (disk sleep)", /* 2 */
8702 "T (stopped)", /* 4 */
8703 "T (tracing stop)", /* 8 */
8704 - "Z (zombie)", /* 16 */
8705 - "X (dead)" /* 32 */
8706 + "H (on hold)", /* 16 */
8707 + "Z (zombie)", /* 32 */
8708 + "X (dead)", /* 64 */
8711 static inline const char * get_task_state(struct task_struct *tsk)
8712 @@ -144,7 +147,8 @@ static inline const char * get_task_stat
8713 TASK_INTERRUPTIBLE |
8714 TASK_UNINTERRUPTIBLE |
8719 (tsk->exit_state & (EXIT_ZOMBIE |
8721 const char **p = &task_state_array[0];
8722 @@ -161,8 +165,16 @@ static inline char * task_state(struct t
8723 struct group_info *group_info;
8725 struct fdtable *fdt = NULL;
8726 + pid_t pid, ptgid, tppid, tgid;
8729 + tgid = vx_map_tgid(p->tgid);
8730 + pid = vx_map_pid(p->pid);
8731 + ptgid = vx_map_pid(pid_alive(p) ?
8732 + rcu_dereference(p->real_parent)->tgid : 0);
8733 + tppid = vx_map_pid(pid_alive(p) && p->ptrace ?
8734 + rcu_dereference(p->parent)->pid : 0);
8736 buffer += sprintf(buffer,
8738 "SleepAVG:\t%lu%%\n"
8739 @@ -174,9 +186,7 @@ static inline char * task_state(struct t
8740 "Gid:\t%d\t%d\t%d\t%d\n",
8742 (p->sleep_avg/1024)*100/(1020000000/1024),
8744 - pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0,
8745 - pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0,
8746 + tgid, pid, (pid > 1) ? ptgid : 0, tppid,
8747 p->uid, p->euid, p->suid, p->fsuid,
8748 p->gid, p->egid, p->sgid, p->fsgid);
8750 @@ -283,12 +293,15 @@ static inline char * task_sig(struct tas
8752 static inline char *task_cap(struct task_struct *p, char *buffer)
8754 - return buffer + sprintf(buffer, "CapInh:\t%016x\n"
8755 - "CapPrm:\t%016x\n"
8756 - "CapEff:\t%016x\n",
8757 - cap_t(p->cap_inheritable),
8758 - cap_t(p->cap_permitted),
8759 - cap_t(p->cap_effective));
8760 + struct vx_info *vxi = p->vx_info;
8762 + return buffer + sprintf(buffer,
8763 + "CapInh:\t%016x\n"
8764 + "CapPrm:\t%016x\n"
8765 + "CapEff:\t%016x\n",
8766 + (unsigned)vx_info_mbcap(vxi, p->cap_inheritable),
8767 + (unsigned)vx_info_mbcap(vxi, p->cap_permitted),
8768 + (unsigned)vx_info_mbcap(vxi, p->cap_effective));
8771 int proc_pid_status(struct task_struct *task, char * buffer)
8772 @@ -306,6 +319,12 @@ int proc_pid_status(struct task_struct *
8773 buffer = task_sig(task, buffer);
8774 buffer = task_cap(task, buffer);
8775 buffer = cpuset_task_status_allowed(task, buffer);
8777 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8779 + buffer += sprintf (buffer,"VxID: %d\n", vx_task_xid(task));
8780 + buffer += sprintf (buffer,"NxID: %d\n", nx_task_nid(task));
8782 #if defined(CONFIG_S390)
8783 buffer = task_show_regs(task, buffer);
8785 @@ -320,7 +339,7 @@ static int do_task_stat(struct task_stru
8786 sigset_t sigign, sigcatch;
8789 - pid_t ppid = 0, pgid = -1, sid = -1;
8790 + pid_t pid = 0, ppid = 0, pgid = -1, sid = -1;
8791 int num_threads = 0;
8792 struct mm_struct *mm;
8793 unsigned long long start_time;
8794 @@ -382,8 +401,10 @@ static int do_task_stat(struct task_stru
8797 sid = signal_session(sig);
8798 - pgid = process_group(task);
8799 - ppid = rcu_dereference(task->real_parent)->tgid;
8800 + pid = vx_info_map_pid(task->vx_info, task->pid);
8801 + pgid = vx_info_map_pid(task->vx_info, process_group(task));
8802 + ppid = (pid > 1) ? vx_info_map_tgid(task->vx_info,
8803 + rcu_dereference(task->real_parent)->tgid) : 0;
8805 unlock_task_sighand(task, &flags);
8807 @@ -410,10 +431,21 @@ static int do_task_stat(struct task_stru
8808 /* convert nsec -> ticks */
8809 start_time = nsec_to_clock_t(start_time);
8811 + /* fixup start time for virt uptime */
8812 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8813 + unsigned long long bias =
8814 + current->vx_info->cvirt.bias_clock;
8816 + if (start_time > bias)
8817 + start_time -= bias;
8822 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %u %lu \
8823 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8824 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n",
8830 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
8831 --- linux-2.6.22.10/fs/proc/base.c 2007-07-09 13:19:28 +0200
8832 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/base.c 2007-09-05 02:49:29 +0200
8834 #include <linux/poll.h>
8835 #include <linux/nsproxy.h>
8836 #include <linux/oom.h>
8837 +#include <linux/vs_context.h>
8838 +#include <linux/vs_network.h>
8840 #include "internal.h"
8843 @@ -1049,6 +1052,8 @@ static struct inode *proc_pid_make_inode
8844 inode->i_uid = task->euid;
8845 inode->i_gid = task->egid;
8847 + /* procfs is xid tagged */
8848 + inode->i_tag = (tag_t)vx_task_xid(task);
8849 security_task_to_inode(task, inode);
8852 @@ -1082,6 +1087,8 @@ static int pid_getattr(struct vfsmount *
8856 +static unsigned name_to_int(struct dentry *dentry);
8859 * Exceptional case: normally we are not allowed to unhash a busy
8860 * directory. In this case, however, we can do it - no aliasing problems
8861 @@ -1102,6 +1109,12 @@ static int pid_revalidate(struct dentry
8862 struct inode *inode = dentry->d_inode;
8863 struct task_struct *task = get_proc_task(inode);
8865 + unsigned pid = name_to_int(dentry);
8866 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
8867 + put_task_struct(task);
8871 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
8872 task_dumpable(task)) {
8873 inode->i_uid = task->euid;
8874 @@ -1115,6 +1128,7 @@ static int pid_revalidate(struct dentry
8875 put_task_struct(task);
8882 @@ -1595,6 +1609,13 @@ static struct dentry *proc_pident_lookup
8886 + /* TODO: maybe we can come up with a generic approach? */
8887 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8888 + (dentry->d_name.len == 5) &&
8889 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8890 + !memcmp(dentry->d_name.name, "ninfo", 5)))
8894 * Yes, it does not scale. And it should not. Don't add
8895 * new entries into /proc/<tgid>/ without very good reasons.
8896 @@ -1790,14 +1811,14 @@ static int proc_self_readlink(struct den
8899 char tmp[PROC_NUMBUF];
8900 - sprintf(tmp, "%d", current->tgid);
8901 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8902 return vfs_readlink(dentry,buffer,buflen,tmp);
8905 static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
8907 char tmp[PROC_NUMBUF];
8908 - sprintf(tmp, "%d", current->tgid);
8909 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
8910 return ERR_PTR(vfs_follow_link(nd,tmp));
8913 @@ -1891,7 +1912,7 @@ out_iput:
8914 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8916 struct dentry *error;
8917 - struct task_struct *task = get_proc_task(dir);
8918 + struct task_struct *task = get_proc_task_real(dir);
8919 const struct pid_entry *p, *last;
8921 error = ERR_PTR(-ENOENT);
8922 @@ -1956,6 +1977,9 @@ static int proc_pid_io_accounting(struct
8923 static const struct file_operations proc_task_operations;
8924 static const struct inode_operations proc_task_inode_operations;
8926 +extern int proc_pid_vx_info(struct task_struct *, char *);
8927 +extern int proc_pid_nx_info(struct task_struct *, char *);
8929 static const struct pid_entry tgid_base_stuff[] = {
8930 DIR("task", S_IRUGO|S_IXUGO, task),
8931 DIR("fd", S_IRUSR|S_IXUSR, fd),
8932 @@ -1995,6 +2019,8 @@ static const struct pid_entry tgid_base_
8933 #ifdef CONFIG_CPUSETS
8934 REG("cpuset", S_IRUGO, cpuset),
8936 + INF("vinfo", S_IRUGO, pid_vx_info),
8937 + INF("ninfo", S_IRUGO, pid_nx_info),
8938 INF("oom_score", S_IRUGO, oom_score),
8939 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
8940 #ifdef CONFIG_AUDITSYSCALL
8941 @@ -2141,9 +2167,11 @@ struct dentry *proc_pid_lookup(struct in
8942 tgid = name_to_int(dentry);
8945 + if (vx_current_initpid(tgid))
8949 - task = find_task_by_pid(tgid);
8950 + task = vx_find_proc_task_by_pid(tgid);
8952 get_task_struct(task);
8954 @@ -2198,7 +2226,7 @@ static int proc_pid_fill_cache(struct fi
8955 struct task_struct *task, int tgid)
8957 char name[PROC_NUMBUF];
8958 - int len = snprintf(name, sizeof(name), "%d", tgid);
8959 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(tgid));
8960 return proc_fill_cache(filp, dirent, filldir, name, len,
8961 proc_pid_instantiate, task, NULL);
8963 @@ -2207,7 +2235,7 @@ static int proc_pid_fill_cache(struct fi
8964 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8966 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8967 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8968 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8969 struct task_struct *task;
8972 @@ -2226,6 +2254,8 @@ int proc_pid_readdir(struct file * filp,
8973 put_task_struct(task), task = next_tgid(tgid + 1)) {
8975 filp->f_pos = tgid + TGID_OFFSET;
8976 + if (!vx_proc_task_visible(task))
8978 if (proc_pid_fill_cache(filp, dirent, filldir, task, tgid) < 0) {
8979 put_task_struct(task);
8981 @@ -2352,9 +2382,11 @@ static struct dentry *proc_task_lookup(s
8982 tid = name_to_int(dentry);
8985 + if (vx_current_initpid(tid))
8989 - task = find_task_by_pid(tid);
8990 + task = vx_find_proc_task_by_pid(tid);
8992 get_task_struct(task);
8994 @@ -2499,7 +2531,7 @@ static int proc_task_readdir(struct file
8995 for (task = first_tid(leader, tid, pos - 2);
8997 task = next_tid(task), pos++) {
8999 + tid = vx_map_pid(task->pid);
9000 if (proc_task_fill_cache(filp, dirent, filldir, task, tid) < 0) {
9001 /* returning this tgid failed, save it as the first
9002 * pid for the next readir call */
9003 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
9004 --- linux-2.6.22.10/fs/proc/generic.c 2007-07-09 13:19:28 +0200
9005 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/generic.c 2007-08-05 20:53:13 +0200
9007 #include <linux/namei.h>
9008 #include <linux/bitops.h>
9009 #include <linux/spinlock.h>
9010 +#include <linux/vserver/inode.h>
9011 #include <asm/uaccess.h>
9013 #include "internal.h"
9014 @@ -395,6 +396,8 @@ struct dentry *proc_lookup(struct inode
9015 for (de = de->subdir; de ; de = de->next) {
9016 if (de->namelen != dentry->d_name.len)
9018 + if (!vx_hide_check(0, de->vx_flags))
9020 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
9021 unsigned int ino = de->low_ino;
9023 @@ -402,6 +405,8 @@ struct dentry *proc_lookup(struct inode
9024 spin_unlock(&proc_subdir_lock);
9026 inode = proc_get_inode(dir->i_sb, ino, de);
9027 + /* generic proc entries belong to the host */
9029 spin_lock(&proc_subdir_lock);
9032 @@ -482,6 +487,8 @@ int proc_readdir(struct file * filp,
9034 /* filldir passes info to user space */
9036 + if (!vx_hide_check(0, de->vx_flags))
9038 spin_unlock(&proc_subdir_lock);
9039 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
9040 de->low_ino, de->mode >> 12) < 0) {
9041 @@ -489,6 +496,7 @@ int proc_readdir(struct file * filp,
9044 spin_lock(&proc_subdir_lock);
9049 @@ -613,6 +621,7 @@ static struct proc_dir_entry *proc_creat
9053 + ent->vx_flags = IATTR_PROC_DEFAULT;
9057 @@ -633,7 +642,8 @@ struct proc_dir_entry *proc_symlink(cons
9063 + ent->vx_flags = IATTR_PROC_SYMLINK;
9067 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
9068 --- linux-2.6.22.10/fs/proc/inode.c 2007-07-09 13:19:28 +0200
9069 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/inode.c 2007-08-05 20:53:13 +0200
9070 @@ -160,6 +160,8 @@ struct inode *proc_get_inode(struct supe
9071 inode->i_uid = de->uid;
9072 inode->i_gid = de->gid;
9075 + PROC_I(inode)->vx_flags = de->vx_flags;
9077 inode->i_size = de->size;
9079 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
9080 --- linux-2.6.22.10/fs/proc/internal.h 2007-07-09 13:19:28 +0200
9081 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/internal.h 2007-08-05 20:53:13 +0200
9085 #include <linux/proc_fs.h>
9086 +#include <linux/vs_pid.h>
9088 #ifdef CONFIG_PROC_SYSCTL
9089 extern int proc_sys_init(void);
9090 @@ -64,11 +65,16 @@ static inline struct pid *proc_pid(struc
9091 return PROC_I(inode)->pid;
9094 -static inline struct task_struct *get_proc_task(struct inode *inode)
9095 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
9097 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
9100 +static inline struct task_struct *get_proc_task(struct inode *inode)
9102 + return vx_get_proc_task(inode, proc_pid(inode));
9105 static inline int proc_fd(struct inode *inode)
9107 return PROC_I(inode)->fd;
9108 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
9109 --- linux-2.6.22.10/fs/proc/proc_misc.c 2007-07-09 13:19:28 +0200
9110 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/proc_misc.c 2007-08-05 20:53:13 +0200
9112 #include <asm/div64.h>
9113 #include "internal.h"
9115 +#include <linux/vs_cvirt.h>
9117 #define LOAD_INT(x) ((x) >> FSHIFT)
9118 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
9120 @@ -82,17 +84,32 @@ static int proc_calc_metrics(char *page,
9121 static int loadavg_read_proc(char *page, char **start, off_t off,
9122 int count, int *eof, void *data)
9124 + unsigned int running, threads;
9128 - a = avenrun[0] + (FIXED_1/200);
9129 - b = avenrun[1] + (FIXED_1/200);
9130 - c = avenrun[2] + (FIXED_1/200);
9131 - len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
9132 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
9133 + struct vx_info *vxi = current->vx_info;
9135 + a = vxi->cvirt.load[0] + (FIXED_1/200);
9136 + b = vxi->cvirt.load[1] + (FIXED_1/200);
9137 + c = vxi->cvirt.load[2] + (FIXED_1/200);
9139 + running = atomic_read(&vxi->cvirt.nr_running);
9140 + threads = atomic_read(&vxi->cvirt.nr_threads);
9142 + a = avenrun[0] + (FIXED_1/200);
9143 + b = avenrun[1] + (FIXED_1/200);
9144 + c = avenrun[2] + (FIXED_1/200);
9146 + running = nr_running();
9147 + threads = nr_threads;
9149 + len = sprintf(page,"%d.%02d %d.%02d %d.%02d %d/%d %d\n",
9150 LOAD_INT(a), LOAD_FRAC(a),
9151 LOAD_INT(b), LOAD_FRAC(b),
9152 LOAD_INT(c), LOAD_FRAC(c),
9153 - nr_running(), nr_threads, current->nsproxy->pid_ns->last_pid);
9154 + running, threads, current->nsproxy->pid_ns->last_pid);
9155 return proc_calc_metrics(page, start, off, count, eof, len);
9158 @@ -106,6 +123,9 @@ static int uptime_read_proc(char *page,
9160 do_posix_clock_monotonic_gettime(&uptime);
9161 cputime_to_timespec(idletime, &idle);
9162 + if (vx_flags(VXF_VIRT_UPTIME, 0))
9163 + vx_vsi_uptime(&uptime, &idle);
9165 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
9166 (unsigned long) uptime.tv_sec,
9167 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
9168 @@ -137,7 +157,7 @@ static int meminfo_read_proc(char *page,
9170 cached = global_page_state(NR_FILE_PAGES) -
9171 total_swapcache_pages - i.bufferram;
9173 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
9176 get_vmalloc_info(&vmi);
9177 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
9178 --- linux-2.6.22.10/fs/proc/root.c 2007-05-02 19:25:21 +0200
9179 +++ linux-2.6.22.10-vs2.3.0.29/fs/proc/root.c 2007-08-05 20:53:13 +0200
9181 #include "internal.h"
9183 struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
9184 +struct proc_dir_entry *proc_virtual;
9186 +extern void proc_vx_init(void);
9188 static int proc_get_sb(struct file_system_type *fs_type,
9189 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
9190 @@ -79,6 +82,7 @@ void __init proc_root_init(void)
9191 proc_device_tree_init();
9193 proc_bus = proc_mkdir("bus", NULL);
9198 diff -NurpP --minimal linux-2.6.22.10/fs/quota.c linux-2.6.22.10-vs2.3.0.29/fs/quota.c
9199 --- linux-2.6.22.10/fs/quota.c 2007-07-09 13:19:28 +0200
9200 +++ linux-2.6.22.10-vs2.3.0.29/fs/quota.c 2007-08-05 20:53:13 +0200
9202 #include <linux/buffer_head.h>
9203 #include <linux/capability.h>
9204 #include <linux/quotaops.h>
9205 +#include <linux/vs_context.h>
9207 /* Check validity of generic quotactl commands */
9208 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
9209 @@ -80,11 +81,11 @@ static int generic_quotactl_valid(struct
9210 if (cmd == Q_GETQUOTA) {
9211 if (((type == USRQUOTA && current->euid != id) ||
9212 (type == GRPQUOTA && !in_egroup_p(id))) &&
9213 - !capable(CAP_SYS_ADMIN))
9214 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9217 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
9218 - if (!capable(CAP_SYS_ADMIN))
9219 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9223 @@ -131,10 +132,10 @@ static int xqm_quotactl_valid(struct sup
9224 if (cmd == Q_XGETQUOTA) {
9225 if (((type == XQM_USRQUOTA && current->euid != id) ||
9226 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
9227 - !capable(CAP_SYS_ADMIN))
9228 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9230 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
9231 - if (!capable(CAP_SYS_ADMIN))
9232 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9236 @@ -327,6 +328,46 @@ static int do_quotactl(struct super_bloc
9240 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
9242 +#include <linux/vroot.h>
9243 +#include <linux/major.h>
9244 +#include <linux/module.h>
9245 +#include <linux/kallsyms.h>
9246 +#include <linux/vserver/debug.h>
9248 +static vroot_grb_func *vroot_get_real_bdev = NULL;
9250 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
9252 +int register_vroot_grb(vroot_grb_func *func) {
9255 + spin_lock(&vroot_grb_lock);
9256 + if (!vroot_get_real_bdev) {
9257 + vroot_get_real_bdev = func;
9260 + spin_unlock(&vroot_grb_lock);
9263 +EXPORT_SYMBOL(register_vroot_grb);
9265 +int unregister_vroot_grb(vroot_grb_func *func) {
9266 + int ret = -EINVAL;
9268 + spin_lock(&vroot_grb_lock);
9269 + if (vroot_get_real_bdev) {
9270 + vroot_get_real_bdev = NULL;
9273 + spin_unlock(&vroot_grb_lock);
9276 +EXPORT_SYMBOL(unregister_vroot_grb);
9281 * look up a superblock on which quota ops will be performed
9282 * - use the name of a block device to find the superblock thereon
9283 @@ -344,6 +385,22 @@ static inline struct super_block *quotac
9286 return ERR_PTR(PTR_ERR(bdev));
9287 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
9288 + if (bdev && bdev->bd_inode &&
9289 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
9290 + struct block_device *bdnew = (void *)-EINVAL;
9292 + if (vroot_get_real_bdev)
9293 + bdnew = vroot_get_real_bdev(bdev);
9295 + vxdprintk(VXD_CBIT(misc, 0),
9296 + "vroot_get_real_bdev not set");
9298 + if (IS_ERR(bdnew))
9299 + return ERR_PTR(PTR_ERR(bdnew));
9303 sb = get_super(bdev);
9306 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
9307 --- linux-2.6.22.10/fs/reiserfs/bitmap.c 2007-02-06 03:01:29 +0100
9308 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/bitmap.c 2007-10-05 15:07:22 +0200
9310 #include <linux/reiserfs_fs_sb.h>
9311 #include <linux/reiserfs_fs_i.h>
9312 #include <linux/quotaops.h>
9313 +#include <linux/vs_dlimit.h>
9315 #define PREALLOCATION_SIZE 9
9317 @@ -425,8 +426,10 @@ static void _reiserfs_free_block(struct
9318 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
9320 journal_mark_dirty(th, s, sbh);
9321 - if (for_unformatted)
9322 + if (for_unformatted) {
9323 + DLIMIT_FREE_BLOCK(inode, 1);
9324 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
9328 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
9329 @@ -1034,6 +1037,7 @@ static inline int blocknrs_and_prealloc_
9330 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
9332 int nr_allocated = 0;
9335 determine_prealloc_size(hint);
9336 if (!hint->formatted_node) {
9337 @@ -1043,19 +1047,30 @@ static inline int blocknrs_and_prealloc_
9338 "reiserquota: allocating %d blocks id=%u",
9339 amount_needed, hint->inode->i_uid);
9342 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
9343 - if (quota_ret) /* Quota exceeded? */
9344 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
9347 return QUOTA_EXCEEDED;
9348 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
9349 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
9351 + return NO_DISK_SPACE;
9354 if (hint->preallocate && hint->prealloc_size) {
9355 #ifdef REISERQUOTA_DEBUG
9356 reiserfs_debug(s, REISERFS_DEBUG_CODE,
9357 "reiserquota: allocating (prealloc) %d blocks id=%u",
9358 hint->prealloc_size, hint->inode->i_uid);
9361 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
9362 - hint->prealloc_size);
9363 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
9364 + hint->prealloc_size);
9366 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
9367 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
9368 + hint->prealloc_size);
9372 hint->preallocate = hint->prealloc_size = 0;
9374 @@ -1087,7 +1102,10 @@ static inline int blocknrs_and_prealloc_
9376 hint->inode->i_uid);
9378 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
9379 + /* Free not allocated blocks */
9380 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
9381 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
9382 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
9384 while (nr_allocated--)
9385 reiserfs_free_block(hint->th, hint->inode,
9386 @@ -1118,10 +1136,10 @@ static inline int blocknrs_and_prealloc_
9387 REISERFS_I(hint->inode)->i_prealloc_count,
9388 hint->inode->i_uid);
9390 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
9391 - hint->prealloc_size - nr_allocated -
9392 - REISERFS_I(hint->inode)->
9393 - i_prealloc_count);
9394 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
9395 + REISERFS_I(hint->inode)->i_prealloc_count;
9396 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
9397 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
9401 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
9402 --- linux-2.6.22.10/fs/reiserfs/file.c 2007-07-09 13:19:28 +0200
9403 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/file.c 2007-09-12 20:04:16 +0200
9404 @@ -1546,4 +1546,5 @@ const struct inode_operations reiserfs_f
9405 .listxattr = reiserfs_listxattr,
9406 .removexattr = reiserfs_removexattr,
9407 .permission = reiserfs_permission,
9408 + .sync_flags = reiserfs_sync_flags,
9410 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
9411 --- linux-2.6.22.10/fs/reiserfs/inode.c 2007-07-09 13:19:28 +0200
9412 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/inode.c 2007-08-05 20:53:13 +0200
9414 #include <linux/mpage.h>
9415 #include <linux/writeback.h>
9416 #include <linux/quotaops.h>
9417 +#include <linux/vs_dlimit.h>
9418 +#include <linux/vs_tag.h>
9420 static int reiserfs_commit_write(struct file *f, struct page *page,
9421 unsigned from, unsigned to);
9422 @@ -50,6 +52,7 @@ void reiserfs_delete_inode(struct inode
9423 * stat data deletion */
9425 DQUOT_FREE_INODE(inode);
9426 + DLIMIT_FREE_INODE(inode);
9428 if (journal_end(&th, inode->i_sb, jbegin_count))
9430 @@ -1112,6 +1115,8 @@ static void init_inode(struct inode *ino
9431 struct buffer_head *bh;
9432 struct item_head *ih;
9436 //int version = ITEM_VERSION_1;
9438 bh = PATH_PLAST_BUFFER(path);
9439 @@ -1135,12 +1140,13 @@ static void init_inode(struct inode *ino
9440 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
9441 unsigned long blocks;
9443 + uid = sd_v1_uid(sd);
9444 + gid = sd_v1_gid(sd);
9446 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
9447 set_inode_sd_version(inode, STAT_DATA_V1);
9448 inode->i_mode = sd_v1_mode(sd);
9449 inode->i_nlink = sd_v1_nlink(sd);
9450 - inode->i_uid = sd_v1_uid(sd);
9451 - inode->i_gid = sd_v1_gid(sd);
9452 inode->i_size = sd_v1_size(sd);
9453 inode->i_atime.tv_sec = sd_v1_atime(sd);
9454 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
9455 @@ -1182,11 +1188,12 @@ static void init_inode(struct inode *ino
9456 // (directories and symlinks)
9457 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
9459 + uid = sd_v2_uid(sd);
9460 + gid = sd_v2_gid(sd);
9462 inode->i_mode = sd_v2_mode(sd);
9463 inode->i_nlink = sd_v2_nlink(sd);
9464 - inode->i_uid = sd_v2_uid(sd);
9465 inode->i_size = sd_v2_size(sd);
9466 - inode->i_gid = sd_v2_gid(sd);
9467 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
9468 inode->i_atime.tv_sec = sd_v2_atime(sd);
9469 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
9470 @@ -1216,6 +1223,10 @@ static void init_inode(struct inode *ino
9471 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
9474 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
9475 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
9476 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
9479 if (S_ISREG(inode->i_mode)) {
9480 inode->i_op = &reiserfs_file_inode_operations;
9481 @@ -1238,13 +1249,15 @@ static void init_inode(struct inode *ino
9482 static void inode2sd(void *sd, struct inode *inode, loff_t size)
9484 struct stat_data *sd_v2 = (struct stat_data *)sd;
9485 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
9486 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
9489 + set_sd_v2_uid(sd_v2, uid);
9490 + set_sd_v2_gid(sd_v2, gid);
9491 set_sd_v2_mode(sd_v2, inode->i_mode);
9492 set_sd_v2_nlink(sd_v2, inode->i_nlink);
9493 - set_sd_v2_uid(sd_v2, inode->i_uid);
9494 set_sd_v2_size(sd_v2, size);
9495 - set_sd_v2_gid(sd_v2, inode->i_gid);
9496 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
9497 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
9498 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
9499 @@ -1775,6 +1788,10 @@ int reiserfs_new_inode(struct reiserfs_t
9501 BUG_ON(!th->t_trans_id);
9503 + if (DLIMIT_ALLOC_INODE(inode)) {
9505 + goto out_bad_dlimit;
9507 if (DQUOT_ALLOC_INODE(inode)) {
9510 @@ -1960,6 +1977,9 @@ int reiserfs_new_inode(struct reiserfs_t
9511 DQUOT_FREE_INODE(inode);
9514 + DLIMIT_FREE_INODE(inode);
9517 journal_end(th, th->t_super, th->t_blocks_allocated);
9518 /* Drop can be outside and it needs more credits so it's better to have it outside */
9520 @@ -2690,6 +2710,14 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
9521 inode->i_flags |= S_IMMUTABLE;
9523 inode->i_flags &= ~S_IMMUTABLE;
9524 + if (sd_attrs & REISERFS_IUNLINK_FL)
9525 + inode->i_flags |= S_IUNLINK;
9527 + inode->i_flags &= ~S_IUNLINK;
9528 + if (sd_attrs & REISERFS_BARRIER_FL)
9529 + inode->i_flags |= S_BARRIER;
9531 + inode->i_flags &= ~S_BARRIER;
9532 if (sd_attrs & REISERFS_APPEND_FL)
9533 inode->i_flags |= S_APPEND;
9535 @@ -2712,6 +2740,14 @@ void i_attrs_to_sd_attrs(struct inode *i
9536 *sd_attrs |= REISERFS_IMMUTABLE_FL;
9538 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
9539 + if (inode->i_flags & S_IUNLINK)
9540 + *sd_attrs |= REISERFS_IUNLINK_FL;
9542 + *sd_attrs &= ~REISERFS_IUNLINK_FL;
9543 + if (inode->i_flags & S_BARRIER)
9544 + *sd_attrs |= REISERFS_BARRIER_FL;
9546 + *sd_attrs &= ~REISERFS_BARRIER_FL;
9547 if (inode->i_flags & S_SYNC)
9548 *sd_attrs |= REISERFS_SYNC_FL;
9550 @@ -2891,6 +2927,22 @@ static ssize_t reiserfs_direct_IO(int rw
9551 reiserfs_get_blocks_direct_io, NULL);
9554 +int reiserfs_sync_flags(struct inode *inode)
9556 + u16 oldflags, newflags;
9558 + oldflags = REISERFS_I(inode)->i_attrs;
9559 + newflags = oldflags;
9560 + i_attrs_to_sd_attrs(inode, &newflags);
9562 + if (oldflags ^ newflags) {
9563 + REISERFS_I(inode)->i_attrs = newflags;
9564 + inode->i_ctime = CURRENT_TIME_SEC;
9565 + mark_inode_dirty(inode);
9570 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
9572 struct inode *inode = dentry->d_inode;
9573 @@ -2940,9 +2992,11 @@ int reiserfs_setattr(struct dentry *dent
9576 error = inode_change_ok(inode, attr);
9579 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
9580 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
9581 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
9582 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
9583 error = reiserfs_chown_xattrs(inode, attr);
9586 @@ -2972,6 +3026,9 @@ int reiserfs_setattr(struct dentry *dent
9587 inode->i_uid = attr->ia_uid;
9588 if (attr->ia_valid & ATTR_GID)
9589 inode->i_gid = attr->ia_gid;
9590 + if ((attr->ia_valid & ATTR_TAG) &&
9592 + inode->i_tag = attr->ia_tag;
9593 mark_inode_dirty(inode);
9595 journal_end(&th, inode->i_sb, jbegin_count);
9596 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
9597 --- linux-2.6.22.10/fs/reiserfs/ioctl.c 2007-02-06 03:01:29 +0100
9598 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/ioctl.c 2007-08-05 20:53:13 +0200
9600 #include <linux/fs.h>
9601 #include <linux/reiserfs_fs.h>
9602 #include <linux/time.h>
9603 +#include <linux/mount.h>
9604 #include <asm/uaccess.h>
9605 #include <linux/pagemap.h>
9606 #include <linux/smp_lock.h>
9607 @@ -24,7 +25,7 @@ static int reiserfs_unpack(struct inode
9608 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
9611 - unsigned int flags;
9612 + unsigned int flags, oldflags;
9615 case REISERFS_IOC_UNPACK:
9616 @@ -43,12 +44,14 @@ int reiserfs_ioctl(struct inode *inode,
9618 flags = REISERFS_I(inode)->i_attrs;
9619 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
9620 + flags &= REISERFS_FL_USER_VISIBLE;
9621 return put_user(flags, (int __user *)arg);
9622 case REISERFS_IOC_SETFLAGS:{
9623 if (!reiserfs_attrs(inode->i_sb))
9626 - if (IS_RDONLY(inode))
9627 + if (IS_RDONLY(inode) ||
9628 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9631 if ((current->fsuid != inode->i_uid)
9632 @@ -58,10 +61,12 @@ int reiserfs_ioctl(struct inode *inode,
9633 if (get_user(flags, (int __user *)arg))
9636 - if (((flags ^ REISERFS_I(inode)->
9637 - i_attrs) & (REISERFS_IMMUTABLE_FL |
9638 - REISERFS_APPEND_FL))
9639 - && !capable(CAP_LINUX_IMMUTABLE))
9640 + oldflags = REISERFS_I(inode) -> i_attrs;
9641 + if (((oldflags & REISERFS_IMMUTABLE_FL) ||
9642 + ((flags ^ oldflags) &
9643 + (REISERFS_IMMUTABLE_FL | REISERFS_IUNLINK_FL |
9644 + REISERFS_APPEND_FL))) &&
9645 + !capable(CAP_LINUX_IMMUTABLE))
9648 if ((flags & REISERFS_NOTAIL_FL) &&
9649 @@ -72,6 +77,9 @@ int reiserfs_ioctl(struct inode *inode,
9654 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
9655 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
9656 sd_attrs_to_i_attrs(flags, inode);
9657 REISERFS_I(inode)->i_attrs = flags;
9658 inode->i_ctime = CURRENT_TIME_SEC;
9659 @@ -83,7 +91,8 @@ int reiserfs_ioctl(struct inode *inode,
9660 case REISERFS_IOC_SETVERSION:
9661 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
9663 - if (IS_RDONLY(inode))
9664 + if (IS_RDONLY(inode) ||
9665 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
9667 if (get_user(inode->i_generation, (int __user *)arg))
9669 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
9670 --- linux-2.6.22.10/fs/reiserfs/namei.c 2007-07-09 13:19:28 +0200
9671 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/namei.c 2007-08-05 20:53:13 +0200
9673 #include <linux/reiserfs_acl.h>
9674 #include <linux/reiserfs_xattr.h>
9675 #include <linux/quotaops.h>
9676 +#include <linux/vs_tag.h>
9678 #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; }
9679 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
9680 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
9681 reiserfs_write_unlock(dir->i_sb);
9682 return ERR_PTR(-EACCES);
9684 + dx_propagate_tag(nd, inode);
9686 /* Propogate the priv_object flag so we know we're in the priv tree */
9687 if (is_reiserfs_priv_object(dir))
9688 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
9690 inode->i_gid = current->fsgid;
9692 + inode->i_tag = dx_current_fstag(inode->i_sb);
9696 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
9697 .listxattr = reiserfs_listxattr,
9698 .removexattr = reiserfs_removexattr,
9699 .permission = reiserfs_permission,
9700 + .sync_flags = reiserfs_sync_flags,
9704 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
9705 .listxattr = reiserfs_listxattr,
9706 .removexattr = reiserfs_removexattr,
9707 .permission = reiserfs_permission,
9708 + .sync_flags = reiserfs_sync_flags,
9712 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
9713 .listxattr = reiserfs_listxattr,
9714 .removexattr = reiserfs_removexattr,
9715 .permission = reiserfs_permission,
9716 + .sync_flags = reiserfs_sync_flags,
9719 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
9720 --- linux-2.6.22.10/fs/reiserfs/stree.c 2007-07-09 13:19:28 +0200
9721 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/stree.c 2007-08-05 20:53:13 +0200
9723 #include <linux/reiserfs_fs.h>
9724 #include <linux/buffer_head.h>
9725 #include <linux/quotaops.h>
9726 +#include <linux/vs_dlimit.h>
9728 /* Does the buffer contain a disk block which is in the tree. */
9729 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
9730 @@ -1296,6 +1297,7 @@ int reiserfs_delete_item(struct reiserfs
9731 "reiserquota delete_item(): freeing %u, id=%u type=%c",
9732 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
9734 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9735 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9737 /* Return deleted body length */
9738 @@ -1384,6 +1386,7 @@ void reiserfs_delete_solid_item(struct r
9740 DQUOT_FREE_SPACE_NODIRTY(inode,
9742 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
9746 @@ -1737,6 +1740,7 @@ int reiserfs_cut_from_item(struct reiser
9747 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
9748 quota_cut_bytes, p_s_inode->i_uid, '?');
9750 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
9751 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
9754 @@ -1978,6 +1982,11 @@ int reiserfs_paste_into_item(struct reis
9755 pathrelse(p_s_search_path);
9758 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
9759 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9760 + pathrelse(p_s_search_path);
9763 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
9765 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
9766 @@ -2030,6 +2039,7 @@ int reiserfs_paste_into_item(struct reis
9767 n_pasted_size, inode->i_uid,
9768 key2type(&(p_s_key->on_disk_key)));
9770 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
9771 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
9774 @@ -2067,6 +2077,11 @@ int reiserfs_insert_item(struct reiserfs
9775 pathrelse(p_s_path);
9778 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
9779 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9780 + pathrelse(p_s_path);
9784 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
9785 IH_SIZE + ih_item_len(p_s_ih));
9786 @@ -2114,7 +2129,9 @@ int reiserfs_insert_item(struct reiserfs
9787 "reiserquota insert_item(): freeing %u id=%u type=%c",
9788 quota_bytes, inode->i_uid, head2type(p_s_ih));
9792 + DLIMIT_FREE_SPACE(inode, quota_bytes);
9793 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
9797 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
9798 --- linux-2.6.22.10/fs/reiserfs/super.c 2007-07-09 13:19:28 +0200
9799 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/super.c 2007-08-05 20:53:13 +0200
9800 @@ -882,6 +882,14 @@ static int reiserfs_parse_options(struct
9801 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9802 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9804 +#ifndef CONFIG_TAGGING_NONE
9805 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9806 + {"tag",.setmask = 1 << REISERFS_TAGGED},
9807 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
9809 +#ifdef CONFIG_PROPAGATE
9810 + {"tag",.arg_required = 'T',.values = NULL},
9812 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9813 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9814 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9815 @@ -1143,6 +1151,12 @@ static int reiserfs_remount(struct super
9819 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
9820 + !(s->s_flags & MS_TAGGED)) {
9821 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
9827 /* Add options that are safe here */
9828 @@ -1591,6 +1605,10 @@ static int reiserfs_fill_super(struct su
9832 + /* map mount option tagxid */
9833 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9834 + s->s_flags |= MS_TAGGED;
9836 rs = SB_DISK_SUPER_BLOCK(s);
9837 /* Let's do basic sanity check to verify that underlying device is not
9838 smaller than the filesystem. If the check fails then abort and scream,
9839 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
9840 --- linux-2.6.22.10/fs/reiserfs/xattr.c 2007-07-09 13:19:28 +0200
9841 +++ linux-2.6.22.10-vs2.3.0.29/fs/reiserfs/xattr.c 2007-08-05 20:53:13 +0200
9843 #include <linux/namei.h>
9844 #include <linux/errno.h>
9845 #include <linux/fs.h>
9846 +#include <linux/mount.h>
9847 #include <linux/file.h>
9848 #include <linux/pagemap.h>
9849 #include <linux/xattr.h>
9850 @@ -775,7 +776,7 @@ int reiserfs_delete_xattrs(struct inode
9851 if (dir->d_inode->i_nlink <= 2) {
9852 root = get_xa_root(inode->i_sb, XATTR_REPLACE);
9853 reiserfs_write_lock_xattrs(inode->i_sb);
9854 - err = vfs_rmdir(root->d_inode, dir);
9855 + err = vfs_rmdir(root->d_inode, dir, NULL);
9856 reiserfs_write_unlock_xattrs(inode->i_sb);
9859 diff -NurpP --minimal linux-2.6.22.10/fs/stat.c linux-2.6.22.10-vs2.3.0.29/fs/stat.c
9860 --- linux-2.6.22.10/fs/stat.c 2007-07-09 13:19:28 +0200
9861 +++ linux-2.6.22.10-vs2.3.0.29/fs/stat.c 2007-08-05 20:53:13 +0200
9862 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9863 stat->nlink = inode->i_nlink;
9864 stat->uid = inode->i_uid;
9865 stat->gid = inode->i_gid;
9866 + stat->tag = inode->i_tag;
9867 stat->rdev = inode->i_rdev;
9868 stat->atime = inode->i_atime;
9869 stat->mtime = inode->i_mtime;
9870 diff -NurpP --minimal linux-2.6.22.10/fs/super.c linux-2.6.22.10-vs2.3.0.29/fs/super.c
9871 --- linux-2.6.22.10/fs/super.c 2007-07-09 13:19:28 +0200
9872 +++ linux-2.6.22.10-vs2.3.0.29/fs/super.c 2007-10-20 00:00:59 +0200
9874 #include <linux/idr.h>
9875 #include <linux/kobject.h>
9876 #include <linux/mutex.h>
9877 +#include <linux/devpts_fs.h>
9878 +#include <linux/proc_fs.h>
9879 +#include <linux/vs_context.h>
9880 #include <asm/uaccess.h>
9883 @@ -860,12 +863,18 @@ struct vfsmount *
9884 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9886 struct vfsmount *mnt;
9887 + struct super_block *sb;
9888 char *secdata = NULL;
9892 return ERR_PTR(-ENODEV);
9895 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9896 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9900 mnt = alloc_vfsmnt(name);
9902 @@ -885,7 +894,14 @@ vfs_kern_mount(struct file_system_type *
9904 goto out_free_secdata;
9906 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
9909 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9910 + (sb->s_magic != PROC_SUPER_MAGIC) &&
9911 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
9914 + error = security_sb_kern_mount(sb, secdata);
9918 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
9919 --- linux-2.6.22.10/fs/sysfs/mount.c 2007-07-09 13:19:28 +0200
9920 +++ linux-2.6.22.10-vs2.3.0.29/fs/sysfs/mount.c 2007-08-05 20:53:13 +0200
9925 -/* Random magic number */
9926 -#define SYSFS_MAGIC 0x62656572
9928 struct vfsmount *sysfs_mount;
9929 struct super_block * sysfs_sb = NULL;
9930 @@ -48,7 +46,7 @@ static int sysfs_fill_super(struct super
9932 sb->s_blocksize = PAGE_CACHE_SIZE;
9933 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9934 - sb->s_magic = SYSFS_MAGIC;
9935 + sb->s_magic = SYSFS_SUPER_MAGIC;
9936 sb->s_op = &sysfs_ops;
9937 sb->s_time_gran = 1;
9939 diff -NurpP --minimal linux-2.6.22.10/fs/utimes.c linux-2.6.22.10-vs2.3.0.29/fs/utimes.c
9940 --- linux-2.6.22.10/fs/utimes.c 2007-07-09 13:19:29 +0200
9941 +++ linux-2.6.22.10-vs2.3.0.29/fs/utimes.c 2007-08-05 20:53:13 +0200
9943 #include <linux/sched.h>
9944 #include <linux/stat.h>
9945 #include <linux/utime.h>
9946 +#include <linux/mount.h>
9947 +#include <linux/vs_cowbl.h>
9948 #include <asm/uaccess.h>
9949 #include <asm/unistd.h>
9951 @@ -70,11 +72,13 @@ long do_utimes(int dfd, char __user *fil
9955 + error = cow_check_and_break(&nd);
9957 + goto dput_and_out;
9961 inode = dentry->d_inode;
9964 if (IS_RDONLY(inode))
9966 diff -NurpP --minimal linux-2.6.22.10/fs/xattr.c linux-2.6.22.10-vs2.3.0.29/fs/xattr.c
9967 --- linux-2.6.22.10/fs/xattr.c 2007-07-09 13:19:29 +0200
9968 +++ linux-2.6.22.10-vs2.3.0.29/fs/xattr.c 2007-08-05 20:53:13 +0200
9970 #include <linux/module.h>
9971 #include <linux/fsnotify.h>
9972 #include <linux/audit.h>
9973 +#include <linux/mount.h>
9974 #include <asm/uaccess.h>
9977 @@ -194,7 +195,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
9980 setxattr(struct dentry *d, char __user *name, void __user *value,
9981 - size_t size, int flags)
9982 + size_t size, int flags, struct vfsmount *mnt)
9985 void *kvalue = NULL;
9986 @@ -221,6 +222,9 @@ setxattr(struct dentry *d, char __user *
9990 + if (MNT_IS_RDONLY(mnt))
9993 error = vfs_setxattr(d, kname, kvalue, size, flags);
9996 @@ -236,7 +240,7 @@ sys_setxattr(char __user *path, char __u
9997 error = user_path_walk(path, &nd);
10000 - error = setxattr(nd.dentry, name, value, size, flags);
10001 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
10005 @@ -251,7 +255,7 @@ sys_lsetxattr(char __user *path, char __
10006 error = user_path_walk_link(path, &nd);
10009 - error = setxattr(nd.dentry, name, value, size, flags);
10010 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
10014 @@ -269,7 +273,7 @@ sys_fsetxattr(int fd, char __user *name,
10016 dentry = f->f_path.dentry;
10017 audit_inode(NULL, dentry->d_inode);
10018 - error = setxattr(dentry, name, value, size, flags);
10019 + error = setxattr(dentry, name, value, size, flags, f->f_vfsmnt);
10023 @@ -433,7 +437,7 @@ sys_flistxattr(int fd, char __user *list
10024 * Extended attribute REMOVE operations
10027 -removexattr(struct dentry *d, char __user *name)
10028 +removexattr(struct dentry *d, char __user *name, struct vfsmount *mnt)
10031 char kname[XATTR_NAME_MAX + 1];
10032 @@ -444,6 +448,9 @@ removexattr(struct dentry *d, char __use
10036 + if (MNT_IS_RDONLY(mnt))
10039 return vfs_removexattr(d, kname);
10042 @@ -456,7 +463,7 @@ sys_removexattr(char __user *path, char
10043 error = user_path_walk(path, &nd);
10046 - error = removexattr(nd.dentry, name);
10047 + error = removexattr(nd.dentry, name, nd.mnt);
10051 @@ -470,7 +477,7 @@ sys_lremovexattr(char __user *path, char
10052 error = user_path_walk_link(path, &nd);
10055 - error = removexattr(nd.dentry, name);
10056 + error = removexattr(nd.dentry, name, nd.mnt);
10060 @@ -487,7 +494,7 @@ sys_fremovexattr(int fd, char __user *na
10062 dentry = f->f_path.dentry;
10063 audit_inode(NULL, dentry->d_inode);
10064 - error = removexattr(dentry, name);
10065 + error = removexattr(dentry, name, f->f_vfsmnt);
10069 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
10070 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_ioctl.c 2007-05-02 19:25:22 +0200
10071 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_ioctl.c 2007-08-05 20:53:13 +0200
10072 @@ -1128,6 +1128,10 @@ xfs_di2lxflags(
10074 if (di_flags & XFS_DIFLAG_IMMUTABLE)
10075 flags |= FS_IMMUTABLE_FL;
10076 + if (di_flags & XFS_DIFLAG_IUNLINK)
10077 + flags |= FS_IUNLINK_FL;
10078 + if (di_flags & XFS_DIFLAG_BARRIER)
10079 + flags |= FS_BARRIER_FL;
10080 if (di_flags & XFS_DIFLAG_APPEND)
10081 flags |= FS_APPEND_FL;
10082 if (di_flags & XFS_DIFLAG_SYNC)
10083 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
10084 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_iops.c 2007-05-02 19:25:22 +0200
10085 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_iops.c 2007-08-05 20:53:13 +0200
10087 #include <linux/xattr.h>
10088 #include <linux/namei.h>
10089 #include <linux/security.h>
10090 +#include <linux/vs_tag.h>
10093 * Get a XFS inode from a given vnode.
10094 @@ -400,6 +401,7 @@ xfs_vn_lookup(
10095 d_add(dentry, NULL);
10098 + dx_propagate_tag(nd, vn_to_inode(cvp));
10100 return d_splice_alias(vn_to_inode(cvp), dentry);
10102 @@ -657,6 +659,10 @@ xfs_vn_setattr(
10106 + error = inode_change_ok(inode, attr);
10110 if (ia_valid & ATTR_UID) {
10111 vattr.va_mask |= XFS_AT_UID;
10112 vattr.va_uid = attr->ia_uid;
10113 @@ -665,6 +671,10 @@ xfs_vn_setattr(
10114 vattr.va_mask |= XFS_AT_GID;
10115 vattr.va_gid = attr->ia_gid;
10117 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode)) {
10118 + vattr.va_mask |= XFS_AT_TAG;
10119 + vattr.va_tag = attr->ia_tag;
10121 if (ia_valid & ATTR_SIZE) {
10122 vattr.va_mask |= XFS_AT_SIZE;
10123 vattr.va_size = attr->ia_size;
10124 @@ -710,6 +720,42 @@ xfs_vn_truncate(
10128 +xfs_vn_sync_flags(struct inode *inode)
10130 + unsigned int oldflags, newflags;
10133 + bhv_vattr_t vattr;
10134 + bhv_vnode_t *vp = vn_from_inode(inode);
10136 + memset(&vattr, 0, sizeof vattr);
10138 + vattr.va_mask = XFS_AT_XFLAGS;
10139 + error = bhv_vop_getattr(vp, &vattr, 0, NULL);
10143 + oldflags = vattr.va_xflags;
10144 + newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
10145 + XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
10147 + if (IS_IMMUTABLE(inode))
10148 + newflags |= XFS_XFLAG_IMMUTABLE;
10149 + if (IS_IUNLINK(inode))
10150 + newflags |= XFS_XFLAG_IUNLINK;
10151 + if (IS_BARRIER(inode))
10152 + newflags |= XFS_XFLAG_BARRIER;
10154 + if (oldflags ^ newflags) {
10155 + vattr.va_xflags = newflags;
10156 + vattr.va_mask |= XFS_AT_XFLAGS;
10157 + error = bhv_vop_setattr(vp, &vattr, flags, NULL);
10159 + vn_revalidate(vp);
10165 struct dentry *dentry,
10167 @@ -822,6 +868,7 @@ const struct inode_operations xfs_inode_
10168 .getxattr = xfs_vn_getxattr,
10169 .listxattr = xfs_vn_listxattr,
10170 .removexattr = xfs_vn_removexattr,
10171 + .sync_flags = xfs_vn_sync_flags,
10174 const struct inode_operations xfs_dir_inode_operations = {
10175 @@ -841,6 +888,7 @@ const struct inode_operations xfs_dir_in
10176 .getxattr = xfs_vn_getxattr,
10177 .listxattr = xfs_vn_listxattr,
10178 .removexattr = xfs_vn_removexattr,
10179 + .sync_flags = xfs_vn_sync_flags,
10182 const struct inode_operations xfs_symlink_inode_operations = {
10183 @@ -854,4 +902,5 @@ const struct inode_operations xfs_symlin
10184 .getxattr = xfs_vn_getxattr,
10185 .listxattr = xfs_vn_listxattr,
10186 .removexattr = xfs_vn_removexattr,
10187 + .sync_flags = xfs_vn_sync_flags,
10189 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
10190 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_linux.h 2007-05-02 19:25:22 +0200
10191 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_linux.h 2007-08-05 20:53:13 +0200
10192 @@ -129,6 +129,7 @@
10193 #define current_pid() (current->pid)
10194 #define current_fsuid(cred) (current->fsuid)
10195 #define current_fsgid(cred) (current->fsgid)
10196 +#define current_fstag(cred,vp) (dx_current_fstag(vn_to_inode(vp)->i_sb))
10197 #define current_test_flags(f) (current->flags & (f))
10198 #define current_set_flags_nested(sp, f) \
10199 (*(sp) = current->flags, current->flags |= (f))
10200 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
10201 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_super.c 2007-07-09 13:19:29 +0200
10202 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_super.c 2007-08-05 20:53:13 +0200
10203 @@ -157,6 +157,7 @@ xfs_revalidate_inode(
10204 inode->i_nlink = ip->i_d.di_nlink;
10205 inode->i_uid = ip->i_d.di_uid;
10206 inode->i_gid = ip->i_d.di_gid;
10207 + inode->i_tag = ip->i_d.di_tag;
10209 switch (inode->i_mode & S_IFMT) {
10211 @@ -184,6 +185,14 @@ xfs_revalidate_inode(
10212 inode->i_flags |= S_IMMUTABLE;
10214 inode->i_flags &= ~S_IMMUTABLE;
10215 + if (ip->i_d.di_flags & XFS_DIFLAG_IUNLINK)
10216 + inode->i_flags |= S_IUNLINK;
10218 + inode->i_flags &= ~S_IUNLINK;
10219 + if (ip->i_d.di_flags & XFS_DIFLAG_BARRIER)
10220 + inode->i_flags |= S_BARRIER;
10222 + inode->i_flags &= ~S_BARRIER;
10223 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
10224 inode->i_flags |= S_APPEND;
10226 @@ -712,6 +721,12 @@ xfs_fs_remount(
10229 error = bhv_vfs_parseargs(vfsp, options, args, 1);
10230 + if ((args->flags2 & XFSMNT2_TAGGED) &&
10231 + !(sb->s_flags & MS_TAGGED)) {
10232 + printk("XFS: %s: tagging not permitted on remount.\n",
10237 error = bhv_vfs_mntupdate(vfsp, flags, args);
10238 kmem_free(args, sizeof(*args));
10239 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
10240 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.c 2007-05-02 19:25:22 +0200
10241 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_vnode.c 2007-08-05 20:53:13 +0200
10242 @@ -119,6 +119,7 @@ vn_revalidate_core(
10243 inode->i_nlink = vap->va_nlink;
10244 inode->i_uid = vap->va_uid;
10245 inode->i_gid = vap->va_gid;
10246 + inode->i_tag = vap->va_tag;
10247 inode->i_blocks = vap->va_nblocks;
10248 inode->i_mtime = vap->va_mtime;
10249 inode->i_ctime = vap->va_ctime;
10250 @@ -126,6 +127,14 @@ vn_revalidate_core(
10251 inode->i_flags |= S_IMMUTABLE;
10253 inode->i_flags &= ~S_IMMUTABLE;
10254 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10255 + inode->i_flags |= S_IUNLINK;
10257 + inode->i_flags &= ~S_IUNLINK;
10258 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10259 + inode->i_flags |= S_BARRIER;
10261 + inode->i_flags &= ~S_BARRIER;
10262 if (vap->va_xflags & XFS_XFLAG_APPEND)
10263 inode->i_flags |= S_APPEND;
10265 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
10266 --- linux-2.6.22.10/fs/xfs/linux-2.6/xfs_vnode.h 2007-07-09 13:19:29 +0200
10267 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/linux-2.6/xfs_vnode.h 2007-08-05 20:53:13 +0200
10268 @@ -350,6 +350,7 @@ typedef struct bhv_vattr {
10269 xfs_nlink_t va_nlink; /* number of references to file */
10270 uid_t va_uid; /* owner user id */
10271 gid_t va_gid; /* owner group id */
10272 + tag_t va_tag; /* owner group id */
10273 xfs_ino_t va_nodeid; /* file id */
10274 xfs_off_t va_size; /* file size in bytes */
10275 u_long va_blocksize; /* blocksize preferred for i/o */
10276 @@ -398,13 +399,15 @@ typedef struct bhv_vattr {
10277 #define XFS_AT_PROJID 0x04000000
10278 #define XFS_AT_SIZE_NOPERM 0x08000000
10279 #define XFS_AT_GENCOUNT 0x10000000
10280 +#define XFS_AT_TAG 0x20000000
10282 #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
10283 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
10284 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
10285 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
10286 XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
10287 - XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
10288 + XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT\
10291 #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
10292 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
10293 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
10294 --- linux-2.6.22.10/fs/xfs/quota/xfs_qm_syscalls.c 2007-07-09 13:19:29 +0200
10295 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/quota/xfs_qm_syscalls.c 2007-08-05 20:53:13 +0200
10299 #include <linux/capability.h>
10300 +#include <linux/vs_context.h>
10303 #include "xfs_fs.h"
10304 @@ -211,7 +212,7 @@ xfs_qm_scall_quotaoff(
10305 xfs_qoff_logitem_t *qoffstart;
10308 - if (!force && !capable(CAP_SYS_ADMIN))
10309 + if (!force && !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10310 return XFS_ERROR(EPERM);
10312 * No file system can have quotas enabled on disk but not in core.
10313 @@ -380,7 +381,7 @@ xfs_qm_scall_trunc_qfiles(
10317 - if (!capable(CAP_SYS_ADMIN))
10318 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10319 return XFS_ERROR(EPERM);
10321 if (!XFS_SB_VERSION_HASQUOTA(&mp->m_sb) || flags == 0) {
10322 @@ -425,7 +426,7 @@ xfs_qm_scall_quotaon(
10326 - if (!capable(CAP_SYS_ADMIN))
10327 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10328 return XFS_ERROR(EPERM);
10330 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
10331 @@ -594,7 +595,7 @@ xfs_qm_scall_setqlim(
10333 xfs_qcnt_t hard, soft;
10335 - if (!capable(CAP_SYS_ADMIN))
10336 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
10337 return XFS_ERROR(EPERM);
10339 if ((newlim->d_fieldmask &
10340 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
10341 --- linux-2.6.22.10/fs/xfs/xfs_clnt.h 2006-06-18 04:54:50 +0200
10342 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_clnt.h 2007-08-05 20:53:13 +0200
10343 @@ -99,5 +99,7 @@ struct xfs_mount_args {
10345 #define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred
10346 * I/O size in stat(2) */
10347 +#define XFSMNT2_TAGGED 0x80000000 /* context tagging */
10350 #endif /* __XFS_CLNT_H__ */
10351 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
10352 --- linux-2.6.22.10/fs/xfs/xfs_dinode.h 2006-09-20 16:58:40 +0200
10353 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_dinode.h 2007-08-05 20:53:13 +0200
10354 @@ -53,7 +53,8 @@ typedef struct xfs_dinode_core
10355 __uint32_t di_gid; /* owner's group id */
10356 __uint32_t di_nlink; /* number of links to file */
10357 __uint16_t di_projid; /* owner's project id */
10358 - __uint8_t di_pad[8]; /* unused, zeroed space */
10359 + __uint16_t di_tag; /* context tagging */
10360 + __uint8_t di_pad[6]; /* unused, zeroed space */
10361 __uint16_t di_flushiter; /* incremented on flush */
10362 xfs_timestamp_t di_atime; /* time last accessed */
10363 xfs_timestamp_t di_mtime; /* time last modified */
10364 @@ -257,6 +258,9 @@ typedef enum xfs_dinode_fmt
10365 #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */
10366 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
10367 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
10368 +#define XFS_DIFLAG_BARRIER_BIT 14 /* chroot() barrier */
10369 +#define XFS_DIFLAG_IUNLINK_BIT 15 /* immutable unlink */
10371 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
10372 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
10373 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
10374 @@ -271,12 +275,15 @@ typedef enum xfs_dinode_fmt
10375 #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT)
10376 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
10377 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
10378 +#define XFS_DIFLAG_BARRIER (1 << XFS_DIFLAG_BARRIER_BIT)
10379 +#define XFS_DIFLAG_IUNLINK (1 << XFS_DIFLAG_IUNLINK_BIT)
10381 #define XFS_DIFLAG_ANY \
10382 (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
10383 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
10384 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
10385 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
10386 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG)
10387 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_BARRIER | \
10388 + XFS_DIFLAG_IUNLINK)
10390 #endif /* __XFS_DINODE_H__ */
10391 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
10392 --- linux-2.6.22.10/fs/xfs/xfs_fs.h 2006-11-30 21:19:29 +0100
10393 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_fs.h 2007-08-05 20:53:13 +0200
10394 @@ -66,6 +66,8 @@ struct fsxattr {
10395 #define XFS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */
10396 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
10397 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
10398 +#define XFS_XFLAG_BARRIER 0x00004000 /* chroot() barrier */
10399 +#define XFS_XFLAG_IUNLINK 0x00008000 /* immutable unlink */
10400 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
10403 @@ -294,7 +296,8 @@ typedef struct xfs_bstat {
10404 __s32 bs_extents; /* number of extents */
10405 __u32 bs_gen; /* generation count */
10406 __u16 bs_projid; /* project id */
10407 - unsigned char bs_pad[14]; /* pad space, unused */
10408 + __u16 bs_tag; /* context tagging */
10409 + unsigned char bs_pad[12]; /* pad space, unused */
10410 __u32 bs_dmevmask; /* DMIG event mask */
10411 __u16 bs_dmstate; /* DMIG state info */
10412 __u16 bs_aextents; /* attribute number of extents */
10413 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
10414 --- linux-2.6.22.10/fs/xfs/xfs_inode.c 2007-07-09 13:19:34 +0200
10415 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_inode.c 2007-08-05 20:53:13 +0200
10417 #include "xfs_quota.h"
10418 #include "xfs_acl.h"
10420 +#include <linux/vs_tag.h>
10422 kmem_zone_t *xfs_ifork_zone;
10423 kmem_zone_t *xfs_inode_zone;
10424 @@ -736,20 +737,35 @@ xfs_xlate_dinode_core(
10425 xfs_dinode_core_t *buf_core = (xfs_dinode_core_t *)buf;
10426 xfs_dinode_core_t *mem_core = (xfs_dinode_core_t *)dip;
10427 xfs_arch_t arch = ARCH_CONVERT;
10428 + uint32_t uid = 0, gid = 0;
10429 + uint16_t tag = 0;
10434 + tag = mem_core->di_tag;
10435 + /* FIXME: supposed to use superblock flag */
10436 + uid = TAGINO_UID(1, mem_core->di_uid, tag);
10437 + gid = TAGINO_GID(1, mem_core->di_gid, tag);
10438 + tag = TAGINO_TAG(1, tag);
10441 INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch);
10442 INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch);
10443 INT_XLATE(buf_core->di_version, mem_core->di_version, dir, arch);
10444 INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch);
10445 INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch);
10446 - INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch);
10447 - INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch);
10448 + INT_XLATE(buf_core->di_uid, uid, dir, arch);
10449 + INT_XLATE(buf_core->di_gid, gid, dir, arch);
10450 + INT_XLATE(buf_core->di_tag, tag, dir, arch);
10451 INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch);
10452 INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch);
10455 + /* FIXME: supposed to use superblock flag */
10456 + mem_core->di_uid = INOTAG_UID(1, uid, gid);
10457 + mem_core->di_gid = INOTAG_GID(1, uid, gid);
10458 + mem_core->di_tag = INOTAG_TAG(1, uid, gid, tag);
10459 memcpy(mem_core->di_pad, buf_core->di_pad,
10460 sizeof(buf_core->di_pad));
10462 @@ -797,6 +813,10 @@ _xfs_dic2xflags(
10463 flags |= XFS_XFLAG_PREALLOC;
10464 if (di_flags & XFS_DIFLAG_IMMUTABLE)
10465 flags |= XFS_XFLAG_IMMUTABLE;
10466 + if (di_flags & XFS_DIFLAG_IUNLINK)
10467 + flags |= XFS_XFLAG_IUNLINK;
10468 + if (di_flags & XFS_DIFLAG_BARRIER)
10469 + flags |= XFS_XFLAG_BARRIER;
10470 if (di_flags & XFS_DIFLAG_APPEND)
10471 flags |= XFS_XFLAG_APPEND;
10472 if (di_flags & XFS_DIFLAG_SYNC)
10473 @@ -1129,6 +1149,7 @@ xfs_ialloc(
10474 ASSERT(ip->i_d.di_nlink == nlink);
10475 ip->i_d.di_uid = current_fsuid(cr);
10476 ip->i_d.di_gid = current_fsgid(cr);
10477 + ip->i_d.di_tag = current_fstag(cr, vp);
10478 ip->i_d.di_projid = prid;
10479 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
10481 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
10482 --- linux-2.6.22.10/fs/xfs/xfs_itable.c 2007-07-09 13:19:34 +0200
10483 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_itable.c 2007-08-05 20:53:13 +0200
10484 @@ -89,6 +89,7 @@ xfs_bulkstat_one_iget(
10485 buf->bs_mode = dic->di_mode;
10486 buf->bs_uid = dic->di_uid;
10487 buf->bs_gid = dic->di_gid;
10488 + buf->bs_tag = dic->di_tag;
10489 buf->bs_size = dic->di_size;
10490 vn_atime_to_bstime(vp, &buf->bs_atime);
10491 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
10492 @@ -163,6 +164,7 @@ xfs_bulkstat_one_dinode(
10493 buf->bs_mode = INT_GET(dic->di_mode, ARCH_CONVERT);
10494 buf->bs_uid = INT_GET(dic->di_uid, ARCH_CONVERT);
10495 buf->bs_gid = INT_GET(dic->di_gid, ARCH_CONVERT);
10496 + buf->bs_tag = INT_GET(dic->di_tag, ARCH_CONVERT);
10497 buf->bs_size = INT_GET(dic->di_size, ARCH_CONVERT);
10498 buf->bs_atime.tv_sec = INT_GET(dic->di_atime.t_sec, ARCH_CONVERT);
10499 buf->bs_atime.tv_nsec = INT_GET(dic->di_atime.t_nsec, ARCH_CONVERT);
10500 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
10501 --- linux-2.6.22.10/fs/xfs/xfs_mount.h 2007-05-02 19:25:23 +0200
10502 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_mount.h 2007-08-05 20:53:13 +0200
10503 @@ -464,6 +464,7 @@ typedef struct xfs_mount {
10504 #define XFS_MOUNT_NO_PERCPU_SB (1ULL << 23) /* don't use per-cpu superblock
10507 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
10510 * Default minimum read and write sizes.
10511 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
10512 --- linux-2.6.22.10/fs/xfs/xfs_vfsops.c 2007-07-09 13:19:34 +0200
10513 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_vfsops.c 2007-08-05 20:53:13 +0200
10514 @@ -300,6 +300,8 @@ xfs_start_flags(
10516 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
10517 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
10518 + if (ap->flags2 & XFSMNT2_TAGGED)
10519 + mp->m_flags |= XFS_MOUNT_TAGGED;
10522 * no recovery flag requires a read-only mount
10523 @@ -394,6 +396,8 @@ xfs_finish_flags(
10524 return XFS_ERROR(EINVAL);
10527 + if (ap->flags2 & XFSMNT2_TAGGED)
10528 + vfs->vfs_super->s_flags |= MS_TAGGED;
10532 @@ -1645,6 +1649,9 @@ xfs_vget(
10534 #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
10535 #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
10536 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
10537 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
10538 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
10540 STATIC unsigned long
10541 suffix_strtoul(char *s, char **endp, unsigned int base)
10542 @@ -1831,6 +1838,19 @@ xfs_parseargs(
10543 args->flags |= XFSMNT_ATTR2;
10544 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
10545 args->flags &= ~XFSMNT_ATTR2;
10546 +#ifndef CONFIG_TAGGING_NONE
10547 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
10548 + args->flags2 |= XFSMNT2_TAGGED;
10549 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
10550 + args->flags2 &= ~XFSMNT2_TAGGED;
10551 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
10552 + args->flags2 |= XFSMNT2_TAGGED;
10554 +#ifdef CONFIG_PROPAGATE
10555 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
10557 + args->flags2 |= XFSMNT2_TAGGED;
10559 } else if (!strcmp(this_char, "osyncisdsync")) {
10560 /* no-op, this is now the default */
10562 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
10563 --- linux-2.6.22.10/fs/xfs/xfs_vnodeops.c 2007-07-09 13:19:34 +0200
10564 +++ linux-2.6.22.10-vs2.3.0.29/fs/xfs/xfs_vnodeops.c 2007-08-05 20:53:13 +0200
10565 @@ -159,6 +159,7 @@ xfs_getattr(
10566 vap->va_mode = ip->i_d.di_mode;
10567 vap->va_uid = ip->i_d.di_uid;
10568 vap->va_gid = ip->i_d.di_gid;
10569 + vap->va_tag = ip->i_d.di_tag;
10570 vap->va_projid = ip->i_d.di_projid;
10573 @@ -259,6 +260,7 @@ xfs_setattr(
10574 uint commit_flags=0;
10575 uid_t uid=0, iuid=0;
10576 gid_t gid=0, igid=0;
10577 + tag_t tag=0, itag=0;
10580 xfs_prid_t projid=0, iprojid=0;
10581 @@ -315,6 +317,7 @@ xfs_setattr(
10582 (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID))) {
10585 + /* TODO: handle tagging? */
10586 if ((mask & XFS_AT_UID) && XFS_IS_UQUOTA_ON(mp)) {
10588 qflags |= XFS_QMOPT_UQUOTA;
10589 @@ -394,6 +397,8 @@ xfs_setattr(
10591 (XFS_AT_MODE|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_UID|
10592 XFS_AT_GID|XFS_AT_PROJID)) {
10593 + /* TODO: handle tagging? */
10596 * CAP_FOWNER overrides the following restrictions:
10598 @@ -442,7 +447,7 @@ xfs_setattr(
10599 * and can change the group id only to a group of which he
10600 * or she is a member.
10602 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10603 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10605 * These IDs could have changed since we last looked at them.
10606 * But, we're assured that if the ownership did change
10607 @@ -450,10 +455,12 @@ xfs_setattr(
10608 * would have changed also.
10610 iuid = ip->i_d.di_uid;
10611 - iprojid = ip->i_d.di_projid;
10612 igid = ip->i_d.di_gid;
10613 - gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10614 + itag = ip->i_d.di_tag;
10615 + iprojid = ip->i_d.di_projid;
10616 uid = (mask & XFS_AT_UID) ? vap->va_uid : iuid;
10617 + gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
10618 + tag = (mask & XFS_AT_TAG) ? vap->va_tag : itag;
10619 projid = (mask & XFS_AT_PROJID) ? (xfs_prid_t)vap->va_projid :
10622 @@ -481,6 +488,7 @@ xfs_setattr(
10623 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
10624 (XFS_IS_PQUOTA_ON(mp) && iprojid != projid) ||
10625 (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
10626 + /* TODO: handle tagging? */
10628 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
10629 capable(CAP_FOWNER) ?
10630 @@ -706,7 +714,7 @@ xfs_setattr(
10631 * and can change the group id only to a group of which he
10632 * or she is a member.
10634 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
10635 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
10637 * CAP_FSETID overrides the following restrictions:
10639 @@ -722,6 +730,9 @@ xfs_setattr(
10640 * Change the ownerships and register quota modifications
10641 * in the transaction.
10643 + if (itag != tag) {
10644 + ip->i_d.di_tag = tag;
10647 if (XFS_IS_UQUOTA_ON(mp)) {
10648 ASSERT(mask & XFS_AT_UID);
10649 @@ -802,6 +813,10 @@ xfs_setattr(
10650 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
10651 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
10652 di_flags |= XFS_DIFLAG_IMMUTABLE;
10653 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
10654 + di_flags |= XFS_DIFLAG_IUNLINK;
10655 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
10656 + di_flags |= XFS_DIFLAG_BARRIER;
10657 if (vap->va_xflags & XFS_XFLAG_APPEND)
10658 di_flags |= XFS_DIFLAG_APPEND;
10659 if (vap->va_xflags & XFS_XFLAG_SYNC)
10660 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
10661 --- linux-2.6.22.10/include/asm-alpha/socket.h 2007-07-09 13:19:35 +0200
10662 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-alpha/socket.h 2007-08-05 20:53:13 +0200
10664 #define SO_TIMESTAMPNS 35
10665 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10667 +#define SO_PEERTAG 36
10669 /* Security levels - as per NRL IPv6 - don't actually do anything */
10670 #define SO_SECURITY_AUTHENTICATION 19
10671 #define SO_SECURITY_ENCRYPTION_TRANSPORT 20
10672 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
10673 --- linux-2.6.22.10/include/asm-arm/socket.h 2007-07-09 13:19:39 +0200
10674 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm/socket.h 2007-08-05 20:53:13 +0200
10676 #define SO_TIMESTAMPNS 35
10677 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10679 +#define SO_PEERTAG 36
10681 #endif /* _ASM_SOCKET_H */
10682 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
10683 --- linux-2.6.22.10/include/asm-arm/tlb.h 2006-06-18 04:54:58 +0200
10684 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm/tlb.h 2007-08-05 20:53:13 +0200
10686 #else /* !CONFIG_MMU */
10688 #include <asm/pgalloc.h>
10689 +#include <linux/vs_memory.h>
10692 * TLB handling. This allows us to remove pages from the page
10693 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
10694 --- linux-2.6.22.10/include/asm-arm26/tlb.h 2006-01-03 17:30:02 +0100
10695 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm26/tlb.h 2007-08-05 20:53:13 +0200
10698 #include <asm/pgalloc.h>
10699 #include <asm/tlbflush.h>
10700 +#include <linux/vs_memory.h>
10703 * TLB handling. This allows us to remove pages from the page
10704 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
10705 --- linux-2.6.22.10/include/asm-arm26/unistd.h 2007-02-06 03:01:35 +0100
10706 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-arm26/unistd.h 2007-08-05 20:53:13 +0200
10707 @@ -302,6 +302,8 @@
10708 #define __NR_mq_getsetattr (__NR_SYSCALL_BASE+279)
10709 #define __NR_waitid (__NR_SYSCALL_BASE+280)
10711 +#define __NR_vserver (__NR_SYSCALL_BASE+313)
10714 * The following SWIs are ARM private. FIXME - make appropriate for arm26
10716 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
10717 --- linux-2.6.22.10/include/asm-cris/socket.h 2007-07-09 13:19:40 +0200
10718 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-cris/socket.h 2007-08-05 20:53:13 +0200
10720 #define SO_TIMESTAMPNS 35
10721 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10723 +#define SO_PEERTAG 36
10725 #endif /* _ASM_SOCKET_H */
10728 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
10729 --- linux-2.6.22.10/include/asm-frv/socket.h 2007-07-09 13:19:40 +0200
10730 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-frv/socket.h 2007-08-05 20:53:13 +0200
10732 #define SO_TIMESTAMPNS 35
10733 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10735 +#define SO_PEERTAG 36
10737 #endif /* _ASM_SOCKET_H */
10739 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
10740 --- linux-2.6.22.10/include/asm-generic/tlb.h 2006-11-30 21:19:31 +0100
10741 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-generic/tlb.h 2007-08-05 20:53:13 +0200
10743 #define _ASM_GENERIC__TLB_H
10745 #include <linux/swap.h>
10746 +#include <linux/vs_memory.h>
10747 #include <asm/pgalloc.h>
10748 #include <asm/tlbflush.h>
10750 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
10751 --- linux-2.6.22.10/include/asm-h8300/socket.h 2007-07-09 13:19:40 +0200
10752 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-h8300/socket.h 2007-08-05 20:53:13 +0200
10754 #define SO_TIMESTAMPNS 35
10755 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10757 +#define SO_PEERTAG 36
10759 #endif /* _ASM_SOCKET_H */
10760 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
10761 --- linux-2.6.22.10/include/asm-i386/socket.h 2007-07-09 13:19:42 +0200
10762 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-i386/socket.h 2007-08-05 20:53:13 +0200
10764 #define SO_TIMESTAMPNS 35
10765 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10767 +#define SO_PEERTAG 36
10769 #endif /* _ASM_SOCKET_H */
10770 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
10771 --- linux-2.6.22.10/include/asm-ia64/socket.h 2007-07-09 13:19:43 +0200
10772 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-ia64/socket.h 2007-08-05 20:53:13 +0200
10774 #define SO_TIMESTAMPNS 35
10775 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10777 +#define SO_PEERTAG 36
10779 #endif /* _ASM_IA64_SOCKET_H */
10780 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
10781 --- linux-2.6.22.10/include/asm-ia64/tlb.h 2006-09-20 16:58:40 +0200
10782 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-ia64/tlb.h 2007-08-05 20:53:13 +0200
10784 #include <linux/mm.h>
10785 #include <linux/pagemap.h>
10786 #include <linux/swap.h>
10787 +#include <linux/vs_memory.h>
10789 #include <asm/pgalloc.h>
10790 #include <asm/processor.h>
10791 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
10792 --- linux-2.6.22.10/include/asm-m32r/socket.h 2007-07-09 13:19:43 +0200
10793 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-m32r/socket.h 2007-08-05 20:53:13 +0200
10795 #define SO_TIMESTAMPNS 35
10796 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10798 +#define SO_PEERTAG 36
10800 #endif /* _ASM_M32R_SOCKET_H */
10801 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
10802 --- linux-2.6.22.10/include/asm-mips/socket.h 2007-07-09 13:19:44 +0200
10803 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-mips/socket.h 2007-08-05 20:53:13 +0200
10804 @@ -73,6 +73,8 @@ To add: #define SO_REUSEPORT 0x0200 /* A
10805 #define SO_TIMESTAMPNS 35
10806 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10808 +#define SO_PEERTAG 36
10812 /** sock_type - Socket types
10813 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
10814 --- linux-2.6.22.10/include/asm-parisc/socket.h 2007-07-09 13:19:44 +0200
10815 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-parisc/socket.h 2007-08-05 20:53:13 +0200
10818 #define SO_PEERSEC 0x401d
10819 #define SO_PASSSEC 0x401e
10820 +#define SO_PEERTAG 0x401f
10822 #endif /* _ASM_SOCKET_H */
10823 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
10824 --- linux-2.6.22.10/include/asm-powerpc/socket.h 2007-07-09 13:19:44 +0200
10825 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/socket.h 2007-08-05 20:53:13 +0200
10827 #define SO_TIMESTAMPNS 35
10828 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10830 +#define SO_PEERTAG 36
10832 #endif /* _ASM_POWERPC_SOCKET_H */
10833 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
10834 --- linux-2.6.22.10/include/asm-powerpc/systbl.h 2007-07-09 13:19:44 +0200
10835 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/systbl.h 2007-08-05 20:53:13 +0200
10836 @@ -260,7 +260,7 @@ COMPAT_SYS_SPU(fstatfs64)
10837 SYSX(sys_ni_syscall, ppc_fadvise64_64, ppc_fadvise64_64)
10839 OLDSYS(debug_setcontext)
10840 -SYSCALL(ni_syscall)
10841 +SYSX(sys_vserver, sys32_vserver, sys_vserver)
10842 COMPAT_SYS(migrate_pages)
10844 COMPAT_SYS(get_mempolicy)
10845 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
10846 --- linux-2.6.22.10/include/asm-powerpc/unistd.h 2007-07-09 13:19:45 +0200
10847 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-powerpc/unistd.h 2007-08-05 20:53:13 +0200
10848 @@ -275,7 +275,7 @@
10850 #define __NR_rtas 255
10851 #define __NR_sys_debug_setcontext 256
10852 -/* Number 257 is reserved for vserver */
10853 +#define __NR_vserver 257
10854 #define __NR_migrate_pages 258
10855 #define __NR_mbind 259
10856 #define __NR_get_mempolicy 260
10857 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
10858 --- linux-2.6.22.10/include/asm-s390/socket.h 2007-07-09 13:19:45 +0200
10859 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-s390/socket.h 2007-08-05 20:53:13 +0200
10861 #define SO_TIMESTAMPNS 35
10862 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10864 +#define SO_PEERTAG 36
10866 #endif /* _ASM_SOCKET_H */
10867 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
10868 --- linux-2.6.22.10/include/asm-s390/unistd.h 2007-07-09 13:19:45 +0200
10869 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-s390/unistd.h 2007-08-05 20:53:13 +0200
10870 @@ -202,7 +202,7 @@
10871 #define __NR_clock_gettime (__NR_timer_create+6)
10872 #define __NR_clock_getres (__NR_timer_create+7)
10873 #define __NR_clock_nanosleep (__NR_timer_create+8)
10874 -/* Number 263 is reserved for vserver */
10875 +#define __NR_vserver 263
10876 #define __NR_statfs64 265
10877 #define __NR_fstatfs64 266
10878 #define __NR_remap_file_pages 267
10879 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
10880 --- linux-2.6.22.10/include/asm-sh/socket.h 2007-07-09 13:19:45 +0200
10881 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sh/socket.h 2007-08-05 20:53:13 +0200
10883 #define SO_TIMESTAMPNS 35
10884 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10886 +#define SO_PEERTAG 36
10888 #endif /* __ASM_SH_SOCKET_H */
10889 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
10890 --- linux-2.6.22.10/include/asm-sparc/socket.h 2007-07-09 13:19:54 +0200
10891 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc/socket.h 2007-08-05 20:53:13 +0200
10893 #define SO_TIMESTAMPNS 0x0021
10894 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10896 +#define SO_PEERTAG 36
10898 /* Security levels - as per NRL IPv6 - don't actually do anything */
10899 #define SO_SECURITY_AUTHENTICATION 0x5001
10900 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
10901 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
10902 --- linux-2.6.22.10/include/asm-sparc/unistd.h 2007-07-09 13:19:54 +0200
10903 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc/unistd.h 2007-08-05 20:53:13 +0200
10904 @@ -283,7 +283,7 @@
10905 #define __NR_timer_getoverrun 264
10906 #define __NR_timer_delete 265
10907 #define __NR_timer_create 266
10908 -/* #define __NR_vserver 267 Reserved for VSERVER */
10909 +#define __NR_vserver 267
10910 #define __NR_io_setup 268
10911 #define __NR_io_destroy 269
10912 #define __NR_io_submit 270
10913 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
10914 --- linux-2.6.22.10/include/asm-sparc64/socket.h 2007-07-09 13:19:54 +0200
10915 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/socket.h 2007-08-05 20:53:13 +0200
10917 #define SO_TIMESTAMPNS 0x0021
10918 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10920 +#define SO_PEERTAG 0x0022
10922 /* Security levels - as per NRL IPv6 - don't actually do anything */
10923 #define SO_SECURITY_AUTHENTICATION 0x5001
10924 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
10925 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
10926 --- linux-2.6.22.10/include/asm-sparc64/tlb.h 2007-07-09 13:19:54 +0200
10927 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/tlb.h 2007-08-05 20:53:13 +0200
10930 #include <linux/swap.h>
10931 #include <linux/pagemap.h>
10932 +#include <linux/vs_memory.h>
10933 #include <asm/pgalloc.h>
10934 #include <asm/tlbflush.h>
10935 #include <asm/mmu_context.h>
10936 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
10937 --- linux-2.6.22.10/include/asm-sparc64/unistd.h 2007-07-09 13:19:54 +0200
10938 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-sparc64/unistd.h 2007-08-05 20:53:13 +0200
10939 @@ -285,7 +285,7 @@
10940 #define __NR_timer_getoverrun 264
10941 #define __NR_timer_delete 265
10942 #define __NR_timer_create 266
10943 -/* #define __NR_vserver 267 Reserved for VSERVER */
10944 +#define __NR_vserver 267
10945 #define __NR_io_setup 268
10946 #define __NR_io_destroy 269
10947 #define __NR_io_submit 270
10948 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
10949 --- linux-2.6.22.10/include/asm-v850/socket.h 2007-07-09 13:19:55 +0200
10950 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-v850/socket.h 2007-08-05 20:53:13 +0200
10952 #define SO_TIMESTAMPNS 35
10953 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10955 +#define SO_PEERTAG 36
10957 #endif /* __V850_SOCKET_H__ */
10958 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
10959 --- linux-2.6.22.10/include/asm-x86_64/socket.h 2007-07-09 13:19:55 +0200
10960 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-x86_64/socket.h 2007-08-05 20:53:13 +0200
10962 #define SO_TIMESTAMPNS 35
10963 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10965 +#define SO_PEERTAG 36
10967 #endif /* _ASM_SOCKET_H */
10968 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
10969 --- linux-2.6.22.10/include/asm-x86_64/unistd.h 2007-07-09 13:19:55 +0200
10970 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-x86_64/unistd.h 2007-08-05 20:53:13 +0200
10971 @@ -532,7 +532,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
10972 #define __NR_utimes 235
10973 __SYSCALL(__NR_utimes, sys_utimes)
10974 #define __NR_vserver 236
10975 -__SYSCALL(__NR_vserver, sys_ni_syscall)
10976 +__SYSCALL(__NR_vserver, sys_vserver)
10977 #define __NR_mbind 237
10978 __SYSCALL(__NR_mbind, sys_mbind)
10979 #define __NR_set_mempolicy 238
10980 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
10981 --- linux-2.6.22.10/include/asm-xtensa/socket.h 2007-07-09 13:19:55 +0200
10982 +++ linux-2.6.22.10-vs2.3.0.29/include/asm-xtensa/socket.h 2007-08-05 20:53:13 +0200
10984 #define SO_TIMESTAMPNS 35
10985 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
10987 +#define SO_PEERTAG 36
10989 #endif /* _XTENSA_SOCKET_H */
10990 diff -NurpP --minimal linux-2.6.22.10/include/linux/Kbuild linux-2.6.22.10-vs2.3.0.29/include/linux/Kbuild
10991 --- linux-2.6.22.10/include/linux/Kbuild 2007-10-30 01:57:14 +0100
10992 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/Kbuild 2007-09-30 14:58:01 +0200
10993 @@ -351,3 +351,6 @@ unifdef-y += xattr.h
10994 unifdef-y += xfrm.h
10996 objhdr-y += version.h
10998 +header-y += vserver/
11000 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
11001 --- linux-2.6.22.10/include/linux/capability.h 2007-07-09 13:19:55 +0200
11002 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/capability.h 2007-08-05 20:53:13 +0200
11003 @@ -237,6 +237,7 @@ typedef __u32 kernel_cap_t;
11004 arbitrary SCSI commands */
11005 /* Allow setting encryption key on loopback filesystem */
11006 /* Allow setting zone reclaim policy */
11007 +/* Allow the selection of a security context */
11009 #define CAP_SYS_ADMIN 21
11011 @@ -290,6 +291,11 @@ typedef __u32 kernel_cap_t;
11013 #define CAP_AUDIT_CONTROL 30
11015 +/* Allow context manipulations */
11016 +/* Allow changing context info on files */
11018 +#define CAP_CONTEXT 31
11023 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
11024 --- linux-2.6.22.10/include/linux/devpts_fs.h 2004-08-14 12:55:59 +0200
11025 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/devpts_fs.h 2007-10-06 18:19:52 +0200
11026 @@ -30,5 +30,4 @@ static inline void devpts_pty_kill(int n
11031 #endif /* _LINUX_DEVPTS_FS_H */
11032 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
11033 --- linux-2.6.22.10/include/linux/ext2_fs.h 2006-11-30 21:19:37 +0100
11034 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ext2_fs.h 2007-10-05 15:07:22 +0200
11035 @@ -188,6 +188,8 @@ struct ext2_group_desc
11036 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
11037 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
11038 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
11039 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
11040 +#define EXT2_IUNLINK_FL FS_IUNLINK_FL /* Immutable unlink */
11041 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
11043 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
11044 @@ -244,7 +246,7 @@ struct ext2_inode {
11046 __u8 l_i_frag; /* Fragment number */
11047 __u8 l_i_fsize; /* Fragment size */
11049 + __u16 l_i_tag; /* Context Tag */
11050 __le16 l_i_uid_high; /* these 2 fields */
11051 __le16 l_i_gid_high; /* were reserved2[0] */
11052 __u32 l_i_reserved2;
11053 @@ -276,6 +278,7 @@ struct ext2_inode {
11054 #define i_gid_low i_gid
11055 #define i_uid_high osd2.linux2.l_i_uid_high
11056 #define i_gid_high osd2.linux2.l_i_gid_high
11057 +#define i_raw_tag osd2.linux2.l_i_tag
11058 #define i_reserved2 osd2.linux2.l_i_reserved2
11061 @@ -317,8 +320,9 @@ struct ext2_inode {
11062 #define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */
11063 #define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */
11064 #define EXT2_MOUNT_XIP 0x010000 /* Execute in place */
11065 -#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
11066 -#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
11067 +#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
11068 +#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
11069 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11072 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
11073 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
11074 --- linux-2.6.22.10/include/linux/ext3_fs.h 2007-07-09 13:19:56 +0200
11075 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ext3_fs.h 2007-08-05 20:53:13 +0200
11076 @@ -177,6 +177,8 @@ struct ext3_group_desc
11077 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
11078 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
11079 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11080 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11081 +#define EXT3_IUNLINK_FL 0x08000000 /* Immutable unlink */
11082 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
11084 #define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
11085 @@ -296,7 +298,7 @@ struct ext3_inode {
11087 __u8 l_i_frag; /* Fragment number */
11088 __u8 l_i_fsize; /* Fragment size */
11090 + __u16 l_i_tag; /* Context Tag */
11091 __le16 l_i_uid_high; /* these 2 fields */
11092 __le16 l_i_gid_high; /* were reserved2[0] */
11093 __u32 l_i_reserved2;
11094 @@ -330,6 +332,7 @@ struct ext3_inode {
11095 #define i_gid_low i_gid
11096 #define i_uid_high osd2.linux2.l_i_uid_high
11097 #define i_gid_high osd2.linux2.l_i_gid_high
11098 +#define i_raw_tag osd2.linux2.l_i_tag
11099 #define i_reserved2 osd2.linux2.l_i_reserved2
11101 #elif defined(__GNU__)
11102 @@ -384,6 +387,7 @@ struct ext3_inode {
11103 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
11104 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
11105 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
11106 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11108 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
11109 #ifndef _LINUX_EXT2_FS_H
11110 @@ -812,6 +816,7 @@ struct buffer_head * ext3_bread (handle_
11111 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
11112 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
11113 int create, int extend_disksize);
11114 +extern int ext3_sync_flags(struct inode *inode);
11116 extern void ext3_read_inode (struct inode *);
11117 extern int ext3_write_inode (struct inode *, int);
11118 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
11119 --- linux-2.6.22.10/include/linux/ext4_fs.h 2007-07-09 13:19:56 +0200
11120 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ext4_fs.h 2007-08-05 20:53:13 +0200
11121 @@ -189,8 +189,10 @@ struct ext4_group_desc
11122 #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
11123 #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
11124 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11125 -#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
11126 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
11127 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11128 +#define EXT4_IUNLINK_FL 0x08000000 /* Immutable unlink */
11129 +#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
11131 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
11132 #define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
11133 @@ -312,7 +314,8 @@ struct ext4_inode {
11134 __le16 l_i_file_acl_high;
11135 __le16 l_i_uid_high; /* these 2 fields */
11136 __le16 l_i_gid_high; /* were reserved2[0] */
11137 - __u32 l_i_reserved2;
11138 + __u16 l_i_tag; /* Context Tag */
11139 + __u16 l_i_reserved2;
11142 __u8 h_i_frag; /* Fragment number */
11143 @@ -344,6 +347,7 @@ struct ext4_inode {
11144 #define i_gid_low i_gid
11145 #define i_uid_high osd2.linux2.l_i_uid_high
11146 #define i_gid_high osd2.linux2.l_i_gid_high
11147 +#define i_raw_tag osd2.linux2.l_i_tag
11148 #define i_reserved2 osd2.linux2.l_i_reserved2
11150 #elif defined(__GNU__)
11151 @@ -400,6 +404,7 @@ struct ext4_inode {
11152 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
11153 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
11154 #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
11155 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11157 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
11158 #ifndef _LINUX_EXT2_FS_H
11159 @@ -850,6 +855,7 @@ struct buffer_head * ext4_bread (handle_
11160 int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
11161 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
11162 int create, int extend_disksize);
11163 +extern int ext4_sync_flags(struct inode *inode);
11165 extern void ext4_read_inode (struct inode *);
11166 extern int ext4_write_inode (struct inode *, int);
11167 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
11168 --- linux-2.6.22.10/include/linux/fs.h 2007-07-09 13:19:56 +0200
11169 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/fs.h 2007-10-20 00:01:05 +0200
11170 @@ -123,6 +123,8 @@ extern int dir_notify_enable;
11171 #define MS_SLAVE (1<<19) /* change to slave */
11172 #define MS_SHARED (1<<20) /* change to shared */
11173 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
11174 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
11175 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
11176 #define MS_ACTIVE (1<<30)
11177 #define MS_NOUSER (1<<31)
11179 @@ -149,6 +151,8 @@ extern int dir_notify_enable;
11180 #define S_NOCMTIME 128 /* Do not update file c/mtime */
11181 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
11182 #define S_PRIVATE 512 /* Inode is fs-internal */
11183 +#define S_BARRIER 1024 /* Barrier for chroot() */
11184 +#define S_IUNLINK 2048 /* Immutable unlink */
11187 * Note that nosuid etc flags are inode-specific: setting some file-system
11188 @@ -165,24 +169,36 @@ extern int dir_notify_enable;
11190 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
11192 -#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
11193 +#define IS_RDONLY(inode) __IS_FLG(inode, MS_RDONLY)
11194 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
11195 ((inode)->i_flags & S_SYNC))
11196 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
11197 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
11198 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
11199 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
11200 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
11201 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
11203 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
11204 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
11205 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
11206 +#define IS_IUNLINK(inode) ((inode)->i_flags & S_IUNLINK)
11207 +#define IS_IXORUNLINK(inode) ((IS_IUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
11208 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
11210 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_flags & S_BARRIER))
11211 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
11212 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
11213 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
11214 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
11216 +#ifdef CONFIG_VSERVER_COWBL
11217 +# define IS_COW(inode) (IS_IUNLINK(inode) && IS_IMMUTABLE(inode))
11218 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
11220 +# define IS_COW(inode) (0)
11221 +# define IS_COW_LINK(inode) (0)
11224 /* the read-only stuff doesn't really belong here, but any other place is
11225 probably as bad and I don't want to create yet another include file. */
11227 @@ -256,12 +272,13 @@ extern int dir_notify_enable;
11228 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
11229 #define FS_EXTENT_FL 0x00080000 /* Extents */
11230 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
11231 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
11232 +#define FS_IUNLINK_FL 0x08000000 /* Immutable unlink */
11233 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
11235 #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
11236 #define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
11239 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
11240 #define SYNC_FILE_RANGE_WRITE 2
11241 #define SYNC_FILE_RANGE_WAIT_AFTER 4
11242 @@ -327,6 +344,7 @@ typedef void (dio_iodone_t)(struct kiocb
11243 #define ATTR_KILL_SUID 2048
11244 #define ATTR_KILL_SGID 4096
11245 #define ATTR_FILE 8192
11246 +#define ATTR_TAG 16384
11249 * This is the Inode Attributes structure, used for notify_change(). It
11250 @@ -342,6 +360,7 @@ struct iattr {
11256 struct timespec ia_atime;
11257 struct timespec ia_mtime;
11258 @@ -355,6 +374,9 @@ struct iattr {
11259 struct file *ia_file;
11262 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
11263 +#define ATTR_FLAG_IUNLINK 1024 /* Immutable unlink */
11266 * Includes for diskquotas.
11268 @@ -537,7 +559,9 @@ struct inode {
11269 unsigned int i_nlink;
11275 unsigned long i_version;
11277 #ifdef __NEED_I_SIZE_ORDERED
11278 @@ -672,12 +696,12 @@ static inline void i_size_write(struct i
11280 static inline unsigned iminor(const struct inode *inode)
11282 - return MINOR(inode->i_rdev);
11283 + return MINOR(inode->i_mdev);
11286 static inline unsigned imajor(const struct inode *inode)
11288 - return MAJOR(inode->i_rdev);
11289 + return MAJOR(inode->i_mdev);
11292 extern struct block_device *I_BDEV(struct inode *inode);
11293 @@ -728,6 +752,7 @@ struct file {
11295 struct fown_struct f_owner;
11296 unsigned int f_uid, f_gid;
11298 struct file_ra_state f_ra;
11300 unsigned long f_version;
11301 @@ -811,6 +836,7 @@ struct file_lock {
11302 unsigned char fl_type;
11307 struct fasync_struct * fl_fasync; /* for lease break notifications */
11308 unsigned long fl_break_time; /* for nonblocking lease breaks */
11309 @@ -993,12 +1019,12 @@ extern void unlock_super(struct super_bl
11311 extern int vfs_permission(struct nameidata *, int);
11312 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
11313 -extern int vfs_mkdir(struct inode *, struct dentry *, int);
11314 -extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
11315 -extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
11316 -extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
11317 -extern int vfs_rmdir(struct inode *, struct dentry *);
11318 -extern int vfs_unlink(struct inode *, struct dentry *);
11319 +extern int vfs_mkdir(struct inode *, struct dentry *, int, struct nameidata *);
11320 +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t, struct nameidata *);
11321 +extern int vfs_symlink(struct inode *, struct dentry *, const char *, int, struct nameidata *);
11322 +extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct nameidata *);
11323 +extern int vfs_rmdir(struct inode *, struct dentry *, struct nameidata *);
11324 +extern int vfs_unlink(struct inode *, struct dentry *, struct nameidata *);
11325 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
11328 @@ -1138,6 +1164,7 @@ struct inode_operations {
11329 ssize_t (*listxattr) (struct dentry *, char *, size_t);
11330 int (*removexattr) (struct dentry *, const char *);
11331 void (*truncate_range)(struct inode *, loff_t, loff_t);
11332 + int (*sync_flags) (struct inode *);
11336 @@ -1153,6 +1180,7 @@ extern ssize_t vfs_readv(struct file *,
11337 unsigned long, loff_t *);
11338 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
11339 unsigned long, loff_t *);
11340 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
11343 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
11344 @@ -1898,6 +1926,7 @@ extern int dcache_dir_open(struct inode
11345 extern int dcache_dir_close(struct inode *, struct file *);
11346 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
11347 extern int dcache_readdir(struct file *, void *, filldir_t);
11348 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
11349 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
11350 extern int simple_statfs(struct dentry *, struct kstatfs *);
11351 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
11352 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
11353 --- linux-2.6.22.10/include/linux/init_task.h 2007-07-09 13:19:56 +0200
11354 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/init_task.h 2007-08-05 20:53:13 +0200
11355 @@ -169,6 +169,10 @@ extern struct group_info init_groups;
11357 INIT_TRACE_IRQFLAGS \
11360 + .vx_info = NULL, \
11362 + .nx_info = NULL, \
11366 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
11367 --- linux-2.6.22.10/include/linux/ipc.h 2007-07-09 13:19:56 +0200
11368 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/ipc.h 2007-08-05 20:53:13 +0200
11369 @@ -63,6 +63,7 @@ struct kern_ipc_perm
11377 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
11378 --- linux-2.6.22.10/include/linux/jffs2.h 2006-11-30 21:19:38 +0100
11379 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/jffs2.h 2007-10-05 15:07:22 +0200
11380 @@ -82,12 +82,36 @@
11381 //#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
11384 -#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
11385 +#define JFFS2_INO_FLAG_PREREAD 0x01 /* Do read_inode() for this one at
11386 mount time, don't wait for it to
11388 -#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
11389 +#define JFFS2_INO_FLAG_USERCOMPR 0x02 /* User has requested a specific
11390 compression type */
11392 +#define JFFS2_INO_FLAG_IMMUTABLE 0x10 /* immutable node */
11393 +#define JFFS2_INO_FLAG_IUNLINK 0x20 /* immutable unlink */
11394 +#define JFFS2_INO_FLAG_BARRIER 0x40 /* barrier */
11396 +#define JFFS2_USER_VISIBLE 0x10
11397 +#define JFFS2_USER_MODIFIABLE 0x10
11402 +#define JFFS2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
11404 +#define clear_opt(o, opt) o &= ~JFFS2_MOUNT_##opt
11405 +#define set_opt(o, opt) o |= JFFS2_MOUNT_##opt
11408 + * Maximal mount counts between two filesystem checks
11410 +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
11411 +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
11414 + * Behaviour when detecting errors
11417 /* These can go once we've made sure we've caught all uses without
11419 @@ -97,7 +121,7 @@ typedef struct {
11420 } __attribute__((packed)) jint32_t;
11425 } __attribute__((packed)) jmode_t;
11428 @@ -145,7 +169,8 @@ struct jffs2_raw_inode
11430 jint32_t ino; /* Inode number. */
11431 jint32_t version; /* Version number. */
11432 - jmode_t mode; /* The file's type or mode. */
11433 + jmode_t mode; /* The file's type or mode. */
11434 + jint16_t tag; /* context tagging */
11435 jint16_t uid; /* The file's owner. */
11436 jint16_t gid; /* The file's group. */
11437 jint32_t isize; /* Total resultant size of this inode (used for truncations) */
11438 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
11439 --- linux-2.6.22.10/include/linux/loop.h 2007-07-09 13:19:56 +0200
11440 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/loop.h 2007-08-05 20:53:13 +0200
11441 @@ -45,6 +45,7 @@ struct loop_device {
11442 struct loop_func_table *lo_encryption;
11444 uid_t lo_key_owner; /* Who set the key */
11446 int (*ioctl)(struct loop_device *, int cmd,
11447 unsigned long arg);
11449 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
11450 --- linux-2.6.22.10/include/linux/magic.h 2007-07-09 13:19:56 +0200
11451 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/magic.h 2007-10-06 18:19:33 +0200
11454 #define ADFS_SUPER_MAGIC 0xadf5
11455 #define AFFS_SUPER_MAGIC 0xadff
11456 -#define AFS_SUPER_MAGIC 0x5346414F
11457 +#define AFS_SUPER_MAGIC 0x5346414F
11458 #define AUTOFS_SUPER_MAGIC 0x0187
11459 #define CODA_SUPER_MAGIC 0x73757245
11460 #define EFS_SUPER_MAGIC 0x414A53
11462 #define NFS_SUPER_MAGIC 0x6969
11463 #define OPENPROM_SUPER_MAGIC 0x9fa1
11464 #define PROC_SUPER_MAGIC 0x9fa0
11465 +#define DEVPTS_SUPER_MAGIC 0x1cd1
11466 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
11468 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
11469 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
11470 --- linux-2.6.22.10/include/linux/major.h 2007-07-09 13:19:56 +0200
11471 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/major.h 2007-08-05 20:53:13 +0200
11473 #define HD_MAJOR IDE0_MAJOR
11474 #define PTY_SLAVE_MAJOR 3
11475 #define TTY_MAJOR 4
11476 +#define VROOT_MAJOR 4
11477 #define TTYAUX_MAJOR 5
11479 #define VCS_MAJOR 7
11480 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
11481 --- linux-2.6.22.10/include/linux/mount.h 2007-07-09 13:19:56 +0200
11482 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/mount.h 2007-09-05 02:29:04 +0200
11483 @@ -28,6 +28,9 @@ struct mnt_namespace;
11484 #define MNT_NOATIME 0x08
11485 #define MNT_NODIRATIME 0x10
11486 #define MNT_RELATIME 0x20
11487 +#define MNT_RDONLY 0x40
11489 +#define MNT_IS_RDONLY(m) ((m) && ((m)->mnt_flags & MNT_RDONLY))
11491 #define MNT_SHRINKABLE 0x100
11493 @@ -35,6 +38,10 @@ struct mnt_namespace;
11494 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
11495 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
11497 +#define MNT_TAGID 0x10000
11498 +#define MNT_NOTAG 0x20000
11499 +#define MNT_NOTAGCHECK 0x40000
11502 struct list_head mnt_hash;
11503 struct vfsmount *mnt_parent; /* fs we are mounted on */
11504 @@ -61,6 +68,7 @@ struct vfsmount {
11505 atomic_t mnt_count;
11506 int mnt_expiry_mark; /* true if marked for expiry */
11508 + tag_t mnt_tag; /* tagging used for vfsmount */
11511 static inline struct vfsmount *mntget(struct vfsmount *mnt)
11512 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
11513 --- linux-2.6.22.10/include/linux/net.h 2007-07-09 13:19:56 +0200
11514 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/net.h 2007-08-05 20:53:13 +0200
11515 @@ -63,6 +63,7 @@ typedef enum {
11516 #define SOCK_NOSPACE 2
11517 #define SOCK_PASSCRED 3
11518 #define SOCK_PASSSEC 4
11519 +#define SOCK_USER_SOCKET 5
11521 #ifndef ARCH_HAS_SOCKET_TYPES
11523 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
11524 --- linux-2.6.22.10/include/linux/nfs_mount.h 2007-07-09 13:20:00 +0200
11525 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/nfs_mount.h 2007-08-05 20:53:13 +0200
11526 @@ -62,6 +62,7 @@ struct nfs_mount_data {
11527 #define NFS_MOUNT_STRICTLOCK 0x1000 /* reserved for NFSv4 */
11528 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
11529 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
11530 +#define NFS_MOUNT_TAGGED 0x8000 /* context tagging */
11531 #define NFS_MOUNT_FLAGMASK 0xFFFF
11534 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
11535 --- linux-2.6.22.10/include/linux/nsproxy.h 2007-07-09 13:20:00 +0200
11536 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/nsproxy.h 2007-08-05 20:53:13 +0200
11539 #include <linux/spinlock.h>
11540 #include <linux/sched.h>
11541 +#include <linux/vserver/debug.h>
11543 struct mnt_namespace;
11544 struct uts_namespace;
11545 @@ -32,26 +33,46 @@ struct nsproxy {
11546 extern struct nsproxy init_nsproxy;
11548 int copy_namespaces(int flags, struct task_struct *tsk);
11549 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
11550 void get_task_namespaces(struct task_struct *tsk);
11551 void free_nsproxy(struct nsproxy *ns);
11552 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
11553 struct fs_struct *);
11555 -static inline void put_nsproxy(struct nsproxy *ns)
11556 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
11558 +static inline void __get_nsproxy(struct nsproxy *ns,
11559 + const char *_file, int _line)
11561 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
11562 + ns, atomic_read(&ns->count), _file, _line);
11563 + atomic_inc(&ns->count);
11566 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
11568 +static inline void __put_nsproxy(struct nsproxy *ns,
11569 + const char *_file, int _line)
11571 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
11572 + ns, atomic_read(&ns->count), _file, _line);
11573 if (atomic_dec_and_test(&ns->count)) {
11578 -static inline void exit_task_namespaces(struct task_struct *p)
11579 +#define exit_task_namespaces(p) __exit_task_namespaces(p, __FILE__, __LINE__)
11581 +static inline void __exit_task_namespaces(struct task_struct *p,
11582 + const char *_file, int _line)
11584 struct nsproxy *ns = p->nsproxy;
11590 + __put_nsproxy(ns, _file, _line);
11595 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
11596 --- linux-2.6.22.10/include/linux/pid.h 2007-07-09 13:20:00 +0200
11597 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/pid.h 2007-08-05 20:53:13 +0200
11598 @@ -8,7 +8,8 @@ enum pid_type
11608 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
11609 --- linux-2.6.22.10/include/linux/proc_fs.h 2007-07-09 13:20:00 +0200
11610 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/proc_fs.h 2007-08-05 20:53:13 +0200
11611 @@ -54,6 +54,7 @@ struct proc_dir_entry {
11617 const struct inode_operations *proc_iops;
11618 const struct file_operations *proc_fops;
11619 @@ -246,13 +247,20 @@ static inline void kclist_add(struct kco
11620 extern void kclist_add(struct kcore_list *, void *, size_t);
11627 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
11628 int (*proc_read)(struct task_struct *task, char *page);
11629 + int (*proc_vs_read)(char *page);
11630 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
11631 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
11634 struct proc_inode {
11639 struct proc_dir_entry *pde;
11640 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
11641 --- linux-2.6.22.10/include/linux/reiserfs_fs.h 2007-05-02 19:25:34 +0200
11642 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/reiserfs_fs.h 2007-08-05 20:53:13 +0200
11643 @@ -821,6 +821,10 @@ struct stat_data_v1 {
11644 #define REISERFS_COMPR_FL FS_COMPR_FL
11645 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
11647 +/* unfortunately reiserfs sdattr is only 16 bit */
11648 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
11649 +#define REISERFS_IUNLINK_FL (FS_IUNLINK_FL >> 16)
11651 /* persistent flags that file inherits from the parent directory */
11652 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
11653 REISERFS_SYNC_FL | \
11654 @@ -830,6 +834,9 @@ struct stat_data_v1 {
11655 REISERFS_COMPR_FL | \
11656 REISERFS_NOTAIL_FL )
11658 +#define REISERFS_FL_USER_VISIBLE 0x80FF
11659 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
11661 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
11664 @@ -1901,6 +1908,7 @@ static inline void reiserfs_update_sd(st
11665 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
11666 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
11667 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
11668 +int reiserfs_sync_flags(struct inode *inode);
11671 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
11672 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
11673 --- linux-2.6.22.10/include/linux/reiserfs_fs_sb.h 2007-07-09 13:20:00 +0200
11674 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/reiserfs_fs_sb.h 2007-08-05 20:53:13 +0200
11675 @@ -458,6 +458,7 @@ enum reiserfs_mount_options {
11677 REISERFS_BARRIER_NONE,
11678 REISERFS_BARRIER_FLUSH,
11681 /* Actions on error */
11682 REISERFS_ERROR_PANIC,
11683 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
11684 --- linux-2.6.22.10/include/linux/sched.h 2007-07-09 13:20:01 +0200
11685 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sched.h 2007-10-04 23:47:06 +0200
11687 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
11688 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
11689 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
11690 +#define CLONE_KTHREAD 0x10000000 /* clone a kernel thread */
11693 * Scheduling policies
11694 @@ -94,7 +95,7 @@ struct bio;
11695 * List of flags we want to share for kernel threads,
11696 * if only because they are not used by them anyway.
11698 -#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
11699 +#define CLONE_KERNEL (CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_KTHREAD)
11702 * These are the constant used to fake the fixed-point load-average
11703 @@ -146,12 +147,13 @@ extern unsigned long weighted_cpuload(co
11704 #define TASK_UNINTERRUPTIBLE 2
11705 #define TASK_STOPPED 4
11706 #define TASK_TRACED 8
11707 +#define TASK_ONHOLD 16
11708 /* in tsk->exit_state */
11709 -#define EXIT_ZOMBIE 16
11710 -#define EXIT_DEAD 32
11711 +#define EXIT_ZOMBIE 32
11712 +#define EXIT_DEAD 64
11713 /* in tsk->state again */
11714 -#define TASK_NONINTERACTIVE 64
11715 -#define TASK_DEAD 128
11716 +#define TASK_NONINTERACTIVE 128
11717 +#define TASK_DEAD 256
11719 #define __set_task_state(tsk, state_value) \
11720 do { (tsk)->state = (state_value); } while (0)
11721 @@ -287,27 +289,30 @@ extern void arch_unmap_area_topdown(stru
11722 * The mm counters are not protected by its page_table_lock,
11723 * so must be incremented atomically.
11725 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
11726 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
11727 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
11728 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
11729 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
11730 typedef atomic_long_t mm_counter_t;
11731 +#define __set_mm_counter(mm, member, value) \
11732 + atomic_long_set(&(mm)->_##member, value)
11733 +#define get_mm_counter(mm, member) \
11734 + ((unsigned long)atomic_long_read(&(mm)->_##member))
11736 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11738 * The mm counters are protected by its page_table_lock,
11739 * so can be incremented directly.
11741 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
11742 -#define get_mm_counter(mm, member) ((mm)->_##member)
11743 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
11744 -#define inc_mm_counter(mm, member) (mm)->_##member++
11745 -#define dec_mm_counter(mm, member) (mm)->_##member--
11746 typedef unsigned long mm_counter_t;
11747 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
11748 +#define get_mm_counter(mm, member) ((mm)->_##member)
11750 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11752 +#define set_mm_counter(mm, member, value) \
11753 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
11754 +#define add_mm_counter(mm, member, value) \
11755 + vx_ ## member ## pages_add((mm), (value))
11756 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
11757 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
11759 #define get_mm_rss(mm) \
11760 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
11761 #define update_hiwater_rss(mm) do { \
11762 @@ -365,6 +370,7 @@ struct mm_struct {
11764 /* Architecture-specific MM context */
11765 mm_context_t context;
11766 + struct vx_info *mm_vx_info;
11768 /* Swap token stuff */
11770 @@ -570,9 +576,10 @@ struct user_struct {
11771 /* Hash table maintenance information */
11772 struct list_head uidhash_list;
11777 -extern struct user_struct *find_user(uid_t);
11778 +extern struct user_struct *find_user(xid_t, uid_t);
11780 extern struct user_struct root_user;
11781 #define INIT_USER (&root_user)
11782 @@ -969,6 +976,15 @@ struct task_struct {
11785 struct audit_context *audit_context;
11787 +/* vserver context data */
11788 + struct vx_info *vx_info;
11789 + struct nx_info *nx_info;
11797 /* Thread group tracking */
11798 @@ -1290,12 +1306,16 @@ extern struct task_struct init_task;
11800 extern struct mm_struct init_mm;
11802 -#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr)
11803 +#define find_task_by_real_pid(nr) \
11804 + find_task_by_pid_type(PIDTYPE_REALPID, nr)
11805 +#define find_task_by_pid(nr) \
11806 + find_task_by_pid_type(PIDTYPE_PID, nr)
11808 extern struct task_struct *find_task_by_pid_type(int type, int pid);
11809 extern void __set_special_pids(pid_t session, pid_t pgrp);
11811 /* per-UID process charging. */
11812 -extern struct user_struct * alloc_uid(uid_t);
11813 +extern struct user_struct * alloc_uid(xid_t, uid_t);
11814 static inline struct user_struct *get_uid(struct user_struct *u)
11816 atomic_inc(&u->__count);
11817 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
11818 --- linux-2.6.22.10/include/linux/shmem_fs.h 2006-11-30 21:19:39 +0100
11819 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/shmem_fs.h 2007-08-05 20:53:13 +0200
11822 #define SHMEM_NR_DIRECT 16
11824 +#define TMPFS_SUPER_MAGIC 0x01021994
11827 struct shmem_inode_info {
11829 unsigned long flags;
11830 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
11831 --- linux-2.6.22.10/include/linux/stat.h 2007-07-09 13:20:01 +0200
11832 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/stat.h 2007-08-05 20:53:13 +0200
11833 @@ -66,6 +66,7 @@ struct kstat {
11834 unsigned int nlink;
11840 struct timespec atime;
11841 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
11842 --- linux-2.6.22.10/include/linux/sunrpc/auth.h 2006-11-30 21:19:40 +0100
11843 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sunrpc/auth.h 2007-08-05 20:53:13 +0200
11849 struct group_info *group_info;
11852 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
11853 --- linux-2.6.22.10/include/linux/sunrpc/clnt.h 2007-07-09 13:20:01 +0200
11854 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sunrpc/clnt.h 2007-08-05 20:53:13 +0200
11855 @@ -43,7 +43,8 @@ struct rpc_clnt {
11856 cl_discrtry : 1,/* disconnect before retry */
11857 cl_autobind : 1,/* use getport() */
11858 cl_oneshot : 1,/* dispose after use */
11859 - cl_dead : 1;/* abandoned */
11860 + cl_dead : 1,/* abandoned */
11861 + cl_tag : 1;/* context tagging */
11863 struct rpc_rtt * cl_rtt; /* RTO estimator data */
11865 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
11866 --- linux-2.6.22.10/include/linux/syscalls.h 2007-07-09 13:20:01 +0200
11867 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/syscalls.h 2007-08-05 20:53:13 +0200
11868 @@ -294,6 +294,8 @@ asmlinkage long sys_symlink(const char _
11869 asmlinkage long sys_unlink(const char __user *pathname);
11870 asmlinkage long sys_rename(const char __user *oldname,
11871 const char __user *newname);
11872 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
11874 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
11875 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
11877 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
11878 --- linux-2.6.22.10/include/linux/sysctl.h 2007-07-09 13:20:01 +0200
11879 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sysctl.h 2007-08-05 20:53:13 +0200
11880 @@ -106,6 +106,7 @@ enum
11881 KERN_CAP_BSET=14, /* int: capability bounding set */
11882 KERN_PANIC=15, /* int: panic timeout */
11883 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
11884 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
11886 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
11887 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
11888 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
11889 --- linux-2.6.22.10/include/linux/sysfs.h 2007-07-09 13:20:01 +0200
11890 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/sysfs.h 2007-08-05 20:53:13 +0200
11892 #include <linux/list.h>
11893 #include <asm/atomic.h>
11895 +#define SYSFS_SUPER_MAGIC 0x62656572
11900 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
11901 --- linux-2.6.22.10/include/linux/time.h 2007-07-09 13:20:01 +0200
11902 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/time.h 2007-08-05 20:53:13 +0200
11903 @@ -176,6 +176,9 @@ static inline void timespec_add_ns(struc
11908 +#include <linux/vs_time.h>
11910 #endif /* __KERNEL__ */
11912 #define NFDBITS __NFDBITS
11913 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
11914 --- linux-2.6.22.10/include/linux/types.h 2007-02-06 03:01:52 +0100
11915 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/types.h 2007-08-05 20:53:13 +0200
11916 @@ -39,6 +39,9 @@ typedef __kernel_uid32_t uid_t;
11917 typedef __kernel_gid32_t gid_t;
11918 typedef __kernel_uid16_t uid16_t;
11919 typedef __kernel_gid16_t gid16_t;
11920 +typedef unsigned int xid_t;
11921 +typedef unsigned int nid_t;
11922 +typedef unsigned int tag_t;
11924 #ifdef CONFIG_UID16
11925 /* This is defined by include/asm-{arch}/posix_types.h */
11926 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
11927 --- linux-2.6.22.10/include/linux/vroot.h 1970-01-01 01:00:00 +0100
11928 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vroot.h 2007-08-05 20:53:13 +0200
11932 + * include/linux/vroot.h
11934 + * written by Herbert Pötzl, 9/11/2002
11935 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
11937 + * Copyright (C) 2002-2007 by Herbert Pötzl.
11938 + * Redistribution of this file is permitted under the
11939 + * GNU General Public License.
11942 +#ifndef _LINUX_VROOT_H
11943 +#define _LINUX_VROOT_H
11948 +/* Possible states of device */
11954 +struct vroot_device {
11958 + struct semaphore vr_ctl_mutex;
11959 + struct block_device *vr_device;
11964 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
11966 +extern int register_vroot_grb(vroot_grb_func *);
11967 +extern int unregister_vroot_grb(vroot_grb_func *);
11969 +#endif /* __KERNEL__ */
11971 +#define MAX_VROOT_DEFAULT 8
11974 + * IOCTL commands --- we will commandeer 0x56 ('V')
11977 +#define VROOT_SET_DEV 0x5600
11978 +#define VROOT_CLR_DEV 0x5601
11980 +#endif /* _LINUX_VROOT_H */
11981 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
11982 --- linux-2.6.22.10/include/linux/vs_base.h 1970-01-01 01:00:00 +0100
11983 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_base.h 2007-08-05 20:53:13 +0200
11985 +#ifndef _VS_BASE_H
11986 +#define _VS_BASE_H
11988 +#include "vserver/base.h"
11989 +#include "vserver/debug.h"
11992 +#warning duplicate inclusion
11994 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
11995 --- linux-2.6.22.10/include/linux/vs_context.h 1970-01-01 01:00:00 +0100
11996 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_context.h 2007-10-01 14:57:41 +0200
11998 +#ifndef _VS_CONTEXT_H
11999 +#define _VS_CONTEXT_H
12001 +#include "vserver/base.h"
12002 +#include "vserver/context.h"
12003 +#include "vserver/history.h"
12004 +#include "vserver/debug.h"
12007 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
12009 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
12010 + const char *_file, int _line, void *_here)
12015 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
12016 + vxi, vxi ? vxi->vx_id : 0,
12017 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12019 + __vxh_get_vx_info(vxi, _here);
12021 + atomic_inc(&vxi->vx_usecnt);
12026 +extern void free_vx_info(struct vx_info *);
12028 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
12030 +static inline void __put_vx_info(struct vx_info *vxi,
12031 + const char *_file, int _line, void *_here)
12036 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
12037 + vxi, vxi ? vxi->vx_id : 0,
12038 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12040 + __vxh_put_vx_info(vxi, _here);
12042 + if (atomic_dec_and_test(&vxi->vx_usecnt))
12043 + free_vx_info(vxi);
12047 +#define init_vx_info(p, i) \
12048 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
12050 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
12051 + const char *_file, int _line, void *_here)
12054 + vxlprintk(VXD_CBIT(xid, 3),
12055 + "init_vx_info(%p[#%d.%d])",
12056 + vxi, vxi ? vxi->vx_id : 0,
12057 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12059 + __vxh_init_vx_info(vxi, vxp, _here);
12061 + atomic_inc(&vxi->vx_usecnt);
12067 +#define set_vx_info(p, i) \
12068 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
12070 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
12071 + const char *_file, int _line, void *_here)
12073 + struct vx_info *vxo;
12078 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
12079 + vxi, vxi ? vxi->vx_id : 0,
12080 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12082 + __vxh_set_vx_info(vxi, vxp, _here);
12084 + atomic_inc(&vxi->vx_usecnt);
12085 + vxo = xchg(vxp, vxi);
12090 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
12092 +static inline void __clr_vx_info(struct vx_info **vxp,
12093 + const char *_file, int _line, void *_here)
12095 + struct vx_info *vxo;
12097 + vxo = xchg(vxp, NULL);
12101 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
12102 + vxo, vxo ? vxo->vx_id : 0,
12103 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
12105 + __vxh_clr_vx_info(vxo, vxp, _here);
12107 + if (atomic_dec_and_test(&vxo->vx_usecnt))
12108 + free_vx_info(vxo);
12112 +#define claim_vx_info(v, p) \
12113 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
12115 +static inline void __claim_vx_info(struct vx_info *vxi,
12116 + struct task_struct *task,
12117 + const char *_file, int _line, void *_here)
12119 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
12120 + vxi, vxi ? vxi->vx_id : 0,
12121 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12122 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
12123 + task, _file, _line);
12124 + __vxh_claim_vx_info(vxi, task, _here);
12126 + atomic_inc(&vxi->vx_tasks);
12130 +extern void unhash_vx_info(struct vx_info *);
12132 +#define release_vx_info(v, p) \
12133 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
12135 +static inline void __release_vx_info(struct vx_info *vxi,
12136 + struct task_struct *task,
12137 + const char *_file, int _line, void *_here)
12139 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
12140 + vxi, vxi ? vxi->vx_id : 0,
12141 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
12142 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
12143 + task, _file, _line);
12144 + __vxh_release_vx_info(vxi, task, _here);
12148 + if (atomic_dec_and_test(&vxi->vx_tasks))
12149 + unhash_vx_info(vxi);
12153 +#define task_get_vx_info(p) \
12154 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
12156 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
12157 + const char *_file, int _line, void *_here)
12159 + struct vx_info *vxi;
12162 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
12163 + p, _file, _line);
12164 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
12170 +static inline void __wakeup_vx_info(struct vx_info *vxi)
12172 + if (waitqueue_active(&vxi->vx_wait))
12173 + wake_up_interruptible(&vxi->vx_wait);
12177 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
12179 +static inline void __enter_vx_info(struct vx_info *vxi,
12180 + struct vx_info_save *vxis, const char *_file, int _line)
12182 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
12183 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
12184 + current->xid, current->vx_info, _file, _line);
12185 + vxis->vxi = xchg(¤t->vx_info, vxi);
12186 + vxis->xid = current->xid;
12187 + current->xid = vxi ? vxi->vx_id : 0;
12190 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
12192 +static inline void __leave_vx_info(struct vx_info_save *vxis,
12193 + const char *_file, int _line)
12195 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
12196 + vxis, vxis->xid, vxis->vxi, current,
12197 + current->xid, current->vx_info, _file, _line);
12198 + (void)xchg(¤t->vx_info, vxis->vxi);
12199 + current->xid = vxis->xid;
12203 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
12205 + vxis->vxi = xchg(¤t->vx_info, NULL);
12206 + vxis->xid = xchg(¤t->xid, (xid_t)0);
12209 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
12211 + (void)xchg(¤t->xid, vxis->xid);
12212 + (void)xchg(¤t->vx_info, vxis->vxi);
12215 +extern void exit_vx_info(struct task_struct *, int);
12216 +extern void exit_vx_info_early(struct task_struct *, int);
12220 +#warning duplicate inclusion
12222 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
12223 --- linux-2.6.22.10/include/linux/vs_cowbl.h 1970-01-01 01:00:00 +0100
12224 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_cowbl.h 2007-08-05 20:53:13 +0200
12226 +#ifndef _VS_COWBL_H
12227 +#define _VS_COWBL_H
12229 +#include <linux/fs.h>
12230 +#include <linux/dcache.h>
12231 +#include <linux/namei.h>
12233 +extern struct dentry *cow_break_link(const char *pathname);
12235 +static inline int cow_check_and_break(struct nameidata *nd)
12237 + struct inode *inode = nd->dentry->d_inode;
12239 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
12241 + if (IS_COW(inode)) {
12242 + if (IS_COW_LINK(inode)) {
12243 + struct dentry *new_dentry, *old_dentry = nd->dentry;
12244 + char *path, *buf;
12246 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
12250 + path = d_path(nd->dentry, nd->mnt, buf, PATH_MAX);
12251 + new_dentry = cow_break_link(path);
12253 + if (!IS_ERR(new_dentry)) {
12254 + nd->dentry = new_dentry;
12255 + dput(old_dentry);
12257 + error = PTR_ERR(new_dentry);
12259 + inode->i_flags &= ~(S_IUNLINK | S_IMMUTABLE);
12260 + inode->i_ctime = CURRENT_TIME;
12261 + mark_inode_dirty(inode);
12268 +#warning duplicate inclusion
12270 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
12271 --- linux-2.6.22.10/include/linux/vs_cvirt.h 1970-01-01 01:00:00 +0100
12272 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_cvirt.h 2007-08-05 20:53:13 +0200
12274 +#ifndef _VS_CVIRT_H
12275 +#define _VS_CVIRT_H
12277 +#include "vserver/cvirt.h"
12278 +#include "vserver/context.h"
12279 +#include "vserver/base.h"
12280 +#include "vserver/debug.h"
12283 +static inline void vx_activate_task(struct task_struct *p)
12285 + struct vx_info *vxi;
12287 + if ((vxi = p->vx_info)) {
12288 + vx_update_load(vxi);
12289 + atomic_inc(&vxi->cvirt.nr_running);
12293 +static inline void vx_deactivate_task(struct task_struct *p)
12295 + struct vx_info *vxi;
12297 + if ((vxi = p->vx_info)) {
12298 + vx_update_load(vxi);
12299 + atomic_dec(&vxi->cvirt.nr_running);
12303 +static inline void vx_uninterruptible_inc(struct task_struct *p)
12305 + struct vx_info *vxi;
12307 + if ((vxi = p->vx_info))
12308 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
12311 +static inline void vx_uninterruptible_dec(struct task_struct *p)
12313 + struct vx_info *vxi;
12315 + if ((vxi = p->vx_info))
12316 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
12321 +#warning duplicate inclusion
12323 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
12324 --- linux-2.6.22.10/include/linux/vs_device.h 1970-01-01 01:00:00 +0100
12325 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_device.h 2007-10-11 01:10:22 +0200
12327 +#ifndef _VS_DEVICE_H
12328 +#define _VS_DEVICE_H
12330 +#include "vserver/base.h"
12331 +#include "vserver/device.h"
12332 +#include "vserver/debug.h"
12335 +#ifdef CONFIG_VSERVER_DEVICE
12337 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
12339 +#define vs_device_perm(v, d, m, p) \
12340 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
12345 +int vs_map_device(struct vx_info *vxi,
12346 + dev_t device, dev_t *target, umode_t mode)
12349 + *target = device;
12353 +#define vs_device_perm(v, d, m, p) ((p) == (p))
12358 +#define vs_map_chrdev(d, t, p) \
12359 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
12360 +#define vs_map_blkdev(d, t, p) \
12361 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
12363 +#define vs_chrdev_perm(d, p) \
12364 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
12365 +#define vs_blkdev_perm(d, p) \
12366 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
12370 +#warning duplicate inclusion
12372 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
12373 --- linux-2.6.22.10/include/linux/vs_dlimit.h 1970-01-01 01:00:00 +0100
12374 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_dlimit.h 2007-08-15 22:04:43 +0200
12376 +#ifndef _VS_DLIMIT_H
12377 +#define _VS_DLIMIT_H
12379 +#include <linux/fs.h>
12381 +#include "vserver/dlimit.h"
12382 +#include "vserver/base.h"
12383 +#include "vserver/debug.h"
12386 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
12388 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
12389 + const char *_file, int _line)
12393 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
12394 + dli, dli ? dli->dl_tag : 0,
12395 + dli ? atomic_read(&dli->dl_usecnt) : 0,
12397 + atomic_inc(&dli->dl_usecnt);
12402 +#define free_dl_info(i) \
12403 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
12405 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
12407 +static inline void __put_dl_info(struct dl_info *dli,
12408 + const char *_file, int _line)
12412 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
12413 + dli, dli ? dli->dl_tag : 0,
12414 + dli ? atomic_read(&dli->dl_usecnt) : 0,
12416 + if (atomic_dec_and_test(&dli->dl_usecnt))
12417 + free_dl_info(dli);
12421 +#define __dlimit_char(d) ((d) ? '*' : ' ')
12423 +static inline int __dl_alloc_space(struct super_block *sb,
12424 + tag_t tag, dlsize_t nr, const char *file, int line)
12426 + struct dl_info *dli = NULL;
12431 + dli = locate_dl_info(sb, tag);
12435 + spin_lock(&dli->dl_lock);
12436 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
12438 + dli->dl_space_used += nr;
12439 + spin_unlock(&dli->dl_lock);
12440 + put_dl_info(dli);
12442 + vxlprintk(VXD_CBIT(dlim, 1),
12443 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
12444 + sb, tag, __dlimit_char(dli), (long long)nr,
12445 + ret, file, line);
12449 +static inline void __dl_free_space(struct super_block *sb,
12450 + tag_t tag, dlsize_t nr, const char *_file, int _line)
12452 + struct dl_info *dli = NULL;
12456 + dli = locate_dl_info(sb, tag);
12460 + spin_lock(&dli->dl_lock);
12461 + if (dli->dl_space_used > nr)
12462 + dli->dl_space_used -= nr;
12464 + dli->dl_space_used = 0;
12465 + spin_unlock(&dli->dl_lock);
12466 + put_dl_info(dli);
12468 + vxlprintk(VXD_CBIT(dlim, 1),
12469 + "FREE (%p,#%d)%c %lld bytes",
12470 + sb, tag, __dlimit_char(dli), (long long)nr,
12474 +static inline int __dl_alloc_inode(struct super_block *sb,
12475 + tag_t tag, const char *_file, int _line)
12477 + struct dl_info *dli;
12480 + dli = locate_dl_info(sb, tag);
12484 + spin_lock(&dli->dl_lock);
12485 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
12487 + dli->dl_inodes_used++;
12488 + spin_unlock(&dli->dl_lock);
12489 + put_dl_info(dli);
12491 + vxlprintk(VXD_CBIT(dlim, 0),
12492 + "ALLOC (%p,#%d)%c inode (%d)",
12493 + sb, tag, __dlimit_char(dli), ret, _file, _line);
12497 +static inline void __dl_free_inode(struct super_block *sb,
12498 + tag_t tag, const char *_file, int _line)
12500 + struct dl_info *dli;
12502 + dli = locate_dl_info(sb, tag);
12506 + spin_lock(&dli->dl_lock);
12507 + if (dli->dl_inodes_used > 1)
12508 + dli->dl_inodes_used--;
12510 + dli->dl_inodes_used = 0;
12511 + spin_unlock(&dli->dl_lock);
12512 + put_dl_info(dli);
12514 + vxlprintk(VXD_CBIT(dlim, 0),
12515 + "FREE (%p,#%d)%c inode",
12516 + sb, tag, __dlimit_char(dli), _file, _line);
12519 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
12520 + unsigned long long *free_blocks, unsigned long long *root_blocks,
12521 + const char *_file, int _line)
12523 + struct dl_info *dli;
12524 + uint64_t broot, bfree;
12526 + dli = locate_dl_info(sb, tag);
12530 + spin_lock(&dli->dl_lock);
12531 + broot = (dli->dl_space_total -
12532 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
12533 + >> sb->s_blocksize_bits;
12534 + bfree = (dli->dl_space_total - dli->dl_space_used)
12535 + >> sb->s_blocksize_bits;
12536 + spin_unlock(&dli->dl_lock);
12538 + vxlprintk(VXD_CBIT(dlim, 2),
12539 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
12540 + (long long)bfree, (long long)broot,
12541 + *free_blocks, *root_blocks, dli->dl_nrlmult,
12543 + if (free_blocks) {
12544 + if (*free_blocks > bfree)
12545 + *free_blocks = bfree;
12547 + if (root_blocks) {
12548 + if (*root_blocks > broot)
12549 + *root_blocks = broot;
12551 + put_dl_info(dli);
12554 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
12555 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
12556 + __FILE__, __LINE__ )
12558 +#define DLIMIT_FREE_SPACE(in, bytes) \
12559 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
12560 + __FILE__, __LINE__ )
12562 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
12563 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
12564 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
12565 + __FILE__, __LINE__ )
12567 +#define DLIMIT_FREE_BLOCK(in, nr) \
12568 + __dl_free_space((in)->i_sb, (in)->i_tag, \
12569 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
12570 + __FILE__, __LINE__ )
12573 +#define DLIMIT_ALLOC_INODE(in) \
12574 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
12576 +#define DLIMIT_FREE_INODE(in) \
12577 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
12580 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
12581 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
12585 +#warning duplicate inclusion
12587 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
12588 --- linux-2.6.22.10/include/linux/vs_inet.h 1970-01-01 01:00:00 +0100
12589 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_inet.h 2007-10-05 15:07:22 +0200
12591 +#ifndef _VS_INET_H
12592 +#define _VS_INET_H
12594 +#include "vserver/base.h"
12595 +#include "vserver/network.h"
12596 +#include "vserver/debug.h"
12598 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
12600 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
12601 + NIPQUAD((a)->mask), (a)->type
12602 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
12606 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
12608 + __be32 ip = nxa->ip[0].s_addr;
12609 + __be32 mask = nxa->mask.s_addr;
12610 + __be32 bcast = ip | ~mask;
12613 + switch (nxa->type & tmask) {
12614 + case NXA_TYPE_MASK:
12615 + ret = (ip == (addr & mask));
12617 + case NXA_TYPE_ADDR:
12621 + /* fall through to broadcast */
12622 + case NXA_MOD_BCAST:
12623 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
12625 + case NXA_TYPE_RANGE:
12626 + ret = ((nxa->ip[0].s_addr <= addr) &&
12627 + (nxa->ip[1].s_addr > addr));
12629 + case NXA_TYPE_ANY:
12634 + vxdprintk(VXD_CBIT(net, 0),
12635 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
12636 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
12641 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
12643 + struct nx_addr_v4 *nxa;
12650 + /* allow 127.0.0.1 when remapping lback */
12651 + if ((tmask & NXA_LOOPBACK) &&
12652 + (addr == IPI_LOOPBACK) &&
12653 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12656 + /* check for lback address */
12657 + if ((tmask & NXA_MOD_LBACK) &&
12658 + (nxi->v4_lback.s_addr == addr))
12661 + /* check for broadcast address */
12662 + if ((tmask & NXA_MOD_BCAST) &&
12663 + (nxi->v4_bcast.s_addr == addr))
12666 + /* check for v4 addresses */
12667 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
12668 + if (v4_addr_match(nxa, addr, tmask))
12672 + vxdprintk(VXD_CBIT(net, 0),
12673 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
12674 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
12679 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
12681 + /* FIXME: needs full range checks */
12682 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
12686 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
12688 + struct nx_addr_v4 *ptr;
12690 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
12691 + if (v4_nx_addr_match(ptr, nxa, mask))
12696 +#include <net/inet_sock.h>
12699 + * Check if a given address matches for a socket
12701 + * nxi: the socket's nx_info if any
12702 + * addr: to be verified address
12705 +int v4_sock_addr_match (
12706 + struct nx_info *nxi,
12707 + struct inet_sock *inet,
12710 + __be32 saddr = inet->rcv_saddr;
12711 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
12713 + if (addr && (saddr == addr || bcast == addr))
12716 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
12721 +/* inet related checks and helpers */
12725 +struct net_device;
12728 +#ifdef CONFIG_INET
12730 +#include <linux/netdevice.h>
12731 +#include <linux/inetdevice.h>
12732 +#include <net/inet_timewait_sock.h>
12735 +int dev_in_nx_info(struct net_device *, struct nx_info *);
12736 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
12737 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
12741 + * check if address is covered by socket
12743 + * sk: the socket to check against
12744 + * addr: the address in question (must be != 0)
12748 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
12750 + struct nx_info *nxi = sk->sk_nx_info;
12751 + __be32 saddr = inet_rcv_saddr(sk);
12753 + vxdprintk(VXD_CBIT(net, 5),
12754 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
12755 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
12756 + (sk->sk_socket?sk->sk_socket->flags:0));
12758 + if (saddr) { /* direct address match */
12759 + return v4_addr_match(nxa, saddr, -1);
12760 + } else if (nxi) { /* match against nx_info */
12761 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
12762 + } else { /* unrestricted any socket */
12770 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
12772 + vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p »%s«) %d",
12773 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
12774 + nxi ? dev_in_nx_info(dev, nxi) : 0);
12776 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
12778 + if (dev_in_nx_info(dev, nxi))
12785 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
12791 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
12795 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
12797 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
12798 + nxi, nxi ? nxi->nx_id : 0, ifa,
12799 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
12801 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
12803 + if (v4_ifa_in_nx_info(ifa, nxi))
12809 +struct nx_v4_sock_addr {
12810 + __be32 saddr; /* Address used for validation */
12811 + __be32 baddr; /* Address used for socket bind */
12815 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
12816 + struct nx_v4_sock_addr *nsa)
12818 + struct sock *sk = &inet->sk;
12819 + struct nx_info *nxi = sk->sk_nx_info;
12820 + __be32 saddr = addr->sin_addr.s_addr;
12821 + __be32 baddr = saddr;
12823 + vxdprintk(VXD_CBIT(net, 3),
12824 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
12825 + sk, sk->sk_nx_info, sk->sk_socket,
12826 + (sk->sk_socket ? sk->sk_socket->flags : 0),
12830 + if (saddr == INADDR_ANY) {
12831 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
12832 + baddr = nxi->v4.ip[0].s_addr;
12833 + } else if (saddr == IPI_LOOPBACK) {
12834 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12835 + baddr = nxi->v4_lback.s_addr;
12836 + } else { /* normal address bind */
12837 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
12838 + return -EADDRNOTAVAIL;
12842 + vxdprintk(VXD_CBIT(net, 3),
12843 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
12844 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
12846 + nsa->saddr = saddr;
12847 + nsa->baddr = baddr;
12852 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
12854 + inet->saddr = nsa->baddr;
12855 + inet->rcv_saddr = nsa->baddr;
12860 + * helper to simplify inet_lookup_listener
12862 + * nxi: the socket's nx_info if any
12863 + * addr: to be verified address
12864 + * saddr: socket address
12866 +static inline int v4_inet_addr_match (
12867 + struct nx_info *nxi,
12871 + if (addr && (saddr == addr))
12874 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
12878 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
12880 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
12881 + (addr == nxi->v4_lback.s_addr))
12882 + return IPI_LOOPBACK;
12887 +int nx_info_has_v4(struct nx_info *nxi)
12891 + if (NX_IPV4(nxi))
12893 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12898 +#else /* CONFIG_INET */
12901 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
12907 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
12913 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
12919 +int nx_info_has_v4(struct nx_info *nxi)
12924 +#endif /* CONFIG_INET */
12926 +#define current_nx_info_has_v4() \
12927 + nx_info_has_v4(current_nx_info())
12930 +#warning duplicate inclusion
12932 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
12933 --- linux-2.6.22.10/include/linux/vs_inet6.h 1970-01-01 01:00:00 +0100
12934 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_inet6.h 2007-10-05 14:54:36 +0200
12936 +#ifndef _VS_INET6_H
12937 +#define _VS_INET6_H
12939 +#include <net/ipv6.h>
12940 +#include "vserver/base.h"
12941 +#include "vserver/network.h"
12942 +#include "vserver/debug.h"
12944 +#define NXAV6(a) NIP6((a)->ip), NIP6((a)->mask), (a)->prefix, (a)->type
12945 +#define NXAV6_FMT "[" NIP6_FMT "/" NIP6_FMT "/%d:%04x]"
12948 +#ifdef CONFIG_IPV6
12951 +int v6_addr_match(struct nx_addr_v6 *nxa,
12952 + const struct in6_addr *addr, uint16_t mask)
12954 + switch (nxa->type & mask) {
12955 + case NXA_TYPE_MASK:
12956 + return ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
12957 + case NXA_TYPE_ADDR:
12958 + return ipv6_addr_equal(&nxa->ip, addr);
12959 + case NXA_TYPE_ANY:
12967 +int v6_addr_in_nx_info(struct nx_info *nxi,
12968 + const struct in6_addr *addr, uint16_t mask)
12970 + struct nx_addr_v6 *nxa;
12974 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
12975 + if (v6_addr_match(nxa, addr, mask))
12981 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
12983 + /* FIXME: needs full range checks */
12984 + return v6_addr_match(nxa, &addr->ip, mask);
12988 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
12990 + struct nx_addr_v6 *ptr;
12992 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
12993 + if (v6_nx_addr_match(ptr, nxa, mask))
13000 + * Check if a given address matches for a socket
13002 + * nxi: the socket's nx_info if any
13003 + * addr: to be verified address
13006 +int v6_sock_addr_match (
13007 + struct nx_info *nxi,
13008 + struct inet_sock *inet,
13009 + struct in6_addr *addr)
13011 + struct sock *sk = &inet->sk;
13012 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13014 + if (!ipv6_addr_any(addr) &&
13015 + ipv6_addr_equal(saddr, addr))
13017 + if (ipv6_addr_any(saddr))
13018 + return v6_addr_in_nx_info(nxi, addr, -1);
13023 + * check if address is covered by socket
13025 + * sk: the socket to check against
13026 + * addr: the address in question (must be != 0)
13030 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
13032 + struct nx_info *nxi = sk->sk_nx_info;
13033 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
13035 + vxdprintk(VXD_CBIT(net, 5),
13036 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:" NIP6_FMT " %p;%lx",
13037 + sk, NXAV6(nxa), nxi, NIP6(*saddr), sk->sk_socket,
13038 + (sk->sk_socket?sk->sk_socket->flags:0));
13040 + if (!ipv6_addr_any(saddr)) { /* direct address match */
13041 + return v6_addr_match(nxa, saddr, -1);
13042 + } else if (nxi) { /* match against nx_info */
13043 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
13044 + } else { /* unrestricted any socket */
13050 +/* inet related checks and helpers */
13054 +struct net_device;
13058 +#include <linux/netdevice.h>
13059 +#include <linux/inetdevice.h>
13060 +#include <net/inet_timewait_sock.h>
13063 +int dev_in_nx_info(struct net_device *, struct nx_info *);
13064 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
13065 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
13070 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
13076 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
13080 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
13082 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
13084 + if (v6_ifa_in_nx_info(ifa, nxi))
13090 +struct nx_v6_sock_addr {
13091 + struct in6_addr saddr; /* Address used for validation */
13092 + struct in6_addr baddr; /* Address used for socket bind */
13096 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
13097 + struct nx_v6_sock_addr *nsa)
13099 + // struct sock *sk = &inet->sk;
13100 + // struct nx_info *nxi = sk->sk_nx_info;
13101 + struct in6_addr saddr = addr->sin6_addr;
13102 + struct in6_addr baddr = saddr;
13104 + nsa->saddr = saddr;
13105 + nsa->baddr = baddr;
13110 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
13112 + // struct sock *sk = &inet->sk;
13113 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
13115 + // *saddr = nsa->baddr;
13116 + // inet->saddr = nsa->baddr;
13120 +int nx_info_has_v6(struct nx_info *nxi)
13124 + if (NX_IPV6(nxi))
13129 +#else /* CONFIG_IPV6 */
13132 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
13139 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
13145 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
13151 +int nx_info_has_v6(struct nx_info *nxi)
13156 +#endif /* CONFIG_IPV6 */
13158 +#define current_nx_info_has_v6() \
13159 + nx_info_has_v6(current_nx_info())
13162 +#warning duplicate inclusion
13164 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
13165 --- linux-2.6.22.10/include/linux/vs_limit.h 1970-01-01 01:00:00 +0100
13166 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_limit.h 2007-08-05 20:53:13 +0200
13168 +#ifndef _VS_LIMIT_H
13169 +#define _VS_LIMIT_H
13171 +#include "vserver/limit.h"
13172 +#include "vserver/base.h"
13173 +#include "vserver/context.h"
13174 +#include "vserver/debug.h"
13175 +#include "vserver/context.h"
13176 +#include "vserver/limit_int.h"
13179 +#define vx_acc_cres(v, d, p, r) \
13180 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
13182 +#define vx_acc_cres_cond(x, d, p, r) \
13183 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13184 + r, d, p, __FILE__, __LINE__)
13187 +#define vx_add_cres(v, a, p, r) \
13188 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
13189 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
13191 +#define vx_add_cres_cond(x, a, p, r) \
13192 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
13193 + r, a, p, __FILE__, __LINE__)
13194 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
13197 +/* process and file limits */
13199 +#define vx_nproc_inc(p) \
13200 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
13202 +#define vx_nproc_dec(p) \
13203 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
13205 +#define vx_files_inc(f) \
13206 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
13208 +#define vx_files_dec(f) \
13209 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
13211 +#define vx_locks_inc(l) \
13212 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
13214 +#define vx_locks_dec(l) \
13215 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
13217 +#define vx_openfd_inc(f) \
13218 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
13220 +#define vx_openfd_dec(f) \
13221 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
13224 +#define vx_cres_avail(v, n, r) \
13225 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
13228 +#define vx_nproc_avail(n) \
13229 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
13231 +#define vx_files_avail(n) \
13232 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
13234 +#define vx_locks_avail(n) \
13235 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
13237 +#define vx_openfd_avail(n) \
13238 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
13241 +/* dentry limits */
13243 +#define vx_dentry_inc(d) do { \
13244 + if (atomic_read(&d->d_count) == 1) \
13245 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
13248 +#define vx_dentry_dec(d) do { \
13249 + if (atomic_read(&d->d_count) == 0) \
13250 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
13253 +#define vx_dentry_avail(n) \
13254 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
13257 +/* socket limits */
13259 +#define vx_sock_inc(s) \
13260 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
13262 +#define vx_sock_dec(s) \
13263 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
13265 +#define vx_sock_avail(n) \
13266 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
13269 +/* ipc resource limits */
13271 +#define vx_ipcmsg_add(v, u, a) \
13272 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
13274 +#define vx_ipcmsg_sub(v, u, a) \
13275 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
13277 +#define vx_ipcmsg_avail(v, a) \
13278 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
13281 +#define vx_ipcshm_add(v, k, a) \
13282 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13284 +#define vx_ipcshm_sub(v, k, a) \
13285 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
13287 +#define vx_ipcshm_avail(v, a) \
13288 + vx_cres_avail(v, a, VLIMIT_SHMEM)
13291 +#define vx_semary_inc(a) \
13292 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
13294 +#define vx_semary_dec(a) \
13295 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
13298 +#define vx_nsems_add(a,n) \
13299 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13301 +#define vx_nsems_sub(a,n) \
13302 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
13306 +#warning duplicate inclusion
13308 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
13309 --- linux-2.6.22.10/include/linux/vs_memory.h 1970-01-01 01:00:00 +0100
13310 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_memory.h 2007-08-05 20:53:13 +0200
13312 +#ifndef _VS_MEMORY_H
13313 +#define _VS_MEMORY_H
13315 +#include "vserver/limit.h"
13316 +#include "vserver/base.h"
13317 +#include "vserver/context.h"
13318 +#include "vserver/debug.h"
13319 +#include "vserver/context.h"
13320 +#include "vserver/limit_int.h"
13323 +#define __acc_add_long(a, v) (*(v) += (a))
13324 +#define __acc_inc_long(v) (++*(v))
13325 +#define __acc_dec_long(v) (--*(v))
13327 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
13328 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
13329 +#define __acc_inc_atomic(v) atomic_long_inc(v)
13330 +#define __acc_dec_atomic(v) atomic_long_dec(v)
13331 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13332 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
13333 +#define __acc_inc_atomic(v) __acc_inc_long(v)
13334 +#define __acc_dec_atomic(v) __acc_dec_long(v)
13335 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
13338 +#define vx_acc_page(m, d, v, r) do { \
13340 + __acc_inc_long(&(m)->v); \
13342 + __acc_dec_long(&(m)->v); \
13343 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13346 +#define vx_acc_page_atomic(m, d, v, r) do { \
13348 + __acc_inc_atomic(&(m)->v); \
13350 + __acc_dec_atomic(&(m)->v); \
13351 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
13355 +#define vx_acc_pages(m, p, v, r) do { \
13356 + unsigned long __p = (p); \
13357 + __acc_add_long(__p, &(m)->v); \
13358 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13361 +#define vx_acc_pages_atomic(m, p, v, r) do { \
13362 + unsigned long __p = (p); \
13363 + __acc_add_atomic(__p, &(m)->v); \
13364 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
13369 +#define vx_acc_vmpage(m, d) \
13370 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
13371 +#define vx_acc_vmlpage(m, d) \
13372 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
13373 +#define vx_acc_file_rsspage(m, d) \
13374 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
13375 +#define vx_acc_anon_rsspage(m, d) \
13376 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
13378 +#define vx_acc_vmpages(m, p) \
13379 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
13380 +#define vx_acc_vmlpages(m, p) \
13381 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
13382 +#define vx_acc_file_rsspages(m, p) \
13383 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
13384 +#define vx_acc_anon_rsspages(m, p) \
13385 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
13387 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
13388 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
13390 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
13391 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
13392 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
13393 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
13395 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
13396 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
13397 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
13398 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
13400 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
13401 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
13402 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
13403 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
13405 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
13406 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
13407 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
13408 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
13411 +#define vx_pages_avail(m, p, r) \
13412 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
13414 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
13415 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
13416 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
13417 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
13419 +#define vx_rss_avail(m, p) \
13420 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
13424 + VXPT_UNKNOWN = 0,
13433 +#define vx_page_fault(mm, vma, type, ret)
13437 +void __vx_page_fault(struct mm_struct *mm,
13438 + struct vm_area_struct *vma, int type, int ret)
13440 + struct vx_info *vxi = mm->mm_vx_info;
13443 + static char *page_type[6] =
13444 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
13445 + static char *page_what[4] =
13446 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
13452 + what = (ret & 0x3);
13454 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
13455 + type, what, ret, page_type[type], page_what[what]);
13457 + if (ret & VM_FAULT_WRITE)
13459 + atomic_inc(&vxi->cacct.page[type][what]);
13462 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
13466 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
13469 +#warning duplicate inclusion
13471 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
13472 --- linux-2.6.22.10/include/linux/vs_network.h 1970-01-01 01:00:00 +0100
13473 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_network.h 2007-08-05 20:53:13 +0200
13475 +#ifndef _NX_VS_NETWORK_H
13476 +#define _NX_VS_NETWORK_H
13478 +#include "vserver/context.h"
13479 +#include "vserver/network.h"
13480 +#include "vserver/base.h"
13481 +#include "vserver/debug.h"
13484 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
13486 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
13487 + const char *_file, int _line)
13492 + vxlprintk(VXD_CBIT(nid, 2), "get_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);
13502 +extern void free_nx_info(struct nx_info *);
13504 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
13506 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
13511 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
13512 + nxi, nxi ? nxi->nx_id : 0,
13513 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13516 + if (atomic_dec_and_test(&nxi->nx_usecnt))
13517 + free_nx_info(nxi);
13521 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
13523 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
13524 + const char *_file, int _line)
13527 + vxlprintk(VXD_CBIT(nid, 3),
13528 + "init_nx_info(%p[#%d.%d])",
13529 + nxi, nxi ? nxi->nx_id : 0,
13530 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13533 + atomic_inc(&nxi->nx_usecnt);
13539 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
13541 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
13542 + const char *_file, int _line)
13544 + struct nx_info *nxo;
13549 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
13550 + nxi, nxi ? nxi->nx_id : 0,
13551 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13554 + atomic_inc(&nxi->nx_usecnt);
13555 + nxo = xchg(nxp, nxi);
13559 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
13561 +static inline void __clr_nx_info(struct nx_info **nxp,
13562 + const char *_file, int _line)
13564 + struct nx_info *nxo;
13566 + nxo = xchg(nxp, NULL);
13570 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
13571 + nxo, nxo ? nxo->nx_id : 0,
13572 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
13575 + if (atomic_dec_and_test(&nxo->nx_usecnt))
13576 + free_nx_info(nxo);
13580 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
13582 +static inline void __claim_nx_info(struct nx_info *nxi,
13583 + struct task_struct *task, const char *_file, int _line)
13585 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
13586 + nxi, nxi ? nxi->nx_id : 0,
13587 + nxi?atomic_read(&nxi->nx_usecnt):0,
13588 + nxi?atomic_read(&nxi->nx_tasks):0,
13589 + task, _file, _line);
13591 + atomic_inc(&nxi->nx_tasks);
13595 +extern void unhash_nx_info(struct nx_info *);
13597 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
13599 +static inline void __release_nx_info(struct nx_info *nxi,
13600 + struct task_struct *task, const char *_file, int _line)
13602 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
13603 + nxi, nxi ? nxi->nx_id : 0,
13604 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
13605 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
13606 + task, _file, _line);
13610 + if (atomic_dec_and_test(&nxi->nx_tasks))
13611 + unhash_nx_info(nxi);
13615 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
13617 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
13618 + const char *_file, int _line)
13620 + struct nx_info *nxi;
13623 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
13624 + p, _file, _line);
13625 + nxi = __get_nx_info(p->nx_info, _file, _line);
13631 +static inline void exit_nx_info(struct task_struct *p)
13634 + release_nx_info(p->nx_info, p);
13639 +#warning duplicate inclusion
13641 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
13642 --- linux-2.6.22.10/include/linux/vs_pid.h 1970-01-01 01:00:00 +0100
13643 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_pid.h 2007-09-05 02:49:29 +0200
13648 +#include "vserver/base.h"
13649 +#include "vserver/context.h"
13650 +#include "vserver/debug.h"
13651 +#include <linux/pid_namespace.h>
13654 +/* pid faking stuff */
13657 +#define vx_info_map_pid(v, p) \
13658 + __vx_info_map_pid((v), (p), __FUNC__, __FILE__, __LINE__)
13659 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13660 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
13661 +#define vx_map_tgid(p) vx_map_pid(p)
13663 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13664 + const char *func, const char *file, int line)
13666 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13667 + vxfprintk(VXD_CBIT(cvirt, 2),
13668 + "vx_map_tgid: %p/%llx: %d -> %d",
13669 + vxi, (long long)vxi->vx_flags, pid,
13670 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13671 + func, file, line);
13674 + if (pid == vxi->vx_initpid)
13680 +#define vx_info_rmap_pid(v, p) \
13681 + __vx_info_rmap_pid((v), (p), __FUNC__, __FILE__, __LINE__)
13682 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
13683 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13685 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13686 + const char *func, const char *file, int line)
13688 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13689 + vxfprintk(VXD_CBIT(cvirt, 2),
13690 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13691 + vxi, (long long)vxi->vx_flags, pid,
13692 + (pid == 1) ? vxi->vx_initpid : pid,
13693 + func, file, line);
13694 + if ((pid == 1) && vxi->vx_initpid)
13695 + return vxi->vx_initpid;
13696 + if (pid == vxi->vx_initpid)
13703 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
13706 +int vx_proc_task_visible(struct task_struct *task)
13708 + if ((task->pid == 1) &&
13709 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
13710 + /* show a blend through init */
13712 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
13720 +struct task_struct *vx_find_proc_task_by_pid(int pid)
13722 + struct task_struct *task = find_task_by_pid(pid);
13724 + if (task && !vx_proc_task_visible(task)) {
13725 + vxdprintk(VXD_CBIT(misc, 6),
13726 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
13727 + task, task->xid, task->pid,
13728 + current, current->xid, current->pid);
13735 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
13737 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
13739 + if (task && !vx_proc_task_visible(task)) {
13740 + vxdprintk(VXD_CBIT(misc, 6),
13741 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
13742 + task, task->xid, task->pid,
13743 + current, current->xid, current->pid);
13744 + put_task_struct(task);
13752 +struct task_struct *vx_child_reaper(struct task_struct *p)
13754 + struct vx_info *vxi = p->vx_info;
13755 + struct task_struct *reaper = child_reaper(p);
13760 + BUG_ON(!p->vx_info->vx_reaper);
13762 + /* child reaper for the guest reaper */
13763 + if (vxi->vx_reaper == p)
13766 + reaper = vxi->vx_reaper;
13768 + vxdprintk(VXD_CBIT(xid, 7),
13769 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
13770 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
13776 +#warning duplicate inclusion
13778 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
13779 --- linux-2.6.22.10/include/linux/vs_sched.h 1970-01-01 01:00:00 +0100
13780 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_sched.h 2007-08-05 20:53:13 +0200
13782 +#ifndef _VS_SCHED_H
13783 +#define _VS_SCHED_H
13785 +#include "vserver/base.h"
13786 +#include "vserver/context.h"
13787 +#include "vserver/sched.h"
13790 +#define VAVAVOOM_RATIO 50
13792 +#define MAX_PRIO_BIAS 20
13793 +#define MIN_PRIO_BIAS -20
13796 +#ifdef CONFIG_VSERVER_HARDCPU
13799 + * effective_prio - return the priority that is based on the static
13800 + * priority but is modified by bonuses/penalties.
13802 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
13803 + * into a -4 ... 0 ... +4 bonus/penalty range.
13805 + * Additionally, we scale another amount based on the number of
13806 + * CPU tokens currently held by the context, if the process is
13807 + * part of a context (and the appropriate SCHED flag is set).
13808 + * This ranges from -5 ... 0 ... +15, quadratically.
13810 + * So, the total bonus is -9 .. 0 .. +19
13811 + * We use ~50% of the full 0...39 priority range so that:
13813 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
13814 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
13815 + * unless that context is far exceeding its CPU allocation.
13817 + * Both properties are important to certain workloads.
13820 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
13822 + int vavavoom, max;
13824 + /* lots of tokens = lots of vavavoom
13825 + * no tokens = no vavavoom */
13826 + if ((vavavoom = sched_pc->tokens) >= 0) {
13827 + max = sched_pc->tokens_max;
13828 + vavavoom = max - vavavoom;
13830 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
13831 + * (vavavoom*vavavoom - (max >> 2)) / max;
13839 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
13841 + struct vx_info *vxi = p->vx_info;
13842 + struct _vx_sched_pc *sched_pc;
13847 + sched_pc = &vx_cpu(vxi, sched_pc);
13848 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
13849 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
13851 + sched_pc->vavavoom = vavavoom;
13852 + prio += vavavoom;
13854 + prio += sched_pc->prio_bias;
13858 +#else /* !CONFIG_VSERVER_HARDCPU */
13861 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
13863 + struct vx_info *vxi = p->vx_info;
13866 + prio += vx_cpu(vxi, sched_pc).prio_bias;
13870 +#endif /* CONFIG_VSERVER_HARDCPU */
13873 +static inline void vx_account_user(struct vx_info *vxi,
13874 + cputime_t cputime, int nice)
13878 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
13881 +static inline void vx_account_system(struct vx_info *vxi,
13882 + cputime_t cputime, int idle)
13886 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
13890 +#warning duplicate inclusion
13892 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
13893 --- linux-2.6.22.10/include/linux/vs_socket.h 1970-01-01 01:00:00 +0100
13894 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_socket.h 2007-08-05 20:53:13 +0200
13896 +#ifndef _VS_SOCKET_H
13897 +#define _VS_SOCKET_H
13899 +#include "vserver/debug.h"
13900 +#include "vserver/base.h"
13901 +#include "vserver/cacct.h"
13902 +#include "vserver/context.h"
13903 +#include "vserver/tag.h"
13906 +/* socket accounting */
13908 +#include <linux/socket.h>
13910 +static inline int vx_sock_type(int family)
13912 + switch (family) {
13914 + return VXA_SOCK_UNSPEC;
13916 + return VXA_SOCK_UNIX;
13918 + return VXA_SOCK_INET;
13920 + return VXA_SOCK_INET6;
13922 + return VXA_SOCK_PACKET;
13924 + return VXA_SOCK_OTHER;
13928 +#define vx_acc_sock(v, f, p, s) \
13929 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
13931 +static inline void __vx_acc_sock(struct vx_info *vxi,
13932 + int family, int pos, int size, char *file, int line)
13935 + int type = vx_sock_type(family);
13937 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
13938 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
13942 +#define vx_sock_recv(sk, s) \
13943 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
13944 +#define vx_sock_send(sk, s) \
13945 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
13946 +#define vx_sock_fail(sk, s) \
13947 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
13950 +#define sock_vx_init(s) do { \
13951 + (s)->sk_xid = 0; \
13952 + (s)->sk_vx_info = NULL; \
13955 +#define sock_nx_init(s) do { \
13956 + (s)->sk_nid = 0; \
13957 + (s)->sk_nx_info = NULL; \
13961 +int vx_socket_peer_tag(struct socket *sock, int level,
13962 + char __user *optval, int __user *optlen, int len)
13964 + struct peer_tag tag;
13966 + tag.xid = sock->sk->sk_xid;
13967 + tag.nid = sock->sk->sk_nid;
13968 + if (copy_to_user(optval, &tag, sizeof(tag)))
13974 +#warning duplicate inclusion
13976 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
13977 --- linux-2.6.22.10/include/linux/vs_tag.h 1970-01-01 01:00:00 +0100
13978 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_tag.h 2007-08-15 19:11:32 +0200
13983 +#include <linux/vserver/tag.h>
13985 +/* check conditions */
13987 +#define DX_ADMIN 0x0001
13988 +#define DX_WATCH 0x0002
13989 +#define DX_HOSTID 0x0008
13991 +#define DX_IDENT 0x0010
13993 +#define DX_ARG_MASK 0x0010
13996 +#define dx_task_tag(t) ((t)->tag)
13998 +#define dx_current_tag() dx_task_tag(current)
14000 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
14002 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
14006 + * check current context for ADMIN/WATCH and
14007 + * optionally against supplied argument
14009 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
14011 + if (mode & DX_ARG_MASK) {
14012 + if ((mode & DX_IDENT) && (id == cid))
14015 + return (((mode & DX_ADMIN) && (cid == 0)) ||
14016 + ((mode & DX_WATCH) && (cid == 1)) ||
14017 + ((mode & DX_HOSTID) && (id == 0)));
14021 +#warning duplicate inclusion
14023 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
14024 --- linux-2.6.22.10/include/linux/vs_time.h 1970-01-01 01:00:00 +0100
14025 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vs_time.h 2007-08-05 20:53:13 +0200
14027 +#ifndef _VS_TIME_H
14028 +#define _VS_TIME_H
14031 +/* time faking stuff */
14033 +#ifdef CONFIG_VSERVER_VTIME
14035 +extern void vx_gettimeofday(struct timeval *tv);
14036 +extern int vx_settimeofday(struct timespec *ts);
14039 +#define vx_gettimeofday(t) do_gettimeofday(t)
14040 +#define vx_settimeofday(t) do_settimeofday(t)
14044 +#warning duplicate inclusion
14046 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
14047 --- linux-2.6.22.10/include/linux/vserver/Kbuild 1970-01-01 01:00:00 +0100
14048 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/Kbuild 2007-10-11 01:10:22 +0200
14051 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
14052 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
14053 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
14054 + debug_cmd.h device_cmd.h
14056 +unifdef-y += switch.h network.h monitor.h inode.h device.h
14058 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
14059 --- linux-2.6.22.10/include/linux/vserver/base.h 1970-01-01 01:00:00 +0100
14060 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/base.h 2007-09-17 14:07:30 +0200
14062 +#ifndef _VX_BASE_H
14063 +#define _VX_BASE_H
14066 +/* context state changes */
14077 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
14079 +/* check conditions */
14081 +#define VS_ADMIN 0x0001
14082 +#define VS_WATCH 0x0002
14083 +#define VS_HIDE 0x0004
14084 +#define VS_HOSTID 0x0008
14086 +#define VS_IDENT 0x0010
14087 +#define VS_EQUIV 0x0020
14088 +#define VS_PARENT 0x0040
14089 +#define VS_CHILD 0x0080
14091 +#define VS_ARG_MASK 0x00F0
14093 +#ifdef CONFIG_VSERVER_PRIVACY
14094 +#define VS_ADMIN_P (0)
14095 +#define VS_WATCH_P (0)
14097 +#define VS_ADMIN_P VS_ADMIN
14098 +#define VS_WATCH_P VS_WATCH
14101 +#define VS_HARDIRQ 0x1000
14102 +#define VS_SOFTIRQ 0x2000
14103 +#define VS_IRQ 0x4000
14105 +#define VS_IRQ_MASK 0xF000
14107 +#include <linux/hardirq.h>
14110 + * check current context for ADMIN/WATCH and
14111 + * optionally against supplied argument
14113 +static inline int __vs_check(int cid, int id, unsigned int mode)
14115 + if (mode & VS_ARG_MASK) {
14116 + if ((mode & VS_IDENT) && (id == cid))
14119 + if (mode & VS_IRQ_MASK) {
14120 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
14122 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
14124 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
14127 + return (((mode & VS_ADMIN) && (cid == 0)) ||
14128 + ((mode & VS_WATCH) && (cid == 1)) ||
14129 + ((mode & VS_HOSTID) && (id == 0)));
14132 +#define vx_task_xid(t) ((t)->xid)
14134 +#define vx_current_xid() vx_task_xid(current)
14136 +#define current_vx_info() (current->vx_info)
14139 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
14141 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
14144 +#define nx_task_nid(t) ((t)->nid)
14146 +#define nx_current_nid() nx_task_nid(current)
14148 +#define current_nx_info() (current->nx_info)
14151 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
14153 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
14157 +/* generic flag merging */
14159 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
14161 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
14163 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
14165 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
14168 +/* context flags */
14170 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
14172 +#define vx_current_flags() __vx_flags(current->vx_info)
14174 +#define vx_info_flags(v, m, f) \
14175 + vs_check_flags(__vx_flags(v), m, f)
14177 +#define task_vx_flags(t, m, f) \
14178 + ((t) && vx_info_flags((t)->vx_info, m, f))
14180 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
14183 +/* context caps */
14185 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
14187 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
14189 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
14191 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
14195 +/* network flags */
14197 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
14199 +#define nx_current_flags() __nx_flags(current->nx_info)
14201 +#define nx_info_flags(n, m, f) \
14202 + vs_check_flags(__nx_flags(n), m, f)
14204 +#define task_nx_flags(t, m, f) \
14205 + ((t) && nx_info_flags((t)->nx_info, m, f))
14207 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
14210 +/* network caps */
14212 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
14214 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
14216 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
14218 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
14221 +/* context mask capabilities */
14223 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
14225 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
14227 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
14230 +/* context bcap mask */
14232 +#define __vx_bcaps(v) ((v) ? (v)->vx_bcaps : ~0 )
14234 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
14236 +#define vx_info_bcaps(v, c) (__vx_bcaps(v) & (c))
14238 +#define vx_bcaps(c) vx_info_bcaps(current->vx_info, c)
14241 +#define vx_info_cap_bset(v) ((v) ? (v)->vx_cap_bset : cap_bset)
14243 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
14246 +#define __vx_info_mbcap(v, b) \
14247 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
14248 + vx_info_bcaps(v, b) : (b))
14250 +#define vx_info_mbcap(v, b) __vx_info_mbcap(v, cap_t(b))
14252 +#define task_vx_mbcap(t, b) \
14253 + vx_info_mbcap((t)->vx_info, (t)->b)
14255 +#define vx_mbcap(b) task_vx_mbcap(current, b)
14257 +#define vx_cap_raised(v, c, f) (vx_info_mbcap(v, c) & CAP_TO_MASK(f))
14259 +#define vx_capable(b, c) (capable(b) || \
14260 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
14262 +#define nx_capable(b, c) (capable(b) || \
14263 + (cap_raised(current->cap_effective, b) && nx_ncaps(c)))
14265 +#define vx_current_initpid(n) \
14266 + (current->vx_info && \
14267 + (current->vx_info->vx_initpid == (n)))
14270 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
14272 +#define vx_info_state(v, m) (__vx_state(v) & (m))
14275 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
14277 +#define nx_info_state(n, m) (__nx_state(n) & (m))
14280 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
14281 --- linux-2.6.22.10/include/linux/vserver/cacct.h 1970-01-01 01:00:00 +0100
14282 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct.h 2007-08-05 20:53:13 +0200
14284 +#ifndef _VX_CACCT_H
14285 +#define _VX_CACCT_H
14288 +enum sock_acc_field {
14289 + VXA_SOCK_UNSPEC = 0,
14295 + VXA_SOCK_SIZE /* array size */
14298 +#endif /* _VX_CACCT_H */
14299 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
14300 --- linux-2.6.22.10/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00 +0100
14301 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_cmd.h 2007-08-05 20:53:13 +0200
14303 +#ifndef _VX_CACCT_CMD_H
14304 +#define _VX_CACCT_CMD_H
14307 +/* virtual host info name commands */
14309 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
14311 +struct vcmd_sock_stat_v0 {
14313 + uint32_t count[3];
14314 + uint64_t total[3];
14320 +#include <linux/compiler.h>
14322 +extern int vc_sock_stat(struct vx_info *, void __user *);
14324 +#endif /* __KERNEL__ */
14325 +#endif /* _VX_CACCT_CMD_H */
14326 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
14327 --- linux-2.6.22.10/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00 +0100
14328 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_def.h 2007-08-05 20:53:13 +0200
14330 +#ifndef _VX_CACCT_DEF_H
14331 +#define _VX_CACCT_DEF_H
14333 +#include <asm/atomic.h>
14334 +#include <linux/vserver/cacct.h>
14337 +struct _vx_sock_acc {
14338 + atomic_long_t count;
14339 + atomic_long_t total;
14342 +/* context sub struct */
14344 +struct _vx_cacct {
14345 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
14346 + atomic_t slab[8];
14347 + atomic_t page[6][8];
14350 +#ifdef CONFIG_VSERVER_DEBUG
14352 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
14356 + printk("\t_vx_cacct:");
14357 + for (i = 0; i < 6; i++) {
14358 + struct _vx_sock_acc *ptr = cacct->sock[i];
14360 + printk("\t [%d] =", i);
14361 + for (j = 0; j < 3; j++) {
14362 + printk(" [%d] = %8lu, %8lu", j,
14363 + atomic_long_read(&ptr[j].count),
14364 + atomic_long_read(&ptr[j].total));
14372 +#endif /* _VX_CACCT_DEF_H */
14373 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
14374 --- linux-2.6.22.10/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00 +0100
14375 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cacct_int.h 2007-08-05 20:53:13 +0200
14377 +#ifndef _VX_CACCT_INT_H
14378 +#define _VX_CACCT_INT_H
14384 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
14386 + return atomic_long_read(&cacct->sock[type][pos].count);
14391 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
14393 + return atomic_long_read(&cacct->sock[type][pos].total);
14396 +#endif /* __KERNEL__ */
14397 +#endif /* _VX_CACCT_INT_H */
14398 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
14399 --- linux-2.6.22.10/include/linux/vserver/context.h 1970-01-01 01:00:00 +0100
14400 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/context.h 2007-10-11 01:10:22 +0200
14402 +#ifndef _VX_CONTEXT_H
14403 +#define _VX_CONTEXT_H
14405 +#include <linux/types.h>
14406 +#include <linux/capability.h>
14409 +/* context flags */
14411 +#define VXF_INFO_SCHED 0x00000002
14412 +#define VXF_INFO_NPROC 0x00000004
14413 +#define VXF_INFO_PRIVATE 0x00000008
14415 +#define VXF_INFO_INIT 0x00000010
14416 +#define VXF_INFO_HIDE 0x00000020
14417 +#define VXF_INFO_ULIMIT 0x00000040
14418 +#define VXF_INFO_NSPACE 0x00000080
14420 +#define VXF_SCHED_HARD 0x00000100
14421 +#define VXF_SCHED_PRIO 0x00000200
14422 +#define VXF_SCHED_PAUSE 0x00000400
14424 +#define VXF_VIRT_MEM 0x00010000
14425 +#define VXF_VIRT_UPTIME 0x00020000
14426 +#define VXF_VIRT_CPU 0x00040000
14427 +#define VXF_VIRT_LOAD 0x00080000
14428 +#define VXF_VIRT_TIME 0x00100000
14430 +#define VXF_HIDE_MOUNT 0x01000000
14431 +/* was VXF_HIDE_NETIF 0x02000000 */
14432 +#define VXF_HIDE_VINFO 0x04000000
14434 +#define VXF_STATE_SETUP (1ULL << 32)
14435 +#define VXF_STATE_INIT (1ULL << 33)
14436 +#define VXF_STATE_ADMIN (1ULL << 34)
14438 +#define VXF_SC_HELPER (1ULL << 36)
14439 +#define VXF_REBOOT_KILL (1ULL << 37)
14440 +#define VXF_PERSISTENT (1ULL << 38)
14442 +#define VXF_FORK_RSS (1ULL << 48)
14443 +#define VXF_PROLIFIC (1ULL << 49)
14445 +#define VXF_IGNEG_NICE (1ULL << 52)
14447 +#define VXF_ONE_TIME (0x0007ULL << 32)
14449 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
14452 +/* context migration */
14454 +#define VXM_SET_INIT 0x00000001
14455 +#define VXM_SET_REAPER 0x00000002
14457 +/* context caps */
14459 +#define VXC_CAP_MASK 0x00000000
14461 +#define VXC_SET_UTSNAME 0x00000001
14462 +#define VXC_SET_RLIMIT 0x00000002
14464 +/* was VXC_RAW_ICMP 0x00000100 */
14465 +#define VXC_SYSLOG 0x00001000
14467 +#define VXC_SECURE_MOUNT 0x00010000
14468 +#define VXC_SECURE_REMOUNT 0x00020000
14469 +#define VXC_BINARY_MOUNT 0x00040000
14471 +#define VXC_QUOTA_CTL 0x00100000
14472 +#define VXC_ADMIN_MAPPER 0x00200000
14473 +#define VXC_ADMIN_CLOOP 0x00400000
14475 +#define VXC_KTHREAD 0x01000000
14480 +#include <linux/list.h>
14481 +#include <linux/spinlock.h>
14482 +#include <linux/rcupdate.h>
14484 +#include "limit_def.h"
14485 +#include "sched_def.h"
14486 +#include "cvirt_def.h"
14487 +#include "cacct_def.h"
14488 +#include "device_def.h"
14490 +struct _vx_info_pc {
14491 + struct _vx_sched_pc sched_pc;
14492 + struct _vx_cvirt_pc cvirt_pc;
14496 + struct hlist_node vx_hlist; /* linked list of contexts */
14497 + xid_t vx_id; /* context id */
14498 + atomic_t vx_usecnt; /* usage count */
14499 + atomic_t vx_tasks; /* tasks count */
14500 + struct vx_info *vx_parent; /* parent context */
14501 + int vx_state; /* context state */
14503 + unsigned long vx_nsmask; /* assignment mask */
14504 + struct nsproxy *vx_nsproxy; /* private namespace */
14505 + struct fs_struct *vx_fs; /* private namespace fs */
14507 + uint64_t vx_flags; /* context flags */
14508 + uint64_t vx_bcaps; /* bounding caps (system) */
14509 + uint64_t vx_ccaps; /* context caps (vserver) */
14510 + kernel_cap_t vx_cap_bset; /* the guest's bset */
14512 + struct task_struct *vx_reaper; /* guest reaper process */
14513 + pid_t vx_initpid; /* PID of guest init */
14514 + int64_t vx_badness_bias; /* OOM points bias */
14516 + struct _vx_limit limit; /* vserver limits */
14517 + struct _vx_sched sched; /* vserver scheduler */
14518 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
14519 + struct _vx_cacct cacct; /* context accounting */
14521 + struct _vx_device dmap; /* default device map targets */
14523 +#ifndef CONFIG_SMP
14524 + struct _vx_info_pc info_pc; /* per cpu data */
14526 + struct _vx_info_pc *ptr_pc; /* per cpu array */
14529 + wait_queue_head_t vx_wait; /* context exit waitqueue */
14530 + int reboot_cmd; /* last sys_reboot() cmd */
14531 + int exit_code; /* last process exit code */
14533 + char vx_name[65]; /* vserver name */
14536 +#ifndef CONFIG_SMP
14537 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
14538 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
14540 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
14541 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
14544 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
14547 +struct vx_info_save {
14548 + struct vx_info *vxi;
14553 +/* status flags */
14555 +#define VXS_HASHED 0x0001
14556 +#define VXS_PAUSED 0x0010
14557 +#define VXS_SHUTDOWN 0x0100
14558 +#define VXS_HELPER 0x1000
14559 +#define VXS_RELEASED 0x8000
14562 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
14563 +extern void release_vx_info(struct vx_info *, struct task_struct *);
14565 +extern struct vx_info *lookup_vx_info(int);
14566 +extern struct vx_info *lookup_or_create_vx_info(int);
14568 +extern int get_xid_list(int, unsigned int *, int);
14569 +extern int xid_is_hashed(xid_t);
14571 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
14573 +extern long vs_state_change(struct vx_info *, unsigned int);
14576 +#endif /* __KERNEL__ */
14577 +#endif /* _VX_CONTEXT_H */
14578 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
14579 --- linux-2.6.22.10/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00 +0100
14580 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/context_cmd.h 2007-08-19 00:40:28 +0200
14582 +#ifndef _VX_CONTEXT_CMD_H
14583 +#define _VX_CONTEXT_CMD_H
14586 +/* vinfo commands */
14588 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
14591 +extern int vc_task_xid(uint32_t);
14593 +#endif /* __KERNEL__ */
14595 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
14597 +struct vcmd_vx_info_v0 {
14599 + uint32_t initpid;
14600 + /* more to come */
14604 +extern int vc_vx_info(struct vx_info *, void __user *);
14606 +#endif /* __KERNEL__ */
14608 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
14610 +struct vcmd_ctx_stat_v0 {
14613 + /* more to come */
14617 +extern int vc_ctx_stat(struct vx_info *, void __user *);
14619 +#endif /* __KERNEL__ */
14621 +/* context commands */
14623 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
14624 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
14626 +struct vcmd_ctx_create {
14627 + uint64_t flagword;
14630 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
14631 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
14633 +struct vcmd_ctx_migrate {
14634 + uint64_t flagword;
14638 +extern int vc_ctx_create(uint32_t, void __user *);
14639 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
14641 +#endif /* __KERNEL__ */
14644 +/* flag commands */
14646 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
14647 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
14649 +struct vcmd_ctx_flags_v0 {
14650 + uint64_t flagword;
14655 +extern int vc_get_cflags(struct vx_info *, void __user *);
14656 +extern int vc_set_cflags(struct vx_info *, void __user *);
14658 +#endif /* __KERNEL__ */
14661 +/* context caps commands */
14663 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
14664 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
14666 +struct vcmd_ctx_caps_v1 {
14672 +extern int vc_get_ccaps(struct vx_info *, void __user *);
14673 +extern int vc_set_ccaps(struct vx_info *, void __user *);
14675 +#endif /* __KERNEL__ */
14678 +/* bcaps commands */
14680 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
14681 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
14683 +struct vcmd_bcaps {
14689 +extern int vc_get_bcaps(struct vx_info *, void __user *);
14690 +extern int vc_set_bcaps(struct vx_info *, void __user *);
14692 +#endif /* __KERNEL__ */
14697 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
14698 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
14700 +struct vcmd_badness_v0 {
14705 +extern int vc_get_badness(struct vx_info *, void __user *);
14706 +extern int vc_set_badness(struct vx_info *, void __user *);
14708 +#endif /* __KERNEL__ */
14709 +#endif /* _VX_CONTEXT_CMD_H */
14710 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
14711 --- linux-2.6.22.10/include/linux/vserver/cvirt.h 1970-01-01 01:00:00 +0100
14712 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt.h 2007-08-05 20:53:13 +0200
14714 +#ifndef _VX_CVIRT_H
14715 +#define _VX_CVIRT_H
14722 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14727 +void vx_update_load(struct vx_info *);
14730 +int vx_do_syslog(int, char __user *, int);
14732 +#endif /* __KERNEL__ */
14733 +#endif /* _VX_CVIRT_H */
14734 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
14735 --- linux-2.6.22.10/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00 +0100
14736 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt_cmd.h 2007-08-05 20:53:13 +0200
14738 +#ifndef _VX_CVIRT_CMD_H
14739 +#define _VX_CVIRT_CMD_H
14742 +/* virtual host info name commands */
14744 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
14745 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
14747 +struct vcmd_vhi_name_v0 {
14753 +enum vhi_name_field {
14754 + VHIN_CONTEXT = 0,
14766 +#include <linux/compiler.h>
14768 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
14769 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
14771 +#endif /* __KERNEL__ */
14773 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
14775 +struct vcmd_virt_stat_v0 {
14778 + uint32_t nr_threads;
14779 + uint32_t nr_running;
14780 + uint32_t nr_uninterruptible;
14781 + uint32_t nr_onhold;
14782 + uint32_t nr_forks;
14783 + uint32_t load[3];
14787 +extern int vc_virt_stat(struct vx_info *, void __user *);
14789 +#endif /* __KERNEL__ */
14790 +#endif /* _VX_CVIRT_CMD_H */
14791 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
14792 --- linux-2.6.22.10/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00 +0100
14793 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/cvirt_def.h 2007-08-05 20:53:13 +0200
14795 +#ifndef _VX_CVIRT_DEF_H
14796 +#define _VX_CVIRT_DEF_H
14798 +#include <linux/jiffies.h>
14799 +#include <linux/spinlock.h>
14800 +#include <linux/wait.h>
14801 +#include <linux/time.h>
14802 +#include <linux/utsname.h>
14803 +#include <asm/atomic.h>
14806 +struct _vx_usage_stat {
14810 + uint64_t softirq;
14816 +struct _vx_syslog {
14817 + wait_queue_head_t log_wait;
14818 + spinlock_t logbuf_lock; /* lock for the log buffer */
14820 + unsigned long log_start; /* next char to be read by syslog() */
14821 + unsigned long con_start; /* next char to be sent to consoles */
14822 + unsigned long log_end; /* most-recently-written-char + 1 */
14823 + unsigned long logged_chars; /* #chars since last read+clear operation */
14825 + char log_buf[1024];
14829 +/* context sub struct */
14831 +struct _vx_cvirt {
14832 + atomic_t nr_threads; /* number of current threads */
14833 + atomic_t nr_running; /* number of running threads */
14834 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
14836 + atomic_t nr_onhold; /* processes on hold */
14837 + uint32_t onhold_last; /* jiffies when put on hold */
14839 + struct timeval bias_tv; /* time offset to the host */
14840 + struct timespec bias_idle;
14841 + struct timespec bias_uptime; /* context creation point */
14842 + uint64_t bias_clock; /* offset in clock_t */
14844 + spinlock_t load_lock; /* lock for the load averages */
14845 + atomic_t load_updates; /* nr of load updates done so far */
14846 + uint32_t load_last; /* last time load was calculated */
14847 + uint32_t load[3]; /* load averages 1,5,15 */
14849 + atomic_t total_forks; /* number of forks so far */
14851 + struct _vx_syslog syslog;
14854 +struct _vx_cvirt_pc {
14855 + struct _vx_usage_stat cpustat;
14859 +#ifdef CONFIG_VSERVER_DEBUG
14861 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
14863 + printk("\t_vx_cvirt:\n");
14864 + printk("\t threads: %4d, %4d, %4d, %4d\n",
14865 + atomic_read(&cvirt->nr_threads),
14866 + atomic_read(&cvirt->nr_running),
14867 + atomic_read(&cvirt->nr_uninterruptible),
14868 + atomic_read(&cvirt->nr_onhold));
14869 + /* add rest here */
14870 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
14875 +#endif /* _VX_CVIRT_DEF_H */
14876 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
14877 --- linux-2.6.22.10/include/linux/vserver/debug.h 1970-01-01 01:00:00 +0100
14878 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/debug.h 2007-10-25 17:05:55 +0200
14880 +#ifndef _VX_DEBUG_H
14881 +#define _VX_DEBUG_H
14884 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
14885 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
14886 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
14888 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
14889 + imajor((d)->bd_inode), iminor((d)->bd_inode)
14890 +#define VXF_DEV "%p[%lu,%d:%d]"
14893 +#define __FUNC__ __func__
14896 +#define vxd_path(d, m) \
14897 + ({ static char _buffer[PATH_MAX]; \
14898 + d_path(d, m, _buffer, sizeof(_buffer)); })
14900 +#define vxd_cond_path(n) \
14901 + ((n) ? vxd_path((n)->dentry, (n)->mnt) : "<null>" )
14904 +#ifdef CONFIG_VSERVER_DEBUG
14906 +extern unsigned int vx_debug_switch;
14907 +extern unsigned int vx_debug_xid;
14908 +extern unsigned int vx_debug_nid;
14909 +extern unsigned int vx_debug_tag;
14910 +extern unsigned int vx_debug_net;
14911 +extern unsigned int vx_debug_limit;
14912 +extern unsigned int vx_debug_cres;
14913 +extern unsigned int vx_debug_dlim;
14914 +extern unsigned int vx_debug_quota;
14915 +extern unsigned int vx_debug_cvirt;
14916 +extern unsigned int vx_debug_space;
14917 +extern unsigned int vx_debug_misc;
14920 +#define VX_LOGLEVEL "vxD: "
14921 +#define VX_PROC_FMT "%p: "
14922 +#define VX_PROCESS current
14924 +#define vxdprintk(c, f, x...) \
14927 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
14928 + VX_PROCESS , ##x); \
14931 +#define vxlprintk(c, f, x...) \
14934 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
14937 +#define vxfprintk(c, f, x...) \
14940 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
14946 +void dump_vx_info(struct vx_info *, int);
14947 +void dump_vx_info_inactive(int);
14949 +#else /* CONFIG_VSERVER_DEBUG */
14951 +#define vx_debug_switch 0
14952 +#define vx_debug_xid 0
14953 +#define vx_debug_nid 0
14954 +#define vx_debug_tag 0
14955 +#define vx_debug_net 0
14956 +#define vx_debug_limit 0
14957 +#define vx_debug_cres 0
14958 +#define vx_debug_dlim 0
14959 +#define vx_debug_cvirt 0
14961 +#define vxdprintk(x...) do { } while (0)
14962 +#define vxlprintk(x...) do { } while (0)
14963 +#define vxfprintk(x...) do { } while (0)
14965 +#endif /* CONFIG_VSERVER_DEBUG */
14968 +#ifdef CONFIG_VSERVER_WARN
14970 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
14971 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u|%u] "
14972 +#define VX_WARN_XID "[xid #%u] "
14973 +#define VX_WARN_NID "[nid #%u] "
14974 +#define VX_WARN_TAG "[tag #%u] "
14976 +#define vxwprintk(c, f, x...) \
14979 + printk(VX_WARNLEVEL f "\n", ##x); \
14982 +#else /* CONFIG_VSERVER_WARN */
14984 +#define vxwprintk(x...) do { } while (0)
14986 +#endif /* CONFIG_VSERVER_WARN */
14988 +#define vxwprintk_task(c, f, x...) \
14989 + vxwprintk(c, VX_WARN_TASK f, \
14990 + current->comm, current->pid, \
14991 + current->xid, current->nid, current->tag, ##x)
14992 +#define vxwprintk_xid(c, f, x...) \
14993 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
14994 +#define vxwprintk_nid(c, f, x...) \
14995 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
14996 +#define vxwprintk_tag(c, f, x...) \
14997 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
14999 +#ifdef CONFIG_VSERVER_DEBUG
15000 +#define vxd_assert_lock(l) assert_spin_locked(l)
15001 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
15002 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
15004 +#define vxd_assert_lock(l) do { } while (0)
15005 +#define vxd_assert(c, f, x...) do { } while (0)
15009 +#endif /* _VX_DEBUG_H */
15010 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
15011 --- linux-2.6.22.10/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00 +0100
15012 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/debug_cmd.h 2007-08-05 20:53:13 +0200
15014 +#ifndef _VX_DEBUG_CMD_H
15015 +#define _VX_DEBUG_CMD_H
15018 +/* debug commands */
15020 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
15022 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
15023 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
15025 +struct vcmd_read_history_v0 {
15028 + char __user *data;
15031 +struct vcmd_read_monitor_v0 {
15034 + char __user *data;
15040 +#ifdef CONFIG_COMPAT
15042 +#include <asm/compat.h>
15044 +struct vcmd_read_history_v0_x32 {
15047 + compat_uptr_t data_ptr;
15050 +struct vcmd_read_monitor_v0_x32 {
15053 + compat_uptr_t data_ptr;
15056 +#endif /* CONFIG_COMPAT */
15058 +extern int vc_dump_history(uint32_t);
15060 +extern int vc_read_history(uint32_t, void __user *);
15061 +extern int vc_read_monitor(uint32_t, void __user *);
15063 +#ifdef CONFIG_COMPAT
15065 +extern int vc_read_history_x32(uint32_t, void __user *);
15066 +extern int vc_read_monitor_x32(uint32_t, void __user *);
15068 +#endif /* CONFIG_COMPAT */
15070 +#endif /* __KERNEL__ */
15071 +#endif /* _VX_DEBUG_CMD_H */
15072 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
15073 --- linux-2.6.22.10/include/linux/vserver/device.h 1970-01-01 01:00:00 +0100
15074 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device.h 2007-10-11 01:10:22 +0200
15076 +#ifndef _VX_DEVICE_H
15077 +#define _VX_DEVICE_H
15080 +#define DATTR_CREATE 0x00000001
15081 +#define DATTR_OPEN 0x00000002
15083 +#define DATTR_REMAP 0x00000010
15085 +#define DATTR_MASK 0x00000013
15088 +#else /* _VX_DEVICE_H */
15089 +#warning duplicate inclusion
15090 +#endif /* _VX_DEVICE_H */
15091 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
15092 --- linux-2.6.22.10/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00 +0100
15093 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device_cmd.h 2007-10-11 01:10:22 +0200
15095 +#ifndef _VX_DEVICE_CMD_H
15096 +#define _VX_DEVICE_CMD_H
15099 +/* device vserver commands */
15101 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
15102 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
15104 +struct vcmd_set_mapping_v0 {
15105 + const char __user *device;
15106 + const char __user *target;
15113 +#ifdef CONFIG_COMPAT
15115 +#include <asm/compat.h>
15117 +struct vcmd_set_mapping_v0_x32 {
15118 + compat_uptr_t device_ptr;
15119 + compat_uptr_t target_ptr;
15123 +#endif /* CONFIG_COMPAT */
15125 +#include <linux/compiler.h>
15127 +extern int vc_set_mapping(struct vx_info *, void __user *);
15128 +extern int vc_unset_mapping(struct vx_info *, void __user *);
15130 +#ifdef CONFIG_COMPAT
15132 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
15133 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
15135 +#endif /* CONFIG_COMPAT */
15137 +#endif /* __KERNEL__ */
15138 +#endif /* _VX_DEVICE_CMD_H */
15139 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
15140 --- linux-2.6.22.10/include/linux/vserver/device_def.h 1970-01-01 01:00:00 +0100
15141 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/device_def.h 2007-10-11 01:10:22 +0200
15143 +#ifndef _VX_DEVICE_DEF_H
15144 +#define _VX_DEVICE_DEF_H
15146 +#include <linux/types.h>
15148 +struct vx_dmap_target {
15153 +struct _vx_device {
15154 +#ifdef CONFIG_VSERVER_DEVICE
15155 + struct vx_dmap_target targets[2];
15159 +#endif /* _VX_DEVICE_DEF_H */
15160 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
15161 --- linux-2.6.22.10/include/linux/vserver/dlimit.h 1970-01-01 01:00:00 +0100
15162 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/dlimit.h 2007-08-15 22:03:58 +0200
15164 +#ifndef _VX_DLIMIT_H
15165 +#define _VX_DLIMIT_H
15167 +#include "switch.h"
15172 +/* keep in sync with CDLIM_INFINITY */
15174 +#define DLIM_INFINITY (~0ULL)
15176 +#include <linux/spinlock.h>
15177 +#include <linux/rcupdate.h>
15179 +struct super_block;
15182 + struct hlist_node dl_hlist; /* linked list of contexts */
15183 + struct rcu_head dl_rcu; /* the rcu head */
15184 + tag_t dl_tag; /* context tag */
15185 + atomic_t dl_usecnt; /* usage count */
15186 + atomic_t dl_refcnt; /* reference count */
15188 + struct super_block *dl_sb; /* associated superblock */
15190 + spinlock_t dl_lock; /* protect the values */
15192 + unsigned long long dl_space_used; /* used space in bytes */
15193 + unsigned long long dl_space_total; /* maximum space in bytes */
15194 + unsigned long dl_inodes_used; /* used inodes */
15195 + unsigned long dl_inodes_total; /* maximum inodes */
15197 + unsigned int dl_nrlmult; /* non root limit mult */
15202 +extern void rcu_free_dl_info(struct rcu_head *);
15203 +extern void unhash_dl_info(struct dl_info *);
15205 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
15210 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
15212 +typedef uint64_t dlsize_t;
15214 +#endif /* __KERNEL__ */
15215 +#else /* _VX_DLIMIT_H */
15216 +#warning duplicate inclusion
15217 +#endif /* _VX_DLIMIT_H */
15218 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
15219 --- linux-2.6.22.10/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00 +0100
15220 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/dlimit_cmd.h 2007-08-05 20:53:13 +0200
15222 +#ifndef _VX_DLIMIT_CMD_H
15223 +#define _VX_DLIMIT_CMD_H
15226 +/* dlimit vserver commands */
15228 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
15229 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
15231 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
15232 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
15234 +struct vcmd_ctx_dlimit_base_v0 {
15235 + const char __user *name;
15239 +struct vcmd_ctx_dlimit_v0 {
15240 + const char __user *name;
15241 + uint32_t space_used; /* used space in kbytes */
15242 + uint32_t space_total; /* maximum space in kbytes */
15243 + uint32_t inodes_used; /* used inodes */
15244 + uint32_t inodes_total; /* maximum inodes */
15245 + uint32_t reserved; /* reserved for root in % */
15249 +#define CDLIM_UNSET ((uint32_t)0UL)
15250 +#define CDLIM_INFINITY ((uint32_t)~0UL)
15251 +#define CDLIM_KEEP ((uint32_t)~1UL)
15255 +#ifdef CONFIG_COMPAT
15257 +#include <asm/compat.h>
15259 +struct vcmd_ctx_dlimit_base_v0_x32 {
15260 + compat_uptr_t name_ptr;
15264 +struct vcmd_ctx_dlimit_v0_x32 {
15265 + compat_uptr_t name_ptr;
15266 + uint32_t space_used; /* used space in kbytes */
15267 + uint32_t space_total; /* maximum space in kbytes */
15268 + uint32_t inodes_used; /* used inodes */
15269 + uint32_t inodes_total; /* maximum inodes */
15270 + uint32_t reserved; /* reserved for root in % */
15274 +#endif /* CONFIG_COMPAT */
15276 +#include <linux/compiler.h>
15278 +extern int vc_add_dlimit(uint32_t, void __user *);
15279 +extern int vc_rem_dlimit(uint32_t, void __user *);
15281 +extern int vc_set_dlimit(uint32_t, void __user *);
15282 +extern int vc_get_dlimit(uint32_t, void __user *);
15284 +#ifdef CONFIG_COMPAT
15286 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
15287 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
15289 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
15290 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
15292 +#endif /* CONFIG_COMPAT */
15294 +#endif /* __KERNEL__ */
15295 +#endif /* _VX_DLIMIT_CMD_H */
15296 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
15297 --- linux-2.6.22.10/include/linux/vserver/global.h 1970-01-01 01:00:00 +0100
15298 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/global.h 2007-08-05 20:53:13 +0200
15300 +#ifndef _VX_GLOBAL_H
15301 +#define _VX_GLOBAL_H
15304 +extern atomic_t vx_global_ctotal;
15305 +extern atomic_t vx_global_cactive;
15307 +extern atomic_t nx_global_ctotal;
15308 +extern atomic_t nx_global_cactive;
15310 +extern atomic_t vs_global_nsproxy;
15311 +extern atomic_t vs_global_fs;
15312 +extern atomic_t vs_global_mnt_ns;
15313 +extern atomic_t vs_global_uts_ns;
15314 +extern atomic_t vs_global_ipc_ns;
15317 +#endif /* _VX_GLOBAL_H */
15318 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
15319 --- linux-2.6.22.10/include/linux/vserver/history.h 1970-01-01 01:00:00 +0100
15320 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/history.h 2007-08-05 20:53:13 +0200
15322 +#ifndef _VX_HISTORY_H
15323 +#define _VX_HISTORY_H
15328 + VXH_THROW_OOPS = 1,
15332 + VXH_INIT_VX_INFO,
15335 + VXH_CLAIM_VX_INFO,
15336 + VXH_RELEASE_VX_INFO,
15337 + VXH_ALLOC_VX_INFO,
15338 + VXH_DEALLOC_VX_INFO,
15339 + VXH_HASH_VX_INFO,
15340 + VXH_UNHASH_VX_INFO,
15342 + VXH_LOOKUP_VX_INFO,
15343 + VXH_CREATE_VX_INFO,
15346 +struct _vxhe_vxi {
15347 + struct vx_info *ptr;
15353 +struct _vxhe_set_clr {
15357 +struct _vxhe_loc_lookup {
15361 +struct _vx_hist_entry {
15363 + unsigned short seq;
15364 + unsigned short type;
15365 + struct _vxhe_vxi vxi;
15367 + struct _vxhe_set_clr sc;
15368 + struct _vxhe_loc_lookup ll;
15372 +#ifdef CONFIG_VSERVER_HISTORY
15374 +extern unsigned volatile int vxh_active;
15376 +struct _vx_hist_entry *vxh_advance(void *loc);
15380 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
15382 + entry->vxi.ptr = vxi;
15384 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
15385 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
15386 + entry->vxi.xid = vxi->vx_id;
15391 +#define __HERE__ current_text_addr()
15393 +#define __VXH_BODY(__type, __data, __here) \
15394 + struct _vx_hist_entry *entry; \
15396 + preempt_disable(); \
15397 + entry = vxh_advance(__here); \
15399 + entry->type = __type; \
15400 + preempt_enable();
15403 + /* pass vxi only */
15405 +#define __VXH_SMPL \
15406 + __vxh_copy_vxi(entry, vxi)
15409 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
15411 + __VXH_BODY(__type, __VXH_SMPL, __here)
15414 + /* pass vxi and data (void *) */
15416 +#define __VXH_DATA \
15417 + __vxh_copy_vxi(entry, vxi); \
15418 + entry->sc.data = data
15421 +void __vxh_data(struct vx_info *vxi, void *data,
15422 + int __type, void *__here)
15424 + __VXH_BODY(__type, __VXH_DATA, __here)
15427 + /* pass vxi and arg (long) */
15429 +#define __VXH_LONG \
15430 + __vxh_copy_vxi(entry, vxi); \
15431 + entry->ll.arg = arg
15434 +void __vxh_long(struct vx_info *vxi, long arg,
15435 + int __type, void *__here)
15437 + __VXH_BODY(__type, __VXH_LONG, __here)
15442 +void __vxh_throw_oops(void *__here)
15444 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
15445 + /* prevent further acquisition */
15450 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
15452 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
15453 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
15455 +#define __vxh_init_vx_info(v, d, h) \
15456 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
15457 +#define __vxh_set_vx_info(v, d, h) \
15458 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
15459 +#define __vxh_clr_vx_info(v, d, h) \
15460 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
15462 +#define __vxh_claim_vx_info(v, d, h) \
15463 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
15464 +#define __vxh_release_vx_info(v, d, h) \
15465 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
15467 +#define vxh_alloc_vx_info(v) \
15468 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
15469 +#define vxh_dealloc_vx_info(v) \
15470 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
15472 +#define vxh_hash_vx_info(v) \
15473 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
15474 +#define vxh_unhash_vx_info(v) \
15475 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
15477 +#define vxh_loc_vx_info(v, l) \
15478 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
15479 +#define vxh_lookup_vx_info(v, l) \
15480 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
15481 +#define vxh_create_vx_info(v, l) \
15482 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
15484 +extern void vxh_dump_history(void);
15487 +#else /* CONFIG_VSERVER_HISTORY */
15489 +#define __HERE__ 0
15491 +#define vxh_throw_oops() do { } while (0)
15493 +#define __vxh_get_vx_info(v, h) do { } while (0)
15494 +#define __vxh_put_vx_info(v, h) do { } while (0)
15496 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
15497 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
15498 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
15500 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
15501 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
15503 +#define vxh_alloc_vx_info(v) do { } while (0)
15504 +#define vxh_dealloc_vx_info(v) do { } while (0)
15506 +#define vxh_hash_vx_info(v) do { } while (0)
15507 +#define vxh_unhash_vx_info(v) do { } while (0)
15509 +#define vxh_loc_vx_info(v, l) do { } while (0)
15510 +#define vxh_lookup_vx_info(v, l) do { } while (0)
15511 +#define vxh_create_vx_info(v, l) do { } while (0)
15513 +#define vxh_dump_history() do { } while (0)
15516 +#endif /* CONFIG_VSERVER_HISTORY */
15518 +#endif /* _VX_HISTORY_H */
15519 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
15520 --- linux-2.6.22.10/include/linux/vserver/inode.h 1970-01-01 01:00:00 +0100
15521 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/inode.h 2007-08-05 20:53:13 +0200
15523 +#ifndef _VX_INODE_H
15524 +#define _VX_INODE_H
15527 +#define IATTR_TAG 0x01000000
15529 +#define IATTR_ADMIN 0x00000001
15530 +#define IATTR_WATCH 0x00000002
15531 +#define IATTR_HIDE 0x00000004
15532 +#define IATTR_FLAGS 0x00000007
15534 +#define IATTR_BARRIER 0x00010000
15535 +#define IATTR_IUNLINK 0x00020000
15536 +#define IATTR_IMMUTABLE 0x00040000
15541 +#ifdef CONFIG_VSERVER_PROC_SECURE
15542 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
15543 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
15545 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
15546 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
15549 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
15551 +#endif /* __KERNEL__ */
15553 +/* inode ioctls */
15555 +#define FIOC_GETXFLG _IOR('x', 5, long)
15556 +#define FIOC_SETXFLG _IOW('x', 6, long)
15558 +#else /* _VX_INODE_H */
15559 +#warning duplicate inclusion
15560 +#endif /* _VX_INODE_H */
15561 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
15562 --- linux-2.6.22.10/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00 +0100
15563 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/inode_cmd.h 2007-08-15 18:08:31 +0200
15565 +#ifndef _VX_INODE_CMD_H
15566 +#define _VX_INODE_CMD_H
15569 +/* inode vserver commands */
15571 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
15572 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
15574 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
15575 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
15577 +struct vcmd_ctx_iattr_v1 {
15578 + const char __user *name;
15584 +struct vcmd_ctx_fiattr_v0 {
15594 +#ifdef CONFIG_COMPAT
15596 +#include <asm/compat.h>
15598 +struct vcmd_ctx_iattr_v1_x32 {
15599 + compat_uptr_t name_ptr;
15605 +#endif /* CONFIG_COMPAT */
15607 +#include <linux/compiler.h>
15609 +extern int vc_get_iattr(void __user *);
15610 +extern int vc_set_iattr(void __user *);
15612 +extern int vc_fget_iattr(uint32_t, void __user *);
15613 +extern int vc_fset_iattr(uint32_t, void __user *);
15615 +#ifdef CONFIG_COMPAT
15617 +extern int vc_get_iattr_x32(void __user *);
15618 +extern int vc_set_iattr_x32(void __user *);
15620 +#endif /* CONFIG_COMPAT */
15622 +#endif /* __KERNEL__ */
15623 +#endif /* _VX_INODE_CMD_H */
15624 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
15625 --- linux-2.6.22.10/include/linux/vserver/limit.h 1970-01-01 01:00:00 +0100
15626 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit.h 2007-08-15 22:27:29 +0200
15628 +#ifndef _VX_LIMIT_H
15629 +#define _VX_LIMIT_H
15631 +#define VLIMIT_NSOCK 16
15632 +#define VLIMIT_OPENFD 17
15633 +#define VLIMIT_ANON 18
15634 +#define VLIMIT_SHMEM 19
15635 +#define VLIMIT_SEMARY 20
15636 +#define VLIMIT_NSEMS 21
15637 +#define VLIMIT_DENTRY 22
15638 +#define VLIMIT_MAPPED 23
15643 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
15645 +/* keep in sync with CRLIM_INFINITY */
15647 +#define VLIM_INFINITY (~0ULL)
15649 +#include <asm/atomic.h>
15650 +#include <asm/resource.h>
15652 +#ifndef RLIM_INFINITY
15653 +#warning RLIM_INFINITY is undefined
15656 +#define __rlim_val(l, r, v) ((l)->res[r].v)
15658 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
15659 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
15661 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
15662 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
15663 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
15665 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
15666 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
15668 +typedef atomic_long_t rlim_atomic_t;
15669 +typedef unsigned long rlim_t;
15671 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
15672 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
15673 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
15674 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
15675 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
15676 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
15679 +#if (RLIM_INFINITY == VLIM_INFINITY)
15680 +#define VX_VLIM(r) ((long long)(long)(r))
15681 +#define VX_RLIM(v) ((rlim_t)(v))
15683 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
15684 + ? VLIM_INFINITY : (long long)(r))
15685 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
15686 + ? RLIM_INFINITY : (rlim_t)(v))
15691 +void vx_vsi_meminfo(struct sysinfo *);
15692 +void vx_vsi_swapinfo(struct sysinfo *);
15694 +#define NUM_LIMITS 24
15696 +#endif /* __KERNEL__ */
15697 +#endif /* _VX_LIMIT_H */
15698 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
15699 --- linux-2.6.22.10/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00 +0100
15700 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_cmd.h 2007-08-05 20:53:13 +0200
15702 +#ifndef _VX_LIMIT_CMD_H
15703 +#define _VX_LIMIT_CMD_H
15706 +/* rlimit vserver commands */
15708 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
15709 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
15710 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
15711 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
15713 +struct vcmd_ctx_rlimit_v0 {
15715 + uint64_t minimum;
15716 + uint64_t softlimit;
15717 + uint64_t maximum;
15720 +struct vcmd_ctx_rlimit_mask_v0 {
15721 + uint32_t minimum;
15722 + uint32_t softlimit;
15723 + uint32_t maximum;
15726 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
15728 +struct vcmd_rlimit_stat_v0 {
15732 + uint64_t minimum;
15733 + uint64_t maximum;
15736 +#define CRLIM_UNSET (0ULL)
15737 +#define CRLIM_INFINITY (~0ULL)
15738 +#define CRLIM_KEEP (~1ULL)
15742 +#ifdef CONFIG_IA32_EMULATION
15744 +struct vcmd_ctx_rlimit_v0_x32 {
15746 + uint64_t minimum;
15747 + uint64_t softlimit;
15748 + uint64_t maximum;
15749 +} __attribute__ ((aligned (4)));
15751 +#endif /* CONFIG_IA32_EMULATION */
15753 +#include <linux/compiler.h>
15755 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
15756 +extern int vc_get_rlimit(struct vx_info *, void __user *);
15757 +extern int vc_set_rlimit(struct vx_info *, void __user *);
15758 +extern int vc_reset_minmax(struct vx_info *, void __user *);
15760 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
15762 +#ifdef CONFIG_IA32_EMULATION
15764 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
15765 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
15767 +#endif /* CONFIG_IA32_EMULATION */
15769 +#endif /* __KERNEL__ */
15770 +#endif /* _VX_LIMIT_CMD_H */
15771 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
15772 --- linux-2.6.22.10/include/linux/vserver/limit_def.h 1970-01-01 01:00:00 +0100
15773 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_def.h 2007-08-05 20:53:13 +0200
15775 +#ifndef _VX_LIMIT_DEF_H
15776 +#define _VX_LIMIT_DEF_H
15778 +#include <asm/atomic.h>
15779 +#include <asm/resource.h>
15781 +#include "limit.h"
15784 +struct _vx_res_limit {
15785 + rlim_t soft; /* Context soft limit */
15786 + rlim_t hard; /* Context hard limit */
15788 + rlim_atomic_t rcur; /* Current value */
15789 + rlim_t rmin; /* Context minimum */
15790 + rlim_t rmax; /* Context maximum */
15792 + atomic_t lhit; /* Limit hits */
15795 +/* context sub struct */
15797 +struct _vx_limit {
15798 + struct _vx_res_limit res[NUM_LIMITS];
15801 +#ifdef CONFIG_VSERVER_DEBUG
15803 +static inline void __dump_vx_limit(struct _vx_limit *limit)
15807 + printk("\t_vx_limit:");
15808 + for (i = 0; i < NUM_LIMITS; i++) {
15809 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
15810 + i, (unsigned long)__rlim_get(limit, i),
15811 + (unsigned long)__rlim_rmin(limit, i),
15812 + (unsigned long)__rlim_rmax(limit, i),
15813 + (long)__rlim_soft(limit, i),
15814 + (long)__rlim_hard(limit, i),
15815 + atomic_read(&__rlim_lhit(limit, i)));
15821 +#endif /* _VX_LIMIT_DEF_H */
15822 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
15823 --- linux-2.6.22.10/include/linux/vserver/limit_int.h 1970-01-01 01:00:00 +0100
15824 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/limit_int.h 2007-08-05 20:53:13 +0200
15826 +#ifndef _VX_LIMIT_INT_H
15827 +#define _VX_LIMIT_INT_H
15829 +#include "context.h"
15833 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
15834 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
15836 +extern const char *vlimit_name[NUM_LIMITS];
15838 +static inline void __vx_acc_cres(struct vx_info *vxi,
15839 + int res, int dir, void *_data, char *_file, int _line)
15841 + if (VXD_RCRES_COND(res))
15842 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
15843 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
15844 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
15845 + (dir > 0) ? "++" : "--", _data, _file, _line);
15850 + __rlim_inc(&vxi->limit, res);
15852 + __rlim_dec(&vxi->limit, res);
15855 +static inline void __vx_add_cres(struct vx_info *vxi,
15856 + int res, int amount, void *_data, char *_file, int _line)
15858 + if (VXD_RCRES_COND(res))
15859 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
15860 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
15861 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
15862 + amount, _data, _file, _line);
15867 + __rlim_add(&vxi->limit, res, amount);
15871 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
15873 + int cond = (value > __rlim_rmax(limit, res));
15876 + __rlim_rmax(limit, res) = value;
15881 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
15883 + int cond = (value < __rlim_rmin(limit, res));
15886 + __rlim_rmin(limit, res) = value;
15891 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
15893 + if (!__vx_cres_adjust_max(limit, res, value))
15894 + __vx_cres_adjust_min(limit, res, value);
15899 + +1 ... no limit hit
15900 + -1 ... over soft limit
15901 + 0 ... over hard limit */
15903 +static inline int __vx_cres_avail(struct vx_info *vxi,
15904 + int res, int num, char *_file, int _line)
15906 + struct _vx_limit *limit;
15909 + if (VXD_RLIMIT_COND(res))
15910 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
15911 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
15912 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
15913 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
15914 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
15915 + num, _file, _line);
15919 + limit = &vxi->limit;
15920 + value = __rlim_get(limit, res);
15922 + if (!__vx_cres_adjust_max(limit, res, value))
15923 + __vx_cres_adjust_min(limit, res, value);
15928 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
15930 + if (value + num <= __rlim_soft(limit, res))
15933 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
15935 + if (value + num <= __rlim_hard(limit, res))
15938 + __rlim_hit(limit, res);
15943 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
15946 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
15948 + rlim_t value, sum = 0;
15951 + while ((res = *array++)) {
15952 + value = __rlim_get(limit, res);
15953 + __vx_cres_fixup(limit, res, value);
15960 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
15962 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
15963 + int res = *array;
15965 + if (value == __rlim_get(limit, res))
15968 + __rlim_set(limit, res, value);
15969 + /* now adjust min/max */
15970 + if (!__vx_cres_adjust_max(limit, res, value))
15971 + __vx_cres_adjust_min(limit, res, value);
15976 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
15977 + const int *array, int num, char *_file, int _line)
15979 + struct _vx_limit *limit;
15980 + rlim_t value = 0;
15988 + limit = &vxi->limit;
15990 + value = __vx_cres_array_sum(limit, array + 1);
15992 + __rlim_set(limit, res, value);
15993 + __vx_cres_fixup(limit, res, value);
15995 + return __vx_cres_avail(vxi, res, num, _file, _line);
15999 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
16004 + /* complex resources first */
16005 + if ((id < 0) || (id == RLIMIT_RSS))
16006 + __vx_cres_array_fixup(limit, VLA_RSS);
16008 + for (res = 0; res < NUM_LIMITS; res++) {
16009 + if ((id > 0) && (res != id))
16012 + value = __rlim_get(limit, res);
16013 + __vx_cres_fixup(limit, res, value);
16015 + /* not supposed to happen, maybe warn? */
16016 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
16017 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
16022 +#endif /* __KERNEL__ */
16023 +#endif /* _VX_LIMIT_INT_H */
16024 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
16025 --- linux-2.6.22.10/include/linux/vserver/monitor.h 1970-01-01 01:00:00 +0100
16026 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/monitor.h 2007-08-15 23:16:12 +0200
16028 +#ifndef _VX_MONITOR_H
16029 +#define _VX_MONITOR_H
16031 +#include <linux/types.h>
16038 + VXM_UPDATE = 0x20,
16042 + VXM_RQINFO_1 = 0x24,
16045 + VXM_ACTIVATE = 0x40,
16052 + VXM_MIGRATE = 0x48,
16055 + /* all other bits are flags */
16056 + VXM_SCHED = 0x80,
16059 +struct _vxm_update_1 {
16060 + uint32_t tokens_max;
16061 + uint32_t fill_rate;
16062 + uint32_t interval;
16065 +struct _vxm_update_2 {
16066 + uint32_t tokens_min;
16067 + uint32_t fill_rate;
16068 + uint32_t interval;
16071 +struct _vxm_rqinfo_1 {
16072 + uint16_t running;
16076 + uint32_t idle_tokens;
16079 +struct _vxm_rqinfo_2 {
16080 + uint32_t norm_time;
16081 + uint32_t idle_time;
16082 + uint32_t idle_skip;
16085 +struct _vxm_sched {
16087 + uint32_t norm_time;
16088 + uint32_t idle_time;
16091 +struct _vxm_task {
16096 +struct _vxm_event {
16105 + struct _vxm_task tsk;
16109 +struct _vx_mon_entry {
16113 + struct _vxm_event ev;
16114 + struct _vxm_sched sd;
16115 + struct _vxm_update_1 u1;
16116 + struct _vxm_update_2 u2;
16117 + struct _vxm_rqinfo_1 q1;
16118 + struct _vxm_rqinfo_2 q2;
16123 +#endif /* _VX_MONITOR_H */
16124 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
16125 --- linux-2.6.22.10/include/linux/vserver/network.h 1970-01-01 01:00:00 +0100
16126 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/network.h 2007-10-05 12:29:05 +0200
16128 +#ifndef _VX_NETWORK_H
16129 +#define _VX_NETWORK_H
16131 +#include <linux/types.h>
16134 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
16137 +/* network flags */
16139 +#define NXF_INFO_PRIVATE 0x00000008
16141 +#define NXF_SINGLE_IP 0x00000100
16142 +#define NXF_LBACK_REMAP 0x00000200
16144 +#define NXF_HIDE_NETIF 0x02000000
16145 +#define NXF_HIDE_LBACK 0x04000000
16147 +#define NXF_STATE_SETUP (1ULL << 32)
16148 +#define NXF_STATE_ADMIN (1ULL << 34)
16150 +#define NXF_SC_HELPER (1ULL << 36)
16151 +#define NXF_PERSISTENT (1ULL << 38)
16153 +#define NXF_ONE_TIME (0x0005ULL << 32)
16156 +#define NXF_INIT_SET (__nxf_init_set())
16158 +static inline uint64_t __nxf_init_set(void) {
16159 + return NXF_STATE_ADMIN
16160 +#ifdef CONFIG_VSERVER_AUTO_LBACK
16161 + | NXF_LBACK_REMAP
16164 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
16167 + | NXF_HIDE_NETIF;
16171 +/* network caps */
16173 +#define NXC_RAW_ICMP 0x00000100
16176 +/* address types */
16178 +#define NXA_TYPE_IPV4 0x0001
16179 +#define NXA_TYPE_IPV6 0x0002
16181 +#define NXA_TYPE_NONE 0x0000
16182 +#define NXA_TYPE_ANY 0x00FF
16184 +#define NXA_TYPE_ADDR 0x0010
16185 +#define NXA_TYPE_MASK 0x0020
16186 +#define NXA_TYPE_RANGE 0x0040
16188 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
16190 +#define NXA_MOD_BCAST 0x0100
16191 +#define NXA_MOD_LBACK 0x0200
16193 +#define NXA_LOOPBACK 0x1000
16195 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
16196 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
16200 +#include <linux/list.h>
16201 +#include <linux/spinlock.h>
16202 +#include <linux/rcupdate.h>
16203 +#include <linux/in.h>
16204 +#include <linux/in6.h>
16205 +#include <asm/atomic.h>
16207 +struct nx_addr_v4 {
16208 + struct nx_addr_v4 *next;
16209 + struct in_addr ip[2];
16210 + struct in_addr mask;
16215 +struct nx_addr_v6 {
16216 + struct nx_addr_v6 *next;
16217 + struct in6_addr ip;
16218 + struct in6_addr mask;
16225 + struct hlist_node nx_hlist; /* linked list of nxinfos */
16226 + nid_t nx_id; /* vnet id */
16227 + atomic_t nx_usecnt; /* usage count */
16228 + atomic_t nx_tasks; /* tasks count */
16229 + int nx_state; /* context state */
16231 + uint64_t nx_flags; /* network flag word */
16232 + uint64_t nx_ncaps; /* network capabilities */
16234 + struct in_addr v4_lback; /* Loopback address */
16235 + struct in_addr v4_bcast; /* Broadcast address */
16236 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
16237 +#ifdef CONFIG_IPV6
16238 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
16240 + char nx_name[65]; /* network context name */
16244 +/* status flags */
16246 +#define NXS_HASHED 0x0001
16247 +#define NXS_SHUTDOWN 0x0100
16248 +#define NXS_RELEASED 0x8000
16250 +extern struct nx_info *lookup_nx_info(int);
16252 +extern int get_nid_list(int, unsigned int *, int);
16253 +extern int nid_is_hashed(nid_t);
16255 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
16257 +extern long vs_net_change(struct nx_info *, unsigned int);
16262 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
16263 +#ifdef CONFIG_IPV6
16264 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
16266 +#define NX_IPV6(n) (0)
16269 +#endif /* __KERNEL__ */
16270 +#endif /* _VX_NETWORK_H */
16271 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
16272 --- linux-2.6.22.10/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00 +0100
16273 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/network_cmd.h 2007-08-15 20:08:10 +0200
16275 +#ifndef _VX_NETWORK_CMD_H
16276 +#define _VX_NETWORK_CMD_H
16279 +/* vinfo commands */
16281 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
16284 +extern int vc_task_nid(uint32_t);
16286 +#endif /* __KERNEL__ */
16288 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
16290 +struct vcmd_nx_info_v0 {
16292 + /* more to come */
16296 +extern int vc_nx_info(struct nx_info *, void __user *);
16298 +#endif /* __KERNEL__ */
16300 +#include <linux/in.h>
16301 +#include <linux/in6.h>
16303 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
16304 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
16306 +struct vcmd_net_create {
16307 + uint64_t flagword;
16310 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
16312 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
16313 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
16315 +struct vcmd_net_addr_v0 {
16318 + struct in_addr ip[4];
16319 + struct in_addr mask[4];
16322 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 1)
16323 +#define VCMD_net_remove_ipv4 VC_CMD(NETALT, 2, 1)
16325 +struct vcmd_net_addr_ipv4_v1 {
16328 + struct in_addr ip;
16329 + struct in_addr mask;
16332 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
16333 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
16335 +struct vcmd_net_addr_ipv6_v1 {
16339 + struct in6_addr ip;
16340 + struct in6_addr mask;
16343 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
16344 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
16346 +struct vcmd_match_ipv4_v0 {
16351 + struct in_addr ip;
16352 + struct in_addr ip2;
16353 + struct in_addr mask;
16356 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
16357 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
16359 +struct vcmd_match_ipv6_v0 {
16364 + struct in6_addr ip;
16365 + struct in6_addr ip2;
16366 + struct in6_addr mask;
16371 +extern int vc_net_create(uint32_t, void __user *);
16372 +extern int vc_net_migrate(struct nx_info *, void __user *);
16374 +extern int vc_net_add(struct nx_info *, void __user *);
16375 +extern int vc_net_remove(struct nx_info *, void __user *);
16377 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
16378 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
16380 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
16381 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
16383 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
16384 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
16386 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
16387 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
16389 +#endif /* __KERNEL__ */
16392 +/* flag commands */
16394 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
16395 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
16397 +struct vcmd_net_flags_v0 {
16398 + uint64_t flagword;
16403 +extern int vc_get_nflags(struct nx_info *, void __user *);
16404 +extern int vc_set_nflags(struct nx_info *, void __user *);
16406 +#endif /* __KERNEL__ */
16409 +/* network caps commands */
16411 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
16412 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
16414 +struct vcmd_net_caps_v0 {
16420 +extern int vc_get_ncaps(struct nx_info *, void __user *);
16421 +extern int vc_set_ncaps(struct nx_info *, void __user *);
16423 +#endif /* __KERNEL__ */
16424 +#endif /* _VX_CONTEXT_CMD_H */
16425 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
16426 --- linux-2.6.22.10/include/linux/vserver/percpu.h 1970-01-01 01:00:00 +0100
16427 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/percpu.h 2007-08-05 20:53:13 +0200
16429 +#ifndef _VX_PERCPU_H
16430 +#define _VX_PERCPU_H
16432 +#include "cvirt_def.h"
16433 +#include "sched_def.h"
16435 +struct _vx_percpu {
16436 + struct _vx_cvirt_pc cvirt;
16437 + struct _vx_sched_pc sched;
16440 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
16442 +#endif /* _VX_PERCPU_H */
16443 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
16444 --- linux-2.6.22.10/include/linux/vserver/sched.h 1970-01-01 01:00:00 +0100
16445 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched.h 2007-08-05 20:53:13 +0200
16447 +#ifndef _VX_SCHED_H
16448 +#define _VX_SCHED_H
16455 +void vx_vsi_uptime(struct timespec *, struct timespec *);
16460 +void vx_update_load(struct vx_info *);
16463 +int vx_tokens_recalc(struct _vx_sched_pc *,
16464 + unsigned long *, unsigned long *, int [2]);
16466 +void vx_update_sched_param(struct _vx_sched *sched,
16467 + struct _vx_sched_pc *sched_pc);
16469 +#endif /* __KERNEL__ */
16470 +#else /* _VX_SCHED_H */
16471 +#warning duplicate inclusion
16472 +#endif /* _VX_SCHED_H */
16473 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
16474 --- linux-2.6.22.10/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00 +0100
16475 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched_cmd.h 2007-08-05 20:53:13 +0200
16477 +#ifndef _VX_SCHED_CMD_H
16478 +#define _VX_SCHED_CMD_H
16481 +/* sched vserver commands */
16483 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
16484 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
16485 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
16487 +struct vcmd_set_sched_v2 {
16488 + int32_t fill_rate;
16489 + int32_t interval;
16491 + int32_t tokens_min;
16492 + int32_t tokens_max;
16493 + uint64_t cpu_mask;
16496 +struct vcmd_set_sched_v3 {
16497 + uint32_t set_mask;
16498 + int32_t fill_rate;
16499 + int32_t interval;
16501 + int32_t tokens_min;
16502 + int32_t tokens_max;
16503 + int32_t priority_bias;
16506 +struct vcmd_set_sched_v4 {
16507 + uint32_t set_mask;
16508 + int32_t fill_rate;
16509 + int32_t interval;
16511 + int32_t tokens_min;
16512 + int32_t tokens_max;
16513 + int32_t prio_bias;
16515 + int32_t bucket_id;
16518 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
16519 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
16521 +struct vcmd_sched_v5 {
16524 + int32_t bucket_id;
16525 + int32_t fill_rate[2];
16526 + int32_t interval[2];
16528 + int32_t tokens_min;
16529 + int32_t tokens_max;
16530 + int32_t prio_bias;
16533 +#define VXSM_FILL_RATE 0x0001
16534 +#define VXSM_INTERVAL 0x0002
16535 +#define VXSM_FILL_RATE2 0x0004
16536 +#define VXSM_INTERVAL2 0x0008
16537 +#define VXSM_TOKENS 0x0010
16538 +#define VXSM_TOKENS_MIN 0x0020
16539 +#define VXSM_TOKENS_MAX 0x0040
16540 +#define VXSM_PRIO_BIAS 0x0100
16542 +#define VXSM_IDLE_TIME 0x0200
16543 +#define VXSM_FORCE 0x0400
16545 +#define VXSM_V3_MASK 0x0173
16546 +#define VXSM_SET_MASK 0x01FF
16548 +#define VXSM_CPU_ID 0x1000
16549 +#define VXSM_BUCKET_ID 0x2000
16551 +#define VXSM_MSEC 0x4000
16553 +#define SCHED_KEEP (-2) /* only for v2 */
16557 +#include <linux/compiler.h>
16559 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
16560 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
16561 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
16562 +extern int vc_set_sched(struct vx_info *, void __user *);
16563 +extern int vc_get_sched(struct vx_info *, void __user *);
16565 +#endif /* __KERNEL__ */
16567 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
16569 +struct vcmd_sched_info {
16571 + int32_t bucket_id;
16572 + uint64_t user_msec;
16573 + uint64_t sys_msec;
16574 + uint64_t hold_msec;
16575 + uint32_t token_usec;
16576 + int32_t vavavoom;
16581 +extern int vc_sched_info(struct vx_info *, void __user *);
16583 +#endif /* __KERNEL__ */
16584 +#endif /* _VX_SCHED_CMD_H */
16585 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
16586 --- linux-2.6.22.10/include/linux/vserver/sched_def.h 1970-01-01 01:00:00 +0100
16587 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/sched_def.h 2007-08-05 20:53:13 +0200
16589 +#ifndef _VX_SCHED_DEF_H
16590 +#define _VX_SCHED_DEF_H
16592 +#include <linux/spinlock.h>
16593 +#include <linux/jiffies.h>
16594 +#include <linux/cpumask.h>
16595 +#include <asm/atomic.h>
16596 +#include <asm/param.h>
16599 +/* context sub struct */
16601 +struct _vx_sched {
16602 + spinlock_t tokens_lock; /* lock for token bucket */
16604 + int tokens; /* number of CPU tokens */
16605 + int fill_rate[2]; /* Fill rate: add X tokens... */
16606 + int interval[2]; /* Divisor: per Y jiffies */
16607 + int tokens_min; /* Limit: minimum for unhold */
16608 + int tokens_max; /* Limit: no more than N tokens */
16610 + int prio_bias; /* bias offset for priority */
16612 + unsigned update_mask; /* which features should be updated */
16613 + cpumask_t update; /* CPUs which should update */
16616 +struct _vx_sched_pc {
16617 + int tokens; /* number of CPU tokens */
16618 + int flags; /* bucket flags */
16620 + int fill_rate[2]; /* Fill rate: add X tokens... */
16621 + int interval[2]; /* Divisor: per Y jiffies */
16622 + int tokens_min; /* Limit: minimum for unhold */
16623 + int tokens_max; /* Limit: no more than N tokens */
16625 + int prio_bias; /* bias offset for priority */
16626 + int vavavoom; /* last calculated vavavoom */
16628 + unsigned long norm_time; /* last time accounted */
16629 + unsigned long idle_time; /* non linear time for fair sched */
16630 + unsigned long token_time; /* token time for accounting */
16631 + unsigned long onhold; /* jiffies when put on hold */
16633 + uint64_t user_ticks; /* token tick events */
16634 + uint64_t sys_ticks; /* token tick events */
16635 + uint64_t hold_ticks; /* token ticks paused */
16639 +#define VXSF_ONHOLD 0x0001
16640 +#define VXSF_IDLE_TIME 0x0100
16642 +#ifdef CONFIG_VSERVER_DEBUG
16644 +static inline void __dump_vx_sched(struct _vx_sched *sched)
16646 + printk("\t_vx_sched:\n");
16647 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
16648 + sched->fill_rate[0], sched->interval[0],
16649 + sched->fill_rate[1], sched->interval[1],
16650 + sched->tokens_min, sched->tokens_max);
16651 + printk("\t priority = %4d\n", sched->prio_bias);
16656 +#endif /* _VX_SCHED_DEF_H */
16657 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
16658 --- linux-2.6.22.10/include/linux/vserver/signal.h 1970-01-01 01:00:00 +0100
16659 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/signal.h 2007-08-05 20:53:13 +0200
16661 +#ifndef _VX_SIGNAL_H
16662 +#define _VX_SIGNAL_H
16669 +int vx_info_kill(struct vx_info *, int, int);
16671 +#endif /* __KERNEL__ */
16672 +#else /* _VX_SIGNAL_H */
16673 +#warning duplicate inclusion
16674 +#endif /* _VX_SIGNAL_H */
16675 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
16676 --- linux-2.6.22.10/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00 +0100
16677 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/signal_cmd.h 2007-08-05 20:53:13 +0200
16679 +#ifndef _VX_SIGNAL_CMD_H
16680 +#define _VX_SIGNAL_CMD_H
16683 +/* signalling vserver commands */
16685 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
16686 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
16688 +struct vcmd_ctx_kill_v0 {
16693 +struct vcmd_wait_exit_v0 {
16694 + int32_t reboot_cmd;
16695 + int32_t exit_code;
16700 +extern int vc_ctx_kill(struct vx_info *, void __user *);
16701 +extern int vc_wait_exit(struct vx_info *, void __user *);
16703 +#endif /* __KERNEL__ */
16705 +/* process alteration commands */
16707 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
16708 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
16710 +struct vcmd_pflags_v0 {
16711 + uint32_t flagword;
16717 +extern int vc_get_pflags(uint32_t pid, void __user *);
16718 +extern int vc_set_pflags(uint32_t pid, void __user *);
16720 +#endif /* __KERNEL__ */
16721 +#endif /* _VX_SIGNAL_CMD_H */
16722 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
16723 --- linux-2.6.22.10/include/linux/vserver/space.h 1970-01-01 01:00:00 +0100
16724 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/space.h 2007-08-05 20:53:13 +0200
16726 +#ifndef _VX_SPACE_H
16727 +#define _VX_SPACE_H
16730 +#include <linux/types.h>
16734 +int vx_set_space(struct vx_info *vxi, unsigned long mask);
16736 +#else /* _VX_SPACE_H */
16737 +#warning duplicate inclusion
16738 +#endif /* _VX_SPACE_H */
16739 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
16740 --- linux-2.6.22.10/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00 +0100
16741 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/space_cmd.h 2007-08-05 20:53:13 +0200
16743 +#ifndef _VX_SPACE_CMD_H
16744 +#define _VX_SPACE_CMD_H
16747 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
16748 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 1)
16750 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
16751 +#define VCMD_set_space VC_CMD(PROCALT, 3, 1)
16753 +#define VCMD_get_space_mask VC_CMD(PROCALT, 4, 0)
16756 +struct vcmd_space_mask {
16763 +extern int vc_enter_space(struct vx_info *, void __user *);
16764 +extern int vc_set_space(struct vx_info *, void __user *);
16765 +extern int vc_get_space_mask(struct vx_info *, void __user *);
16767 +#endif /* __KERNEL__ */
16768 +#endif /* _VX_SPACE_CMD_H */
16769 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
16770 --- linux-2.6.22.10/include/linux/vserver/switch.h 1970-01-01 01:00:00 +0100
16771 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/switch.h 2007-10-11 01:10:22 +0200
16773 +#ifndef _VX_SWITCH_H
16774 +#define _VX_SWITCH_H
16776 +#include <linux/types.h>
16779 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
16780 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
16781 +#define VC_VERSION(c) ((c) & 0xFFF)
16783 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
16784 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
16788 + Syscall Matrix V2.8
16790 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
16791 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
16792 + |INFO |SETUP | |MOVE | | | | | |
16793 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16794 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
16795 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
16796 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16797 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
16798 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
16799 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16800 + MEMORY | | | | |MEMCTRL| | |SWAP | |
16801 + | 16| 17| 18| 19| 20| 21| | 22| 23|
16802 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16803 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
16804 + | 24| 25| 26| 27| 28| 29| | 30| 31|
16805 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16806 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
16807 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
16808 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16809 + OTHER |VSTAT | | | | | | |VINFO | |
16810 + | 40| 41| 42| 43| 44| 45| | 46| 47|
16811 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
16812 + SPECIAL|EVENT | | | |FLAGS | | | | |
16813 + | 48| 49| 50| 51| 52| 53| | 54| 55|
16814 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16815 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
16816 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
16817 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
16821 +#define VC_CAT_VERSION 0
16823 +#define VC_CAT_VSETUP 1
16824 +#define VC_CAT_VHOST 2
16826 +#define VC_CAT_DEVICE 6
16828 +#define VC_CAT_VPROC 9
16829 +#define VC_CAT_PROCALT 10
16830 +#define VC_CAT_PROCMIG 11
16831 +#define VC_CAT_PROCTRL 12
16833 +#define VC_CAT_SCHED 14
16834 +#define VC_CAT_MEMCTRL 20
16836 +#define VC_CAT_VNET 25
16837 +#define VC_CAT_NETALT 26
16838 +#define VC_CAT_NETMIG 27
16839 +#define VC_CAT_NETCTRL 28
16841 +#define VC_CAT_TAGMIG 35
16842 +#define VC_CAT_DLIMIT 36
16843 +#define VC_CAT_INODE 38
16845 +#define VC_CAT_VSTAT 40
16846 +#define VC_CAT_VINFO 46
16847 +#define VC_CAT_EVENT 48
16849 +#define VC_CAT_FLAGS 52
16850 +#define VC_CAT_DEBUG 56
16851 +#define VC_CAT_RLIMIT 60
16853 +#define VC_CAT_SYSTEST 61
16854 +#define VC_CAT_COMPAT 63
16856 +/* query version */
16858 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
16859 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
16864 +#include <linux/errno.h>
16867 +#else /* __KERNEL__ */
16869 +#endif /* __KERNEL__ */
16871 +#endif /* _VX_SWITCH_H */
16872 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
16873 --- linux-2.6.22.10/include/linux/vserver/tag.h 1970-01-01 01:00:00 +0100
16874 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/tag.h 2007-10-10 19:05:04 +0200
16879 +#include <linux/types.h>
16882 +#define DX_TAG(in) (IS_TAGGED(in))
16885 +#ifdef CONFIG_DX_TAG_NFSD
16886 +#define DX_TAG_NFSD 1
16888 +#define DX_TAG_NFSD 0
16892 +#ifdef CONFIG_TAGGING_NONE
16894 +#define MAX_UID 0xFFFFFFFF
16895 +#define MAX_GID 0xFFFFFFFF
16897 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
16899 +#define TAGINO_UID(cond, uid, tag) (uid)
16900 +#define TAGINO_GID(cond, gid, tag) (gid)
16905 +#ifdef CONFIG_TAGGING_GID16
16907 +#define MAX_UID 0xFFFFFFFF
16908 +#define MAX_GID 0x0000FFFF
16910 +#define INOTAG_TAG(cond, uid, gid, tag) \
16911 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
16913 +#define TAGINO_UID(cond, uid, tag) (uid)
16914 +#define TAGINO_GID(cond, gid, tag) \
16915 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
16920 +#ifdef CONFIG_TAGGING_ID24
16922 +#define MAX_UID 0x00FFFFFF
16923 +#define MAX_GID 0x00FFFFFF
16925 +#define INOTAG_TAG(cond, uid, gid, tag) \
16926 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
16928 +#define TAGINO_UID(cond, uid, tag) \
16929 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
16930 +#define TAGINO_GID(cond, gid, tag) \
16931 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
16936 +#ifdef CONFIG_TAGGING_UID16
16938 +#define MAX_UID 0x0000FFFF
16939 +#define MAX_GID 0xFFFFFFFF
16941 +#define INOTAG_TAG(cond, uid, gid, tag) \
16942 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
16944 +#define TAGINO_UID(cond, uid, tag) \
16945 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
16946 +#define TAGINO_GID(cond, gid, tag) (gid)
16951 +#ifdef CONFIG_TAGGING_INTERN
16953 +#define MAX_UID 0xFFFFFFFF
16954 +#define MAX_GID 0xFFFFFFFF
16956 +#define INOTAG_TAG(cond, uid, gid, tag) \
16957 + ((cond) ? (tag) : 0)
16959 +#define TAGINO_UID(cond, uid, tag) (uid)
16960 +#define TAGINO_GID(cond, gid, tag) (gid)
16965 +#ifndef CONFIG_TAGGING_NONE
16966 +#define dx_current_fstag(sb) \
16967 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
16969 +#define dx_current_fstag(sb) (0)
16972 +#ifndef CONFIG_TAGGING_INTERN
16973 +#define TAGINO_TAG(cond, tag) (0)
16975 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
16978 +#define INOTAG_UID(cond, uid, gid) \
16979 + ((cond) ? ((uid) & MAX_UID) : (uid))
16980 +#define INOTAG_GID(cond, uid, gid) \
16981 + ((cond) ? ((gid) & MAX_GID) : (gid))
16984 +static inline uid_t dx_map_uid(uid_t uid)
16986 + if ((uid > MAX_UID) && (uid != -1))
16988 + return (uid & MAX_UID);
16991 +static inline gid_t dx_map_gid(gid_t gid)
16993 + if ((gid > MAX_GID) && (gid != -1))
16995 + return (gid & MAX_GID);
17003 +#define dx_notagcheck(nd) \
17004 + ((nd) && (nd)->mnt && ((nd)->mnt->mnt_flags & MNT_NOTAGCHECK))
17006 +int dx_parse_tag(char *string, tag_t *tag, int remove);
17008 +#ifdef CONFIG_PROPAGATE
17010 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
17012 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
17015 +#define dx_propagate_tag(n, i) do { } while (0)
17018 +#endif /* _DX_TAG_H */
17019 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
17020 --- linux-2.6.22.10/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00 +0100
17021 +++ linux-2.6.22.10-vs2.3.0.29/include/linux/vserver/tag_cmd.h 2007-08-15 20:16:43 +0200
17023 +#ifndef _VX_TAG_CMD_H
17024 +#define _VX_TAG_CMD_H
17027 +/* vinfo commands */
17029 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
17032 +extern int vc_task_tag(uint32_t);
17034 +#endif /* __KERNEL__ */
17036 +/* context commands */
17038 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
17041 +extern int vc_tag_migrate(uint32_t);
17043 +#endif /* __KERNEL__ */
17044 +#endif /* _VX_TAG_CMD_H */
17045 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
17046 --- linux-2.6.22.10/include/net/addrconf.h 2007-07-09 13:20:01 +0200
17047 +++ linux-2.6.22.10-vs2.3.0.29/include/net/addrconf.h 2007-08-12 00:22:19 +0200
17048 @@ -69,10 +69,12 @@ extern struct inet6_ifaddr * ipv6_get_if
17050 extern int ipv6_get_saddr(struct dst_entry *dst,
17051 struct in6_addr *daddr,
17052 - struct in6_addr *saddr);
17053 + struct in6_addr *saddr,
17054 + struct nx_info *nxi);
17055 extern int ipv6_dev_get_saddr(struct net_device *dev,
17056 struct in6_addr *daddr,
17057 - struct in6_addr *saddr);
17058 + struct in6_addr *saddr,
17059 + struct nx_info *nxi);
17060 extern int ipv6_get_lladdr(struct net_device *dev,
17061 struct in6_addr *addr,
17062 unsigned char banned_flags);
17063 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
17064 --- linux-2.6.22.10/include/net/af_unix.h 2007-07-09 13:20:01 +0200
17065 +++ linux-2.6.22.10-vs2.3.0.29/include/net/af_unix.h 2007-08-05 20:53:13 +0200
17067 #include <linux/socket.h>
17068 #include <linux/un.h>
17069 #include <linux/mutex.h>
17070 +#include <linux/vs_base.h>
17071 #include <net/sock.h>
17073 extern void unix_inflight(struct file *fp);
17074 @@ -17,9 +18,9 @@ extern spinlock_t unix_table_lock;
17076 extern atomic_t unix_tot_inflight;
17078 -static inline struct sock *first_unix_socket(int *i)
17079 +static inline struct sock *next_unix_socket_table(int *i)
17081 - for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
17082 + for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
17083 if (!hlist_empty(&unix_socket_table[*i]))
17084 return __sk_head(&unix_socket_table[*i]);
17086 @@ -28,16 +29,19 @@ static inline struct sock *first_unix_so
17088 static inline struct sock *next_unix_socket(int *i, struct sock *s)
17090 - struct sock *next = sk_next(s);
17091 - /* More in this chain? */
17094 - /* Look for next non-empty chain. */
17095 - for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
17096 - if (!hlist_empty(&unix_socket_table[*i]))
17097 - return __sk_head(&unix_socket_table[*i]);
17104 + s = next_unix_socket_table(i);
17105 + } while (s && !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT));
17109 +static inline struct sock *first_unix_socket(int *i)
17112 + return next_unix_socket(i, NULL);
17115 #define forall_unix_sockets(i, s) \
17116 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
17117 --- linux-2.6.22.10/include/net/inet_timewait_sock.h 2007-05-02 19:25:35 +0200
17118 +++ linux-2.6.22.10-vs2.3.0.29/include/net/inet_timewait_sock.h 2007-08-05 20:53:13 +0200
17119 @@ -115,6 +115,10 @@ struct inet_timewait_sock {
17120 #define tw_refcnt __tw_common.skc_refcnt
17121 #define tw_hash __tw_common.skc_hash
17122 #define tw_prot __tw_common.skc_prot
17123 +#define tw_xid __tw_common.skc_xid
17124 +#define tw_vx_info __tw_common.skc_vx_info
17125 +#define tw_nid __tw_common.skc_nid
17126 +#define tw_nx_info __tw_common.skc_nx_info
17127 volatile unsigned char tw_substate;
17128 /* 3 bits hole, try to pack */
17129 unsigned char tw_rcv_wscale;
17130 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
17131 --- linux-2.6.22.10/include/net/route.h 2007-05-02 19:25:35 +0200
17132 +++ linux-2.6.22.10-vs2.3.0.29/include/net/route.h 2007-09-18 03:52:05 +0200
17133 @@ -27,12 +27,16 @@
17134 #include <net/dst.h>
17135 #include <net/inetpeer.h>
17136 #include <net/flow.h>
17137 +#include <net/inet_sock.h>
17138 #include <linux/in_route.h>
17139 #include <linux/rtnetlink.h>
17140 #include <linux/route.h>
17141 #include <linux/ip.h>
17142 #include <linux/cache.h>
17143 #include <linux/security.h>
17144 +#include <linux/vs_base.h>
17145 +#include <linux/vs_inet.h>
17146 +#include <linux/in.h>
17149 #warning This file is not supposed to be used outside of kernel.
17150 @@ -143,6 +147,8 @@ static inline char rt_tos2priority(u8 to
17151 return ip_tos2prio[IPTOS_TOS(tos)>>1];
17154 +extern int ip_v4_find_src(struct nx_info *, struct rtable **, struct flowi *);
17156 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
17157 __be32 src, u32 tos, int oif, u8 protocol,
17158 __be16 sport, __be16 dport, struct sock *sk,
17159 @@ -158,7 +164,21 @@ static inline int ip_route_connect(struc
17160 .dport = dport } } };
17163 - if (!dst || !src) {
17164 + struct nx_info *nx_info = current->nx_info;
17167 + nx_info = sk->sk_nx_info;
17169 + vxdprintk(VXD_CBIT(net, 4),
17170 + "ip_route_connect(%p) %p,%p;%lx",
17171 + sk, nx_info, sk->sk_socket,
17172 + (sk->sk_socket?sk->sk_socket->flags:0));
17174 + err = ip_v4_find_src(nx_info, rp, &fl);
17178 + if (!fl.fl4_dst || !fl.fl4_src) {
17179 err = __ip_route_output_key(rp, &fl);
17182 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
17183 --- linux-2.6.22.10/include/net/sock.h 2007-07-09 13:20:02 +0200
17184 +++ linux-2.6.22.10-vs2.3.0.29/include/net/sock.h 2007-08-05 20:53:13 +0200
17185 @@ -119,6 +119,10 @@ struct sock_common {
17186 atomic_t skc_refcnt;
17187 unsigned int skc_hash;
17188 struct proto *skc_prot;
17190 + struct vx_info *skc_vx_info;
17192 + struct nx_info *skc_nx_info;
17196 @@ -195,6 +199,10 @@ struct sock {
17197 #define sk_refcnt __sk_common.skc_refcnt
17198 #define sk_hash __sk_common.skc_hash
17199 #define sk_prot __sk_common.skc_prot
17200 +#define sk_xid __sk_common.skc_xid
17201 +#define sk_vx_info __sk_common.skc_vx_info
17202 +#define sk_nid __sk_common.skc_nid
17203 +#define sk_nx_info __sk_common.skc_nx_info
17204 unsigned char sk_shutdown : 2,
17207 diff -NurpP --minimal linux-2.6.22.10/init/main.c linux-2.6.22.10-vs2.3.0.29/init/main.c
17208 --- linux-2.6.22.10/init/main.c 2007-07-09 13:20:03 +0200
17209 +++ linux-2.6.22.10-vs2.3.0.29/init/main.c 2007-08-05 20:53:13 +0200
17211 #include <linux/pid_namespace.h>
17212 #include <linux/device.h>
17213 #include <linux/kthread.h>
17214 +#include <linux/vserver/percpu.h>
17216 #include <asm/io.h>
17217 #include <asm/bugs.h>
17218 @@ -364,12 +365,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
17220 static void __init setup_per_cpu_areas(void)
17222 - unsigned long size, i;
17223 + unsigned long size, vspc, i;
17225 unsigned long nr_possible_cpus = num_possible_cpus();
17227 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
17229 /* Copy section for each CPU (we discard the original) */
17230 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
17231 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
17232 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
17234 for_each_possible_cpu(i) {
17235 diff -NurpP --minimal linux-2.6.22.10/ipc/mqueue.c linux-2.6.22.10-vs2.3.0.29/ipc/mqueue.c
17236 --- linux-2.6.22.10/ipc/mqueue.c 2007-07-09 13:20:03 +0200
17237 +++ linux-2.6.22.10-vs2.3.0.29/ipc/mqueue.c 2007-10-01 14:57:41 +0200
17239 #include <linux/audit.h>
17240 #include <linux/signal.h>
17241 #include <linux/mutex.h>
17242 +#include <linux/vs_context.h>
17243 +#include <linux/vs_limit.h>
17245 #include <net/sock.h>
17247 @@ -151,17 +153,20 @@ static struct inode *mqueue_get_inode(st
17248 spin_lock(&mq_lock);
17249 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
17250 u->mq_bytes + mq_bytes >
17251 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
17252 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
17253 + !vx_ipcmsg_avail(p->vx_info, mq_bytes)) {
17254 spin_unlock(&mq_lock);
17257 u->mq_bytes += mq_bytes;
17258 + vx_ipcmsg_add(p->vx_info, u, mq_bytes);
17259 spin_unlock(&mq_lock);
17261 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
17262 if (!info->messages) {
17263 spin_lock(&mq_lock);
17264 u->mq_bytes -= mq_bytes;
17265 + vx_ipcmsg_sub(p->vx_info, u, mq_bytes);
17266 spin_unlock(&mq_lock);
17269 @@ -257,10 +262,14 @@ static void mqueue_delete_inode(struct i
17270 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
17273 + struct vx_info *vxi = lookup_vx_info(user->xid);
17275 spin_lock(&mq_lock);
17276 user->mq_bytes -= mq_bytes;
17277 + vx_ipcmsg_sub(vxi, user, mq_bytes);
17279 spin_unlock(&mq_lock);
17280 + put_vx_info(vxi);
17284 @@ -748,7 +757,7 @@ asmlinkage long sys_mq_unlink(const char
17286 atomic_inc(&inode->i_count);
17288 - err = vfs_unlink(dentry->d_parent->d_inode, dentry);
17289 + err = vfs_unlink(dentry->d_parent->d_inode, dentry, NULL);
17293 diff -NurpP --minimal linux-2.6.22.10/ipc/msg.c linux-2.6.22.10-vs2.3.0.29/ipc/msg.c
17294 --- linux-2.6.22.10/ipc/msg.c 2007-02-06 03:01:55 +0100
17295 +++ linux-2.6.22.10-vs2.3.0.29/ipc/msg.c 2007-08-05 20:53:13 +0200
17297 #include <linux/seq_file.h>
17298 #include <linux/mutex.h>
17299 #include <linux/nsproxy.h>
17300 +#include <linux/vs_base.h>
17302 #include <asm/current.h>
17303 #include <asm/uaccess.h>
17304 @@ -149,6 +150,7 @@ static int newque (struct ipc_namespace
17306 msq->q_perm.mode = msgflg & S_IRWXUGO;
17307 msq->q_perm.key = key;
17308 + msq->q_perm.xid = vx_current_xid();
17310 msq->q_perm.security = NULL;
17311 retval = security_msg_queue_alloc(msq);
17312 diff -NurpP --minimal linux-2.6.22.10/ipc/sem.c linux-2.6.22.10-vs2.3.0.29/ipc/sem.c
17313 --- linux-2.6.22.10/ipc/sem.c 2007-07-09 13:20:03 +0200
17314 +++ linux-2.6.22.10-vs2.3.0.29/ipc/sem.c 2007-08-05 20:53:13 +0200
17316 #include <linux/seq_file.h>
17317 #include <linux/mutex.h>
17318 #include <linux/nsproxy.h>
17319 +#include <linux/vs_base.h>
17320 +#include <linux/vs_limit.h>
17322 #include <asm/uaccess.h>
17324 @@ -229,6 +231,7 @@ static int newary (struct ipc_namespace
17326 sma->sem_perm.mode = (semflg & S_IRWXUGO);
17327 sma->sem_perm.key = key;
17328 + sma->sem_perm.xid = vx_current_xid();
17330 sma->sem_perm.security = NULL;
17331 retval = security_sem_alloc(sma);
17332 @@ -244,6 +247,9 @@ static int newary (struct ipc_namespace
17335 ns->used_sems += nsems;
17336 + /* FIXME: obsoleted? */
17337 + vx_semary_inc(sma);
17338 + vx_nsems_add(sma, nsems);
17340 sma->sem_id = sem_buildid(ns, id, sma->sem_perm.seq);
17341 sma->sem_base = (struct sem *) &sma[1];
17342 @@ -525,6 +531,9 @@ static void freeary (struct ipc_namespac
17345 ns->used_sems -= sma->sem_nsems;
17346 + /* FIXME: obsoleted? */
17347 + vx_nsems_sub(sma, sma->sem_nsems);
17348 + vx_semary_dec(sma);
17349 size = sizeof (*sma) + sma->sem_nsems * sizeof (struct sem);
17350 security_sem_free(sma);
17351 ipc_rcu_putref(sma);
17352 diff -NurpP --minimal linux-2.6.22.10/ipc/shm.c linux-2.6.22.10-vs2.3.0.29/ipc/shm.c
17353 --- linux-2.6.22.10/ipc/shm.c 2007-10-30 01:57:14 +0100
17354 +++ linux-2.6.22.10-vs2.3.0.29/ipc/shm.c 2007-10-01 14:57:41 +0200
17356 #include <linux/mutex.h>
17357 #include <linux/nsproxy.h>
17358 #include <linux/mount.h>
17359 +#include <linux/vs_context.h>
17360 +#include <linux/vs_limit.h>
17362 #include <asm/uaccess.h>
17364 @@ -185,7 +187,12 @@ static void shm_open(struct vm_area_stru
17366 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
17368 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
17369 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
17370 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
17372 + vx_ipcshm_sub(vxi, shp, numpages);
17373 + ns->shm_tot -= numpages;
17375 shm_rmid(ns, shp->id);
17377 if (!is_file_hugepages(shp->shm_file))
17378 @@ -195,6 +202,7 @@ static void shm_destroy(struct ipc_names
17380 fput (shp->shm_file);
17381 security_shm_free(shp);
17382 + put_vx_info(vxi);
17383 ipc_rcu_putref(shp);
17386 @@ -351,11 +359,15 @@ static int newseg (struct ipc_namespace
17387 if (ns->shm_tot + numpages > ns->shm_ctlall)
17390 + if (!vx_ipcshm_avail(current->vx_info, numpages))
17393 shp = ipc_rcu_alloc(sizeof(*shp));
17397 shp->shm_perm.key = key;
17398 + shp->shm_perm.xid = vx_current_xid();
17399 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
17400 shp->mlock_user = NULL;
17402 @@ -406,6 +418,7 @@ static int newseg (struct ipc_namespace
17403 file->f_dentry->d_inode->i_ino = shp->id;
17405 ns->shm_tot += numpages;
17406 + vx_ipcshm_add(current->vx_info, key, numpages);
17410 diff -NurpP --minimal linux-2.6.22.10/ipc/util.c linux-2.6.22.10-vs2.3.0.29/ipc/util.c
17411 --- linux-2.6.22.10/ipc/util.c 2007-07-09 13:20:03 +0200
17412 +++ linux-2.6.22.10-vs2.3.0.29/ipc/util.c 2007-08-05 20:53:13 +0200
17414 #include <linux/proc_fs.h>
17415 #include <linux/audit.h>
17416 #include <linux/nsproxy.h>
17417 +#include <linux/vs_base.h>
17418 +#include <linux/vserver/global.h>
17420 #include <asm/unistd.h>
17422 @@ -72,6 +74,7 @@ static struct ipc_namespace *clone_ipc_n
17425 kref_init(&ns->kref);
17426 + atomic_inc(&vs_global_ipc_ns);
17430 @@ -108,6 +111,7 @@ void free_ipc_ns(struct kref *kref)
17434 + atomic_dec(&vs_global_ipc_ns);
17438 diff -NurpP --minimal linux-2.6.22.10/kernel/Makefile linux-2.6.22.10-vs2.3.0.29/kernel/Makefile
17439 --- linux-2.6.22.10/kernel/Makefile 2007-07-09 13:20:03 +0200
17440 +++ linux-2.6.22.10-vs2.3.0.29/kernel/Makefile 2007-08-05 20:53:13 +0200
17441 @@ -10,6 +10,8 @@ obj-y = sched.o fork.o exec_domain.o
17442 kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
17443 hrtimer.o rwsem.o latency.o nsproxy.o srcu.o die_notifier.o
17447 obj-$(CONFIG_STACKTRACE) += stacktrace.o
17449 obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
17450 diff -NurpP --minimal linux-2.6.22.10/kernel/capability.c linux-2.6.22.10-vs2.3.0.29/kernel/capability.c
17451 --- linux-2.6.22.10/kernel/capability.c 2007-05-02 19:25:37 +0200
17452 +++ linux-2.6.22.10-vs2.3.0.29/kernel/capability.c 2007-08-05 20:53:13 +0200
17454 #include <linux/module.h>
17455 #include <linux/security.h>
17456 #include <linux/syscalls.h>
17457 +#include <linux/vs_context.h>
17458 #include <asm/uaccess.h>
17460 unsigned securebits = SECUREBITS_DEFAULT; /* systemwide security settings */
17461 @@ -103,6 +104,8 @@ static inline int cap_set_pg(int pgrp_nr
17463 pgrp = find_pid(pgrp_nr);
17464 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
17465 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
17468 while_each_thread(g, target) {
17469 if (!security_capset_check(target, effective,
17470 @@ -246,8 +249,12 @@ int __capable(struct task_struct *t, int
17472 EXPORT_SYMBOL(__capable);
17474 +#include <linux/vserver/base.h>
17475 int capable(int cap)
17477 + /* here for now so we don't require task locking */
17478 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
17480 return __capable(current, cap);
17482 EXPORT_SYMBOL(capable);
17483 diff -NurpP --minimal linux-2.6.22.10/kernel/compat.c linux-2.6.22.10-vs2.3.0.29/kernel/compat.c
17484 --- linux-2.6.22.10/kernel/compat.c 2007-07-09 13:20:03 +0200
17485 +++ linux-2.6.22.10-vs2.3.0.29/kernel/compat.c 2007-08-05 20:53:13 +0200
17486 @@ -846,7 +846,7 @@ asmlinkage long compat_sys_time(compat_t
17490 - do_gettimeofday(&tv);
17491 + vx_gettimeofday(&tv);
17495 @@ -870,7 +870,7 @@ asmlinkage long compat_sys_stime(compat_
17499 - do_settimeofday(&tv);
17500 + vx_settimeofday(&tv);
17504 diff -NurpP --minimal linux-2.6.22.10/kernel/exit.c linux-2.6.22.10-vs2.3.0.29/kernel/exit.c
17505 --- linux-2.6.22.10/kernel/exit.c 2007-07-09 13:20:03 +0200
17506 +++ linux-2.6.22.10-vs2.3.0.29/kernel/exit.c 2007-10-01 18:31:46 +0200
17508 #include <linux/resource.h>
17509 #include <linux/blkdev.h>
17510 #include <linux/task_io_accounting_ops.h>
17511 +#include <linux/vs_limit.h>
17512 +#include <linux/vs_context.h>
17513 +#include <linux/vs_network.h>
17514 +#include <linux/vs_pid.h>
17515 +#include <linux/vserver/global.h>
17517 #include <asm/uaccess.h>
17518 #include <asm/unistd.h>
17519 @@ -443,9 +448,11 @@ static void close_files(struct files_str
17520 filp_close(file, files);
17523 + vx_openfd_dec(i);
17531 @@ -525,6 +532,7 @@ static inline void __put_fs_struct(struc
17533 mntput(fs->altrootmnt);
17535 + atomic_dec(&vs_global_fs);
17536 kmem_cache_free(fs_cachep, fs);
17539 @@ -596,6 +604,14 @@ static void exit_mm(struct task_struct *
17541 choose_new_parent(struct task_struct *p, struct task_struct *reaper)
17543 + /* check for reaper context */
17544 + vxwprintk((p->xid != reaper->xid) && (reaper != child_reaper(p)),
17545 + "rogue reaper: %p[%d,#%u] <> %p[%d,#%u]",
17546 + p, p->pid, p->xid, reaper, reaper->pid, reaper->xid);
17549 + reaper = vx_child_reaper(p);
17552 * Make sure we're not reparenting to ourselves and that
17553 * the parent is not a zombie.
17554 @@ -687,7 +703,7 @@ forget_original_parent(struct task_struc
17556 reaper = next_thread(reaper);
17557 if (reaper == father) {
17558 - reaper = child_reaper(father);
17559 + reaper = vx_child_reaper(father);
17562 } while (reaper->exit_state);
17563 @@ -964,6 +980,8 @@ fastcall NORET_TYPE void do_exit(long co
17564 tsk->exit_code = code;
17565 proc_exit_connector(tsk);
17566 exit_task_namespaces(tsk);
17567 + /* needs to stay before exit_notify() */
17568 + exit_vx_info_early(tsk, code);
17571 mpol_free(tsk->mempolicy);
17572 @@ -994,6 +1012,10 @@ fastcall NORET_TYPE void do_exit(long co
17573 if (tsk->splice_pipe)
17574 __free_pipe_info(tsk->splice_pipe);
17576 + /* needs to stay after exit_notify() */
17577 + exit_vx_info(tsk, code);
17578 + exit_nx_info(tsk);
17581 /* causes final put_task_struct in finish_task_switch(). */
17582 tsk->state = TASK_DEAD;
17583 diff -NurpP --minimal linux-2.6.22.10/kernel/fork.c linux-2.6.22.10-vs2.3.0.29/kernel/fork.c
17584 --- linux-2.6.22.10/kernel/fork.c 2007-07-09 13:20:03 +0200
17585 +++ linux-2.6.22.10-vs2.3.0.29/kernel/fork.c 2007-10-25 17:05:55 +0200
17587 #include <linux/delayacct.h>
17588 #include <linux/taskstats_kern.h>
17589 #include <linux/random.h>
17590 +#include <linux/vs_context.h>
17591 +#include <linux/vs_network.h>
17592 +#include <linux/vs_limit.h>
17593 +#include <linux/vs_memory.h>
17594 +#include <linux/vserver/global.h>
17596 #include <asm/pgtable.h>
17597 #include <asm/pgalloc.h>
17598 @@ -108,6 +113,8 @@ void free_task(struct task_struct *tsk)
17600 free_thread_info(tsk->stack);
17601 rt_mutex_debug_task_free(tsk);
17602 + clr_vx_info(&tsk->vx_info);
17603 + clr_nx_info(&tsk->nx_info);
17604 free_task_struct(tsk);
17606 EXPORT_SYMBOL(free_task);
17607 @@ -215,6 +222,8 @@ static inline int dup_mmap(struct mm_str
17608 mm->free_area_cache = oldmm->mmap_base;
17609 mm->cached_hole_size = ~0UL;
17611 + __set_mm_counter(mm, file_rss, 0);
17612 + __set_mm_counter(mm, anon_rss, 0);
17613 cpus_clear(mm->cpu_vm_mask);
17614 mm->mm_rb = RB_ROOT;
17615 rb_link = &mm->mm_rb.rb_node;
17616 @@ -226,7 +235,7 @@ static inline int dup_mmap(struct mm_str
17618 if (mpnt->vm_flags & VM_DONTCOPY) {
17619 long pages = vma_pages(mpnt);
17620 - mm->total_vm -= pages;
17621 + vx_vmpages_sub(mm, pages);
17622 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
17625 @@ -327,7 +336,7 @@ static inline void mm_free_pgd(struct mm
17627 #include <linux/init_task.h>
17629 -static struct mm_struct * mm_init(struct mm_struct * mm)
17630 +static struct mm_struct * mm_init(struct mm_struct * mm, struct vx_info *vxi)
17632 atomic_set(&mm->mm_users, 1);
17633 atomic_set(&mm->mm_count, 1);
17634 @@ -335,8 +344,8 @@ static struct mm_struct * mm_init(struct
17635 INIT_LIST_HEAD(&mm->mmlist);
17636 mm->core_waiters = 0;
17638 - set_mm_counter(mm, file_rss, 0);
17639 - set_mm_counter(mm, anon_rss, 0);
17640 + __set_mm_counter(mm, file_rss, 0);
17641 + __set_mm_counter(mm, anon_rss, 0);
17642 spin_lock_init(&mm->page_table_lock);
17643 rwlock_init(&mm->ioctx_list_lock);
17644 mm->ioctx_list = NULL;
17645 @@ -345,6 +354,7 @@ static struct mm_struct * mm_init(struct
17647 if (likely(!mm_alloc_pgd(mm))) {
17649 + set_vx_info(&mm->mm_vx_info, vxi);
17653 @@ -361,7 +371,7 @@ struct mm_struct * mm_alloc(void)
17654 mm = allocate_mm();
17656 memset(mm, 0, sizeof(*mm));
17657 - mm = mm_init(mm);
17658 + mm = mm_init(mm, current->vx_info);
17662 @@ -376,6 +386,7 @@ void fastcall __mmdrop(struct mm_struct
17663 BUG_ON(mm == &init_mm);
17665 destroy_context(mm);
17666 + clr_vx_info(&mm->mm_vx_info);
17670 @@ -490,12 +501,13 @@ static struct mm_struct *dup_mm(struct t
17673 memcpy(mm, oldmm, sizeof(*mm));
17674 + mm->mm_vx_info = NULL;
17676 /* Initializing for Swap token stuff */
17677 mm->token_priority = 0;
17678 mm->last_interval = 0;
17680 - if (!mm_init(mm))
17681 + if (!mm_init(mm, oldmm->mm_vx_info))
17684 if (init_new_context(tsk, mm))
17685 @@ -521,6 +533,7 @@ fail_nocontext:
17686 * If init_new_context() failed, we cannot use mmput() to free the mm
17687 * because it calls destroy_context()
17689 + clr_vx_info(&mm->mm_vx_info);
17693 @@ -591,6 +604,7 @@ static inline struct fs_struct *__copy_f
17694 fs->altroot = NULL;
17696 read_unlock(&old->lock);
17697 + atomic_inc(&vs_global_fs);
17701 @@ -709,6 +723,8 @@ static struct files_struct *dup_fd(struc
17702 struct file *f = *old_fds++;
17705 + /* TODO: sum it first for check and performance */
17706 + vx_openfd_inc(open_files - i);
17709 * The fd may be claimed in the fd bitmap but not yet
17710 @@ -961,6 +977,8 @@ static struct task_struct *copy_process(
17713 struct task_struct *p = NULL;
17714 + struct vx_info *vxi;
17715 + struct nx_info *nxi;
17717 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
17718 return ERR_PTR(-EINVAL);
17719 @@ -995,12 +1013,30 @@ static struct task_struct *copy_process(
17720 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
17721 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
17723 + init_vx_info(&p->vx_info, current->vx_info);
17724 + init_nx_info(&p->nx_info, current->nx_info);
17726 + /* check vserver memory */
17727 + if (p->mm && !(clone_flags & CLONE_VM)) {
17728 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
17729 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17731 + goto bad_fork_free;
17733 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
17734 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
17735 + goto bad_fork_cleanup_vm;
17739 + if (!vx_nproc_avail(1))
17740 + goto bad_fork_cleanup_vm;
17742 if (atomic_read(&p->user->processes) >=
17743 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
17744 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
17745 p->user != &root_user)
17746 - goto bad_fork_free;
17747 + goto bad_fork_cleanup_vm;
17750 atomic_inc(&p->user->__count);
17751 @@ -1265,6 +1301,18 @@ static struct task_struct *copy_process(
17754 spin_unlock(¤t->sighand->siglock);
17756 + /* p is copy of current */
17757 + vxi = p->vx_info;
17759 + claim_vx_info(vxi, p);
17760 + atomic_inc(&vxi->cvirt.nr_threads);
17761 + atomic_inc(&vxi->cvirt.total_forks);
17764 + nxi = p->nx_info;
17766 + claim_nx_info(nxi, p);
17767 write_unlock_irq(&tasklist_lock);
17768 proc_fork_connector(p);
17770 @@ -1306,6 +1354,9 @@ bad_fork_cleanup_count:
17771 put_group_info(p->group_info);
17772 atomic_dec(&p->user->processes);
17774 +bad_fork_cleanup_vm:
17775 + if (p->mm && !(clone_flags & CLONE_VM))
17776 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17780 @@ -1367,6 +1418,15 @@ long do_fork(unsigned long clone_flags,
17785 + /* kernel threads are host only */
17786 + if ((clone_flags & CLONE_KTHREAD) &&
17787 + !vx_capable(CAP_SYS_ADMIN, VXC_KTHREAD)) {
17788 + vxwprintk_task(1, "tried to spawn a kernel thread.");
17794 if (unlikely(current->ptrace)) {
17795 trace = fork_traceflag (clone_flags);
17796 diff -NurpP --minimal linux-2.6.22.10/kernel/kthread.c linux-2.6.22.10-vs2.3.0.29/kernel/kthread.c
17797 --- linux-2.6.22.10/kernel/kthread.c 2007-07-09 13:20:03 +0200
17798 +++ linux-2.6.22.10-vs2.3.0.29/kernel/kthread.c 2007-08-05 20:53:13 +0200
17799 @@ -96,7 +96,7 @@ static void create_kthread(struct kthrea
17801 wait_for_completion(&create->started);
17802 read_lock(&tasklist_lock);
17803 - create->result = find_task_by_pid(pid);
17804 + create->result = find_task_by_real_pid(pid);
17805 read_unlock(&tasklist_lock);
17807 complete(&create->done);
17808 diff -NurpP --minimal linux-2.6.22.10/kernel/nsproxy.c linux-2.6.22.10-vs2.3.0.29/kernel/nsproxy.c
17809 --- linux-2.6.22.10/kernel/nsproxy.c 2007-07-09 13:20:03 +0200
17810 +++ linux-2.6.22.10-vs2.3.0.29/kernel/nsproxy.c 2007-08-05 20:53:13 +0200
17811 @@ -20,14 +20,11 @@
17812 #include <linux/mnt_namespace.h>
17813 #include <linux/utsname.h>
17814 #include <linux/pid_namespace.h>
17815 +#include <linux/vserver/global.h>
17816 +#include <linux/vserver/debug.h>
17818 struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
17820 -static inline void get_nsproxy(struct nsproxy *ns)
17822 - atomic_inc(&ns->count);
17825 void get_task_namespaces(struct task_struct *tsk)
17827 struct nsproxy *ns = tsk->nsproxy;
17828 @@ -46,6 +43,9 @@ static inline struct nsproxy *clone_nspr
17829 ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL);
17831 atomic_set(&ns->count, 1);
17832 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
17833 + orig, atomic_read(&orig->count), ns);
17834 + atomic_inc(&vs_global_nsproxy);
17838 @@ -54,28 +54,32 @@ static inline struct nsproxy *clone_nspr
17839 * Return the newly created nsproxy. Do not attach this to the task,
17840 * leave it to the caller to do proper locking and attach it to task.
17842 -static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17843 +static struct nsproxy *unshare_namespaces(int flags, struct nsproxy *orig,
17844 struct fs_struct *new_fs)
17846 struct nsproxy *new_nsp;
17848 - new_nsp = clone_nsproxy(tsk->nsproxy);
17849 + vxdprintk(VXD_CBIT(space, 4),
17850 + "unshare_namespaces(0x%08x,%p,%p)",
17851 + flags, orig, new_fs);
17853 + new_nsp = clone_nsproxy(orig);
17855 return ERR_PTR(-ENOMEM);
17857 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
17858 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
17859 if (IS_ERR(new_nsp->mnt_ns))
17862 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
17863 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
17864 if (IS_ERR(new_nsp->uts_ns))
17867 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
17868 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
17869 if (IS_ERR(new_nsp->ipc_ns))
17872 - new_nsp->pid_ns = copy_pid_ns(flags, tsk->nsproxy->pid_ns);
17873 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
17874 if (IS_ERR(new_nsp->pid_ns))
17877 @@ -95,6 +99,33 @@ out_ns:
17878 return ERR_PTR(-ENOMEM);
17881 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17882 + struct fs_struct *new_fs)
17884 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
17888 + * copies the nsproxy, setting refcount to 1, and grabbing a
17889 + * reference to all contained namespaces.
17891 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
17893 + struct nsproxy *ns = clone_nsproxy(orig);
17897 + get_mnt_ns(ns->mnt_ns);
17899 + get_uts_ns(ns->uts_ns);
17901 + get_ipc_ns(ns->ipc_ns);
17903 + get_pid_ns(ns->pid_ns);
17909 * called from clone. This now handles copy for nsproxy and all
17910 * namespaces therein.
17911 @@ -102,9 +133,12 @@ out_ns:
17912 int copy_namespaces(int flags, struct task_struct *tsk)
17914 struct nsproxy *old_ns = tsk->nsproxy;
17915 - struct nsproxy *new_ns;
17916 + struct nsproxy *new_ns = NULL;
17919 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08x,%p[%p])",
17920 + flags, tsk, old_ns);
17925 @@ -127,6 +161,9 @@ int copy_namespaces(int flags, struct ta
17926 tsk->nsproxy = new_ns;
17928 put_nsproxy(old_ns);
17929 + vxdprintk(VXD_CBIT(space, 3),
17930 + "copy_namespaces(0x%08x,%p[%p]) = %d [%p]",
17931 + flags, tsk, old_ns, err, new_ns);
17935 @@ -140,6 +177,7 @@ void free_nsproxy(struct nsproxy *ns)
17936 put_ipc_ns(ns->ipc_ns);
17938 put_pid_ns(ns->pid_ns);
17939 + atomic_dec(&vs_global_nsproxy);
17943 @@ -152,6 +190,10 @@ int unshare_nsproxy_namespaces(unsigned
17947 + vxdprintk(VXD_CBIT(space, 4),
17948 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
17949 + unshare_flags, current->nsproxy);
17951 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC)))
17954 diff -NurpP --minimal linux-2.6.22.10/kernel/pid.c linux-2.6.22.10-vs2.3.0.29/kernel/pid.c
17955 --- linux-2.6.22.10/kernel/pid.c 2007-07-09 13:20:03 +0200
17956 +++ linux-2.6.22.10-vs2.3.0.29/kernel/pid.c 2007-08-05 20:53:13 +0200
17958 #include <linux/hash.h>
17959 #include <linux/pid_namespace.h>
17960 #include <linux/init_task.h>
17961 +#include <linux/vs_pid.h>
17963 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
17964 static struct hlist_head *pid_hash;
17965 @@ -295,6 +296,9 @@ void fastcall transfer_pid(struct task_s
17966 struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
17968 struct task_struct *result = NULL;
17970 + if (type == PIDTYPE_REALPID)
17971 + type = PIDTYPE_PID;
17973 struct hlist_node *first;
17974 first = rcu_dereference(pid->tasks[type].first);
17975 @@ -309,7 +313,17 @@ struct task_struct * fastcall pid_task(s
17977 struct task_struct *find_task_by_pid_type(int type, int nr)
17979 - return pid_task(find_pid(nr), type);
17980 + struct task_struct *task;
17982 + if (type == PIDTYPE_PID)
17983 + nr = vx_rmap_pid(nr);
17985 + task = pid_task(find_pid(nr), type);
17986 + if (task && (type != PIDTYPE_REALPID) &&
17987 + /* maybe VS_WATCH_P in the future? */
17988 + !vx_check(task->xid, VS_WATCH|VS_IDENT))
17993 EXPORT_SYMBOL(find_task_by_pid_type);
17994 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
17995 --- linux-2.6.22.10/kernel/posix-timers.c 2007-07-09 13:20:03 +0200
17996 +++ linux-2.6.22.10-vs2.3.0.29/kernel/posix-timers.c 2007-10-01 15:41:45 +0200
17998 #include <linux/wait.h>
17999 #include <linux/workqueue.h>
18000 #include <linux/module.h>
18001 +#include <linux/vs_context.h>
18004 * Management arrays for POSIX timers. Timers are kept in slab memory
18005 @@ -297,6 +298,12 @@ void do_schedule_next_timer(struct sigin
18007 int posix_timer_event(struct k_itimer *timr,int si_private)
18009 + struct vx_info_save vxis;
18010 + struct vx_info *vxi;
18013 + vxi = task_get_vx_info(timr->it_process);
18014 + enter_vx_info(vxi, &vxis);
18015 memset(&timr->sigq->info, 0, sizeof(siginfo_t));
18016 timr->sigq->info.si_sys_private = si_private;
18017 /* Send signal to the process that owns this timer.*/
18018 @@ -309,11 +316,11 @@ int posix_timer_event(struct k_itimer *t
18020 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
18021 struct task_struct *leader;
18022 - int ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
18023 - timr->it_process);
18025 + ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
18026 + timr->it_process);
18027 if (likely(ret >= 0))
18031 timr->it_sigev_notify = SIGEV_SIGNAL;
18032 leader = timr->it_process->group_leader;
18033 @@ -321,8 +328,12 @@ int posix_timer_event(struct k_itimer *t
18034 timr->it_process = leader;
18037 - return send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
18038 + ret = send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
18041 + leave_vx_info(&vxis);
18042 + put_vx_info(vxi);
18045 EXPORT_SYMBOL_GPL(posix_timer_event);
18047 @@ -402,7 +413,7 @@ static struct task_struct * good_sigeven
18048 struct task_struct *rtn = current->group_leader;
18050 if ((event->sigev_notify & SIGEV_THREAD_ID ) &&
18051 - (!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) ||
18052 + (!(rtn = find_task_by_real_pid(event->sigev_notify_thread_id)) ||
18053 rtn->tgid != current->tgid ||
18054 (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))
18056 diff -NurpP --minimal linux-2.6.22.10/kernel/printk.c linux-2.6.22.10-vs2.3.0.29/kernel/printk.c
18057 --- linux-2.6.22.10/kernel/printk.c 2007-07-09 13:20:03 +0200
18058 +++ linux-2.6.22.10-vs2.3.0.29/kernel/printk.c 2007-08-05 20:53:13 +0200
18060 #include <linux/bootmem.h>
18061 #include <linux/syscalls.h>
18062 #include <linux/jiffies.h>
18063 +#include <linux/vs_cvirt.h>
18065 #include <asm/uaccess.h>
18067 @@ -182,18 +183,13 @@ int do_syslog(int type, char __user *buf
18068 unsigned long i, j, limit, count;
18074 error = security_syslog(type);
18079 - case 0: /* Close log */
18081 - case 1: /* Open log */
18083 - case 2: /* Read from log */
18084 + if ((type >= 2) && (type <= 4)) {
18086 if (!buf || len < 0)
18088 @@ -204,6 +200,16 @@ int do_syslog(int type, char __user *buf
18093 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
18094 + return vx_do_syslog(type, buf, len);
18097 + case 0: /* Close log */
18099 + case 1: /* Open log */
18101 + case 2: /* Read from log */
18102 error = wait_event_interruptible(log_wait,
18103 (log_start - log_end));
18105 @@ -228,16 +234,6 @@ int do_syslog(int type, char __user *buf
18108 case 3: /* Read last kernel messages */
18110 - if (!buf || len < 0)
18115 - if (!access_ok(VERIFY_WRITE, buf, len)) {
18120 if (count > log_buf_len)
18121 count = log_buf_len;
18122 diff -NurpP --minimal linux-2.6.22.10/kernel/ptrace.c linux-2.6.22.10-vs2.3.0.29/kernel/ptrace.c
18123 --- linux-2.6.22.10/kernel/ptrace.c 2007-07-09 13:20:03 +0200
18124 +++ linux-2.6.22.10-vs2.3.0.29/kernel/ptrace.c 2007-08-05 20:53:13 +0200
18126 #include <linux/security.h>
18127 #include <linux/signal.h>
18128 #include <linux/audit.h>
18129 +#include <linux/vs_context.h>
18131 #include <asm/pgtable.h>
18132 #include <asm/uaccess.h>
18133 @@ -145,6 +146,11 @@ static int may_attach(struct task_struct
18134 dumpable = task->mm->dumpable;
18135 if (!dumpable && !capable(CAP_SYS_PTRACE))
18137 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
18139 + if (!vx_check(task->xid, VS_IDENT) &&
18140 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
18143 return security_ptrace(current, task);
18145 @@ -471,6 +477,10 @@ asmlinkage long sys_ptrace(long request,
18150 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
18151 + goto out_put_task_struct;
18153 if (request == PTRACE_ATTACH) {
18154 ret = ptrace_attach(child);
18155 goto out_put_task_struct;
18156 diff -NurpP --minimal linux-2.6.22.10/kernel/sched.c linux-2.6.22.10-vs2.3.0.29/kernel/sched.c
18157 --- linux-2.6.22.10/kernel/sched.c 2007-07-09 13:20:03 +0200
18158 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sched.c 2007-08-05 20:53:13 +0200
18161 #include <asm/tlb.h>
18162 #include <asm/unistd.h>
18163 +#include <linux/vs_sched.h>
18164 +#include <linux/vs_cvirt.h>
18167 * Scheduler clock - returns current time in nanosec units.
18168 @@ -281,6 +283,16 @@ struct rq {
18169 struct task_struct *migration_thread;
18170 struct list_head migration_queue;
18172 + unsigned long norm_time;
18173 + unsigned long idle_time;
18174 +#ifdef CONFIG_VSERVER_IDLETIME
18177 +#ifdef CONFIG_VSERVER_HARDCPU
18178 + struct list_head hold_queue;
18179 + unsigned long nr_onhold;
18183 #ifdef CONFIG_SCHEDSTATS
18184 /* latency stats */
18185 @@ -714,6 +726,7 @@ sched_info_switch(struct task_struct *pr
18187 static void dequeue_task(struct task_struct *p, struct prio_array *array)
18189 + BUG_ON(p->state & TASK_ONHOLD);
18190 array->nr_active--;
18191 list_del(&p->run_list);
18192 if (list_empty(array->queue + p->prio))
18193 @@ -722,6 +735,7 @@ static void dequeue_task(struct task_str
18195 static void enqueue_task(struct task_struct *p, struct prio_array *array)
18197 + BUG_ON(p->state & TASK_ONHOLD);
18198 sched_info_queued(p);
18199 list_add_tail(&p->run_list, array->queue + p->prio);
18200 __set_bit(p->prio, array->bitmap);
18201 @@ -735,12 +749,14 @@ static void enqueue_task(struct task_str
18203 static void requeue_task(struct task_struct *p, struct prio_array *array)
18205 + BUG_ON(p->state & TASK_ONHOLD);
18206 list_move_tail(&p->run_list, array->queue + p->prio);
18210 enqueue_task_head(struct task_struct *p, struct prio_array *array)
18212 + BUG_ON(p->state & TASK_ONHOLD);
18213 list_add(&p->run_list, array->queue + p->prio);
18214 __set_bit(p->prio, array->bitmap);
18215 array->nr_active++;
18216 @@ -769,6 +785,10 @@ static inline int __normal_prio(struct t
18217 bonus = CURRENT_BONUS(p) - MAX_BONUS / 2;
18219 prio = p->static_prio - bonus;
18221 + /* adjust effective priority */
18222 + prio = vx_adjust_prio(p, prio, MAX_USER_PRIO);
18224 if (prio < MAX_RT_PRIO)
18225 prio = MAX_RT_PRIO;
18226 if (prio > MAX_PRIO-1)
18227 @@ -878,6 +898,9 @@ static int effective_prio(struct task_st
18231 +#include "sched_mon.h"
18235 * __activate_task - move a task to the runqueue.
18237 @@ -887,6 +910,7 @@ static void __activate_task(struct task_
18240 target = rq->expired;
18241 + vxm_activate_task(p, rq);
18242 enqueue_task(p, target);
18243 inc_nr_running(p, rq);
18245 @@ -896,6 +920,7 @@ static void __activate_task(struct task_
18247 static inline void __activate_idle_task(struct task_struct *p, struct rq *rq)
18249 + vxm_activate_idle(p, rq);
18250 enqueue_task_head(p, rq->active);
18251 inc_nr_running(p, rq);
18253 @@ -1030,19 +1055,30 @@ static void activate_task(struct task_st
18255 p->timestamp = now;
18257 + vx_activate_task(p);
18258 __activate_task(p, rq);
18262 - * deactivate_task - remove a task from the runqueue.
18263 + * __deactivate_task - remove a task from the runqueue.
18265 -static void deactivate_task(struct task_struct *p, struct rq *rq)
18266 +static void __deactivate_task(struct task_struct *p, struct rq *rq)
18268 dec_nr_running(p, rq);
18269 dequeue_task(p, p->array);
18270 + vxm_deactivate_task(p, rq);
18275 +void deactivate_task(struct task_struct *p, struct rq *rq)
18277 + vx_deactivate_task(p);
18278 + __deactivate_task(p, rq);
18281 +#include "sched_hard.h"
18284 * resched_task - mark a task 'to be rescheduled now'.
18286 @@ -1129,6 +1165,7 @@ migrate_task(struct task_struct *p, int
18288 struct rq *rq = task_rq(p);
18290 + vxm_migrate_task(p, rq, dest_cpu);
18292 * If the task is not on a runqueue (and not running), then
18293 * it is sufficient to simply update the task's cpu field.
18294 @@ -1518,6 +1555,12 @@ static int try_to_wake_up(struct task_st
18296 rq = task_rq_lock(p, &flags);
18297 old_state = p->state;
18299 + /* we need to unhold suspended tasks */
18300 + if (old_state & TASK_ONHOLD) {
18301 + vx_unhold_task(p, rq);
18302 + old_state = p->state;
18304 if (!(old_state & state))
18307 @@ -1625,6 +1668,7 @@ out_activate:
18308 #endif /* CONFIG_SMP */
18309 if (old_state == TASK_UNINTERRUPTIBLE) {
18310 rq->nr_uninterruptible--;
18311 + vx_uninterruptible_dec(p);
18313 * Tasks on involuntary sleep don't earn
18314 * sleep_avg beyond just interactive state.
18315 @@ -1676,7 +1720,7 @@ int fastcall wake_up_state(struct task_s
18316 return try_to_wake_up(p, state, 0);
18319 -static void task_running_tick(struct rq *rq, struct task_struct *p);
18320 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu);
18322 * Perform scheduler related setup for a newly forked process p.
18323 * p is forked by current.
18324 @@ -1737,7 +1781,7 @@ void fastcall sched_fork(struct task_str
18325 * runqueue lock is not a problem.
18327 current->time_slice = 1;
18328 - task_running_tick(cpu_rq(cpu), current);
18329 + task_running_tick(cpu_rq(cpu), current, cpu);
18331 local_irq_enable();
18333 @@ -1772,6 +1816,7 @@ void fastcall wake_up_new_task(struct ta
18335 p->prio = effective_prio(p);
18337 + vx_activate_task(p);
18338 if (likely(cpu == this_cpu)) {
18339 if (!(clone_flags & CLONE_VM)) {
18341 @@ -1783,6 +1828,7 @@ void fastcall wake_up_new_task(struct ta
18342 __activate_task(p, rq);
18344 p->prio = current->prio;
18345 + BUG_ON(p->state & TASK_ONHOLD);
18346 p->normal_prio = current->normal_prio;
18347 list_add_tail(&p->run_list, ¤t->run_list);
18348 p->array = current->array;
18349 @@ -3351,13 +3397,16 @@ static inline int expired_starving(struc
18350 void account_user_time(struct task_struct *p, cputime_t cputime)
18352 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
18353 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
18355 + int nice = (TASK_NICE(p) > 0);
18357 p->utime = cputime_add(p->utime, cputime);
18358 + vx_account_user(vxi, cputime, nice);
18360 /* Add user time to cpustat. */
18361 tmp = cputime_to_cputime64(cputime);
18362 - if (TASK_NICE(p) > 0)
18364 cpustat->nice = cputime64_add(cpustat->nice, tmp);
18366 cpustat->user = cputime64_add(cpustat->user, tmp);
18367 @@ -3373,10 +3422,12 @@ void account_system_time(struct task_str
18370 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
18371 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
18372 struct rq *rq = this_rq();
18375 p->stime = cputime_add(p->stime, cputime);
18376 + vx_account_system(vxi, cputime, (p == rq->idle));
18378 /* Add system time to cpustat. */
18379 tmp = cputime_to_cputime64(cputime);
18380 @@ -3415,7 +3466,7 @@ void account_steal_time(struct task_stru
18381 cpustat->steal = cputime64_add(cpustat->steal, tmp);
18384 -static void task_running_tick(struct rq *rq, struct task_struct *p)
18385 +static void task_running_tick(struct rq *rq, struct task_struct *p, int cpu)
18387 if (p->array != rq->active) {
18388 /* Task has expired but was not scheduled yet */
18389 @@ -3445,7 +3496,7 @@ static void task_running_tick(struct rq
18393 - if (!--p->time_slice) {
18394 + if (vx_need_resched(p, --p->time_slice, cpu)) {
18395 dequeue_task(p, rq->active);
18396 set_tsk_need_resched(p);
18397 p->prio = effective_prio(p);
18398 @@ -3506,9 +3557,12 @@ void scheduler_tick(void)
18399 struct rq *rq = cpu_rq(cpu);
18401 update_cpu_clock(p, rq, now);
18402 + vxm_sync(now, cpu);
18404 - if (!idle_at_tick)
18405 - task_running_tick(rq, p);
18406 + if (idle_at_tick)
18407 + vx_idle_resched(rq);
18409 + task_running_tick(rq, p, cpu);
18412 rq->idle_at_tick = idle_at_tick;
18413 @@ -3630,14 +3684,25 @@ need_resched_nonpreemptible:
18414 unlikely(signal_pending(prev))))
18415 prev->state = TASK_RUNNING;
18417 - if (prev->state == TASK_UNINTERRUPTIBLE)
18418 + if (prev->state == TASK_UNINTERRUPTIBLE) {
18419 rq->nr_uninterruptible++;
18420 + vx_uninterruptible_inc(prev);
18422 deactivate_task(prev, rq);
18426 cpu = smp_processor_id();
18427 + vx_set_rq_time(rq, jiffies);
18429 + vx_try_unhold(rq, cpu);
18432 if (unlikely(!rq->nr_running)) {
18433 + /* can we skip idle time? */
18434 + if (vx_try_skip(rq, cpu))
18437 idle_balance(cpu, rq);
18438 if (!rq->nr_running) {
18440 @@ -3663,6 +3728,10 @@ need_resched_nonpreemptible:
18441 queue = array->queue + idx;
18442 next = list_entry(queue->next, struct task_struct, run_list);
18444 + /* check before we schedule this context */
18445 + if (!vx_schedule(next, rq, cpu))
18448 if (!rt_task(next) && interactive_sleep(next->sleep_type)) {
18449 unsigned long long delta = now - next->timestamp;
18450 if (unlikely((long long)(now - next->timestamp) < 0))
18451 @@ -4263,7 +4332,7 @@ asmlinkage long sys_nice(int increment)
18454 if (increment < 0 && !can_nice(current, nice))
18456 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
18458 retval = security_task_setnice(current, nice);
18460 @@ -4435,6 +4504,7 @@ recheck:
18462 __setscheduler(p, policy, param->sched_priority);
18464 + vx_activate_task(p);
18465 __activate_task(p, rq);
18467 * Reschedule if we are currently running on this runqueue and
18468 @@ -5188,6 +5258,7 @@ static int __migrate_task(struct task_st
18469 p->timestamp = p->timestamp - rq_src->most_recent_timestamp
18470 + rq_dest->most_recent_timestamp;
18471 deactivate_task(p, rq_src);
18472 + vx_activate_task(p);
18473 __activate_task(p, rq_dest);
18474 if (TASK_PREEMPTS_CURR(p, rq_dest))
18475 resched_task(rq_dest->curr);
18476 @@ -7058,7 +7129,10 @@ void __init sched_init(void)
18477 INIT_LIST_HEAD(&rq->migration_queue);
18479 atomic_set(&rq->nr_iowait, 0);
18481 +#ifdef CONFIG_VSERVER_HARDCPU
18482 + INIT_LIST_HEAD(&rq->hold_queue);
18483 + rq->nr_onhold = 0;
18485 for (j = 0; j < 2; j++) {
18486 array = rq->arrays + j;
18487 for (k = 0; k < MAX_PRIO; k++) {
18488 @@ -7144,6 +7218,7 @@ void normalize_rt_tasks(void)
18489 deactivate_task(p, task_rq(p));
18490 __setscheduler(p, SCHED_NORMAL, 0);
18492 + vx_activate_task(p);
18493 __activate_task(p, task_rq(p));
18494 resched_task(rq->curr);
18496 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
18497 --- linux-2.6.22.10/kernel/sched_hard.h 1970-01-01 01:00:00 +0100
18498 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sched_hard.h 2007-08-05 20:53:13 +0200
18501 +#ifdef CONFIG_VSERVER_IDLELIMIT
18504 + * vx_idle_resched - reschedule after maxidle
18507 +void vx_idle_resched(struct rq *rq)
18509 + /* maybe have a better criterion for paused */
18510 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
18511 + set_need_resched();
18514 +#else /* !CONFIG_VSERVER_IDLELIMIT */
18516 +#define vx_idle_resched(rq)
18518 +#endif /* CONFIG_VSERVER_IDLELIMIT */
18522 +#ifdef CONFIG_VSERVER_IDLETIME
18524 +#define vx_set_rq_min_skip(rq, min) \
18525 + (rq)->idle_skip = (min)
18527 +#define vx_save_min_skip(ret, min, val) \
18528 + __vx_save_min_skip(ret, min, val)
18531 +void __vx_save_min_skip(int ret, int *min, int val)
18535 + if ((*min > val) || !*min)
18540 +int vx_try_skip(struct rq *rq, int cpu)
18542 + /* artificially advance time */
18543 + if (rq->idle_skip > 0) {
18544 + vxdprintk(list_empty(&rq->hold_queue),
18545 + "hold queue empty on cpu %d", cpu);
18546 + rq->idle_time += rq->idle_skip;
18547 + vxm_idle_skip(rq, cpu);
18553 +#else /* !CONFIG_VSERVER_IDLETIME */
18555 +#define vx_set_rq_min_skip(rq, min) \
18556 + ({ int dummy = (min); dummy; })
18558 +#define vx_save_min_skip(ret, min, val)
18561 +int vx_try_skip(struct rq *rq, int cpu)
18566 +#endif /* CONFIG_VSERVER_IDLETIME */
18570 +#ifdef CONFIG_VSERVER_HARDCPU
18572 +#define vx_set_rq_max_idle(rq, max) \
18573 + (rq)->idle_tokens = (max)
18575 +#define vx_save_max_idle(ret, min, val) \
18576 + __vx_save_max_idle(ret, min, val)
18579 +void __vx_save_max_idle(int ret, int *min, int val)
18587 + * vx_hold_task - put a task on the hold queue
18590 +void vx_hold_task(struct task_struct *p, struct rq *rq)
18592 + __deactivate_task(p, rq);
18593 + p->state |= TASK_ONHOLD;
18594 + /* a new one on hold */
18596 + vxm_hold_task(p, rq);
18597 + list_add_tail(&p->run_list, &rq->hold_queue);
18601 + * vx_unhold_task - put a task back to the runqueue
18604 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
18606 + list_del(&p->run_list);
18607 + /* one less waiting */
18609 + p->state &= ~TASK_ONHOLD;
18610 + enqueue_task(p, rq->expired);
18611 + inc_nr_running(p, rq);
18612 + vxm_unhold_task(p, rq);
18614 + if (p->static_prio < rq->best_expired_prio)
18615 + rq->best_expired_prio = p->static_prio;
18618 +unsigned long nr_onhold(void)
18620 + unsigned long i, sum = 0;
18622 + for_each_online_cpu(i)
18623 + sum += cpu_rq(i)->nr_onhold;
18631 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
18633 + return sched_pc->tokens;
18637 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
18639 + sched_pc->tokens--;
18643 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
18645 + struct vx_info *vxi = p->vx_info;
18647 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
18648 + struct _vx_sched_pc *sched_pc =
18649 + &vx_per_cpu(vxi, sched_pc, cpu);
18652 + /* maybe we can simplify that to decrement
18653 + the token counter unconditional? */
18655 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
18656 + __vx_consume_token(sched_pc);
18658 + /* for tokens > 0, one token was consumed */
18662 + vxm_need_resched(p, slice, cpu);
18663 + return (slice == 0);
18667 +#define vx_set_rq_time(rq, time) do { \
18668 + rq->norm_time = time; \
18673 +void vx_try_unhold(struct rq *rq, int cpu)
18675 + struct vx_info *vxi = NULL;
18676 + struct list_head *l, *n;
18677 + int maxidle = HZ;
18680 + /* nothing to do? what about pause? */
18681 + if (list_empty(&rq->hold_queue))
18684 + list_for_each_safe(l, n, &rq->hold_queue) {
18685 + int ret, delta_min[2];
18686 + struct _vx_sched_pc *sched_pc;
18687 + struct task_struct *p;
18689 + p = list_entry(l, struct task_struct, run_list);
18690 + /* don't bother with same context */
18691 + if (vxi == p->vx_info)
18694 + vxi = p->vx_info;
18695 + /* ignore paused contexts */
18696 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
18699 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18701 + /* recalc tokens */
18702 + vxm_sched_info(sched_pc, vxi, cpu);
18703 + ret = vx_tokens_recalc(sched_pc,
18704 + &rq->norm_time, &rq->idle_time, delta_min);
18705 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18708 + /* we found a runable context */
18709 + vx_unhold_task(p, rq);
18712 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
18713 + vx_save_min_skip(ret, &minskip, delta_min[1]);
18715 + vx_set_rq_max_idle(rq, maxidle);
18716 + vx_set_rq_min_skip(rq, minskip);
18717 + vxm_rq_max_min(rq, cpu);
18722 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
18724 + struct vx_info *vxi = next->vx_info;
18725 + struct _vx_sched_pc *sched_pc;
18726 + int delta_min[2];
18732 + flags = vxi->vx_flags;
18734 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
18735 + goto put_on_hold;
18736 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
18739 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18741 + /* update scheduler params */
18742 + if (cpu_isset(cpu, vxi->sched.update)) {
18743 + vx_update_sched_param(&vxi->sched, sched_pc);
18744 + vxm_update_sched(sched_pc, vxi, cpu);
18745 + cpu_clear(cpu, vxi->sched.update);
18748 + vxm_sched_info(sched_pc, vxi, cpu);
18749 + ret = vx_tokens_recalc(sched_pc,
18750 + &rq->norm_time, &rq->idle_time, delta_min);
18751 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18753 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
18756 + if (unlikely(ret < 0)) {
18757 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
18758 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
18759 + vxm_rq_max_min(rq, cpu);
18761 + vx_hold_task(next, rq);
18768 +#else /* CONFIG_VSERVER_HARDCPU */
18771 +void vx_hold_task(struct task_struct *p, struct rq *rq)
18777 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
18782 +unsigned long nr_onhold(void)
18789 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
18791 + return (slice == 0);
18795 +#define vx_set_rq_time(rq, time)
18798 +void vx_try_unhold(struct rq *rq, int cpu)
18804 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
18806 + struct vx_info *vxi = next->vx_info;
18807 + struct _vx_sched_pc *sched_pc;
18808 + int delta_min[2];
18811 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
18814 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
18815 + vxm_sched_info(sched_pc, vxi, cpu);
18816 + ret = vx_tokens_recalc(sched_pc,
18817 + &rq->norm_time, &rq->idle_time, delta_min);
18818 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
18822 +#endif /* CONFIG_VSERVER_HARDCPU */
18824 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
18825 --- linux-2.6.22.10/kernel/sched_mon.h 1970-01-01 01:00:00 +0100
18826 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sched_mon.h 2007-08-05 20:53:13 +0200
18829 +#include <linux/vserver/monitor.h>
18831 +#ifdef CONFIG_VSERVER_MONITOR
18833 +#ifdef CONFIG_VSERVER_HARDCPU
18834 +#define HARDCPU(x) (x)
18836 +#define HARDCPU(x) (0)
18839 +#ifdef CONFIG_VSERVER_IDLETIME
18840 +#define IDLETIME(x) (x)
18842 +#define IDLETIME(x) (0)
18845 +struct _vx_mon_entry *vxm_advance(int cpu);
18849 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
18851 + entry->type = type;
18852 + entry->xid = xid;
18856 +void __vxm_sync(int cpu)
18858 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18860 + __vxm_basic(entry, 0, VXM_SYNC);
18861 + entry->ev.sec = xtime.tv_sec;
18862 + entry->ev.nsec = xtime.tv_nsec;
18866 +void __vxm_task(struct task_struct *p, int type)
18868 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
18870 + __vxm_basic(entry, p->xid, type);
18871 + entry->ev.tsk.pid = p->pid;
18872 + entry->ev.tsk.state = p->state;
18876 +void __vxm_sched(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_SCHED | s->flags));
18881 + entry->sd.tokens = s->tokens;
18882 + entry->sd.norm_time = s->norm_time;
18883 + entry->sd.idle_time = s->idle_time;
18887 +void __vxm_rqinfo1(struct rq *q, int cpu)
18889 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18891 + entry->type = VXM_RQINFO_1;
18892 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
18893 + entry->q1.running = q->nr_running;
18894 + entry->q1.onhold = HARDCPU(q->nr_onhold);
18895 + entry->q1.iowait = atomic_read(&q->nr_iowait);
18896 + entry->q1.uintr = q->nr_uninterruptible;
18897 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
18901 +void __vxm_rqinfo2(struct rq *q, int cpu)
18903 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18905 + entry->type = VXM_RQINFO_2;
18906 + entry->xid = (unsigned long)q & 0xffff;
18907 + entry->q2.norm_time = q->norm_time;
18908 + entry->q2.idle_time = q->idle_time;
18909 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
18913 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18915 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18917 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
18918 + entry->ev.tokens = s->tokens;
18922 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18924 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18926 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
18927 + entry->u1.tokens_max = s->tokens_max;
18928 + entry->u1.fill_rate = s->fill_rate[0];
18929 + entry->u1.interval = s->interval[0];
18933 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18935 + struct _vx_mon_entry *entry = vxm_advance(cpu);
18937 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
18938 + entry->u2.tokens_min = s->tokens_min;
18939 + entry->u2.fill_rate = s->fill_rate[1];
18940 + entry->u2.interval = s->interval[1];
18944 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
18945 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
18946 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
18947 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
18948 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
18951 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
18953 + __vxm_task(p, VXM_MIGRATE);
18954 + __vxm_rqinfo1(rq, task_cpu(p));
18955 + __vxm_rqinfo2(rq, task_cpu(p));
18959 +void vxm_idle_skip(struct rq *rq, int cpu)
18961 + __vxm_rqinfo1(rq, cpu);
18962 + __vxm_rqinfo2(rq, cpu);
18966 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
18971 + __vxm_task(p, VXM_RESCHED);
18975 +void vxm_sync(unsigned long now, int cpu)
18977 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
18978 + (now % CONFIG_VSERVER_MONITOR_SYNC))
18984 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
18987 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
18988 + struct vx_info *vxi, int cpu)
18990 + __vxm_sched(s, vxi, cpu);
18991 + __vxm_rqinfo2(rq, cpu);
18995 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
18997 + __vxm_sched(s, vxi, cpu);
18998 + __vxm_update(s, vxi, cpu);
18999 + __vxm_update1(s, vxi, cpu);
19000 + __vxm_update2(s, vxi, cpu);
19004 +void vxm_rq_max_min(struct rq *rq, int cpu)
19006 + __vxm_rqinfo1(rq, cpu);
19007 + __vxm_rqinfo2(rq, cpu);
19010 +#else /* CONFIG_VSERVER_MONITOR */
19012 +#define vxm_activate_task(t,q) do { } while (0)
19013 +#define vxm_activate_idle(t,q) do { } while (0)
19014 +#define vxm_deactivate_task(t,q) do { } while (0)
19015 +#define vxm_hold_task(t,q) do { } while (0)
19016 +#define vxm_unhold_task(t,q) do { } while (0)
19017 +#define vxm_migrate_task(t,q,d) do { } while (0)
19018 +#define vxm_idle_skip(q,c) do { } while (0)
19019 +#define vxm_need_resched(t,s,c) do { } while (0)
19020 +#define vxm_sync(s,c) do { } while (0)
19021 +#define vxm_sched_info(s,v,c) do { } while (0)
19022 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
19023 +#define vxm_update_sched(s,v,c) do { } while (0)
19024 +#define vxm_rq_max_min(q,c) do { } while (0)
19026 +#endif /* CONFIG_VSERVER_MONITOR */
19028 diff -NurpP --minimal linux-2.6.22.10/kernel/signal.c linux-2.6.22.10-vs2.3.0.29/kernel/signal.c
19029 --- linux-2.6.22.10/kernel/signal.c 2007-10-30 01:57:15 +0100
19030 +++ linux-2.6.22.10-vs2.3.0.29/kernel/signal.c 2007-09-30 14:58:01 +0200
19032 #include <linux/freezer.h>
19033 #include <linux/pid_namespace.h>
19034 #include <linux/nsproxy.h>
19035 +#include <linux/vs_context.h>
19036 +#include <linux/vs_pid.h>
19038 #include <asm/param.h>
19039 #include <asm/uaccess.h>
19040 @@ -523,19 +525,34 @@ static int check_kill_permission(int sig
19041 if (!valid_signal(sig))
19044 + if ((info != SEND_SIG_NOINFO) &&
19045 + (is_si_special(info) || !SI_FROMUSER(info)))
19048 + vxdprintk(VXD_CBIT(misc, 7),
19049 + "check_kill_permission(%d,%p,%p[#%u,%u])",
19050 + sig, info, t, vx_task_xid(t), t->pid);
19052 error = audit_signal_info(sig, t); /* Let audit system see the signal */
19057 - if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
19058 - && ((sig != SIGCONT) ||
19059 + if (((sig != SIGCONT) ||
19060 (process_session(current) != process_session(t)))
19061 && (current->euid ^ t->suid) && (current->euid ^ t->uid)
19062 && (current->uid ^ t->suid) && (current->uid ^ t->uid)
19063 && !capable(CAP_KILL))
19067 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
19068 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
19069 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
19070 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
19074 return security_task_kill(t, info, sig, 0);
19077 @@ -1043,7 +1060,7 @@ int kill_pid_info(int sig, struct siginf
19079 p = pid_task(pid, PIDTYPE_PID);
19082 + if (p && vx_check(vx_task_xid(p), VS_IDENT))
19083 error = group_send_sig_info(sig, info, p);
19085 if (unlikely(sig_needs_tasklist(sig)))
19086 @@ -1057,7 +1074,7 @@ kill_proc_info(int sig, struct siginfo *
19090 - error = kill_pid_info(sig, info, find_pid(pid));
19091 + error = kill_pid_info(sig, info, find_pid(vx_rmap_pid(pid)));
19095 @@ -1118,7 +1135,9 @@ static int kill_something_info(int sig,
19097 read_lock(&tasklist_lock);
19098 for_each_process(p) {
19099 - if (p->pid > 1 && p->tgid != current->tgid) {
19100 + if (vx_check(vx_task_xid(p), VS_ADMIN_P|VS_IDENT) &&
19101 + p->pid > 1 && p->tgid != current->tgid &&
19102 + !vx_current_initpid(p->pid)) {
19103 int err = group_send_sig_info(sig, info, p);
19106 @@ -1128,9 +1147,9 @@ static int kill_something_info(int sig,
19107 read_unlock(&tasklist_lock);
19108 ret = count ? retval : -ESRCH;
19109 } else if (pid < 0) {
19110 - ret = kill_pgrp_info(sig, info, find_pid(-pid));
19111 + ret = kill_pgrp_info(sig, info, find_pid(vx_rmap_pid(-pid)));
19113 - ret = kill_pid_info(sig, info, find_pid(pid));
19114 + ret = kill_pid_info(sig, info, find_pid(vx_rmap_pid(pid)));
19118 @@ -1814,6 +1833,11 @@ relock:
19119 if (current == child_reaper(current))
19122 + /* virtual init is protected against user signals */
19123 + if ((info->si_code == SI_USER) &&
19124 + vx_current_initpid(current->pid))
19127 if (sig_kernel_stop(signr)) {
19129 * The default action is to stop all threads in
19130 diff -NurpP --minimal linux-2.6.22.10/kernel/softirq.c linux-2.6.22.10-vs2.3.0.29/kernel/softirq.c
19131 --- linux-2.6.22.10/kernel/softirq.c 2007-07-09 13:20:03 +0200
19132 +++ linux-2.6.22.10-vs2.3.0.29/kernel/softirq.c 2007-08-05 20:53:13 +0200
19134 #include <linux/rcupdate.h>
19135 #include <linux/smp.h>
19136 #include <linux/tick.h>
19137 +#include <linux/vs_context.h>
19139 #include <asm/irq.h>
19141 diff -NurpP --minimal linux-2.6.22.10/kernel/sys.c linux-2.6.22.10-vs2.3.0.29/kernel/sys.c
19142 --- linux-2.6.22.10/kernel/sys.c 2007-10-30 01:57:15 +0100
19143 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sys.c 2007-10-30 01:21:54 +0100
19145 #include <linux/compat.h>
19146 #include <linux/syscalls.h>
19147 #include <linux/kprobes.h>
19148 +#include <linux/vs_pid.h>
19150 #include <asm/uaccess.h>
19151 #include <asm/io.h>
19152 @@ -639,7 +640,10 @@ static int set_one_prio(struct task_stru
19155 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
19157 + if (vx_flags(VXF_IGNEG_NICE, 0))
19163 no_nice = security_task_setnice(p, niceval);
19164 @@ -687,6 +691,8 @@ asmlinkage long sys_setpriority(int whic
19166 pgrp = task_pgrp(current);
19167 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
19168 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
19170 error = set_one_prio(p, niceval, error);
19171 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
19173 @@ -695,7 +701,8 @@ asmlinkage long sys_setpriority(int whic
19175 who = current->uid;
19177 - if ((who != current->uid) && !(user = find_user(who)))
19178 + if ((who != current->uid) &&
19179 + !(user = find_user(vx_current_xid(), who)))
19180 goto out_unlock; /* No processes for this user */
19182 do_each_thread(g, p)
19183 @@ -747,6 +754,8 @@ asmlinkage long sys_getpriority(int whic
19185 pgrp = task_pgrp(current);
19186 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
19187 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
19189 niceval = 20 - task_nice(p);
19190 if (niceval > retval)
19192 @@ -757,7 +766,8 @@ asmlinkage long sys_getpriority(int whic
19194 who = current->uid;
19196 - if ((who != current->uid) && !(user = find_user(who)))
19197 + if ((who != current->uid) &&
19198 + !(user = find_user(vx_current_xid(), who)))
19199 goto out_unlock; /* No processes for this user */
19201 do_each_thread(g, p)
19202 @@ -871,6 +881,9 @@ void kernel_power_off(void)
19203 machine_power_off();
19205 EXPORT_SYMBOL_GPL(kernel_power_off);
19207 +long vs_reboot(unsigned int, void __user *);
19210 * Reboot system call: for obvious reasons only root may call it,
19211 * and even root needs to set up some magic numbers in the registers
19212 @@ -901,6 +914,9 @@ asmlinkage long sys_reboot(int magic1, i
19213 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
19214 cmd = LINUX_REBOOT_CMD_HALT;
19216 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
19217 + return vs_reboot(cmd, arg);
19221 case LINUX_REBOOT_CMD_RESTART:
19222 @@ -1080,7 +1096,7 @@ static int set_user(uid_t new_ruid, int
19224 struct user_struct *new_user;
19226 - new_user = alloc_uid(new_ruid);
19227 + new_user = alloc_uid(vx_current_xid(), new_ruid);
19231 @@ -1434,15 +1450,18 @@ asmlinkage long sys_setpgid(pid_t pid, p
19233 struct task_struct *p;
19234 struct task_struct *group_leader = current->group_leader;
19239 - pid = group_leader->pid;
19240 + pid = vx_map_pid(group_leader->pid);
19246 + rpgid = vx_rmap_pid(pgid);
19248 /* From this point forward we keep holding onto the tasklist lock
19249 * so that our parent does not change from under us. -DaveM
19251 @@ -1476,20 +1495,20 @@ asmlinkage long sys_setpgid(pid_t pid, p
19254 struct task_struct *g =
19255 - find_task_by_pid_type(PIDTYPE_PGID, pgid);
19256 + find_task_by_pid_type(PIDTYPE_PGID, rpgid);
19258 if (!g || task_session(g) != task_session(group_leader))
19262 - err = security_task_setpgid(p, pgid);
19263 + err = security_task_setpgid(p, rpgid);
19267 - if (process_group(p) != pgid) {
19268 + if (process_group(p) != rpgid) {
19269 detach_pid(p, PIDTYPE_PGID);
19270 - p->signal->pgrp = pgid;
19271 - attach_pid(p, PIDTYPE_PGID, find_pid(pgid));
19272 + p->signal->pgrp = rpgid;
19273 + attach_pid(p, PIDTYPE_PGID, find_pid(rpgid));
19277 @@ -1502,7 +1521,7 @@ out:
19278 asmlinkage long sys_getpgid(pid_t pid)
19281 - return process_group(current);
19282 + return vx_rmap_pid(process_group(current));
19285 struct task_struct *p;
19286 @@ -1514,7 +1533,7 @@ asmlinkage long sys_getpgid(pid_t pid)
19288 retval = security_task_getpgid(p);
19290 - retval = process_group(p);
19291 + retval = vx_rmap_pid(process_group(p));
19293 read_unlock(&tasklist_lock);
19295 @@ -1865,7 +1884,7 @@ asmlinkage long sys_sethostname(char __u
19297 char tmp[__NEW_UTS_LEN];
19299 - if (!capable(CAP_SYS_ADMIN))
19300 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
19302 if (len < 0 || len > __NEW_UTS_LEN)
19304 @@ -1910,7 +1929,7 @@ asmlinkage long sys_setdomainname(char _
19306 char tmp[__NEW_UTS_LEN];
19308 - if (!capable(CAP_SYS_ADMIN))
19309 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
19311 if (len < 0 || len > __NEW_UTS_LEN)
19313 @@ -1977,7 +1996,7 @@ asmlinkage long sys_setrlimit(unsigned i
19315 old_rlim = current->signal->rlim + resource;
19316 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
19317 - !capable(CAP_SYS_RESOURCE))
19318 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
19320 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
19322 diff -NurpP --minimal linux-2.6.22.10/kernel/sysctl.c linux-2.6.22.10-vs2.3.0.29/kernel/sysctl.c
19323 --- linux-2.6.22.10/kernel/sysctl.c 2007-07-09 13:20:03 +0200
19324 +++ linux-2.6.22.10-vs2.3.0.29/kernel/sysctl.c 2007-08-05 20:53:13 +0200
19325 @@ -89,6 +89,7 @@ static int ngroups_max = NGROUPS_MAX;
19327 extern char modprobe_path[];
19329 +extern char vshelper_path[];
19330 #ifdef CONFIG_CHR_DEV_SG
19331 extern int sg_big_buff;
19333 @@ -343,6 +344,15 @@ static ctl_table kern_table[] = {
19334 .strategy = &sysctl_string,
19338 + .ctl_name = KERN_VSHELPER,
19339 + .procname = "vshelper",
19340 + .data = &vshelper_path,
19343 + .proc_handler = &proc_dostring,
19344 + .strategy = &sysctl_string,
19346 #ifdef CONFIG_CHR_DEV_SG
19348 .ctl_name = KERN_SG_BIG_BUFF,
19349 diff -NurpP --minimal linux-2.6.22.10/kernel/time.c linux-2.6.22.10-vs2.3.0.29/kernel/time.c
19350 --- linux-2.6.22.10/kernel/time.c 2007-07-09 13:20:03 +0200
19351 +++ linux-2.6.22.10-vs2.3.0.29/kernel/time.c 2007-08-05 20:53:13 +0200
19352 @@ -60,7 +60,7 @@ asmlinkage long sys_time(time_t __user *
19356 - do_gettimeofday(&tv);
19357 + vx_gettimeofday(&tv);
19361 @@ -91,7 +91,7 @@ asmlinkage long sys_stime(time_t __user
19365 - do_settimeofday(&tv);
19366 + vx_settimeofday(&tv);
19370 @@ -101,7 +101,7 @@ asmlinkage long sys_gettimeofday(struct
19372 if (likely(tv != NULL)) {
19373 struct timeval ktv;
19374 - do_gettimeofday(&ktv);
19375 + vx_gettimeofday(&ktv);
19376 if (copy_to_user(tv, &ktv, sizeof(ktv)))
19379 @@ -175,7 +175,7 @@ int do_sys_settimeofday(struct timespec
19380 /* SMP safe, again the code in arch/foo/time.c should
19381 * globally block out interrupts when it runs.
19383 - return do_settimeofday(tv);
19384 + return vx_settimeofday(tv);
19388 @@ -388,7 +388,7 @@ void getnstimeofday(struct timespec *tv)
19392 - do_gettimeofday(&x);
19393 + vx_gettimeofday(&x);
19394 tv->tv_sec = x.tv_sec;
19395 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
19397 diff -NurpP --minimal linux-2.6.22.10/kernel/timer.c linux-2.6.22.10-vs2.3.0.29/kernel/timer.c
19398 --- linux-2.6.22.10/kernel/timer.c 2007-07-09 13:20:04 +0200
19399 +++ linux-2.6.22.10-vs2.3.0.29/kernel/timer.c 2007-08-05 20:53:13 +0200
19401 #include <linux/delay.h>
19402 #include <linux/tick.h>
19403 #include <linux/kallsyms.h>
19404 +#include <linux/vs_base.h>
19405 +#include <linux/vs_cvirt.h>
19406 +#include <linux/vs_pid.h>
19407 +#include <linux/vserver/sched.h>
19409 #include <asm/uaccess.h>
19410 #include <asm/unistd.h>
19411 @@ -921,12 +925,6 @@ asmlinkage unsigned long sys_alarm(unsig
19418 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
19419 - * should be moved into arch/i386 instead?
19423 * sys_getpid - return the thread group id of the current process
19424 @@ -939,7 +937,7 @@ asmlinkage unsigned long sys_alarm(unsig
19426 asmlinkage long sys_getpid(void)
19428 - return current->tgid;
19429 + return vx_map_tgid(current->tgid);
19433 @@ -955,10 +953,23 @@ asmlinkage long sys_getppid(void)
19435 pid = rcu_dereference(current->real_parent)->tgid;
19437 + return vx_map_pid(pid);
19444 + * The Alpha uses getxpid, getxuid, and getxgid instead.
19447 +asmlinkage long do_getxpid(long *ppid)
19449 + *ppid = sys_getppid();
19450 + return sys_getpid();
19453 +#else /* _alpha_ */
19455 asmlinkage long sys_getuid(void)
19457 /* Only we change this so SMP safe */
19458 @@ -1118,6 +1129,8 @@ int do_sysinfo(struct sysinfo *info)
19459 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
19462 + if (vx_flags(VXF_VIRT_UPTIME, 0))
19463 + vx_vsi_uptime(&tp, NULL);
19464 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
19466 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
19467 diff -NurpP --minimal linux-2.6.22.10/kernel/user.c linux-2.6.22.10-vs2.3.0.29/kernel/user.c
19468 --- linux-2.6.22.10/kernel/user.c 2007-02-06 03:01:56 +0100
19469 +++ linux-2.6.22.10-vs2.3.0.29/kernel/user.c 2007-08-05 20:53:13 +0200
19471 #define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8)
19472 #define UIDHASH_SZ (1 << UIDHASH_BITS)
19473 #define UIDHASH_MASK (UIDHASH_SZ - 1)
19474 -#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
19475 -#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid)))
19476 +#define __uidhashfn(xid,uid) ((((uid) >> UIDHASH_BITS) + ((uid)^(xid))) & UIDHASH_MASK)
19477 +#define uidhashentry(xid,uid) (uidhash_table + __uidhashfn((xid),(uid)))
19479 static struct kmem_cache *uid_cachep;
19480 static struct list_head uidhash_table[UIDHASH_SZ];
19481 @@ -66,7 +66,7 @@ static inline void uid_hash_remove(struc
19482 list_del(&up->uidhash_list);
19485 -static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
19486 +static inline struct user_struct *uid_hash_find(xid_t xid, uid_t uid, struct list_head *hashent)
19488 struct list_head *up;
19490 @@ -75,7 +75,7 @@ static inline struct user_struct *uid_ha
19492 user = list_entry(up, struct user_struct, uidhash_list);
19494 - if(user->uid == uid) {
19495 + if(user->uid == uid && user->xid == xid) {
19496 atomic_inc(&user->__count);
19499 @@ -90,13 +90,13 @@ static inline struct user_struct *uid_ha
19501 * If the user_struct could not be found, return NULL.
19503 -struct user_struct *find_user(uid_t uid)
19504 +struct user_struct *find_user(xid_t xid, uid_t uid)
19506 struct user_struct *ret;
19507 unsigned long flags;
19509 spin_lock_irqsave(&uidhash_lock, flags);
19510 - ret = uid_hash_find(uid, uidhashentry(uid));
19511 + ret = uid_hash_find(xid, uid, uidhashentry(xid, uid));
19512 spin_unlock_irqrestore(&uidhash_lock, flags);
19515 @@ -120,13 +120,13 @@ void free_uid(struct user_struct *up)
19519 -struct user_struct * alloc_uid(uid_t uid)
19520 +struct user_struct * alloc_uid(xid_t xid, uid_t uid)
19522 - struct list_head *hashent = uidhashentry(uid);
19523 + struct list_head *hashent = uidhashentry(xid, uid);
19524 struct user_struct *up;
19526 spin_lock_irq(&uidhash_lock);
19527 - up = uid_hash_find(uid, hashent);
19528 + up = uid_hash_find(xid, uid, hashent);
19529 spin_unlock_irq(&uidhash_lock);
19532 @@ -136,6 +136,7 @@ struct user_struct * alloc_uid(uid_t uid
19537 atomic_set(&new->__count, 1);
19538 atomic_set(&new->processes, 0);
19539 atomic_set(&new->files, 0);
19540 @@ -158,7 +159,7 @@ struct user_struct * alloc_uid(uid_t uid
19541 * on adding the same user already..
19543 spin_lock_irq(&uidhash_lock);
19544 - up = uid_hash_find(uid, hashent);
19545 + up = uid_hash_find(xid, uid, hashent);
19547 key_put(new->uid_keyring);
19548 key_put(new->session_keyring);
19549 @@ -215,7 +216,7 @@ static int __init uid_cache_init(void)
19551 /* Insert the root user immediately (init already runs as root) */
19552 spin_lock_irq(&uidhash_lock);
19553 - uid_hash_insert(&root_user, uidhashentry(0));
19554 + uid_hash_insert(&root_user, uidhashentry(0,0));
19555 spin_unlock_irq(&uidhash_lock);
19558 diff -NurpP --minimal linux-2.6.22.10/kernel/utsname.c linux-2.6.22.10-vs2.3.0.29/kernel/utsname.c
19559 --- linux-2.6.22.10/kernel/utsname.c 2007-07-09 13:20:04 +0200
19560 +++ linux-2.6.22.10-vs2.3.0.29/kernel/utsname.c 2007-08-05 20:53:13 +0200
19562 #include <linux/uts.h>
19563 #include <linux/utsname.h>
19564 #include <linux/version.h>
19565 +#include <linux/vserver/global.h>
19568 * Clone a new ns copying an original utsname, setting refcount to 1
19569 @@ -27,6 +28,7 @@ static struct uts_namespace *clone_uts_n
19571 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
19572 kref_init(&ns->kref);
19573 + atomic_inc(&vs_global_uts_ns);
19577 @@ -58,5 +60,6 @@ void free_uts_ns(struct kref *kref)
19578 struct uts_namespace *ns;
19580 ns = container_of(kref, struct uts_namespace, kref);
19581 + atomic_dec(&vs_global_uts_ns);
19584 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/Kconfig linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Kconfig
19585 --- linux-2.6.22.10/kernel/vserver/Kconfig 1970-01-01 01:00:00 +0100
19586 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Kconfig 2007-10-11 01:10:22 +0200
19589 +# Linux VServer configuration
19592 +menu "Linux VServer"
19594 +config VSERVER_AUTO_LBACK
19595 + bool "Automatically Assign Loopback IP"
19598 + Automatically assign a guest specific loopback
19599 + IP and add it to the kernel network stack on
19602 +config VSERVER_AUTO_SINGLE
19603 + bool "Automatic Single IP Special Casing"
19604 + depends on EXPERIMENTAL
19607 + This allows network contexts with a single IP to
19608 + automatically remap 0.0.0.0 bindings to that IP,
19609 + avoiding further network checks and improving
19612 + (note: such guests do not allow to change the ip
19613 + on the fly and do not show loopback addresses)
19615 +config VSERVER_COWBL
19616 + bool "Enable COW Immutable Link Breaking"
19619 + This enables the COW (Copy-On-Write) link break code.
19620 + It allows you to treat unified files like normal files
19621 + when writing to them (which will implicitely break the
19622 + link and create a copy of the unified file)
19624 +config VSERVER_VTIME
19625 + bool "Enable Virtualized Guest Time"
19626 + depends on EXPERIMENTAL
19629 + This enables per guest time offsets to allow for
19630 + adjusting the system clock individually per guest.
19631 + this adds some overhead to the time functions and
19632 + therefore should not be enabled without good reason.
19634 +config VSERVER_DEVICE
19635 + bool "Enable Guest Device Mapping"
19636 + depends on EXPERIMENTAL
19639 + This enables generic device remapping.
19641 +config VSERVER_PROC_SECURE
19642 + bool "Enable Proc Security"
19643 + depends on PROC_FS
19646 + This configures ProcFS security to initially hide
19647 + non-process entries for all contexts except the main and
19648 + spectator context (i.e. for all guests), which is a secure
19651 + (note: on 1.2x the entries were visible by default)
19653 +config VSERVER_HARDCPU
19654 + bool "Enable Hard CPU Limits"
19657 + Activate the Hard CPU Limits
19659 + This will compile in code that allows the Token Bucket
19660 + Scheduler to put processes on hold when a context's
19661 + tokens are depleted (provided that its per-context
19662 + sched_hard flag is set).
19664 + Processes belonging to that context will not be able
19665 + to consume CPU resources again until a per-context
19666 + configured minimum of tokens has been reached.
19668 +config VSERVER_IDLETIME
19669 + bool "Avoid idle CPUs by skipping Time"
19670 + depends on VSERVER_HARDCPU
19673 + This option allows the scheduler to artificially
19674 + advance time (per cpu) when otherwise the idle
19675 + task would be scheduled, thus keeping the cpu
19676 + busy and sharing the available resources among
19677 + certain contexts.
19679 +config VSERVER_IDLELIMIT
19680 + bool "Limit the IDLE task"
19681 + depends on VSERVER_HARDCPU
19684 + Limit the idle slices, so the the next context
19685 + will be scheduled as soon as possible.
19687 + This might improve interactivity and latency, but
19688 + will also marginally increase scheduling overhead.
19691 + prompt "Persistent Inode Tagging"
19692 + default TAGGING_ID24
19694 + This adds persistent context information to filesystems
19695 + mounted with the tagxid option. Tagging is a requirement
19696 + for per-context disk limits and per-context quota.
19699 +config TAGGING_NONE
19702 + do not store per-context information in inodes.
19704 +config TAGGING_UID16
19705 + bool "UID16/GID32"
19707 + reduces UID to 16 bit, but leaves GID at 32 bit.
19709 +config TAGGING_GID16
19710 + bool "UID32/GID16"
19712 + reduces GID to 16 bit, but leaves UID at 32 bit.
19714 +config TAGGING_ID24
19715 + bool "UID24/GID24"
19717 + uses the upper 8bit from UID and GID for XID tagging
19718 + which leaves 24bit for UID/GID each, which should be
19719 + more than sufficient for normal use.
19721 +config TAGGING_INTERN
19722 + bool "UID32/GID32"
19724 + this uses otherwise reserved inode fields in the on
19725 + disk representation, which limits the use to a few
19726 + filesystems (currently ext2 and ext3)
19731 + bool "Tag NFSD User Auth and Files"
19734 + Enable this if you do want the in-kernel NFS
19735 + Server to use the tagging specified above.
19736 + (will require patched clients too)
19738 +config VSERVER_PRIVACY
19739 + bool "Honor Privacy Aspects of Guests"
19742 + When enabled, most context checks will disallow
19743 + access to structures assigned to a specific context,
19744 + like ptys or loop devices.
19746 +config VSERVER_CONTEXTS
19747 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
19749 + default "768" if 64BIT
19752 + This setting will optimize certain data structures
19753 + and memory allocations according to the expected
19756 + note: this is not a strict upper limit.
19758 +config VSERVER_WARN
19759 + bool "VServer Warnings"
19762 + This enables various runtime warnings, which will
19763 + notify about potential manipulation attempts or
19764 + resource shortage. It is generally considered to
19765 + be a good idea to have that enabled.
19767 +config VSERVER_DEBUG
19768 + bool "VServer Debugging Code"
19771 + Set this to yes if you want to be able to activate
19772 + debugging output at runtime. It adds a very small
19773 + overhead to all vserver related functions and
19774 + increases the kernel size by about 20k.
19776 +config VSERVER_HISTORY
19777 + bool "VServer History Tracing"
19778 + depends on VSERVER_DEBUG
19781 + Set this to yes if you want to record the history of
19782 + linux-vserver activities, so they can be replayed in
19783 + the event of a kernel panic or oops.
19785 +config VSERVER_HISTORY_SIZE
19786 + int "Per-CPU History Size (32-65536)"
19787 + depends on VSERVER_HISTORY
19791 + This allows you to specify the number of entries in
19792 + the per-CPU history buffer.
19794 +config VSERVER_MONITOR
19795 + bool "VServer Scheduling Monitor"
19796 + depends on VSERVER_DEBUG
19799 + Set this to yes if you want to record the scheduling
19800 + decisions, so that they can be relayed to userspace
19801 + for detailed analysis.
19803 +config VSERVER_MONITOR_SIZE
19804 + int "Per-CPU Monitor Queue Size (32-65536)"
19805 + depends on VSERVER_MONITOR
19809 + This allows you to specify the number of entries in
19810 + the per-CPU scheduling monitor buffer.
19812 +config VSERVER_MONITOR_SYNC
19813 + int "Per-CPU Monitor Sync Interval (0-65536)"
19814 + depends on VSERVER_MONITOR
19818 + This allows you to specify the interval in ticks
19819 + when a time sync entry is inserted.
19831 +config VSERVER_SECURITY
19833 + depends on SECURITY
19835 + select SECURITY_CAPABILITIES
19837 diff -NurpP --minimal linux-2.6.22.10/kernel/vserver/Makefile linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Makefile
19838 --- linux-2.6.22.10/kernel/vserver/Makefile 1970-01-01 01:00:00 +0100
19839 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/Makefile 2007-10-11 01:10:22 +0200
19842 +# Makefile for the Linux vserver routines.
19846 +obj-y += vserver.o
19848 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
19849 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
19852 +vserver-$(CONFIG_INET) += inet.o
19853 +vserver-$(CONFIG_PROC_FS) += proc.o
19854 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
19855 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
19856 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
19857 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
19859 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
19860 --- linux-2.6.22.10/kernel/vserver/cacct.c 1970-01-01 01:00:00 +0100
19861 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct.c 2007-08-15 21:54:31 +0200
19864 + * linux/kernel/vserver/cacct.c
19866 + * Virtual Server: Context Accounting
19868 + * Copyright (C) 2006-2007 Herbert Pötzl
19870 + * V0.01 added accounting stats
19874 +#include <linux/types.h>
19875 +#include <linux/vs_context.h>
19876 +#include <linux/vserver/cacct_cmd.h>
19877 +#include <linux/vserver/cacct_int.h>
19879 +#include <asm/errno.h>
19880 +#include <asm/uaccess.h>
19883 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
19885 + struct vcmd_sock_stat_v0 vc_data;
19888 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19891 + field = vc_data.field;
19892 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
19895 + for (j = 0; j < 3; j++) {
19896 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
19897 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
19900 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19905 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
19906 --- linux-2.6.22.10/kernel/vserver/cacct_init.h 1970-01-01 01:00:00 +0100
19907 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct_init.h 2007-08-05 20:53:13 +0200
19911 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
19916 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
19917 + for (j = 0; j < 3; j++) {
19918 + atomic_set(&cacct->sock[i][j].count, 0);
19919 + atomic_set(&cacct->sock[i][j].total, 0);
19922 + for (i = 0; i < 8; i++)
19923 + atomic_set(&cacct->slab[i], 0);
19924 + for (i = 0; i < 5; i++)
19925 + for (j = 0; j < 4; j++)
19926 + atomic_set(&cacct->page[i][j], 0);
19929 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
19934 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
19935 --- linux-2.6.22.10/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00 +0100
19936 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cacct_proc.h 2007-08-05 20:53:13 +0200
19938 +#ifndef _VX_CACCT_PROC_H
19939 +#define _VX_CACCT_PROC_H
19941 +#include <linux/vserver/cacct_int.h>
19944 +#define VX_SOCKA_TOP \
19945 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
19947 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
19949 + int i, j, length = 0;
19950 + static char *type[VXA_SOCK_SIZE] = {
19951 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
19954 + length += sprintf(buffer + length, VX_SOCKA_TOP);
19955 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
19956 + length += sprintf(buffer + length, "%s:", type[i]);
19957 + for (j = 0; j < 3; j++) {
19958 + length += sprintf(buffer + length,
19959 + "\t%10lu/%-10lu",
19960 + vx_sock_count(cacct, i, j),
19961 + vx_sock_total(cacct, i, j));
19963 + buffer[length++] = '\n';
19966 + length += sprintf(buffer + length, "\n");
19967 + length += sprintf(buffer + length,
19968 + "slab:\t %8u %8u %8u %8u\n",
19969 + atomic_read(&cacct->slab[1]),
19970 + atomic_read(&cacct->slab[4]),
19971 + atomic_read(&cacct->slab[0]),
19972 + atomic_read(&cacct->slab[2]));
19974 + length += sprintf(buffer + length, "\n");
19975 + for (i = 0; i < 5; i++) {
19976 + length += sprintf(buffer + length,
19977 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
19978 + atomic_read(&cacct->page[i][0]),
19979 + atomic_read(&cacct->page[i][1]),
19980 + atomic_read(&cacct->page[i][2]),
19981 + atomic_read(&cacct->page[i][3]),
19982 + atomic_read(&cacct->page[i][4]),
19983 + atomic_read(&cacct->page[i][5]),
19984 + atomic_read(&cacct->page[i][6]),
19985 + atomic_read(&cacct->page[i][7]));
19990 +#endif /* _VX_CACCT_PROC_H */
19991 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
19992 --- linux-2.6.22.10/kernel/vserver/context.c 1970-01-01 01:00:00 +0100
19993 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/context.c 2007-10-05 14:54:36 +0200
19996 + * linux/kernel/vserver/context.c
19998 + * Virtual Server: Context Support
20000 + * Copyright (C) 2003-2007 Herbert Pötzl
20002 + * V0.01 context helper
20003 + * V0.02 vx_ctx_kill syscall command
20004 + * V0.03 replaced context_info calls
20005 + * V0.04 redesign of struct (de)alloc
20006 + * V0.05 rlimit basic implementation
20007 + * V0.06 task_xid and info commands
20008 + * V0.07 context flags and caps
20009 + * V0.08 switch to RCU based hash
20010 + * V0.09 revert to non RCU for now
20011 + * V0.10 and back to working RCU hash
20012 + * V0.11 and back to locking again
20013 + * V0.12 referenced context store
20014 + * V0.13 separate per cpu data
20015 + * V0.14 changed vcmds to vxi arg
20016 + * V0.15 added context stat
20017 + * V0.16 have __create claim() the vxi
20018 + * V0.17 removed older and legacy stuff
20022 +#include <linux/slab.h>
20023 +#include <linux/types.h>
20024 +#include <linux/pid_namespace.h>
20026 +#include <linux/vserver/context.h>
20027 +#include <linux/vserver/network.h>
20028 +#include <linux/vserver/debug.h>
20029 +#include <linux/vserver/limit.h>
20030 +#include <linux/vserver/limit_int.h>
20031 +#include <linux/vserver/space.h>
20033 +#include <linux/vs_context.h>
20034 +#include <linux/vs_limit.h>
20035 +#include <linux/vserver/context_cmd.h>
20037 +#include "cvirt_init.h"
20038 +#include "cacct_init.h"
20039 +#include "limit_init.h"
20040 +#include "sched_init.h"
20043 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
20044 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
20047 +/* now inactive context structures */
20049 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
20051 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
20054 +/* __alloc_vx_info()
20056 + * allocate an initialized vx_info struct
20057 + * doesn't make it visible (hash) */
20059 +static struct vx_info *__alloc_vx_info(xid_t xid)
20061 + struct vx_info *new = NULL;
20064 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
20066 + /* would this benefit from a slab cache? */
20067 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
20071 + memset(new, 0, sizeof(struct vx_info));
20073 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
20074 + if (!new->ptr_pc)
20077 + new->vx_id = xid;
20078 + INIT_HLIST_NODE(&new->vx_hlist);
20079 + atomic_set(&new->vx_usecnt, 0);
20080 + atomic_set(&new->vx_tasks, 0);
20081 + new->vx_parent = NULL;
20082 + new->vx_state = 0;
20083 + init_waitqueue_head(&new->vx_wait);
20085 + /* prepare reaper */
20086 + get_task_struct(init_pid_ns.child_reaper);
20087 + new->vx_reaper = init_pid_ns.child_reaper;
20088 + new->vx_badness_bias = 0;
20090 + /* rest of init goes here */
20091 + vx_info_init_limit(&new->limit);
20092 + vx_info_init_sched(&new->sched);
20093 + vx_info_init_cvirt(&new->cvirt);
20094 + vx_info_init_cacct(&new->cacct);
20096 + /* per cpu data structures */
20097 + for_each_possible_cpu(cpu) {
20098 + vx_info_init_sched_pc(
20099 + &vx_per_cpu(new, sched_pc, cpu), cpu);
20100 + vx_info_init_cvirt_pc(
20101 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
20104 + new->vx_flags = VXF_INIT_SET;
20105 + new->vx_bcaps = CAP_INIT_EFF_SET;
20106 + new->vx_ccaps = 0;
20107 + new->vx_cap_bset = cap_bset;
20109 + new->reboot_cmd = 0;
20110 + new->exit_code = 0;
20112 + new->vx_nsproxy = copy_nsproxy(current->nsproxy);
20114 + vxdprintk(VXD_CBIT(xid, 0),
20115 + "alloc_vx_info(%d) = %p", xid, new);
20116 + vxh_alloc_vx_info(new);
20117 + atomic_inc(&vx_global_ctotal);
20126 +/* __dealloc_vx_info()
20128 + * final disposal of vx_info */
20130 +static void __dealloc_vx_info(struct vx_info *vxi)
20134 + vxdprintk(VXD_CBIT(xid, 0),
20135 + "dealloc_vx_info(%p)", vxi);
20136 + vxh_dealloc_vx_info(vxi);
20140 + vx_info_exit_limit(&vxi->limit);
20141 + vx_info_exit_sched(&vxi->sched);
20142 + vx_info_exit_cvirt(&vxi->cvirt);
20143 + vx_info_exit_cacct(&vxi->cacct);
20145 + for_each_possible_cpu(cpu) {
20146 + vx_info_exit_sched_pc(
20147 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
20148 + vx_info_exit_cvirt_pc(
20149 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
20152 + vxi->vx_state |= VXS_RELEASED;
20155 + free_percpu(vxi->ptr_pc);
20158 + atomic_dec(&vx_global_ctotal);
20161 +static void __shutdown_vx_info(struct vx_info *vxi)
20163 + struct nsproxy *nsproxy;
20164 + struct fs_struct *fs;
20168 + vxi->vx_state |= VXS_SHUTDOWN;
20169 + vs_state_change(vxi, VSC_SHUTDOWN);
20171 + nsproxy = xchg(&vxi->vx_nsproxy, NULL);
20172 + fs = xchg(&vxi->vx_fs, NULL);
20175 + put_nsproxy(nsproxy);
20177 + put_fs_struct(fs);
20180 +/* exported stuff */
20182 +void free_vx_info(struct vx_info *vxi)
20184 + unsigned long flags;
20186 + /* check for reference counts first */
20187 + BUG_ON(atomic_read(&vxi->vx_usecnt));
20188 + BUG_ON(atomic_read(&vxi->vx_tasks));
20190 + /* context must not be hashed */
20191 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
20193 + /* context shutdown is mandatory */
20194 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
20196 + BUG_ON(vxi->vx_nsproxy);
20197 + BUG_ON(vxi->vx_fs);
20199 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
20200 + hlist_del(&vxi->vx_hlist);
20201 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
20203 + __dealloc_vx_info(vxi);
20207 +/* hash table for vx_info hash */
20209 +#define VX_HASH_SIZE 13
20211 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
20212 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
20214 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
20217 +static inline unsigned int __hashval(xid_t xid)
20219 + return (xid % VX_HASH_SIZE);
20224 +/* __hash_vx_info()
20226 + * add the vxi to the global hash table
20227 + * requires the hash_lock to be held */
20229 +static inline void __hash_vx_info(struct vx_info *vxi)
20231 + struct hlist_head *head;
20233 + vxd_assert_lock(&vx_info_hash_lock);
20234 + vxdprintk(VXD_CBIT(xid, 4),
20235 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
20236 + vxh_hash_vx_info(vxi);
20238 + /* context must not be hashed */
20239 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
20241 + vxi->vx_state |= VXS_HASHED;
20242 + head = &vx_info_hash[__hashval(vxi->vx_id)];
20243 + hlist_add_head(&vxi->vx_hlist, head);
20244 + atomic_inc(&vx_global_cactive);
20247 +/* __unhash_vx_info()
20249 + * remove the vxi from the global hash table
20250 + * requires the hash_lock to be held */
20252 +static inline void __unhash_vx_info(struct vx_info *vxi)
20254 + unsigned long flags;
20256 + vxd_assert_lock(&vx_info_hash_lock);
20257 + vxdprintk(VXD_CBIT(xid, 4),
20258 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
20259 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
20260 + vxh_unhash_vx_info(vxi);
20262 + /* context must be hashed */
20263 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
20264 + /* but without tasks */
20265 + BUG_ON(atomic_read(&vxi->vx_tasks));
20267 + vxi->vx_state &= ~VXS_HASHED;
20268 + hlist_del_init(&vxi->vx_hlist);
20269 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
20270 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
20271 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
20272 + atomic_dec(&vx_global_cactive);
20276 +/* __lookup_vx_info()
20278 + * requires the hash_lock to be held
20279 + * doesn't increment the vx_refcnt */
20281 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
20283 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
20284 + struct hlist_node *pos;
20285 + struct vx_info *vxi;
20287 + vxd_assert_lock(&vx_info_hash_lock);
20288 + hlist_for_each(pos, head) {
20289 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
20291 + if (vxi->vx_id == xid)
20296 + vxdprintk(VXD_CBIT(xid, 0),
20297 + "__lookup_vx_info(#%u): %p[#%u]",
20298 + xid, vxi, vxi ? vxi->vx_id : 0);
20299 + vxh_lookup_vx_info(vxi, xid);
20304 +/* __create_vx_info()
20306 + * create the requested context
20307 + * get(), claim() and hash it */
20309 +static struct vx_info *__create_vx_info(int id)
20311 + struct vx_info *new, *vxi = NULL;
20313 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
20315 + if (!(new = __alloc_vx_info(id)))
20316 + return ERR_PTR(-ENOMEM);
20318 + /* required to make dynamic xids unique */
20319 + spin_lock(&vx_info_hash_lock);
20321 + /* static context requested */
20322 + if ((vxi = __lookup_vx_info(id))) {
20323 + vxdprintk(VXD_CBIT(xid, 0),
20324 + "create_vx_info(%d) = %p (already there)", id, vxi);
20325 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
20326 + vxi = ERR_PTR(-EBUSY);
20328 + vxi = ERR_PTR(-EEXIST);
20331 + /* new context */
20332 + vxdprintk(VXD_CBIT(xid, 0),
20333 + "create_vx_info(%d) = %p (new)", id, new);
20334 + claim_vx_info(new, NULL);
20335 + __hash_vx_info(get_vx_info(new));
20336 + vxi = new, new = NULL;
20339 + spin_unlock(&vx_info_hash_lock);
20340 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
20342 + __dealloc_vx_info(new);
20347 +/* exported stuff */
20350 +void unhash_vx_info(struct vx_info *vxi)
20352 + __shutdown_vx_info(vxi);
20353 + spin_lock(&vx_info_hash_lock);
20354 + __unhash_vx_info(vxi);
20355 + spin_unlock(&vx_info_hash_lock);
20356 + __wakeup_vx_info(vxi);
20360 +/* lookup_vx_info()
20362 + * search for a vx_info and get() it
20363 + * negative id means current */
20365 +struct vx_info *lookup_vx_info(int id)
20367 + struct vx_info *vxi = NULL;
20370 + vxi = get_vx_info(current->vx_info);
20371 + } else if (id > 1) {
20372 + spin_lock(&vx_info_hash_lock);
20373 + vxi = get_vx_info(__lookup_vx_info(id));
20374 + spin_unlock(&vx_info_hash_lock);
20379 +/* xid_is_hashed()
20381 + * verify that xid is still hashed */
20383 +int xid_is_hashed(xid_t xid)
20387 + spin_lock(&vx_info_hash_lock);
20388 + hashed = (__lookup_vx_info(xid) != NULL);
20389 + spin_unlock(&vx_info_hash_lock);
20393 +#ifdef CONFIG_PROC_FS
20397 + * get a subset of hashed xids for proc
20398 + * assumes size is at least one */
20400 +int get_xid_list(int index, unsigned int *xids, int size)
20402 + int hindex, nr_xids = 0;
20404 + /* only show current and children */
20405 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
20408 + xids[nr_xids] = vx_current_xid();
20412 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
20413 + struct hlist_head *head = &vx_info_hash[hindex];
20414 + struct hlist_node *pos;
20416 + spin_lock(&vx_info_hash_lock);
20417 + hlist_for_each(pos, head) {
20418 + struct vx_info *vxi;
20423 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
20424 + xids[nr_xids] = vxi->vx_id;
20425 + if (++nr_xids >= size) {
20426 + spin_unlock(&vx_info_hash_lock);
20430 + /* keep the lock time short */
20431 + spin_unlock(&vx_info_hash_lock);
20438 +#ifdef CONFIG_VSERVER_DEBUG
20440 +void dump_vx_info_inactive(int level)
20442 + struct hlist_node *entry, *next;
20444 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
20445 + struct vx_info *vxi =
20446 + list_entry(entry, struct vx_info, vx_hlist);
20448 + dump_vx_info(vxi, level);
20454 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
20456 + struct user_struct *new_user, *old_user;
20461 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
20464 + new_user = alloc_uid(vxi->vx_id, p->uid);
20468 + old_user = p->user;
20469 + if (new_user != old_user) {
20470 + atomic_inc(&new_user->processes);
20471 + atomic_dec(&old_user->processes);
20472 + p->user = new_user;
20474 + free_uid(old_user);
20478 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
20480 + p->cap_effective &= vxi->vx_cap_bset;
20481 + p->cap_inheritable &= vxi->vx_cap_bset;
20482 + p->cap_permitted &= vxi->vx_cap_bset;
20486 +#include <linux/file.h>
20488 +static int vx_openfd_task(struct task_struct *tsk)
20490 + struct files_struct *files = tsk->files;
20491 + struct fdtable *fdt;
20492 + const unsigned long *bptr;
20493 + int count, total;
20495 + /* no rcu_read_lock() because of spin_lock() */
20496 + spin_lock(&files->file_lock);
20497 + fdt = files_fdtable(files);
20498 + bptr = fdt->open_fds->fds_bits;
20499 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
20500 + for (total = 0; count > 0; count--) {
20502 + total += hweight_long(*bptr);
20505 + spin_unlock(&files->file_lock);
20510 +/* for *space compatibility */
20512 +asmlinkage long sys_unshare(unsigned long);
20515 + * migrate task to new context
20516 + * gets vxi, puts old_vxi on change
20517 + * optionally unshares namespaces (hack)
20520 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
20522 + struct vx_info *old_vxi;
20528 + vxdprintk(VXD_CBIT(xid, 5),
20529 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
20530 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
20532 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
20533 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
20536 + if (vx_info_state(vxi, VXS_SHUTDOWN))
20539 + old_vxi = task_get_vx_info(p);
20540 + if (old_vxi == vxi)
20543 + if (!(ret = vx_migrate_user(p, vxi))) {
20547 + openfd = vx_openfd_task(p);
20550 + atomic_dec(&old_vxi->cvirt.nr_threads);
20551 + atomic_dec(&old_vxi->cvirt.nr_running);
20552 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
20553 + /* FIXME: what about the struct files here? */
20554 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
20555 + /* account for the executable */
20556 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
20558 + atomic_inc(&vxi->cvirt.nr_threads);
20559 + atomic_inc(&vxi->cvirt.nr_running);
20560 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
20561 + /* FIXME: what about the struct files here? */
20562 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
20563 + /* account for the executable */
20564 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
20567 + release_vx_info(old_vxi, p);
20568 + clr_vx_info(&p->vx_info);
20570 + claim_vx_info(vxi, p);
20571 + set_vx_info(&p->vx_info, vxi);
20572 + p->xid = vxi->vx_id;
20574 + vxdprintk(VXD_CBIT(xid, 5),
20575 + "moved task %p into vxi:%p[#%d]",
20576 + p, vxi, vxi->vx_id);
20578 + vx_mask_cap_bset(vxi, p);
20581 + /* hack for *spaces to provide compatibility */
20583 + struct nsproxy *old_nsp, *new_nsp;
20585 + ret = unshare_nsproxy_namespaces(
20586 + CLONE_NEWUTS | CLONE_NEWIPC,
20591 + old_nsp = xchg(&p->nsproxy, new_nsp);
20592 + vx_set_space(vxi, CLONE_NEWUTS | CLONE_NEWIPC);
20593 + put_nsproxy(old_nsp);
20597 + put_vx_info(old_vxi);
20601 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
20603 + struct task_struct *old_reaper;
20608 + vxdprintk(VXD_CBIT(xid, 6),
20609 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
20610 + vxi, vxi->vx_id, p, p->xid, p->pid);
20612 + old_reaper = vxi->vx_reaper;
20613 + if (old_reaper == p)
20616 + /* set new child reaper */
20617 + get_task_struct(p);
20618 + vxi->vx_reaper = p;
20619 + put_task_struct(old_reaper);
20623 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
20628 + vxdprintk(VXD_CBIT(xid, 6),
20629 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
20630 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
20632 + vxi->vx_flags &= ~VXF_STATE_INIT;
20633 + vxi->vx_initpid = p->tgid;
20637 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
20639 + vxdprintk(VXD_CBIT(xid, 6),
20640 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
20641 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
20643 + vxi->exit_code = code;
20644 + vxi->vx_initpid = 0;
20648 +void vx_set_persistent(struct vx_info *vxi)
20650 + vxdprintk(VXD_CBIT(xid, 6),
20651 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
20653 + get_vx_info(vxi);
20654 + claim_vx_info(vxi, NULL);
20657 +void vx_clear_persistent(struct vx_info *vxi)
20659 + vxdprintk(VXD_CBIT(xid, 6),
20660 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
20662 + release_vx_info(vxi, NULL);
20663 + put_vx_info(vxi);
20666 +void vx_update_persistent(struct vx_info *vxi)
20668 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
20669 + vx_set_persistent(vxi);
20671 + vx_clear_persistent(vxi);
20675 +/* task must be current or locked */
20677 +void exit_vx_info(struct task_struct *p, int code)
20679 + struct vx_info *vxi = p->vx_info;
20682 + atomic_dec(&vxi->cvirt.nr_threads);
20685 + vxi->exit_code = code;
20686 + release_vx_info(vxi, p);
20690 +void exit_vx_info_early(struct task_struct *p, int code)
20692 + struct vx_info *vxi = p->vx_info;
20695 + if (vxi->vx_initpid == p->tgid)
20696 + vx_exit_init(vxi, p, code);
20697 + if (vxi->vx_reaper == p)
20698 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
20703 +/* vserver syscall commands below here */
20705 +/* taks xid and vx_info functions */
20707 +#include <asm/uaccess.h>
20710 +int vc_task_xid(uint32_t id)
20715 + struct task_struct *tsk;
20717 + read_lock(&tasklist_lock);
20718 + tsk = find_task_by_real_pid(id);
20719 + xid = (tsk) ? tsk->xid : -ESRCH;
20720 + read_unlock(&tasklist_lock);
20722 + xid = vx_current_xid();
20727 +int vc_vx_info(struct vx_info *vxi, void __user *data)
20729 + struct vcmd_vx_info_v0 vc_data;
20731 + vc_data.xid = vxi->vx_id;
20732 + vc_data.initpid = vxi->vx_initpid;
20734 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20740 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
20742 + struct vcmd_ctx_stat_v0 vc_data;
20744 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
20745 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
20747 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20753 +/* context functions */
20755 +int vc_ctx_create(uint32_t xid, void __user *data)
20757 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
20758 + struct vx_info *new_vxi;
20761 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20764 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
20767 + new_vxi = __create_vx_info(xid);
20768 + if (IS_ERR(new_vxi))
20769 + return PTR_ERR(new_vxi);
20771 + /* initial flags */
20772 + new_vxi->vx_flags = vc_data.flagword;
20775 + if (vs_state_change(new_vxi, VSC_STARTUP))
20778 + ret = vx_migrate_task(current, new_vxi, (!data));
20782 + /* return context id on success */
20783 + ret = new_vxi->vx_id;
20785 + /* get a reference for persistent contexts */
20786 + if ((vc_data.flagword & VXF_PERSISTENT))
20787 + vx_set_persistent(new_vxi);
20789 + release_vx_info(new_vxi, NULL);
20790 + put_vx_info(new_vxi);
20795 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
20797 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
20800 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20803 + ret = vx_migrate_task(current, vxi, 0);
20806 + if (vc_data.flagword & VXM_SET_INIT)
20807 + ret = vx_set_init(vxi, current);
20810 + if (vc_data.flagword & VXM_SET_REAPER)
20811 + ret = vx_set_reaper(vxi, current);
20816 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
20818 + struct vcmd_ctx_flags_v0 vc_data;
20820 + vc_data.flagword = vxi->vx_flags;
20822 + /* special STATE flag handling */
20823 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
20825 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20830 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
20832 + struct vcmd_ctx_flags_v0 vc_data;
20833 + uint64_t mask, trigger;
20835 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20838 + /* special STATE flag handling */
20839 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
20840 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
20842 + if (vxi == current->vx_info) {
20843 + if (trigger & VXF_STATE_SETUP)
20844 + vx_mask_cap_bset(vxi, current);
20845 + if (trigger & VXF_STATE_INIT) {
20848 + ret = vx_set_init(vxi, current);
20851 + ret = vx_set_reaper(vxi, current);
20857 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
20858 + vc_data.flagword, mask);
20859 + if (trigger & VXF_PERSISTENT)
20860 + vx_update_persistent(vxi);
20865 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
20868 + *bcaps = vxi->vx_bcaps;
20870 + *ccaps = vxi->vx_ccaps;
20875 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
20877 + struct vcmd_ctx_caps_v1 vc_data;
20880 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
20883 + vc_data.cmask = ~0ULL;
20885 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20890 +static int do_set_caps(struct vx_info *vxi,
20891 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
20893 + vxi->vx_bcaps = vs_mask_flags(vxi->vx_bcaps, bcaps, bmask);
20894 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
20899 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
20901 + struct vcmd_ctx_caps_v1 vc_data;
20903 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20906 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
20909 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
20911 + struct vcmd_bcaps vc_data;
20914 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
20917 + vc_data.bmask = ~0ULL;
20919 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20924 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
20926 + struct vcmd_bcaps vc_data;
20928 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20931 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
20935 +int vc_get_badness(struct vx_info *vxi, void __user *data)
20937 + struct vcmd_badness_v0 vc_data;
20939 + vc_data.bias = vxi->vx_badness_bias;
20941 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20946 +int vc_set_badness(struct vx_info *vxi, void __user *data)
20948 + struct vcmd_badness_v0 vc_data;
20950 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20953 + vxi->vx_badness_bias = vc_data.bias;
20957 +#include <linux/module.h>
20959 +EXPORT_SYMBOL_GPL(free_vx_info);
20961 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
20962 --- linux-2.6.22.10/kernel/vserver/cvirt.c 1970-01-01 01:00:00 +0100
20963 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt.c 2007-08-15 22:00:34 +0200
20966 + * linux/kernel/vserver/cvirt.c
20968 + * Virtual Server: Context Virtualization
20970 + * Copyright (C) 2004-2007 Herbert Pötzl
20972 + * V0.01 broken out from limit.c
20973 + * V0.02 added utsname stuff
20974 + * V0.03 changed vcmds to vxi arg
20978 +#include <linux/types.h>
20979 +#include <linux/vs_cvirt.h>
20980 +#include <linux/vserver/switch.h>
20981 +#include <linux/vserver/cvirt_cmd.h>
20983 +#include <asm/uaccess.h>
20986 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
20988 + struct vx_info *vxi = current->vx_info;
20990 + set_normalized_timespec(uptime,
20991 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
20992 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
20995 + set_normalized_timespec(idle,
20996 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
20997 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
21001 +uint64_t vx_idle_jiffies(void)
21003 + return init_task.utime + init_task.stime;
21008 +static inline uint32_t __update_loadavg(uint32_t load,
21009 + int wsize, int delta, int n)
21011 + unsigned long long calc, prev;
21013 + /* just set it to n */
21014 + if (unlikely(delta >= wsize))
21015 + return (n << FSHIFT);
21017 + calc = delta * n;
21019 + prev = (wsize - delta);
21022 + do_div(calc, wsize);
21027 +void vx_update_load(struct vx_info *vxi)
21029 + uint32_t now, last, delta;
21030 + unsigned int nr_running, nr_uninterruptible;
21031 + unsigned int total;
21032 + unsigned long flags;
21034 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
21037 + last = vxi->cvirt.load_last;
21038 + delta = now - last;
21040 + if (delta < 5*HZ)
21043 + nr_running = atomic_read(&vxi->cvirt.nr_running);
21044 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
21045 + total = nr_running + nr_uninterruptible;
21047 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
21048 + 60*HZ, delta, total);
21049 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
21050 + 5*60*HZ, delta, total);
21051 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
21052 + 15*60*HZ, delta, total);
21054 + vxi->cvirt.load_last = now;
21056 + atomic_inc(&vxi->cvirt.load_updates);
21057 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
21062 + * Commands to do_syslog:
21064 + * 0 -- Close the log. Currently a NOP.
21065 + * 1 -- Open the log. Currently a NOP.
21066 + * 2 -- Read from the log.
21067 + * 3 -- Read all messages remaining in the ring buffer.
21068 + * 4 -- Read and clear all messages remaining in the ring buffer
21069 + * 5 -- Clear ring buffer.
21070 + * 6 -- Disable printk's to console
21071 + * 7 -- Enable printk's to console
21072 + * 8 -- Set level of messages printed to console
21073 + * 9 -- Return number of unread characters in the log buffer
21074 + * 10 -- Return size of the log buffer
21076 +int vx_do_syslog(int type, char __user *buf, int len)
21079 + int do_clear = 0;
21080 + struct vx_info *vxi = current->vx_info;
21081 + struct _vx_syslog *log;
21085 + log = &vxi->cvirt.syslog;
21088 + case 0: /* Close log */
21089 + case 1: /* Open log */
21091 + case 2: /* Read from log */
21092 + error = wait_event_interruptible(log->log_wait,
21093 + (log->log_start - log->log_end));
21096 + spin_lock_irq(&log->logbuf_lock);
21097 + spin_unlock_irq(&log->logbuf_lock);
21099 + case 4: /* Read/clear last kernel messages */
21101 + /* fall through */
21102 + case 3: /* Read last kernel messages */
21105 + case 5: /* Clear ring buffer */
21108 + case 6: /* Disable logging to console */
21109 + case 7: /* Enable logging to console */
21110 + case 8: /* Set level of messages printed to console */
21113 + case 9: /* Number of chars in the log buffer */
21115 + case 10: /* Size of the log buffer */
21125 +/* virtual host info names */
21127 +static char *vx_vhi_name(struct vx_info *vxi, int id)
21129 + struct nsproxy *nsproxy;
21130 + struct uts_namespace *uts;
21133 + if (id == VHIN_CONTEXT)
21134 + return vxi->vx_name;
21136 + nsproxy = vxi->vx_nsproxy;
21140 + uts = nsproxy->uts_ns;
21145 + case VHIN_SYSNAME:
21146 + return uts->name.sysname;
21147 + case VHIN_NODENAME:
21148 + return uts->name.nodename;
21149 + case VHIN_RELEASE:
21150 + return uts->name.release;
21151 + case VHIN_VERSION:
21152 + return uts->name.version;
21153 + case VHIN_MACHINE:
21154 + return uts->name.machine;
21155 + case VHIN_DOMAINNAME:
21156 + return uts->name.domainname;
21163 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
21165 + struct vcmd_vhi_name_v0 vc_data;
21168 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21171 + name = vx_vhi_name(vxi, vc_data.field);
21175 + memcpy(name, vc_data.name, 65);
21179 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
21181 + struct vcmd_vhi_name_v0 vc_data;
21184 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21187 + name = vx_vhi_name(vxi, vc_data.field);
21191 + memcpy(vc_data.name, name, 65);
21192 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21198 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
21200 + struct vcmd_virt_stat_v0 vc_data;
21201 + struct _vx_cvirt *cvirt = &vxi->cvirt;
21202 + struct timespec uptime;
21204 + do_posix_clock_monotonic_gettime(&uptime);
21205 + set_normalized_timespec(&uptime,
21206 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
21207 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
21209 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
21210 + vc_data.uptime = timespec_to_ns(&uptime);
21211 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
21212 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
21213 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
21214 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
21215 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
21216 + vc_data.load[0] = cvirt->load[0];
21217 + vc_data.load[1] = cvirt->load[1];
21218 + vc_data.load[2] = cvirt->load[2];
21220 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21226 +#ifdef CONFIG_VSERVER_VTIME
21228 +/* virtualized time base */
21230 +void vx_gettimeofday(struct timeval *tv)
21232 + do_gettimeofday(tv);
21233 + if (!vx_flags(VXF_VIRT_TIME, 0))
21236 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
21237 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
21239 + if (tv->tv_usec >= USEC_PER_SEC) {
21241 + tv->tv_usec -= USEC_PER_SEC;
21242 + } else if (tv->tv_usec < 0) {
21244 + tv->tv_usec += USEC_PER_SEC;
21248 +int vx_settimeofday(struct timespec *ts)
21250 + struct timeval tv;
21252 + if (!vx_flags(VXF_VIRT_TIME, 0))
21253 + return do_settimeofday(ts);
21255 + do_gettimeofday(&tv);
21256 + current->vx_info->cvirt.bias_tv.tv_sec =
21257 + ts->tv_sec - tv.tv_sec;
21258 + current->vx_info->cvirt.bias_tv.tv_usec =
21259 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
21265 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
21266 --- linux-2.6.22.10/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00 +0100
21267 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt_init.h 2007-10-25 17:05:55 +0200
21271 +extern uint64_t vx_idle_jiffies(void);
21273 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
21275 + uint64_t idle_jiffies = vx_idle_jiffies();
21276 + uint64_t nsuptime;
21278 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
21279 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
21280 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
21281 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
21282 + cvirt->bias_tv.tv_sec = 0;
21283 + cvirt->bias_tv.tv_usec = 0;
21285 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
21286 + atomic_set(&cvirt->nr_threads, 0);
21287 + atomic_set(&cvirt->nr_running, 0);
21288 + atomic_set(&cvirt->nr_uninterruptible, 0);
21289 + atomic_set(&cvirt->nr_onhold, 0);
21291 + spin_lock_init(&cvirt->load_lock);
21292 + cvirt->load_last = jiffies;
21293 + atomic_set(&cvirt->load_updates, 0);
21294 + cvirt->load[0] = 0;
21295 + cvirt->load[1] = 0;
21296 + cvirt->load[2] = 0;
21297 + atomic_set(&cvirt->total_forks, 0);
21299 + spin_lock_init(&cvirt->syslog.logbuf_lock);
21300 + init_waitqueue_head(&cvirt->syslog.log_wait);
21301 + cvirt->syslog.log_start = 0;
21302 + cvirt->syslog.log_end = 0;
21303 + cvirt->syslog.con_start = 0;
21304 + cvirt->syslog.logged_chars = 0;
21308 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
21310 + // cvirt_pc->cpustat = { 0 };
21313 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
21317 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
21318 + "!!! cvirt: %p[nr_threads] = %d on exit.",
21320 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
21321 + "!!! cvirt: %p[nr_running] = %d on exit.",
21323 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
21324 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
21326 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
21327 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
21333 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
21338 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
21339 --- linux-2.6.22.10/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00 +0100
21340 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/cvirt_proc.h 2007-08-05 20:53:13 +0200
21342 +#ifndef _VX_CVIRT_PROC_H
21343 +#define _VX_CVIRT_PROC_H
21345 +#include <linux/nsproxy.h>
21346 +#include <linux/mnt_namespace.h>
21347 +#include <linux/utsname.h>
21348 +#include <linux/ipc.h>
21352 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
21354 + struct mnt_namespace *ns;
21355 + struct uts_namespace *uts;
21356 + struct ipc_namespace *ipc;
21357 + struct vfsmount *mnt;
21358 + char *path, *root;
21364 + length += sprintf(buffer + length,
21365 + "NSProxy:\t%p [%p,%p,%p]\n",
21366 + nsproxy, nsproxy->mnt_ns,
21367 + nsproxy->uts_ns, nsproxy->ipc_ns);
21369 + ns = nsproxy->mnt_ns;
21373 + path = kmalloc(PATH_MAX, GFP_KERNEL);
21378 + root = d_path(mnt->mnt_root, mnt->mnt_parent, path, PATH_MAX - 2);
21379 + length += sprintf(buffer + length,
21380 + "Namespace:\t%p [#%u]\n"
21381 + "RootPath:\t%s\n",
21382 + ns, atomic_read(&ns->count),
21387 + uts = nsproxy->uts_ns;
21391 + length += sprintf(buffer + length,
21392 + "SysName:\t%.*s\n"
21393 + "NodeName:\t%.*s\n"
21394 + "Release:\t%.*s\n"
21395 + "Version:\t%.*s\n"
21396 + "Machine:\t%.*s\n"
21397 + "DomainName:\t%.*s\n",
21398 + __NEW_UTS_LEN, uts->name.sysname,
21399 + __NEW_UTS_LEN, uts->name.nodename,
21400 + __NEW_UTS_LEN, uts->name.release,
21401 + __NEW_UTS_LEN, uts->name.version,
21402 + __NEW_UTS_LEN, uts->name.machine,
21403 + __NEW_UTS_LEN, uts->name.domainname);
21406 + ipc = nsproxy->ipc_ns;
21410 + length += sprintf(buffer + length,
21411 + "SEMS:\t\t%d %d %d %d %d\n"
21412 + "MSG:\t\t%d %d %d\n"
21413 + "SHM:\t\t%lu %lu %d %d\n",
21414 + ipc->sem_ctls[0], ipc->sem_ctls[1],
21415 + ipc->sem_ctls[2], ipc->sem_ctls[3],
21417 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
21418 + (unsigned long)ipc->shm_ctlmax,
21419 + (unsigned long)ipc->shm_ctlall,
21420 + ipc->shm_ctlmni, ipc->shm_tot);
21427 +#include <linux/sched.h>
21429 +#define LOAD_INT(x) ((x) >> FSHIFT)
21430 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
21433 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
21438 + length += sprintf(buffer + length,
21439 + "BiasUptime:\t%lu.%02lu\n",
21440 + (unsigned long)cvirt->bias_uptime.tv_sec,
21441 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
21443 + a = cvirt->load[0] + (FIXED_1 / 200);
21444 + b = cvirt->load[1] + (FIXED_1 / 200);
21445 + c = cvirt->load[2] + (FIXED_1 / 200);
21446 + length += sprintf(buffer + length,
21447 + "nr_threads:\t%d\n"
21448 + "nr_running:\t%d\n"
21449 + "nr_unintr:\t%d\n"
21450 + "nr_onhold:\t%d\n"
21451 + "load_updates:\t%d\n"
21452 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
21453 + "total_forks:\t%d\n",
21454 + atomic_read(&cvirt->nr_threads),
21455 + atomic_read(&cvirt->nr_running),
21456 + atomic_read(&cvirt->nr_uninterruptible),
21457 + atomic_read(&cvirt->nr_onhold),
21458 + atomic_read(&cvirt->load_updates),
21459 + LOAD_INT(a), LOAD_FRAC(a),
21460 + LOAD_INT(b), LOAD_FRAC(b),
21461 + LOAD_INT(c), LOAD_FRAC(c),
21462 + atomic_read(&cvirt->total_forks));
21467 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
21468 + char *buffer, int cpu)
21474 +#endif /* _VX_CVIRT_PROC_H */
21475 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
21476 --- linux-2.6.22.10/kernel/vserver/debug.c 1970-01-01 01:00:00 +0100
21477 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/debug.c 2007-10-01 14:57:41 +0200
21480 + * kernel/vserver/debug.c
21482 + * Copyright (C) 2005-2007 Herbert Pötzl
21484 + * V0.01 vx_info dump support
21488 +#include <linux/module.h>
21490 +#include <linux/vserver/context.h>
21493 +void dump_vx_info(struct vx_info *vxi, int level)
21495 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
21496 + atomic_read(&vxi->vx_usecnt),
21497 + atomic_read(&vxi->vx_tasks),
21500 + __dump_vx_limit(&vxi->limit);
21501 + __dump_vx_sched(&vxi->sched);
21502 + __dump_vx_cvirt(&vxi->cvirt);
21503 + __dump_vx_cacct(&vxi->cacct);
21509 +EXPORT_SYMBOL_GPL(dump_vx_info);
21511 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
21512 --- linux-2.6.22.10/kernel/vserver/device.c 1970-01-01 01:00:00 +0100
21513 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/device.c 2007-10-11 01:10:22 +0200
21516 + * linux/kernel/vserver/device.c
21518 + * Linux-VServer: Device Support
21520 + * Copyright (C) 2006 Herbert Pötzl
21521 + * Copyright (C) 2007 Daniel Hokka Zakrisson
21523 + * V0.01 device mapping basics
21524 + * V0.02 added defaults
21528 +#include <linux/slab.h>
21529 +#include <linux/rcupdate.h>
21530 +#include <linux/fs.h>
21531 +#include <linux/namei.h>
21532 +#include <linux/hash.h>
21534 +#include <asm/errno.h>
21535 +#include <asm/uaccess.h>
21536 +#include <linux/vserver/base.h>
21537 +#include <linux/vserver/debug.h>
21538 +#include <linux/vserver/context.h>
21539 +#include <linux/vserver/device.h>
21540 +#include <linux/vserver/device_cmd.h>
21543 +#define DMAP_HASH_BITS 4
21546 +struct vs_mapping {
21548 + struct hlist_node hlist;
21549 + struct list_head list;
21551 +#define dm_hlist u.hlist
21552 +#define dm_list u.list
21555 + struct vx_dmap_target target;
21559 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
21561 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
21563 +static struct vx_dmap_target dmap_defaults[2] = {
21564 + { .flags = DATTR_OPEN },
21565 + { .flags = DATTR_OPEN },
21569 +struct kmem_cache *dmap_cachep __read_mostly;
21571 +int __init dmap_cache_init(void)
21573 + dmap_cachep = kmem_cache_create("dmap_cache",
21574 + sizeof(struct vs_mapping), 0,
21575 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
21579 +__initcall(dmap_cache_init);
21582 +static inline unsigned int __hashval(dev_t dev, int bits)
21584 + return hash_long((unsigned long)dev, bits);
21588 +/* __hash_mapping()
21589 + * add the mapping to the hash table
21591 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
21593 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21594 + struct hlist_head *head, *hash = dmap_main_hash;
21595 + int device = vdm->device;
21597 + spin_lock(hash_lock);
21598 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
21599 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
21601 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
21602 + hlist_add_head(&vdm->dm_hlist, head);
21603 + spin_unlock(hash_lock);
21607 +static inline int __mode_to_default(umode_t mode)
21620 +/* __set_default()
21623 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
21624 + struct vx_dmap_target *vdmt)
21626 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21627 + spin_lock(hash_lock);
21630 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
21632 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
21635 + spin_unlock(hash_lock);
21637 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
21638 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
21642 +/* __remove_default()
21643 + * remove a default
21645 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
21647 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21648 + spin_lock(hash_lock);
21651 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
21652 + else /* remove == reset */
21653 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
21655 + spin_unlock(hash_lock);
21660 +/* __find_mapping()
21661 + * find a mapping in the hash table
21663 + * caller must hold hash_lock
21665 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
21666 + struct vs_mapping **local, struct vs_mapping **global)
21668 + struct hlist_head *hash = dmap_main_hash;
21669 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
21670 + struct hlist_node *pos;
21671 + struct vs_mapping *vdm;
21677 + hlist_for_each(pos, head) {
21678 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
21680 + if ((vdm->device == device) &&
21681 + !((vdm->target.flags ^ mode) & S_IFMT)) {
21682 + if (vdm->xid == xid) {
21685 + } else if (global && vdm->xid == 0)
21690 + if (global && *global)
21697 +/* __lookup_mapping()
21698 + * find a mapping and store the result in target and flags
21700 +static inline int __lookup_mapping(struct vx_info *vxi,
21701 + dev_t device, dev_t *target, int *flags, umode_t mode)
21703 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21704 + struct vs_mapping *vdm, *global;
21705 + struct vx_dmap_target *vdmt;
21707 + xid_t xid = vxi->vx_id;
21710 + spin_lock(hash_lock);
21711 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
21713 + vdmt = &vdm->target;
21717 + index = __mode_to_default(mode);
21718 + if (vxi && vxi->dmap.targets[index].flags) {
21720 + vdmt = &vxi->dmap.targets[index];
21721 + } else if (global) {
21723 + vdmt = &global->target;
21727 + vdmt = &dmap_defaults[index];
21731 + if (target && (vdmt->flags & DATTR_REMAP))
21732 + *target = vdmt->target;
21734 + *target = device;
21736 + *flags = vdmt->flags;
21738 + spin_unlock(hash_lock);
21744 +/* __remove_mapping()
21745 + * remove a mapping from the hash table
21747 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
21750 + spinlock_t *hash_lock = &dmap_main_hash_lock;
21751 + struct vs_mapping *vdm = NULL;
21754 + spin_lock(hash_lock);
21756 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
21758 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
21759 + vxi, vxi ? vxi->vx_id : 0, device, mode);
21762 + hlist_del(&vdm->dm_hlist);
21765 + spin_unlock(hash_lock);
21767 + kmem_cache_free(dmap_cachep, vdm);
21773 +int vs_map_device(struct vx_info *vxi,
21774 + dev_t device, dev_t *target, umode_t mode)
21776 + int ret, flags = DATTR_MASK;
21780 + *target = device;
21783 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
21784 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
21785 + device, target ? *target : 0, flags, mode, ret);
21787 + return (flags & DATTR_MASK);
21792 +static int do_set_mapping(struct vx_info *vxi,
21793 + dev_t device, dev_t target, int flags, umode_t mode)
21796 + struct vs_mapping *new;
21798 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
21802 + INIT_HLIST_NODE(&new->dm_hlist);
21803 + new->device = device;
21804 + new->target.target = target;
21805 + new->target.flags = flags | mode;
21806 + new->xid = (vxi ? vxi->vx_id : 0);
21808 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
21809 + __hash_mapping(vxi, new);
21811 + struct vx_dmap_target new = {
21812 + .target = target,
21813 + .flags = flags | mode,
21815 + __set_default(vxi, mode, &new);
21821 +static int do_unset_mapping(struct vx_info *vxi,
21822 + dev_t device, dev_t target, int flags, umode_t mode)
21824 + int ret = -EINVAL;
21827 + ret = __remove_mapping(vxi, device, mode);
21831 + ret = __remove_default(vxi, mode);
21841 +static inline int __user_device(const char __user *name, dev_t *dev,
21844 + struct nameidata nd;
21851 + ret = user_path_walk_link(name, &nd);
21854 + if (nd.dentry->d_inode) {
21855 + *dev = nd.dentry->d_inode->i_rdev;
21856 + *mode = nd.dentry->d_inode->i_mode;
21858 + path_release(&nd);
21862 +static inline int __mapping_mode(dev_t device, dev_t target,
21863 + umode_t device_mode, umode_t target_mode, umode_t *mode)
21866 + *mode = device_mode & S_IFMT;
21868 + *mode = target_mode & S_IFMT;
21872 + /* if both given, device and target mode have to match */
21873 + if (device && target &&
21874 + ((device_mode ^ target_mode) & S_IFMT))
21880 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
21881 + const char __user *target_path, int flags, int set)
21883 + dev_t device = ~0, target = ~0;
21884 + umode_t device_mode = 0, target_mode = 0, mode;
21887 + ret = __user_device(device_path, &device, &device_mode);
21890 + ret = __user_device(target_path, &target, &target_mode);
21894 + ret = __mapping_mode(device, target,
21895 + device_mode, target_mode, &mode);
21900 + return do_set_mapping(vxi, device, target,
21903 + return do_unset_mapping(vxi, device, target,
21908 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
21910 + struct vcmd_set_mapping_v0 vc_data;
21912 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21915 + return do_mapping(vxi, vc_data.device, vc_data.target,
21916 + vc_data.flags, 1);
21919 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
21921 + struct vcmd_set_mapping_v0 vc_data;
21923 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21926 + return do_mapping(vxi, vc_data.device, vc_data.target,
21927 + vc_data.flags, 0);
21931 +#ifdef CONFIG_COMPAT
21933 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
21935 + struct vcmd_set_mapping_v0_x32 vc_data;
21937 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21940 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
21941 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
21944 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
21946 + struct vcmd_set_mapping_v0_x32 vc_data;
21948 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21951 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
21952 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
21955 +#endif /* CONFIG_COMPAT */
21958 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
21959 --- linux-2.6.22.10/kernel/vserver/dlimit.c 1970-01-01 01:00:00 +0100
21960 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/dlimit.c 2007-08-15 22:07:58 +0200
21963 + * linux/kernel/vserver/dlimit.c
21965 + * Virtual Server: Context Disk Limits
21967 + * Copyright (C) 2004-2007 Herbert Pötzl
21969 + * V0.01 initial version
21970 + * V0.02 compat32 splitup
21974 +#include <linux/statfs.h>
21975 +#include <linux/vs_tag.h>
21976 +#include <linux/vs_dlimit.h>
21977 +#include <linux/vserver/dlimit_cmd.h>
21979 +#include <asm/uaccess.h>
21981 +/* __alloc_dl_info()
21983 + * allocate an initialized dl_info struct
21984 + * doesn't make it visible (hash) */
21986 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
21988 + struct dl_info *new = NULL;
21990 + vxdprintk(VXD_CBIT(dlim, 5),
21991 + "alloc_dl_info(%p,%d)*", sb, tag);
21993 + /* would this benefit from a slab cache? */
21994 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
21998 + memset(new, 0, sizeof(struct dl_info));
21999 + new->dl_tag = tag;
22001 + INIT_RCU_HEAD(&new->dl_rcu);
22002 + INIT_HLIST_NODE(&new->dl_hlist);
22003 + spin_lock_init(&new->dl_lock);
22004 + atomic_set(&new->dl_refcnt, 0);
22005 + atomic_set(&new->dl_usecnt, 0);
22007 + /* rest of init goes here */
22009 + vxdprintk(VXD_CBIT(dlim, 4),
22010 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
22014 +/* __dealloc_dl_info()
22016 + * final disposal of dl_info */
22018 +static void __dealloc_dl_info(struct dl_info *dli)
22020 + vxdprintk(VXD_CBIT(dlim, 4),
22021 + "dealloc_dl_info(%p)", dli);
22023 + dli->dl_hlist.next = LIST_POISON1;
22024 + dli->dl_tag = -1;
22027 + BUG_ON(atomic_read(&dli->dl_usecnt));
22028 + BUG_ON(atomic_read(&dli->dl_refcnt));
22034 +/* hash table for dl_info hash */
22036 +#define DL_HASH_SIZE 13
22038 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
22040 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
22043 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
22045 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
22050 +/* __hash_dl_info()
22052 + * add the dli to the global hash table
22053 + * requires the hash_lock to be held */
22055 +static inline void __hash_dl_info(struct dl_info *dli)
22057 + struct hlist_head *head;
22059 + vxdprintk(VXD_CBIT(dlim, 6),
22060 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
22061 + get_dl_info(dli);
22062 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
22063 + hlist_add_head_rcu(&dli->dl_hlist, head);
22066 +/* __unhash_dl_info()
22068 + * remove the dli from the global hash table
22069 + * requires the hash_lock to be held */
22071 +static inline void __unhash_dl_info(struct dl_info *dli)
22073 + vxdprintk(VXD_CBIT(dlim, 6),
22074 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
22075 + hlist_del_rcu(&dli->dl_hlist);
22076 + put_dl_info(dli);
22080 +/* __lookup_dl_info()
22082 + * requires the rcu_read_lock()
22083 + * doesn't increment the dl_refcnt */
22085 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
22087 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
22088 + struct hlist_node *pos;
22089 + struct dl_info *dli;
22091 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
22093 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
22101 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
22103 + struct dl_info *dli;
22106 + dli = get_dl_info(__lookup_dl_info(sb, tag));
22107 + vxdprintk(VXD_CBIT(dlim, 7),
22108 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
22109 + rcu_read_unlock();
22113 +void rcu_free_dl_info(struct rcu_head *head)
22115 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
22116 + int usecnt, refcnt;
22118 + BUG_ON(!dli || !head);
22120 + usecnt = atomic_read(&dli->dl_usecnt);
22121 + BUG_ON(usecnt < 0);
22123 + refcnt = atomic_read(&dli->dl_refcnt);
22124 + BUG_ON(refcnt < 0);
22126 + vxdprintk(VXD_CBIT(dlim, 3),
22127 + "rcu_free_dl_info(%p)", dli);
22129 + __dealloc_dl_info(dli);
22131 + printk("!!! rcu didn't free\n");
22137 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
22138 + uint32_t flags, int add)
22140 + struct nameidata nd;
22143 + ret = user_path_walk_link(name, &nd);
22145 + struct super_block *sb;
22146 + struct dl_info *dli;
22149 + if (!nd.dentry->d_inode)
22150 + goto out_release;
22151 + if (!(sb = nd.dentry->d_inode->i_sb))
22152 + goto out_release;
22155 + dli = __alloc_dl_info(sb, id);
22156 + spin_lock(&dl_info_hash_lock);
22159 + if (__lookup_dl_info(sb, id))
22161 + __hash_dl_info(dli);
22164 + spin_lock(&dl_info_hash_lock);
22165 + dli = __lookup_dl_info(sb, id);
22170 + __unhash_dl_info(dli);
22174 + spin_unlock(&dl_info_hash_lock);
22176 + __dealloc_dl_info(dli);
22178 + path_release(&nd);
22183 +int vc_add_dlimit(uint32_t id, void __user *data)
22185 + struct vcmd_ctx_dlimit_base_v0 vc_data;
22187 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22190 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
22193 +int vc_rem_dlimit(uint32_t id, void __user *data)
22195 + struct vcmd_ctx_dlimit_base_v0 vc_data;
22197 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22200 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
22203 +#ifdef CONFIG_COMPAT
22205 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
22207 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
22209 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22212 + return do_addrem_dlimit(id,
22213 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
22216 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
22218 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
22220 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22223 + return do_addrem_dlimit(id,
22224 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
22227 +#endif /* CONFIG_COMPAT */
22231 +int do_set_dlimit(uint32_t id, const char __user *name,
22232 + uint32_t space_used, uint32_t space_total,
22233 + uint32_t inodes_used, uint32_t inodes_total,
22234 + uint32_t reserved, uint32_t flags)
22236 + struct nameidata nd;
22239 + ret = user_path_walk_link(name, &nd);
22241 + struct super_block *sb;
22242 + struct dl_info *dli;
22245 + if (!nd.dentry->d_inode)
22246 + goto out_release;
22247 + if (!(sb = nd.dentry->d_inode->i_sb))
22248 + goto out_release;
22249 + if ((reserved != CDLIM_KEEP &&
22250 + reserved > 100) ||
22251 + (inodes_used != CDLIM_KEEP &&
22252 + inodes_used > inodes_total) ||
22253 + (space_used != CDLIM_KEEP &&
22254 + space_used > space_total))
22255 + goto out_release;
22258 + dli = locate_dl_info(sb, id);
22260 + goto out_release;
22262 + spin_lock(&dli->dl_lock);
22264 + if (inodes_used != CDLIM_KEEP)
22265 + dli->dl_inodes_used = inodes_used;
22266 + if (inodes_total != CDLIM_KEEP)
22267 + dli->dl_inodes_total = inodes_total;
22268 + if (space_used != CDLIM_KEEP) {
22269 + dli->dl_space_used = space_used;
22270 + dli->dl_space_used <<= 10;
22272 + if (space_total == CDLIM_INFINITY)
22273 + dli->dl_space_total = DLIM_INFINITY;
22274 + else if (space_total != CDLIM_KEEP) {
22275 + dli->dl_space_total = space_total;
22276 + dli->dl_space_total <<= 10;
22278 + if (reserved != CDLIM_KEEP)
22279 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
22281 + spin_unlock(&dli->dl_lock);
22283 + put_dl_info(dli);
22287 + path_release(&nd);
22292 +int vc_set_dlimit(uint32_t id, void __user *data)
22294 + struct vcmd_ctx_dlimit_v0 vc_data;
22296 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22299 + return do_set_dlimit(id, vc_data.name,
22300 + vc_data.space_used, vc_data.space_total,
22301 + vc_data.inodes_used, vc_data.inodes_total,
22302 + vc_data.reserved, vc_data.flags);
22305 +#ifdef CONFIG_COMPAT
22307 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
22309 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
22311 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22314 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
22315 + vc_data.space_used, vc_data.space_total,
22316 + vc_data.inodes_used, vc_data.inodes_total,
22317 + vc_data.reserved, vc_data.flags);
22320 +#endif /* CONFIG_COMPAT */
22324 +int do_get_dlimit(uint32_t id, const char __user *name,
22325 + uint32_t *space_used, uint32_t *space_total,
22326 + uint32_t *inodes_used, uint32_t *inodes_total,
22327 + uint32_t *reserved, uint32_t *flags)
22329 + struct nameidata nd;
22332 + ret = user_path_walk_link(name, &nd);
22334 + struct super_block *sb;
22335 + struct dl_info *dli;
22338 + if (!nd.dentry->d_inode)
22339 + goto out_release;
22340 + if (!(sb = nd.dentry->d_inode->i_sb))
22341 + goto out_release;
22344 + dli = locate_dl_info(sb, id);
22346 + goto out_release;
22348 + spin_lock(&dli->dl_lock);
22349 + *inodes_used = dli->dl_inodes_used;
22350 + *inodes_total = dli->dl_inodes_total;
22351 + *space_used = dli->dl_space_used >> 10;
22352 + if (dli->dl_space_total == DLIM_INFINITY)
22353 + *space_total = CDLIM_INFINITY;
22355 + *space_total = dli->dl_space_total >> 10;
22357 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
22358 + spin_unlock(&dli->dl_lock);
22360 + put_dl_info(dli);
22365 + path_release(&nd);
22371 +int vc_get_dlimit(uint32_t id, void __user *data)
22373 + struct vcmd_ctx_dlimit_v0 vc_data;
22376 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22379 + ret = do_get_dlimit(id, vc_data.name,
22380 + &vc_data.space_used, &vc_data.space_total,
22381 + &vc_data.inodes_used, &vc_data.inodes_total,
22382 + &vc_data.reserved, &vc_data.flags);
22386 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22391 +#ifdef CONFIG_COMPAT
22393 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
22395 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
22398 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22401 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
22402 + &vc_data.space_used, &vc_data.space_total,
22403 + &vc_data.inodes_used, &vc_data.inodes_total,
22404 + &vc_data.reserved, &vc_data.flags);
22408 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22413 +#endif /* CONFIG_COMPAT */
22416 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
22418 + struct dl_info *dli;
22419 + __u64 blimit, bfree, bavail;
22422 + dli = locate_dl_info(sb, dx_current_tag());
22426 + spin_lock(&dli->dl_lock);
22427 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
22430 + /* reduce max inodes available to limit */
22431 + if (buf->f_files > dli->dl_inodes_total)
22432 + buf->f_files = dli->dl_inodes_total;
22434 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
22435 + /* reduce free inodes to min */
22436 + if (ifree < buf->f_ffree)
22437 + buf->f_ffree = ifree;
22440 + if (dli->dl_space_total == DLIM_INFINITY)
22443 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
22445 + if (dli->dl_space_total < dli->dl_space_used)
22448 + bfree = (dli->dl_space_total - dli->dl_space_used)
22449 + >> sb->s_blocksize_bits;
22451 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
22452 + if (bavail < dli->dl_space_used)
22455 + bavail = (bavail - dli->dl_space_used)
22456 + >> sb->s_blocksize_bits;
22458 + /* reduce max space available to limit */
22459 + if (buf->f_blocks > blimit)
22460 + buf->f_blocks = blimit;
22462 + /* reduce free space to min */
22463 + if (bfree < buf->f_bfree)
22464 + buf->f_bfree = bfree;
22466 + /* reduce avail space to min */
22467 + if (bavail < buf->f_bavail)
22468 + buf->f_bavail = bavail;
22471 + spin_unlock(&dli->dl_lock);
22472 + put_dl_info(dli);
22477 +#include <linux/module.h>
22479 +EXPORT_SYMBOL_GPL(locate_dl_info);
22480 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
22482 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
22483 --- linux-2.6.22.10/kernel/vserver/helper.c 1970-01-01 01:00:00 +0100
22484 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/helper.c 2007-08-15 22:12:01 +0200
22487 + * linux/kernel/vserver/helper.c
22489 + * Virtual Context Support
22491 + * Copyright (C) 2004-2007 Herbert Pötzl
22493 + * V0.01 basic helper
22497 +#include <linux/kmod.h>
22498 +#include <linux/reboot.h>
22499 +#include <linux/vs_context.h>
22500 +#include <linux/vs_network.h>
22501 +#include <linux/vserver/signal.h>
22504 +char vshelper_path[255] = "/sbin/vshelper";
22507 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
22511 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
22512 + printk( KERN_WARNING
22513 + "%s: (%s %s) returned %s with %d\n",
22514 + name, argv[1], argv[2],
22515 + sync ? "sync" : "async", ret);
22517 + vxdprintk(VXD_CBIT(switch, 4),
22518 + "%s: (%s %s) returned %s with %d",
22519 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
22524 + * vshelper path is set via /proc/sys
22525 + * invoked by vserver sys_reboot(), with
22526 + * the following arguments
22528 + * argv [0] = vshelper_path;
22529 + * argv [1] = action: "restart", "halt", "poweroff", ...
22530 + * argv [2] = context identifier
22532 + * envp [*] = type-specific parameters
22535 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
22537 + char id_buf[8], cmd_buf[16];
22538 + char uid_buf[16], pid_buf[16];
22541 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22542 + char *envp[] = {"HOME=/", "TERM=linux",
22543 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
22544 + uid_buf, pid_buf, cmd_buf, 0};
22546 + if (vx_info_state(vxi, VXS_HELPER))
22548 + vxi->vx_state |= VXS_HELPER;
22550 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
22552 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22553 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
22554 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
22557 + case LINUX_REBOOT_CMD_RESTART:
22558 + argv[1] = "restart";
22561 + case LINUX_REBOOT_CMD_HALT:
22562 + argv[1] = "halt";
22565 + case LINUX_REBOOT_CMD_POWER_OFF:
22566 + argv[1] = "poweroff";
22569 + case LINUX_REBOOT_CMD_SW_SUSPEND:
22570 + argv[1] = "swsusp";
22574 + vxi->vx_state &= ~VXS_HELPER;
22578 + ret = do_vshelper(vshelper_path, argv, envp, 0);
22579 + vxi->vx_state &= ~VXS_HELPER;
22580 + __wakeup_vx_info(vxi);
22581 + return (ret) ? -EPERM : 0;
22585 +long vs_reboot(unsigned int cmd, void __user *arg)
22587 + struct vx_info *vxi = current->vx_info;
22590 + vxdprintk(VXD_CBIT(misc, 5),
22591 + "vs_reboot(%p[#%d],%d)",
22592 + vxi, vxi ? vxi->vx_id : 0, cmd);
22594 + ret = vs_reboot_helper(vxi, cmd, arg);
22598 + vxi->reboot_cmd = cmd;
22599 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
22601 + case LINUX_REBOOT_CMD_RESTART:
22602 + case LINUX_REBOOT_CMD_HALT:
22603 + case LINUX_REBOOT_CMD_POWER_OFF:
22604 + vx_info_kill(vxi, 0, SIGKILL);
22605 + vx_info_kill(vxi, 1, SIGKILL);
22615 + * argv [0] = vshelper_path;
22616 + * argv [1] = action: "startup", "shutdown"
22617 + * argv [2] = context identifier
22619 + * envp [*] = type-specific parameters
22622 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
22624 + char id_buf[8], cmd_buf[16];
22625 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22626 + char *envp[] = {"HOME=/", "TERM=linux",
22627 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
22629 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
22632 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
22633 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22636 + case VSC_STARTUP:
22637 + argv[1] = "startup";
22639 + case VSC_SHUTDOWN:
22640 + argv[1] = "shutdown";
22646 + return do_vshelper(vshelper_path, argv, envp, 1);
22651 + * argv [0] = vshelper_path;
22652 + * argv [1] = action: "netup", "netdown"
22653 + * argv [2] = context identifier
22655 + * envp [*] = type-specific parameters
22658 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
22660 + char id_buf[8], cmd_buf[16];
22661 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
22662 + char *envp[] = {"HOME=/", "TERM=linux",
22663 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
22665 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
22668 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
22669 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
22673 + argv[1] = "netup";
22675 + case VSC_NETDOWN:
22676 + argv[1] = "netdown";
22682 + return do_vshelper(vshelper_path, argv, envp, 1);
22685 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
22686 --- linux-2.6.22.10/kernel/vserver/history.c 1970-01-01 01:00:00 +0100
22687 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/history.c 2007-08-15 22:13:54 +0200
22690 + * kernel/vserver/history.c
22692 + * Virtual Context History Backtrace
22694 + * Copyright (C) 2004-2007 Herbert Pötzl
22696 + * V0.01 basic structure
22697 + * V0.02 hash/unhash and trace
22698 + * V0.03 preemption fixes
22702 +#include <linux/module.h>
22703 +#include <asm/uaccess.h>
22705 +#include <linux/vserver/context.h>
22706 +#include <linux/vserver/debug.h>
22707 +#include <linux/vserver/debug_cmd.h>
22708 +#include <linux/vserver/history.h>
22711 +#ifdef CONFIG_VSERVER_HISTORY
22712 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
22714 +#define VXH_SIZE 64
22717 +struct _vx_history {
22718 + unsigned int counter;
22720 + struct _vx_hist_entry entry[VXH_SIZE + 1];
22724 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
22726 +unsigned volatile int vxh_active = 1;
22728 +static atomic_t sequence = ATOMIC_INIT(0);
22733 + * requires disabled preemption */
22735 +struct _vx_hist_entry *vxh_advance(void *loc)
22737 + unsigned int cpu = smp_processor_id();
22738 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
22739 + struct _vx_hist_entry *entry;
22740 + unsigned int index;
22742 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
22743 + entry = &hist->entry[index];
22745 + entry->seq = atomic_inc_return(&sequence);
22746 + entry->loc = loc;
22750 +EXPORT_SYMBOL_GPL(vxh_advance);
22753 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
22755 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
22758 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
22760 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
22761 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
22762 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
22763 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
22765 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
22767 + switch (e->type) {
22768 + case VXH_THROW_OOPS:
22769 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
22772 + case VXH_GET_VX_INFO:
22773 + case VXH_PUT_VX_INFO:
22774 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
22776 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
22777 + VXH_VXI_ARGS(e));
22780 + case VXH_INIT_VX_INFO:
22781 + case VXH_SET_VX_INFO:
22782 + case VXH_CLR_VX_INFO:
22783 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
22785 + (e->type == VXH_INIT_VX_INFO) ? "init" :
22786 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
22787 + VXH_VXI_ARGS(e), e->sc.data);
22790 + case VXH_CLAIM_VX_INFO:
22791 + case VXH_RELEASE_VX_INFO:
22792 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
22794 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
22795 + VXH_VXI_ARGS(e), e->sc.data);
22798 + case VXH_ALLOC_VX_INFO:
22799 + case VXH_DEALLOC_VX_INFO:
22800 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
22802 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
22803 + VXH_VXI_ARGS(e));
22806 + case VXH_HASH_VX_INFO:
22807 + case VXH_UNHASH_VX_INFO:
22808 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
22810 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
22811 + VXH_VXI_ARGS(e));
22814 + case VXH_LOC_VX_INFO:
22815 + case VXH_LOOKUP_VX_INFO:
22816 + case VXH_CREATE_VX_INFO:
22817 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
22819 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
22820 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
22821 + e->ll.arg, VXH_VXI_ARGS(e));
22826 +static void __vxh_dump_history(void)
22828 + unsigned int i, cpu;
22830 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
22831 + atomic_read(&sequence), NR_CPUS);
22833 + for (i = 0; i < VXH_SIZE; i++) {
22834 + for_each_online_cpu(cpu) {
22835 + struct _vx_history *hist =
22836 + &per_cpu(vx_history_buffer, cpu);
22837 + unsigned int index = (hist->counter - i) % VXH_SIZE;
22838 + struct _vx_hist_entry *entry = &hist->entry[index];
22840 + vxh_dump_entry(entry, cpu);
22845 +void vxh_dump_history(void)
22849 + local_irq_enable();
22851 + local_irq_disable();
22853 + __vxh_dump_history();
22857 +/* vserver syscall commands below here */
22860 +int vc_dump_history(uint32_t id)
22863 + __vxh_dump_history();
22870 +int do_read_history(struct __user _vx_hist_entry *data,
22871 + int cpu, uint32_t *index, uint32_t *count)
22873 + int pos, ret = 0;
22874 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
22875 + int end = hist->counter;
22876 + int start = end - VXH_SIZE + 2;
22877 + int idx = *index;
22879 + /* special case: get current pos */
22885 + /* have we lost some data? */
22889 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22890 + struct _vx_hist_entry *entry =
22891 + &hist->entry[idx % VXH_SIZE];
22893 + /* send entry to userspace */
22894 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22898 + /* save new index and count */
22901 + return ret ? ret : (*index < end);
22904 +int vc_read_history(uint32_t id, void __user *data)
22906 + struct vcmd_read_history_v0 vc_data;
22909 + if (id >= NR_CPUS)
22912 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22915 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
22916 + id, &vc_data.index, &vc_data.count);
22918 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22923 +#ifdef CONFIG_COMPAT
22925 +int vc_read_history_x32(uint32_t id, void __user *data)
22927 + struct vcmd_read_history_v0_x32 vc_data;
22930 + if (id >= NR_CPUS)
22933 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22936 + ret = do_read_history((struct __user _vx_hist_entry *)
22937 + compat_ptr(vc_data.data_ptr),
22938 + id, &vc_data.index, &vc_data.count);
22940 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22945 +#endif /* CONFIG_COMPAT */
22947 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
22948 --- linux-2.6.22.10/kernel/vserver/inet.c 1970-01-01 01:00:00 +0100
22949 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/inet.c 2007-10-10 23:55:30 +0200
22952 +#include <linux/in.h>
22953 +#include <linux/inetdevice.h>
22954 +#include <linux/vs_inet6.h>
22955 +#include <linux/vserver/debug.h>
22956 +#include <net/route.h>
22957 +#include <net/addrconf.h>
22960 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
22964 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
22967 + struct nx_addr_v4 *ptr;
22969 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
22970 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
22977 + vxdprintk(VXD_CBIT(net, 2),
22978 + "nx_v4_addr_conflict(%p,%p): %d",
22979 + nxi1, nxi2, ret);
22985 +#ifdef CONFIG_IPV6
22987 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
22991 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
22994 + struct nx_addr_v6 *ptr;
22996 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
22997 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
23004 + vxdprintk(VXD_CBIT(net, 2),
23005 + "nx_v6_addr_conflict(%p,%p): %d",
23006 + nxi1, nxi2, ret);
23013 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
23015 + struct in_device *in_dev;
23016 + struct in_ifaddr **ifap;
23017 + struct in_ifaddr *ifa;
23022 + in_dev = in_dev_get(dev);
23026 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
23027 + ifap = &ifa->ifa_next) {
23028 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
23033 + in_dev_put(in_dev);
23039 +#ifdef CONFIG_IPV6
23041 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
23043 + struct inet6_dev *in_dev;
23044 + struct inet6_ifaddr **ifap;
23045 + struct inet6_ifaddr *ifa;
23050 + in_dev = in6_dev_get(dev);
23054 + for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
23055 + ifap = &ifa->if_next) {
23056 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
23061 + in6_dev_put(in_dev);
23068 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
23074 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
23076 +#ifdef CONFIG_IPV6
23078 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
23083 + vxdprintk(VXD_CBIT(net, 3),
23084 + "dev_in_nx_info(%p,%p[#%d]) = %d",
23085 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
23089 +int ip_v4_find_src(struct nx_info *nxi, struct rtable **rp, struct flowi *fl)
23094 + /* FIXME: handle lback only case */
23095 + if (!NX_IPV4(nxi))
23098 + vxdprintk(VXD_CBIT(net, 4),
23099 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
23100 + nxi, nxi ? nxi->nx_id : 0,
23101 + NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
23103 + /* single IP is unconditional */
23104 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
23105 + (fl->fl4_src == INADDR_ANY))
23106 + fl->fl4_src = nxi->v4.ip[0].s_addr;
23108 + if (fl->fl4_src == INADDR_ANY) {
23109 + struct nx_addr_v4 *ptr;
23113 + err = __ip_route_output_key(rp, fl);
23115 + found = (*rp)->rt_src;
23117 + vxdprintk(VXD_CBIT(net, 4),
23118 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
23119 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
23120 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
23124 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
23125 + __be32 primary = ptr->ip[0].s_addr;
23126 + __be32 mask = ptr->mask.s_addr;
23127 + __be32 net = primary & mask;
23129 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
23130 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
23131 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
23132 + NIPQUAD(mask), NIPQUAD(net));
23133 + if ((found & mask) != net)
23136 + fl->fl4_src = primary;
23137 + err = __ip_route_output_key(rp, fl);
23138 + vxdprintk(VXD_CBIT(net, 4),
23139 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
23140 + nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
23142 + found = (*rp)->rt_src;
23144 + if (found == primary)
23148 + /* still no source ip? */
23149 + found = LOOPBACK(fl->fl4_dst)
23150 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
23152 + /* assign src ip to flow */
23153 + fl->fl4_src = found;
23156 + if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
23160 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
23161 + if (LOOPBACK(fl->fl4_dst))
23162 + fl->fl4_dst = nxi->v4_lback.s_addr;
23163 + if (LOOPBACK(fl->fl4_src))
23164 + fl->fl4_src = nxi->v4_lback.s_addr;
23165 + } else if (LOOPBACK(fl->fl4_dst))
23171 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
23173 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
23174 --- linux-2.6.22.10/kernel/vserver/init.c 1970-01-01 01:00:00 +0100
23175 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/init.c 2007-08-15 22:15:36 +0200
23178 + * linux/kernel/init.c
23180 + * Virtual Server Init
23182 + * Copyright (C) 2004-2007 Herbert Pötzl
23184 + * V0.01 basic structure
23188 +#include <linux/init.h>
23190 +int vserver_register_sysctl(void);
23191 +void vserver_unregister_sysctl(void);
23194 +static int __init init_vserver(void)
23198 +#ifdef CONFIG_VSERVER_DEBUG
23199 + vserver_register_sysctl();
23205 +static void __exit exit_vserver(void)
23208 +#ifdef CONFIG_VSERVER_DEBUG
23209 + vserver_unregister_sysctl();
23214 +/* FIXME: GFP_ZONETYPES gone
23215 +long vx_slab[GFP_ZONETYPES]; */
23219 +module_init(init_vserver);
23220 +module_exit(exit_vserver);
23222 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
23223 --- linux-2.6.22.10/kernel/vserver/inode.c 1970-01-01 01:00:00 +0100
23224 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/inode.c 2007-09-11 17:57:41 +0200
23227 + * linux/kernel/vserver/inode.c
23229 + * Virtual Server: File System Support
23231 + * Copyright (C) 2004-2007 Herbert Pötzl
23233 + * V0.01 separated from vcontext V0.05
23234 + * V0.02 moved to tag (instead of xid)
23238 +#include <linux/tty.h>
23239 +#include <linux/proc_fs.h>
23240 +#include <linux/devpts_fs.h>
23241 +#include <linux/fs.h>
23242 +#include <linux/file.h>
23243 +#include <linux/mount.h>
23244 +#include <linux/parser.h>
23245 +#include <linux/vserver/inode.h>
23246 +#include <linux/vserver/inode_cmd.h>
23247 +#include <linux/vs_base.h>
23248 +#include <linux/vs_tag.h>
23250 +#include <asm/uaccess.h>
23253 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
23255 + struct proc_dir_entry *entry;
23257 + if (!in || !in->i_sb)
23260 + *flags = IATTR_TAG
23261 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
23262 + | (IS_IUNLINK(in) ? IATTR_IUNLINK : 0)
23263 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
23264 + *mask = IATTR_IUNLINK | IATTR_IMMUTABLE;
23266 + if (S_ISDIR(in->i_mode))
23267 + *mask |= IATTR_BARRIER;
23269 + if (IS_TAGGED(in)) {
23270 + *tag = in->i_tag;
23271 + *mask |= IATTR_TAG;
23274 + switch (in->i_sb->s_magic) {
23275 + case PROC_SUPER_MAGIC:
23276 + entry = PROC_I(in)->pde;
23278 + /* check for specific inodes? */
23280 + *mask |= IATTR_FLAGS;
23282 + *flags |= (entry->vx_flags & IATTR_FLAGS);
23284 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
23287 + case DEVPTS_SUPER_MAGIC:
23288 + *tag = in->i_tag;
23289 + *mask |= IATTR_TAG;
23298 +int vc_get_iattr(void __user *data)
23300 + struct nameidata nd;
23301 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
23304 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23307 + ret = user_path_walk_link(vc_data.name, &nd);
23309 + ret = __vc_get_iattr(nd.dentry->d_inode,
23310 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23311 + path_release(&nd);
23316 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23321 +#ifdef CONFIG_COMPAT
23323 +int vc_get_iattr_x32(void __user *data)
23325 + struct nameidata nd;
23326 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
23329 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23332 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
23334 + ret = __vc_get_iattr(nd.dentry->d_inode,
23335 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23336 + path_release(&nd);
23341 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23346 +#endif /* CONFIG_COMPAT */
23349 +int vc_fget_iattr(uint32_t fd, void __user *data)
23351 + struct file *filp;
23352 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
23355 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23359 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
23362 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
23363 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23367 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23373 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
23375 + struct inode *in = de->d_inode;
23376 + int error = 0, is_proc = 0, has_tag = 0;
23377 + struct iattr attr = { 0 };
23379 + if (!in || !in->i_sb)
23382 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
23383 + if ((*mask & IATTR_FLAGS) && !is_proc)
23386 + has_tag = IS_TAGGED(in) ||
23387 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
23388 + if ((*mask & IATTR_TAG) && !has_tag)
23391 + mutex_lock(&in->i_mutex);
23392 + if (*mask & IATTR_TAG) {
23393 + attr.ia_tag = *tag;
23394 + attr.ia_valid |= ATTR_TAG;
23397 + if (*mask & IATTR_FLAGS) {
23398 + struct proc_dir_entry *entry = PROC_I(in)->pde;
23399 + unsigned int iflags = PROC_I(in)->vx_flags;
23401 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
23402 + | (*flags & IATTR_FLAGS);
23403 + PROC_I(in)->vx_flags = iflags;
23405 + entry->vx_flags = iflags;
23408 + if (*mask & (IATTR_BARRIER | IATTR_IUNLINK | IATTR_IMMUTABLE)) {
23409 + if (*mask & IATTR_IMMUTABLE) {
23410 + if (*flags & IATTR_IMMUTABLE)
23411 + in->i_flags |= S_IMMUTABLE;
23413 + in->i_flags &= ~S_IMMUTABLE;
23415 + if (*mask & IATTR_IUNLINK) {
23416 + if (*flags & IATTR_IUNLINK)
23417 + in->i_flags |= S_IUNLINK;
23419 + in->i_flags &= ~S_IUNLINK;
23421 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
23422 + if (*flags & IATTR_BARRIER)
23423 + in->i_flags |= S_BARRIER;
23425 + in->i_flags &= ~S_BARRIER;
23427 + if (in->i_op && in->i_op->sync_flags) {
23428 + error = in->i_op->sync_flags(in);
23434 + if (attr.ia_valid) {
23435 + if (in->i_op && in->i_op->setattr)
23436 + error = in->i_op->setattr(de, &attr);
23438 + error = inode_change_ok(in, &attr);
23440 + error = inode_setattr(in, &attr);
23445 + mutex_unlock(&in->i_mutex);
23449 +int vc_set_iattr(void __user *data)
23451 + struct nameidata nd;
23452 + struct vcmd_ctx_iattr_v1 vc_data;
23455 + if (!capable(CAP_LINUX_IMMUTABLE))
23457 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23460 + ret = user_path_walk_link(vc_data.name, &nd);
23462 + ret = __vc_set_iattr(nd.dentry,
23463 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23464 + path_release(&nd);
23467 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23472 +#ifdef CONFIG_COMPAT
23474 +int vc_set_iattr_x32(void __user *data)
23476 + struct nameidata nd;
23477 + struct vcmd_ctx_iattr_v1_x32 vc_data;
23480 + if (!capable(CAP_LINUX_IMMUTABLE))
23482 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23485 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
23487 + ret = __vc_set_iattr(nd.dentry,
23488 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
23489 + path_release(&nd);
23492 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23497 +#endif /* CONFIG_COMPAT */
23499 +int vc_fset_iattr(uint32_t fd, void __user *data)
23501 + struct file *filp;
23502 + struct vcmd_ctx_fiattr_v0 vc_data;
23505 + if (!capable(CAP_LINUX_IMMUTABLE))
23507 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23511 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
23514 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
23515 + &vc_data.flags, &vc_data.mask);
23519 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23525 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
23527 +static match_table_t tokens = {
23528 + {Opt_notagcheck, "notagcheck"},
23529 +#ifdef CONFIG_PROPAGATE
23530 + {Opt_notag, "notag"},
23531 + {Opt_tag, "tag"},
23532 + {Opt_tagid, "tagid=%u"},
23538 +static void __dx_parse_remove(char *string, char *opt)
23540 + char *p = strstr(string, opt);
23544 + while (*q != '\0' && *q != ',')
23554 +int __dx_parse_tag(char *string, tag_t *tag, int remove)
23556 + substring_t args[MAX_OPT_ARGS];
23557 + int token, option = 0;
23562 + token = match_token(string, tokens, args);
23564 + vxdprintk(VXD_CBIT(tag, 7),
23565 + "dx_parse_tag(»%s«): %d:#%d",
23566 + string, token, option);
23573 + __dx_parse_remove(string, "tag");
23574 + return MNT_TAGID;
23577 + __dx_parse_remove(string, "notag");
23578 + return MNT_NOTAG;
23579 + case Opt_notagcheck:
23581 + __dx_parse_remove(string, "notagcheck");
23582 + return MNT_NOTAGCHECK;
23584 + if (tag && !match_int(args, &option))
23587 + __dx_parse_remove(string, "tagid");
23588 + return MNT_TAGID;
23593 +int dx_parse_tag(char *string, tag_t *tag, int remove)
23595 + int retval, flags = 0;
23597 + while ((retval = __dx_parse_tag(string, tag, remove)))
23602 +#ifdef CONFIG_PROPAGATE
23604 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
23606 + tag_t new_tag = 0;
23607 + struct vfsmount *mnt;
23616 + propagate = (mnt->mnt_flags & MNT_TAGID);
23618 + new_tag = mnt->mnt_tag;
23620 + vxdprintk(VXD_CBIT(tag, 7),
23621 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
23622 + inode, inode->i_ino, inode->i_tag,
23623 + new_tag, (propagate) ? 1 : 0);
23626 + inode->i_tag = new_tag;
23629 +#include <linux/module.h>
23631 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
23633 +#endif /* CONFIG_PROPAGATE */
23635 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
23636 --- linux-2.6.22.10/kernel/vserver/limit.c 1970-01-01 01:00:00 +0100
23637 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit.c 2007-08-19 00:08:19 +0200
23640 + * linux/kernel/vserver/limit.c
23642 + * Virtual Server: Context Limits
23644 + * Copyright (C) 2004-2007 Herbert Pötzl
23646 + * V0.01 broken out from vcontext V0.05
23647 + * V0.02 changed vcmds to vxi arg
23651 +#include <linux/module.h>
23652 +#include <linux/vs_limit.h>
23653 +#include <linux/vserver/limit.h>
23654 +#include <linux/vserver/limit_cmd.h>
23656 +#include <asm/uaccess.h>
23659 +const char *vlimit_name[NUM_LIMITS] = {
23660 + [RLIMIT_CPU] = "CPU",
23661 + [RLIMIT_RSS] = "RSS",
23662 + [RLIMIT_NPROC] = "NPROC",
23663 + [RLIMIT_NOFILE] = "NOFILE",
23664 + [RLIMIT_MEMLOCK] = "VML",
23665 + [RLIMIT_AS] = "VM",
23666 + [RLIMIT_LOCKS] = "LOCKS",
23667 + [RLIMIT_SIGPENDING] = "SIGP",
23668 + [RLIMIT_MSGQUEUE] = "MSGQ",
23670 + [VLIMIT_NSOCK] = "NSOCK",
23671 + [VLIMIT_OPENFD] = "OPENFD",
23672 + [VLIMIT_ANON] = "ANON",
23673 + [VLIMIT_SHMEM] = "SHMEM",
23674 + [VLIMIT_DENTRY] = "DENTRY",
23677 +EXPORT_SYMBOL_GPL(vlimit_name);
23679 +#define MASK_ENTRY(x) (1 << (x))
23681 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
23684 + , /* softlimit */
23685 + MASK_ENTRY( RLIMIT_RSS ) |
23686 + MASK_ENTRY( VLIMIT_ANON ) |
23689 + MASK_ENTRY( RLIMIT_RSS ) |
23690 + MASK_ENTRY( RLIMIT_NPROC ) |
23691 + MASK_ENTRY( RLIMIT_NOFILE ) |
23692 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
23693 + MASK_ENTRY( RLIMIT_AS ) |
23694 + MASK_ENTRY( RLIMIT_LOCKS ) |
23695 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
23697 + MASK_ENTRY( VLIMIT_NSOCK ) |
23698 + MASK_ENTRY( VLIMIT_OPENFD ) |
23699 + MASK_ENTRY( VLIMIT_ANON ) |
23700 + MASK_ENTRY( VLIMIT_SHMEM ) |
23701 + MASK_ENTRY( VLIMIT_DENTRY ) |
23704 + /* accounting only */
23705 +uint32_t account_mask =
23706 + MASK_ENTRY( VLIMIT_SEMARY ) |
23707 + MASK_ENTRY( VLIMIT_NSEMS ) |
23708 + MASK_ENTRY( VLIMIT_MAPPED ) |
23712 +static int is_valid_vlimit(int id)
23714 + uint32_t mask = vlimit_mask.minimum |
23715 + vlimit_mask.softlimit | vlimit_mask.maximum;
23716 + return mask & (1 << id);
23719 +static int is_accounted_vlimit(int id)
23721 + if (is_valid_vlimit(id))
23723 + return account_mask & (1 << id);
23727 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
23729 + rlim_t limit = __rlim_soft(&vxi->limit, id);
23730 + return VX_VLIM(limit);
23733 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
23735 + rlim_t limit = __rlim_hard(&vxi->limit, id);
23736 + return VX_VLIM(limit);
23739 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
23740 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
23742 + if (!is_valid_vlimit(id))
23746 + *minimum = CRLIM_UNSET;
23748 + *softlimit = vc_get_soft(vxi, id);
23750 + *maximum = vc_get_hard(vxi, id);
23754 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
23756 + struct vcmd_ctx_rlimit_v0 vc_data;
23759 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23762 + ret = do_get_rlimit(vxi, vc_data.id,
23763 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
23767 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23772 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
23773 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
23775 + if (!is_valid_vlimit(id))
23778 + if (maximum != CRLIM_KEEP)
23779 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
23780 + if (softlimit != CRLIM_KEEP)
23781 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
23783 + /* clamp soft limit */
23784 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
23785 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
23790 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
23792 + struct vcmd_ctx_rlimit_v0 vc_data;
23794 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23797 + return do_set_rlimit(vxi, vc_data.id,
23798 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
23801 +#ifdef CONFIG_IA32_EMULATION
23803 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
23805 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
23807 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23810 + return do_set_rlimit(vxi, vc_data.id,
23811 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
23814 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
23816 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
23819 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23822 + ret = do_get_rlimit(vxi, vc_data.id,
23823 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
23827 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23832 +#endif /* CONFIG_IA32_EMULATION */
23835 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
23837 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
23843 +static inline void vx_reset_minmax(struct _vx_limit *limit)
23848 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23849 + value = __rlim_get(limit, lim);
23850 + __rlim_rmax(limit, lim) = value;
23851 + __rlim_rmin(limit, lim) = value;
23856 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
23858 + vx_reset_minmax(&vxi->limit);
23863 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
23865 + struct vcmd_rlimit_stat_v0 vc_data;
23866 + struct _vx_limit *limit = &vxi->limit;
23869 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23873 + if (!is_accounted_vlimit(id))
23876 + vx_limit_fixup(limit, id);
23877 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
23878 + vc_data.value = __rlim_get(limit, id);
23879 + vc_data.minimum = __rlim_rmin(limit, id);
23880 + vc_data.maximum = __rlim_rmax(limit, id);
23882 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23888 +void vx_vsi_meminfo(struct sysinfo *val)
23890 + struct vx_info *vxi = current->vx_info;
23891 + unsigned long totalram, freeram;
23894 + /* we blindly accept the max */
23895 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23896 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
23898 + /* total minus used equals free */
23899 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23900 + freeram = (v < totalram) ? totalram - v : 0;
23902 + val->totalram = totalram;
23903 + val->freeram = freeram;
23904 + val->bufferram = 0;
23905 + val->totalhigh = 0;
23906 + val->freehigh = 0;
23910 +void vx_vsi_swapinfo(struct sysinfo *val)
23912 + struct vx_info *vxi = current->vx_info;
23913 + unsigned long totalswap, freeswap;
23916 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23917 + if (v == RLIM_INFINITY) {
23918 + val->freeswap = val->totalswap;
23922 + /* we blindly accept the max */
23923 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
23924 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
23926 + /* currently 'used' swap */
23927 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23928 + w -= (w > v) ? v : w;
23930 + /* total minus used equals free */
23931 + freeswap = (w < totalswap) ? totalswap - w : 0;
23933 + val->totalswap = totalswap;
23934 + val->freeswap = freeswap;
23939 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
23941 + struct vx_info *vxi = mm->mm_vx_info;
23942 + unsigned long points;
23948 + points = vxi->vx_badness_bias;
23950 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
23951 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
23952 + points += (v > w) ? (v - w) : 0;
23957 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
23958 --- linux-2.6.22.10/kernel/vserver/limit_init.h 1970-01-01 01:00:00 +0100
23959 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit_init.h 2007-10-25 17:05:55 +0200
23963 +static inline void vx_info_init_limit(struct _vx_limit *limit)
23967 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23968 + __rlim_soft(limit, lim) = RLIM_INFINITY;
23969 + __rlim_hard(limit, lim) = RLIM_INFINITY;
23970 + __rlim_set(limit, lim, 0);
23971 + atomic_set(&__rlim_lhit(limit, lim), 0);
23972 + __rlim_rmin(limit, lim) = 0;
23973 + __rlim_rmax(limit, lim) = 0;
23977 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
23979 +#ifdef CONFIG_VSERVER_WARN
23983 + for (lim = 0; lim < NUM_LIMITS; lim++) {
23984 + if ((1 << lim) & VLIM_NOCHECK)
23986 + value = __rlim_get(limit, lim);
23987 + vxwprintk_xid(value,
23988 + "!!! limit: %p[%s,%d] = %ld on exit.",
23989 + limit, vlimit_name[lim], lim, (long)value);
23994 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
23995 --- linux-2.6.22.10/kernel/vserver/limit_proc.h 1970-01-01 01:00:00 +0100
23996 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/limit_proc.h 2007-08-05 20:53:13 +0200
23998 +#ifndef _VX_LIMIT_PROC_H
23999 +#define _VX_LIMIT_PROC_H
24001 +#include <linux/vserver/limit_int.h>
24004 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
24005 +#define VX_LIMIT_TOP \
24006 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
24008 +#define VX_LIMIT_ARG(r) \
24009 + (unsigned long)__rlim_get(limit, r), \
24010 + (unsigned long)__rlim_rmin(limit, r), \
24011 + (unsigned long)__rlim_rmax(limit, r), \
24012 + VX_VLIM(__rlim_soft(limit, r)), \
24013 + VX_VLIM(__rlim_hard(limit, r)), \
24014 + atomic_read(&__rlim_lhit(limit, r))
24016 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
24018 + vx_limit_fixup(limit, -1);
24019 + return sprintf(buffer, VX_LIMIT_TOP
24020 + "PROC" VX_LIMIT_FMT
24021 + "VM" VX_LIMIT_FMT
24022 + "VML" VX_LIMIT_FMT
24023 + "RSS" VX_LIMIT_FMT
24024 + "ANON" VX_LIMIT_FMT
24025 + "RMAP" VX_LIMIT_FMT
24026 + "FILES" VX_LIMIT_FMT
24027 + "OFD" VX_LIMIT_FMT
24028 + "LOCKS" VX_LIMIT_FMT
24029 + "SOCK" VX_LIMIT_FMT
24030 + "MSGQ" VX_LIMIT_FMT
24031 + "SHM" VX_LIMIT_FMT
24032 + "SEMA" VX_LIMIT_FMT
24033 + "SEMS" VX_LIMIT_FMT
24034 + "DENT" VX_LIMIT_FMT,
24035 + VX_LIMIT_ARG(RLIMIT_NPROC),
24036 + VX_LIMIT_ARG(RLIMIT_AS),
24037 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
24038 + VX_LIMIT_ARG(RLIMIT_RSS),
24039 + VX_LIMIT_ARG(VLIMIT_ANON),
24040 + VX_LIMIT_ARG(VLIMIT_MAPPED),
24041 + VX_LIMIT_ARG(RLIMIT_NOFILE),
24042 + VX_LIMIT_ARG(VLIMIT_OPENFD),
24043 + VX_LIMIT_ARG(RLIMIT_LOCKS),
24044 + VX_LIMIT_ARG(VLIMIT_NSOCK),
24045 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
24046 + VX_LIMIT_ARG(VLIMIT_SHMEM),
24047 + VX_LIMIT_ARG(VLIMIT_SEMARY),
24048 + VX_LIMIT_ARG(VLIMIT_NSEMS),
24049 + VX_LIMIT_ARG(VLIMIT_DENTRY));
24052 +#endif /* _VX_LIMIT_PROC_H */
24055 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
24056 --- linux-2.6.22.10/kernel/vserver/monitor.c 1970-01-01 01:00:00 +0100
24057 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/monitor.c 2007-08-15 23:18:20 +0200
24060 + * kernel/vserver/monitor.c
24062 + * Virtual Context Scheduler Monitor
24064 + * Copyright (C) 2006-2007 Herbert Pötzl
24066 + * V0.01 basic design
24070 +#include <linux/module.h>
24071 +#include <linux/jiffies.h>
24072 +#include <asm/uaccess.h>
24073 +#include <asm/atomic.h>
24075 +#include <linux/vserver/monitor.h>
24076 +#include <linux/vserver/debug_cmd.h>
24079 +#ifdef CONFIG_VSERVER_MONITOR
24080 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
24082 +#define VXM_SIZE 64
24085 +struct _vx_monitor {
24086 + unsigned int counter;
24088 + struct _vx_mon_entry entry[VXM_SIZE+1];
24092 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
24094 +unsigned volatile int vxm_active = 1;
24096 +static atomic_t sequence = ATOMIC_INIT(0);
24101 + * requires disabled preemption */
24103 +struct _vx_mon_entry *vxm_advance(int cpu)
24105 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
24106 + struct _vx_mon_entry *entry;
24107 + unsigned int index;
24109 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
24110 + entry = &mon->entry[index];
24112 + entry->ev.seq = atomic_inc_return(&sequence);
24113 + entry->ev.jif = jiffies;
24117 +EXPORT_SYMBOL_GPL(vxm_advance);
24120 +int do_read_monitor(struct __user _vx_mon_entry *data,
24121 + int cpu, uint32_t *index, uint32_t *count)
24123 + int pos, ret = 0;
24124 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
24125 + int end = mon->counter;
24126 + int start = end - VXM_SIZE + 2;
24127 + int idx = *index;
24129 + /* special case: get current pos */
24135 + /* have we lost some data? */
24139 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
24140 + struct _vx_mon_entry *entry =
24141 + &mon->entry[idx % VXM_SIZE];
24143 + /* send entry to userspace */
24144 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
24148 + /* save new index and count */
24151 + return ret ? ret : (*index < end);
24154 +int vc_read_monitor(uint32_t id, void __user *data)
24156 + struct vcmd_read_monitor_v0 vc_data;
24159 + if (id >= NR_CPUS)
24162 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24165 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
24166 + id, &vc_data.index, &vc_data.count);
24168 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24173 +#ifdef CONFIG_COMPAT
24175 +int vc_read_monitor_x32(uint32_t id, void __user *data)
24177 + struct vcmd_read_monitor_v0_x32 vc_data;
24180 + if (id >= NR_CPUS)
24183 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24186 + ret = do_read_monitor((struct __user _vx_mon_entry *)
24187 + compat_ptr(vc_data.data_ptr),
24188 + id, &vc_data.index, &vc_data.count);
24190 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24195 +#endif /* CONFIG_COMPAT */
24197 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
24198 --- linux-2.6.22.10/kernel/vserver/network.c 1970-01-01 01:00:00 +0100
24199 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/network.c 2007-10-05 14:54:36 +0200
24202 + * linux/kernel/vserver/network.c
24204 + * Virtual Server: Network Support
24206 + * Copyright (C) 2003-2007 Herbert Pötzl
24208 + * V0.01 broken out from vcontext V0.05
24209 + * V0.02 cleaned up implementation
24210 + * V0.03 added equiv nx commands
24211 + * V0.04 switch to RCU based hash
24212 + * V0.05 and back to locking again
24213 + * V0.06 changed vcmds to nxi arg
24214 + * V0.07 have __create claim() the nxi
24218 +#include <linux/err.h>
24219 +#include <linux/slab.h>
24220 +#include <linux/rcupdate.h>
24222 +#include <linux/vs_network.h>
24223 +#include <linux/vserver/network_cmd.h>
24226 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
24227 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
24229 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
24230 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
24233 +static int __init init_network(void)
24235 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
24236 + sizeof(struct nx_addr_v4), 0, SLAB_PANIC, NULL, NULL);
24237 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
24238 + sizeof(struct nx_addr_v6), 0, SLAB_PANIC, NULL, NULL);
24243 +/* __alloc_nx_addr_v4() */
24245 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
24247 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
24248 + nx_addr_v4_cachep, GFP_KERNEL);
24250 + if (!IS_ERR(nxa))
24251 + memset(nxa, 0, sizeof(*nxa));
24255 +/* __dealloc_nx_addr_v4() */
24257 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
24259 + kmem_cache_free(nx_addr_v4_cachep, nxa);
24262 +/* __dealloc_nx_addr_v4_all() */
24264 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
24267 + struct nx_addr_v4 *next = nxa->next;
24269 + __dealloc_nx_addr_v4(nxa);
24275 +#ifdef CONFIG_IPV6
24277 +/* __alloc_nx_addr_v6() */
24279 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
24281 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
24282 + nx_addr_v6_cachep, GFP_KERNEL);
24284 + if (!IS_ERR(nxa))
24285 + memset(nxa, 0, sizeof(*nxa));
24289 +/* __dealloc_nx_addr_v6() */
24291 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
24293 + kmem_cache_free(nx_addr_v6_cachep, nxa);
24296 +/* __dealloc_nx_addr_v6_all() */
24298 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
24301 + struct nx_addr_v6 *next = nxa->next;
24303 + __dealloc_nx_addr_v6(nxa);
24308 +#endif /* CONFIG_IPV6 */
24311 +/* __alloc_nx_info()
24313 + * allocate an initialized nx_info struct
24314 + * doesn't make it visible (hash) */
24316 +static struct nx_info *__alloc_nx_info(nid_t nid)
24318 + struct nx_info *new = NULL;
24320 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
24322 + /* would this benefit from a slab cache? */
24323 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
24327 + memset(new, 0, sizeof(struct nx_info));
24328 + new->nx_id = nid;
24329 + INIT_HLIST_NODE(&new->nx_hlist);
24330 + atomic_set(&new->nx_usecnt, 0);
24331 + atomic_set(&new->nx_tasks, 0);
24332 + new->nx_state = 0;
24334 + new->nx_flags = NXF_INIT_SET;
24336 + /* rest of init goes here */
24338 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
24339 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
24341 + vxdprintk(VXD_CBIT(nid, 0),
24342 + "alloc_nx_info(%d) = %p", nid, new);
24343 + atomic_inc(&nx_global_ctotal);
24347 +/* __dealloc_nx_info()
24349 + * final disposal of nx_info */
24351 +static void __dealloc_nx_info(struct nx_info *nxi)
24353 + vxdprintk(VXD_CBIT(nid, 0),
24354 + "dealloc_nx_info(%p)", nxi);
24356 + nxi->nx_hlist.next = LIST_POISON1;
24359 + BUG_ON(atomic_read(&nxi->nx_usecnt));
24360 + BUG_ON(atomic_read(&nxi->nx_tasks));
24362 + __dealloc_nx_addr_v4_all(nxi->v4.next);
24364 + nxi->nx_state |= NXS_RELEASED;
24366 + atomic_dec(&nx_global_ctotal);
24369 +static void __shutdown_nx_info(struct nx_info *nxi)
24371 + nxi->nx_state |= NXS_SHUTDOWN;
24372 + vs_net_change(nxi, VSC_NETDOWN);
24375 +/* exported stuff */
24377 +void free_nx_info(struct nx_info *nxi)
24379 + /* context shutdown is mandatory */
24380 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
24382 + /* context must not be hashed */
24383 + BUG_ON(nxi->nx_state & NXS_HASHED);
24385 + BUG_ON(atomic_read(&nxi->nx_usecnt));
24386 + BUG_ON(atomic_read(&nxi->nx_tasks));
24388 + __dealloc_nx_info(nxi);
24392 +void __nx_set_lback(struct nx_info *nxi)
24394 + int nid = nxi->nx_id;
24395 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
24397 + nxi->v4_lback.s_addr = lback;
24400 +extern int __nx_inet_add_lback(__be32 addr);
24401 +extern int __nx_inet_del_lback(__be32 addr);
24404 +/* hash table for nx_info hash */
24406 +#define NX_HASH_SIZE 13
24408 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
24410 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
24413 +static inline unsigned int __hashval(nid_t nid)
24415 + return (nid % NX_HASH_SIZE);
24420 +/* __hash_nx_info()
24422 + * add the nxi to the global hash table
24423 + * requires the hash_lock to be held */
24425 +static inline void __hash_nx_info(struct nx_info *nxi)
24427 + struct hlist_head *head;
24429 + vxd_assert_lock(&nx_info_hash_lock);
24430 + vxdprintk(VXD_CBIT(nid, 4),
24431 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
24433 + /* context must not be hashed */
24434 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
24436 + nxi->nx_state |= NXS_HASHED;
24437 + head = &nx_info_hash[__hashval(nxi->nx_id)];
24438 + hlist_add_head(&nxi->nx_hlist, head);
24439 + atomic_inc(&nx_global_cactive);
24442 +/* __unhash_nx_info()
24444 + * remove the nxi from the global hash table
24445 + * requires the hash_lock to be held */
24447 +static inline void __unhash_nx_info(struct nx_info *nxi)
24449 + vxd_assert_lock(&nx_info_hash_lock);
24450 + vxdprintk(VXD_CBIT(nid, 4),
24451 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
24452 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
24454 + /* context must be hashed */
24455 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
24456 + /* but without tasks */
24457 + BUG_ON(atomic_read(&nxi->nx_tasks));
24459 + nxi->nx_state &= ~NXS_HASHED;
24460 + hlist_del(&nxi->nx_hlist);
24461 + atomic_dec(&nx_global_cactive);
24465 +/* __lookup_nx_info()
24467 + * requires the hash_lock to be held
24468 + * doesn't increment the nx_refcnt */
24470 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
24472 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
24473 + struct hlist_node *pos;
24474 + struct nx_info *nxi;
24476 + vxd_assert_lock(&nx_info_hash_lock);
24477 + hlist_for_each(pos, head) {
24478 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
24480 + if (nxi->nx_id == nid)
24485 + vxdprintk(VXD_CBIT(nid, 0),
24486 + "__lookup_nx_info(#%u): %p[#%u]",
24487 + nid, nxi, nxi ? nxi->nx_id : 0);
24492 +/* __create_nx_info()
24494 + * create the requested context
24495 + * get(), claim() and hash it */
24497 +static struct nx_info *__create_nx_info(int id)
24499 + struct nx_info *new, *nxi = NULL;
24501 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
24503 + if (!(new = __alloc_nx_info(id)))
24504 + return ERR_PTR(-ENOMEM);
24506 + /* required to make dynamic xids unique */
24507 + spin_lock(&nx_info_hash_lock);
24509 + /* static context requested */
24510 + if ((nxi = __lookup_nx_info(id))) {
24511 + vxdprintk(VXD_CBIT(nid, 0),
24512 + "create_nx_info(%d) = %p (already there)", id, nxi);
24513 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
24514 + nxi = ERR_PTR(-EBUSY);
24516 + nxi = ERR_PTR(-EEXIST);
24519 + /* new context */
24520 + vxdprintk(VXD_CBIT(nid, 0),
24521 + "create_nx_info(%d) = %p (new)", id, new);
24522 + claim_nx_info(new, NULL);
24523 + __nx_set_lback(new);
24524 + __hash_nx_info(get_nx_info(new));
24525 + nxi = new, new = NULL;
24528 + spin_unlock(&nx_info_hash_lock);
24530 + __dealloc_nx_info(new);
24536 +/* exported stuff */
24539 +void unhash_nx_info(struct nx_info *nxi)
24541 + __shutdown_nx_info(nxi);
24542 + spin_lock(&nx_info_hash_lock);
24543 + __unhash_nx_info(nxi);
24544 + spin_unlock(&nx_info_hash_lock);
24547 +/* lookup_nx_info()
24549 + * search for a nx_info and get() it
24550 + * negative id means current */
24552 +struct nx_info *lookup_nx_info(int id)
24554 + struct nx_info *nxi = NULL;
24557 + nxi = get_nx_info(current->nx_info);
24558 + } else if (id > 1) {
24559 + spin_lock(&nx_info_hash_lock);
24560 + nxi = get_nx_info(__lookup_nx_info(id));
24561 + spin_unlock(&nx_info_hash_lock);
24566 +/* nid_is_hashed()
24568 + * verify that nid is still hashed */
24570 +int nid_is_hashed(nid_t nid)
24574 + spin_lock(&nx_info_hash_lock);
24575 + hashed = (__lookup_nx_info(nid) != NULL);
24576 + spin_unlock(&nx_info_hash_lock);
24581 +#ifdef CONFIG_PROC_FS
24585 + * get a subset of hashed nids for proc
24586 + * assumes size is at least one */
24588 +int get_nid_list(int index, unsigned int *nids, int size)
24590 + int hindex, nr_nids = 0;
24592 + /* only show current and children */
24593 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
24596 + nids[nr_nids] = nx_current_nid();
24600 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
24601 + struct hlist_head *head = &nx_info_hash[hindex];
24602 + struct hlist_node *pos;
24604 + spin_lock(&nx_info_hash_lock);
24605 + hlist_for_each(pos, head) {
24606 + struct nx_info *nxi;
24611 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
24612 + nids[nr_nids] = nxi->nx_id;
24613 + if (++nr_nids >= size) {
24614 + spin_unlock(&nx_info_hash_lock);
24618 + /* keep the lock time short */
24619 + spin_unlock(&nx_info_hash_lock);
24628 + * migrate task to new network
24629 + * gets nxi, puts old_nxi on change
24632 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
24634 + struct nx_info *old_nxi;
24640 + vxdprintk(VXD_CBIT(nid, 5),
24641 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
24642 + p, nxi, nxi->nx_id,
24643 + atomic_read(&nxi->nx_usecnt),
24644 + atomic_read(&nxi->nx_tasks));
24646 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
24647 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
24650 + if (nx_info_state(nxi, NXS_SHUTDOWN))
24653 + /* maybe disallow this completely? */
24654 + old_nxi = task_get_nx_info(p);
24655 + if (old_nxi == nxi)
24660 + clr_nx_info(&p->nx_info);
24661 + claim_nx_info(nxi, p);
24662 + set_nx_info(&p->nx_info, nxi);
24663 + p->nid = nxi->nx_id;
24666 + vxdprintk(VXD_CBIT(nid, 5),
24667 + "moved task %p into nxi:%p[#%d]",
24668 + p, nxi, nxi->nx_id);
24671 + release_nx_info(old_nxi, p);
24674 + put_nx_info(old_nxi);
24679 +void nx_set_persistent(struct nx_info *nxi)
24681 + vxdprintk(VXD_CBIT(nid, 6),
24682 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
24684 + get_nx_info(nxi);
24685 + claim_nx_info(nxi, NULL);
24688 +void nx_clear_persistent(struct nx_info *nxi)
24690 + vxdprintk(VXD_CBIT(nid, 6),
24691 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
24693 + release_nx_info(nxi, NULL);
24694 + put_nx_info(nxi);
24697 +void nx_update_persistent(struct nx_info *nxi)
24699 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
24700 + nx_set_persistent(nxi);
24702 + nx_clear_persistent(nxi);
24705 +/* vserver syscall commands below here */
24707 +/* taks nid and nx_info functions */
24709 +#include <asm/uaccess.h>
24712 +int vc_task_nid(uint32_t id)
24717 + struct task_struct *tsk;
24719 + read_lock(&tasklist_lock);
24720 + tsk = find_task_by_real_pid(id);
24721 + nid = (tsk) ? tsk->nid : -ESRCH;
24722 + read_unlock(&tasklist_lock);
24724 + nid = nx_current_nid();
24729 +int vc_nx_info(struct nx_info *nxi, void __user *data)
24731 + struct vcmd_nx_info_v0 vc_data;
24733 + vc_data.nid = nxi->nx_id;
24735 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24741 +/* network functions */
24743 +int vc_net_create(uint32_t nid, void __user *data)
24745 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
24746 + struct nx_info *new_nxi;
24749 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24752 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
24755 + new_nxi = __create_nx_info(nid);
24756 + if (IS_ERR(new_nxi))
24757 + return PTR_ERR(new_nxi);
24759 + /* initial flags */
24760 + new_nxi->nx_flags = vc_data.flagword;
24763 + if (vs_net_change(new_nxi, VSC_NETUP))
24766 + ret = nx_migrate_task(current, new_nxi);
24770 + /* return context id on success */
24771 + ret = new_nxi->nx_id;
24773 + /* get a reference for persistent contexts */
24774 + if ((vc_data.flagword & NXF_PERSISTENT))
24775 + nx_set_persistent(new_nxi);
24777 + release_nx_info(new_nxi, NULL);
24778 + put_nx_info(new_nxi);
24783 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
24785 + return nx_migrate_task(current, nxi);
24790 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
24791 + uint16_t type, uint16_t flags)
24793 + struct nx_addr_v4 *nxa = &nxi->v4;
24795 + if (NX_IPV4(nxi)) {
24796 + /* locate last entry */
24797 + for (; nxa->next; nxa = nxa->next);
24798 + nxa->next = __alloc_nx_addr_v4();
24802 + return PTR_ERR(nxa);
24805 + if (nxi->v4.next)
24806 + /* remove single ip for ip list */
24807 + nxi->nx_flags &= ~NXF_SINGLE_IP;
24809 + nxa->ip[0].s_addr = ip;
24810 + nxa->ip[1].s_addr = ip2;
24811 + nxa->mask.s_addr = mask;
24812 + nxa->type = type;
24813 + nxa->flags = flags;
24818 +int vc_net_add(struct nx_info *nxi, void __user *data)
24820 + struct vcmd_net_addr_v0 vc_data;
24821 + int index, ret = 0;
24823 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24826 + switch (vc_data.type) {
24827 + case NXA_TYPE_IPV4:
24828 + if ((vc_data.count < 1) || (vc_data.count > 4))
24832 + while (index < vc_data.count) {
24833 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
24834 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
24842 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
24843 + nxi->v4_bcast = vc_data.ip[0];
24847 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
24848 + nxi->v4_lback = vc_data.ip[0];
24859 +int vc_net_remove(struct nx_info *nxi, void __user *data)
24861 + struct vcmd_net_addr_v0 vc_data;
24863 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24866 + switch (vc_data.type) {
24867 + case NXA_TYPE_ANY:
24868 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24869 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24879 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
24881 + struct vcmd_net_addr_ipv4_v1 vc_data;
24883 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24886 + switch (vc_data.type) {
24887 + case NXA_TYPE_ADDR:
24888 + case NXA_TYPE_RANGE:
24889 + case NXA_TYPE_MASK:
24890 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
24891 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
24893 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
24894 + nxi->v4_bcast = vc_data.ip;
24897 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
24898 + nxi->v4_lback = vc_data.ip;
24907 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
24909 + struct vcmd_net_addr_ipv4_v1 vc_data;
24911 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24914 + switch (vc_data.type) {
24915 +/* case NXA_TYPE_ADDR:
24918 + case NXA_TYPE_ANY:
24919 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
24920 + memset(&nxi->v4, 0, sizeof(nxi->v4));
24930 +#ifdef CONFIG_IPV6
24932 +int do_add_v6_addr(struct nx_info *nxi,
24933 + struct in6_addr *ip, struct in6_addr *mask,
24934 + uint32_t prefix, uint16_t type, uint16_t flags)
24936 + struct nx_addr_v6 *nxa = &nxi->v6;
24938 + if (NX_IPV6(nxi)) {
24939 + /* locate last entry */
24940 + for (; nxa->next; nxa = nxa->next);
24941 + nxa->next = __alloc_nx_addr_v6();
24945 + return PTR_ERR(nxa);
24949 + nxa->mask = *mask;
24950 + nxa->prefix = prefix;
24951 + nxa->type = type;
24952 + nxa->flags = flags;
24957 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
24959 + struct vcmd_net_addr_ipv6_v1 vc_data;
24961 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24964 + switch (vc_data.type) {
24965 + case NXA_TYPE_ADDR:
24966 + case NXA_TYPE_MASK:
24967 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
24968 + vc_data.prefix, vc_data.type, vc_data.flags);
24975 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
24977 + struct vcmd_net_addr_ipv6_v1 vc_data;
24979 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24982 + switch (vc_data.type) {
24983 + case NXA_TYPE_ANY:
24984 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
24985 + memset(&nxi->v6, 0, sizeof(nxi->v6));
24994 +#endif /* CONFIG_IPV6 */
24997 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
24999 + struct vcmd_net_flags_v0 vc_data;
25001 + vc_data.flagword = nxi->nx_flags;
25003 + /* special STATE flag handling */
25004 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
25006 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25011 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
25013 + struct vcmd_net_flags_v0 vc_data;
25014 + uint64_t mask, trigger;
25016 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25019 + /* special STATE flag handling */
25020 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
25021 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
25023 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
25024 + vc_data.flagword, mask);
25025 + if (trigger & NXF_PERSISTENT)
25026 + nx_update_persistent(nxi);
25031 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
25033 + struct vcmd_net_caps_v0 vc_data;
25035 + vc_data.ncaps = nxi->nx_ncaps;
25036 + vc_data.cmask = ~0ULL;
25038 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25043 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
25045 + struct vcmd_net_caps_v0 vc_data;
25047 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25050 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
25051 + vc_data.ncaps, vc_data.cmask);
25056 +#include <linux/module.h>
25058 +module_init(init_network);
25060 +EXPORT_SYMBOL_GPL(free_nx_info);
25061 +EXPORT_SYMBOL_GPL(unhash_nx_info);
25063 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
25064 --- linux-2.6.22.10/kernel/vserver/proc.c 1970-01-01 01:00:00 +0100
25065 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/proc.c 2007-10-05 14:54:36 +0200
25068 + * linux/kernel/vserver/proc.c
25070 + * Virtual Context Support
25072 + * Copyright (C) 2003-2007 Herbert Pötzl
25074 + * V0.01 basic structure
25075 + * V0.02 adaptation vs1.3.0
25076 + * V0.03 proc permissions
25077 + * V0.04 locking/generic
25078 + * V0.05 next generation procfs
25079 + * V0.06 inode validation
25080 + * V0.07 generic rewrite vid
25081 + * V0.08 remove inode type
25085 +#include <linux/proc_fs.h>
25086 +#include <asm/unistd.h>
25088 +#include <linux/vs_context.h>
25089 +#include <linux/vs_network.h>
25090 +#include <linux/vs_cvirt.h>
25091 +#include <linux/vs_inet.h>
25092 +#include <linux/vs_inet6.h>
25094 +#include <linux/vserver/global.h>
25096 +#include "cvirt_proc.h"
25097 +#include "cacct_proc.h"
25098 +#include "limit_proc.h"
25099 +#include "sched_proc.h"
25100 +#include "vci_config.h"
25102 +static struct proc_dir_entry *proc_virtual;
25104 +static struct proc_dir_entry *proc_virtnet;
25107 +/* first the actual feeds */
25110 +static int proc_vci(char *buffer)
25112 + return sprintf(buffer,
25113 + "VCIVersion:\t%04x:%04x\n"
25114 + "VCISyscall:\t%d\n"
25115 + "VCIKernel:\t%08x\n",
25116 + VCI_VERSION >> 16,
25117 + VCI_VERSION & 0xFFFF,
25119 + vci_kernel_config());
25122 +static int proc_virtual_info(char *buffer)
25124 + return proc_vci(buffer);
25127 +static int proc_virtual_status(char *buffer)
25129 + return sprintf(buffer,
25131 + "#CActive:\t%d\n"
25132 + "#NSProxy:\t%d\t%d %d %d %d\n",
25133 + atomic_read(&vx_global_ctotal),
25134 + atomic_read(&vx_global_cactive),
25135 + atomic_read(&vs_global_nsproxy),
25136 + atomic_read(&vs_global_fs),
25137 + atomic_read(&vs_global_mnt_ns),
25138 + atomic_read(&vs_global_uts_ns),
25139 + atomic_read(&vs_global_ipc_ns));
25143 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
25147 + length = sprintf(buffer,
25155 + vxi->vx_badness_bias);
25159 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
25163 + length = sprintf(buffer,
25166 + "Flags:\t%016llx\n"
25167 + "BCaps:\t%016llx\n"
25168 + "CCaps:\t%016llx\n"
25169 + "Spaces:\t%08lx\n",
25170 + atomic_read(&vxi->vx_usecnt),
25171 + atomic_read(&vxi->vx_tasks),
25172 + (unsigned long long)vxi->vx_flags,
25173 + (unsigned long long)vxi->vx_bcaps,
25174 + (unsigned long long)vxi->vx_ccaps,
25179 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
25181 + return vx_info_proc_limit(&vxi->limit, buffer);
25184 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
25188 + length = vx_info_proc_sched(&vxi->sched, buffer);
25189 + for_each_online_cpu(cpu) {
25190 + length += vx_info_proc_sched_pc(
25191 + &vx_per_cpu(vxi, sched_pc, cpu),
25192 + buffer + length, cpu);
25197 +int proc_vxi_nsproxy(struct vx_info *vxi, char *buffer)
25199 + return vx_info_proc_nsproxy(vxi->vx_nsproxy, buffer);
25202 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
25206 + vx_update_load(vxi);
25207 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
25208 + for_each_online_cpu(cpu) {
25209 + length += vx_info_proc_cvirt_pc(
25210 + &vx_per_cpu(vxi, cvirt_pc, cpu),
25211 + buffer + length, cpu);
25216 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
25218 + return vx_info_proc_cacct(&vxi->cacct, buffer);
25222 +static int proc_virtnet_info(char *buffer)
25224 + return proc_vci(buffer);
25227 +static int proc_virtnet_status(char *buffer)
25229 + return sprintf(buffer,
25231 + "#CActive:\t%d\n",
25232 + atomic_read(&nx_global_ctotal),
25233 + atomic_read(&nx_global_cactive));
25236 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
25238 + struct nx_addr_v4 *v4a;
25239 +#ifdef CONFIG_IPV6
25240 + struct nx_addr_v6 *v6a;
25244 + length = sprintf(buffer,
25247 + "Bcast:\t" NIPQUAD_FMT "\n"
25248 + "Lback:\t" NIPQUAD_FMT "\n",
25251 + NIPQUAD(nxi->v4_bcast.s_addr),
25252 + NIPQUAD(nxi->v4_lback.s_addr));
25254 + if (!NX_IPV4(nxi))
25256 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
25257 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
25260 +#ifdef CONFIG_IPV6
25261 + if (!NX_IPV6(nxi))
25263 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
25264 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
25271 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
25275 + length = sprintf(buffer,
25278 + "Flags:\t%016llx\n"
25279 + "NCaps:\t%016llx\n",
25280 + atomic_read(&nxi->nx_usecnt),
25281 + atomic_read(&nxi->nx_tasks),
25282 + (unsigned long long)nxi->nx_flags,
25283 + (unsigned long long)nxi->nx_ncaps);
25289 +/* here the inode helpers */
25295 + struct inode_operations *iop;
25296 + struct file_operations *fop;
25297 + union proc_op op;
25300 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
25302 + struct inode *inode = new_inode(sb);
25307 + inode->i_mode = p->mode;
25309 + inode->i_op = p->iop;
25311 + inode->i_fop = p->fop;
25313 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
25314 + inode->i_flags |= S_IMMUTABLE;
25316 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
25318 + inode->i_uid = 0;
25319 + inode->i_gid = 0;
25320 + inode->i_tag = 0;
25325 +static struct dentry *vs_proc_instantiate(struct inode *dir,
25326 + struct dentry *dentry, int id, void *ptr)
25328 + struct vs_entry *p = ptr;
25329 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
25330 + struct dentry *error = ERR_PTR(-EINVAL);
25335 + PROC_I(inode)->op = p->op;
25336 + PROC_I(inode)->fd = id;
25337 + d_add(dentry, inode);
25345 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
25348 + * Fill a directory entry.
25350 + * If possible create the dcache entry and derive our inode number and
25351 + * file type from dcache entry.
25353 + * Since all of the proc inode numbers are dynamically generated, the inode
25354 + * numbers do not exist until the inode is cache. This means creating the
25355 + * the dcache entry in readdir is necessary to keep the inode numbers
25356 + * reported by readdir in sync with the inode numbers reported
25359 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
25360 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
25362 + struct dentry *child, *dir = filp->f_dentry;
25363 + struct inode *inode;
25364 + struct qstr qname;
25366 + unsigned type = DT_UNKNOWN;
25368 + qname.name = name;
25370 + qname.hash = full_name_hash(name, len);
25372 + child = d_lookup(dir, &qname);
25374 + struct dentry *new;
25375 + new = d_alloc(dir, &qname);
25377 + child = instantiate(dir->d_inode, new, id, ptr);
25384 + if (!child || IS_ERR(child) || !child->d_inode)
25385 + goto end_instantiate;
25386 + inode = child->d_inode;
25388 + ino = inode->i_ino;
25389 + type = inode->i_mode >> 12;
25394 + ino = find_inode_number(dir, &qname);
25397 + return filldir(dirent, name, len, filp->f_pos, ino, type);
25402 +/* get and revalidate vx_info/xid */
25405 +struct vx_info *get_proc_vx_info(struct inode *inode)
25407 + return lookup_vx_info(PROC_I(inode)->fd);
25410 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
25412 + struct inode *inode = dentry->d_inode;
25413 + xid_t xid = PROC_I(inode)->fd;
25415 + if (!xid || xid_is_hashed(xid))
25422 +/* get and revalidate nx_info/nid */
25424 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
25426 + struct inode *inode = dentry->d_inode;
25427 + nid_t nid = PROC_I(inode)->fd;
25429 + if (!nid || nid_is_hashed(nid))
25437 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
25439 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
25440 + size_t count, loff_t *ppos)
25442 + struct inode *inode = file->f_dentry->d_inode;
25443 + unsigned long page;
25444 + ssize_t length = 0;
25446 + if (count > PROC_BLOCK_SIZE)
25447 + count = PROC_BLOCK_SIZE;
25449 + /* fade that out as soon as stable */
25450 + WARN_ON(PROC_I(inode)->fd);
25452 + if (!(page = __get_free_page(GFP_KERNEL)))
25455 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
25456 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
25459 + length = simple_read_from_buffer(buf, count, ppos,
25460 + (char *)page, length);
25466 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
25467 + size_t count, loff_t *ppos)
25469 + struct inode *inode = file->f_dentry->d_inode;
25470 + struct vx_info *vxi = NULL;
25471 + xid_t xid = PROC_I(inode)->fd;
25472 + unsigned long page;
25473 + ssize_t length = 0;
25475 + if (count > PROC_BLOCK_SIZE)
25476 + count = PROC_BLOCK_SIZE;
25478 + /* fade that out as soon as stable */
25480 + vxi = lookup_vx_info(xid);
25484 + length = -ENOMEM;
25485 + if (!(page = __get_free_page(GFP_KERNEL)))
25488 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
25489 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
25492 + length = simple_read_from_buffer(buf, count, ppos,
25493 + (char *)page, length);
25497 + put_vx_info(vxi);
25502 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
25503 + size_t count, loff_t *ppos)
25505 + struct inode *inode = file->f_dentry->d_inode;
25506 + struct nx_info *nxi = NULL;
25507 + nid_t nid = PROC_I(inode)->fd;
25508 + unsigned long page;
25509 + ssize_t length = 0;
25511 + if (count > PROC_BLOCK_SIZE)
25512 + count = PROC_BLOCK_SIZE;
25514 + /* fade that out as soon as stable */
25516 + nxi = lookup_nx_info(nid);
25520 + length = -ENOMEM;
25521 + if (!(page = __get_free_page(GFP_KERNEL)))
25524 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
25525 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
25528 + length = simple_read_from_buffer(buf, count, ppos,
25529 + (char *)page, length);
25533 + put_nx_info(nxi);
25540 +/* here comes the lower level */
25543 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
25544 + .len = sizeof(NAME) - 1, \
25545 + .name = (NAME), \
25553 +#define DIR(NAME, MODE, OTYPE) \
25554 + NOD(NAME, (S_IFDIR | (MODE)), \
25555 + &proc_ ## OTYPE ## _inode_operations, \
25556 + &proc_ ## OTYPE ## _file_operations, { } )
25558 +#define INF(NAME, MODE, OTYPE) \
25559 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25560 + &proc_vs_info_file_operations, \
25561 + { .proc_vs_read = &proc_##OTYPE } )
25563 +#define VINF(NAME, MODE, OTYPE) \
25564 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25565 + &proc_vx_info_file_operations, \
25566 + { .proc_vxi_read = &proc_##OTYPE } )
25568 +#define NINF(NAME, MODE, OTYPE) \
25569 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
25570 + &proc_nx_info_file_operations, \
25571 + { .proc_nxi_read = &proc_##OTYPE } )
25574 +static struct file_operations proc_vs_info_file_operations = {
25575 + .read = proc_vs_info_read,
25578 +static struct file_operations proc_vx_info_file_operations = {
25579 + .read = proc_vx_info_read,
25582 +static struct dentry_operations proc_xid_dentry_operations = {
25583 + .d_revalidate = proc_xid_revalidate,
25586 +static struct vs_entry vx_base_stuff[] = {
25587 + VINF("info", S_IRUGO, vxi_info),
25588 + VINF("status", S_IRUGO, vxi_status),
25589 + VINF("limit", S_IRUGO, vxi_limit),
25590 + VINF("sched", S_IRUGO, vxi_sched),
25591 + VINF("nsproxy", S_IRUGO, vxi_nsproxy),
25592 + VINF("cvirt", S_IRUGO, vxi_cvirt),
25593 + VINF("cacct", S_IRUGO, vxi_cacct),
25600 +static struct dentry *proc_xid_instantiate(struct inode *dir,
25601 + struct dentry *dentry, int id, void *ptr)
25603 + dentry->d_op = &proc_xid_dentry_operations;
25604 + return vs_proc_instantiate(dir, dentry, id, ptr);
25607 +static struct dentry *proc_xid_lookup(struct inode *dir,
25608 + struct dentry *dentry, struct nameidata *nd)
25610 + struct vs_entry *p = vx_base_stuff;
25611 + struct dentry *error = ERR_PTR(-ENOENT);
25613 + for (; p->name; p++) {
25614 + if (p->len != dentry->d_name.len)
25616 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25622 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
25627 +static int proc_xid_readdir(struct file *filp,
25628 + void *dirent, filldir_t filldir)
25630 + struct dentry *dentry = filp->f_dentry;
25631 + struct inode *inode = dentry->d_inode;
25632 + struct vs_entry *p = vx_base_stuff;
25633 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
25637 + pos = filp->f_pos;
25640 + ino = inode->i_ino;
25641 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25644 + /* fall through */
25646 + ino = parent_ino(dentry);
25647 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25650 + /* fall through */
25653 + if (index >= size)
25655 + for (p += index; p->name; p++) {
25656 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25657 + vs_proc_instantiate, PROC_I(inode)->fd, p))
25663 + filp->f_pos = pos;
25669 +static struct file_operations proc_nx_info_file_operations = {
25670 + .read = proc_nx_info_read,
25673 +static struct dentry_operations proc_nid_dentry_operations = {
25674 + .d_revalidate = proc_nid_revalidate,
25677 +static struct vs_entry nx_base_stuff[] = {
25678 + NINF("info", S_IRUGO, nxi_info),
25679 + NINF("status", S_IRUGO, nxi_status),
25684 +static struct dentry *proc_nid_instantiate(struct inode *dir,
25685 + struct dentry *dentry, int id, void *ptr)
25687 + dentry->d_op = &proc_nid_dentry_operations;
25688 + return vs_proc_instantiate(dir, dentry, id, ptr);
25691 +static struct dentry *proc_nid_lookup(struct inode *dir,
25692 + struct dentry *dentry, struct nameidata *nd)
25694 + struct vs_entry *p = nx_base_stuff;
25695 + struct dentry *error = ERR_PTR(-ENOENT);
25697 + for (; p->name; p++) {
25698 + if (p->len != dentry->d_name.len)
25700 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25706 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
25711 +static int proc_nid_readdir(struct file *filp,
25712 + void *dirent, filldir_t filldir)
25714 + struct dentry *dentry = filp->f_dentry;
25715 + struct inode *inode = dentry->d_inode;
25716 + struct vs_entry *p = nx_base_stuff;
25717 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
25721 + pos = filp->f_pos;
25724 + ino = inode->i_ino;
25725 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25728 + /* fall through */
25730 + ino = parent_ino(dentry);
25731 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25734 + /* fall through */
25737 + if (index >= size)
25739 + for (p += index; p->name; p++) {
25740 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25741 + vs_proc_instantiate, PROC_I(inode)->fd, p))
25747 + filp->f_pos = pos;
25752 +#define MAX_MULBY10 ((~0U - 9) / 10)
25754 +static inline int atovid(const char *str, int len)
25759 + while (len-- > 0) {
25764 + if (vid >= MAX_MULBY10)
25774 +/* now the upper level (virtual) */
25777 +static struct file_operations proc_xid_file_operations = {
25778 + .read = generic_read_dir,
25779 + .readdir = proc_xid_readdir,
25782 +static struct inode_operations proc_xid_inode_operations = {
25783 + .lookup = proc_xid_lookup,
25786 +static struct vs_entry vx_virtual_stuff[] = {
25787 + INF("info", S_IRUGO, virtual_info),
25788 + INF("status", S_IRUGO, virtual_status),
25789 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
25793 +static struct dentry *proc_virtual_lookup(struct inode *dir,
25794 + struct dentry *dentry, struct nameidata *nd)
25796 + struct vs_entry *p = vx_virtual_stuff;
25797 + struct dentry *error = ERR_PTR(-ENOENT);
25800 + for (; p->name; p++) {
25801 + if (p->len != dentry->d_name.len)
25803 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25807 + goto instantiate;
25809 + id = atovid(dentry->d_name.name, dentry->d_name.len);
25810 + if ((id < 0) || !xid_is_hashed(id))
25814 + error = proc_xid_instantiate(dir, dentry, id, p);
25819 +static struct file_operations proc_nid_file_operations = {
25820 + .read = generic_read_dir,
25821 + .readdir = proc_nid_readdir,
25824 +static struct inode_operations proc_nid_inode_operations = {
25825 + .lookup = proc_nid_lookup,
25828 +static struct vs_entry nx_virtnet_stuff[] = {
25829 + INF("info", S_IRUGO, virtnet_info),
25830 + INF("status", S_IRUGO, virtnet_status),
25831 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
25835 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
25836 + struct dentry *dentry, struct nameidata *nd)
25838 + struct vs_entry *p = nx_virtnet_stuff;
25839 + struct dentry *error = ERR_PTR(-ENOENT);
25842 + for (; p->name; p++) {
25843 + if (p->len != dentry->d_name.len)
25845 + if (!memcmp(dentry->d_name.name, p->name, p->len))
25849 + goto instantiate;
25851 + id = atovid(dentry->d_name.name, dentry->d_name.len);
25852 + if ((id < 0) || !nid_is_hashed(id))
25856 + error = proc_nid_instantiate(dir, dentry, id, p);
25863 +#define PROC_NUMBUF 10
25864 +#define PROC_MAXVIDS 32
25866 +int proc_virtual_readdir(struct file *filp,
25867 + void *dirent, filldir_t filldir)
25869 + struct dentry *dentry = filp->f_dentry;
25870 + struct inode *inode = dentry->d_inode;
25871 + struct vs_entry *p = vx_virtual_stuff;
25872 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
25874 + unsigned int xid_array[PROC_MAXVIDS];
25875 + char buf[PROC_NUMBUF];
25876 + unsigned int nr_xids, i;
25879 + pos = filp->f_pos;
25882 + ino = inode->i_ino;
25883 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25886 + /* fall through */
25888 + ino = parent_ino(dentry);
25889 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25892 + /* fall through */
25895 + if (index >= size)
25897 + for (p += index; p->name; p++) {
25898 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25899 + vs_proc_instantiate, 0, p))
25904 + index = pos - size;
25905 + p = &vx_virtual_stuff[size - 1];
25906 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
25907 + for (i = 0; i < nr_xids; i++) {
25908 + int n, xid = xid_array[i];
25909 + unsigned int j = PROC_NUMBUF;
25913 + buf[--j] = '0' + (n % 10);
25916 + if (proc_fill_cache(filp, dirent, filldir,
25917 + buf + j, PROC_NUMBUF - j,
25918 + vs_proc_instantiate, xid, p))
25924 + filp->f_pos = pos;
25928 +static int proc_virtual_getattr(struct vfsmount *mnt,
25929 + struct dentry *dentry, struct kstat *stat)
25931 + struct inode *inode = dentry->d_inode;
25933 + generic_fillattr(inode, stat);
25934 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
25938 +static struct file_operations proc_virtual_dir_operations = {
25939 + .read = generic_read_dir,
25940 + .readdir = proc_virtual_readdir,
25943 +static struct inode_operations proc_virtual_dir_inode_operations = {
25944 + .getattr = proc_virtual_getattr,
25945 + .lookup = proc_virtual_lookup,
25952 +int proc_virtnet_readdir(struct file *filp,
25953 + void *dirent, filldir_t filldir)
25955 + struct dentry *dentry = filp->f_dentry;
25956 + struct inode *inode = dentry->d_inode;
25957 + struct vs_entry *p = nx_virtnet_stuff;
25958 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
25960 + unsigned int nid_array[PROC_MAXVIDS];
25961 + char buf[PROC_NUMBUF];
25962 + unsigned int nr_nids, i;
25965 + pos = filp->f_pos;
25968 + ino = inode->i_ino;
25969 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
25972 + /* fall through */
25974 + ino = parent_ino(dentry);
25975 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
25978 + /* fall through */
25981 + if (index >= size)
25983 + for (p += index; p->name; p++) {
25984 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
25985 + vs_proc_instantiate, 0, p))
25990 + index = pos - size;
25991 + p = &nx_virtnet_stuff[size - 1];
25992 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
25993 + for (i = 0; i < nr_nids; i++) {
25994 + int n, nid = nid_array[i];
25995 + unsigned int j = PROC_NUMBUF;
25999 + buf[--j] = '0' + (n % 10);
26002 + if (proc_fill_cache(filp, dirent, filldir,
26003 + buf + j, PROC_NUMBUF - j,
26004 + vs_proc_instantiate, nid, p))
26010 + filp->f_pos = pos;
26014 +static int proc_virtnet_getattr(struct vfsmount *mnt,
26015 + struct dentry *dentry, struct kstat *stat)
26017 + struct inode *inode = dentry->d_inode;
26019 + generic_fillattr(inode, stat);
26020 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
26024 +static struct file_operations proc_virtnet_dir_operations = {
26025 + .read = generic_read_dir,
26026 + .readdir = proc_virtnet_readdir,
26029 +static struct inode_operations proc_virtnet_dir_inode_operations = {
26030 + .getattr = proc_virtnet_getattr,
26031 + .lookup = proc_virtnet_lookup,
26036 +void proc_vx_init(void)
26038 + struct proc_dir_entry *ent;
26040 + ent = proc_mkdir("virtual", 0);
26042 + ent->proc_fops = &proc_virtual_dir_operations;
26043 + ent->proc_iops = &proc_virtual_dir_inode_operations;
26045 + proc_virtual = ent;
26047 + ent = proc_mkdir("virtnet", 0);
26049 + ent->proc_fops = &proc_virtnet_dir_operations;
26050 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
26052 + proc_virtnet = ent;
26058 +/* per pid info */
26061 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
26063 + struct vx_info *vxi;
26064 + char *orig = buffer;
26066 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
26068 + vxi = task_get_vx_info(p);
26072 + buffer += sprintf(buffer, "BCaps:\t%016llx\n",
26073 + (unsigned long long)vxi->vx_bcaps);
26074 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
26075 + (unsigned long long)vxi->vx_ccaps);
26076 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
26077 + (unsigned long long)vxi->vx_flags);
26078 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
26080 + put_vx_info(vxi);
26082 + return buffer - orig;
26086 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
26088 + struct nx_info *nxi;
26089 + struct nx_addr_v4 *v4a;
26090 +#ifdef CONFIG_IPV6
26091 + struct nx_addr_v6 *v6a;
26093 + char *orig = buffer;
26096 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
26098 + nxi = task_get_nx_info(p);
26102 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
26103 + (unsigned long long)nxi->nx_ncaps);
26104 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
26105 + (unsigned long long)nxi->nx_flags);
26107 + buffer += sprintf(buffer,
26108 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
26109 + NIPQUAD(nxi->v4_bcast.s_addr));
26110 + buffer += sprintf (buffer,
26111 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
26112 + NIPQUAD(nxi->v4_lback.s_addr));
26113 + if (!NX_IPV4(nxi))
26115 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
26116 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
26119 +#ifdef CONFIG_IPV6
26120 + if (!NX_IPV6(nxi))
26122 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
26123 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
26127 + put_nx_info(nxi);
26129 + return buffer - orig;
26132 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
26133 --- linux-2.6.22.10/kernel/vserver/sched.c 1970-01-01 01:00:00 +0100
26134 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched.c 2007-08-15 23:32:49 +0200
26137 + * linux/kernel/vserver/sched.c
26139 + * Virtual Server: Scheduler Support
26141 + * Copyright (C) 2004-2007 Herbert Pötzl
26143 + * V0.01 adapted Sam Vilains version to 2.6.3
26144 + * V0.02 removed legacy interface
26145 + * V0.03 changed vcmds to vxi arg
26146 + * V0.04 removed older and legacy interfaces
26150 +#include <linux/vs_context.h>
26151 +#include <linux/vs_sched.h>
26152 +#include <linux/vserver/sched_cmd.h>
26154 +#include <asm/uaccess.h>
26157 +#define vxd_check_range(val, min, max) do { \
26158 + vxlprintk((val < min) || (val > max), \
26159 + "check_range(%ld,%ld,%ld)", \
26160 + (long)val, (long)min, (long)max, \
26161 + __FILE__, __LINE__); \
26165 +void vx_update_sched_param(struct _vx_sched *sched,
26166 + struct _vx_sched_pc *sched_pc)
26168 + unsigned int set_mask = sched->update_mask;
26170 + if (set_mask & VXSM_FILL_RATE)
26171 + sched_pc->fill_rate[0] = sched->fill_rate[0];
26172 + if (set_mask & VXSM_INTERVAL)
26173 + sched_pc->interval[0] = sched->interval[0];
26174 + if (set_mask & VXSM_FILL_RATE2)
26175 + sched_pc->fill_rate[1] = sched->fill_rate[1];
26176 + if (set_mask & VXSM_INTERVAL2)
26177 + sched_pc->interval[1] = sched->interval[1];
26178 + if (set_mask & VXSM_TOKENS)
26179 + sched_pc->tokens = sched->tokens;
26180 + if (set_mask & VXSM_TOKENS_MIN)
26181 + sched_pc->tokens_min = sched->tokens_min;
26182 + if (set_mask & VXSM_TOKENS_MAX)
26183 + sched_pc->tokens_max = sched->tokens_max;
26184 + if (set_mask & VXSM_PRIO_BIAS)
26185 + sched_pc->prio_bias = sched->prio_bias;
26187 + if (set_mask & VXSM_IDLE_TIME)
26188 + sched_pc->flags |= VXSF_IDLE_TIME;
26190 + sched_pc->flags &= ~VXSF_IDLE_TIME;
26193 + sched_pc->norm_time = jiffies;
26198 + * recalculate the context's scheduling tokens
26200 + * ret > 0 : number of tokens available
26201 + * ret < 0 : on hold, check delta_min[]
26202 + * -1 only jiffies
26203 + * -2 also idle time
26206 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
26207 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
26211 + int flags = sched_pc->flags;
26213 + /* how much time did pass? */
26214 + delta = *norm_time - sched_pc->norm_time;
26215 + vxd_check_range(delta, 0, INT_MAX);
26217 + if (delta >= sched_pc->interval[0]) {
26218 + long tokens, integral;
26220 + /* calc integral token part */
26221 + tokens = delta / sched_pc->interval[0];
26222 + integral = tokens * sched_pc->interval[0];
26223 + tokens *= sched_pc->fill_rate[0];
26224 +#ifdef CONFIG_VSERVER_HARDCPU
26225 + delta_min[0] = delta - integral;
26226 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
26228 + /* advance time */
26229 + sched_pc->norm_time += delta;
26232 + sched_pc->tokens += tokens;
26233 + sched_pc->token_time += tokens;
26235 + delta_min[0] = delta;
26237 +#ifdef CONFIG_VSERVER_IDLETIME
26238 + if (!(flags & VXSF_IDLE_TIME))
26241 + /* how much was the idle skip? */
26242 + delta = *idle_time - sched_pc->idle_time;
26243 + vxd_check_range(delta, 0, INT_MAX);
26245 + if (delta >= sched_pc->interval[1]) {
26246 + long tokens, integral;
26248 + /* calc fair share token part */
26249 + tokens = delta / sched_pc->interval[1];
26250 + integral = tokens * sched_pc->interval[1];
26251 + tokens *= sched_pc->fill_rate[1];
26252 + delta_min[1] = delta - integral;
26253 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
26255 + /* advance idle time */
26256 + sched_pc->idle_time += integral;
26259 + sched_pc->tokens += tokens;
26260 + sched_pc->token_time += tokens;
26262 + delta_min[1] = delta;
26266 + /* clip at maximum */
26267 + if (sched_pc->tokens > sched_pc->tokens_max)
26268 + sched_pc->tokens = sched_pc->tokens_max;
26269 + tokens = sched_pc->tokens;
26271 + if ((flags & VXSF_ONHOLD)) {
26272 + /* can we unhold? */
26273 + if (tokens >= sched_pc->tokens_min) {
26274 + flags &= ~VXSF_ONHOLD;
26275 + sched_pc->hold_ticks +=
26276 + *norm_time - sched_pc->onhold;
26280 + /* put on hold? */
26281 + if (tokens <= 0) {
26282 + flags |= VXSF_ONHOLD;
26283 + sched_pc->onhold = *norm_time;
26287 + sched_pc->flags = flags;
26291 + tokens = sched_pc->tokens_min - tokens;
26292 + sched_pc->flags = flags;
26293 + BUG_ON(tokens < 0);
26295 +#ifdef CONFIG_VSERVER_HARDCPU
26296 + /* next interval? */
26297 + if (!sched_pc->fill_rate[0])
26298 + delta_min[0] = HZ;
26299 + else if (tokens > sched_pc->fill_rate[0])
26300 + delta_min[0] += sched_pc->interval[0] *
26301 + tokens / sched_pc->fill_rate[0];
26303 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
26304 + vxd_check_range(delta_min[0], 0, INT_MAX);
26306 +#ifdef CONFIG_VSERVER_IDLETIME
26307 + if (!(flags & VXSF_IDLE_TIME))
26310 + /* next interval? */
26311 + if (!sched_pc->fill_rate[1])
26312 + delta_min[1] = HZ;
26313 + else if (tokens > sched_pc->fill_rate[1])
26314 + delta_min[1] += sched_pc->interval[1] *
26315 + tokens / sched_pc->fill_rate[1];
26317 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
26318 + vxd_check_range(delta_min[1], 0, INT_MAX);
26323 +#endif /* CONFIG_VSERVER_IDLETIME */
26326 +#endif /* CONFIG_VSERVER_HARDCPU */
26329 +static inline unsigned long msec_to_ticks(unsigned long msec)
26331 + return msecs_to_jiffies(msec);
26334 +static inline unsigned long ticks_to_msec(unsigned long ticks)
26336 + return jiffies_to_msecs(ticks);
26339 +static inline unsigned long ticks_to_usec(unsigned long ticks)
26341 + return jiffies_to_usecs(ticks);
26345 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
26347 + unsigned int set_mask = data->mask;
26348 + unsigned int update_mask;
26351 + /* Sanity check data values */
26352 + if (data->tokens_max <= 0)
26353 + data->tokens_max = HZ;
26354 + if (data->tokens_min < 0)
26355 + data->tokens_min = HZ / 3;
26356 + if (data->tokens_min >= data->tokens_max)
26357 + data->tokens_min = data->tokens_max;
26359 + if (data->prio_bias > MAX_PRIO_BIAS)
26360 + data->prio_bias = MAX_PRIO_BIAS;
26361 + if (data->prio_bias < MIN_PRIO_BIAS)
26362 + data->prio_bias = MIN_PRIO_BIAS;
26364 + spin_lock(&vxi->sched.tokens_lock);
26366 + /* sync up on delayed updates */
26367 + for_each_cpu_mask(cpu, vxi->sched.update)
26368 + vx_update_sched_param(&vxi->sched,
26369 + &vx_per_cpu(vxi, sched_pc, cpu));
26371 + if (set_mask & VXSM_FILL_RATE)
26372 + vxi->sched.fill_rate[0] = data->fill_rate[0];
26373 + if (set_mask & VXSM_FILL_RATE2)
26374 + vxi->sched.fill_rate[1] = data->fill_rate[1];
26375 + if (set_mask & VXSM_INTERVAL)
26376 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
26377 + msec_to_ticks(data->interval[0]) : data->interval[0];
26378 + if (set_mask & VXSM_INTERVAL2)
26379 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
26380 + msec_to_ticks(data->interval[1]) : data->interval[1];
26381 + if (set_mask & VXSM_TOKENS)
26382 + vxi->sched.tokens = data->tokens;
26383 + if (set_mask & VXSM_TOKENS_MIN)
26384 + vxi->sched.tokens_min = data->tokens_min;
26385 + if (set_mask & VXSM_TOKENS_MAX)
26386 + vxi->sched.tokens_max = data->tokens_max;
26387 + if (set_mask & VXSM_PRIO_BIAS)
26388 + vxi->sched.prio_bias = data->prio_bias;
26390 + /* Sanity check rate/interval */
26391 + for (i = 0; i < 2; i++) {
26392 + if (data->fill_rate[i] < 0)
26393 + data->fill_rate[i] = 0;
26394 + if (data->interval[i] <= 0)
26395 + data->interval[i] = HZ;
26398 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
26399 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
26400 + vxi->sched.update_mask = update_mask;
26404 + if (set_mask & VXSM_CPU_ID) {
26405 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
26406 + cpus_and(vxi->sched.update, cpu_online_map,
26407 + vxi->sched.update);
26409 + vxi->sched.update = cpu_online_map;
26411 + /* forced reload? */
26412 + if (set_mask & VXSM_FORCE) {
26413 + for_each_cpu_mask(cpu, vxi->sched.update)
26414 + vx_update_sched_param(&vxi->sched,
26415 + &vx_per_cpu(vxi, sched_pc, cpu));
26416 + vxi->sched.update = CPU_MASK_NONE;
26419 + /* on UP we update immediately */
26420 + vx_update_sched_param(&vxi->sched,
26421 + &vx_per_cpu(vxi, sched_pc, 0));
26424 + spin_unlock(&vxi->sched.tokens_lock);
26429 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
26430 +#define COPY_PRI(C) C(prio_bias)
26431 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
26432 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
26433 + C(fill_rate[1]); C(interval[1]);
26435 +#define COPY_VALUE(name) vc_data.name = data->name
26437 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
26439 + struct vcmd_sched_v5 vc_data;
26441 + vc_data.mask = data->set_mask;
26442 + COPY_IDS(COPY_VALUE);
26443 + COPY_PRI(COPY_VALUE);
26444 + COPY_TOK(COPY_VALUE);
26445 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
26446 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
26447 + return do_set_sched(vxi, &vc_data);
26450 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
26452 + struct vcmd_set_sched_v4 vc_data;
26454 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26457 + return do_set_sched_v4(vxi, &vc_data);
26460 + /* latest interface is v5 */
26462 +int vc_set_sched(struct vx_info *vxi, void __user *data)
26464 + struct vcmd_sched_v5 vc_data;
26466 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26469 + return do_set_sched(vxi, &vc_data);
26473 +#define COPY_PRI(C) C(prio_bias)
26474 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
26475 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
26476 + C(fill_rate[1]); C(interval[1]);
26478 +#define COPY_VALUE(name) vc_data.name = data->name
26481 +int vc_get_sched(struct vx_info *vxi, void __user *data)
26483 + struct vcmd_sched_v5 vc_data;
26485 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26488 + if (vc_data.mask & VXSM_CPU_ID) {
26489 + int cpu = vc_data.cpu_id;
26490 + struct _vx_sched_pc *data;
26492 + if (!cpu_possible(cpu))
26495 + data = &vx_per_cpu(vxi, sched_pc, cpu);
26496 + COPY_TOK(COPY_VALUE);
26497 + COPY_PRI(COPY_VALUE);
26498 + COPY_FRI(COPY_VALUE);
26500 + if (data->flags & VXSF_IDLE_TIME)
26501 + vc_data.mask |= VXSM_IDLE_TIME;
26503 + struct _vx_sched *data = &vxi->sched;
26505 + COPY_TOK(COPY_VALUE);
26506 + COPY_PRI(COPY_VALUE);
26507 + COPY_FRI(COPY_VALUE);
26510 + if (vc_data.mask & VXSM_MSEC) {
26511 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
26512 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
26515 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26521 +int vc_sched_info(struct vx_info *vxi, void __user *data)
26523 + struct vcmd_sched_info vc_data;
26526 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26529 + cpu = vc_data.cpu_id;
26530 + if (!cpu_possible(cpu))
26534 + struct _vx_sched_pc *sched_pc =
26535 + &vx_per_cpu(vxi, sched_pc, cpu);
26537 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
26538 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
26539 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
26540 + vc_data.vavavoom = sched_pc->vavavoom;
26542 + vc_data.token_usec = ticks_to_usec(1);
26544 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26549 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
26550 --- linux-2.6.22.10/kernel/vserver/sched_init.h 1970-01-01 01:00:00 +0100
26551 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched_init.h 2007-08-05 20:53:13 +0200
26554 +static inline void vx_info_init_sched(struct _vx_sched *sched)
26556 + static struct lock_class_key tokens_lock_key;
26558 + /* scheduling; hard code starting values as constants */
26559 + sched->fill_rate[0] = 1;
26560 + sched->interval[0] = 4;
26561 + sched->fill_rate[1] = 1;
26562 + sched->interval[1] = 8;
26563 + sched->tokens = HZ >> 2;
26564 + sched->tokens_min = HZ >> 4;
26565 + sched->tokens_max = HZ >> 1;
26566 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
26567 + sched->prio_bias = 0;
26569 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
26573 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
26575 + sched_pc->fill_rate[0] = 1;
26576 + sched_pc->interval[0] = 4;
26577 + sched_pc->fill_rate[1] = 1;
26578 + sched_pc->interval[1] = 8;
26579 + sched_pc->tokens = HZ >> 2;
26580 + sched_pc->tokens_min = HZ >> 4;
26581 + sched_pc->tokens_max = HZ >> 1;
26582 + sched_pc->prio_bias = 0;
26583 + sched_pc->vavavoom = 0;
26584 + sched_pc->token_time = 0;
26585 + sched_pc->idle_time = 0;
26586 + sched_pc->norm_time = jiffies;
26588 + sched_pc->user_ticks = 0;
26589 + sched_pc->sys_ticks = 0;
26590 + sched_pc->hold_ticks = 0;
26593 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
26599 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
26603 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
26604 --- linux-2.6.22.10/kernel/vserver/sched_proc.h 1970-01-01 01:00:00 +0100
26605 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sched_proc.h 2007-08-05 20:53:13 +0200
26607 +#ifndef _VX_SCHED_PROC_H
26608 +#define _VX_SCHED_PROC_H
26612 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
26616 + length += sprintf(buffer,
26617 + "FillRate:\t%8d,%d\n"
26618 + "Interval:\t%8d,%d\n"
26619 + "TokensMin:\t%8d\n"
26620 + "TokensMax:\t%8d\n"
26621 + "PrioBias:\t%8d\n",
26622 + sched->fill_rate[0],
26623 + sched->fill_rate[1],
26624 + sched->interval[0],
26625 + sched->interval[1],
26626 + sched->tokens_min,
26627 + sched->tokens_max,
26628 + sched->prio_bias);
26633 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
26634 + char *buffer, int cpu)
26638 + length += sprintf(buffer + length,
26639 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
26640 + (unsigned long long)sched_pc->user_ticks,
26641 + (unsigned long long)sched_pc->sys_ticks,
26642 + (unsigned long long)sched_pc->hold_ticks,
26643 + sched_pc->token_time,
26644 + sched_pc->idle_time);
26645 + length += sprintf(buffer + length,
26646 + " %c%c %d %d %d %d/%d %d/%d",
26647 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
26648 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
26649 + sched_pc->tokens,
26650 + sched_pc->tokens_min,
26651 + sched_pc->tokens_max,
26652 + sched_pc->fill_rate[0],
26653 + sched_pc->interval[0],
26654 + sched_pc->fill_rate[1],
26655 + sched_pc->interval[1]);
26656 + length += sprintf(buffer + length,
26658 + sched_pc->prio_bias,
26659 + sched_pc->vavavoom);
26663 +#endif /* _VX_SCHED_PROC_H */
26664 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
26665 --- linux-2.6.22.10/kernel/vserver/signal.c 1970-01-01 01:00:00 +0100
26666 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/signal.c 2007-08-15 23:34:41 +0200
26669 + * linux/kernel/vserver/signal.c
26671 + * Virtual Server: Signal Support
26673 + * Copyright (C) 2003-2007 Herbert Pötzl
26675 + * V0.01 broken out from vcontext V0.05
26676 + * V0.02 changed vcmds to vxi arg
26677 + * V0.03 adjusted siginfo for kill
26681 +#include <asm/uaccess.h>
26683 +#include <linux/vs_context.h>
26684 +#include <linux/vserver/signal_cmd.h>
26687 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
26689 + int retval, count = 0;
26690 + struct task_struct *p;
26691 + struct siginfo *sip = SEND_SIG_PRIV;
26694 + vxdprintk(VXD_CBIT(misc, 4),
26695 + "vx_info_kill(%p[#%d],%d,%d)*",
26696 + vxi, vxi->vx_id, pid, sig);
26697 + read_lock(&tasklist_lock);
26701 + for_each_process(p) {
26704 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
26705 + (pid && vxi->vx_initpid == p->pid))
26708 + err = group_send_sig_info(sig, sip, p);
26710 + if (err != -EPERM)
26716 + if (vxi->vx_initpid) {
26717 + pid = vxi->vx_initpid;
26718 + /* for now, only SIGINT to private init ... */
26719 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
26720 + /* ... as long as there are tasks left */
26721 + (atomic_read(&vxi->vx_tasks) > 1))
26724 + /* fallthrough */
26726 + p = find_task_by_real_pid(pid);
26728 + if (vx_task_xid(p) == vxi->vx_id)
26729 + retval = group_send_sig_info(sig, sip, p);
26733 + read_unlock(&tasklist_lock);
26734 + vxdprintk(VXD_CBIT(misc, 4),
26735 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
26736 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
26740 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
26742 + struct vcmd_ctx_kill_v0 vc_data;
26744 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
26747 + /* special check to allow guest shutdown */
26748 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
26749 + /* forbid killall pid=0 when init is present */
26750 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
26751 + (vc_data.pid > 1)))
26754 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
26758 +static int __wait_exit(struct vx_info *vxi)
26760 + DECLARE_WAITQUEUE(wait, current);
26763 + add_wait_queue(&vxi->vx_wait, &wait);
26764 + set_current_state(TASK_INTERRUPTIBLE);
26767 + if (vx_info_state(vxi,
26768 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
26770 + if (signal_pending(current)) {
26771 + ret = -ERESTARTSYS;
26778 + set_current_state(TASK_RUNNING);
26779 + remove_wait_queue(&vxi->vx_wait, &wait);
26785 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
26787 + struct vcmd_wait_exit_v0 vc_data;
26790 + ret = __wait_exit(vxi);
26791 + vc_data.reboot_cmd = vxi->reboot_cmd;
26792 + vc_data.exit_code = vxi->exit_code;
26794 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
26799 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
26800 --- linux-2.6.22.10/kernel/vserver/space.c 1970-01-01 01:00:00 +0100
26801 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/space.c 2007-08-15 23:39:13 +0200
26804 + * linux/kernel/vserver/space.c
26806 + * Virtual Server: Context Space Support
26808 + * Copyright (C) 2003-2007 Herbert Pötzl
26810 + * V0.01 broken out from context.c 0.07
26811 + * V0.02 added task locking for namespace
26812 + * V0.03 broken out vx_enter_namespace
26813 + * V0.04 added *space support and commands
26817 +#include <linux/utsname.h>
26818 +#include <linux/nsproxy.h>
26819 +#include <linux/err.h>
26820 +#include <asm/uaccess.h>
26822 +#include <linux/vs_context.h>
26823 +#include <linux/vserver/space.h>
26824 +#include <linux/vserver/space_cmd.h>
26827 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
26828 +atomic_t vs_global_fs = ATOMIC_INIT(0);
26829 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
26830 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
26831 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
26834 +/* namespace functions */
26836 +#include <linux/mnt_namespace.h>
26838 +const struct vcmd_space_mask space_mask = {
26839 + .mask = CLONE_NEWNS |
26847 + * build a new nsproxy mix
26848 + * assumes that both proxies are 'const'
26849 + * does not touch nsproxy refcounts
26850 + * will hold a reference on the result.
26853 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
26854 + struct nsproxy *new_nsproxy, unsigned long mask)
26856 + struct mnt_namespace *old_ns;
26857 + struct uts_namespace *old_uts;
26858 + struct ipc_namespace *old_ipc;
26859 + struct nsproxy *nsproxy;
26861 + nsproxy = copy_nsproxy(old_nsproxy);
26865 + if (mask & CLONE_NEWNS) {
26866 + old_ns = nsproxy->mnt_ns;
26867 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
26868 + if (nsproxy->mnt_ns)
26869 + get_mnt_ns(nsproxy->mnt_ns);
26873 + if (mask & CLONE_NEWUTS) {
26874 + old_uts = nsproxy->uts_ns;
26875 + nsproxy->uts_ns = new_nsproxy->uts_ns;
26876 + if (nsproxy->uts_ns)
26877 + get_uts_ns(nsproxy->uts_ns);
26881 + if (mask & CLONE_NEWIPC) {
26882 + old_ipc = nsproxy->ipc_ns;
26883 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
26884 + if (nsproxy->ipc_ns)
26885 + get_ipc_ns(nsproxy->ipc_ns);
26890 + put_mnt_ns(old_ns);
26892 + put_uts_ns(old_uts);
26894 + put_ipc_ns(old_ipc);
26901 + * merge two nsproxy structs into a new one.
26902 + * will hold a reference on the result.
26906 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
26907 + struct nsproxy *proxy, unsigned long mask)
26909 + struct nsproxy null_proxy = { .mnt_ns = NULL };
26915 + /* vs_mix_nsproxy returns with reference */
26916 + return vs_mix_nsproxy(old ? old : &null_proxy,
26919 + get_nsproxy(proxy);
26924 + * merge two fs structs into a new one.
26925 + * will take a reference on the result.
26929 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
26930 + struct fs_struct *fs, unsigned long mask)
26932 + if (!(mask & CLONE_FS)) {
26934 + atomic_inc(&old->count);
26941 + return copy_fs_struct(fs);
26945 +int vx_enter_space(struct vx_info *vxi, unsigned long mask)
26947 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
26948 + struct fs_struct *fs, *fs_cur, *fs_new;
26951 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
26955 + mask = vxi->vx_nsmask;
26957 + if ((mask & vxi->vx_nsmask) != mask)
26960 + proxy = vxi->vx_nsproxy;
26963 + task_lock(current);
26964 + fs_cur = current->fs;
26965 + atomic_inc(&fs_cur->count);
26966 + proxy_cur = current->nsproxy;
26967 + get_nsproxy(proxy_cur);
26968 + task_unlock(current);
26970 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
26971 + if (IS_ERR(fs_new)) {
26972 + ret = PTR_ERR(fs_new);
26976 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
26977 + if (IS_ERR(proxy_new)) {
26978 + ret = PTR_ERR(proxy_new);
26982 + fs_new = xchg(¤t->fs, fs_new);
26983 + proxy_new = xchg(¤t->nsproxy, proxy_new);
26987 + put_nsproxy(proxy_new);
26990 + put_fs_struct(fs_new);
26993 + put_nsproxy(proxy_cur);
26995 + put_fs_struct(fs_cur);
27000 +int vx_set_space(struct vx_info *vxi, unsigned long mask)
27002 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
27003 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
27007 + mask = space_mask.mask;
27009 + if ((mask & space_mask.mask) != mask)
27012 + proxy_vxi = vxi->vx_nsproxy;
27013 + fs_vxi = vxi->vx_fs;
27015 + task_lock(current);
27016 + fs_cur = current->fs;
27017 + atomic_inc(&fs_cur->count);
27018 + proxy_cur = current->nsproxy;
27019 + get_nsproxy(proxy_cur);
27020 + task_unlock(current);
27022 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
27023 + if (IS_ERR(fs_new)) {
27024 + ret = PTR_ERR(fs_new);
27028 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
27029 + if (IS_ERR(proxy_new)) {
27030 + ret = PTR_ERR(proxy_new);
27034 + fs_new = xchg(&vxi->vx_fs, fs_new);
27035 + proxy_new = xchg(&vxi->vx_nsproxy, proxy_new);
27036 + vxi->vx_nsmask |= mask;
27040 + put_nsproxy(proxy_new);
27043 + put_fs_struct(fs_new);
27046 + put_nsproxy(proxy_cur);
27048 + put_fs_struct(fs_cur);
27053 +int vc_enter_space(struct vx_info *vxi, void __user *data)
27055 + struct vcmd_space_mask vc_data = { .mask = 0 };
27057 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
27060 + return vx_enter_space(vxi, vc_data.mask);
27063 +int vc_set_space(struct vx_info *vxi, void __user *data)
27065 + struct vcmd_space_mask vc_data = { .mask = 0 };
27067 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
27070 + return vx_set_space(vxi, vc_data.mask);
27073 +int vc_get_space_mask(struct vx_info *vxi, void __user *data)
27075 + if (copy_to_user(data, &space_mask, sizeof(space_mask)))
27080 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
27081 --- linux-2.6.22.10/kernel/vserver/switch.c 1970-01-01 01:00:00 +0100
27082 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/switch.c 2007-10-25 17:05:55 +0200
27085 + * linux/kernel/vserver/switch.c
27087 + * Virtual Server: Syscall Switch
27089 + * Copyright (C) 2003-2007 Herbert Pötzl
27091 + * V0.01 syscall switch
27092 + * V0.02 added signal to context
27093 + * V0.03 added rlimit functions
27094 + * V0.04 added iattr, task/xid functions
27095 + * V0.05 added debug/history stuff
27096 + * V0.06 added compat32 layer
27097 + * V0.07 vcmd args and perms
27098 + * V0.08 added status commands
27099 + * V0.09 added tag commands
27100 + * V0.10 added oom bias
27101 + * V0.11 added device commands
27105 +#include <linux/vs_context.h>
27106 +#include <linux/vs_network.h>
27107 +#include <linux/vserver/switch.h>
27109 +#include "vci_config.h"
27113 +int vc_get_version(uint32_t id)
27115 + return VCI_VERSION;
27119 +int vc_get_vci(uint32_t id)
27121 + return vci_kernel_config();
27124 +#include <linux/vserver/context_cmd.h>
27125 +#include <linux/vserver/cvirt_cmd.h>
27126 +#include <linux/vserver/cacct_cmd.h>
27127 +#include <linux/vserver/limit_cmd.h>
27128 +#include <linux/vserver/network_cmd.h>
27129 +#include <linux/vserver/sched_cmd.h>
27130 +#include <linux/vserver/debug_cmd.h>
27131 +#include <linux/vserver/inode_cmd.h>
27132 +#include <linux/vserver/dlimit_cmd.h>
27133 +#include <linux/vserver/signal_cmd.h>
27134 +#include <linux/vserver/space_cmd.h>
27135 +#include <linux/vserver/tag_cmd.h>
27136 +#include <linux/vserver/device_cmd.h>
27138 +#include <linux/vserver/inode.h>
27139 +#include <linux/vserver/dlimit.h>
27142 +#ifdef CONFIG_COMPAT
27143 +#define __COMPAT(name, id, data, compat) \
27144 + (compat) ? name ## _x32(id, data) : name(id, data)
27145 +#define __COMPAT_NO_ID(name, data, compat) \
27146 + (compat) ? name ## _x32(data) : name(data)
27148 +#define __COMPAT(name, id, data, compat) \
27150 +#define __COMPAT_NO_ID(name, data, compat) \
27156 +long do_vcmd(uint32_t cmd, uint32_t id,
27157 + struct vx_info *vxi, struct nx_info *nxi,
27158 + void __user *data, int compat)
27162 + case VCMD_get_version:
27163 + return vc_get_version(id);
27164 + case VCMD_get_vci:
27165 + return vc_get_vci(id);
27167 + case VCMD_task_xid:
27168 + return vc_task_xid(id);
27169 + case VCMD_vx_info:
27170 + return vc_vx_info(vxi, data);
27172 + case VCMD_task_nid:
27173 + return vc_task_nid(id);
27174 + case VCMD_nx_info:
27175 + return vc_nx_info(nxi, data);
27177 + case VCMD_task_tag:
27178 + return vc_task_tag(id);
27180 + /* this is version 1 */
27181 + case VCMD_set_space:
27182 + return vc_set_space(vxi, data);
27184 + case VCMD_get_space_mask:
27185 + return vc_get_space_mask(vxi, data);
27187 +#ifdef CONFIG_IA32_EMULATION
27188 + case VCMD_get_rlimit:
27189 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
27190 + case VCMD_set_rlimit:
27191 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
27193 + case VCMD_get_rlimit:
27194 + return vc_get_rlimit(vxi, data);
27195 + case VCMD_set_rlimit:
27196 + return vc_set_rlimit(vxi, data);
27198 + case VCMD_get_rlimit_mask:
27199 + return vc_get_rlimit_mask(id, data);
27200 + case VCMD_reset_minmax:
27201 + return vc_reset_minmax(vxi, data);
27203 + case VCMD_get_vhi_name:
27204 + return vc_get_vhi_name(vxi, data);
27205 + case VCMD_set_vhi_name:
27206 + return vc_set_vhi_name(vxi, data);
27208 + case VCMD_ctx_stat:
27209 + return vc_ctx_stat(vxi, data);
27210 + case VCMD_virt_stat:
27211 + return vc_virt_stat(vxi, data);
27212 + case VCMD_sock_stat:
27213 + return vc_sock_stat(vxi, data);
27214 + case VCMD_rlimit_stat:
27215 + return vc_rlimit_stat(vxi, data);
27217 + case VCMD_set_cflags:
27218 + return vc_set_cflags(vxi, data);
27219 + case VCMD_get_cflags:
27220 + return vc_get_cflags(vxi, data);
27222 + /* this is version 1 */
27223 + case VCMD_set_ccaps:
27224 + return vc_set_ccaps(vxi, data);
27225 + /* this is version 1 */
27226 + case VCMD_get_ccaps:
27227 + return vc_get_ccaps(vxi, data);
27228 + case VCMD_set_bcaps:
27229 + return vc_set_bcaps(vxi, data);
27230 + case VCMD_get_bcaps:
27231 + return vc_get_bcaps(vxi, data);
27233 + case VCMD_set_badness:
27234 + return vc_set_badness(vxi, data);
27235 + case VCMD_get_badness:
27236 + return vc_get_badness(vxi, data);
27238 + case VCMD_set_nflags:
27239 + return vc_set_nflags(nxi, data);
27240 + case VCMD_get_nflags:
27241 + return vc_get_nflags(nxi, data);
27243 + case VCMD_set_ncaps:
27244 + return vc_set_ncaps(nxi, data);
27245 + case VCMD_get_ncaps:
27246 + return vc_get_ncaps(nxi, data);
27248 + case VCMD_set_sched_v4:
27249 + return vc_set_sched_v4(vxi, data);
27250 + /* this is version 5 */
27251 + case VCMD_set_sched:
27252 + return vc_set_sched(vxi, data);
27253 + case VCMD_get_sched:
27254 + return vc_get_sched(vxi, data);
27255 + case VCMD_sched_info:
27256 + return vc_sched_info(vxi, data);
27258 + case VCMD_add_dlimit:
27259 + return __COMPAT(vc_add_dlimit, id, data, compat);
27260 + case VCMD_rem_dlimit:
27261 + return __COMPAT(vc_rem_dlimit, id, data, compat);
27262 + case VCMD_set_dlimit:
27263 + return __COMPAT(vc_set_dlimit, id, data, compat);
27264 + case VCMD_get_dlimit:
27265 + return __COMPAT(vc_get_dlimit, id, data, compat);
27267 + case VCMD_ctx_kill:
27268 + return vc_ctx_kill(vxi, data);
27270 + case VCMD_wait_exit:
27271 + return vc_wait_exit(vxi, data);
27273 + case VCMD_get_iattr:
27274 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
27275 + case VCMD_set_iattr:
27276 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
27278 + case VCMD_fget_iattr:
27279 + return vc_fget_iattr(id, data);
27280 + case VCMD_fset_iattr:
27281 + return vc_fset_iattr(id, data);
27283 + case VCMD_enter_space_v0:
27284 + return vc_enter_space(vxi, NULL);
27285 + /* this is version 1 */
27286 + case VCMD_enter_space:
27287 + return vc_enter_space(vxi, data);
27289 + case VCMD_ctx_create_v0:
27290 + return vc_ctx_create(id, NULL);
27291 + case VCMD_ctx_create:
27292 + return vc_ctx_create(id, data);
27293 + case VCMD_ctx_migrate_v0:
27294 + return vc_ctx_migrate(vxi, NULL);
27295 + case VCMD_ctx_migrate:
27296 + return vc_ctx_migrate(vxi, data);
27298 + case VCMD_net_create_v0:
27299 + return vc_net_create(id, NULL);
27300 + case VCMD_net_create:
27301 + return vc_net_create(id, data);
27302 + case VCMD_net_migrate:
27303 + return vc_net_migrate(nxi, data);
27305 + case VCMD_tag_migrate:
27306 + return vc_tag_migrate(id);
27308 + case VCMD_net_add:
27309 + return vc_net_add(nxi, data);
27310 + case VCMD_net_remove:
27311 + return vc_net_remove(nxi, data);
27313 + case VCMD_net_add_ipv4:
27314 + return vc_net_add_ipv4(nxi, data);
27315 + case VCMD_net_remove_ipv4:
27316 + return vc_net_remove_ipv4(nxi, data);
27317 +#ifdef CONFIG_IPV6
27318 + case VCMD_net_add_ipv6:
27319 + return vc_net_add_ipv6(nxi, data);
27320 + case VCMD_net_remove_ipv6:
27321 + return vc_net_remove_ipv6(nxi, data);
27323 +/* case VCMD_add_match_ipv4:
27324 + return vc_add_match_ipv4(nxi, data);
27325 + case VCMD_get_match_ipv4:
27326 + return vc_get_match_ipv4(nxi, data);
27327 +#ifdef CONFIG_IPV6
27328 + case VCMD_add_match_ipv6:
27329 + return vc_add_match_ipv6(nxi, data);
27330 + case VCMD_get_match_ipv6:
27331 + return vc_get_match_ipv6(nxi, data);
27334 +#ifdef CONFIG_VSERVER_DEVICE
27335 + case VCMD_set_mapping:
27336 + return __COMPAT(vc_set_mapping, vxi, data, compat);
27337 + case VCMD_unset_mapping:
27338 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
27340 +#ifdef CONFIG_VSERVER_HISTORY
27341 + case VCMD_dump_history:
27342 + return vc_dump_history(id);
27343 + case VCMD_read_history:
27344 + return __COMPAT(vc_read_history, id, data, compat);
27346 +#ifdef CONFIG_VSERVER_MONITOR
27347 + case VCMD_read_monitor:
27348 + return __COMPAT(vc_read_monitor, id, data, compat);
27351 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
27352 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
27358 +#define __VCMD(vcmd, _perm, _args, _flags) \
27359 + case VCMD_ ## vcmd: perm = _perm; \
27360 + args = _args; flags = _flags; break
27363 +#define VCA_NONE 0x00
27364 +#define VCA_VXI 0x01
27365 +#define VCA_NXI 0x02
27367 +#define VCF_NONE 0x00
27368 +#define VCF_INFO 0x01
27369 +#define VCF_ADMIN 0x02
27370 +#define VCF_ARES 0x06 /* includes admin */
27371 +#define VCF_SETUP 0x08
27373 +#define VCF_ZIDOK 0x10 /* zero id okay */
27377 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
27380 + int permit = -1, state = 0;
27381 + int perm = -1, args = 0, flags = 0;
27382 + struct vx_info *vxi = NULL;
27383 + struct nx_info *nxi = NULL;
27386 + /* unpriviledged commands */
27387 + __VCMD(get_version, 0, VCA_NONE, 0);
27388 + __VCMD(get_vci, 0, VCA_NONE, 0);
27389 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
27390 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
27392 + /* info commands */
27393 + __VCMD(task_xid, 2, VCA_NONE, 0);
27394 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
27395 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
27396 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
27397 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
27398 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
27399 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
27400 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
27401 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
27403 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
27404 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
27405 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
27406 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
27408 + __VCMD(task_nid, 2, VCA_NONE, 0);
27409 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
27410 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
27411 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
27413 + __VCMD(task_tag, 2, VCA_NONE, 0);
27415 + __VCMD(get_iattr, 2, VCA_NONE, 0);
27416 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
27417 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
27418 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
27419 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
27421 + /* lower admin commands */
27422 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
27423 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
27424 + __VCMD(ctx_create, 5, VCA_NONE, 0);
27425 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
27426 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
27427 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
27428 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
27430 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
27431 + __VCMD(net_create, 5, VCA_NONE, 0);
27432 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
27434 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
27436 + /* higher admin commands */
27437 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
27438 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27440 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27441 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27442 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27443 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27445 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27446 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27447 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27448 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
27450 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
27451 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
27452 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27453 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27454 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27455 + __VCMD(net_remove_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27456 +#ifdef CONFIG_IPV6
27457 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27458 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
27460 + __VCMD(set_iattr, 7, VCA_NONE, 0);
27461 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
27462 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
27463 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
27464 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
27466 +#ifdef CONFIG_VSERVER_DEVICE
27467 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
27468 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
27470 + /* debug level admin commands */
27471 +#ifdef CONFIG_VSERVER_HISTORY
27472 + __VCMD(dump_history, 9, VCA_NONE, 0);
27473 + __VCMD(read_history, 9, VCA_NONE, 0);
27475 +#ifdef CONFIG_VSERVER_MONITOR
27476 + __VCMD(read_monitor, 9, VCA_NONE, 0);
27483 + vxdprintk(VXD_CBIT(switch, 0),
27484 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
27485 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
27486 + VC_VERSION(cmd), id, data, compat,
27487 + perm, args, flags);
27494 + if (!capable(CAP_CONTEXT))
27498 + /* moved here from the individual commands */
27500 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
27504 + /* vcmd involves resource management */
27506 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
27510 + /* various legacy exceptions */
27512 + /* will go away when spectator is a cap */
27513 + case VCMD_ctx_migrate_v0:
27514 + case VCMD_ctx_migrate:
27516 + current->xid = 1;
27522 + /* will go away when spectator is a cap */
27523 + case VCMD_net_migrate:
27525 + current->nid = 1;
27532 + /* vcmds are fine by default */
27535 + /* admin type vcmds require admin ... */
27536 + if (flags & VCF_ADMIN)
27537 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
27539 + /* ... but setup type vcmds override that */
27540 + if (!permit && (flags & VCF_SETUP))
27541 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
27549 + if (!id && (flags & VCF_ZIDOK))
27553 + if (args & VCA_VXI) {
27554 + vxi = lookup_vx_info(id);
27558 + if ((flags & VCF_ADMIN) &&
27559 + /* special case kill for shutdown */
27560 + (cmd != VCMD_ctx_kill) &&
27561 + /* can context be administrated? */
27562 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
27568 + if (args & VCA_NXI) {
27569 + nxi = lookup_nx_info(id);
27573 + if ((flags & VCF_ADMIN) &&
27574 + /* can context be administrated? */
27575 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
27582 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
27585 + if ((args & VCA_NXI) && nxi)
27586 + put_nx_info(nxi);
27588 + if ((args & VCA_VXI) && vxi)
27589 + put_vx_info(vxi);
27591 + vxdprintk(VXD_CBIT(switch, 1),
27592 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
27593 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
27594 + VC_VERSION(cmd), ret, ret, state, permit);
27599 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
27601 + return do_vserver(cmd, id, data, 0);
27604 +#ifdef CONFIG_COMPAT
27607 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
27609 + return do_vserver(cmd, id, data, 1);
27612 +#endif /* CONFIG_COMPAT */
27613 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
27614 --- linux-2.6.22.10/kernel/vserver/sysctl.c 1970-01-01 01:00:00 +0100
27615 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/sysctl.c 2007-08-15 23:42:57 +0200
27618 + * kernel/vserver/sysctl.c
27620 + * Virtual Context Support
27622 + * Copyright (C) 2004-2007 Herbert Pötzl
27624 + * V0.01 basic structure
27628 +#include <linux/module.h>
27629 +#include <linux/ctype.h>
27630 +#include <linux/sysctl.h>
27631 +#include <linux/parser.h>
27632 +#include <asm/uaccess.h>
27635 +#define CTL_VSERVER 4242 /* unused? */
27638 + CTL_DEBUG_ERROR = 0,
27639 + CTL_DEBUG_SWITCH = 1,
27654 +unsigned int vx_debug_switch = 0;
27655 +unsigned int vx_debug_xid = 0;
27656 +unsigned int vx_debug_nid = 0;
27657 +unsigned int vx_debug_tag = 0;
27658 +unsigned int vx_debug_net = 0;
27659 +unsigned int vx_debug_limit = 0;
27660 +unsigned int vx_debug_cres = 0;
27661 +unsigned int vx_debug_dlim = 0;
27662 +unsigned int vx_debug_quota = 0;
27663 +unsigned int vx_debug_cvirt = 0;
27664 +unsigned int vx_debug_space = 0;
27665 +unsigned int vx_debug_misc = 0;
27668 +static struct ctl_table_header *vserver_table_header;
27669 +static ctl_table vserver_table[];
27672 +void vserver_register_sysctl(void)
27674 + if (!vserver_table_header) {
27675 + vserver_table_header = register_sysctl_table(vserver_table);
27680 +void vserver_unregister_sysctl(void)
27682 + if (vserver_table_header) {
27683 + unregister_sysctl_table(vserver_table_header);
27684 + vserver_table_header = NULL;
27689 +static int proc_dodebug(ctl_table *table, int write,
27690 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
27692 + char tmpbuf[20], *p, c;
27693 + unsigned int value;
27694 + size_t left, len;
27696 + if ((*ppos && !write) || !*lenp) {
27704 + if (!access_ok(VERIFY_READ, buffer, left))
27706 + p = (char *)buffer;
27707 + while (left && __get_user(c, p) >= 0 && isspace(c))
27712 + if (left > sizeof(tmpbuf) - 1)
27714 + if (copy_from_user(tmpbuf, p, left))
27716 + tmpbuf[left] = '\0';
27718 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
27719 + value = 10 * value + (*p - '0');
27720 + if (*p && !isspace(*p))
27722 + while (left && isspace(*p))
27724 + *(unsigned int *)table->data = value;
27726 + if (!access_ok(VERIFY_WRITE, buffer, left))
27728 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
27731 + if (__copy_to_user(buffer, tmpbuf, len))
27733 + if ((left -= len) > 0) {
27734 + if (put_user('\n', (char *)buffer + len))
27747 +#define CTL_ENTRY(ctl, name) \
27749 + .ctl_name = ctl, \
27750 + .procname = #name, \
27751 + .data = &vx_ ## name, \
27752 + .maxlen = sizeof(int), \
27754 + .proc_handler = &proc_dodebug \
27757 +static ctl_table debug_table[] = {
27758 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
27759 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
27760 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
27761 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
27762 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
27763 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
27764 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
27765 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
27766 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
27767 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
27768 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
27769 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
27770 + { .ctl_name = 0 }
27773 +static ctl_table vserver_table[] = {
27775 + .ctl_name = CTL_VSERVER,
27776 + .procname = "vserver",
27778 + .child = debug_table
27780 + { .ctl_name = 0 }
27784 +static match_table_t tokens = {
27785 + { CTL_DEBUG_SWITCH, "switch=%x" },
27786 + { CTL_DEBUG_XID, "xid=%x" },
27787 + { CTL_DEBUG_NID, "nid=%x" },
27788 + { CTL_DEBUG_TAG, "tag=%x" },
27789 + { CTL_DEBUG_NET, "net=%x" },
27790 + { CTL_DEBUG_LIMIT, "limit=%x" },
27791 + { CTL_DEBUG_CRES, "cres=%x" },
27792 + { CTL_DEBUG_DLIM, "dlim=%x" },
27793 + { CTL_DEBUG_QUOTA, "quota=%x" },
27794 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
27795 + { CTL_DEBUG_SPACE, "space=%x" },
27796 + { CTL_DEBUG_MISC, "misc=%x" },
27797 + { CTL_DEBUG_ERROR, NULL }
27800 +#define HANDLE_CASE(id, name, val) \
27801 + case CTL_DEBUG_ ## id: \
27802 + vx_debug_ ## name = val; \
27803 + printk("vs_debug_" #name "=0x%x\n", val); \
27807 +static int __init vs_debug_setup(char *str)
27812 + printk("vs_debug_setup(%s)\n", str);
27813 + while ((p = strsep(&str, ",")) != NULL) {
27814 + substring_t args[MAX_OPT_ARGS];
27815 + unsigned int value;
27820 + token = match_token(p, tokens, args);
27821 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
27824 + HANDLE_CASE(SWITCH, switch, value);
27825 + HANDLE_CASE(XID, xid, value);
27826 + HANDLE_CASE(NID, nid, value);
27827 + HANDLE_CASE(TAG, tag, value);
27828 + HANDLE_CASE(NET, net, value);
27829 + HANDLE_CASE(LIMIT, limit, value);
27830 + HANDLE_CASE(CRES, cres, value);
27831 + HANDLE_CASE(DLIM, dlim, value);
27832 + HANDLE_CASE(QUOTA, quota, value);
27833 + HANDLE_CASE(CVIRT, cvirt, value);
27834 + HANDLE_CASE(SPACE, space, value);
27835 + HANDLE_CASE(MISC, misc, value);
27844 +__setup("vsdebug=", vs_debug_setup);
27848 +EXPORT_SYMBOL_GPL(vx_debug_switch);
27849 +EXPORT_SYMBOL_GPL(vx_debug_xid);
27850 +EXPORT_SYMBOL_GPL(vx_debug_nid);
27851 +EXPORT_SYMBOL_GPL(vx_debug_net);
27852 +EXPORT_SYMBOL_GPL(vx_debug_limit);
27853 +EXPORT_SYMBOL_GPL(vx_debug_cres);
27854 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
27855 +EXPORT_SYMBOL_GPL(vx_debug_quota);
27856 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
27857 +EXPORT_SYMBOL_GPL(vx_debug_space);
27858 +EXPORT_SYMBOL_GPL(vx_debug_misc);
27860 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
27861 --- linux-2.6.22.10/kernel/vserver/tag.c 1970-01-01 01:00:00 +0100
27862 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/tag.c 2007-10-05 14:54:36 +0200
27865 + * linux/kernel/vserver/tag.c
27867 + * Virtual Server: Shallow Tag Space
27869 + * Copyright (C) 2007 Herbert Pötzl
27871 + * V0.01 basic implementation
27875 +#include <linux/sched.h>
27876 +#include <linux/vserver/debug.h>
27877 +#include <linux/vs_tag.h>
27879 +#include <linux/vserver/tag_cmd.h>
27882 +int dx_migrate_task(struct task_struct *p, tag_t tag)
27887 + vxdprintk(VXD_CBIT(tag, 5),
27888 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
27894 + vxdprintk(VXD_CBIT(tag, 5),
27895 + "moved task %p into [#%d]", p, tag);
27899 +/* vserver syscall commands below here */
27901 +/* taks xid and vx_info functions */
27904 +int vc_task_tag(uint32_t id)
27909 + struct task_struct *tsk;
27910 + read_lock(&tasklist_lock);
27911 + tsk = find_task_by_real_pid(id);
27912 + tag = (tsk) ? tsk->tag : -ESRCH;
27913 + read_unlock(&tasklist_lock);
27915 + tag = dx_current_tag();
27920 +int vc_tag_migrate(uint32_t tag)
27922 + return dx_migrate_task(current, tag & 0xFFFF);
27926 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
27927 --- linux-2.6.22.10/kernel/vserver/vci_config.h 1970-01-01 01:00:00 +0100
27928 +++ linux-2.6.22.10-vs2.3.0.29/kernel/vserver/vci_config.h 2007-08-16 03:56:22 +0200
27931 +/* interface version */
27933 +#define VCI_VERSION 0x00020302
27937 + VCI_KCBIT_NO_DYNAMIC = 0,
27939 + VCI_KCBIT_PROC_SECURE = 4,
27940 + VCI_KCBIT_HARDCPU = 5,
27941 + VCI_KCBIT_IDLELIMIT = 6,
27942 + VCI_KCBIT_IDLETIME = 7,
27944 + VCI_KCBIT_COWBL = 8,
27945 + VCI_KCBIT_FULLCOWBL = 9,
27946 + VCI_KCBIT_SPACES = 10,
27947 + VCI_KCBIT_NETV2 = 11,
27949 + VCI_KCBIT_DEBUG = 16,
27950 + VCI_KCBIT_HISTORY = 20,
27951 + VCI_KCBIT_TAGGED = 24,
27952 + VCI_KCBIT_PPTAG = 28,
27954 + VCI_KCBIT_MORE = 31,
27958 +static inline uint32_t vci_kernel_config(void)
27961 + (1 << VCI_KCBIT_NO_DYNAMIC) |
27963 + /* configured features */
27964 +#ifdef CONFIG_VSERVER_PROC_SECURE
27965 + (1 << VCI_KCBIT_PROC_SECURE) |
27967 +#ifdef CONFIG_VSERVER_HARDCPU
27968 + (1 << VCI_KCBIT_HARDCPU) |
27970 +#ifdef CONFIG_VSERVER_IDLELIMIT
27971 + (1 << VCI_KCBIT_IDLELIMIT) |
27973 +#ifdef CONFIG_VSERVER_IDLETIME
27974 + (1 << VCI_KCBIT_IDLETIME) |
27976 +#ifdef CONFIG_VSERVER_COWBL
27977 + (1 << VCI_KCBIT_COWBL) |
27978 + (1 << VCI_KCBIT_FULLCOWBL) |
27980 + (1 << VCI_KCBIT_SPACES) |
27981 + (1 << VCI_KCBIT_NETV2) |
27983 + /* debug options */
27984 +#ifdef CONFIG_VSERVER_DEBUG
27985 + (1 << VCI_KCBIT_DEBUG) |
27987 +#ifdef CONFIG_VSERVER_HISTORY
27988 + (1 << VCI_KCBIT_HISTORY) |
27991 + /* inode context tagging */
27992 +#if defined(CONFIG_TAGGING_NONE)
27993 + (0 << VCI_KCBIT_TAGGED) |
27994 +#elif defined(CONFIG_TAGGING_UID16)
27995 + (1 << VCI_KCBIT_TAGGED) |
27996 +#elif defined(CONFIG_TAGGING_GID16)
27997 + (2 << VCI_KCBIT_TAGGED) |
27998 +#elif defined(CONFIG_TAGGING_ID24)
27999 + (3 << VCI_KCBIT_TAGGED) |
28000 +#elif defined(CONFIG_TAGGING_INTERN)
28001 + (4 << VCI_KCBIT_TAGGED) |
28002 +#elif defined(CONFIG_TAGGING_RUNTIME)
28003 + (5 << VCI_KCBIT_TAGGED) |
28005 + (7 << VCI_KCBIT_TAGGED) |
28007 + (1 << VCI_KCBIT_PPTAG) |
28011 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
28012 --- linux-2.6.22.10/mm/filemap_xip.c 2007-07-09 13:20:04 +0200
28013 +++ linux-2.6.22.10-vs2.3.0.29/mm/filemap_xip.c 2007-08-05 20:53:13 +0200
28015 #include <linux/uio.h>
28016 #include <linux/rmap.h>
28017 #include <linux/sched.h>
28018 +#include <linux/vs_memory.h>
28019 #include <asm/tlbflush.h>
28020 #include "filemap.h"
28022 diff -NurpP --minimal linux-2.6.22.10/mm/fremap.c linux-2.6.22.10-vs2.3.0.29/mm/fremap.c
28023 --- linux-2.6.22.10/mm/fremap.c 2007-02-06 03:01:56 +0100
28024 +++ linux-2.6.22.10-vs2.3.0.29/mm/fremap.c 2007-08-05 20:53:13 +0200
28026 #include <linux/rmap.h>
28027 #include <linux/module.h>
28028 #include <linux/syscalls.h>
28029 +#include <linux/vs_memory.h>
28031 #include <asm/mmu_context.h>
28032 #include <asm/cacheflush.h>
28033 @@ -74,6 +75,8 @@ int install_page(struct mm_struct *mm, s
28035 if (page_mapcount(page) > INT_MAX/2)
28037 + if (!vx_rss_avail(mm, 1))
28040 if (pte_none(*pte) || !zap_pte(mm, vma, addr, pte))
28041 inc_mm_counter(mm, file_rss);
28042 diff -NurpP --minimal linux-2.6.22.10/mm/hugetlb.c linux-2.6.22.10-vs2.3.0.29/mm/hugetlb.c
28043 --- linux-2.6.22.10/mm/hugetlb.c 2007-10-30 01:57:15 +0100
28044 +++ linux-2.6.22.10-vs2.3.0.29/mm/hugetlb.c 2007-08-11 22:41:51 +0200
28046 #include <asm/pgtable.h>
28048 #include <linux/hugetlb.h>
28049 +#include <linux/vs_memory.h>
28050 #include "internal.h"
28052 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
28053 diff -NurpP --minimal linux-2.6.22.10/mm/memory.c linux-2.6.22.10-vs2.3.0.29/mm/memory.c
28054 --- linux-2.6.22.10/mm/memory.c 2007-07-09 13:20:04 +0200
28055 +++ linux-2.6.22.10-vs2.3.0.29/mm/memory.c 2007-08-05 20:53:13 +0200
28056 @@ -498,6 +498,9 @@ static int copy_pte_range(struct mm_stru
28060 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
28064 rss[1] = rss[0] = 0;
28065 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
28066 @@ -2157,6 +2160,11 @@ static int do_swap_page(struct mm_struct
28067 count_vm_event(PGMAJFAULT);
28070 + if (!vx_rss_avail(mm, 1)) {
28071 + ret = VM_FAULT_OOM;
28075 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
28076 mark_page_accessed(page);
28078 @@ -2229,6 +2237,8 @@ static int do_anonymous_page(struct mm_s
28079 /* Allocate our own private page. */
28080 pte_unmap(page_table);
28082 + if (!vx_rss_avail(mm, 1))
28084 if (unlikely(anon_vma_prepare(vma)))
28086 page = alloc_zeroed_user_highpage(vma, address);
28087 @@ -2302,6 +2312,9 @@ static int do_no_page(struct mm_struct *
28088 pte_unmap(page_table);
28089 BUG_ON(vma->vm_flags & VM_PFNMAP);
28091 + if (!vx_rss_avail(mm, 1))
28092 + return VM_FAULT_OOM;
28094 if (vma->vm_file) {
28095 mapping = vma->vm_file->f_mapping;
28096 sequence = mapping->truncate_count;
28097 @@ -2527,6 +2540,7 @@ static inline int handle_pte_fault(struc
28101 + int ret, type = VXPT_UNKNOWN;
28104 if (!pte_present(entry)) {
28105 @@ -2555,9 +2569,12 @@ static inline int handle_pte_fault(struc
28106 if (unlikely(!pte_same(*pte, entry)))
28108 if (write_access) {
28109 - if (!pte_write(entry))
28110 - return do_wp_page(mm, vma, address,
28111 + if (!pte_write(entry)) {
28112 + ret = do_wp_page(mm, vma, address,
28113 pte, pmd, ptl, entry);
28114 + type = VXPT_WRITE;
28117 entry = pte_mkdirty(entry);
28119 entry = pte_mkyoung(entry);
28120 @@ -2576,7 +2593,10 @@ static inline int handle_pte_fault(struc
28123 pte_unmap_unlock(pte, ptl);
28124 - return VM_FAULT_MINOR;
28125 + ret = VM_FAULT_MINOR;
28127 + vx_page_fault(mm, vma, type, ret);
28132 diff -NurpP --minimal linux-2.6.22.10/mm/mlock.c linux-2.6.22.10-vs2.3.0.29/mm/mlock.c
28133 --- linux-2.6.22.10/mm/mlock.c 2007-10-30 01:57:15 +0100
28134 +++ linux-2.6.22.10-vs2.3.0.29/mm/mlock.c 2007-08-11 22:41:51 +0200
28136 #include <linux/syscalls.h>
28137 #include <linux/sched.h>
28138 #include <linux/module.h>
28139 +#include <linux/vs_memory.h>
28141 int can_do_mlock(void)
28143 @@ -76,7 +77,7 @@ success:
28144 ret = make_pages_present(start, end);
28147 - mm->locked_vm -= pages;
28148 + vx_vmlocked_sub(mm, pages);
28150 if (ret == -ENOMEM)
28152 @@ -134,7 +135,7 @@ static int do_mlock(unsigned long start,
28154 asmlinkage long sys_mlock(unsigned long start, size_t len)
28156 - unsigned long locked;
28157 + unsigned long locked, grow;
28158 unsigned long lock_limit;
28159 int error = -ENOMEM;
28161 @@ -145,8 +146,10 @@ asmlinkage long sys_mlock(unsigned long
28162 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
28163 start &= PAGE_MASK;
28165 - locked = len >> PAGE_SHIFT;
28166 - locked += current->mm->locked_vm;
28167 + grow = len >> PAGE_SHIFT;
28168 + if (!vx_vmlocked_avail(current->mm, grow))
28170 + locked = current->mm->locked_vm + grow;
28172 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
28173 lock_limit >>= PAGE_SHIFT;
28174 @@ -154,6 +157,7 @@ asmlinkage long sys_mlock(unsigned long
28175 /* check against resource limits */
28176 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
28177 error = do_mlock(start, len, 1);
28179 up_write(¤t->mm->mmap_sem);
28182 @@ -213,6 +217,8 @@ asmlinkage long sys_mlockall(int flags)
28183 lock_limit >>= PAGE_SHIFT;
28186 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
28188 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
28189 capable(CAP_IPC_LOCK))
28190 ret = do_mlockall(flags);
28191 diff -NurpP --minimal linux-2.6.22.10/mm/mmap.c linux-2.6.22.10-vs2.3.0.29/mm/mmap.c
28192 --- linux-2.6.22.10/mm/mmap.c 2007-07-09 13:20:04 +0200
28193 +++ linux-2.6.22.10-vs2.3.0.29/mm/mmap.c 2007-08-05 20:53:13 +0200
28194 @@ -1144,10 +1144,10 @@ munmap_back:
28195 kmem_cache_free(vm_area_cachep, vma);
28198 - mm->total_vm += len >> PAGE_SHIFT;
28199 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28200 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
28201 if (vm_flags & VM_LOCKED) {
28202 - mm->locked_vm += len >> PAGE_SHIFT;
28203 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
28204 make_pages_present(addr, addr + len);
28206 if (flags & MAP_POPULATE) {
28207 @@ -1502,9 +1502,9 @@ static int acct_stack_growth(struct vm_a
28210 /* Ok, everything looks good - let it rip */
28211 - mm->total_vm += grow;
28212 + vx_vmpages_add(mm, grow);
28213 if (vma->vm_flags & VM_LOCKED)
28214 - mm->locked_vm += grow;
28215 + vx_vmlocked_add(mm, grow);
28216 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
28219 @@ -1662,9 +1662,9 @@ static void remove_vma_list(struct mm_st
28221 long nrpages = vma_pages(vma);
28223 - mm->total_vm -= nrpages;
28224 + vx_vmpages_sub(mm, nrpages);
28225 if (vma->vm_flags & VM_LOCKED)
28226 - mm->locked_vm -= nrpages;
28227 + vx_vmlocked_sub(mm, nrpages);
28228 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
28229 vma = remove_vma(vma);
28231 @@ -1903,6 +1903,8 @@ unsigned long do_brk(unsigned long addr,
28232 lock_limit >>= PAGE_SHIFT;
28233 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
28235 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
28240 @@ -1929,7 +1931,8 @@ unsigned long do_brk(unsigned long addr,
28241 if (mm->map_count > sysctl_max_map_count)
28244 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
28245 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
28246 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
28249 /* Can we just expand an old private anonymous mapping? */
28250 @@ -1955,9 +1958,9 @@ unsigned long do_brk(unsigned long addr,
28251 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)];
28252 vma_link(mm, vma, prev, rb_link, rb_parent);
28254 - mm->total_vm += len >> PAGE_SHIFT;
28255 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28256 if (flags & VM_LOCKED) {
28257 - mm->locked_vm += len >> PAGE_SHIFT;
28258 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
28259 make_pages_present(addr, addr + len);
28262 @@ -1986,6 +1989,11 @@ void exit_mmap(struct mm_struct *mm)
28263 free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, 0);
28264 tlb_finish_mmu(tlb, 0, end);
28266 + set_mm_counter(mm, file_rss, 0);
28267 + set_mm_counter(mm, anon_rss, 0);
28268 + vx_vmpages_sub(mm, mm->total_vm);
28269 + vx_vmlocked_sub(mm, mm->locked_vm);
28272 * Walk the list again, actually closing and freeing it,
28273 * with preemption enabled, without holding any MM locks.
28274 @@ -2025,7 +2033,8 @@ int insert_vm_struct(struct mm_struct *
28275 if (__vma && __vma->vm_start < vma->vm_end)
28277 if ((vma->vm_flags & VM_ACCOUNT) &&
28278 - security_vm_enough_memory(vma_pages(vma)))
28279 + (security_vm_enough_memory(vma_pages(vma)) ||
28280 + !vx_vmpages_avail(mm, vma_pages(vma))))
28282 vma_link(mm, vma, prev, rb_link, rb_parent);
28284 @@ -2098,6 +2107,8 @@ int may_expand_vm(struct mm_struct *mm,
28286 if (cur + npages > lim)
28288 + if (!vx_vmpages_avail(mm, npages))
28293 @@ -2168,7 +2179,6 @@ int install_special_mapping(struct mm_st
28297 - mm->total_vm += len >> PAGE_SHIFT;
28299 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
28302 diff -NurpP --minimal linux-2.6.22.10/mm/mremap.c linux-2.6.22.10-vs2.3.0.29/mm/mremap.c
28303 --- linux-2.6.22.10/mm/mremap.c 2007-02-06 03:01:56 +0100
28304 +++ linux-2.6.22.10-vs2.3.0.29/mm/mremap.c 2007-08-05 20:53:13 +0200
28306 #include <linux/highmem.h>
28307 #include <linux/security.h>
28308 #include <linux/syscalls.h>
28309 +#include <linux/vs_memory.h>
28311 #include <asm/uaccess.h>
28312 #include <asm/cacheflush.h>
28313 @@ -212,7 +213,7 @@ static unsigned long move_vma(struct vm_
28314 * If this were a serious issue, we'd add a flag to do_munmap().
28316 hiwater_vm = mm->hiwater_vm;
28317 - mm->total_vm += new_len >> PAGE_SHIFT;
28318 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
28319 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
28321 if (do_munmap(mm, old_addr, old_len) < 0) {
28322 @@ -230,7 +231,7 @@ static unsigned long move_vma(struct vm_
28325 if (vm_flags & VM_LOCKED) {
28326 - mm->locked_vm += new_len >> PAGE_SHIFT;
28327 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
28328 if (new_len > old_len)
28329 make_pages_present(new_addr + old_len,
28330 new_addr + new_len);
28331 @@ -337,6 +338,9 @@ unsigned long do_mremap(unsigned long ad
28333 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
28335 + if (!vx_vmlocked_avail(current->mm,
28336 + (new_len - old_len) >> PAGE_SHIFT))
28339 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
28341 @@ -365,10 +369,10 @@ unsigned long do_mremap(unsigned long ad
28342 vma_adjust(vma, vma->vm_start,
28343 addr + new_len, vma->vm_pgoff, NULL);
28345 - mm->total_vm += pages;
28346 + vx_vmpages_add(mm, pages);
28347 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
28348 if (vma->vm_flags & VM_LOCKED) {
28349 - mm->locked_vm += pages;
28350 + vx_vmlocked_add(mm, pages);
28351 make_pages_present(addr + old_len,
28354 diff -NurpP --minimal linux-2.6.22.10/mm/nommu.c linux-2.6.22.10-vs2.3.0.29/mm/nommu.c
28355 --- linux-2.6.22.10/mm/nommu.c 2007-07-09 13:20:04 +0200
28356 +++ linux-2.6.22.10-vs2.3.0.29/mm/nommu.c 2007-08-05 20:53:13 +0200
28357 @@ -936,7 +936,7 @@ unsigned long do_mmap_pgoff(struct file
28358 realalloc += kobjsize(vma);
28359 askedalloc += sizeof(*vma);
28361 - current->mm->total_vm += len >> PAGE_SHIFT;
28362 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
28364 add_nommu_vma(vma);
28366 @@ -1061,7 +1061,7 @@ int do_munmap(struct mm_struct *mm, unsi
28369 update_hiwater_vm(mm);
28370 - mm->total_vm -= len >> PAGE_SHIFT;
28371 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
28374 show_process_blocks();
28375 @@ -1093,7 +1093,7 @@ void exit_mmap(struct mm_struct * mm)
28376 printk("Exit_mmap:\n");
28379 - mm->total_vm = 0;
28380 + vx_vmpages_sub(mm, mm->total_vm);
28382 while ((tmp = mm->context.vmlist)) {
28383 mm->context.vmlist = tmp->next;
28384 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
28385 --- linux-2.6.22.10/mm/oom_kill.c 2007-07-09 13:20:04 +0200
28386 +++ linux-2.6.22.10-vs2.3.0.29/mm/oom_kill.c 2007-08-05 20:53:13 +0200
28388 #include <linux/cpuset.h>
28389 #include <linux/module.h>
28390 #include <linux/notifier.h>
28391 +#include <linux/vs_memory.h>
28393 int sysctl_panic_on_oom;
28394 /* #define DEBUG */
28395 @@ -66,6 +67,12 @@ unsigned long badness(struct task_struct
28396 points = mm->total_vm;
28399 + * add points for context badness
28402 + points += vx_badness(p, mm);
28405 * After this unlock we can no longer dereference local variable `mm'
28408 @@ -156,8 +163,8 @@ unsigned long badness(struct task_struct
28412 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %d points\n",
28413 - p->pid, p->comm, points);
28414 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
28415 + p->pid, p->xid, p->comm, points);
28419 @@ -288,7 +295,8 @@ static void __oom_kill_task(struct task_
28423 - printk(KERN_ERR "Killed process %d (%s)\n", p->pid, p->comm);
28424 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
28425 + p->pid, p->xid, p->comm);
28428 * We give our sacrificial lamb high priority and access to
28429 @@ -358,8 +366,8 @@ static int oom_kill_process(struct task_
28433 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
28434 - message, p->pid, p->comm, points);
28435 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
28436 + message, p->pid, p->xid, p->comm, points);
28438 /* Try to kill a child first */
28439 list_for_each(tsk, &p->children) {
28440 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
28441 --- linux-2.6.22.10/mm/page_alloc.c 2007-07-09 13:20:04 +0200
28442 +++ linux-2.6.22.10-vs2.3.0.29/mm/page_alloc.c 2007-08-05 20:53:13 +0200
28444 #include <linux/pfn.h>
28445 #include <linux/backing-dev.h>
28446 #include <linux/fault-inject.h>
28447 +#include <linux/vs_base.h>
28448 +#include <linux/vs_limit.h>
28450 #include <asm/tlbflush.h>
28451 #include <asm/div64.h>
28452 @@ -1488,6 +1490,9 @@ void si_meminfo(struct sysinfo *val)
28453 val->totalhigh = totalhigh_pages;
28454 val->freehigh = nr_free_highpages();
28455 val->mem_unit = PAGE_SIZE;
28457 + if (vx_flags(VXF_VIRT_MEM, 0))
28458 + vx_vsi_meminfo(val);
28461 EXPORT_SYMBOL(si_meminfo);
28462 @@ -1508,6 +1513,9 @@ void si_meminfo_node(struct sysinfo *val
28465 val->mem_unit = PAGE_SIZE;
28467 + if (vx_flags(VXF_VIRT_MEM, 0))
28468 + vx_vsi_meminfo(val);
28472 diff -NurpP --minimal linux-2.6.22.10/mm/rmap.c linux-2.6.22.10-vs2.3.0.29/mm/rmap.c
28473 --- linux-2.6.22.10/mm/rmap.c 2007-07-09 13:20:04 +0200
28474 +++ linux-2.6.22.10-vs2.3.0.29/mm/rmap.c 2007-08-05 20:53:13 +0200
28476 #include <linux/rcupdate.h>
28477 #include <linux/module.h>
28478 #include <linux/kallsyms.h>
28479 +#include <linux/vs_memory.h>
28481 #include <asm/tlbflush.h>
28483 diff -NurpP --minimal linux-2.6.22.10/mm/shmem.c linux-2.6.22.10-vs2.3.0.29/mm/shmem.c
28484 --- linux-2.6.22.10/mm/shmem.c 2007-07-09 13:20:04 +0200
28485 +++ linux-2.6.22.10-vs2.3.0.29/mm/shmem.c 2007-08-05 20:53:13 +0200
28487 #include <asm/pgtable.h>
28489 /* This magic number is used in glibc for posix shared memory */
28490 -#define TMPFS_MAGIC 0x01021994
28492 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
28493 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
28494 @@ -1734,7 +1733,7 @@ static int shmem_statfs(struct dentry *d
28496 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
28498 - buf->f_type = TMPFS_MAGIC;
28499 + buf->f_type = TMPFS_SUPER_MAGIC;
28500 buf->f_bsize = PAGE_CACHE_SIZE;
28501 buf->f_namelen = NAME_MAX;
28502 spin_lock(&sbinfo->stat_lock);
28503 @@ -2308,7 +2307,7 @@ static int shmem_fill_super(struct super
28504 sb->s_maxbytes = SHMEM_MAX_BYTES;
28505 sb->s_blocksize = PAGE_CACHE_SIZE;
28506 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
28507 - sb->s_magic = TMPFS_MAGIC;
28508 + sb->s_magic = TMPFS_SUPER_MAGIC;
28509 sb->s_op = &shmem_ops;
28510 sb->s_time_gran = 1;
28511 #ifdef CONFIG_TMPFS_POSIX_ACL
28512 diff -NurpP --minimal linux-2.6.22.10/mm/slab.c linux-2.6.22.10-vs2.3.0.29/mm/slab.c
28513 --- linux-2.6.22.10/mm/slab.c 2007-07-09 13:20:04 +0200
28514 +++ linux-2.6.22.10-vs2.3.0.29/mm/slab.c 2007-08-05 20:53:13 +0200
28515 @@ -510,6 +510,8 @@ struct kmem_cache {
28516 #define STATS_INC_FREEMISS(x) do { } while (0)
28519 +#include "slab_vs.h"
28524 @@ -3314,6 +3316,7 @@ retry:
28526 obj = slab_get_obj(cachep, slabp, nodeid);
28527 check_slabp(cachep, slabp);
28528 + vx_slab_alloc(cachep, flags);
28529 l3->free_objects--;
28530 /* move slabp to correct slabp list: */
28531 list_del(&slabp->list);
28532 @@ -3386,6 +3389,7 @@ __cache_alloc_node(struct kmem_cache *ca
28533 /* ___cache_alloc_node can fall back to other nodes */
28534 ptr = ____cache_alloc_node(cachep, flags, nodeid);
28536 + vx_slab_alloc(cachep, flags);
28537 local_irq_restore(save_flags);
28538 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
28540 @@ -3551,6 +3555,7 @@ static inline void __cache_free(struct k
28543 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
28544 + vx_slab_free(cachep);
28546 if (cache_free_alien(cachep, objp))
28548 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
28549 --- linux-2.6.22.10/mm/slab_vs.h 1970-01-01 01:00:00 +0100
28550 +++ linux-2.6.22.10-vs2.3.0.29/mm/slab_vs.h 2007-08-05 20:53:13 +0200
28553 +#include <linux/vserver/context.h>
28555 +#include <linux/vs_context.h>
28558 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
28560 + int what = gfp_zone(cachep->gfpflags);
28562 + if (!current->vx_info)
28565 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
28569 +void vx_slab_free(struct kmem_cache *cachep)
28571 + int what = gfp_zone(cachep->gfpflags);
28573 + if (!current->vx_info)
28576 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
28579 diff -NurpP --minimal linux-2.6.22.10/mm/swapfile.c linux-2.6.22.10-vs2.3.0.29/mm/swapfile.c
28580 --- linux-2.6.22.10/mm/swapfile.c 2007-07-09 13:20:04 +0200
28581 +++ linux-2.6.22.10-vs2.3.0.29/mm/swapfile.c 2007-08-05 20:53:13 +0200
28583 #include <asm/pgtable.h>
28584 #include <asm/tlbflush.h>
28585 #include <linux/swapops.h>
28586 +#include <linux/vs_base.h>
28587 +#include <linux/vs_memory.h>
28589 DEFINE_SPINLOCK(swap_lock);
28590 unsigned int nr_swapfiles;
28591 @@ -1712,6 +1714,8 @@ void si_swapinfo(struct sysinfo *val)
28592 val->freeswap = nr_swap_pages + nr_to_be_unused;
28593 val->totalswap = total_swap_pages + nr_to_be_unused;
28594 spin_unlock(&swap_lock);
28595 + if (vx_flags(VXF_VIRT_MEM, 0))
28596 + vx_vsi_swapinfo(val);
28600 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
28601 --- linux-2.6.22.10/net/core/dev.c 2007-10-30 01:57:15 +0100
28602 +++ linux-2.6.22.10-vs2.3.0.29/net/core/dev.c 2007-09-05 03:06:12 +0200
28603 @@ -117,6 +117,7 @@
28604 #include <linux/err.h>
28605 #include <linux/ctype.h>
28606 #include <linux/if_arp.h>
28607 +#include <linux/vs_inet.h>
28610 * The list of packet types we will receive (as opposed to discard)
28611 @@ -2120,6 +2121,8 @@ static int dev_ifconf(char __user *arg)
28614 for_each_netdev(dev) {
28615 + if (!nx_dev_visible(current->nx_info, dev))
28617 for (i = 0; i < NPROTO; i++) {
28618 if (gifconf_list[i]) {
28620 @@ -2184,6 +2187,9 @@ static void dev_seq_printf_stats(struct
28622 struct net_device_stats *stats = dev->get_stats(dev);
28624 + if (!nx_dev_visible(current->nx_info, dev))
28627 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
28628 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
28629 dev->name, stats->rx_bytes, stats->rx_packets,
28630 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
28631 --- linux-2.6.22.10/net/core/rtnetlink.c 2007-07-09 13:20:05 +0200
28632 +++ linux-2.6.22.10-vs2.3.0.29/net/core/rtnetlink.c 2007-08-05 20:53:13 +0200
28633 @@ -537,6 +537,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
28636 for_each_netdev(dev) {
28637 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
28641 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
28642 @@ -797,6 +799,9 @@ void rtmsg_ifinfo(int type, struct net_d
28643 struct sk_buff *skb;
28644 int err = -ENOBUFS;
28646 + if (!nx_dev_visible(current->nx_info, dev))
28649 skb = nlmsg_new(if_nlmsg_size(), GFP_KERNEL);
28652 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
28653 --- linux-2.6.22.10/net/core/sock.c 2007-07-09 13:20:05 +0200
28654 +++ linux-2.6.22.10-vs2.3.0.29/net/core/sock.c 2007-10-01 14:57:43 +0200
28655 @@ -125,6 +125,10 @@
28656 #include <linux/ipsec.h>
28658 #include <linux/filter.h>
28659 +#include <linux/vs_socket.h>
28660 +#include <linux/vs_limit.h>
28661 +#include <linux/vs_context.h>
28662 +#include <linux/vs_network.h>
28665 #include <net/tcp.h>
28666 @@ -812,6 +816,9 @@ int sock_getsockopt(struct socket *sock,
28668 return security_socket_getpeersec_stream(sock, optval, optlen, len);
28671 + return vx_socket_peer_tag(sock, level, optval, optlen, len);
28674 return -ENOPROTOOPT;
28676 @@ -869,6 +876,8 @@ struct sock *sk_alloc(int family, gfp_t
28677 sk->sk_prot = sk->sk_prot_creator = prot;
28678 sock_lock_init(sk);
28680 + sock_vx_init(sk);
28681 + sock_nx_init(sk);
28683 if (security_sk_alloc(sk, family, priority))
28685 @@ -907,6 +916,11 @@ void sk_free(struct sock *sk)
28686 __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
28688 security_sk_free(sk);
28690 + clr_vx_info(&sk->sk_vx_info);
28692 + clr_nx_info(&sk->sk_nx_info);
28694 if (sk->sk_prot_creator->slab != NULL)
28695 kmem_cache_free(sk->sk_prot_creator->slab, sk);
28697 @@ -924,6 +938,8 @@ struct sock *sk_clone(const struct sock
28698 sock_copy(newsk, sk);
28701 + sock_vx_init(newsk);
28702 + sock_nx_init(newsk);
28703 sk_node_init(&newsk->sk_node);
28704 sock_lock_init(newsk);
28705 bh_lock_sock(newsk);
28706 @@ -969,6 +985,12 @@ struct sock *sk_clone(const struct sock
28707 newsk->sk_priority = 0;
28708 atomic_set(&newsk->sk_refcnt, 2);
28710 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
28711 + newsk->sk_xid = sk->sk_xid;
28712 + vx_sock_inc(newsk);
28713 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
28714 + newsk->sk_nid = sk->sk_nid;
28717 * Increment the counter in the same struct proto as the master
28718 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
28719 @@ -1551,6 +1573,11 @@ void sock_init_data(struct socket *sock,
28721 sk->sk_stamp = ktime_set(-1L, -1L);
28723 + set_vx_info(&sk->sk_vx_info, current->vx_info);
28724 + sk->sk_xid = vx_current_xid();
28726 + set_nx_info(&sk->sk_nx_info, current->nx_info);
28727 + sk->sk_nid = nx_current_nid();
28728 atomic_set(&sk->sk_refcnt, 1);
28731 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
28732 --- linux-2.6.22.10/net/ipv4/af_inet.c 2007-10-30 01:57:15 +0100
28733 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/af_inet.c 2007-10-05 14:54:36 +0200
28734 @@ -115,6 +115,7 @@
28735 #ifdef CONFIG_IP_MROUTE
28736 #include <linux/mroute.h>
28738 +#include <linux/vs_limit.h>
28740 DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly;
28742 @@ -308,9 +309,12 @@ lookup_protocol:
28746 + if ((protocol == IPPROTO_ICMP) &&
28747 + nx_capable(answer->capability, NXC_RAW_ICMP))
28749 if (answer->capability > 0 && !capable(answer->capability))
28750 goto out_rcu_unlock;
28753 sock->ops = answer->ops;
28754 answer_prot = answer->prot;
28755 answer_no_check = answer->no_check;
28756 @@ -424,6 +428,7 @@ int inet_bind(struct socket *sock, struc
28757 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
28758 struct sock *sk = sock->sk;
28759 struct inet_sock *inet = inet_sk(sk);
28760 + struct nx_v4_sock_addr nsa;
28761 unsigned short snum;
28764 @@ -437,7 +442,11 @@ int inet_bind(struct socket *sock, struc
28765 if (addr_len < sizeof(struct sockaddr_in))
28768 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
28769 + err = v4_map_sock_addr(inet, addr, &nsa);
28773 + chk_addr_ret = inet_addr_type(nsa.saddr);
28775 /* Not specified by any standard per-se, however it breaks too
28776 * many applications when removed. It is unfortunate since
28777 @@ -449,7 +458,7 @@ int inet_bind(struct socket *sock, struc
28778 err = -EADDRNOTAVAIL;
28779 if (!sysctl_ip_nonlocal_bind &&
28781 - addr->sin_addr.s_addr != INADDR_ANY &&
28782 + nsa.saddr != INADDR_ANY &&
28783 chk_addr_ret != RTN_LOCAL &&
28784 chk_addr_ret != RTN_MULTICAST &&
28785 chk_addr_ret != RTN_BROADCAST)
28786 @@ -474,7 +483,7 @@ int inet_bind(struct socket *sock, struc
28787 if (sk->sk_state != TCP_CLOSE || inet->num)
28788 goto out_release_sock;
28790 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
28791 + v4_set_sock_addr(inet, &nsa);
28792 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
28793 inet->saddr = 0; /* Use device */
28795 @@ -667,11 +676,13 @@ int inet_getname(struct socket *sock, st
28798 sin->sin_port = inet->dport;
28799 - sin->sin_addr.s_addr = inet->daddr;
28800 + sin->sin_addr.s_addr =
28801 + nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
28803 __be32 addr = inet->rcv_saddr;
28805 addr = inet->saddr;
28806 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
28807 sin->sin_port = inet->sport;
28808 sin->sin_addr.s_addr = addr;
28810 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
28811 --- linux-2.6.22.10/net/ipv4/devinet.c 2007-10-30 01:57:15 +0100
28812 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/devinet.c 2007-09-30 14:58:01 +0200
28813 @@ -427,6 +427,7 @@ struct in_device *inetdev_by_index(int i
28818 /* Called only from RTNL semaphored context. No locks. */
28820 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
28821 @@ -676,6 +677,8 @@ int devinet_ioctl(unsigned int cmd, void
28824 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
28825 + struct nx_info *nxi = current->nx_info;
28827 if (tryaddrmatch) {
28828 /* Matthias Andree */
28829 /* compare label and address (4.4BSD style) */
28830 @@ -684,6 +687,8 @@ int devinet_ioctl(unsigned int cmd, void
28831 This is checked above. */
28832 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
28833 ifap = &ifa->ifa_next) {
28834 + if (!nx_v4_ifa_visible(nxi, ifa))
28836 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
28837 sin_orig.sin_addr.s_addr ==
28838 ifa->ifa_address) {
28839 @@ -696,9 +701,12 @@ int devinet_ioctl(unsigned int cmd, void
28840 comparing just the label */
28842 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
28843 - ifap = &ifa->ifa_next)
28844 + ifap = &ifa->ifa_next) {
28845 + if (!nx_v4_ifa_visible(nxi, ifa))
28847 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
28853 @@ -849,6 +857,8 @@ static int inet_gifconf(struct net_devic
28856 for (; ifa; ifa = ifa->ifa_next) {
28857 + if (!nx_v4_ifa_visible(current->nx_info, ifa))
28860 done += sizeof(ifr);
28862 @@ -1179,6 +1189,7 @@ static int inet_dump_ifaddr(struct sk_bu
28863 struct net_device *dev;
28864 struct in_device *in_dev;
28865 struct in_ifaddr *ifa;
28866 + struct sock *sk = skb->sk;
28867 int s_ip_idx, s_idx = cb->args[0];
28869 s_ip_idx = ip_idx = cb->args[1];
28870 @@ -1193,6 +1204,8 @@ static int inet_dump_ifaddr(struct sk_bu
28872 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
28873 ifa = ifa->ifa_next, ip_idx++) {
28874 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
28876 if (ip_idx < s_ip_idx)
28878 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
28879 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
28880 --- linux-2.6.22.10/net/ipv4/fib_hash.c 2007-07-09 13:20:05 +0200
28881 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/fib_hash.c 2007-08-05 20:53:13 +0200
28882 @@ -1012,7 +1012,7 @@ static int fib_seq_show(struct seq_file
28883 prefix = f->fn_key;
28884 mask = FZ_MASK(iter->zone);
28885 flags = fib_flag_trans(fa->fa_type, mask, fi);
28887 + if (fi && nx_dev_visible(current->nx_info, fi->fib_dev))
28888 snprintf(bf, sizeof(bf),
28889 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
28890 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
28891 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
28892 --- linux-2.6.22.10/net/ipv4/inet_connection_sock.c 2007-07-09 13:20:05 +0200
28893 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_connection_sock.c 2007-10-18 01:28:12 +0200
28894 @@ -34,10 +34,40 @@ EXPORT_SYMBOL(inet_csk_timer_bug_msg);
28896 int sysctl_local_port_range[2] = { 32768, 61000 };
28898 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
28900 + __be32 sk1_rcv_saddr = inet_rcv_saddr(sk1),
28901 + sk2_rcv_saddr = inet_rcv_saddr(sk2);
28903 + if (inet_v6_ipv6only(sk2))
28906 + if (sk1_rcv_saddr &&
28908 + sk1_rcv_saddr == sk2_rcv_saddr)
28911 + if (sk1_rcv_saddr &&
28912 + !sk2_rcv_saddr &&
28913 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
28916 + if (sk2_rcv_saddr &&
28917 + !sk1_rcv_saddr &&
28918 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
28921 + if (!sk1_rcv_saddr &&
28922 + !sk2_rcv_saddr &&
28923 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
28929 int inet_csk_bind_conflict(const struct sock *sk,
28930 const struct inet_bind_bucket *tb)
28932 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
28934 struct hlist_node *node;
28935 int reuse = sk->sk_reuse;
28936 @@ -50,9 +80,7 @@ int inet_csk_bind_conflict(const struct
28937 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
28938 if (!reuse || !sk2->sk_reuse ||
28939 sk2->sk_state == TCP_LISTEN) {
28940 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28941 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
28942 - sk2_rcv_saddr == sk_rcv_saddr)
28943 + if (ipv4_rcv_saddr_equal(sk, sk2))
28947 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
28948 --- linux-2.6.22.10/net/ipv4/inet_diag.c 2007-10-30 01:57:15 +0100
28949 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_diag.c 2007-10-30 02:36:32 +0100
28950 @@ -98,8 +98,8 @@ static int inet_csk_diag_fill(struct soc
28952 r->id.idiag_sport = inet->sport;
28953 r->id.idiag_dport = inet->dport;
28954 - r->id.idiag_src[0] = inet->rcv_saddr;
28955 - r->id.idiag_dst[0] = inet->daddr;
28956 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, inet->rcv_saddr);
28957 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, inet->daddr);
28959 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
28960 if (r->idiag_family == AF_INET6) {
28961 @@ -186,8 +186,8 @@ static int inet_twsk_diag_fill(struct in
28962 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
28963 r->id.idiag_sport = tw->tw_sport;
28964 r->id.idiag_dport = tw->tw_dport;
28965 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
28966 - r->id.idiag_dst[0] = tw->tw_daddr;
28967 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
28968 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
28969 r->idiag_state = tw->tw_substate;
28970 r->idiag_timer = 3;
28971 r->idiag_expires = (tmo * 1000 + HZ - 1) / HZ;
28972 @@ -239,6 +239,7 @@ static int inet_diag_get_exact(struct sk
28973 hashinfo = handler->idiag_hashinfo;
28975 if (req->idiag_family == AF_INET) {
28976 + /* TODO: lback */
28977 sk = inet_lookup(hashinfo, req->id.idiag_dst[0],
28978 req->id.idiag_dport, req->id.idiag_src[0],
28979 req->id.idiag_sport, req->id.idiag_if);
28980 @@ -478,6 +479,7 @@ static int inet_csk_diag_dump(struct soc
28984 + /* TODO: lback */
28985 entry.saddr = &inet->rcv_saddr;
28986 entry.daddr = &inet->daddr;
28988 @@ -514,6 +516,7 @@ static int inet_twsk_diag_dump(struct in
28992 + /* TODO: lback */
28993 entry.saddr = &tw->tw_rcv_saddr;
28994 entry.daddr = &tw->tw_daddr;
28996 @@ -560,8 +563,8 @@ static int inet_diag_fill_req(struct sk_
28998 r->id.idiag_sport = inet->sport;
28999 r->id.idiag_dport = ireq->rmt_port;
29000 - r->id.idiag_src[0] = ireq->loc_addr;
29001 - r->id.idiag_dst[0] = ireq->rmt_addr;
29002 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
29003 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
29004 r->idiag_expires = jiffies_to_msecs(tmo);
29005 r->idiag_rqueue = 0;
29006 r->idiag_wqueue = 0;
29007 @@ -631,6 +634,7 @@ static int inet_diag_dump_reqs(struct sk
29011 + /* TODO: lback */
29013 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
29014 (entry.family == AF_INET6) ?
29015 @@ -697,6 +701,8 @@ static int inet_diag_dump(struct sk_buff
29016 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
29017 struct inet_sock *inet = inet_sk(sk);
29019 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29024 @@ -757,6 +763,8 @@ skip_listen_ht:
29025 sk_for_each(sk, node, &head->chain) {
29026 struct inet_sock *inet = inet_sk(sk);
29028 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29032 if (!(r->idiag_states & (1 << sk->sk_state)))
29033 @@ -781,6 +789,8 @@ next_normal:
29034 inet_twsk_for_each(tw, node,
29037 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
29041 if (r->id.idiag_sport != tw->tw_sport &&
29042 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
29043 --- linux-2.6.22.10/net/ipv4/inet_hashtables.c 2007-05-02 19:25:40 +0200
29044 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/inet_hashtables.c 2007-08-05 20:53:13 +0200
29045 @@ -140,11 +140,10 @@ static struct sock *inet_lookup_listener
29046 const __be32 rcv_saddr = inet->rcv_saddr;
29047 int score = sk->sk_family == PF_INET ? 1 : 0;
29050 - if (rcv_saddr != daddr)
29052 + if (v4_inet_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
29057 if (sk->sk_bound_dev_if) {
29058 if (sk->sk_bound_dev_if != dif)
29060 @@ -175,7 +174,7 @@ struct sock *__inet_lookup_listener(stru
29061 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
29063 if (inet->num == hnum && !sk->sk_node.next &&
29064 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
29065 + v4_inet_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
29066 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
29067 !sk->sk_bound_dev_if)
29069 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
29070 --- linux-2.6.22.10/net/ipv4/raw.c 2007-07-09 13:20:06 +0200
29071 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/raw.c 2007-10-05 12:29:05 +0200
29072 @@ -112,7 +112,7 @@ struct sock *__raw_v4_lookup(struct sock
29074 if (inet->num == num &&
29075 !(inet->daddr && inet->daddr != raddr) &&
29076 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
29077 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
29078 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
29079 goto found; /* gotcha */
29081 @@ -314,6 +314,12 @@ static int raw_send_hdrinc(struct sock *
29082 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
29086 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
29087 + sk->sk_nx_info &&
29088 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
29091 err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
29094 @@ -325,6 +331,7 @@ out:
29101 IP_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
29102 @@ -491,6 +498,12 @@ static int raw_sendmsg(struct kiocb *ioc
29105 security_sk_classify_flow(sk, &fl);
29106 + if (sk->sk_nx_info) {
29107 + err = ip_v4_find_src(sk->sk_nx_info, &rt, &fl);
29112 err = ip_route_output_flow(&rt, &fl, sk, 1);
29115 @@ -553,17 +566,19 @@ static int raw_bind(struct sock *sk, str
29117 struct inet_sock *inet = inet_sk(sk);
29118 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
29119 + struct nx_v4_sock_addr nsa = { 0 };
29123 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
29125 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
29126 + v4_map_sock_addr(inet, addr, &nsa);
29127 + chk_addr_ret = inet_addr_type(nsa.saddr);
29128 ret = -EADDRNOTAVAIL;
29129 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
29130 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
29131 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
29133 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
29134 + v4_set_sock_addr(inet, &nsa);
29135 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
29136 inet->saddr = 0; /* Use device */
29138 @@ -615,7 +630,8 @@ static int raw_recvmsg(struct kiocb *ioc
29139 /* Copy the address. */
29141 sin->sin_family = AF_INET;
29142 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
29143 + sin->sin_addr.s_addr =
29144 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
29146 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
29148 @@ -795,7 +811,8 @@ static struct sock *raw_get_first(struct
29149 struct hlist_node *node;
29151 sk_for_each(sk, node, &raw_v4_htable[state->bucket])
29152 - if (sk->sk_family == PF_INET)
29153 + if (sk->sk_family == PF_INET &&
29154 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29158 @@ -811,7 +828,8 @@ static struct sock *raw_get_next(struct
29162 - } while (sk && sk->sk_family != PF_INET);
29163 + } while (sk && (sk->sk_family != PF_INET ||
29164 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
29166 if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
29167 sk = sk_head(&raw_v4_htable[state->bucket]);
29168 @@ -863,7 +881,10 @@ static __inline__ char *get_raw_sock(str
29170 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29171 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
29172 - i, src, srcp, dest, destp, sp->sk_state,
29174 + nx_map_sock_lback(current_nx_info(), src), srcp,
29175 + nx_map_sock_lback(current_nx_info(), dest), destp,
29177 atomic_read(&sp->sk_wmem_alloc),
29178 atomic_read(&sp->sk_rmem_alloc),
29179 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
29180 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
29181 --- linux-2.6.22.10/net/ipv4/tcp.c 2007-10-30 01:57:15 +0100
29182 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp.c 2007-09-05 03:06:12 +0200
29183 @@ -258,6 +258,7 @@
29184 #include <linux/cache.h>
29185 #include <linux/err.h>
29186 #include <linux/crypto.h>
29187 +#include <linux/in.h>
29189 #include <net/icmp.h>
29190 #include <net/tcp.h>
29191 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
29192 --- linux-2.6.22.10/net/ipv4/tcp_ipv4.c 2007-10-30 01:57:15 +0100
29193 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp_ipv4.c 2007-09-05 03:06:12 +0200
29194 @@ -1975,6 +1975,12 @@ static void *listening_get_next(struct s
29195 req = req->dl_next;
29198 + vxdprintk(VXD_CBIT(net, 6),
29199 + "sk,req: %p [#%d] (from %d)", req->sk,
29200 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
29202 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
29204 if (req->rsk_ops->family == st->family) {
29207 @@ -1999,6 +2005,10 @@ get_req:
29210 sk_for_each_from(sk, node) {
29211 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
29212 + sk, sk->sk_nid, nx_current_nid());
29213 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29215 if (sk->sk_family == st->family) {
29218 @@ -2050,18 +2060,26 @@ static void *established_get_first(struc
29220 read_lock(&tcp_hashinfo.ehash[st->bucket].lock);
29221 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
29222 - if (sk->sk_family != st->family) {
29223 + vxdprintk(VXD_CBIT(net, 6),
29224 + "sk,egf: %p [#%d] (from %d)",
29225 + sk, sk->sk_nid, nx_current_nid());
29226 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29228 + if (sk->sk_family != st->family)
29234 st->state = TCP_SEQ_STATE_TIME_WAIT;
29235 inet_twsk_for_each(tw, node,
29236 &tcp_hashinfo.ehash[st->bucket].twchain) {
29237 - if (tw->tw_family != st->family) {
29238 + vxdprintk(VXD_CBIT(net, 6),
29239 + "tw: %p [#%d] (from %d)",
29240 + tw, tw->tw_nid, nx_current_nid());
29241 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
29243 + if (tw->tw_family != st->family)
29249 @@ -2085,7 +2103,8 @@ static void *established_get_next(struct
29253 - while (tw && tw->tw_family != st->family) {
29254 + while (tw && (tw->tw_family != st->family ||
29255 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
29259 @@ -2109,6 +2128,11 @@ get_tw:
29262 sk_for_each_from(sk, node) {
29263 + vxdprintk(VXD_CBIT(net, 6),
29264 + "sk,egn: %p [#%d] (from %d)",
29265 + sk, sk->sk_nid, nx_current_nid());
29266 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29268 if (sk->sk_family == st->family)
29271 @@ -2284,9 +2308,9 @@ static void get_openreq4(struct sock *sk
29272 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29273 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p",
29276 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
29277 ntohs(inet_sk(sk)->sport),
29279 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
29280 ntohs(ireq->rmt_port),
29282 0, 0, /* could print option size, but that is af dependent. */
29283 @@ -2328,7 +2352,10 @@ static void get_tcp4_sock(struct sock *s
29285 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
29286 "%08X %5d %8d %lu %d %p %u %u %u %u %d",
29287 - i, src, srcp, dest, destp, sk->sk_state,
29289 + nx_map_sock_lback(current_nx_info(), src), srcp,
29290 + nx_map_sock_lback(current_nx_info(), dest), destp,
29292 tp->write_seq - tp->snd_una,
29293 sk->sk_state == TCP_LISTEN ? sk->sk_ack_backlog :
29294 (tp->rcv_nxt - tp->copied_seq),
29295 @@ -2363,7 +2390,10 @@ static void get_timewait4_sock(struct in
29297 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29298 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p",
29299 - i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
29301 + nx_map_sock_lback(current_nx_info(), src), srcp,
29302 + nx_map_sock_lback(current_nx_info(), dest), destp,
29303 + tw->tw_substate, 0, 0,
29304 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
29305 atomic_read(&tw->tw_refcnt), tw);
29307 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
29308 --- linux-2.6.22.10/net/ipv4/tcp_minisocks.c 2007-07-09 13:20:06 +0200
29309 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/tcp_minisocks.c 2007-08-05 20:53:13 +0200
29311 #include <net/inet_common.h>
29312 #include <net/xfrm.h>
29314 +#include <linux/vs_limit.h>
29315 +#include <linux/vs_socket.h>
29316 +#include <linux/vs_context.h>
29318 #ifdef CONFIG_SYSCTL
29319 #define SYNC_INIT 0 /* let the user enable it */
29321 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
29322 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
29323 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
29325 + tw->tw_xid = sk->sk_xid;
29326 + tw->tw_vx_info = NULL;
29327 + tw->tw_nid = sk->sk_nid;
29328 + tw->tw_nx_info = NULL;
29330 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
29331 if (tw->tw_family == PF_INET6) {
29332 struct ipv6_pinfo *np = inet6_sk(sk);
29333 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
29334 --- linux-2.6.22.10/net/ipv4/udp.c 2007-07-09 13:20:06 +0200
29335 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv4/udp.c 2007-10-09 14:09:19 +0200
29336 @@ -219,14 +219,7 @@ int udp_get_port(struct sock *sk, unsign
29337 return __udp_lib_get_port(sk, snum, udp_hash, &udp_port_rover, scmp);
29340 -int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
29342 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
29344 - return ( !ipv6_only_sock(sk2) &&
29345 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
29346 - inet1->rcv_saddr == inet2->rcv_saddr ));
29348 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
29350 static inline int udp_v4_get_port(struct sock *sk, unsigned short snum)
29352 @@ -246,15 +239,22 @@ static struct sock *__udp4_lib_lookup(__
29355 read_lock(&udp_hash_lock);
29357 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
29358 struct inet_sock *inet = inet_sk(sk);
29360 if (sk->sk_hash == hnum && !ipv6_only_sock(sk)) {
29361 int score = (sk->sk_family == PF_INET ? 1 : 0);
29363 if (inet->rcv_saddr) {
29364 if (inet->rcv_saddr != daddr)
29368 + /* block non nx_info ips */
29369 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
29370 + daddr, NXA_MASK_BIND))
29374 if (inet->daddr != saddr)
29375 @@ -280,6 +280,7 @@ static struct sock *__udp4_lib_lookup(__
29382 read_unlock(&udp_hash_lock);
29383 @@ -301,7 +302,7 @@ static inline struct sock *udp_v4_mcast_
29384 if (s->sk_hash != hnum ||
29385 (inet->daddr && inet->daddr != rmt_addr) ||
29386 (inet->dport != rmt_port && inet->dport) ||
29387 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
29388 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
29389 ipv6_only_sock(s) ||
29390 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
29392 @@ -631,7 +632,14 @@ int udp_sendmsg(struct kiocb *iocb, stru
29393 .uli_u = { .ports =
29394 { .sport = inet->sport,
29395 .dport = dport } } };
29396 + struct nx_info *nxi = sk->sk_nx_info;
29398 security_sk_classify_flow(sk, &fl);
29400 + err = ip_v4_find_src(nxi, &rt, &fl);
29404 err = ip_route_output_flow(&rt, &fl, sk, 1);
29406 if (err == -ENETUNREACH)
29407 @@ -871,7 +879,8 @@ try_again:
29409 sin->sin_family = AF_INET;
29410 sin->sin_port = udp_hdr(skb)->source;
29411 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
29412 + sin->sin_addr.s_addr = nx_map_sock_lback(
29413 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
29414 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
29416 if (inet->cmsg_flags)
29417 @@ -1551,7 +1560,8 @@ static struct sock *udp_get_first(struct
29418 for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
29419 struct hlist_node *node;
29420 sk_for_each(sk, node, state->hashtable + state->bucket) {
29421 - if (sk->sk_family == state->family)
29422 + if (sk->sk_family == state->family &&
29423 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
29427 @@ -1568,7 +1578,8 @@ static struct sock *udp_get_next(struct
29431 - } while (sk && sk->sk_family != state->family);
29432 + } while (sk && (sk->sk_family != state->family ||
29433 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
29435 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
29436 sk = sk_head(state->hashtable + state->bucket);
29437 @@ -1681,7 +1692,10 @@ static void udp4_format_sock(struct sock
29439 sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
29440 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
29441 - bucket, src, srcp, dest, destp, sp->sk_state,
29443 + nx_map_sock_lback(current_nx_info(), src), srcp,
29444 + nx_map_sock_lback(current_nx_info(), dest), destp,
29446 atomic_read(&sp->sk_wmem_alloc),
29447 atomic_read(&sp->sk_rmem_alloc),
29448 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
29449 diff -NurpP --minimal linux-2.6.22.10/net/ipv6/Kconfig linux-2.6.22.10-vs2.3.0.29/net/ipv6/Kconfig
29450 --- linux-2.6.22.10/net/ipv6/Kconfig 2007-07-09 13:20:06 +0200
29451 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/Kconfig 2007-08-05 20:53:13 +0200
29454 # IPv6 as module will cause a CRASH if you try to unload it
29456 - tristate "The IPv6 protocol"
29458 + bool "The IPv6 protocol"
29461 This is complemental support for the IP version 6.
29462 You will still be able to do traditional IPv4 networking as well.
29463 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
29464 --- linux-2.6.22.10/net/ipv6/addrconf.c 2007-10-30 01:57:15 +0100
29465 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/addrconf.c 2007-10-05 14:54:36 +0200
29468 #include <linux/proc_fs.h>
29469 #include <linux/seq_file.h>
29470 +#include <linux/vs_inet6.h>
29472 /* Set to 3 to get tracing... */
29473 #define ACONF_DEBUG 2
29474 @@ -897,7 +898,8 @@ static inline int ipv6_saddr_label(const
29477 int ipv6_dev_get_saddr(struct net_device *daddr_dev,
29478 - struct in6_addr *daddr, struct in6_addr *saddr)
29479 + struct in6_addr *daddr, struct in6_addr *saddr,
29480 + struct nx_info *nxi)
29482 struct ipv6_saddr_score hiscore;
29483 struct inet6_ifaddr *ifa_result = NULL;
29484 @@ -942,6 +944,10 @@ int ipv6_dev_get_saddr(struct net_device
29486 score.addr_type = __ipv6_addr_type(&ifa->addr);
29488 + /* Use only addresses assigned to the context */
29489 + if (!v6_ifa_in_nx_info(ifa, nxi))
29493 * - Tentative Address (RFC2462 section 5.4)
29494 * - A tentative address is not considered
29495 @@ -1155,9 +1161,10 @@ record_it:
29498 int ipv6_get_saddr(struct dst_entry *dst,
29499 - struct in6_addr *daddr, struct in6_addr *saddr)
29500 + struct in6_addr *daddr, struct in6_addr *saddr,
29501 + struct nx_info *nxi)
29503 - return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr);
29504 + return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr, nxi);
29507 EXPORT_SYMBOL(ipv6_get_saddr);
29508 @@ -1253,35 +1260,46 @@ struct inet6_ifaddr * ipv6_get_ifaddr(st
29512 +extern int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2);
29514 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
29516 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
29517 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
29518 - __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
29519 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
29520 int sk_ipv6only = ipv6_only_sock(sk);
29521 int sk2_ipv6only = inet_v6_ipv6only(sk2);
29522 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
29523 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
29525 - if (!sk2_rcv_saddr && !sk_ipv6only)
29526 + /* FIXME: needs handling for v4 ANY */
29527 + if (!sk2_rcv_saddr && !sk_ipv6only && !sk2->sk_nx_info)
29530 if (addr_type2 == IPV6_ADDR_ANY &&
29531 - !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
29532 + !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED) &&
29533 + v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1))
29536 if (addr_type == IPV6_ADDR_ANY &&
29537 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
29538 + !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED) &&
29539 + (sk2_rcv_saddr6 && v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1)))
29542 + if (addr_type == IPV6_ADDR_ANY &&
29543 + addr_type2 == IPV6_ADDR_ANY &&
29544 + nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info))
29547 if (sk2_rcv_saddr6 &&
29548 + addr_type != IPV6_ADDR_ANY &&
29549 + addr_type != IPV6_ADDR_ANY &&
29550 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
29553 if (addr_type == IPV6_ADDR_MAPPED &&
29555 - (!sk2_rcv_saddr || !sk_rcv_saddr || sk_rcv_saddr == sk2_rcv_saddr))
29556 + ipv4_rcv_saddr_equal(sk, sk2))
29560 @@ -2772,7 +2790,10 @@ static void if6_seq_stop(struct seq_file
29561 static int if6_seq_show(struct seq_file *seq, void *v)
29563 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
29566 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
29567 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
29569 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
29571 ifp->idev->dev->ifindex,
29572 @@ -3254,6 +3275,11 @@ static int inet6_dump_addr(struct sk_buf
29573 struct inet6_ifaddr *ifa;
29574 struct ifmcaddr6 *ifmca;
29575 struct ifacaddr6 *ifaca;
29576 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29578 + /* disable ipv6 on non v6 guests */
29579 + if (nxi && !nx_info_has_v6(nxi))
29582 s_idx = cb->args[0];
29583 s_ip_idx = ip_idx = cb->args[1];
29584 @@ -3275,6 +3301,8 @@ static int inet6_dump_addr(struct sk_buf
29585 ifa = ifa->if_next, ip_idx++) {
29586 if (ip_idx < s_ip_idx)
29588 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
29590 if ((err = inet6_fill_ifaddr(skb, ifa,
29591 NETLINK_CB(cb->skb).pid,
29592 cb->nlh->nlmsg_seq, RTM_NEWADDR,
29593 @@ -3288,6 +3316,8 @@ static int inet6_dump_addr(struct sk_buf
29594 ifmca = ifmca->next, ip_idx++) {
29595 if (ip_idx < s_ip_idx)
29597 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
29599 if ((err = inet6_fill_ifmcaddr(skb, ifmca,
29600 NETLINK_CB(cb->skb).pid,
29601 cb->nlh->nlmsg_seq, RTM_GETMULTICAST,
29602 @@ -3301,6 +3331,8 @@ static int inet6_dump_addr(struct sk_buf
29603 ifaca = ifaca->aca_next, ip_idx++) {
29604 if (ip_idx < s_ip_idx)
29606 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
29608 if ((err = inet6_fill_ifacaddr(skb, ifaca,
29609 NETLINK_CB(cb->skb).pid,
29610 cb->nlh->nlmsg_seq, RTM_GETANYCAST,
29611 @@ -3577,12 +3609,19 @@ static int inet6_dump_ifinfo(struct sk_b
29612 int s_idx = cb->args[0];
29613 struct net_device *dev;
29614 struct inet6_dev *idev;
29615 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
29617 + /* FIXME: maybe disable ipv6 on non v6 guests?
29618 + if (skb->sk && skb->sk->sk_vx_info)
29619 + return skb->len; */
29621 read_lock(&dev_base_lock);
29623 for_each_netdev(dev) {
29626 + if (!v6_dev_in_nx_info(dev, nxi))
29628 if ((idev = in6_dev_get(dev)) == NULL)
29630 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
29631 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
29632 --- linux-2.6.22.10/net/ipv6/af_inet6.c 2007-10-30 01:57:15 +0100
29633 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/af_inet6.c 2007-10-05 12:29:05 +0200
29635 #include <linux/netdevice.h>
29636 #include <linux/icmpv6.h>
29637 #include <linux/netfilter_ipv6.h>
29638 +#include <linux/vs_inet6.h>
29640 #include <net/ip.h>
29641 #include <net/ipv6.h>
29642 @@ -150,9 +151,12 @@ lookup_protocol:
29646 + if ((protocol == IPPROTO_ICMPV6) &&
29647 + nx_capable(answer->capability, NXC_RAW_ICMP))
29649 if (answer->capability > 0 && !capable(answer->capability))
29650 goto out_rcu_unlock;
29653 sock->ops = answer->ops;
29654 answer_prot = answer->prot;
29655 answer_no_check = answer->no_check;
29656 @@ -250,6 +254,7 @@ int inet6_bind(struct socket *sock, stru
29657 struct sock *sk = sock->sk;
29658 struct inet_sock *inet = inet_sk(sk);
29659 struct ipv6_pinfo *np = inet6_sk(sk);
29660 + struct nx_v6_sock_addr nsa;
29662 unsigned short snum;
29664 @@ -261,6 +266,11 @@ int inet6_bind(struct socket *sock, stru
29666 if (addr_len < SIN6_LEN_RFC2133)
29669 + err = v6_map_sock_addr(inet, addr, &nsa);
29673 addr_type = ipv6_addr_type(&addr->sin6_addr);
29674 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
29676 @@ -284,6 +294,10 @@ int inet6_bind(struct socket *sock, stru
29677 err = -EADDRNOTAVAIL;
29680 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
29681 + err = -EADDRNOTAVAIL;
29685 if (addr_type != IPV6_ADDR_ANY) {
29686 struct net_device *dev = NULL;
29687 @@ -309,6 +323,11 @@ int inet6_bind(struct socket *sock, stru
29691 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
29692 + err = -EADDRNOTAVAIL;
29696 /* ipv4 addr of the socket is invalid. Only the
29697 * unspecified and mapped address have a v4 equivalent.
29699 @@ -326,6 +345,8 @@ int inet6_bind(struct socket *sock, stru
29703 + v6_set_sock_addr(inet, &nsa);
29705 inet->rcv_saddr = v4addr;
29706 inet->saddr = v4addr;
29708 @@ -420,9 +441,11 @@ int inet6_getname(struct socket *sock, s
29710 sin->sin6_port = inet->dport;
29711 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
29712 + /* FIXME: remap lback? */
29714 sin->sin6_flowinfo = np->flow_label;
29716 + /* FIXME: remap lback? */
29717 if (ipv6_addr_any(&np->rcv_saddr))
29718 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
29720 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
29721 --- linux-2.6.22.10/net/ipv6/fib6_rules.c 2007-07-09 13:20:06 +0200
29722 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/fib6_rules.c 2007-08-12 00:22:19 +0200
29723 @@ -107,7 +107,7 @@ static int fib6_rule_action(struct fib_r
29724 r->src.plen && !(flags & RT6_LOOKUP_F_HAS_SADDR)) {
29725 struct in6_addr saddr;
29726 if (ipv6_get_saddr(&rt->u.dst, &flp->fl6_dst,
29730 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
29732 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
29733 --- linux-2.6.22.10/net/ipv6/inet6_hashtables.c 2007-05-02 19:25:45 +0200
29734 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/inet6_hashtables.c 2007-08-05 20:53:13 +0200
29737 #include <linux/module.h>
29738 #include <linux/random.h>
29739 +#include <linux/vs_inet6.h>
29741 #include <net/inet_connection_sock.h>
29742 #include <net/inet_hashtables.h>
29743 @@ -121,6 +122,9 @@ struct sock *inet6_lookup_listener(struc
29744 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29748 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29751 if (sk->sk_bound_dev_if) {
29752 if (sk->sk_bound_dev_if != dif)
29753 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
29754 --- linux-2.6.22.10/net/ipv6/ip6_output.c 2007-10-30 01:57:15 +0100
29755 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/ip6_output.c 2007-09-30 14:58:01 +0200
29756 @@ -884,7 +884,7 @@ static int ip6_dst_lookup_tail(struct so
29757 goto out_err_release;
29759 if (ipv6_addr_any(&fl->fl6_src)) {
29760 - err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src);
29761 + err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src, sk->sk_nx_info);
29763 goto out_err_release;
29765 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
29766 --- linux-2.6.22.10/net/ipv6/ndisc.c 2007-10-30 01:57:15 +0100
29767 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/ndisc.c 2007-09-30 14:58:01 +0200
29768 @@ -531,7 +531,7 @@ static void ndisc_send_na(struct net_dev
29772 - if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr))
29773 + if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr, NULL))
29775 src_addr = &tmpaddr;
29777 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
29778 --- linux-2.6.22.10/net/ipv6/route.c 2007-07-09 13:20:06 +0200
29779 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/route.c 2007-08-12 00:22:19 +0200
29780 @@ -2182,7 +2182,7 @@ static int rt6_fill_node(struct sk_buff
29781 NLA_PUT_U32(skb, RTA_IIF, iif);
29783 struct in6_addr saddr_buf;
29784 - if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf) == 0)
29785 + if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf, (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
29786 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
29789 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
29790 --- linux-2.6.22.10/net/ipv6/tcp_ipv6.c 2007-10-30 01:57:15 +0100
29791 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/tcp_ipv6.c 2007-09-18 12:32:20 +0200
29794 #include <linux/crypto.h>
29795 #include <linux/scatterlist.h>
29796 +#include <linux/vs_inet6.h>
29798 /* Socket used for sending RSTs and ACKs */
29799 static struct socket *tcp6_socket;
29800 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
29801 * connect() to INADDR_ANY means loopback (BSD'ism).
29804 - if(ipv6_addr_any(&usin->sin6_addr))
29805 - usin->sin6_addr.s6_addr[15] = 0x1;
29806 + if(ipv6_addr_any(&usin->sin6_addr)) {
29807 + struct nx_info *nxi = sk->sk_nx_info;
29809 + if (nxi && nx_info_has_v6(nxi))
29810 + /* FIXME: remap lback? */
29811 + usin->sin6_addr = nxi->v6.ip;
29813 + usin->sin6_addr.s6_addr[15] = 0x1;
29816 addr_type = ipv6_addr_type(&usin->sin6_addr);
29818 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
29819 --- linux-2.6.22.10/net/ipv6/udp.c 2007-07-09 13:20:06 +0200
29820 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/udp.c 2007-08-12 03:34:32 +0200
29823 #include <linux/proc_fs.h>
29824 #include <linux/seq_file.h>
29825 +#include <linux/vs_inet6.h>
29826 #include "udp_impl.h"
29828 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
29829 @@ -82,6 +83,10 @@ static struct sock *__udp6_lib_lookup(st
29830 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
29834 + /* block non nx_info ips */
29835 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
29838 if (!ipv6_addr_any(&np->daddr)) {
29839 if (!ipv6_addr_equal(&np->daddr, saddr))
29840 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
29841 --- linux-2.6.22.10/net/ipv6/xfrm6_policy.c 2007-07-09 13:20:06 +0200
29842 +++ linux-2.6.22.10-vs2.3.0.29/net/ipv6/xfrm6_policy.c 2007-08-12 00:22:19 +0200
29843 @@ -49,7 +49,7 @@ static int xfrm6_get_saddr(xfrm_address_
29845 if (!xfrm6_dst_lookup((struct xfrm_dst **)&rt, &fl_tunnel)) {
29846 ipv6_get_saddr(&rt->u.dst, (struct in6_addr *)&daddr->a6,
29847 - (struct in6_addr *)&saddr->a6);
29848 + (struct in6_addr *)&saddr->a6, NULL);
29849 dst_release(&rt->u.dst);
29852 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
29853 --- linux-2.6.22.10/net/netlink/af_netlink.c 2007-07-09 13:20:07 +0200
29854 +++ linux-2.6.22.10-vs2.3.0.29/net/netlink/af_netlink.c 2007-08-05 20:53:13 +0200
29856 #include <linux/audit.h>
29857 #include <linux/selinux.h>
29858 #include <linux/mutex.h>
29859 +#include <linux/vs_context.h>
29860 +#include <linux/vs_network.h>
29861 +#include <linux/vs_limit.h>
29863 #include <net/sock.h>
29864 #include <net/scm.h>
29865 @@ -885,6 +888,10 @@ static inline int do_one_broadcast(struc
29866 !test_bit(p->group - 1, nlk->groups))
29869 + if (sk->sk_nx_info &&
29870 + (p->group == RTNLGRP_IPV4_IFADDR || p->group == RTNLGRP_IPV6_IFADDR))
29874 netlink_overrun(sk);
29876 diff -NurpP --minimal linux-2.6.22.16/net/rxrpc/Kconfig linux-2.6.22.16-vs2.3.0.32/net/rxrpc/Kconfig
29877 --- linux-2.6.22.16/net/rxrpc/Kconfig 2008-01-18 12:27:36 +0100
29878 +++ linux-2.6.22.16-vs2.3.0.32/net/rxrpc/Kconfig 2008-01-18 12:59:53 +0100
29882 tristate "RxRPC session sockets"
29883 - depends on INET && EXPERIMENTAL
29884 + depends on INET && EXPERIMENTAL && !VSERVER_SECURITY
29887 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
29888 --- linux-2.6.22.10/net/sctp/ipv6.c 2007-10-30 01:57:15 +0100
29889 +++ linux-2.6.22.10-vs2.3.0.29/net/sctp/ipv6.c 2007-08-12 00:22:19 +0200
29890 @@ -303,7 +303,7 @@ static void sctp_v6_get_saddr(struct sct
29891 __FUNCTION__, asoc, dst, NIP6(daddr->v6.sin6_addr));
29894 - ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr);
29895 + ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr, asoc->base.sk->sk_nx_info);
29896 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n",
29897 NIP6(saddr->v6.sin6_addr));
29899 diff -NurpP --minimal linux-2.6.22.10/net/socket.c linux-2.6.22.10-vs2.3.0.29/net/socket.c
29900 --- linux-2.6.22.10/net/socket.c 2007-10-30 01:57:15 +0100
29901 +++ linux-2.6.22.10-vs2.3.0.29/net/socket.c 2007-09-05 03:06:12 +0200
29904 #include <net/sock.h>
29905 #include <linux/netfilter.h>
29906 +#include <linux/vs_base.h>
29907 +#include <linux/vs_socket.h>
29908 +#include <linux/vs_inet.h>
29909 +#include <linux/vs_inet6.h>
29911 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
29912 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
29913 @@ -543,7 +547,7 @@ static inline int __sock_sendmsg(struct
29914 struct msghdr *msg, size_t size)
29916 struct sock_iocb *si = kiocb_to_siocb(iocb);
29922 @@ -554,7 +558,22 @@ static inline int __sock_sendmsg(struct
29926 - return sock->ops->sendmsg(iocb, sock, msg, size);
29927 + len = sock->ops->sendmsg(iocb, sock, msg, size);
29930 + vx_sock_send(sock->sk, size);
29932 + vx_sock_fail(sock->sk, size);
29934 + vxdprintk(VXD_CBIT(net, 7),
29935 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29937 + (sock->sk)?sock->sk->sk_nx_info:0,
29938 + (sock->sk)?sock->sk->sk_vx_info:0,
29939 + (sock->sk)?sock->sk->sk_xid:0,
29940 + (sock->sk)?sock->sk->sk_nid:0,
29941 + (unsigned int)size, len);
29945 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
29946 @@ -623,7 +642,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
29947 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
29948 struct msghdr *msg, size_t size, int flags)
29952 struct sock_iocb *si = kiocb_to_siocb(iocb);
29955 @@ -636,7 +655,18 @@ static inline int __sock_recvmsg(struct
29959 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
29960 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
29961 + if ((len >= 0) && sock->sk)
29962 + vx_sock_recv(sock->sk, len);
29963 + vxdprintk(VXD_CBIT(net, 7),
29964 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29966 + (sock->sk)?sock->sk->sk_nx_info:0,
29967 + (sock->sk)?sock->sk->sk_vx_info:0,
29968 + (sock->sk)?sock->sk->sk_xid:0,
29969 + (sock->sk)?sock->sk->sk_nid:0,
29970 + (unsigned int)size, len);
29974 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
29975 @@ -1090,6 +1120,13 @@ static int __sock_create(int family, int
29976 if (type < 0 || type >= SOCK_MAX)
29979 + if (!nx_check(0, VS_ADMIN)) {
29980 + if (family == PF_INET && !current_nx_info_has_v4())
29981 + return -EAFNOSUPPORT;
29982 + if (family == PF_INET6 && !current_nx_info_has_v6())
29983 + return -EAFNOSUPPORT;
29988 This uglymoron is moved from INET layer to here to avoid
29989 @@ -1207,6 +1244,7 @@ asmlinkage long sys_socket(int family, i
29993 + set_bit(SOCK_USER_SOCKET, &sock->flags);
29994 retval = sock_map_fd(sock);
29997 @@ -1239,10 +1277,12 @@ asmlinkage long sys_socketpair(int famil
29998 err = sock_create(family, type, protocol, &sock1);
30001 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
30003 err = sock_create(family, type, protocol, &sock2);
30005 goto out_release_1;
30006 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
30008 err = sock1->ops->socketpair(sock1, sock2);
30010 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
30011 --- linux-2.6.22.10/net/sunrpc/auth.c 2007-05-02 19:25:48 +0200
30012 +++ linux-2.6.22.10-vs2.3.0.29/net/sunrpc/auth.c 2007-08-05 20:53:13 +0200
30014 #include <linux/errno.h>
30015 #include <linux/sunrpc/clnt.h>
30016 #include <linux/spinlock.h>
30017 +#include <linux/vs_tag.h>
30020 # define RPCDBG_FACILITY RPCDBG_AUTH
30021 @@ -263,6 +264,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
30022 struct auth_cred acred = {
30023 .uid = current->fsuid,
30024 .gid = current->fsgid,
30025 + .tag = dx_current_tag(),
30026 .group_info = current->group_info,
30028 struct rpc_cred *ret;
30029 @@ -282,6 +284,7 @@ rpcauth_bindcred(struct rpc_task *task)
30030 struct auth_cred acred = {
30031 .uid = current->fsuid,
30032 .gid = current->fsgid,
30033 + .tag = dx_current_tag(),
30034 .group_info = current->group_info,
30036 struct rpc_cred *ret;
30037 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
30038 --- linux-2.6.22.10/net/sunrpc/auth_unix.c 2007-05-02 19:25:48 +0200
30039 +++ linux-2.6.22.10-vs2.3.0.29/net/sunrpc/auth_unix.c 2007-08-05 20:53:13 +0200
30040 @@ -11,12 +11,14 @@
30041 #include <linux/module.h>
30042 #include <linux/sunrpc/clnt.h>
30043 #include <linux/sunrpc/auth.h>
30044 +#include <linux/vs_tag.h>
30046 #define NFS_NGROUPS 16
30049 struct rpc_cred uc_base;
30052 gid_t uc_gids[NFS_NGROUPS];
30054 #define uc_uid uc_base.cr_uid
30055 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
30056 if (flags & RPCAUTH_LOOKUP_ROOTCREDS) {
30059 + cred->uc_tag = dx_current_tag();
30060 cred->uc_gids[0] = NOGROUP;
30062 int groups = acred->group_info->ngroups;
30063 @@ -87,6 +90,7 @@ unx_create_cred(struct rpc_auth *auth, s
30065 cred->uc_uid = acred->uid;
30066 cred->uc_gid = acred->gid;
30067 + cred->uc_tag = acred->tag;
30068 for (i = 0; i < groups; i++)
30069 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
30070 if (i < NFS_NGROUPS)
30071 @@ -118,7 +122,8 @@ unx_match(struct auth_cred *acred, struc
30074 if (cred->uc_uid != acred->uid
30075 - || cred->uc_gid != acred->gid)
30076 + || cred->uc_gid != acred->gid
30077 + || cred->uc_tag != acred->tag)
30080 groups = acred->group_info->ngroups;
30081 @@ -144,7 +149,7 @@ unx_marshal(struct rpc_task *task, __be3
30082 struct rpc_clnt *clnt = task->tk_client;
30083 struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred;
30084 __be32 *base, *hold;
30088 *p++ = htonl(RPC_AUTH_UNIX);
30090 @@ -154,9 +159,12 @@ unx_marshal(struct rpc_task *task, __be3
30091 * Copy the UTS nodename captured when the client was created.
30093 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
30094 + tag = task->tk_client->cl_tag;
30096 - *p++ = htonl((u32) cred->uc_uid);
30097 - *p++ = htonl((u32) cred->uc_gid);
30098 + *p++ = htonl((u32) TAGINO_UID(tag,
30099 + cred->uc_uid, cred->uc_tag));
30100 + *p++ = htonl((u32) TAGINO_GID(tag,
30101 + cred->uc_gid, cred->uc_tag));
30103 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
30104 *p++ = htonl((u32) cred->uc_gids[i]);
30105 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
30106 --- linux-2.6.22.10/net/sunrpc/clnt.c 2007-07-09 13:20:13 +0200
30107 +++ linux-2.6.22.10-vs2.3.0.29/net/sunrpc/clnt.c 2007-08-05 20:53:13 +0200
30109 #include <linux/smp_lock.h>
30110 #include <linux/utsname.h>
30111 #include <linux/workqueue.h>
30112 +#include <linux/vs_cvirt.h>
30114 #include <linux/sunrpc/clnt.h>
30115 #include <linux/sunrpc/rpc_pipe_fs.h>
30116 @@ -249,7 +250,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
30117 clnt->cl_oneshot = 1;
30118 if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
30119 clnt->cl_discrtry = 1;
30121 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
30122 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
30123 + clnt->cl_tag = 1; */
30126 EXPORT_SYMBOL_GPL(rpc_create);
30127 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
30128 --- linux-2.6.22.10/net/unix/af_unix.c 2007-07-09 13:20:13 +0200
30129 +++ linux-2.6.22.10-vs2.3.0.29/net/unix/af_unix.c 2007-08-05 20:53:13 +0200
30130 @@ -115,6 +115,8 @@
30131 #include <linux/mount.h>
30132 #include <net/checksum.h>
30133 #include <linux/security.h>
30134 +#include <linux/vs_context.h>
30135 +#include <linux/vs_limit.h>
30137 int sysctl_unix_max_dgram_qlen __read_mostly = 10;
30139 @@ -252,6 +254,8 @@ static struct sock *__unix_find_socket_b
30140 sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
30141 struct unix_sock *u = unix_sk(s);
30143 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
30145 if (u->addr->len == len &&
30146 !memcmp(u->addr->name, sunname, len))
30148 @@ -807,7 +811,7 @@ static int unix_bind(struct socket *sock
30151 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
30152 - err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
30153 + err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0, NULL);
30155 goto out_mknod_dput;
30156 mutex_unlock(&nd.dentry->d_inode->i_mutex);
30157 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
30158 --- linux-2.6.22.10/net/x25/af_x25.c 2007-07-09 13:20:13 +0200
30159 +++ linux-2.6.22.10-vs2.3.0.29/net/x25/af_x25.c 2007-08-05 20:53:13 +0200
30160 @@ -500,7 +500,10 @@ static int x25_create(struct socket *soc
30164 - sock_init_data(sock, sk);
30165 + sk->sk_socket = sock;
30166 + sk->sk_type = sock->type;
30167 + sk->sk_sleep = &sock->wait;
30170 x25_init_timers(sk);
30172 diff -NurpP --minimal linux-2.6.22.10/security/Kconfig linux-2.6.22.10-vs2.3.0.29/security/Kconfig
30173 --- linux-2.6.22.10/security/Kconfig 2006-11-30 21:19:47 +0100
30174 +++ linux-2.6.22.10-vs2.3.0.29/security/Kconfig 2007-08-05 20:53:13 +0200
30175 @@ -6,6 +6,7 @@ menu "Security options"
30178 bool "Enable access key retention support"
30179 + depends on !VSERVER_SECURITY
30181 This option provides support for retaining authentication tokens and
30182 access keys in the kernel.
30183 diff -NurpP --minimal linux-2.6.22.10/security/commoncap.c linux-2.6.22.10-vs2.3.0.29/security/commoncap.c
30184 --- linux-2.6.22.10/security/commoncap.c 2007-07-09 13:20:14 +0200
30185 +++ linux-2.6.22.10-vs2.3.0.29/security/commoncap.c 2007-08-05 20:53:13 +0200
30186 @@ -22,10 +22,11 @@
30187 #include <linux/ptrace.h>
30188 #include <linux/xattr.h>
30189 #include <linux/hugetlb.h>
30190 +#include <linux/vs_context.h>
30192 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
30194 - NETLINK_CB(skb).eff_cap = current->cap_effective;
30195 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
30199 @@ -43,7 +44,7 @@ EXPORT_SYMBOL(cap_netlink_recv);
30200 int cap_capable (struct task_struct *tsk, int cap)
30202 /* Derived from include/linux/sched.h:capable. */
30203 - if (cap_raised(tsk->cap_effective, cap))
30204 + if (vx_cap_raised(tsk->vx_info, tsk->cap_effective, cap))
30208 @@ -141,7 +142,8 @@ void cap_bprm_apply_creds (struct linux_
30209 /* Derived from fs/exec.c:compute_creds. */
30210 kernel_cap_t new_permitted, working;
30212 - new_permitted = cap_intersect (bprm->cap_permitted, cap_bset);
30213 + new_permitted = cap_intersect (bprm->cap_permitted,
30214 + vx_current_cap_bset());
30215 working = cap_intersect (bprm->cap_inheritable,
30216 current->cap_inheritable);
30217 new_permitted = cap_combine (new_permitted, working);
30218 @@ -310,7 +312,8 @@ void cap_task_reparent_to_init (struct t
30220 int cap_syslog (int type)
30222 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
30223 + if ((type != 3 && type != 10) &&
30224 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
30228 diff -NurpP --minimal linux-2.6.22.10/security/dummy.c linux-2.6.22.10-vs2.3.0.29/security/dummy.c
30229 --- linux-2.6.22.10/security/dummy.c 2007-05-02 19:25:51 +0200
30230 +++ linux-2.6.22.10-vs2.3.0.29/security/dummy.c 2007-08-05 20:53:13 +0200
30232 #include <linux/hugetlb.h>
30233 #include <linux/ptrace.h>
30234 #include <linux/file.h>
30235 +#include <linux/vs_context.h>
30237 static int dummy_ptrace (struct task_struct *parent, struct task_struct *child)
30239 @@ -678,7 +679,7 @@ static int dummy_sem_semop (struct sem_a
30241 static int dummy_netlink_send (struct sock *sk, struct sk_buff *skb)
30243 - NETLINK_CB(skb).eff_cap = current->cap_effective;
30244 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
30248 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
30249 --- linux-2.6.22.10/security/selinux/hooks.c 2007-10-30 01:57:15 +0100
30250 +++ linux-2.6.22.10-vs2.3.0.29/security/selinux/hooks.c 2007-10-30 01:21:54 +0100
30252 #include <linux/dccp.h>
30253 #include <linux/quota.h>
30254 #include <linux/un.h> /* for Unix socket types */
30255 -#include <net/af_unix.h> /* for Unix socket types */
30256 #include <linux/parser.h>
30257 #include <linux/nfs_mount.h>
30258 #include <net/ipv6.h>