1 diff -NurpP --minimal linux-2.6.24-rc7/Documentation/vserver/debug.txt linux-2.6.24-rc7-vs2.2.0.5.0.7/Documentation/vserver/debug.txt
2 --- linux-2.6.24-rc7/Documentation/vserver/debug.txt 1970-01-01 01:00:00 +0100
3 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/Documentation/vserver/debug.txt 2007-12-13 13:25:42 +0100
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.24-rc7/arch/alpha/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/Kconfig
160 --- linux-2.6.24-rc7/arch/alpha/Kconfig 2007-11-29 01:09:49 +0100
161 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/Kconfig 2007-12-13 13:25:26 +0100
162 @@ -665,6 +665,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-2.6.24-rc7/arch/alpha/kernel/asm-offsets.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/asm-offsets.c
172 --- linux-2.6.24-rc7/arch/alpha/kernel/asm-offsets.c 2006-02-15 13:54:10 +0100
173 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/asm-offsets.c 2007-12-13 13:25:44 +0100
174 @@ -36,6 +36,7 @@ void foo(void)
175 DEFINE(PT_PTRACED, PT_PTRACED);
176 DEFINE(CLONE_VM, CLONE_VM);
177 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
178 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
179 DEFINE(SIGCHLD, SIGCHLD);
182 diff -NurpP --minimal linux-2.6.24-rc7/arch/alpha/kernel/entry.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/entry.S
183 --- linux-2.6.24-rc7/arch/alpha/kernel/entry.S 2007-11-29 01:09:50 +0100
184 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/entry.S 2007-12-13 13:25:48 +0100
185 @@ -643,7 +643,7 @@ kernel_thread:
186 stq $2, 152($sp) /* HAE */
188 /* Shuffle FLAGS to the front; add CLONE_VM. */
189 - ldi $1, CLONE_VM|CLONE_UNTRACED
190 + ldi $1, CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
194 @@ -872,24 +872,15 @@ sys_getxgid:
201 - ldq $2, TI_TASK($8)
203 - /* See linux/kernel/timer.c sys_getppid for discussion
204 - about this loop. */
205 - ldq $3, TASK_GROUP_LEADER($2)
206 - ldq $4, TASK_REAL_PARENT($3)
207 - ldl $0, TASK_TGID($2)
208 -1: ldl $1, TASK_TGID($4)
212 - ldq $3, TASK_GROUP_LEADER($2)
213 - ldq $4, TASK_REAL_PARENT($3)
219 + jsr $26, do_getxpid
226 diff -NurpP --minimal linux-2.6.24-rc7/arch/alpha/kernel/osf_sys.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/osf_sys.c
227 --- linux-2.6.24-rc7/arch/alpha/kernel/osf_sys.c 2007-11-29 01:09:50 +0100
228 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/osf_sys.c 2007-12-13 13:25:31 +0100
229 @@ -883,7 +883,7 @@ osf_gettimeofday(struct timeval32 __user
233 - do_gettimeofday(&ktv);
234 + vx_gettimeofday(&ktv);
235 if (put_tv32(tv, &ktv))
238 diff -NurpP --minimal linux-2.6.24-rc7/arch/alpha/kernel/ptrace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/ptrace.c
239 --- linux-2.6.24-rc7/arch/alpha/kernel/ptrace.c 2007-11-29 01:09:50 +0100
240 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/ptrace.c 2007-12-13 13:25:11 +0100
242 #include <linux/slab.h>
243 #include <linux/security.h>
244 #include <linux/signal.h>
245 +#include <linux/vs_base.h>
247 #include <asm/uaccess.h>
248 #include <asm/pgtable.h>
249 diff -NurpP --minimal linux-2.6.24-rc7/arch/alpha/kernel/semaphore.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/semaphore.c
250 --- linux-2.6.24-rc7/arch/alpha/kernel/semaphore.c 2007-11-29 01:09:50 +0100
251 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/semaphore.c 2007-12-13 13:25:29 +0100
252 @@ -68,8 +68,8 @@ __down_failed(struct semaphore *sem)
253 DECLARE_WAITQUEUE(wait, tsk);
255 #ifdef CONFIG_DEBUG_SEMAPHORE
256 - printk("%s(%d): down failed(%p)\n",
257 - tsk->comm, task_pid_nr(tsk), sem);
258 + printk("%s(%d:#%u): down failed(%p)\n",
259 + tsk->comm, task_pid_nr(tsk), tsk->xid, sem);
262 tsk->state = TASK_UNINTERRUPTIBLE;
263 @@ -97,8 +97,8 @@ __down_failed(struct semaphore *sem)
266 #ifdef CONFIG_DEBUG_SEMAPHORE
267 - printk("%s(%d): down acquired(%p)\n",
268 - tsk->comm, task_pid_nr(tsk), sem);
269 + printk("%s(%d:#%u): down acquired(%p)\n",
270 + tsk->comm, task_pid_nr(tsk), tsk->xid, sem);
274 @@ -110,8 +110,8 @@ __down_failed_interruptible(struct semap
277 #ifdef CONFIG_DEBUG_SEMAPHORE
278 - printk("%s(%d): down failed(%p)\n",
279 - tsk->comm, task_pid_nr(tsk), sem);
280 + printk("%s(%d:#%u): down failed(%p)\n",
281 + tsk->comm, task_pid_nr(tsk), tsk->xid, sem);
284 tsk->state = TASK_INTERRUPTIBLE;
285 diff -NurpP --minimal linux-2.6.24-rc7/arch/alpha/kernel/systbls.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/systbls.S
286 --- linux-2.6.24-rc7/arch/alpha/kernel/systbls.S 2007-07-09 13:17:31 +0200
287 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/systbls.S 2007-12-13 13:25:27 +0100
288 @@ -446,7 +446,7 @@ sys_call_table:
289 .quad sys_stat64 /* 425 */
292 - .quad sys_ni_syscall /* sys_vserver */
293 + .quad sys_vserver /* sys_vserver */
294 .quad sys_ni_syscall /* sys_mbind */
295 .quad sys_ni_syscall /* sys_get_mempolicy */
296 .quad sys_ni_syscall /* sys_set_mempolicy */
297 diff -NurpP --minimal linux-2.6.24-rc7/arch/alpha/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/traps.c
298 --- linux-2.6.24-rc7/arch/alpha/kernel/traps.c 2007-11-29 01:09:50 +0100
299 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/kernel/traps.c 2007-12-13 13:25:29 +0100
300 @@ -182,7 +182,8 @@ die_if_kernel(char * str, struct pt_regs
302 printk("CPU %d ", hard_smp_processor_id());
304 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
305 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
306 + task_pid_nr(current), current->xid, str, err);
307 dik_show_regs(regs, r9_15);
308 add_taint(TAINT_DIE);
309 dik_show_trace((unsigned long *)(regs+1));
310 diff -NurpP --minimal linux-2.6.24-rc7/arch/alpha/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/mm/fault.c
311 --- linux-2.6.24-rc7/arch/alpha/mm/fault.c 2007-11-29 01:09:50 +0100
312 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/alpha/mm/fault.c 2007-12-13 13:25:29 +0100
313 @@ -193,8 +193,8 @@ do_page_fault(unsigned long address, uns
314 down_read(&mm->mmap_sem);
317 - printk(KERN_ALERT "VM: killing process %s(%d)\n",
318 - current->comm, task_pid_nr(current));
319 + printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
320 + current->comm, task_pid_nr(current), current->xid);
321 if (!user_mode(regs))
323 do_group_exit(SIGKILL);
324 diff -NurpP --minimal linux-2.6.24-rc7/arch/arm/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/arm/Kconfig
325 --- linux-2.6.24-rc7/arch/arm/Kconfig 2007-12-31 17:58:08 +0100
326 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/arm/Kconfig 2007-12-31 12:34:02 +0100
327 @@ -1080,6 +1080,8 @@ source "kernel/Kconfig.instrumentation"
329 source "arch/arm/Kconfig.debug"
331 +source "kernel/vserver/Kconfig"
333 source "security/Kconfig"
335 source "crypto/Kconfig"
336 diff -NurpP --minimal linux-2.6.24-rc7/arch/arm/kernel/calls.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/arm/kernel/calls.S
337 --- linux-2.6.24-rc7/arch/arm/kernel/calls.S 2007-11-29 01:09:50 +0100
338 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/arm/kernel/calls.S 2007-12-13 13:25:28 +0100
340 /* 310 */ CALL(sys_request_key)
342 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
343 -/* vserver */ CALL(sys_ni_syscall)
346 /* 315 */ CALL(sys_ioprio_get)
347 CALL(sys_inotify_init)
348 diff -NurpP --minimal linux-2.6.24-rc7/arch/arm/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/arm/kernel/process.c
349 --- linux-2.6.24-rc7/arch/arm/kernel/process.c 2007-11-29 01:09:50 +0100
350 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/arm/kernel/process.c 2007-12-13 13:25:44 +0100
351 @@ -265,7 +265,8 @@ void __show_regs(struct pt_regs *regs)
352 void show_regs(struct pt_regs * regs)
355 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
356 + printk("Pid: %d[#%u], comm: %20s\n",
357 + task_pid_nr(current), current->xid, current->comm);
361 @@ -427,7 +428,8 @@ pid_t kernel_thread(int (*fn)(void *), v
362 regs.ARM_pc = (unsigned long)kernel_thread_helper;
363 regs.ARM_cpsr = SVC_MODE;
365 - return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
366 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
367 + 0, ®s, 0, NULL, NULL);
369 EXPORT_SYMBOL(kernel_thread);
371 diff -NurpP --minimal linux-2.6.24-rc7/arch/arm/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/arm/kernel/traps.c
372 --- linux-2.6.24-rc7/arch/arm/kernel/traps.c 2007-12-31 17:58:08 +0100
373 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/arm/kernel/traps.c 2007-12-31 12:34:02 +0100
374 @@ -222,8 +222,8 @@ static void __die(const char *str, int e
375 str, err, ++die_counter);
378 - printk("Process %s (pid: %d, stack limit = 0x%p)\n",
379 - tsk->comm, task_pid_nr(tsk), thread + 1);
380 + printk("Process %s (pid: %d:#%u, stack limit = 0x%p)\n",
381 + tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
383 if (!user_mode(regs) || in_interrupt()) {
384 dump_mem("Stack: ", regs->ARM_sp,
385 diff -NurpP --minimal linux-2.6.24-rc7/arch/arm/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/arm/mm/fault.c
386 --- linux-2.6.24-rc7/arch/arm/mm/fault.c 2007-11-29 01:09:52 +0100
387 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/arm/mm/fault.c 2007-12-13 13:25:29 +0100
388 @@ -265,7 +265,8 @@ do_page_fault(unsigned long addr, unsign
389 * happened to us that made us unable to handle
390 * the page fault gracefully.
392 - printk("VM: killing process %s\n", tsk->comm);
393 + printk("VM: killing process %s(%d:#%u)\n",
394 + tsk->comm, task_pid_nr(tsk), tsk->xid);
395 do_group_exit(SIGKILL);
398 diff -NurpP --minimal linux-2.6.24-rc7/arch/cris/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/cris/Kconfig
399 --- linux-2.6.24-rc7/arch/cris/Kconfig 2007-11-29 01:09:56 +0100
400 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/cris/Kconfig 2007-12-13 13:25:26 +0100
401 @@ -217,6 +217,8 @@ source "kernel/Kconfig.instrumentation"
403 source "arch/cris/Kconfig.debug"
405 +source "kernel/vserver/Kconfig"
407 source "security/Kconfig"
409 source "crypto/Kconfig"
410 diff -NurpP --minimal linux-2.6.24-rc7/arch/cris/arch-v10/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/cris/arch-v10/kernel/process.c
411 --- linux-2.6.24-rc7/arch/cris/arch-v10/kernel/process.c 2007-11-29 01:09:57 +0100
412 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/cris/arch-v10/kernel/process.c 2007-12-13 13:25:44 +0100
413 @@ -103,7 +103,8 @@ int kernel_thread(int (*fn)(void *), voi
414 regs.dccr = 1 << I_DCCR_BITNR;
416 /* Ok, create the new process.. */
417 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
418 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
419 + 0, ®s, 0, NULL, NULL);
422 /* setup the child's kernel stack with a pt_regs and switch_stack on it.
423 diff -NurpP --minimal linux-2.6.24-rc7/arch/cris/arch-v32/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/cris/arch-v32/kernel/process.c
424 --- linux-2.6.24-rc7/arch/cris/arch-v32/kernel/process.c 2007-11-29 01:09:57 +0100
425 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/cris/arch-v32/kernel/process.c 2007-12-13 13:25:44 +0100
426 @@ -120,7 +120,8 @@ kernel_thread(int (*fn)(void *), void *
427 regs.ccs = 1 << (I_CCS_BITNR + CCS_SHIFT);
429 /* Create the new process. */
430 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
431 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
432 + 0, ®s, 0, NULL, NULL);
436 diff -NurpP --minimal linux-2.6.24-rc7/arch/frv/kernel/kernel_thread.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/frv/kernel/kernel_thread.S
437 --- linux-2.6.24-rc7/arch/frv/kernel/kernel_thread.S 2005-03-02 12:38:20 +0100
438 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/frv/kernel/kernel_thread.S 2007-12-13 13:25:44 +0100
440 #include <asm/unistd.h>
442 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
443 +#define CLONE_KTHREAD 0x10000000 /* kernel thread */
444 +#define CLONE_KT (CLONE_VM | CLONE_KTHREAD) /* kernel thread flags */
445 #define KERN_ERR "<3>"
448 @@ -37,7 +39,7 @@ kernel_thread:
450 # start by forking the current process, but with shared VM
451 setlos.p #__NR_clone,gr7 ; syscall number
452 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
453 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
454 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
456 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
457 diff -NurpP --minimal linux-2.6.24-rc7/arch/h8300/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/h8300/Kconfig
458 --- linux-2.6.24-rc7/arch/h8300/Kconfig 2007-11-29 01:09:58 +0100
459 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/h8300/Kconfig 2007-12-13 13:25:26 +0100
460 @@ -227,6 +227,8 @@ source "kernel/Kconfig.instrumentation"
462 source "arch/h8300/Kconfig.debug"
464 +source "kernel/vserver/Kconfig"
466 source "security/Kconfig"
468 source "crypto/Kconfig"
469 diff -NurpP --minimal linux-2.6.24-rc7/arch/h8300/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/h8300/kernel/process.c
470 --- linux-2.6.24-rc7/arch/h8300/kernel/process.c 2007-11-29 01:00:10 +0100
471 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/h8300/kernel/process.c 2007-12-13 13:25:44 +0100
472 @@ -135,7 +135,7 @@ int kernel_thread(int (*fn)(void *), voi
476 - clone_arg = flags | CLONE_VM;
477 + clone_arg = flags | CLONE_VM | CLONE_KTHREAD;
478 __asm__("mov.l sp,er3\n\t"
481 diff -NurpP --minimal linux-2.6.24-rc7/arch/ia64/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/Kconfig
482 --- linux-2.6.24-rc7/arch/ia64/Kconfig 2007-11-29 01:10:02 +0100
483 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/Kconfig 2007-12-13 13:25:26 +0100
484 @@ -596,6 +596,8 @@ source "kernel/Kconfig.instrumentation"
486 source "arch/ia64/Kconfig.debug"
488 +source "kernel/vserver/Kconfig"
490 source "security/Kconfig"
492 source "crypto/Kconfig"
493 diff -NurpP --minimal linux-2.6.24-rc7/arch/ia64/ia32/ia32_entry.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/ia32/ia32_entry.S
494 --- linux-2.6.24-rc7/arch/ia64/ia32/ia32_entry.S 2007-11-29 01:00:17 +0100
495 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/ia32/ia32_entry.S 2007-12-13 13:25:28 +0100
496 @@ -446,7 +446,7 @@ ia32_syscall_table:
497 data8 sys_tgkill /* 270 */
498 data8 compat_sys_utimes
499 data8 sys32_fadvise64_64
500 - data8 sys_ni_syscall
501 + data8 sys32_vserver
503 data8 sys_ni_syscall /* 275 */
505 diff -NurpP --minimal linux-2.6.24-rc7/arch/ia64/ia32/sys_ia32.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/ia32/sys_ia32.c
506 --- linux-2.6.24-rc7/arch/ia64/ia32/sys_ia32.c 2007-11-29 01:10:03 +0100
507 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/ia32/sys_ia32.c 2007-12-13 13:25:31 +0100
508 @@ -1182,7 +1182,7 @@ sys32_gettimeofday (struct compat_timeva
512 - do_gettimeofday(&ktv);
513 + vx_gettimeofday(&ktv);
514 if (put_tv32(tv, &ktv))
517 diff -NurpP --minimal linux-2.6.24-rc7/arch/ia64/kernel/asm-offsets.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/asm-offsets.c
518 --- linux-2.6.24-rc7/arch/ia64/kernel/asm-offsets.c 2007-11-29 01:00:17 +0100
519 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/asm-offsets.c 2007-12-13 13:25:44 +0100
520 @@ -194,6 +194,7 @@ void foo(void)
521 /* for assembly files which can't include sched.h: */
522 DEFINE(IA64_CLONE_VFORK, CLONE_VFORK);
523 DEFINE(IA64_CLONE_VM, CLONE_VM);
524 + DEFINE(IA64_CLONE_KTHREAD, CLONE_KTHREAD);
527 DEFINE(IA64_CPUINFO_NSEC_PER_CYC_OFFSET,
528 diff -NurpP --minimal linux-2.6.24-rc7/arch/ia64/kernel/entry.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/entry.S
529 --- linux-2.6.24-rc7/arch/ia64/kernel/entry.S 2007-11-29 01:00:17 +0100
530 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/entry.S 2007-12-13 13:25:28 +0100
531 @@ -1547,7 +1547,7 @@ sys_call_table:
533 data8 sys_mq_getsetattr
535 - data8 sys_ni_syscall // reserved for vserver
537 data8 sys_waitid // 1270
539 data8 sys_request_key
540 diff -NurpP --minimal linux-2.6.24-rc7/arch/ia64/kernel/perfmon.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/perfmon.c
541 --- linux-2.6.24-rc7/arch/ia64/kernel/perfmon.c 2007-11-29 01:10:03 +0100
542 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/perfmon.c 2007-12-13 13:25:41 +0100
544 #include <linux/capability.h>
545 #include <linux/rcupdate.h>
546 #include <linux/completion.h>
547 +#include <linux/vs_memory.h>
549 #include <asm/errno.h>
550 #include <asm/intrinsics.h>
551 @@ -2389,7 +2390,7 @@ pfm_smpl_buffer_alloc(struct task_struct
553 insert_vm_struct(mm, vma);
555 - mm->total_vm += size >> PAGE_SHIFT;
556 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
557 vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
559 up_write(&task->mm->mmap_sem);
560 diff -NurpP --minimal linux-2.6.24-rc7/arch/ia64/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/process.c
561 --- linux-2.6.24-rc7/arch/ia64/kernel/process.c 2007-12-31 17:58:10 +0100
562 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/process.c 2007-12-31 12:36:36 +0100
563 @@ -106,8 +106,8 @@ show_regs (struct pt_regs *regs)
564 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
567 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
568 - smp_processor_id(), current->comm);
569 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
570 + current->xid, smp_processor_id(), current->comm);
571 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
572 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
573 init_utsname()->release);
574 @@ -705,7 +705,8 @@ kernel_thread (int (*fn)(void *), void *
575 regs.sw.ar_fpsr = regs.pt.ar_fpsr = ia64_getreg(_IA64_REG_AR_FPSR);
576 regs.sw.ar_bspstore = (unsigned long) current + IA64_RBS_OFFSET;
577 regs.sw.pr = (1 << PRED_KERNEL_STACK);
578 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s.pt, 0, NULL, NULL);
579 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
580 + 0, ®s.pt, 0, NULL, NULL);
582 EXPORT_SYMBOL(kernel_thread);
584 diff -NurpP --minimal linux-2.6.24-rc7/arch/ia64/kernel/ptrace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/ptrace.c
585 --- linux-2.6.24-rc7/arch/ia64/kernel/ptrace.c 2007-11-29 01:00:17 +0100
586 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/ptrace.c 2007-12-13 13:25:28 +0100
588 #include <linux/security.h>
589 #include <linux/audit.h>
590 #include <linux/signal.h>
591 +#include <linux/vs_base.h>
593 #include <asm/pgtable.h>
594 #include <asm/processor.h>
595 @@ -1447,6 +1448,9 @@ sys_ptrace (long request, pid_t pid, uns
596 read_unlock(&tasklist_lock);
599 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
603 if (pid == 1) /* no messing around with init! */
605 diff -NurpP --minimal linux-2.6.24-rc7/arch/ia64/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/traps.c
606 --- linux-2.6.24-rc7/arch/ia64/kernel/traps.c 2007-11-29 01:10:03 +0100
607 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/kernel/traps.c 2007-12-13 13:25:29 +0100
608 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
611 if (++die.lock_owner_depth < 3) {
612 - printk("%s[%d]: %s %ld [%d]\n",
613 - current->comm, task_pid_nr(current), str, err, ++die_counter);
614 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
615 + current->comm, task_pid_nr(current), current->xid,
616 + str, err, ++die_counter);
617 (void) notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV);
620 @@ -314,8 +315,9 @@ handle_fpu_swa (int fp_fault, struct pt_
621 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
622 last.time = current_jiffies + 5 * HZ;
624 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
625 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
626 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
627 + current->comm, task_pid_nr(current), current->xid,
628 + regs->cr_iip + ia64_psr(regs)->ri, isr);
632 diff -NurpP --minimal linux-2.6.24-rc7/arch/ia64/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/mm/fault.c
633 --- linux-2.6.24-rc7/arch/ia64/mm/fault.c 2007-11-29 01:10:03 +0100
634 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ia64/mm/fault.c 2007-12-13 13:25:11 +0100
636 #include <linux/interrupt.h>
637 #include <linux/kprobes.h>
638 #include <linux/kdebug.h>
639 +#include <linux/vs_memory.h>
641 #include <asm/pgtable.h>
642 #include <asm/processor.h>
643 diff -NurpP --minimal linux-2.6.24-rc7/arch/m32r/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m32r/kernel/process.c
644 --- linux-2.6.24-rc7/arch/m32r/kernel/process.c 2007-05-02 19:24:21 +0200
645 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m32r/kernel/process.c 2007-12-13 13:25:44 +0100
646 @@ -211,8 +211,8 @@ int kernel_thread(int (*fn)(void *), voi
647 regs.psw = M32R_PSW_BIE;
649 /* Ok, create the new process. */
650 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL,
652 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
653 + 0, ®s, 0, NULL, NULL);
657 diff -NurpP --minimal linux-2.6.24-rc7/arch/m32r/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m32r/kernel/traps.c
658 --- linux-2.6.24-rc7/arch/m32r/kernel/traps.c 2007-11-29 01:10:04 +0100
659 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m32r/kernel/traps.c 2007-12-13 13:25:29 +0100
660 @@ -195,8 +195,9 @@ static void show_registers(struct pt_reg
662 printk("SPI: %08lx\n", sp);
664 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
665 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
666 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
667 + current->comm, task_pid_nr(current), current->xid,
668 + 0xffff & i, 4096+(unsigned long)current);
671 * When in-kernel, we also print out the stack and code at the
672 diff -NurpP --minimal linux-2.6.24-rc7/arch/m68k/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68k/Kconfig
673 --- linux-2.6.24-rc7/arch/m68k/Kconfig 2007-11-29 01:10:04 +0100
674 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68k/Kconfig 2007-12-13 13:25:26 +0100
675 @@ -687,6 +687,8 @@ source "kernel/Kconfig.instrumentation"
677 source "arch/m68k/Kconfig.debug"
679 +source "kernel/vserver/Kconfig"
681 source "security/Kconfig"
683 source "crypto/Kconfig"
684 diff -NurpP --minimal linux-2.6.24-rc7/arch/m68k/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68k/kernel/process.c
685 --- linux-2.6.24-rc7/arch/m68k/kernel/process.c 2007-11-29 01:00:20 +0100
686 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68k/kernel/process.c 2007-12-13 13:25:44 +0100
687 @@ -160,7 +160,8 @@ int kernel_thread(int (*fn)(void *), voi
690 register long retval __asm__ ("d0");
691 - register long clone_arg __asm__ ("d1") = flags | CLONE_VM | CLONE_UNTRACED;
692 + register long clone_arg __asm__ ("d1") =
693 + flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD;
697 diff -NurpP --minimal linux-2.6.24-rc7/arch/m68k/kernel/ptrace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68k/kernel/ptrace.c
698 --- linux-2.6.24-rc7/arch/m68k/kernel/ptrace.c 2007-11-29 01:10:05 +0100
699 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68k/kernel/ptrace.c 2007-12-13 13:25:28 +0100
701 #include <linux/ptrace.h>
702 #include <linux/user.h>
703 #include <linux/signal.h>
704 +#include <linux/vs_base.h>
706 #include <asm/uaccess.h>
707 #include <asm/page.h>
708 @@ -269,6 +270,8 @@ long arch_ptrace(struct task_struct *chi
709 ret = ptrace_request(child, request, addr, data);
712 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
717 diff -NurpP --minimal linux-2.6.24-rc7/arch/m68k/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68k/kernel/traps.c
718 --- linux-2.6.24-rc7/arch/m68k/kernel/traps.c 2007-11-29 01:10:05 +0100
719 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68k/kernel/traps.c 2007-12-13 13:25:29 +0100
720 @@ -899,8 +899,8 @@ void show_registers(struct pt_regs *regs
721 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
722 regs->d4, regs->d5, regs->a0, regs->a1);
724 - printk("Process %s (pid: %d, task=%p)\n",
725 - current->comm, task_pid_nr(current), current);
726 + printk("Process %s (pid: %d[#%u], task=%p)\n",
727 + current->comm, task_pid_nr(current), current->xid, current);
728 addr = (unsigned long)&fp->un;
729 printk("Frame format=%X ", regs->format);
730 switch (regs->format) {
731 diff -NurpP --minimal linux-2.6.24-rc7/arch/m68knommu/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68knommu/Kconfig
732 --- linux-2.6.24-rc7/arch/m68knommu/Kconfig 2007-11-29 01:10:05 +0100
733 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68knommu/Kconfig 2007-12-13 13:25:26 +0100
734 @@ -711,6 +711,8 @@ source "kernel/Kconfig.instrumentation"
736 source "arch/m68knommu/Kconfig.debug"
738 +source "kernel/vserver/Kconfig"
740 source "security/Kconfig"
742 source "crypto/Kconfig"
743 diff -NurpP --minimal linux-2.6.24-rc7/arch/m68knommu/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68knommu/kernel/process.c
744 --- linux-2.6.24-rc7/arch/m68knommu/kernel/process.c 2007-11-29 01:00:20 +0100
745 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68knommu/kernel/process.c 2007-12-13 13:25:44 +0100
746 @@ -123,7 +123,7 @@ void show_regs(struct pt_regs * regs)
747 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
750 - long clone_arg = flags | CLONE_VM;
751 + long clone_arg = flags | CLONE_VM | CLONE_KTHREAD;
755 diff -NurpP --minimal linux-2.6.24-rc7/arch/m68knommu/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68knommu/kernel/traps.c
756 --- linux-2.6.24-rc7/arch/m68knommu/kernel/traps.c 2007-11-29 01:00:20 +0100
757 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/m68knommu/kernel/traps.c 2007-12-13 13:25:29 +0100
758 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
759 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
760 fp->d4, fp->d5, fp->a0, fp->a1);
762 - printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
763 - current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
764 + printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
765 + current->comm, task_pid_nr(current), current->xid,
766 + PAGE_SIZE+(unsigned long)current);
767 show_stack(NULL, (unsigned long *)(fp + 1));
768 add_taint(TAINT_DIE);
770 diff -NurpP --minimal linux-2.6.24-rc7/arch/mips/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/Kconfig
771 --- linux-2.6.24-rc7/arch/mips/Kconfig 2007-12-31 17:58:10 +0100
772 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/Kconfig 2007-12-31 12:34:06 +0100
773 @@ -2060,6 +2060,8 @@ source "kernel/Kconfig.instrumentation"
775 source "arch/mips/Kconfig.debug"
777 +source "kernel/vserver/Kconfig"
779 source "security/Kconfig"
781 source "crypto/Kconfig"
782 diff -NurpP --minimal linux-2.6.24-rc7/arch/mips/kernel/linux32.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/linux32.c
783 --- linux-2.6.24-rc7/arch/mips/kernel/linux32.c 2007-11-29 01:10:07 +0100
784 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/linux32.c 2007-12-13 13:25:35 +0100
785 @@ -229,7 +229,7 @@ sys32_gettimeofday(struct compat_timeval
789 - do_gettimeofday(&ktv);
790 + vx_gettimeofday(&ktv);
791 if (put_tv32(tv, &ktv))
794 diff -NurpP --minimal linux-2.6.24-rc7/arch/mips/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/process.c
795 --- linux-2.6.24-rc7/arch/mips/kernel/process.c 2007-12-31 17:58:10 +0100
796 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/process.c 2007-12-31 12:34:06 +0100
797 @@ -240,7 +240,8 @@ long kernel_thread(int (*fn)(void *), vo
800 /* Ok, create the new process.. */
801 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
802 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
803 + 0, ®s, 0, NULL, NULL);
807 diff -NurpP --minimal linux-2.6.24-rc7/arch/mips/kernel/ptrace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/ptrace.c
808 --- linux-2.6.24-rc7/arch/mips/kernel/ptrace.c 2007-11-29 01:10:07 +0100
809 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/ptrace.c 2007-12-13 13:25:28 +0100
811 #include <linux/security.h>
812 #include <linux/audit.h>
813 #include <linux/seccomp.h>
814 +#include <linux/vs_base.h>
816 #include <asm/byteorder.h>
818 @@ -171,6 +172,9 @@ long arch_ptrace(struct task_struct *chi
822 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
826 /* when I and D space are separate, these will need to be fixed. */
827 case PTRACE_PEEKTEXT: /* read word at location addr. */
828 diff -NurpP --minimal linux-2.6.24-rc7/arch/mips/kernel/scall32-o32.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/scall32-o32.S
829 --- linux-2.6.24-rc7/arch/mips/kernel/scall32-o32.S 2007-11-29 01:00:23 +0100
830 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/scall32-o32.S 2007-12-13 13:25:28 +0100
831 @@ -619,7 +619,7 @@ einval: li v0, -EINVAL
832 sys sys_mq_timedreceive 5
833 sys sys_mq_notify 2 /* 4275 */
834 sys sys_mq_getsetattr 3
835 - sys sys_ni_syscall 0 /* sys_vserver */
838 sys sys_ni_syscall 0 /* available, was setaltroot */
839 sys sys_add_key 5 /* 4280 */
840 diff -NurpP --minimal linux-2.6.24-rc7/arch/mips/kernel/scall64-64.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/scall64-64.S
841 --- linux-2.6.24-rc7/arch/mips/kernel/scall64-64.S 2007-11-29 01:00:23 +0100
842 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/scall64-64.S 2007-12-13 13:25:28 +0100
843 @@ -434,7 +434,7 @@ sys_call_table:
844 PTR sys_mq_timedreceive
846 PTR sys_mq_getsetattr /* 5235 */
847 - PTR sys_ni_syscall /* sys_vserver */
850 PTR sys_ni_syscall /* available, was setaltroot */
852 diff -NurpP --minimal linux-2.6.24-rc7/arch/mips/kernel/scall64-n32.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/scall64-n32.S
853 --- linux-2.6.24-rc7/arch/mips/kernel/scall64-n32.S 2007-11-29 01:10:07 +0100
854 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/scall64-n32.S 2007-12-13 13:25:28 +0100
855 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
856 PTR compat_sys_mq_timedreceive
857 PTR compat_sys_mq_notify
858 PTR compat_sys_mq_getsetattr
859 - PTR sys_ni_syscall /* 6240, sys_vserver */
860 + PTR sys32_vserver /* 6240 */
861 PTR compat_sys_waitid
862 PTR sys_ni_syscall /* available, was setaltroot */
864 diff -NurpP --minimal linux-2.6.24-rc7/arch/mips/kernel/scall64-o32.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/scall64-o32.S
865 --- linux-2.6.24-rc7/arch/mips/kernel/scall64-o32.S 2007-11-29 01:00:23 +0100
866 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/scall64-o32.S 2007-12-13 13:25:28 +0100
867 @@ -482,7 +482,7 @@ sys_call_table:
868 PTR compat_sys_mq_timedreceive
869 PTR compat_sys_mq_notify /* 4275 */
870 PTR compat_sys_mq_getsetattr
871 - PTR sys_ni_syscall /* sys_vserver */
874 PTR sys_ni_syscall /* available, was setaltroot */
875 PTR sys_add_key /* 4280 */
876 diff -NurpP --minimal linux-2.6.24-rc7/arch/mips/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/traps.c
877 --- linux-2.6.24-rc7/arch/mips/kernel/traps.c 2007-12-31 17:58:10 +0100
878 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/kernel/traps.c 2007-12-31 12:34:06 +0100
879 @@ -313,8 +313,9 @@ void show_registers(const struct pt_regs
883 - printk("Process %s (pid: %d, threadinfo=%p, task=%p)\n",
884 - current->comm, task_pid_nr(current), current_thread_info(), current);
885 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p)\n",
886 + current->comm, task_pid_nr(current), current->xid,
887 + current_thread_info(), current);
888 show_stacktrace(current, regs);
889 show_code((unsigned int __user *) regs->cp0_epc);
891 diff -NurpP --minimal linux-2.6.24-rc7/arch/mips/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/mm/fault.c
892 --- linux-2.6.24-rc7/arch/mips/mm/fault.c 2007-11-29 01:10:14 +0100
893 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/mips/mm/fault.c 2007-12-13 13:25:29 +0100
894 @@ -178,7 +178,8 @@ out_of_memory:
895 down_read(&mm->mmap_sem);
898 - printk("VM: killing process %s\n", tsk->comm);
899 + printk("VM: killing process %s(%d:#%u)\n",
900 + tsk->comm, tsk->pid, tsk->xid);
902 do_group_exit(SIGKILL);
904 diff -NurpP --minimal linux-2.6.24-rc7/arch/parisc/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/Kconfig
905 --- linux-2.6.24-rc7/arch/parisc/Kconfig 2007-11-29 01:10:16 +0100
906 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/Kconfig 2007-12-13 13:25:26 +0100
907 @@ -271,6 +271,8 @@ source "kernel/Kconfig.instrumentation"
909 source "arch/parisc/Kconfig.debug"
911 +source "kernel/vserver/Kconfig"
913 source "security/Kconfig"
915 source "crypto/Kconfig"
916 diff -NurpP --minimal linux-2.6.24-rc7/arch/parisc/kernel/entry.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/kernel/entry.S
917 --- linux-2.6.24-rc7/arch/parisc/kernel/entry.S 2007-11-29 01:10:16 +0100
918 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/kernel/entry.S 2007-12-13 13:25:44 +0100
919 @@ -740,6 +740,7 @@ END(fault_vector_11)
921 #define CLONE_VM 0x100 /* Must agree with <linux/sched.h> */
922 #define CLONE_UNTRACED 0x00800000
923 +#define CLONE_KTHREAD 0x10000000
926 ENTRY(__kernel_thread)
927 diff -NurpP --minimal linux-2.6.24-rc7/arch/parisc/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/kernel/process.c
928 --- linux-2.6.24-rc7/arch/parisc/kernel/process.c 2007-11-29 01:00:27 +0100
929 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/kernel/process.c 2007-12-13 13:25:44 +0100
930 @@ -174,7 +174,7 @@ pid_t kernel_thread(int (*fn)(void *), v
931 * kernel_thread can become a #define.
934 - return __kernel_thread(fn, arg, flags);
935 + return __kernel_thread(fn, arg, flags | CLONE_KTHREAD);
937 EXPORT_SYMBOL(kernel_thread);
939 diff -NurpP --minimal linux-2.6.24-rc7/arch/parisc/kernel/sys_parisc32.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/kernel/sys_parisc32.c
940 --- linux-2.6.24-rc7/arch/parisc/kernel/sys_parisc32.c 2007-11-29 01:10:16 +0100
941 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/kernel/sys_parisc32.c 2007-12-13 13:25:35 +0100
942 @@ -204,11 +204,11 @@ static inline long get_ts32(struct times
944 sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
946 - extern void do_gettimeofday(struct timeval *tv);
947 + extern void vx_gettimeofday(struct timeval *tv);
951 - do_gettimeofday(&ktv);
952 + vx_gettimeofday(&ktv);
953 if (put_compat_timeval(tv, &ktv))
956 diff -NurpP --minimal linux-2.6.24-rc7/arch/parisc/kernel/syscall_table.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/kernel/syscall_table.S
957 --- linux-2.6.24-rc7/arch/parisc/kernel/syscall_table.S 2007-11-29 01:10:17 +0100
958 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/kernel/syscall_table.S 2007-12-13 13:25:28 +0100
960 ENTRY_COMP(mbind) /* 260 */
961 ENTRY_COMP(get_mempolicy)
962 ENTRY_COMP(set_mempolicy)
963 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
964 + ENTRY_DIFF(vserver)
966 ENTRY_SAME(request_key) /* 265 */
968 diff -NurpP --minimal linux-2.6.24-rc7/arch/parisc/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/kernel/traps.c
969 --- linux-2.6.24-rc7/arch/parisc/kernel/traps.c 2007-11-29 01:10:17 +0100
970 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/kernel/traps.c 2007-12-13 13:25:29 +0100
971 @@ -218,8 +218,9 @@ void die_if_kernel(char *str, struct pt_
975 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
976 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
977 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
978 + current->comm, task_pid_nr(current), current->xid,
979 + str, err, regs->iaoq[0]);
980 #ifdef PRINT_USER_FAULTS
981 /* XXX for debugging only */
983 @@ -251,8 +252,8 @@ KERN_CRIT " || |
984 pdc_console_restart();
987 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
988 - current->comm, task_pid_nr(current), str, err);
989 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
990 + current->comm, task_pid_nr(current), current->xid, str, err);
992 /* Wot's wrong wif bein' racy? */
993 if (current->thread.flags & PARISC_KERNEL_DEATH) {
994 diff -NurpP --minimal linux-2.6.24-rc7/arch/parisc/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/mm/fault.c
995 --- linux-2.6.24-rc7/arch/parisc/mm/fault.c 2007-11-29 01:10:17 +0100
996 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/parisc/mm/fault.c 2007-12-13 13:25:29 +0100
997 @@ -210,8 +210,9 @@ bad_area:
999 #ifdef PRINT_USER_FAULTS
1000 printk(KERN_DEBUG "\n");
1001 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
1002 - task_pid_nr(tsk), tsk->comm, code, address);
1003 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
1004 + "command='%s' type=%lu address=0x%08lx\n",
1005 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
1007 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
1008 vma->vm_start, vma->vm_end);
1009 @@ -261,7 +262,8 @@ no_context:
1012 up_read(&mm->mmap_sem);
1013 - printk(KERN_CRIT "VM: killing process %s\n", current->comm);
1014 + printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
1015 + current->comm, current->pid, current->xid);
1016 if (user_mode(regs))
1017 do_group_exit(SIGKILL);
1019 diff -NurpP --minimal linux-2.6.24-rc7/arch/powerpc/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/Kconfig
1020 --- linux-2.6.24-rc7/arch/powerpc/Kconfig 2007-12-31 17:58:11 +0100
1021 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/Kconfig 2007-12-31 12:34:06 +0100
1022 @@ -678,6 +678,8 @@ source "kernel/Kconfig.instrumentation"
1024 source "arch/powerpc/Kconfig.debug"
1026 +source "kernel/vserver/Kconfig"
1028 source "security/Kconfig"
1031 diff -NurpP --minimal linux-2.6.24-rc7/arch/powerpc/kernel/asm-offsets.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/asm-offsets.c
1032 --- linux-2.6.24-rc7/arch/powerpc/kernel/asm-offsets.c 2007-12-31 17:58:11 +0100
1033 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/asm-offsets.c 2007-12-31 12:34:07 +0100
1034 @@ -251,6 +251,7 @@ int main(void)
1036 DEFINE(CLONE_VM, CLONE_VM);
1037 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
1038 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
1040 #ifndef CONFIG_PPC64
1041 DEFINE(MM_PGD, offsetof(struct mm_struct, pgd));
1042 diff -NurpP --minimal linux-2.6.24-rc7/arch/powerpc/kernel/irq.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/irq.c
1043 --- linux-2.6.24-rc7/arch/powerpc/kernel/irq.c 2007-11-29 01:10:18 +0100
1044 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/irq.c 2007-12-13 13:25:11 +0100
1046 #include <linux/bootmem.h>
1047 #include <linux/pci.h>
1048 #include <linux/debugfs.h>
1049 +#include <linux/vs_context.h>
1051 #include <asm/uaccess.h>
1052 #include <asm/system.h>
1053 diff -NurpP --minimal linux-2.6.24-rc7/arch/powerpc/kernel/misc_32.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/misc_32.S
1054 --- linux-2.6.24-rc7/arch/powerpc/kernel/misc_32.S 2007-11-29 01:10:18 +0100
1055 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/misc_32.S 2007-12-13 13:25:44 +0100
1056 @@ -773,7 +773,7 @@ _GLOBAL(kernel_thread)
1057 mr r30,r3 /* function */
1058 mr r31,r4 /* argument */
1059 ori r3,r5,CLONE_VM /* flags */
1060 - oris r3,r3,CLONE_UNTRACED>>16
1061 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1062 li r4,0 /* new sp (unused) */
1065 diff -NurpP --minimal linux-2.6.24-rc7/arch/powerpc/kernel/misc_64.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/misc_64.S
1066 --- linux-2.6.24-rc7/arch/powerpc/kernel/misc_64.S 2007-11-29 01:00:28 +0100
1067 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/misc_64.S 2007-12-13 13:25:44 +0100
1068 @@ -434,7 +434,7 @@ _GLOBAL(kernel_thread)
1071 ori r3,r5,CLONE_VM /* flags */
1072 - oris r3,r3,(CLONE_UNTRACED>>16)
1073 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1074 li r4,0 /* new sp (unused) */
1077 diff -NurpP --minimal linux-2.6.24-rc7/arch/powerpc/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/process.c
1078 --- linux-2.6.24-rc7/arch/powerpc/kernel/process.c 2007-12-31 17:58:11 +0100
1079 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/process.c 2007-12-31 12:34:07 +0100
1080 @@ -458,8 +458,9 @@ void show_regs(struct pt_regs * regs)
1082 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
1084 - printk("TASK = %p[%d] '%s' THREAD: %p",
1085 - current, task_pid_nr(current), current->comm, task_thread_info(current));
1086 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
1087 + current, task_pid_nr(current), current->xid,
1088 + current->comm, task_thread_info(current));
1091 printk(" CPU: %d", smp_processor_id());
1092 diff -NurpP --minimal linux-2.6.24-rc7/arch/powerpc/kernel/sys_ppc32.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/sys_ppc32.c
1093 --- linux-2.6.24-rc7/arch/powerpc/kernel/sys_ppc32.c 2007-11-29 01:10:18 +0100
1094 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/sys_ppc32.c 2007-12-13 13:25:35 +0100
1095 @@ -205,7 +205,7 @@ asmlinkage long compat_sys_gettimeofday(
1099 - do_gettimeofday(&ktv);
1100 + vx_gettimeofday(&ktv);
1101 if (put_tv32(tv, &ktv))
1104 diff -NurpP --minimal linux-2.6.24-rc7/arch/powerpc/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/traps.c
1105 --- linux-2.6.24-rc7/arch/powerpc/kernel/traps.c 2007-11-29 01:10:18 +0100
1106 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/traps.c 2007-12-13 13:25:29 +0100
1107 @@ -880,8 +880,9 @@ void nonrecoverable_exception(struct pt_
1109 void trace_syscall(struct pt_regs *regs)
1111 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1112 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
1113 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1114 + current, task_pid_nr(current), current->xid,
1115 + regs->nip, regs->link, regs->gpr[0],
1116 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
1119 diff -NurpP --minimal linux-2.6.24-rc7/arch/powerpc/kernel/vdso.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/vdso.c
1120 --- linux-2.6.24-rc7/arch/powerpc/kernel/vdso.c 2007-12-31 17:58:11 +0100
1121 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/kernel/vdso.c 2007-12-31 12:34:07 +0100
1123 #include <linux/elf.h>
1124 #include <linux/security.h>
1125 #include <linux/bootmem.h>
1126 +#include <linux/vs_memory.h>
1128 #include <asm/pgtable.h>
1129 #include <asm/system.h>
1130 diff -NurpP --minimal linux-2.6.24-rc7/arch/powerpc/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/mm/fault.c
1131 --- linux-2.6.24-rc7/arch/powerpc/mm/fault.c 2007-11-29 01:10:19 +0100
1132 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/powerpc/mm/fault.c 2007-12-13 13:25:29 +0100
1133 @@ -380,7 +380,8 @@ out_of_memory:
1134 down_read(&mm->mmap_sem);
1137 - printk("VM: killing process %s\n", current->comm);
1138 + printk("VM: killing process %s(%d:#%u)\n",
1139 + current->comm, current->pid, current->xid);
1140 if (user_mode(regs))
1141 do_group_exit(SIGKILL);
1143 diff -NurpP --minimal linux-2.6.24-rc7/arch/ppc/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ppc/Kconfig
1144 --- linux-2.6.24-rc7/arch/ppc/Kconfig 2007-11-29 01:10:22 +0100
1145 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ppc/Kconfig 2007-12-13 13:25:26 +0100
1146 @@ -1321,6 +1321,8 @@ source "kernel/Kconfig.instrumentation"
1148 source "arch/ppc/Kconfig.debug"
1150 +source "kernel/vserver/Kconfig"
1152 source "security/Kconfig"
1154 source "crypto/Kconfig"
1155 diff -NurpP --minimal linux-2.6.24-rc7/arch/ppc/kernel/asm-offsets.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ppc/kernel/asm-offsets.c
1156 --- linux-2.6.24-rc7/arch/ppc/kernel/asm-offsets.c 2007-07-09 13:18:01 +0200
1157 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ppc/kernel/asm-offsets.c 2007-12-13 13:25:44 +0100
1158 @@ -120,6 +120,7 @@ main(void)
1159 DEFINE(TRAP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, trap));
1160 DEFINE(CLONE_VM, CLONE_VM);
1161 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
1162 + DEFINE(CLONE_KTHREAD, CLONE_KTHREAD);
1163 DEFINE(MM_PGD, offsetof(struct mm_struct, pgd));
1165 /* About the CPU features table */
1166 diff -NurpP --minimal linux-2.6.24-rc7/arch/ppc/kernel/misc.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ppc/kernel/misc.S
1167 --- linux-2.6.24-rc7/arch/ppc/kernel/misc.S 2007-11-29 01:10:22 +0100
1168 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ppc/kernel/misc.S 2007-12-13 13:25:44 +0100
1169 @@ -875,7 +875,7 @@ _GLOBAL(kernel_thread)
1170 mr r30,r3 /* function */
1171 mr r31,r4 /* argument */
1172 ori r3,r5,CLONE_VM /* flags */
1173 - oris r3,r3,CLONE_UNTRACED>>16
1174 + oris r3,r3,(CLONE_UNTRACED|CLONE_KTHREAD)>>16
1175 li r4,0 /* new sp (unused) */
1178 diff -NurpP --minimal linux-2.6.24-rc7/arch/ppc/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ppc/kernel/traps.c
1179 --- linux-2.6.24-rc7/arch/ppc/kernel/traps.c 2007-11-29 01:10:22 +0100
1180 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ppc/kernel/traps.c 2007-12-13 13:25:29 +0100
1181 @@ -697,8 +697,9 @@ void nonrecoverable_exception(struct pt_
1183 void trace_syscall(struct pt_regs *regs)
1185 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1186 - current, current->pid, regs->nip, regs->link, regs->gpr[0],
1187 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
1188 + current, current->pid, current->xid,
1189 + regs->nip, regs->link, regs->gpr[0],
1190 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
1193 diff -NurpP --minimal linux-2.6.24-rc7/arch/ppc/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ppc/mm/fault.c
1194 --- linux-2.6.24-rc7/arch/ppc/mm/fault.c 2007-11-29 01:10:22 +0100
1195 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/ppc/mm/fault.c 2007-12-13 13:25:29 +0100
1196 @@ -295,7 +295,8 @@ out_of_memory:
1197 down_read(&mm->mmap_sem);
1200 - printk("VM: killing process %s\n", current->comm);
1201 + printk("VM: killing process %s(%d:#%u)\n",
1202 + current->comm, current->pid, current->xid);
1203 if (user_mode(regs))
1204 do_group_exit(SIGKILL);
1206 diff -NurpP --minimal linux-2.6.24-rc7/arch/s390/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/Kconfig
1207 --- linux-2.6.24-rc7/arch/s390/Kconfig 2007-11-29 01:10:22 +0100
1208 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/Kconfig 2007-12-13 13:25:26 +0100
1209 @@ -533,6 +533,8 @@ source "kernel/Kconfig.instrumentation"
1211 source "arch/s390/Kconfig.debug"
1213 +source "kernel/vserver/Kconfig"
1215 source "security/Kconfig"
1217 source "crypto/Kconfig"
1218 diff -NurpP --minimal linux-2.6.24-rc7/arch/s390/kernel/compat_linux.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/kernel/compat_linux.c
1219 --- linux-2.6.24-rc7/arch/s390/kernel/compat_linux.c 2007-11-29 01:10:23 +0100
1220 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/kernel/compat_linux.c 2007-12-13 13:25:35 +0100
1221 @@ -567,7 +567,7 @@ asmlinkage long sys32_gettimeofday(struc
1225 - do_gettimeofday(&ktv);
1226 + vx_gettimeofday(&ktv);
1227 if (put_tv32(tv, &ktv))
1230 diff -NurpP --minimal linux-2.6.24-rc7/arch/s390/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/kernel/process.c
1231 --- linux-2.6.24-rc7/arch/s390/kernel/process.c 2007-11-29 01:10:23 +0100
1232 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/kernel/process.c 2007-12-13 13:25:44 +0100
1233 @@ -185,9 +185,9 @@ void show_regs(struct pt_regs *regs)
1234 struct task_struct *tsk = current;
1236 printk("CPU: %d %s\n", task_thread_info(tsk)->cpu, print_tainted());
1237 - printk("Process %s (pid: %d, task: %p, ksp: %p)\n",
1238 - current->comm, task_pid_nr(current), (void *) tsk,
1239 - (void *) tsk->thread.ksp);
1240 + printk("Process %s (pid: %d[#%u], task: %p, ksp: %p)\n",
1241 + current->comm, task_pid_nr(current), current->xid,
1242 + (void *) tsk, (void *) tsk->thread.ksp);
1244 show_registers(regs);
1245 /* Show stack backtrace if pt_regs is from kernel mode */
1246 @@ -218,7 +218,7 @@ int kernel_thread(int (*fn)(void *), voi
1247 regs.orig_gpr2 = -1;
1249 /* Ok, create the new process.. */
1250 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED,
1251 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
1252 0, ®s, 0, NULL, NULL);
1255 diff -NurpP --minimal linux-2.6.24-rc7/arch/s390/kernel/ptrace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/kernel/ptrace.c
1256 --- linux-2.6.24-rc7/arch/s390/kernel/ptrace.c 2007-11-29 01:10:23 +0100
1257 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/kernel/ptrace.c 2007-12-13 13:25:28 +0100
1259 #include <linux/security.h>
1260 #include <linux/audit.h>
1261 #include <linux/signal.h>
1262 +#include <linux/vs_base.h>
1264 #include <asm/segment.h>
1265 #include <asm/page.h>
1266 @@ -713,7 +714,13 @@ sys_ptrace(long request, long pid, long
1270 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1275 ret = do_ptrace(child, request, addr, data);
1277 put_task_struct(child);
1280 diff -NurpP --minimal linux-2.6.24-rc7/arch/s390/kernel/syscalls.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/kernel/syscalls.S
1281 --- linux-2.6.24-rc7/arch/s390/kernel/syscalls.S 2007-11-29 01:00:32 +0100
1282 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/kernel/syscalls.S 2007-12-13 13:25:28 +0100
1283 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
1284 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
1285 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
1286 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
1287 -NI_SYSCALL /* reserved for vserver */
1288 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
1289 SYSCALL(s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
1290 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
1291 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
1292 diff -NurpP --minimal linux-2.6.24-rc7/arch/s390/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/mm/fault.c
1293 --- linux-2.6.24-rc7/arch/s390/mm/fault.c 2007-11-29 01:10:23 +0100
1294 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/s390/mm/fault.c 2007-12-13 13:25:29 +0100
1295 @@ -216,7 +216,8 @@ static int do_out_of_memory(struct pt_re
1296 down_read(&mm->mmap_sem);
1299 - printk("VM: killing process %s\n", tsk->comm);
1300 + printk("VM: killing process %s(%d:#%u)\n",
1301 + tsk->comm, tsk->pid, tsk->xid);
1302 if (regs->psw.mask & PSW_MASK_PSTATE)
1303 do_group_exit(SIGKILL);
1304 do_no_context(regs, error_code, address);
1305 diff -NurpP --minimal linux-2.6.24-rc7/arch/sh/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh/Kconfig
1306 --- linux-2.6.24-rc7/arch/sh/Kconfig 2007-11-29 01:10:23 +0100
1307 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh/Kconfig 2007-12-13 13:25:26 +0100
1308 @@ -760,6 +760,8 @@ source "kernel/Kconfig.instrumentation"
1310 source "arch/sh/Kconfig.debug"
1312 +source "kernel/vserver/Kconfig"
1314 source "security/Kconfig"
1316 source "crypto/Kconfig"
1317 diff -NurpP --minimal linux-2.6.24-rc7/arch/sh/kernel/irq.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh/kernel/irq.c
1318 --- linux-2.6.24-rc7/arch/sh/kernel/irq.c 2007-11-29 01:10:25 +0100
1319 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh/kernel/irq.c 2007-12-13 13:25:11 +0100
1321 #include <linux/module.h>
1322 #include <linux/kernel_stat.h>
1323 #include <linux/seq_file.h>
1324 +#include <linux/vs_context.h>
1325 #include <asm/processor.h>
1326 #include <asm/machvec.h>
1327 #include <asm/uaccess.h>
1328 diff -NurpP --minimal linux-2.6.24-rc7/arch/sh/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh/kernel/process.c
1329 --- linux-2.6.24-rc7/arch/sh/kernel/process.c 2007-11-29 01:10:25 +0100
1330 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh/kernel/process.c 2007-12-13 13:25:44 +0100
1331 @@ -121,7 +121,8 @@ void machine_power_off(void)
1332 void show_regs(struct pt_regs * regs)
1335 - printk("Pid : %d, Comm: %20s\n", task_pid_nr(current), current->comm);
1336 + printk("Pid : %d:#%u, Comm: %20s\n",
1337 + task_pid_nr(current), current->xid, current->comm);
1338 print_symbol("PC is at %s\n", instruction_pointer(regs));
1339 printk("PC : %08lx SP : %08lx SR : %08lx ",
1340 regs->pc, regs->regs[15], regs->sr);
1341 @@ -182,7 +183,7 @@ int kernel_thread(int (*fn)(void *), voi
1342 regs.sr = (1 << 30);
1344 /* Ok, create the new process.. */
1345 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
1346 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD, 0,
1347 ®s, 0, NULL, NULL);
1350 diff -NurpP --minimal linux-2.6.24-rc7/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh/kernel/vsyscall/vsyscall.c
1351 --- linux-2.6.24-rc7/arch/sh/kernel/vsyscall/vsyscall.c 2007-11-29 01:00:41 +0100
1352 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh/kernel/vsyscall/vsyscall.c 2007-12-13 13:25:11 +0100
1354 #include <linux/elf.h>
1355 #include <linux/sched.h>
1356 #include <linux/err.h>
1357 +#include <linux/vs_memory.h>
1360 * Should the kernel map a VDSO page into processes and pass its
1361 diff -NurpP --minimal linux-2.6.24-rc7/arch/sh/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh/mm/fault.c
1362 --- linux-2.6.24-rc7/arch/sh/mm/fault.c 2007-12-31 17:58:12 +0100
1363 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh/mm/fault.c 2007-12-31 12:34:08 +0100
1364 @@ -212,7 +212,8 @@ out_of_memory:
1365 down_read(&mm->mmap_sem);
1368 - printk("VM: killing process %s\n", tsk->comm);
1369 + printk("VM: killing process %s(%d:#%u)\n",
1370 + tsk->comm, tsk->pid, tsk->xid);
1371 if (user_mode(regs))
1372 do_group_exit(SIGKILL);
1374 diff -NurpP --minimal linux-2.6.24-rc7/arch/sh64/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh64/kernel/process.c
1375 --- linux-2.6.24-rc7/arch/sh64/kernel/process.c 2007-11-29 01:10:26 +0100
1376 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh64/kernel/process.c 2007-12-13 13:25:45 +0100
1377 @@ -402,8 +402,8 @@ int kernel_thread(int (*fn)(void *), voi
1378 regs.pc = (unsigned long)kernel_thread_helper;
1379 regs.sr = (1 << 30);
1381 - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
1382 - ®s, 0, NULL, NULL);
1383 + return do_fork(flags | CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD,
1384 + 0, ®s, 0, NULL, NULL);
1388 diff -NurpP --minimal linux-2.6.24-rc7/arch/sh64/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh64/mm/fault.c
1389 --- linux-2.6.24-rc7/arch/sh64/mm/fault.c 2007-11-29 01:10:26 +0100
1390 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sh64/mm/fault.c 2007-12-13 13:25:29 +0100
1391 @@ -81,7 +81,7 @@ static inline void print_vma(struct vm_a
1393 static inline void print_task(struct task_struct *tsk)
1395 - printk("Task pid %d\n", task_pid_nr(tsk));
1396 + printk("Task pid %d:#%u\n", task_pid_nr(tsk), tsk->xid);
1399 static pte_t *lookup_pte(struct mm_struct *mm, unsigned long address)
1400 @@ -332,7 +332,8 @@ out_of_memory:
1401 down_read(&mm->mmap_sem);
1404 - printk("VM: killing process %s\n", tsk->comm);
1405 + printk("VM: killing process %s(%d:#%u)\n",
1406 + tsk->comm, tsk->pid, tsk->xid);
1407 if (user_mode(regs))
1408 do_group_exit(SIGKILL);
1410 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/Kconfig
1411 --- linux-2.6.24-rc7/arch/sparc/Kconfig 2007-11-29 01:10:26 +0100
1412 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/Kconfig 2007-12-13 13:25:26 +0100
1413 @@ -324,6 +324,8 @@ source "kernel/Kconfig.instrumentation"
1415 source "arch/sparc/Kconfig.debug"
1417 +source "kernel/vserver/Kconfig"
1419 source "security/Kconfig"
1421 source "crypto/Kconfig"
1422 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/kernel/process.c
1423 --- linux-2.6.24-rc7/arch/sparc/kernel/process.c 2007-11-29 01:10:26 +0100
1424 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/kernel/process.c 2007-12-13 13:25:45 +0100
1425 @@ -706,7 +706,8 @@ pid_t kernel_thread(int (*fn)(void *), v
1426 /* Notreached by child. */
1427 "1: mov %%o0, %0\n\t" :
1429 - "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
1430 + "i" (__NR_clone), "r" (flags |
1431 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD),
1432 "i" (__NR_exit), "r" (fn), "r" (arg) :
1433 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
1435 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc/kernel/ptrace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/kernel/ptrace.c
1436 --- linux-2.6.24-rc7/arch/sparc/kernel/ptrace.c 2008-01-11 12:00:47 +0100
1437 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/kernel/ptrace.c 2008-01-11 04:30:05 +0100
1439 #include <linux/smp_lock.h>
1440 #include <linux/security.h>
1441 #include <linux/signal.h>
1442 +#include <linux/vs_base.h>
1444 #include <asm/pgtable.h>
1445 #include <asm/system.h>
1446 @@ -302,6 +303,10 @@ asmlinkage void do_ptrace(struct pt_regs
1447 pt_error_return(regs, -ret);
1450 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1451 + pt_error_return(regs, ESRCH);
1455 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1456 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1457 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc/kernel/systbls.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/kernel/systbls.S
1458 --- linux-2.6.24-rc7/arch/sparc/kernel/systbls.S 2007-11-29 01:00:41 +0100
1459 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/kernel/systbls.S 2007-12-13 13:25:28 +0100
1460 @@ -70,7 +70,7 @@ sys_call_table:
1461 /*250*/ .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1462 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1463 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1464 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
1465 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1466 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1467 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1468 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
1469 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/kernel/traps.c
1470 --- linux-2.6.24-rc7/arch/sparc/kernel/traps.c 2007-11-29 01:10:27 +0100
1471 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/kernel/traps.c 2007-12-13 13:25:29 +0100
1472 @@ -99,7 +99,8 @@ void die_if_kernel(char *str, struct pt_
1476 - printk("%s(%d): %s [#%d]\n", current->comm, task_pid_nr(current), str, ++die_counter);
1477 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
1478 + task_pid_nr(current), current->xid, str, ++die_counter);
1480 add_taint(TAINT_DIE);
1482 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/mm/fault.c
1483 --- linux-2.6.24-rc7/arch/sparc/mm/fault.c 2007-11-29 01:10:27 +0100
1484 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc/mm/fault.c 2007-12-13 13:25:29 +0100
1485 @@ -367,7 +367,8 @@ no_context:
1488 up_read(&mm->mmap_sem);
1489 - printk("VM: killing process %s\n", tsk->comm);
1490 + printk("VM: killing process %s(%d:#%u)\n",
1491 + tsk->comm, tsk->pid, tsk->xid);
1493 do_group_exit(SIGKILL);
1495 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc64/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/Kconfig
1496 --- linux-2.6.24-rc7/arch/sparc64/Kconfig 2007-11-29 01:10:27 +0100
1497 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/Kconfig 2007-12-13 13:25:26 +0100
1498 @@ -466,6 +466,8 @@ source "kernel/Kconfig.instrumentation"
1500 source "arch/sparc64/Kconfig.debug"
1502 +source "kernel/vserver/Kconfig"
1504 source "security/Kconfig"
1506 source "crypto/Kconfig"
1507 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc64/kernel/binfmt_aout32.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/binfmt_aout32.c
1508 --- linux-2.6.24-rc7/arch/sparc64/kernel/binfmt_aout32.c 2007-11-29 01:10:27 +0100
1509 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/binfmt_aout32.c 2007-12-13 13:25:11 +0100
1511 #include <linux/binfmts.h>
1512 #include <linux/personality.h>
1513 #include <linux/init.h>
1514 +#include <linux/vs_memory.h>
1516 #include <asm/system.h>
1517 #include <asm/uaccess.h>
1518 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc64/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/process.c
1519 --- linux-2.6.24-rc7/arch/sparc64/kernel/process.c 2007-11-29 01:00:42 +0100
1520 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/process.c 2007-12-13 13:25:45 +0100
1521 @@ -719,7 +719,8 @@ pid_t kernel_thread(int (*fn)(void *), v
1522 /* Notreached by child. */
1525 - "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
1526 + "i" (__NR_clone), "r" (flags |
1527 + CLONE_VM | CLONE_UNTRACED | CLONE_KTHREAD),
1528 "i" (__NR_exit), "r" (fn), "r" (arg) :
1529 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
1531 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc64/kernel/ptrace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/ptrace.c
1532 --- linux-2.6.24-rc7/arch/sparc64/kernel/ptrace.c 2007-02-06 03:00:18 +0100
1533 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/ptrace.c 2007-12-13 13:25:28 +0100
1535 #include <linux/seccomp.h>
1536 #include <linux/audit.h>
1537 #include <linux/signal.h>
1538 +#include <linux/vs_base.h>
1540 #include <asm/asi.h>
1541 #include <asm/pgtable.h>
1542 @@ -215,6 +216,10 @@ asmlinkage void do_ptrace(struct pt_regs
1543 pt_error_return(regs, -ret);
1546 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT)) {
1547 + pt_error_return(regs, ESRCH);
1551 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1552 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1553 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc64/kernel/sys_sparc32.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/sys_sparc32.c
1554 --- linux-2.6.24-rc7/arch/sparc64/kernel/sys_sparc32.c 2007-11-29 01:10:27 +0100
1555 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/sys_sparc32.c 2007-12-13 13:25:36 +0100
1556 @@ -726,7 +726,7 @@ asmlinkage long sys32_gettimeofday(struc
1560 - do_gettimeofday(&ktv);
1561 + vx_gettimeofday(&ktv);
1562 if (put_tv32(tv, &ktv))
1565 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc64/kernel/systbls.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/systbls.S
1566 --- linux-2.6.24-rc7/arch/sparc64/kernel/systbls.S 2007-11-29 01:00:42 +0100
1567 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/systbls.S 2007-12-13 13:25:28 +0100
1568 @@ -71,7 +71,7 @@ sys_call_table32:
1569 /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
1570 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
1571 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
1572 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
1573 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
1574 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
1575 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
1576 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
1577 @@ -143,7 +143,7 @@ sys_call_table:
1578 /*250*/ .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1579 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1580 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1581 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
1582 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1583 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1584 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1585 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
1586 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc64/kernel/traps.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/traps.c
1587 --- linux-2.6.24-rc7/arch/sparc64/kernel/traps.c 2007-11-29 01:10:27 +0100
1588 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/kernel/traps.c 2007-12-13 13:25:29 +0100
1589 @@ -2224,7 +2224,8 @@ void die_if_kernel(char *str, struct pt_
1593 - printk("%s(%d): %s [#%d]\n", current->comm, task_pid_nr(current), str, ++die_counter);
1594 + printk("%s(%d[#%u]): %s [#%d]\n", current->comm,
1595 + task_pid_nr(current), current->xid, str, ++die_counter);
1596 notify_die(DIE_OOPS, str, regs, 0, 255, SIGSEGV);
1597 __asm__ __volatile__("flushw");
1599 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc64/mm/fault.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/mm/fault.c
1600 --- linux-2.6.24-rc7/arch/sparc64/mm/fault.c 2007-11-29 01:10:27 +0100
1601 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/mm/fault.c 2007-12-13 13:25:29 +0100
1602 @@ -461,7 +461,8 @@ handle_kernel_fault:
1604 insn = get_fault_insn(regs, insn);
1605 up_read(&mm->mmap_sem);
1606 - printk("VM: killing process %s\n", current->comm);
1607 + printk("VM: killing process %s(%d:#%u)\n",
1608 + current->comm, current->pid, current->xid);
1609 if (!(regs->tstate & TSTATE_PRIV))
1610 do_group_exit(SIGKILL);
1611 goto handle_kernel_fault;
1612 diff -NurpP --minimal linux-2.6.24-rc7/arch/sparc64/solaris/fs.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/solaris/fs.c
1613 --- linux-2.6.24-rc7/arch/sparc64/solaris/fs.c 2007-02-06 03:00:21 +0100
1614 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/sparc64/solaris/fs.c 2007-12-13 13:25:47 +0100
1615 @@ -368,7 +368,7 @@ static int report_statvfs(struct vfsmoun
1619 - if (IS_RDONLY(inode)) i = 1;
1620 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
1621 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
1622 if (!sysv_valid_dev(inode->i_sb->s_dev))
1624 @@ -404,7 +404,7 @@ static int report_statvfs64(struct vfsmo
1628 - if (IS_RDONLY(inode)) i = 1;
1629 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
1630 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
1631 if (!sysv_valid_dev(inode->i_sb->s_dev))
1633 diff -NurpP --minimal linux-2.6.24-rc7/arch/um/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/um/Kconfig
1634 --- linux-2.6.24-rc7/arch/um/Kconfig 2007-11-29 01:10:28 +0100
1635 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/um/Kconfig 2007-12-13 13:25:26 +0100
1636 @@ -270,6 +270,8 @@ source "drivers/connector/Kconfig"
1640 +source "kernel/vserver/Kconfig"
1642 source "security/Kconfig"
1644 source "crypto/Kconfig"
1645 diff -NurpP --minimal linux-2.6.24-rc7/arch/um/kernel/trap.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/um/kernel/trap.c
1646 --- linux-2.6.24-rc7/arch/um/kernel/trap.c 2007-11-29 01:10:30 +0100
1647 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/um/kernel/trap.c 2007-12-13 13:25:29 +0100
1648 @@ -202,7 +202,8 @@ unsigned long segv(struct faultinfo fi,
1649 current->thread.arch.faultinfo = fi;
1650 force_sig_info(SIGBUS, &si, current);
1651 } else if (err == -ENOMEM) {
1652 - printk(KERN_INFO "VM: killing process %s\n", current->comm);
1653 + printk(KERN_INFO "VM: killing process %s(%d:#%u)\n",
1654 + current->comm, task_pid_nr(current), current->xid);
1657 BUG_ON(err != -EFAULT);
1658 diff -NurpP --minimal linux-2.6.24-rc7/arch/v850/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/v850/Kconfig
1659 --- linux-2.6.24-rc7/arch/v850/Kconfig 2007-11-29 01:10:31 +0100
1660 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/v850/Kconfig 2007-12-13 13:25:26 +0100
1661 @@ -335,6 +335,8 @@ source "kernel/Kconfig.instrumentation"
1663 source "arch/v850/Kconfig.debug"
1665 +source "kernel/vserver/Kconfig"
1667 source "security/Kconfig"
1669 source "crypto/Kconfig"
1670 diff -NurpP --minimal linux-2.6.24-rc7/arch/v850/kernel/process.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/v850/kernel/process.c
1671 --- linux-2.6.24-rc7/arch/v850/kernel/process.c 2007-07-09 13:18:08 +0200
1672 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/v850/kernel/process.c 2007-12-13 13:25:45 +0100
1673 @@ -82,7 +82,7 @@ int kernel_thread (int (*fn)(void *), vo
1674 /* Clone this thread. Note that we don't pass the clone syscall's
1675 second argument -- it's ignored for calls from kernel mode (the
1676 child's SP is always set to the top of the kernel stack). */
1677 - arg0 = flags | CLONE_VM;
1678 + arg0 = flags | CLONE_VM | CLONE_KTHREAD;
1679 syscall = __NR_clone;
1680 asm volatile ("trap " SYSCALL_SHORT_TRAP
1681 : "=r" (ret), "=r" (syscall)
1682 diff -NurpP --minimal linux-2.6.24-rc7/arch/v850/kernel/ptrace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/v850/kernel/ptrace.c
1683 --- linux-2.6.24-rc7/arch/v850/kernel/ptrace.c 2007-11-29 01:00:43 +0100
1684 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/v850/kernel/ptrace.c 2007-12-13 13:25:28 +0100
1686 #include <linux/sched.h>
1687 #include <linux/ptrace.h>
1688 #include <linux/signal.h>
1689 +#include <linux/vs_base.h>
1691 #include <asm/errno.h>
1692 #include <asm/ptrace.h>
1693 @@ -116,6 +117,9 @@ long arch_ptrace(struct task_struct *chi
1697 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
1703 diff -NurpP --minimal linux-2.6.24-rc7/arch/x86/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/x86/Kconfig
1704 --- linux-2.6.24-rc7/arch/x86/Kconfig 2007-12-31 17:58:13 +0100
1705 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/x86/Kconfig 2007-12-31 12:34:15 +0100
1706 @@ -1615,6 +1615,8 @@ source "kernel/Kconfig.instrumentation"
1708 source "arch/x86/Kconfig.debug"
1710 +source "kernel/vserver/Kconfig"
1712 source "security/Kconfig"
1714 source "crypto/Kconfig"
1715 diff -NurpP --minimal linux-2.6.24-rc7/arch/x86/kernel/syscall_table_32.S linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/x86/kernel/syscall_table_32.S
1716 --- linux-2.6.24-rc7/arch/x86/kernel/syscall_table_32.S 2007-11-29 01:10:42 +0100
1717 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/arch/x86/kernel/syscall_table_32.S 2007-12-15 02:26:25 +0100
1718 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
1719 .long sys_tgkill /* 270 */
1721 .long sys_fadvise64_64
1722 - .long sys_ni_syscall /* sys_vserver */
1725 .long sys_get_mempolicy
1726 .long sys_set_mempolicy
1727 diff -NurpP --minimal linux-2.6.24-rc7/drivers/block/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/block/Kconfig
1728 --- linux-2.6.24-rc7/drivers/block/Kconfig 2007-11-29 01:10:50 +0100
1729 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/block/Kconfig 2007-12-13 13:25:46 +0100
1730 @@ -262,6 +262,13 @@ config BLK_DEV_CRYPTOLOOP
1731 instead, which can be configured to be on-disk compatible with the
1734 +config BLK_DEV_VROOT
1735 + tristate "Virtual Root device support"
1736 + depends on QUOTACTL
1738 + Saying Y here will allow you to use quota/fs ioctls on a shared
1739 + partition within a virtual server without compromising security.
1742 tristate "Network block device support"
1744 diff -NurpP --minimal linux-2.6.24-rc7/drivers/block/Makefile linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/block/Makefile
1745 --- linux-2.6.24-rc7/drivers/block/Makefile 2007-11-29 01:10:51 +0100
1746 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/block/Makefile 2007-12-13 13:25:46 +0100
1747 @@ -30,5 +30,6 @@ obj-$(CONFIG_VIRTIO_BLK) += virtio_blk.o
1748 obj-$(CONFIG_VIODASD) += viodasd.o
1749 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
1750 obj-$(CONFIG_BLK_DEV_UB) += ub.o
1751 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1753 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1754 diff -NurpP --minimal linux-2.6.24-rc7/drivers/block/loop.c linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/block/loop.c
1755 --- linux-2.6.24-rc7/drivers/block/loop.c 2007-11-29 01:10:53 +0100
1756 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/block/loop.c 2007-12-13 13:25:47 +0100
1758 #include <linux/gfp.h>
1759 #include <linux/kthread.h>
1760 #include <linux/splice.h>
1761 +#include <linux/vs_context.h>
1763 #include <asm/uaccess.h>
1765 @@ -789,6 +790,7 @@ static int loop_set_fd(struct loop_devic
1766 lo->lo_blocksize = lo_blocksize;
1767 lo->lo_device = bdev;
1768 lo->lo_flags = lo_flags;
1769 + lo->lo_xid = vx_current_xid();
1770 lo->lo_backing_file = file;
1771 lo->transfer = transfer_none;
1773 @@ -908,6 +910,7 @@ static int loop_clr_fd(struct loop_devic
1774 lo->lo_encrypt_key_size = 0;
1776 lo->lo_thread = NULL;
1778 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1779 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1780 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1781 @@ -929,7 +932,7 @@ loop_set_status(struct loop_device *lo,
1782 struct loop_func_table *xfer;
1784 if (lo->lo_encrypt_key_size && lo->lo_key_owner != current->uid &&
1785 - !capable(CAP_SYS_ADMIN))
1786 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1788 if (lo->lo_state != Lo_bound)
1790 @@ -1009,7 +1012,8 @@ loop_get_status(struct loop_device *lo,
1791 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1792 info->lo_encrypt_type =
1793 lo->lo_encryption ? lo->lo_encryption->number : 0;
1794 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1795 + if (lo->lo_encrypt_key_size &&
1796 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1797 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1798 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1799 lo->lo_encrypt_key_size);
1800 @@ -1318,6 +1322,9 @@ static int lo_open(struct inode *inode,
1802 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
1804 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID))
1807 mutex_lock(&lo->lo_ctl_mutex);
1809 mutex_unlock(&lo->lo_ctl_mutex);
1810 diff -NurpP --minimal linux-2.6.24-rc7/drivers/block/vroot.c linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/block/vroot.c
1811 --- linux-2.6.24-rc7/drivers/block/vroot.c 1970-01-01 01:00:00 +0100
1812 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/block/vroot.c 2007-12-31 12:40:51 +0100
1815 + * linux/drivers/block/vroot.c
1817 + * written by Herbert Pötzl, 9/11/2002
1818 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1820 + * based on the loop.c code by Theodore Ts'o.
1822 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1823 + * Redistribution of this file is permitted under the
1824 + * GNU General Public License.
1828 +#include <linux/module.h>
1829 +#include <linux/moduleparam.h>
1830 +#include <linux/file.h>
1831 +#include <linux/major.h>
1832 +#include <linux/blkdev.h>
1834 +#include <linux/vroot.h>
1835 +#include <linux/vs_context.h>
1838 +static int max_vroot = 8;
1840 +static struct vroot_device *vroot_dev;
1841 +static struct gendisk **disks;
1844 +static int vroot_set_dev(
1845 + struct vroot_device *vr,
1846 + struct file *vr_file,
1847 + struct block_device *bdev,
1850 + struct block_device *real_bdev;
1851 + struct file *file;
1852 + struct inode *inode;
1856 + if (vr->vr_state != Vr_unbound)
1865 + inode = file->f_dentry->d_inode;
1868 + if (S_ISBLK(inode->i_mode)) {
1869 + real_bdev = inode->i_bdev;
1870 + vr->vr_device = real_bdev;
1871 + __iget(real_bdev->bd_inode);
1875 + vxdprintk(VXD_CBIT(misc, 0),
1876 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1877 + vr->vr_number, VXD_DEV(real_bdev));
1879 + vr->vr_state = Vr_bound;
1888 +static int vroot_clr_dev(
1889 + struct vroot_device *vr,
1890 + struct file *vr_file,
1891 + struct block_device *bdev)
1893 + struct block_device *real_bdev;
1895 + if (vr->vr_state != Vr_bound)
1897 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1900 + real_bdev = vr->vr_device;
1902 + vxdprintk(VXD_CBIT(misc, 0),
1903 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1904 + vr->vr_number, VXD_DEV(real_bdev));
1907 + vr->vr_state = Vr_unbound;
1908 + vr->vr_device = NULL;
1913 +static int vr_ioctl(struct inode *inode, struct file *file,
1914 + unsigned int cmd, unsigned long arg)
1916 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
1919 + down(&vr->vr_ctl_mutex);
1921 + case VROOT_SET_DEV:
1922 + err = vroot_set_dev(vr, file, inode->i_bdev, arg);
1924 + case VROOT_CLR_DEV:
1925 + err = vroot_clr_dev(vr, file, inode->i_bdev);
1931 + up(&vr->vr_ctl_mutex);
1935 +static int vr_open(struct inode *inode, struct file *file)
1937 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
1939 + down(&vr->vr_ctl_mutex);
1941 + up(&vr->vr_ctl_mutex);
1945 +static int vr_release(struct inode *inode, struct file *file)
1947 + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data;
1949 + down(&vr->vr_ctl_mutex);
1951 + up(&vr->vr_ctl_mutex);
1955 +static struct block_device_operations vr_fops = {
1956 + .owner = THIS_MODULE,
1958 + .release = vr_release,
1959 + .ioctl = vr_ioctl,
1962 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1964 + struct inode *inode = bdev->bd_inode;
1965 + struct vroot_device *vr;
1966 + struct block_device *real_bdev;
1967 + int minor = iminor(inode);
1969 + vr = &vroot_dev[minor];
1970 + real_bdev = vr->vr_device;
1972 + vxdprintk(VXD_CBIT(misc, 0),
1973 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1974 + vr->vr_number, VXD_DEV(real_bdev));
1976 + if (vr->vr_state != Vr_bound)
1977 + return ERR_PTR(-ENXIO);
1979 + __iget(real_bdev->bd_inode);
1984 + * And now the modules code and kernel interface.
1987 +module_param(max_vroot, int, 0);
1989 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1990 +MODULE_LICENSE("GPL");
1991 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1993 +MODULE_AUTHOR ("Herbert Pötzl");
1994 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1997 +int __init vroot_init(void)
2001 + if (max_vroot < 1 || max_vroot > 256) {
2002 + max_vroot = MAX_VROOT_DEFAULT;
2003 + printk(KERN_WARNING "vroot: invalid max_vroot "
2004 + "(must be between 1 and 256), "
2005 + "using default (%d)\n", max_vroot);
2008 + if (register_blkdev(VROOT_MAJOR, "vroot"))
2012 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2015 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2017 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2021 + for (i = 0; i < max_vroot; i++) {
2022 + disks[i] = alloc_disk(1);
2027 + for (i = 0; i < max_vroot; i++) {
2028 + struct vroot_device *vr = &vroot_dev[i];
2029 + struct gendisk *disk = disks[i];
2031 + memset(vr, 0, sizeof(*vr));
2032 + init_MUTEX(&vr->vr_ctl_mutex);
2033 + vr->vr_number = i;
2034 + disk->major = VROOT_MAJOR;
2035 + disk->first_minor = i;
2036 + disk->fops = &vr_fops;
2037 + sprintf(disk->disk_name, "vroot%d", i);
2038 + disk->private_data = vr;
2041 + err = register_vroot_grb(&__vroot_get_real_bdev);
2045 + for (i = 0; i < max_vroot; i++)
2046 + add_disk(disks[i]);
2047 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2052 + put_disk(disks[i]);
2057 + unregister_blkdev(VROOT_MAJOR, "vroot");
2058 + printk(KERN_ERR "vroot: ran out of memory\n");
2062 +void vroot_exit(void)
2066 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
2067 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
2069 + for (i = 0; i < max_vroot; i++) {
2070 + del_gendisk(disks[i]);
2071 + put_disk(disks[i]);
2073 + unregister_blkdev(VROOT_MAJOR, "vroot");
2079 +module_init(vroot_init);
2080 +module_exit(vroot_exit);
2084 +static int __init max_vroot_setup(char *str)
2086 + max_vroot = simple_strtol(str, NULL, 0);
2090 +__setup("max_vroot=", max_vroot_setup);
2094 diff -NurpP --minimal linux-2.6.24-rc7/drivers/char/sysrq.c linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/char/sysrq.c
2095 --- linux-2.6.24-rc7/drivers/char/sysrq.c 2007-11-29 01:10:56 +0100
2096 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/char/sysrq.c 2007-12-13 13:25:42 +0100
2098 #include <linux/irq.h>
2099 #include <linux/hrtimer.h>
2100 #include <linux/oom.h>
2101 +#include <linux/vserver/debug.h>
2103 #include <asm/ptrace.h>
2104 #include <asm/irq_regs.h>
2105 @@ -310,6 +311,21 @@ static struct sysrq_key_op sysrq_unrt_op
2106 .enable_mask = SYSRQ_ENABLE_RTNICE,
2110 +#ifdef CONFIG_VSERVER_DEBUG
2111 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
2113 + dump_vx_info_inactive((key == 'x')?0:1);
2116 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2117 + .handler = sysrq_handle_vxinfo,
2118 + .help_msg = "conteXt",
2119 + .action_msg = "Show Context Info",
2120 + .enable_mask = SYSRQ_ENABLE_DUMP,
2124 /* Key Operations table and lock */
2125 static DEFINE_SPINLOCK(sysrq_key_table_lock);
2127 @@ -358,7 +374,11 @@ static struct sysrq_key_op *sysrq_key_ta
2128 /* x: May be registered on ppc/powerpc for xmon */
2132 +#ifdef CONFIG_VSERVER_DEBUG
2133 + &sysrq_showvxinfo_op, /* z */
2139 /* key2index calculation, -1 on invalid index */
2140 @@ -370,6 +390,8 @@ static int sysrq_key_table_key2index(int
2142 else if ((key >= 'a') && (key <= 'z'))
2143 retval = key + 10 - 'a';
2144 + else if ((key >= 'A') && (key <= 'Z'))
2145 + retval = key + 10 - 'A';
2149 diff -NurpP --minimal linux-2.6.24-rc7/drivers/char/tty_io.c linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/char/tty_io.c
2150 --- linux-2.6.24-rc7/drivers/char/tty_io.c 2007-11-29 01:10:56 +0100
2151 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/char/tty_io.c 2007-12-13 13:25:48 +0100
2154 #include <linux/kmod.h>
2155 #include <linux/nsproxy.h>
2156 +#include <linux/vs_pid.h>
2158 #undef TTY_DEBUG_HANGUP
2160 @@ -3139,6 +3140,7 @@ static int tiocspgrp(struct tty_struct *
2162 if (get_user(pgrp_nr, p))
2164 + pgrp_nr = vx_rmap_pid(pgrp_nr);
2168 diff -NurpP --minimal linux-2.6.24-rc7/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/infiniband/hw/ipath/ipath_user_pages.c
2169 --- linux-2.6.24-rc7/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-11-29 01:01:03 +0100
2170 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/infiniband/hw/ipath/ipath_user_pages.c 2007-12-13 13:25:41 +0100
2173 #include <linux/mm.h>
2174 #include <linux/device.h>
2175 +#include <linux/vs_memory.h>
2177 #include "ipath_kernel.h"
2179 @@ -61,7 +62,8 @@ static int __get_user_pages(unsigned lon
2180 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
2183 - if (num_pages > lock_limit) {
2184 + if (num_pages > lock_limit ||
2185 + !vx_vmlocked_avail(current->mm, num_pages)) {
2189 @@ -78,7 +80,7 @@ static int __get_user_pages(unsigned lon
2193 - current->mm->locked_vm += num_pages;
2194 + vx_vmlocked_add(current->mm, num_pages);
2198 @@ -177,7 +179,7 @@ void ipath_release_user_pages(struct pag
2200 __ipath_release_user_pages(p, num_pages, 1);
2202 - current->mm->locked_vm -= num_pages;
2203 + vx_vmlocked_sub(current->mm, num_pages);
2205 up_write(¤t->mm->mmap_sem);
2207 @@ -194,7 +196,7 @@ static void user_pages_account(struct wo
2208 container_of(_work, struct ipath_user_pages_work, work);
2210 down_write(&work->mm->mmap_sem);
2211 - work->mm->locked_vm -= work->num_pages;
2212 + vx_vmlocked_sub(work->mm, work->num_pages);
2213 up_write(&work->mm->mmap_sem);
2216 diff -NurpP --minimal linux-2.6.24-rc7/drivers/md/dm-ioctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/md/dm-ioctl.c
2217 --- linux-2.6.24-rc7/drivers/md/dm-ioctl.c 2007-12-31 17:58:18 +0100
2218 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/md/dm-ioctl.c 2007-12-31 12:34:20 +0100
2220 #include <linux/slab.h>
2221 #include <linux/dm-ioctl.h>
2222 #include <linux/hdreg.h>
2223 +#include <linux/vs_context.h>
2225 #include <asm/uaccess.h>
2227 @@ -100,7 +101,8 @@ static struct hash_cell *__get_name_cell
2228 unsigned int h = hash_str(str);
2230 list_for_each_entry (hc, _name_buckets + h, name_list)
2231 - if (!strcmp(hc->name, str)) {
2232 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2233 + !strcmp(hc->name, str)) {
2237 @@ -114,7 +116,8 @@ static struct hash_cell *__get_uuid_cell
2238 unsigned int h = hash_str(str);
2240 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
2241 - if (!strcmp(hc->uuid, str)) {
2242 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
2243 + !strcmp(hc->uuid, str)) {
2247 @@ -351,6 +354,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
2249 static int remove_all(struct dm_ioctl *param, size_t param_size)
2251 + if (!vx_check(0, VS_ADMIN))
2254 dm_hash_remove_all(1);
2255 param->data_size = 0;
2257 @@ -398,6 +404,8 @@ static int list_devices(struct dm_ioctl
2259 for (i = 0; i < NUM_BUCKETS; i++) {
2260 list_for_each_entry (hc, _name_buckets + i, name_list) {
2261 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2263 needed += sizeof(struct dm_name_list);
2264 needed += strlen(hc->name) + 1;
2265 needed += ALIGN_MASK;
2266 @@ -421,6 +429,8 @@ static int list_devices(struct dm_ioctl
2268 for (i = 0; i < NUM_BUCKETS; i++) {
2269 list_for_each_entry (hc, _name_buckets + i, name_list) {
2270 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
2273 old_nl->next = (uint32_t) ((void *) nl -
2275 @@ -611,10 +621,11 @@ static struct hash_cell *__find_device_h
2279 - mdptr = dm_get_mdptr(md);
2280 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
2281 + mdptr = dm_get_mdptr(md);
2289 @@ -1407,8 +1418,8 @@ static int ctl_ioctl(struct inode *inode
2293 - /* only root can play with this */
2294 - if (!capable(CAP_SYS_ADMIN))
2295 + /* only root and certain contexts can play with this */
2296 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
2299 if (_IOC_TYPE(command) != DM_IOCTL)
2300 diff -NurpP --minimal linux-2.6.24-rc7/drivers/md/dm.c linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/md/dm.c
2301 --- linux-2.6.24-rc7/drivers/md/dm.c 2007-12-31 17:58:18 +0100
2302 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/md/dm.c 2007-12-31 12:34:20 +0100
2304 #include <linux/hdreg.h>
2305 #include <linux/blktrace_api.h>
2306 #include <linux/smp_lock.h>
2307 +#include <linux/vs_base.h>
2309 #define DM_MSG_PREFIX "core"
2311 @@ -78,6 +79,7 @@ struct mapped_device {
2314 atomic_t open_count;
2317 unsigned long flags;
2319 @@ -232,6 +234,7 @@ static void __exit dm_exit(void)
2320 static int dm_blk_open(struct inode *inode, struct file *file)
2322 struct mapped_device *md;
2325 spin_lock(&_minor_lock);
2327 @@ -240,18 +243,19 @@ static int dm_blk_open(struct inode *ino
2330 if (test_bit(DMF_FREEING, &md->flags) ||
2331 - test_bit(DMF_DELETING, &md->flags)) {
2333 + test_bit(DMF_DELETING, &md->flags))
2337 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
2342 atomic_inc(&md->open_count);
2346 spin_unlock(&_minor_lock);
2348 - return md ? 0 : -ENXIO;
2352 static int dm_blk_close(struct inode *inode, struct file *file)
2353 @@ -447,6 +451,14 @@ int dm_set_geometry(struct mapped_device
2358 + * Get the xid associated with a dm device
2360 +xid_t dm_get_xid(struct mapped_device *md)
2365 /*-----------------------------------------------------------------
2367 * A more elegant soln is in the works that uses the queue
2368 @@ -1004,6 +1016,7 @@ static struct mapped_device *alloc_dev(i
2369 INIT_LIST_HEAD(&md->uevent_list);
2370 spin_lock_init(&md->uevent_lock);
2372 + md->xid = vx_current_xid();
2373 md->queue = blk_alloc_queue(GFP_KERNEL);
2375 goto bad1_free_minor;
2376 diff -NurpP --minimal linux-2.6.24-rc7/drivers/md/dm.h linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/md/dm.h
2377 --- linux-2.6.24-rc7/drivers/md/dm.h 2007-12-31 17:58:18 +0100
2378 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/drivers/md/dm.h 2007-12-31 12:34:20 +0100
2379 @@ -127,6 +127,8 @@ void dm_put_target_type(struct target_ty
2380 int dm_target_iterate(void (*iter_func)(struct target_type *tt,
2381 void *param), void *param);
2383 +xid_t dm_get_xid(struct mapped_device *md);
2385 /*-----------------------------------------------------------------
2387 *---------------------------------------------------------------*/
2388 diff -NurpP --minimal linux-2.6.24-rc7/fs/attr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/attr.c
2389 --- linux-2.6.24-rc7/fs/attr.c 2007-11-29 01:11:47 +0100
2390 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/attr.c 2007-12-13 13:25:40 +0100
2392 #include <linux/fcntl.h>
2393 #include <linux/quotaops.h>
2394 #include <linux/security.h>
2395 +#include <linux/proc_fs.h>
2396 +#include <linux/devpts_fs.h>
2397 +#include <linux/vs_base.h>
2399 /* Taken over from the old code... */
2401 @@ -55,6 +58,27 @@ int inode_change_ok(struct inode *inode,
2402 if (!is_owner_or_cap(inode))
2406 + /* Check for evil vserver activity */
2407 + if (vx_check(0, VS_ADMIN))
2410 + if (IS_BARRIER(inode)) {
2411 + vxwprintk_task(1, "messing with the barrier.");
2414 + switch (inode->i_sb->s_magic) {
2415 + case PROC_SUPER_MAGIC:
2416 + /* maybe allow that in the future? */
2417 + vxwprintk_task(1, "messing with the procfs.");
2419 + case DEVPTS_SUPER_MAGIC:
2420 + /* devpts is xid tagged */
2421 + if (vx_check((xid_t)inode->i_tag, VS_IDENT))
2423 + vxwprintk_task(1, "messing with the devpts.");
2429 @@ -78,6 +102,8 @@ int inode_setattr(struct inode * inode,
2430 inode->i_uid = attr->ia_uid;
2431 if (ia_valid & ATTR_GID)
2432 inode->i_gid = attr->ia_gid;
2433 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2434 + inode->i_tag = attr->ia_tag;
2435 if (ia_valid & ATTR_ATIME)
2436 inode->i_atime = timespec_trunc(attr->ia_atime,
2437 inode->i_sb->s_time_gran);
2438 @@ -167,7 +193,8 @@ int notify_change(struct dentry * dentry
2439 error = security_inode_setattr(dentry, attr);
2441 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2442 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2443 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2444 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
2445 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
2447 error = inode_setattr(inode, attr);
2448 diff -NurpP --minimal linux-2.6.24-rc7/fs/binfmt_aout.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/binfmt_aout.c
2449 --- linux-2.6.24-rc7/fs/binfmt_aout.c 2007-12-31 17:58:24 +0100
2450 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/binfmt_aout.c 2007-12-31 12:34:39 +0100
2452 #include <linux/binfmts.h>
2453 #include <linux/personality.h>
2454 #include <linux/init.h>
2455 +#include <linux/vs_memory.h>
2457 #include <asm/system.h>
2458 #include <asm/uaccess.h>
2459 diff -NurpP --minimal linux-2.6.24-rc7/fs/binfmt_elf.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/binfmt_elf.c
2460 --- linux-2.6.24-rc7/fs/binfmt_elf.c 2007-11-29 01:11:48 +0100
2461 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/binfmt_elf.c 2007-12-13 13:25:11 +0100
2463 #include <linux/random.h>
2464 #include <linux/elf.h>
2465 #include <linux/utsname.h>
2466 +#include <linux/vs_memory.h>
2467 #include <asm/uaccess.h>
2468 #include <asm/param.h>
2469 #include <asm/page.h>
2470 diff -NurpP --minimal linux-2.6.24-rc7/fs/binfmt_flat.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/binfmt_flat.c
2471 --- linux-2.6.24-rc7/fs/binfmt_flat.c 2007-11-29 01:11:48 +0100
2472 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/binfmt_flat.c 2007-12-13 13:25:11 +0100
2474 #include <linux/init.h>
2475 #include <linux/flat.h>
2476 #include <linux/syscalls.h>
2477 +#include <linux/vs_memory.h>
2479 #include <asm/byteorder.h>
2480 #include <asm/system.h>
2481 diff -NurpP --minimal linux-2.6.24-rc7/fs/binfmt_som.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/binfmt_som.c
2482 --- linux-2.6.24-rc7/fs/binfmt_som.c 2007-11-29 01:11:48 +0100
2483 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/binfmt_som.c 2007-12-13 13:25:11 +0100
2485 #include <linux/shm.h>
2486 #include <linux/personality.h>
2487 #include <linux/init.h>
2488 +#include <linux/vs_memory.h>
2490 #include <asm/a.out.h>
2491 #include <asm/uaccess.h>
2492 diff -NurpP --minimal linux-2.6.24-rc7/fs/dcache.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/dcache.c
2493 --- linux-2.6.24-rc7/fs/dcache.c 2007-11-29 01:11:48 +0100
2494 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/dcache.c 2007-12-13 13:25:42 +0100
2496 #include <linux/seqlock.h>
2497 #include <linux/swap.h>
2498 #include <linux/bootmem.h>
2499 +#include <linux/vs_limit.h>
2500 #include "internal.h"
2503 @@ -176,6 +177,7 @@ void dput(struct dentry *dentry)
2507 + vx_dentry_dec(dentry);
2509 if (atomic_read(&dentry->d_count) == 1)
2511 @@ -189,6 +191,8 @@ repeat:
2515 + vx_dentry_dec(dentry);
2518 * AV: ->d_delete() is _NOT_ allowed to block now.
2520 @@ -288,6 +292,7 @@ static inline struct dentry * __dget_loc
2521 if (!list_empty(&dentry->d_lru)) {
2522 dentry_stat.nr_unused--;
2523 list_del_init(&dentry->d_lru);
2524 + vx_dentry_inc(dentry);
2528 @@ -899,6 +904,9 @@ struct dentry *d_alloc(struct dentry * p
2529 struct dentry *dentry;
2532 + if (!vx_dentry_avail(1))
2535 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2538 @@ -947,6 +955,7 @@ struct dentry *d_alloc(struct dentry * p
2540 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
2541 dentry_stat.nr_dentry++;
2542 + vx_dentry_inc(dentry);
2543 spin_unlock(&dcache_lock);
2546 @@ -1296,6 +1305,7 @@ struct dentry * __d_lookup(struct dentry
2548 if (!d_unhashed(dentry)) {
2549 atomic_inc(&dentry->d_count);
2550 + vx_dentry_inc(dentry);
2553 spin_unlock(&dentry->d_lock);
2554 diff -NurpP --minimal linux-2.6.24-rc7/fs/devpts/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/devpts/inode.c
2555 --- linux-2.6.24-rc7/fs/devpts/inode.c 2007-07-09 13:19:23 +0200
2556 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/devpts/inode.c 2007-12-13 13:25:30 +0100
2558 #include <linux/devpts_fs.h>
2559 #include <linux/parser.h>
2560 #include <linux/fsnotify.h>
2561 +#include <linux/vs_base.h>
2563 -#define DEVPTS_SUPER_MAGIC 0x1cd1
2565 +static int devpts_permission(struct inode *inode, int mask, struct nameidata *nd)
2567 + int ret = -EACCES;
2569 + /* devpts is xid tagged */
2570 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2571 + ret = generic_permission(inode, mask, NULL);
2575 +static struct inode_operations devpts_file_inode_operations = {
2576 + .permission = devpts_permission,
2579 static struct vfsmount *devpts_mnt;
2580 static struct dentry *devpts_root;
2581 @@ -92,6 +106,25 @@ static int devpts_remount(struct super_b
2585 +static int devpts_filter(struct dentry *de)
2587 + /* devpts is xid tagged */
2588 + return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
2591 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2593 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2596 +static struct file_operations devpts_dir_operations = {
2597 + .open = dcache_dir_open,
2598 + .release = dcache_dir_close,
2599 + .llseek = dcache_dir_lseek,
2600 + .read = generic_read_dir,
2601 + .readdir = devpts_readdir,
2604 static const struct super_operations devpts_sops = {
2605 .statfs = simple_statfs,
2606 .remount_fs = devpts_remount,
2607 @@ -117,8 +150,10 @@ devpts_fill_super(struct super_block *s,
2608 inode->i_uid = inode->i_gid = 0;
2609 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2610 inode->i_op = &simple_dir_inode_operations;
2611 - inode->i_fop = &simple_dir_operations;
2612 + inode->i_fop = &devpts_dir_operations;
2614 + /* devpts is xid tagged */
2615 + inode->i_tag = (tag_t)vx_current_xid();
2617 devpts_root = s->s_root = d_alloc_root(inode);
2619 @@ -176,6 +211,9 @@ int devpts_pty_new(struct tty_struct *tt
2620 inode->i_gid = config.setgid ? config.gid : current->fsgid;
2621 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2622 init_special_inode(inode, S_IFCHR|config.mode, device);
2623 + /* devpts is xid tagged */
2624 + inode->i_tag = (tag_t)vx_current_xid();
2625 + inode->i_op = &devpts_file_inode_operations;
2626 inode->i_private = tty;
2628 dentry = get_node(number);
2629 diff -NurpP --minimal linux-2.6.24-rc7/fs/ecryptfs/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ecryptfs/inode.c
2630 --- linux-2.6.24-rc7/fs/ecryptfs/inode.c 2007-11-29 01:11:49 +0100
2631 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ecryptfs/inode.c 2007-12-13 13:25:47 +0100
2632 @@ -414,7 +414,7 @@ static int ecryptfs_link(struct dentry *
2633 dget(lower_new_dentry);
2634 lower_dir_dentry = lock_parent(lower_new_dentry);
2635 rc = vfs_link(lower_old_dentry, lower_dir_dentry->d_inode,
2636 - lower_new_dentry);
2637 + lower_new_dentry, NULL);
2638 if (rc || !lower_new_dentry->d_inode)
2640 rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
2641 @@ -442,7 +442,7 @@ static int ecryptfs_unlink(struct inode
2642 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
2644 lock_parent(lower_dentry);
2645 - rc = vfs_unlink(lower_dir_inode, lower_dentry);
2646 + rc = vfs_unlink(lower_dir_inode, lower_dentry, NULL);
2648 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
2650 @@ -479,7 +479,7 @@ static int ecryptfs_symlink(struct inode
2653 rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry,
2654 - encoded_symname, mode);
2655 + encoded_symname, mode, NULL);
2656 kfree(encoded_symname);
2657 if (rc || !lower_dentry->d_inode)
2659 @@ -504,7 +504,7 @@ static int ecryptfs_mkdir(struct inode *
2661 lower_dentry = ecryptfs_dentry_to_lower(dentry);
2662 lower_dir_dentry = lock_parent(lower_dentry);
2663 - rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode);
2664 + rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode, NULL);
2665 if (rc || !lower_dentry->d_inode)
2667 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
2668 @@ -530,7 +530,7 @@ static int ecryptfs_rmdir(struct inode *
2670 lower_dir_dentry = lock_parent(lower_dentry);
2672 - rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry);
2673 + rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry, NULL);
2676 d_delete(lower_dentry);
2677 @@ -552,7 +552,7 @@ ecryptfs_mknod(struct inode *dir, struct
2679 lower_dentry = ecryptfs_dentry_to_lower(dentry);
2680 lower_dir_dentry = lock_parent(lower_dentry);
2681 - rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev);
2682 + rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev, NULL);
2683 if (rc || !lower_dentry->d_inode)
2685 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
2686 diff -NurpP --minimal linux-2.6.24-rc7/fs/exec.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/exec.c
2687 --- linux-2.6.24-rc7/fs/exec.c 2007-12-31 17:58:24 +0100
2688 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/exec.c 2007-12-31 12:34:39 +0100
2689 @@ -241,7 +241,9 @@ static int __bprm_mm_init(struct linux_b
2693 - mm->stack_vm = mm->total_vm = 1;
2695 + vx_vmpages_inc(mm);
2697 up_write(&mm->mmap_sem);
2699 bprm->p = vma->vm_end - sizeof(void *);
2700 @@ -1465,7 +1467,7 @@ static int format_corename(char *corenam
2701 /* UNIX time of coredump */
2704 - do_gettimeofday(&tv);
2705 + vx_gettimeofday(&tv);
2706 rc = snprintf(out_ptr, out_end - out_ptr,
2708 if (rc > out_end - out_ptr)
2709 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext2/balloc.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/balloc.c
2710 --- linux-2.6.24-rc7/fs/ext2/balloc.c 2007-11-29 01:11:49 +0100
2711 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/balloc.c 2007-12-13 16:31:05 +0100
2713 #include <linux/sched.h>
2714 #include <linux/buffer_head.h>
2715 #include <linux/capability.h>
2716 +#include <linux/vs_dlimit.h>
2717 +#include <linux/vs_tag.h>
2720 * balloc.c contains the blocks allocation and deallocation routines
2721 @@ -504,6 +506,7 @@ do_more:
2725 + DLIMIT_FREE_BLOCK(inode, freed);
2726 release_blocks(sb, freed);
2727 DQUOT_FREE_BLOCK(inode, freed);
2729 @@ -636,7 +639,6 @@ ext2_try_to_allocate(struct super_block
2731 end = EXT2_BLOCKS_PER_GROUP(sb);
2734 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2737 @@ -1186,6 +1188,11 @@ ext2_fsblk_t ext2_new_blocks(struct inod
2741 + if (DLIMIT_ALLOC_BLOCK(inode, num)) {
2743 + DQUOT_FREE_BLOCK(inode, num);
2748 es = EXT2_SB(sb)->s_es;
2749 @@ -1336,6 +1343,7 @@ allocated:
2753 + DLIMIT_FREE_BLOCK(inode, *count-num);
2754 DQUOT_FREE_BLOCK(inode, *count-num);
2757 @@ -1346,8 +1354,10 @@ out:
2759 * Undo the block allocation
2761 - if (!performed_allocation)
2762 + if (!performed_allocation) {
2763 + DLIMIT_FREE_BLOCK(inode, *count);
2764 DQUOT_FREE_BLOCK(inode, *count);
2769 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext2/ext2.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/ext2.h
2770 --- linux-2.6.24-rc7/fs/ext2/ext2.h 2007-12-31 17:58:24 +0100
2771 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/ext2.h 2007-12-31 12:34:39 +0100
2772 @@ -170,6 +170,7 @@ extern const struct file_operations ext2
2773 extern const struct address_space_operations ext2_aops;
2774 extern const struct address_space_operations ext2_aops_xip;
2775 extern const struct address_space_operations ext2_nobh_aops;
2776 +extern int ext2_sync_flags(struct inode *inode);
2779 extern const struct inode_operations ext2_dir_inode_operations;
2780 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext2/file.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/file.c
2781 --- linux-2.6.24-rc7/fs/ext2/file.c 2007-11-29 01:11:49 +0100
2782 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/file.c 2007-12-13 13:25:39 +0100
2783 @@ -86,4 +86,5 @@ const struct inode_operations ext2_file_
2785 .setattr = ext2_setattr,
2786 .permission = ext2_permission,
2787 + .sync_flags = ext2_sync_flags,
2789 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext2/ialloc.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/ialloc.c
2790 --- linux-2.6.24-rc7/fs/ext2/ialloc.c 2007-11-29 01:11:49 +0100
2791 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/ialloc.c 2007-12-13 13:25:46 +0100
2793 #include <linux/backing-dev.h>
2794 #include <linux/buffer_head.h>
2795 #include <linux/random.h>
2796 +#include <linux/vs_dlimit.h>
2797 +#include <linux/vs_tag.h>
2801 @@ -125,6 +127,7 @@ void ext2_free_inode (struct inode * ino
2802 ext2_xattr_delete_inode(inode);
2803 DQUOT_FREE_INODE(inode);
2805 + DLIMIT_FREE_INODE(inode);
2808 es = EXT2_SB(sb)->s_es;
2809 @@ -456,6 +459,11 @@ struct inode *ext2_new_inode(struct inod
2811 return ERR_PTR(-ENOMEM);
2813 + inode->i_tag = dx_current_fstag(sb);
2814 + if (DLIMIT_ALLOC_INODE(inode)) {
2821 @@ -569,7 +577,8 @@ got:
2822 inode->i_blocks = 0;
2823 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
2824 memset(ei->i_data, 0, sizeof(ei->i_data));
2825 - ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
2826 + ei->i_flags = EXT2_I(dir)->i_flags &
2827 + ~(EXT2_BTREE_FL|EXT2_IUNLINK_FL|EXT2_BARRIER_FL);
2829 ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
2830 /* dirsync is only applied to directories */
2831 @@ -614,12 +623,15 @@ fail_free_drop:
2835 + DLIMIT_FREE_INODE(inode);
2836 inode->i_flags |= S_NOQUOTA;
2839 return ERR_PTR(err);
2842 + DLIMIT_FREE_INODE(inode);
2844 make_bad_inode(inode);
2846 return ERR_PTR(err);
2847 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext2/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/inode.c
2848 --- linux-2.6.24-rc7/fs/ext2/inode.c 2007-11-29 01:11:49 +0100
2849 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/inode.c 2007-12-13 13:25:40 +0100
2851 #include <linux/writeback.h>
2852 #include <linux/buffer_head.h>
2853 #include <linux/mpage.h>
2854 +#include <linux/vs_tag.h>
2858 @@ -1015,7 +1016,7 @@ void ext2_truncate(struct inode *inode)
2860 if (ext2_inode_is_fast_symlink(inode))
2862 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2863 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2866 blocksize = inode->i_sb->s_blocksize;
2867 @@ -1153,13 +1154,20 @@ void ext2_set_inode_flags(struct inode *
2869 unsigned int flags = EXT2_I(inode)->i_flags;
2871 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2872 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
2873 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2875 + if (flags & EXT2_IMMUTABLE_FL)
2876 + inode->i_flags |= S_IMMUTABLE;
2877 + if (flags & EXT2_IUNLINK_FL)
2878 + inode->i_flags |= S_IUNLINK;
2879 + if (flags & EXT2_BARRIER_FL)
2880 + inode->i_flags |= S_BARRIER;
2882 if (flags & EXT2_SYNC_FL)
2883 inode->i_flags |= S_SYNC;
2884 if (flags & EXT2_APPEND_FL)
2885 inode->i_flags |= S_APPEND;
2886 - if (flags & EXT2_IMMUTABLE_FL)
2887 - inode->i_flags |= S_IMMUTABLE;
2888 if (flags & EXT2_NOATIME_FL)
2889 inode->i_flags |= S_NOATIME;
2890 if (flags & EXT2_DIRSYNC_FL)
2891 @@ -1185,12 +1193,37 @@ void ext2_get_inode_flags(struct ext2_in
2892 ei->i_flags |= EXT2_DIRSYNC_FL;
2895 +int ext2_sync_flags(struct inode *inode)
2897 + unsigned int oldflags, newflags;
2899 + oldflags = EXT2_I(inode)->i_flags;
2900 + newflags = oldflags & ~(EXT2_IMMUTABLE_FL |
2901 + EXT2_IUNLINK_FL | EXT2_BARRIER_FL);
2903 + if (IS_IMMUTABLE(inode))
2904 + newflags |= EXT2_IMMUTABLE_FL;
2905 + if (IS_IUNLINK(inode))
2906 + newflags |= EXT2_IUNLINK_FL;
2907 + if (IS_BARRIER(inode))
2908 + newflags |= EXT2_BARRIER_FL;
2910 + if (oldflags ^ newflags) {
2911 + EXT2_I(inode)->i_flags = newflags;
2912 + inode->i_ctime = CURRENT_TIME;
2913 + mark_inode_dirty(inode);
2918 void ext2_read_inode (struct inode * inode)
2920 struct ext2_inode_info *ei = EXT2_I(inode);
2921 ino_t ino = inode->i_ino;
2922 struct buffer_head * bh;
2923 struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh);
2928 #ifdef CONFIG_EXT2_FS_POSIX_ACL
2929 @@ -1203,12 +1236,17 @@ void ext2_read_inode (struct inode * ino
2932 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2933 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2934 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2935 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2936 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2937 if (!(test_opt (inode->i_sb, NO_UID32))) {
2938 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2939 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2940 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2941 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2943 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2944 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2945 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2946 + le16_to_cpu(raw_inode->i_raw_tag));
2948 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2949 inode->i_size = le32_to_cpu(raw_inode->i_size);
2950 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2951 @@ -1302,8 +1340,8 @@ static int ext2_update_inode(struct inod
2952 struct ext2_inode_info *ei = EXT2_I(inode);
2953 struct super_block *sb = inode->i_sb;
2954 ino_t ino = inode->i_ino;
2955 - uid_t uid = inode->i_uid;
2956 - gid_t gid = inode->i_gid;
2957 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2958 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2959 struct buffer_head * bh;
2960 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2962 @@ -1339,6 +1377,9 @@ static int ext2_update_inode(struct inod
2963 raw_inode->i_uid_high = 0;
2964 raw_inode->i_gid_high = 0;
2966 +#ifdef CONFIG_TAGGING_INTERN
2967 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2969 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2970 raw_inode->i_size = cpu_to_le32(inode->i_size);
2971 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2972 @@ -1425,7 +1466,8 @@ int ext2_setattr(struct dentry *dentry,
2975 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2976 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2977 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2978 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2979 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
2982 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext2/ioctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/ioctl.c
2983 --- linux-2.6.24-rc7/fs/ext2/ioctl.c 2007-11-29 01:11:49 +0100
2984 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/ioctl.c 2007-12-13 13:25:47 +0100
2986 #include <linux/sched.h>
2987 #include <linux/compat.h>
2988 #include <linux/smp_lock.h>
2989 +#include <linux/mount.h>
2990 #include <asm/current.h>
2991 #include <asm/uaccess.h>
2993 @@ -34,7 +35,8 @@ int ext2_ioctl (struct inode * inode, st
2994 case EXT2_IOC_SETFLAGS: {
2995 unsigned int oldflags;
2997 - if (IS_RDONLY(inode))
2998 + if (IS_RDONLY(inode) ||
2999 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3002 if (!is_owner_or_cap(inode))
3003 @@ -60,7 +62,9 @@ int ext2_ioctl (struct inode * inode, st
3005 * This test looks nicer. Thanks to Pauline Middelink
3007 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
3008 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
3009 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
3010 + EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL))) {
3011 if (!capable(CAP_LINUX_IMMUTABLE)) {
3012 mutex_unlock(&inode->i_mutex);
3014 @@ -82,7 +86,8 @@ int ext2_ioctl (struct inode * inode, st
3015 case EXT2_IOC_SETVERSION:
3016 if (!is_owner_or_cap(inode))
3018 - if (IS_RDONLY(inode))
3019 + if (IS_RDONLY(inode) ||
3020 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3022 if (get_user(inode->i_generation, (int __user *) arg))
3024 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext2/namei.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/namei.c
3025 --- linux-2.6.24-rc7/fs/ext2/namei.c 2007-05-02 19:25:17 +0200
3026 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/namei.c 2007-12-13 13:25:41 +0100
3030 #include <linux/pagemap.h>
3031 +#include <linux/vs_tag.h>
3035 @@ -66,6 +67,7 @@ static struct dentry *ext2_lookup(struct
3036 inode = iget(dir->i_sb, ino);
3038 return ERR_PTR(-EACCES);
3039 + dx_propagate_tag(nd, inode);
3041 return d_splice_alias(inode, dentry);
3043 @@ -391,6 +393,7 @@ const struct inode_operations ext2_dir_i
3045 .setattr = ext2_setattr,
3046 .permission = ext2_permission,
3047 + .sync_flags = ext2_sync_flags,
3050 const struct inode_operations ext2_special_inode_operations = {
3051 @@ -402,4 +405,5 @@ const struct inode_operations ext2_speci
3053 .setattr = ext2_setattr,
3054 .permission = ext2_permission,
3055 + .sync_flags = ext2_sync_flags,
3057 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext2/super.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/super.c
3058 --- linux-2.6.24-rc7/fs/ext2/super.c 2007-11-29 01:11:49 +0100
3059 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/super.c 2007-12-13 13:25:38 +0100
3060 @@ -389,7 +389,8 @@ enum {
3061 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
3062 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
3063 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
3064 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
3065 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
3066 + Opt_tag, Opt_notag, Opt_tagid
3069 static match_table_t tokens = {
3070 @@ -417,6 +418,10 @@ static match_table_t tokens = {
3072 {Opt_noacl, "noacl"},
3075 + {Opt_notag, "notag"},
3076 + {Opt_tagid, "tagid=%u"},
3077 + {Opt_tag, "tagxid"},
3078 {Opt_grpquota, "grpquota"},
3079 {Opt_ignore, "noquota"},
3080 {Opt_quota, "quota"},
3081 @@ -487,6 +492,20 @@ static int parse_options (char * options
3083 set_opt (sbi->s_mount_opt, NO_UID32);
3085 +#ifndef CONFIG_TAGGING_NONE
3087 + set_opt (sbi->s_mount_opt, TAGGED);
3090 + clear_opt (sbi->s_mount_opt, TAGGED);
3093 +#ifdef CONFIG_PROPAGATE
3096 + set_opt (sbi->s_mount_opt, TAGGED);
3100 clear_opt (sbi->s_mount_opt, CHECK);
3102 @@ -809,6 +828,8 @@ static int ext2_fill_super(struct super_
3103 if (!parse_options ((char *) data, sbi))
3106 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
3107 + sb->s_flags |= MS_TAGGED;
3108 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3109 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
3111 @@ -1138,6 +1159,13 @@ static int ext2_remount (struct super_bl
3115 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
3116 + !(sb->s_flags & MS_TAGGED)) {
3117 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
3122 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3123 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3125 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext2/symlink.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/symlink.c
3126 --- linux-2.6.24-rc7/fs/ext2/symlink.c 2007-05-02 19:25:17 +0200
3127 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/symlink.c 2007-12-13 13:25:39 +0100
3128 @@ -38,6 +38,7 @@ const struct inode_operations ext2_symli
3129 .listxattr = ext2_listxattr,
3130 .removexattr = generic_removexattr,
3132 + .sync_flags = ext2_sync_flags,
3135 const struct inode_operations ext2_fast_symlink_inode_operations = {
3136 @@ -49,4 +50,5 @@ const struct inode_operations ext2_fast_
3137 .listxattr = ext2_listxattr,
3138 .removexattr = generic_removexattr,
3140 + .sync_flags = ext2_sync_flags,
3142 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext2/xattr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/xattr.c
3143 --- linux-2.6.24-rc7/fs/ext2/xattr.c 2007-11-29 01:11:49 +0100
3144 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext2/xattr.c 2007-12-13 13:25:46 +0100
3146 #include <linux/mbcache.h>
3147 #include <linux/quotaops.h>
3148 #include <linux/rwsem.h>
3149 +#include <linux/vs_dlimit.h>
3153 @@ -641,8 +642,12 @@ ext2_xattr_set2(struct inode *inode, str
3155 ea_bdebug(new_bh, "reusing block");
3158 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3161 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
3162 + DLIMIT_FREE_BLOCK(inode, 1);
3163 unlock_buffer(new_bh);
3166 @@ -735,6 +740,7 @@ ext2_xattr_set2(struct inode *inode, str
3167 le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
3169 mb_cache_entry_release(ce);
3170 + DLIMIT_FREE_BLOCK(inode, 1);
3171 DQUOT_FREE_BLOCK(inode, 1);
3172 mark_buffer_dirty(old_bh);
3173 ea_bdebug(old_bh, "refcount now=%d",
3174 @@ -799,6 +805,7 @@ ext2_xattr_delete_inode(struct inode *in
3175 mark_buffer_dirty(bh);
3177 sync_dirty_buffer(bh);
3178 + DLIMIT_FREE_BLOCK(inode, 1);
3179 DQUOT_FREE_BLOCK(inode, 1);
3181 EXT2_I(inode)->i_file_acl = 0;
3182 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext3/balloc.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/balloc.c
3183 --- linux-2.6.24-rc7/fs/ext3/balloc.c 2007-11-29 01:11:49 +0100
3184 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/balloc.c 2007-12-13 13:25:46 +0100
3186 #include <linux/ext3_jbd.h>
3187 #include <linux/quotaops.h>
3188 #include <linux/buffer_head.h>
3189 +#include <linux/vs_dlimit.h>
3190 +#include <linux/vs_tag.h>
3193 * balloc.c contains the blocks allocation and deallocation routines
3194 @@ -613,8 +615,10 @@ void ext3_free_blocks(handle_t *handle,
3197 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
3198 - if (dquot_freed_blocks)
3199 + if (dquot_freed_blocks) {
3200 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3201 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3206 @@ -1353,18 +1357,33 @@ out:
3208 * Check if filesystem has at least 1 free block available for allocation.
3210 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
3211 +static int ext3_has_free_blocks(struct super_block *sb)
3213 - ext3_fsblk_t free_blocks, root_blocks;
3214 + struct ext3_sb_info *sbi = EXT3_SB(sb);
3215 + unsigned long long free_blocks, root_blocks;
3218 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3219 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
3220 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
3222 + vxdprintk(VXD_CBIT(dlim, 3),
3223 + "ext3_has_free_blocks(%p): free=%llu, root=%llu",
3224 + sb, free_blocks, root_blocks);
3226 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3228 + cond = (free_blocks < root_blocks + 1 &&
3229 + !capable(CAP_SYS_RESOURCE) &&
3230 sbi->s_resuid != current->fsuid &&
3231 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
3235 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
3237 + vxdprintk(VXD_CBIT(dlim, 3),
3238 + "ext3_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
3239 + sb, free_blocks, root_blocks,
3240 + !capable(CAP_SYS_RESOURCE)?'1':'0',
3241 + sbi->s_resuid, current->fsuid, cond?0:1);
3243 + return (cond ? 0 : 1);
3247 @@ -1381,7 +1400,7 @@ static int ext3_has_free_blocks(struct e
3249 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
3251 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
3252 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
3255 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
3256 @@ -1444,6 +1463,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3260 + if (DLIMIT_ALLOC_BLOCK(inode, num))
3264 es = EXT3_SB(sb)->s_es;
3265 @@ -1460,7 +1481,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
3266 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
3267 my_rsv = &block_i->rsv_window_node;
3269 - if (!ext3_has_free_blocks(sbi)) {
3270 + if (!ext3_has_free_blocks(sb)) {
3274 @@ -1647,12 +1668,16 @@ allocated:
3277 DQUOT_FREE_BLOCK(inode, *count-num);
3278 + DLIMIT_FREE_BLOCK(inode, *count-num);
3285 + if (!performed_allocation)
3286 + DLIMIT_FREE_BLOCK(inode, *count);
3290 ext3_std_error(sb, fatal);
3291 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext3/file.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/file.c
3292 --- linux-2.6.24-rc7/fs/ext3/file.c 2007-11-29 01:01:52 +0100
3293 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/file.c 2007-12-13 13:25:39 +0100
3294 @@ -134,5 +134,6 @@ const struct inode_operations ext3_file_
3295 .removexattr = generic_removexattr,
3297 .permission = ext3_permission,
3298 + .sync_flags = ext3_sync_flags,
3301 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext3/ialloc.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/ialloc.c
3302 --- linux-2.6.24-rc7/fs/ext3/ialloc.c 2007-11-29 01:11:49 +0100
3303 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/ialloc.c 2007-12-13 13:25:46 +0100
3305 #include <linux/buffer_head.h>
3306 #include <linux/random.h>
3307 #include <linux/bitops.h>
3308 +#include <linux/vs_dlimit.h>
3309 +#include <linux/vs_tag.h>
3311 #include <asm/byteorder.h>
3313 @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle,
3314 ext3_xattr_delete_inode(handle, inode);
3315 DQUOT_FREE_INODE(inode);
3317 + DLIMIT_FREE_INODE(inode);
3319 is_directory = S_ISDIR(inode->i_mode);
3321 @@ -442,6 +445,12 @@ struct inode *ext3_new_inode(handle_t *h
3322 inode = new_inode(sb);
3324 return ERR_PTR(-ENOMEM);
3326 + inode->i_tag = dx_current_fstag(sb);
3327 + if (DLIMIT_ALLOC_INODE(inode)) {
3334 @@ -563,7 +572,8 @@ got:
3335 ei->i_dir_start_lookup = 0;
3338 - ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
3339 + ei->i_flags = EXT3_I(dir)->i_flags &
3340 + ~(EXT3_INDEX_FL|EXT3_IUNLINK_FL|EXT3_BARRIER_FL);
3342 ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
3343 /* dirsync only applies to directories */
3344 @@ -618,6 +628,8 @@ got:
3346 ext3_std_error(sb, err);
3348 + DLIMIT_FREE_INODE(inode);
3353 @@ -629,6 +641,7 @@ fail_free_drop:
3357 + DLIMIT_FREE_INODE(inode);
3358 inode->i_flags |= S_NOQUOTA;
3361 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext3/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/inode.c
3362 --- linux-2.6.24-rc7/fs/ext3/inode.c 2007-11-29 01:11:49 +0100
3363 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/inode.c 2007-12-13 13:25:40 +0100
3365 #include <linux/mpage.h>
3366 #include <linux/uio.h>
3367 #include <linux/bio.h>
3368 +#include <linux/vs_tag.h>
3372 @@ -2304,7 +2305,7 @@ void ext3_truncate(struct inode *inode)
3374 if (ext3_inode_is_fast_symlink(inode))
3376 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3377 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3381 @@ -2626,13 +2627,20 @@ void ext3_set_inode_flags(struct inode *
3383 unsigned int flags = EXT3_I(inode)->i_flags;
3385 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3386 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
3387 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3389 + if (flags & EXT3_IMMUTABLE_FL)
3390 + inode->i_flags |= S_IMMUTABLE;
3391 + if (flags & EXT3_IUNLINK_FL)
3392 + inode->i_flags |= S_IUNLINK;
3393 + if (flags & EXT3_BARRIER_FL)
3394 + inode->i_flags |= S_BARRIER;
3396 if (flags & EXT3_SYNC_FL)
3397 inode->i_flags |= S_SYNC;
3398 if (flags & EXT3_APPEND_FL)
3399 inode->i_flags |= S_APPEND;
3400 - if (flags & EXT3_IMMUTABLE_FL)
3401 - inode->i_flags |= S_IMMUTABLE;
3402 if (flags & EXT3_NOATIME_FL)
3403 inode->i_flags |= S_NOATIME;
3404 if (flags & EXT3_DIRSYNC_FL)
3405 @@ -2658,6 +2666,45 @@ void ext3_get_inode_flags(struct ext3_in
3406 ei->i_flags |= EXT3_DIRSYNC_FL;
3409 +int ext3_sync_flags(struct inode *inode)
3411 + unsigned int oldflags, newflags;
3414 + oldflags = EXT3_I(inode)->i_flags;
3415 + newflags = oldflags & ~(EXT3_IMMUTABLE_FL |
3416 + EXT3_IUNLINK_FL | EXT3_BARRIER_FL);
3418 + if (IS_IMMUTABLE(inode))
3419 + newflags |= EXT3_IMMUTABLE_FL;
3420 + if (IS_IUNLINK(inode))
3421 + newflags |= EXT3_IUNLINK_FL;
3422 + if (IS_BARRIER(inode))
3423 + newflags |= EXT3_BARRIER_FL;
3425 + if (oldflags ^ newflags) {
3427 + struct ext3_iloc iloc;
3429 + handle = ext3_journal_start(inode, 1);
3430 + if (IS_ERR(handle))
3431 + return PTR_ERR(handle);
3432 + if (IS_SYNC(inode))
3433 + handle->h_sync = 1;
3434 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3438 + EXT3_I(inode)->i_flags = newflags;
3439 + inode->i_ctime = CURRENT_TIME;
3441 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3443 + ext3_journal_stop(handle);
3448 void ext3_read_inode(struct inode * inode)
3450 struct ext3_iloc iloc;
3451 @@ -2665,6 +2712,8 @@ void ext3_read_inode(struct inode * inod
3452 struct ext3_inode_info *ei = EXT3_I(inode);
3453 struct buffer_head *bh;
3458 #ifdef CONFIG_EXT3_FS_POSIX_ACL
3459 ei->i_acl = EXT3_ACL_NOT_CACHED;
3460 @@ -2677,12 +2726,17 @@ void ext3_read_inode(struct inode * inod
3462 raw_inode = ext3_raw_inode(&iloc);
3463 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3464 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3465 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3466 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3467 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3468 if(!(test_opt (inode->i_sb, NO_UID32))) {
3469 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3470 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3471 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3472 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3474 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3475 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3476 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3477 + le16_to_cpu(raw_inode->i_raw_tag));
3479 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3480 inode->i_size = le32_to_cpu(raw_inode->i_size);
3481 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
3482 @@ -2808,6 +2862,8 @@ static int ext3_do_update_inode(handle_t
3483 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3484 struct ext3_inode_info *ei = EXT3_I(inode);
3485 struct buffer_head *bh = iloc->bh;
3486 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3487 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3488 int err = 0, rc, block;
3490 /* For fields not not tracking in the in-memory inode,
3491 @@ -2818,29 +2874,32 @@ static int ext3_do_update_inode(handle_t
3492 ext3_get_inode_flags(ei);
3493 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3494 if(!(test_opt(inode->i_sb, NO_UID32))) {
3495 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3496 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3497 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3498 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3500 * Fix up interoperability with old kernels. Otherwise, old inodes get
3501 * re-used with the upper 16 bits of the uid/gid intact
3504 raw_inode->i_uid_high =
3505 - cpu_to_le16(high_16_bits(inode->i_uid));
3506 + cpu_to_le16(high_16_bits(uid));
3507 raw_inode->i_gid_high =
3508 - cpu_to_le16(high_16_bits(inode->i_gid));
3509 + cpu_to_le16(high_16_bits(gid));
3511 raw_inode->i_uid_high = 0;
3512 raw_inode->i_gid_high = 0;
3515 raw_inode->i_uid_low =
3516 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3517 + cpu_to_le16(fs_high2lowuid(uid));
3518 raw_inode->i_gid_low =
3519 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3520 + cpu_to_le16(fs_high2lowgid(gid));
3521 raw_inode->i_uid_high = 0;
3522 raw_inode->i_gid_high = 0;
3524 +#ifdef CONFIG_TAGGING_INTERN
3525 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3527 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3528 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3529 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3530 @@ -2993,7 +3052,8 @@ int ext3_setattr(struct dentry *dentry,
3533 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3534 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3535 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3536 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3539 /* (user+group)*(old+new) structure, inode write (sb,
3540 @@ -3015,6 +3075,8 @@ int ext3_setattr(struct dentry *dentry,
3541 inode->i_uid = attr->ia_uid;
3542 if (attr->ia_valid & ATTR_GID)
3543 inode->i_gid = attr->ia_gid;
3544 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3545 + inode->i_tag = attr->ia_tag;
3546 error = ext3_mark_inode_dirty(handle, inode);
3547 ext3_journal_stop(handle);
3549 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext3/ioctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/ioctl.c
3550 --- linux-2.6.24-rc7/fs/ext3/ioctl.c 2007-11-29 01:11:49 +0100
3551 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/ioctl.c 2007-12-13 13:25:52 +0100
3555 #include <linux/fs.h>
3556 +#include <linux/mount.h>
3557 #include <linux/jbd.h>
3558 #include <linux/capability.h>
3559 #include <linux/ext3_fs.h>
3561 #include <linux/time.h>
3562 #include <linux/compat.h>
3563 #include <linux/smp_lock.h>
3564 +#include <linux/vs_tag.h>
3565 #include <asm/uaccess.h>
3567 int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
3568 @@ -38,7 +40,8 @@ int ext3_ioctl (struct inode * inode, st
3569 unsigned int oldflags;
3572 - if (IS_RDONLY(inode))
3573 + if (IS_RDONLY(inode) ||
3574 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3577 if (!is_owner_or_cap(inode))
3578 @@ -67,7 +70,9 @@ int ext3_ioctl (struct inode * inode, st
3580 * This test looks nicer. Thanks to Pauline Middelink
3582 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3583 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3584 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3585 + EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL))) {
3586 if (!capable(CAP_LINUX_IMMUTABLE)) {
3587 mutex_unlock(&inode->i_mutex);
3589 @@ -129,7 +134,8 @@ flags_err:
3591 if (!is_owner_or_cap(inode))
3593 - if (IS_RDONLY(inode))
3594 + if (IS_RDONLY(inode) ||
3595 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3597 if (get_user(generation, (int __user *) arg))
3599 @@ -183,7 +189,8 @@ flags_err:
3600 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
3603 - if (IS_RDONLY(inode))
3604 + if (IS_RDONLY(inode) ||
3605 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3608 if (!is_owner_or_cap(inode))
3609 @@ -218,7 +225,8 @@ flags_err:
3610 if (!capable(CAP_SYS_RESOURCE))
3613 - if (IS_RDONLY(inode))
3614 + if (IS_RDONLY(inode) ||
3615 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3618 if (get_user(n_blocks_count, (__u32 __user *)arg))
3619 @@ -239,7 +247,8 @@ flags_err:
3620 if (!capable(CAP_SYS_RESOURCE))
3623 - if (IS_RDONLY(inode))
3624 + if (IS_RDONLY(inode) ||
3625 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
3628 if (copy_from_user(&input, (struct ext3_new_group_input __user *)arg,
3629 @@ -254,6 +263,38 @@ flags_err:
3633 +#if defined(CONFIG_VSERVER_LEGACY) && !defined(CONFIG_TAGGING_NONE)
3634 + case EXT3_IOC_SETTAG: {
3636 + struct ext3_iloc iloc;
3640 + /* fixme: if stealth, return -ENOTTY */
3641 + if (!capable(CAP_CONTEXT))
3643 + if (IS_RDONLY(inode))
3645 + if (!(inode->i_sb->s_flags & MS_TAGGED))
3647 + if (get_user(tag, (int __user *) arg))
3650 + handle = ext3_journal_start(inode, 1);
3651 + if (IS_ERR(handle))
3652 + return PTR_ERR(handle);
3653 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3657 + inode->i_tag = (tag & 0xFFFF);
3658 + inode->i_ctime = CURRENT_TIME;
3660 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3661 + ext3_journal_stop(handle);
3668 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext3/namei.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/namei.c
3669 --- linux-2.6.24-rc7/fs/ext3/namei.c 2007-11-29 01:11:49 +0100
3670 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/namei.c 2007-12-13 13:25:41 +0100
3672 #include <linux/quotaops.h>
3673 #include <linux/buffer_head.h>
3674 #include <linux/bio.h>
3675 +#include <linux/vs_tag.h>
3679 @@ -1052,6 +1053,7 @@ static struct dentry *ext3_lookup(struct
3681 return ERR_PTR(-ENOENT);
3683 + dx_propagate_tag(nd, inode);
3685 return d_splice_alias(inode, dentry);
3687 @@ -2432,6 +2434,7 @@ const struct inode_operations ext3_dir_i
3688 .removexattr = generic_removexattr,
3690 .permission = ext3_permission,
3691 + .sync_flags = ext3_sync_flags,
3694 const struct inode_operations ext3_special_inode_operations = {
3695 @@ -2443,4 +2446,5 @@ const struct inode_operations ext3_speci
3696 .removexattr = generic_removexattr,
3698 .permission = ext3_permission,
3699 + .sync_flags = ext3_sync_flags,
3701 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext3/super.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/super.c
3702 --- linux-2.6.24-rc7/fs/ext3/super.c 2007-12-31 17:58:24 +0100
3703 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/super.c 2007-12-31 12:34:39 +0100
3704 @@ -758,7 +758,7 @@ enum {
3705 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3706 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
3707 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
3709 + Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
3712 static match_table_t tokens = {
3713 @@ -808,6 +808,10 @@ static match_table_t tokens = {
3714 {Opt_quota, "quota"},
3715 {Opt_usrquota, "usrquota"},
3716 {Opt_barrier, "barrier=%u"},
3718 + {Opt_notag, "notag"},
3719 + {Opt_tagid, "tagid=%u"},
3720 + {Opt_tag, "tagxid"},
3722 {Opt_resize, "resize"},
3724 @@ -901,6 +905,20 @@ static int parse_options (char *options,
3726 set_opt (sbi->s_mount_opt, NO_UID32);
3728 +#ifndef CONFIG_TAGGING_NONE
3730 + set_opt (sbi->s_mount_opt, TAGGED);
3733 + clear_opt (sbi->s_mount_opt, TAGGED);
3736 +#ifdef CONFIG_PROPAGATE
3739 + set_opt (sbi->s_mount_opt, TAGGED);
3743 clear_opt (sbi->s_mount_opt, CHECK);
3745 @@ -1573,6 +1591,9 @@ static int ext3_fill_super (struct super
3749 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3750 + sb->s_flags |= MS_TAGGED;
3752 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3753 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3755 @@ -2405,6 +2426,12 @@ static int ext3_remount (struct super_bl
3757 if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
3758 ext3_abort(sb, __FUNCTION__, "Abort forced by user");
3759 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3760 + !(sb->s_flags & MS_TAGGED)) {
3761 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3766 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3767 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3768 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext3/symlink.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/symlink.c
3769 --- linux-2.6.24-rc7/fs/ext3/symlink.c 2007-05-02 19:25:17 +0200
3770 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/symlink.c 2007-12-13 13:25:39 +0100
3771 @@ -40,6 +40,7 @@ const struct inode_operations ext3_symli
3772 .listxattr = ext3_listxattr,
3773 .removexattr = generic_removexattr,
3775 + .sync_flags = ext3_sync_flags,
3778 const struct inode_operations ext3_fast_symlink_inode_operations = {
3779 @@ -51,4 +52,5 @@ const struct inode_operations ext3_fast_
3780 .listxattr = ext3_listxattr,
3781 .removexattr = generic_removexattr,
3783 + .sync_flags = ext3_sync_flags,
3785 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext3/xattr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/xattr.c
3786 --- linux-2.6.24-rc7/fs/ext3/xattr.c 2007-11-29 01:11:49 +0100
3787 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext3/xattr.c 2007-12-13 13:25:46 +0100
3789 #include <linux/mbcache.h>
3790 #include <linux/quotaops.h>
3791 #include <linux/rwsem.h>
3792 +#include <linux/vs_dlimit.h>
3796 @@ -497,6 +498,7 @@ ext3_xattr_release_block(handle_t *handl
3797 error = ext3_journal_dirty_metadata(handle, bh);
3800 + DLIMIT_FREE_BLOCK(inode, 1);
3801 DQUOT_FREE_BLOCK(inode, 1);
3802 ea_bdebug(bh, "refcount now=%d; releasing",
3803 le32_to_cpu(BHDR(bh)->h_refcount));
3804 @@ -770,11 +772,14 @@ inserted:
3805 if (new_bh == bs->bh)
3806 ea_bdebug(new_bh, "keeping");
3809 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
3811 /* The old block is released after updating
3814 if (DQUOT_ALLOC_BLOCK(inode, 1))
3816 + goto cleanup_dlimit;
3817 error = ext3_journal_get_write_access(handle,
3820 @@ -851,6 +856,8 @@ cleanup:
3823 DQUOT_FREE_BLOCK(inode, 1);
3825 + DLIMIT_FREE_BLOCK(inode, 1);
3829 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext4/balloc.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/balloc.c
3830 --- linux-2.6.24-rc7/fs/ext4/balloc.c 2007-11-29 01:11:49 +0100
3831 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/balloc.c 2007-12-13 13:25:46 +0100
3833 #include <linux/ext4_jbd2.h>
3834 #include <linux/quotaops.h>
3835 #include <linux/buffer_head.h>
3836 +#include <linux/vs_dlimit.h>
3837 +#include <linux/vs_tag.h>
3841 @@ -733,8 +735,10 @@ void ext4_free_blocks(handle_t *handle,
3844 ext4_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
3845 - if (dquot_freed_blocks)
3846 + if (dquot_freed_blocks) {
3847 + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks);
3848 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
3853 @@ -1473,18 +1477,33 @@ out:
3855 * Check if filesystem has at least 1 free block available for allocation.
3857 -static int ext4_has_free_blocks(struct ext4_sb_info *sbi)
3858 +static int ext4_has_free_blocks(struct super_block *sb)
3860 + struct ext4_sb_info *sbi = EXT4_SB(sb);
3861 ext4_fsblk_t free_blocks, root_blocks;
3864 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
3865 root_blocks = ext4_r_blocks_count(sbi->s_es);
3866 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
3868 + vxdprintk(VXD_CBIT(dlim, 3),
3869 + "ext4_has_free_blocks(%p): free=%llu, root=%llu",
3870 + sb, free_blocks, root_blocks);
3872 + DLIMIT_ADJUST_BLOCK(sb, dx_current_tag(), &free_blocks, &root_blocks);
3874 + cond = (free_blocks < root_blocks + 1 &&
3875 + !capable(CAP_SYS_RESOURCE) &&
3876 sbi->s_resuid != current->fsuid &&
3877 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
3881 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
3883 + vxdprintk(VXD_CBIT(dlim, 3),
3884 + "ext4_has_free_blocks(%p): %llu<%llu+1, %c, %u!=%u r=%d",
3885 + sb, free_blocks, root_blocks,
3886 + !capable(CAP_SYS_RESOURCE)?'1':'0',
3887 + sbi->s_resuid, current->fsuid, cond?0:1);
3889 + return (cond ? 0 : 1);
3893 @@ -1501,7 +1520,7 @@ static int ext4_has_free_blocks(struct e
3895 int ext4_should_retry_alloc(struct super_block *sb, int *retries)
3897 - if (!ext4_has_free_blocks(EXT4_SB(sb)) || (*retries)++ > 3)
3898 + if (!ext4_has_free_blocks(sb) || (*retries)++ > 3)
3901 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
3902 @@ -1564,6 +1583,8 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
3906 + if (DLIMIT_ALLOC_BLOCK(inode, num))
3910 es = EXT4_SB(sb)->s_es;
3911 @@ -1580,7 +1601,7 @@ ext4_fsblk_t ext4_new_blocks(handle_t *h
3912 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
3913 my_rsv = &block_i->rsv_window_node;
3915 - if (!ext4_has_free_blocks(sbi)) {
3916 + if (!ext4_has_free_blocks(sb)) {
3920 @@ -1767,12 +1788,16 @@ allocated:
3923 DQUOT_FREE_BLOCK(inode, *count-num);
3924 + DLIMIT_FREE_BLOCK(inode, *count-num);
3931 + if (!performed_allocation)
3932 + DLIMIT_FREE_BLOCK(inode, *count);
3936 ext4_std_error(sb, fatal);
3937 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext4/file.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/file.c
3938 --- linux-2.6.24-rc7/fs/ext4/file.c 2007-11-29 01:01:52 +0100
3939 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/file.c 2007-12-13 13:25:39 +0100
3940 @@ -135,5 +135,6 @@ const struct inode_operations ext4_file_
3942 .permission = ext4_permission,
3943 .fallocate = ext4_fallocate,
3944 + .sync_flags = ext4_sync_flags,
3947 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext4/ialloc.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/ialloc.c
3948 --- linux-2.6.24-rc7/fs/ext4/ialloc.c 2007-11-29 01:11:50 +0100
3949 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/ialloc.c 2007-12-13 13:25:46 +0100
3951 #include <linux/random.h>
3952 #include <linux/bitops.h>
3953 #include <linux/blkdev.h>
3954 +#include <linux/vs_dlimit.h>
3955 +#include <linux/vs_tag.h>
3956 #include <asm/byteorder.h>
3959 @@ -186,6 +188,7 @@ void ext4_free_inode (handle_t *handle,
3960 ext4_xattr_delete_inode(handle, inode);
3961 DQUOT_FREE_INODE(inode);
3963 + DLIMIT_FREE_INODE(inode);
3965 is_directory = S_ISDIR(inode->i_mode);
3967 @@ -506,6 +509,12 @@ struct inode *ext4_new_inode(handle_t *h
3968 inode = new_inode(sb);
3970 return ERR_PTR(-ENOMEM);
3972 + inode->i_tag = dx_current_fstag(sb);
3973 + if (DLIMIT_ALLOC_INODE(inode)) {
3980 @@ -695,7 +704,8 @@ got:
3981 ei->i_dir_start_lookup = 0;
3984 - ei->i_flags = EXT4_I(dir)->i_flags & ~EXT4_INDEX_FL;
3985 + ei->i_flags = EXT4_I(dir)->i_flags &
3986 + ~(EXT4_INDEX_FL|EXT4_IUNLINK_FL|EXT4_BARRIER_FL);
3988 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
3989 /* dirsync only applies to directories */
3990 @@ -755,6 +765,8 @@ got:
3992 ext4_std_error(sb, err);
3994 + DLIMIT_FREE_INODE(inode);
3999 @@ -766,6 +778,7 @@ fail_free_drop:
4003 + DLIMIT_FREE_INODE(inode);
4004 inode->i_flags |= S_NOQUOTA;
4007 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext4/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/inode.c
4008 --- linux-2.6.24-rc7/fs/ext4/inode.c 2007-11-29 01:11:50 +0100
4009 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/inode.c 2007-12-13 13:25:40 +0100
4011 #include <linux/mpage.h>
4012 #include <linux/uio.h>
4013 #include <linux/bio.h>
4014 +#include <linux/vs_tag.h>
4018 @@ -2303,7 +2304,7 @@ void ext4_truncate(struct inode *inode)
4020 if (ext4_inode_is_fast_symlink(inode))
4022 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4023 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4027 @@ -2629,13 +2630,20 @@ void ext4_set_inode_flags(struct inode *
4029 unsigned int flags = EXT4_I(inode)->i_flags;
4031 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4032 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
4033 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4035 + if (flags & EXT4_IMMUTABLE_FL)
4036 + inode->i_flags |= S_IMMUTABLE;
4037 + if (flags & EXT4_IUNLINK_FL)
4038 + inode->i_flags |= S_IUNLINK;
4039 + if (flags & EXT4_BARRIER_FL)
4040 + inode->i_flags |= S_BARRIER;
4042 if (flags & EXT4_SYNC_FL)
4043 inode->i_flags |= S_SYNC;
4044 if (flags & EXT4_APPEND_FL)
4045 inode->i_flags |= S_APPEND;
4046 - if (flags & EXT4_IMMUTABLE_FL)
4047 - inode->i_flags |= S_IMMUTABLE;
4048 if (flags & EXT4_NOATIME_FL)
4049 inode->i_flags |= S_NOATIME;
4050 if (flags & EXT4_DIRSYNC_FL)
4051 @@ -2661,6 +2669,45 @@ void ext4_get_inode_flags(struct ext4_in
4052 ei->i_flags |= EXT4_DIRSYNC_FL;
4055 +int ext4_sync_flags(struct inode *inode)
4057 + unsigned int oldflags, newflags;
4060 + oldflags = EXT4_I(inode)->i_flags;
4061 + newflags = oldflags & ~(EXT4_IMMUTABLE_FL |
4062 + EXT4_IUNLINK_FL | EXT4_BARRIER_FL);
4064 + if (IS_IMMUTABLE(inode))
4065 + newflags |= EXT4_IMMUTABLE_FL;
4066 + if (IS_IUNLINK(inode))
4067 + newflags |= EXT4_IUNLINK_FL;
4068 + if (IS_BARRIER(inode))
4069 + newflags |= EXT4_BARRIER_FL;
4071 + if (oldflags ^ newflags) {
4073 + struct ext4_iloc iloc;
4075 + handle = ext4_journal_start(inode, 1);
4076 + if (IS_ERR(handle))
4077 + return PTR_ERR(handle);
4078 + if (IS_SYNC(inode))
4079 + handle->h_sync = 1;
4080 + err = ext4_reserve_inode_write(handle, inode, &iloc);
4084 + EXT4_I(inode)->i_flags = newflags;
4085 + inode->i_ctime = CURRENT_TIME;
4087 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
4089 + ext4_journal_stop(handle);
4094 void ext4_read_inode(struct inode * inode)
4096 struct ext4_iloc iloc;
4097 @@ -2668,6 +2715,8 @@ void ext4_read_inode(struct inode * inod
4098 struct ext4_inode_info *ei = EXT4_I(inode);
4099 struct buffer_head *bh;
4104 #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
4105 ei->i_acl = EXT4_ACL_NOT_CACHED;
4106 @@ -2680,12 +2729,17 @@ void ext4_read_inode(struct inode * inod
4108 raw_inode = ext4_raw_inode(&iloc);
4109 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4110 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4111 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4112 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4113 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4114 if(!(test_opt (inode->i_sb, NO_UID32))) {
4115 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4116 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4117 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4118 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4120 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4121 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4122 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4123 + le16_to_cpu(raw_inode->i_raw_tag));
4125 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4126 inode->i_size = le32_to_cpu(raw_inode->i_size);
4128 @@ -2811,6 +2865,8 @@ static int ext4_do_update_inode(handle_t
4129 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
4130 struct ext4_inode_info *ei = EXT4_I(inode);
4131 struct buffer_head *bh = iloc->bh;
4132 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4133 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4134 int err = 0, rc, block;
4136 /* For fields not not tracking in the in-memory inode,
4137 @@ -2821,29 +2877,32 @@ static int ext4_do_update_inode(handle_t
4138 ext4_get_inode_flags(ei);
4139 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4140 if(!(test_opt(inode->i_sb, NO_UID32))) {
4141 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4142 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4143 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4144 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4146 * Fix up interoperability with old kernels. Otherwise, old inodes get
4147 * re-used with the upper 16 bits of the uid/gid intact
4150 raw_inode->i_uid_high =
4151 - cpu_to_le16(high_16_bits(inode->i_uid));
4152 + cpu_to_le16(high_16_bits(uid));
4153 raw_inode->i_gid_high =
4154 - cpu_to_le16(high_16_bits(inode->i_gid));
4155 + cpu_to_le16(high_16_bits(gid));
4157 raw_inode->i_uid_high = 0;
4158 raw_inode->i_gid_high = 0;
4161 raw_inode->i_uid_low =
4162 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4163 + cpu_to_le16(fs_high2lowuid(uid));
4164 raw_inode->i_gid_low =
4165 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4166 + cpu_to_le16(fs_high2lowgid(gid));
4167 raw_inode->i_uid_high = 0;
4168 raw_inode->i_gid_high = 0;
4170 +#ifdef CONFIG_TAGGING_INTERN
4171 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4173 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4174 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4176 @@ -2998,7 +3057,8 @@ int ext4_setattr(struct dentry *dentry,
4179 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4180 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4181 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4182 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4185 /* (user+group)*(old+new) structure, inode write (sb,
4186 @@ -3020,6 +3080,8 @@ int ext4_setattr(struct dentry *dentry,
4187 inode->i_uid = attr->ia_uid;
4188 if (attr->ia_valid & ATTR_GID)
4189 inode->i_gid = attr->ia_gid;
4190 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4191 + inode->i_tag = attr->ia_tag;
4192 error = ext4_mark_inode_dirty(handle, inode);
4193 ext4_journal_stop(handle);
4195 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext4/ioctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/ioctl.c
4196 --- linux-2.6.24-rc7/fs/ext4/ioctl.c 2007-11-29 01:11:50 +0100
4197 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/ioctl.c 2007-12-13 13:25:52 +0100
4201 #include <linux/fs.h>
4202 +#include <linux/mount.h>
4203 #include <linux/jbd2.h>
4204 #include <linux/capability.h>
4205 #include <linux/ext4_fs.h>
4207 #include <linux/time.h>
4208 #include <linux/compat.h>
4209 #include <linux/smp_lock.h>
4210 +#include <linux/vs_tag.h>
4211 #include <asm/uaccess.h>
4213 int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
4214 @@ -38,7 +40,8 @@ int ext4_ioctl (struct inode * inode, st
4215 unsigned int oldflags;
4218 - if (IS_RDONLY(inode))
4219 + if (IS_RDONLY(inode) ||
4220 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4223 if (!is_owner_or_cap(inode))
4224 @@ -67,7 +70,9 @@ int ext4_ioctl (struct inode * inode, st
4226 * This test looks nicer. Thanks to Pauline Middelink
4228 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
4229 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
4230 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
4231 + EXT4_IMMUTABLE_FL | EXT4_IUNLINK_FL))) {
4232 if (!capable(CAP_LINUX_IMMUTABLE)) {
4233 mutex_unlock(&inode->i_mutex);
4235 @@ -129,7 +134,8 @@ flags_err:
4237 if (!is_owner_or_cap(inode))
4239 - if (IS_RDONLY(inode))
4240 + if (IS_RDONLY(inode) ||
4241 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4243 if (get_user(generation, (int __user *) arg))
4245 @@ -183,7 +189,8 @@ flags_err:
4246 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
4249 - if (IS_RDONLY(inode))
4250 + if (IS_RDONLY(inode) ||
4251 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4254 if (!is_owner_or_cap(inode))
4255 @@ -218,7 +225,8 @@ flags_err:
4256 if (!capable(CAP_SYS_RESOURCE))
4259 - if (IS_RDONLY(inode))
4260 + if (IS_RDONLY(inode) ||
4261 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4264 if (get_user(n_blocks_count, (__u32 __user *)arg))
4265 @@ -239,7 +247,8 @@ flags_err:
4266 if (!capable(CAP_SYS_RESOURCE))
4269 - if (IS_RDONLY(inode))
4270 + if (IS_RDONLY(inode) ||
4271 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4274 if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg,
4275 @@ -254,6 +263,39 @@ flags_err:
4279 +#if defined(CONFIG_VSERVER_LEGACY) && !defined(CONFIG_TAGGING_NONE)
4280 + case EXT4_IOC_SETTAG: {
4282 + struct ext4_iloc iloc;
4286 + /* fixme: if stealth, return -ENOTTY */
4287 + if (!capable(CAP_CONTEXT))
4289 + if (IS_RDONLY(inode))
4291 + if (!(inode->i_sb->s_flags & MS_TAGGED))
4293 + if (get_user(tag, (int __user *) arg))
4296 + handle = ext4_journal_start(inode, 1);
4297 + if (IS_ERR(handle))
4298 + return PTR_ERR(handle);
4299 + err = ext4_reserve_inode_write(handle, inode, &iloc);
4303 + inode->i_tag = (tag & 0xFFFF);
4304 + inode->i_ctime = CURRENT_TIME;
4306 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
4307 + ext4_journal_stop(handle);
4315 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext4/namei.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/namei.c
4316 --- linux-2.6.24-rc7/fs/ext4/namei.c 2007-11-29 01:11:50 +0100
4317 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/namei.c 2007-12-13 13:25:41 +0100
4319 #include <linux/quotaops.h>
4320 #include <linux/buffer_head.h>
4321 #include <linux/bio.h>
4322 +#include <linux/vs_tag.h>
4326 @@ -1048,6 +1049,7 @@ static struct dentry *ext4_lookup(struct
4328 return ERR_PTR(-ENOENT);
4330 + dx_propagate_tag(nd, inode);
4332 return d_splice_alias(inode, dentry);
4334 @@ -2463,6 +2465,7 @@ const struct inode_operations ext4_dir_i
4335 .removexattr = generic_removexattr,
4337 .permission = ext4_permission,
4338 + .sync_flags = ext4_sync_flags,
4341 const struct inode_operations ext4_special_inode_operations = {
4342 @@ -2474,4 +2477,5 @@ const struct inode_operations ext4_speci
4343 .removexattr = generic_removexattr,
4345 .permission = ext4_permission,
4346 + .sync_flags = ext4_sync_flags,
4348 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext4/super.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/super.c
4349 --- linux-2.6.24-rc7/fs/ext4/super.c 2007-12-31 17:58:24 +0100
4350 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/super.c 2007-12-31 12:34:39 +0100
4351 @@ -814,6 +814,7 @@ enum {
4352 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
4353 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
4354 Opt_grpquota, Opt_extents, Opt_noextents,
4355 + Opt_tag, Opt_notag, Opt_tagid
4358 static match_table_t tokens = {
4359 @@ -865,6 +866,10 @@ static match_table_t tokens = {
4360 {Opt_barrier, "barrier=%u"},
4361 {Opt_extents, "extents"},
4362 {Opt_noextents, "noextents"},
4364 + {Opt_notag, "notag"},
4365 + {Opt_tagid, "tagid=%u"},
4366 + {Opt_tag, "tagxid"},
4368 {Opt_resize, "resize"},
4370 @@ -958,6 +963,20 @@ static int parse_options (char *options,
4372 set_opt (sbi->s_mount_opt, NO_UID32);
4374 +#ifndef CONFIG_TAGGING_NONE
4376 + set_opt (sbi->s_mount_opt, TAGGED);
4379 + clear_opt (sbi->s_mount_opt, TAGGED);
4382 +#ifdef CONFIG_PROPAGATE
4385 + set_opt (sbi->s_mount_opt, TAGGED);
4389 clear_opt (sbi->s_mount_opt, CHECK);
4391 @@ -1694,6 +1713,9 @@ static int ext4_fill_super (struct super
4395 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
4396 + sb->s_flags |= MS_TAGGED;
4398 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4399 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4401 @@ -2558,6 +2580,12 @@ static int ext4_remount (struct super_bl
4403 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT)
4404 ext4_abort(sb, __FUNCTION__, "Abort forced by user");
4405 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
4406 + !(sb->s_flags & MS_TAGGED)) {
4407 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
4412 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4413 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4414 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext4/symlink.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/symlink.c
4415 --- linux-2.6.24-rc7/fs/ext4/symlink.c 2007-05-02 19:25:17 +0200
4416 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/symlink.c 2007-12-13 13:25:39 +0100
4417 @@ -40,6 +40,7 @@ const struct inode_operations ext4_symli
4418 .listxattr = ext4_listxattr,
4419 .removexattr = generic_removexattr,
4421 + .sync_flags = ext4_sync_flags,
4424 const struct inode_operations ext4_fast_symlink_inode_operations = {
4425 @@ -51,4 +52,5 @@ const struct inode_operations ext4_fast_
4426 .listxattr = ext4_listxattr,
4427 .removexattr = generic_removexattr,
4429 + .sync_flags = ext4_sync_flags,
4431 diff -NurpP --minimal linux-2.6.24-rc7/fs/ext4/xattr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/xattr.c
4432 --- linux-2.6.24-rc7/fs/ext4/xattr.c 2007-11-29 01:11:51 +0100
4433 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ext4/xattr.c 2007-12-13 13:25:46 +0100
4435 #include <linux/mbcache.h>
4436 #include <linux/quotaops.h>
4437 #include <linux/rwsem.h>
4438 +#include <linux/vs_dlimit.h>
4442 @@ -489,6 +490,7 @@ ext4_xattr_release_block(handle_t *handl
4443 error = ext4_journal_dirty_metadata(handle, bh);
4446 + DLIMIT_FREE_BLOCK(inode, 1);
4447 DQUOT_FREE_BLOCK(inode, 1);
4448 ea_bdebug(bh, "refcount now=%d; releasing",
4449 le32_to_cpu(BHDR(bh)->h_refcount));
4450 @@ -779,11 +781,14 @@ inserted:
4451 if (new_bh == bs->bh)
4452 ea_bdebug(new_bh, "keeping");
4455 + if (DLIMIT_ALLOC_BLOCK(inode, 1))
4457 /* The old block is released after updating
4460 if (DQUOT_ALLOC_BLOCK(inode, 1))
4462 + goto cleanup_dlimit;
4463 error = ext4_journal_get_write_access(handle,
4466 @@ -860,6 +865,8 @@ cleanup:
4469 DQUOT_FREE_BLOCK(inode, 1);
4471 + DLIMIT_FREE_BLOCK(inode, 1);
4475 diff -NurpP --minimal linux-2.6.24-rc7/fs/fcntl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/fcntl.c
4476 --- linux-2.6.24-rc7/fs/fcntl.c 2007-11-29 01:11:51 +0100
4477 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/fcntl.c 2007-12-13 13:25:42 +0100
4479 #include <linux/signal.h>
4480 #include <linux/rcupdate.h>
4481 #include <linux/pid_namespace.h>
4482 +#include <linux/vs_limit.h>
4484 #include <asm/poll.h>
4485 #include <asm/siginfo.h>
4486 @@ -85,6 +86,8 @@ repeat:
4488 if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
4490 + if (!vx_files_avail(1))
4493 error = expand_files(files, newfd);
4495 @@ -128,6 +131,7 @@ static int dupfd(struct file *file, unsi
4497 FD_CLR(fd, fdt->close_on_exec);
4498 spin_unlock(&files->file_lock);
4499 + vx_openfd_inc(fd);
4500 fd_install(fd, file);
4502 spin_unlock(&files->file_lock);
4503 @@ -180,6 +184,9 @@ asmlinkage long sys_dup2(unsigned int ol
4506 filp_close(tofree, files);
4508 + vx_openfd_inc(newfd); /* fd was unused */
4513 diff -NurpP --minimal linux-2.6.24-rc7/fs/file_table.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/file_table.c
4514 --- linux-2.6.24-rc7/fs/file_table.c 2007-11-29 01:11:51 +0100
4515 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/file_table.c 2007-12-13 13:25:42 +0100
4517 #include <linux/fsnotify.h>
4518 #include <linux/sysctl.h>
4519 #include <linux/percpu_counter.h>
4520 +#include <linux/vs_limit.h>
4521 +#include <linux/vs_context.h>
4523 #include <asm/atomic.h>
4525 @@ -118,6 +120,8 @@ struct file *get_empty_filp(void)
4526 f->f_gid = tsk->fsgid;
4527 eventpoll_init_file(f);
4528 /* f->f_version: 0 */
4529 + f->f_xid = vx_current_xid();
4534 @@ -233,6 +237,8 @@ void fastcall __fput(struct file *file)
4535 if (file->f_mode & FMODE_WRITE)
4536 put_write_access(inode);
4537 put_pid(file->f_owner.pid);
4538 + vx_files_dec(file);
4541 file->f_path.dentry = NULL;
4542 file->f_path.mnt = NULL;
4543 @@ -298,6 +304,8 @@ void put_filp(struct file *file)
4545 if (atomic_dec_and_test(&file->f_count)) {
4546 security_file_free(file);
4547 + vx_files_dec(file);
4552 diff -NurpP --minimal linux-2.6.24-rc7/fs/hfsplus/ioctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/hfsplus/ioctl.c
4553 --- linux-2.6.24-rc7/fs/hfsplus/ioctl.c 2007-11-29 01:01:53 +0100
4554 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/hfsplus/ioctl.c 2007-12-13 13:25:47 +0100
4556 #include <linux/fs.h>
4557 #include <linux/sched.h>
4558 #include <linux/xattr.h>
4559 +#include <linux/mount.h>
4560 #include <asm/uaccess.h>
4561 #include "hfsplus_fs.h"
4563 @@ -35,7 +36,8 @@ int hfsplus_ioctl(struct inode *inode, s
4564 flags |= FS_NODUMP_FL; /* EXT2_NODUMP_FL */
4565 return put_user(flags, (int __user *)arg);
4566 case HFSPLUS_IOC_EXT2_SETFLAGS: {
4567 - if (IS_RDONLY(inode))
4568 + if (IS_RDONLY(inode) ||
4569 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4572 if (!is_owner_or_cap(inode))
4573 diff -NurpP --minimal linux-2.6.24-rc7/fs/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/inode.c
4574 --- linux-2.6.24-rc7/fs/inode.c 2007-11-29 01:11:52 +0100
4575 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/inode.c 2007-12-13 13:25:52 +0100
4576 @@ -124,6 +124,9 @@ static struct inode *alloc_inode(struct
4577 struct address_space * const mapping = &inode->i_data;
4581 + /* essential because of inode slab reuse */
4583 inode->i_blkbits = sb->s_blocksize_bits;
4585 atomic_set(&inode->i_count, 1);
4586 @@ -246,6 +249,8 @@ void __iget(struct inode * inode)
4587 inodes_stat.nr_unused--;
4590 +EXPORT_SYMBOL_GPL(__iget);
4593 * clear_inode - clear an inode
4594 * @inode: inode to clear
4595 diff -NurpP --minimal linux-2.6.24-rc7/fs/ioctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ioctl.c
4596 --- linux-2.6.24-rc7/fs/ioctl.c 2007-11-29 01:01:53 +0100
4597 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ioctl.c 2007-12-13 13:25:52 +0100
4599 #include <linux/fs.h>
4600 #include <linux/security.h>
4601 #include <linux/module.h>
4602 +#include <linux/proc_fs.h>
4603 +#include <linux/vserver/inode.h>
4604 +#include <linux/vs_tag.h>
4606 #include <asm/uaccess.h>
4607 #include <asm/ioctls.h>
4610 +#ifdef CONFIG_VSERVER_LEGACY
4611 +extern int vx_proc_ioctl(struct inode *, struct file *,
4612 + unsigned int, unsigned long);
4615 static long do_ioctl(struct file *filp, unsigned int cmd,
4618 @@ -144,6 +153,48 @@ int vfs_ioctl(struct file *filp, unsigne
4622 +#ifdef CONFIG_VSERVER_LEGACY
4623 +#ifndef CONFIG_TAGGING_NONE
4624 + case FIOC_GETTAG: {
4625 + struct inode *inode = filp->f_dentry->d_inode;
4627 + /* fixme: if stealth, return -ENOTTY */
4629 + if (capable(CAP_CONTEXT))
4630 + error = put_user(inode->i_tag, (int __user *) arg);
4633 + case FIOC_SETTAG: {
4634 + struct inode *inode = filp->f_dentry->d_inode;
4637 + /* fixme: if stealth, return -ENOTTY */
4639 + if (!capable(CAP_CONTEXT))
4642 + if (IS_RDONLY(inode))
4645 + if (!(inode->i_sb->s_flags & MS_TAGGED))
4648 + if (get_user(tag, (int __user *) arg))
4651 + inode->i_tag = (tag & 0xFFFF);
4652 + inode->i_ctime = CURRENT_TIME;
4653 + mark_inode_dirty(inode);
4657 + case FIOC_GETXFLG:
4658 + case FIOC_SETXFLG:
4660 + if (filp->f_dentry->d_inode->i_sb->s_magic == PROC_SUPER_MAGIC)
4661 + error = vx_proc_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
4665 if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
4666 error = file_ioctl(filp, cmd, arg);
4667 diff -NurpP --minimal linux-2.6.24-rc7/fs/ioprio.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ioprio.c
4668 --- linux-2.6.24-rc7/fs/ioprio.c 2007-11-29 01:11:52 +0100
4669 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ioprio.c 2007-12-13 16:09:12 +0100
4671 #include <linux/syscalls.h>
4672 #include <linux/security.h>
4673 #include <linux/pid_namespace.h>
4674 +#include <linux/vs_base.h>
4676 static int set_task_ioprio(struct task_struct *task, int ioprio)
4678 @@ -108,6 +109,8 @@ asmlinkage long sys_ioprio_set(int which
4680 pgrp = find_vpid(who);
4681 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
4682 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4684 ret = set_task_ioprio(p, ioprio);
4687 @@ -195,6 +198,8 @@ asmlinkage long sys_ioprio_get(int which
4689 pgrp = find_vpid(who);
4690 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
4691 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
4693 tmpio = get_task_ioprio(p);
4696 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/acl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/acl.c
4697 --- linux-2.6.24-rc7/fs/jfs/acl.c 2006-11-30 21:19:25 +0100
4698 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/acl.c 2007-12-13 13:25:40 +0100
4699 @@ -232,7 +232,8 @@ int jfs_setattr(struct dentry *dentry, s
4702 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4703 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4704 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4705 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4706 if (DQUOT_TRANSFER(inode, iattr))
4709 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/file.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/file.c
4710 --- linux-2.6.24-rc7/fs/jfs/file.c 2007-11-29 01:01:54 +0100
4711 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/file.c 2007-12-13 13:25:39 +0100
4712 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
4713 .setattr = jfs_setattr,
4714 .permission = jfs_permission,
4716 + .sync_flags = jfs_sync_flags,
4719 const struct file_operations jfs_file_operations = {
4720 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/inode.c
4721 --- linux-2.6.24-rc7/fs/jfs/inode.c 2007-11-29 01:11:53 +0100
4722 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/inode.c 2007-12-13 13:25:46 +0100
4724 #include <linux/buffer_head.h>
4725 #include <linux/pagemap.h>
4726 #include <linux/quotaops.h>
4727 +#include <linux/vs_dlimit.h>
4728 #include "jfs_incore.h"
4729 #include "jfs_inode.h"
4730 #include "jfs_filsys.h"
4731 @@ -143,6 +144,7 @@ void jfs_delete_inode(struct inode *inod
4733 DQUOT_FREE_INODE(inode);
4735 + DLIMIT_FREE_INODE(inode);
4739 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/ioctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/ioctl.c
4740 --- linux-2.6.24-rc7/fs/jfs/ioctl.c 2007-11-29 01:11:53 +0100
4741 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/ioctl.c 2007-12-13 13:25:47 +0100
4743 #include <linux/capability.h>
4744 #include <linux/time.h>
4745 #include <linux/sched.h>
4746 +#include <linux/mount.h>
4747 #include <asm/current.h>
4748 #include <asm/uaccess.h>
4750 @@ -66,7 +67,8 @@ int jfs_ioctl(struct inode * inode, stru
4751 case JFS_IOC_SETFLAGS: {
4752 unsigned int oldflags;
4754 - if (IS_RDONLY(inode))
4755 + if (IS_RDONLY(inode) ||
4756 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
4759 if (!is_owner_or_cap(inode))
4760 @@ -90,8 +92,8 @@ int jfs_ioctl(struct inode * inode, stru
4761 * the relevant capability.
4763 if ((oldflags & JFS_IMMUTABLE_FL) ||
4764 - ((flags ^ oldflags) &
4765 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
4766 + ((flags ^ oldflags) & (JFS_APPEND_FL |
4767 + JFS_IMMUTABLE_FL | JFS_IUNLINK_FL))) {
4768 if (!capable(CAP_LINUX_IMMUTABLE))
4771 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/jfs_dinode.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_dinode.h
4772 --- linux-2.6.24-rc7/fs/jfs/jfs_dinode.h 2007-11-29 01:01:54 +0100
4773 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_dinode.h 2007-12-13 13:25:39 +0100
4774 @@ -162,9 +162,12 @@ struct dinode {
4775 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
4776 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
4778 -#define JFS_FL_USER_VISIBLE 0x03F80000
4779 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4780 +#define JFS_IUNLINK_FL 0x08000000 /* Immutable unlink */
4782 +#define JFS_FL_USER_VISIBLE 0x0FF80000
4783 #define JFS_FL_USER_MODIFIABLE 0x03F80000
4784 -#define JFS_FL_INHERIT 0x03C80000
4785 +#define JFS_FL_INHERIT 0x0BC80000
4787 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
4788 #define JFS_IOC_GETFLAGS _IOR('f', 1, long)
4789 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/jfs_dtree.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_dtree.c
4790 --- linux-2.6.24-rc7/fs/jfs/jfs_dtree.c 2007-11-29 01:11:53 +0100
4791 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_dtree.c 2007-12-13 13:25:46 +0100
4794 #include <linux/fs.h>
4795 #include <linux/quotaops.h>
4796 +#include <linux/vs_dlimit.h>
4797 #include "jfs_incore.h"
4798 #include "jfs_superblock.h"
4799 #include "jfs_filsys.h"
4800 @@ -383,10 +384,10 @@ static u32 add_index(tid_t tid, struct i
4802 if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
4804 - if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
4805 - DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
4808 + if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
4809 + goto clean_up_dquot;
4810 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
4811 + goto clean_up_dlimit;
4814 * Save the table, we're going to overwrite it with the
4815 @@ -479,6 +480,12 @@ static u32 add_index(tid_t tid, struct i
4820 + DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
4823 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
4827 jfs_ip->next_index--;
4828 @@ -952,6 +959,7 @@ static int dtSplitUp(tid_t tid,
4831 int quota_allocation = 0;
4832 + int dlimit_allocation = 0;
4834 /* get split page */
4836 @@ -1036,6 +1044,12 @@ static int dtSplitUp(tid_t tid,
4838 quota_allocation += n;
4840 + if (DLIMIT_ALLOC_BLOCK(ip, n)) {
4844 + dlimit_allocation += n;
4846 if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
4849 @@ -1309,6 +1323,9 @@ static int dtSplitUp(tid_t tid,
4853 + /* Rollback dlimit allocation */
4854 + if (rc && dlimit_allocation)
4855 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
4856 /* Rollback quota allocation */
4857 if (rc && quota_allocation)
4858 DQUOT_FREE_BLOCK(ip, quota_allocation);
4859 @@ -1376,6 +1393,12 @@ static int dtSplitPage(tid_t tid, struct
4860 release_metapage(rmp);
4863 + /* Allocate blocks to dlimit. */
4864 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4865 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4866 + release_metapage(rmp);
4870 jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
4872 @@ -1923,6 +1946,12 @@ static int dtSplitRoot(tid_t tid,
4873 release_metapage(rmp);
4876 + /* Allocate blocks to dlimit. */
4877 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
4878 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
4879 + release_metapage(rmp);
4883 BT_MARK_DIRTY(rmp, ip);
4885 @@ -2289,6 +2318,8 @@ static int dtDeleteUp(tid_t tid, struct
4887 xlen = lengthPXD(&fp->header.self);
4889 + /* Free dlimit allocation. */
4890 + DLIMIT_FREE_BLOCK(ip, xlen);
4891 /* Free quota allocation. */
4892 DQUOT_FREE_BLOCK(ip, xlen);
4894 @@ -2365,6 +2396,8 @@ static int dtDeleteUp(tid_t tid, struct
4896 xlen = lengthPXD(&p->header.self);
4898 + /* Free dlimit allocation */
4899 + DLIMIT_FREE_BLOCK(ip, xlen);
4900 /* Free quota allocation */
4901 DQUOT_FREE_BLOCK(ip, xlen);
4903 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/jfs_extent.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_extent.c
4904 --- linux-2.6.24-rc7/fs/jfs/jfs_extent.c 2007-11-29 01:01:54 +0100
4905 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_extent.c 2007-12-13 13:25:46 +0100
4908 #include <linux/fs.h>
4909 #include <linux/quotaops.h>
4910 +#include <linux/vs_dlimit.h>
4911 #include "jfs_incore.h"
4912 #include "jfs_inode.h"
4913 #include "jfs_superblock.h"
4914 @@ -147,6 +148,14 @@ extAlloc(struct inode *ip, s64 xlen, s64
4918 + /* Allocate blocks to dlimit. */
4919 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4920 + DQUOT_FREE_BLOCK(ip, nxlen);
4921 + dbFree(ip, nxaddr, (s64) nxlen);
4922 + mutex_unlock(&JFS_IP(ip)->commit_mutex);
4926 /* determine the value of the extent flag */
4927 xflag = abnr ? XAD_NOTRECORDED : 0;
4929 @@ -164,6 +173,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
4932 dbFree(ip, nxaddr, nxlen);
4933 + DLIMIT_FREE_BLOCK(ip, nxlen);
4934 DQUOT_FREE_BLOCK(ip, nxlen);
4935 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4937 @@ -261,6 +271,13 @@ int extRealloc(struct inode *ip, s64 nxl
4938 mutex_unlock(&JFS_IP(ip)->commit_mutex);
4941 + /* Allocate blocks to dlimit. */
4942 + if (DLIMIT_ALLOC_BLOCK(ip, nxlen)) {
4943 + DQUOT_FREE_BLOCK(ip, nxlen);
4944 + dbFree(ip, nxaddr, (s64) nxlen);
4945 + up(&JFS_IP(ip)->commit_sem);
4949 delta = nxlen - xlen;
4951 @@ -297,6 +314,7 @@ int extRealloc(struct inode *ip, s64 nxl
4952 /* extend the extent */
4953 if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
4954 dbFree(ip, xaddr + xlen, delta);
4955 + DLIMIT_FREE_BLOCK(ip, nxlen);
4956 DQUOT_FREE_BLOCK(ip, nxlen);
4959 @@ -308,6 +326,7 @@ int extRealloc(struct inode *ip, s64 nxl
4961 if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
4962 dbFree(ip, nxaddr, nxlen);
4963 + DLIMIT_FREE_BLOCK(ip, nxlen);
4964 DQUOT_FREE_BLOCK(ip, nxlen);
4967 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/jfs_filsys.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_filsys.h
4968 --- linux-2.6.24-rc7/fs/jfs/jfs_filsys.h 2007-11-29 01:01:54 +0100
4969 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_filsys.h 2007-12-13 13:25:40 +0100
4971 #define JFS_NAME_MAX 255
4972 #define JFS_PATH_MAX BPSIZE
4974 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4977 * file system state (superblock state)
4978 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/jfs_imap.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_imap.c
4979 --- linux-2.6.24-rc7/fs/jfs/jfs_imap.c 2007-11-29 01:01:54 +0100
4980 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_imap.c 2007-12-13 13:25:40 +0100
4982 #include <linux/buffer_head.h>
4983 #include <linux/pagemap.h>
4984 #include <linux/quotaops.h>
4985 +#include <linux/vs_tag.h>
4987 #include "jfs_incore.h"
4988 #include "jfs_inode.h"
4989 @@ -3061,6 +3062,8 @@ static int copy_from_dinode(struct dinod
4991 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4992 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4996 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4997 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4998 @@ -3081,14 +3084,18 @@ static int copy_from_dinode(struct dinod
5000 ip->i_nlink = le32_to_cpu(dip->di_nlink);
5002 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
5003 + uid = le32_to_cpu(dip->di_uid);
5004 + gid = le32_to_cpu(dip->di_gid);
5005 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
5007 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
5009 ip->i_uid = jfs_ip->saved_uid;
5011 ip->i_uid = sbi->uid;
5014 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
5015 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
5017 ip->i_gid = jfs_ip->saved_gid;
5019 @@ -3153,14 +3160,12 @@ static void copy_to_dinode(struct dinode
5020 dip->di_size = cpu_to_le64(ip->i_size);
5021 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
5022 dip->di_nlink = cpu_to_le32(ip->i_nlink);
5023 - if (sbi->uid == -1)
5024 - dip->di_uid = cpu_to_le32(ip->i_uid);
5026 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
5027 - if (sbi->gid == -1)
5028 - dip->di_gid = cpu_to_le32(ip->i_gid);
5030 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
5032 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
5033 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
5034 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
5035 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
5037 jfs_get_inode_flags(jfs_ip);
5039 * mode2 is only needed for storing the higher order bits.
5040 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/jfs_inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_inode.c
5041 --- linux-2.6.24-rc7/fs/jfs/jfs_inode.c 2007-07-09 13:19:27 +0200
5042 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_inode.c 2007-12-13 13:25:46 +0100
5045 #include <linux/fs.h>
5046 #include <linux/quotaops.h>
5047 +#include <linux/vs_dlimit.h>
5048 +#include <linux/vs_tag.h>
5049 #include "jfs_incore.h"
5050 #include "jfs_inode.h"
5051 #include "jfs_filsys.h"
5052 @@ -30,19 +32,47 @@ void jfs_set_inode_flags(struct inode *i
5054 unsigned int flags = JFS_IP(inode)->mode2;
5056 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
5057 - S_NOATIME | S_DIRSYNC | S_SYNC);
5058 + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER |
5059 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5061 if (flags & JFS_IMMUTABLE_FL)
5062 inode->i_flags |= S_IMMUTABLE;
5063 + if (flags & JFS_IUNLINK_FL)
5064 + inode->i_flags |= S_IUNLINK;
5065 + if (flags & JFS_BARRIER_FL)
5066 + inode->i_flags |= S_BARRIER;
5068 + if (flags & JFS_SYNC_FL)
5069 + inode->i_flags |= S_SYNC;
5070 if (flags & JFS_APPEND_FL)
5071 inode->i_flags |= S_APPEND;
5072 if (flags & JFS_NOATIME_FL)
5073 inode->i_flags |= S_NOATIME;
5074 if (flags & JFS_DIRSYNC_FL)
5075 inode->i_flags |= S_DIRSYNC;
5076 - if (flags & JFS_SYNC_FL)
5077 - inode->i_flags |= S_SYNC;
5080 +int jfs_sync_flags(struct inode *inode)
5082 + unsigned int oldflags, newflags;
5084 + oldflags = JFS_IP(inode)->mode2;
5085 + newflags = oldflags & ~(JFS_IMMUTABLE_FL |
5086 + JFS_IUNLINK_FL | JFS_BARRIER_FL);
5088 + if (IS_IMMUTABLE(inode))
5089 + newflags |= JFS_IMMUTABLE_FL;
5090 + if (IS_IUNLINK(inode))
5091 + newflags |= JFS_IUNLINK_FL;
5092 + if (IS_BARRIER(inode))
5093 + newflags |= JFS_BARRIER_FL;
5095 + if (oldflags ^ newflags) {
5096 + JFS_IP(inode)->mode2 = newflags;
5097 + inode->i_ctime = CURRENT_TIME;
5098 + mark_inode_dirty(inode);
5103 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
5104 @@ -108,10 +138,17 @@ struct inode *ialloc(struct inode *paren
5105 jfs_inode->saved_uid = inode->i_uid;
5106 jfs_inode->saved_gid = inode->i_gid;
5108 + inode->i_tag = dx_current_fstag(sb);
5109 + if (DLIMIT_ALLOC_INODE(inode)) {
5111 + return ERR_PTR(-ENOSPC);
5115 * Allocate inode to quota.
5117 if (DQUOT_ALLOC_INODE(inode)) {
5118 + DLIMIT_FREE_INODE(inode);
5120 inode->i_flags |= S_NOQUOTA;
5122 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/jfs_inode.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_inode.h
5123 --- linux-2.6.24-rc7/fs/jfs/jfs_inode.h 2007-11-29 01:11:53 +0100
5124 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_inode.h 2007-12-13 13:25:39 +0100
5125 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
5126 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
5127 int fh_len, int fh_type);
5128 extern void jfs_set_inode_flags(struct inode *);
5129 +extern int jfs_sync_flags(struct inode *);
5130 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
5132 extern const struct address_space_operations jfs_aops;
5133 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/jfs_xtree.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_xtree.c
5134 --- linux-2.6.24-rc7/fs/jfs/jfs_xtree.c 2007-11-29 01:01:54 +0100
5135 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/jfs_xtree.c 2007-12-13 13:25:46 +0100
5138 #include <linux/fs.h>
5139 #include <linux/quotaops.h>
5140 +#include <linux/vs_dlimit.h>
5141 #include "jfs_incore.h"
5142 #include "jfs_filsys.h"
5143 #include "jfs_metapage.h"
5144 @@ -846,7 +847,12 @@ int xtInsert(tid_t tid, /* transaction
5146 if ((rc = DQUOT_ALLOC_BLOCK(ip, xlen)))
5148 + if ((rc = DLIMIT_ALLOC_BLOCK(ip, xlen))) {
5149 + DQUOT_FREE_BLOCK(ip, xlen);
5152 if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
5153 + DLIMIT_FREE_BLOCK(ip, xlen);
5154 DQUOT_FREE_BLOCK(ip, xlen);
5157 @@ -876,6 +882,7 @@ int xtInsert(tid_t tid, /* transaction
5158 /* undo data extent allocation */
5160 dbFree(ip, xaddr, (s64) xlen);
5161 + DLIMIT_FREE_BLOCK(ip, xlen);
5162 DQUOT_FREE_BLOCK(ip, xlen);
5165 @@ -1236,6 +1243,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
5167 struct xtlock *sxtlck = NULL, *rxtlck = NULL;
5168 int quota_allocation = 0;
5169 + int dlimit_allocation = 0;
5172 sp = XT_PAGE(ip, smp);
5173 @@ -1255,6 +1263,13 @@ xtSplitPage(tid_t tid, struct inode *ip,
5175 quota_allocation += lengthPXD(pxd);
5177 + /* Allocate blocks to dlimit. */
5178 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5182 + dlimit_allocation += lengthPXD(pxd);
5185 * allocate the new right page for the split
5187 @@ -1456,6 +1471,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
5191 + /* Rollback dlimit allocation. */
5192 + if (dlimit_allocation)
5193 + DLIMIT_FREE_BLOCK(ip, dlimit_allocation);
5194 /* Rollback quota allocation. */
5195 if (quota_allocation)
5196 DQUOT_FREE_BLOCK(ip, quota_allocation);
5197 @@ -1519,6 +1537,12 @@ xtSplitRoot(tid_t tid,
5198 release_metapage(rmp);
5201 + /* Allocate blocks to dlimit. */
5202 + if (DLIMIT_ALLOC_BLOCK(ip, lengthPXD(pxd))) {
5203 + DQUOT_FREE_BLOCK(ip, lengthPXD(pxd));
5204 + release_metapage(rmp);
5208 jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
5210 @@ -3948,6 +3972,8 @@ s64 xtTruncate(tid_t tid, struct inode *
5212 ip->i_size = newsize;
5214 + /* update dlimit allocation to reflect freed blocks */
5215 + DLIMIT_FREE_BLOCK(ip, nfreed);
5216 /* update quota allocation to reflect freed blocks */
5217 DQUOT_FREE_BLOCK(ip, nfreed);
5219 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/namei.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/namei.c
5220 --- linux-2.6.24-rc7/fs/jfs/namei.c 2007-11-29 01:11:53 +0100
5221 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/namei.c 2007-12-13 13:25:41 +0100
5223 #include <linux/ctype.h>
5224 #include <linux/quotaops.h>
5225 #include <linux/exportfs.h>
5226 +#include <linux/vs_tag.h>
5227 #include "jfs_incore.h"
5228 #include "jfs_superblock.h"
5229 #include "jfs_inode.h"
5230 @@ -1470,6 +1471,7 @@ static struct dentry *jfs_lookup(struct
5231 return ERR_PTR(-EACCES);
5234 + dx_propagate_tag(nd, ip);
5235 dentry = d_splice_alias(ip, dentry);
5237 if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
5238 @@ -1556,6 +1558,7 @@ const struct inode_operations jfs_dir_in
5239 .setattr = jfs_setattr,
5240 .permission = jfs_permission,
5242 + .sync_flags = jfs_sync_flags,
5245 const struct file_operations jfs_dir_operations = {
5246 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/super.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/super.c
5247 --- linux-2.6.24-rc7/fs/jfs/super.c 2007-11-29 01:11:53 +0100
5248 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/super.c 2007-12-13 13:25:38 +0100
5249 @@ -195,7 +195,8 @@ static void jfs_put_super(struct super_b
5251 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
5252 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
5253 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
5254 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
5255 + Opt_tag, Opt_notag, Opt_tagid
5258 static match_table_t tokens = {
5259 @@ -205,6 +206,10 @@ static match_table_t tokens = {
5260 {Opt_resize, "resize=%u"},
5261 {Opt_resize_nosize, "resize"},
5262 {Opt_errors, "errors=%s"},
5264 + {Opt_notag, "notag"},
5265 + {Opt_tagid, "tagid=%u"},
5266 + {Opt_tag, "tagxid"},
5267 {Opt_ignore, "noquota"},
5268 {Opt_ignore, "quota"},
5269 {Opt_usrquota, "usrquota"},
5270 @@ -339,6 +344,20 @@ static int parse_options(char *options,
5274 +#ifndef CONFIG_TAGGING_NONE
5276 + *flag |= JFS_TAGGED;
5279 + *flag &= JFS_TAGGED;
5282 +#ifdef CONFIG_PROPAGATE
5285 + *flag |= JFS_TAGGED;
5289 printk("jfs: Unrecognized mount option \"%s\" "
5290 " or missing value\n", p);
5291 @@ -369,6 +388,13 @@ static int jfs_remount(struct super_bloc
5292 if (!parse_options(data, sb, &newLVSize, &flag)) {
5296 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
5297 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
5303 if (sb->s_flags & MS_RDONLY) {
5305 @@ -440,6 +466,9 @@ static int jfs_fill_super(struct super_b
5306 #ifdef CONFIG_JFS_POSIX_ACL
5307 sb->s_flags |= MS_POSIXACL;
5309 + /* map mount option tagxid */
5310 + if (sbi->flag & JFS_TAGGED)
5311 + sb->s_flags |= MS_TAGGED;
5314 printk(KERN_ERR "resize option for remount only\n");
5315 diff -NurpP --minimal linux-2.6.24-rc7/fs/jfs/xattr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/xattr.c
5316 --- linux-2.6.24-rc7/fs/jfs/xattr.c 2007-11-29 01:01:54 +0100
5317 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/jfs/xattr.c 2007-12-13 13:25:46 +0100
5319 #include <linux/posix_acl_xattr.h>
5320 #include <linux/quotaops.h>
5321 #include <linux/security.h>
5322 +#include <linux/vs_dlimit.h>
5323 #include "jfs_incore.h"
5324 #include "jfs_superblock.h"
5325 #include "jfs_dmap.h"
5326 @@ -263,9 +264,16 @@ static int ea_write(struct inode *ip, st
5327 if (DQUOT_ALLOC_BLOCK(ip, nblocks)) {
5330 + /* Allocate new blocks to dlimit. */
5331 + if (DLIMIT_ALLOC_BLOCK(ip, nblocks)) {
5332 + DQUOT_FREE_BLOCK(ip, nblocks);
5336 rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
5338 + /*Rollback dlimit allocation. */
5339 + DLIMIT_FREE_BLOCK(ip, nblocks);
5340 /*Rollback quota allocation. */
5341 DQUOT_FREE_BLOCK(ip, nblocks);
5343 @@ -332,6 +340,8 @@ static int ea_write(struct inode *ip, st
5346 /* Rollback quota allocation. */
5347 + DLIMIT_FREE_BLOCK(ip, nblocks);
5348 + /* Rollback quota allocation. */
5349 DQUOT_FREE_BLOCK(ip, nblocks);
5351 dbFree(ip, blkno, nblocks);
5352 @@ -468,6 +478,7 @@ static int ea_get(struct inode *inode, s
5355 int quota_allocation = 0;
5356 + int dlimit_allocation = 0;
5358 /* When fsck.jfs clears a bad ea, it doesn't clear the size */
5359 if (ji->ea.flag == 0)
5360 @@ -543,6 +554,12 @@ static int ea_get(struct inode *inode, s
5362 quota_allocation = blocks_needed;
5364 + /* Allocate new blocks to dlimit. */
5366 + if (DLIMIT_ALLOC_BLOCK(inode, blocks_needed))
5368 + dlimit_allocation = blocks_needed;
5370 rc = dbAlloc(inode, INOHINT(inode), (s64) blocks_needed,
5373 @@ -600,6 +617,9 @@ static int ea_get(struct inode *inode, s
5377 + /* Rollback dlimit allocation */
5378 + if (dlimit_allocation)
5379 + DLIMIT_FREE_BLOCK(inode, dlimit_allocation);
5380 /* Rollback quota allocation */
5381 if (quota_allocation)
5382 DQUOT_FREE_BLOCK(inode, quota_allocation);
5383 @@ -676,8 +696,10 @@ static int ea_put(tid_t tid, struct inod
5386 /* If old blocks exist, they must be removed from quota allocation. */
5389 + DLIMIT_FREE_BLOCK(inode, old_blocks);
5390 DQUOT_FREE_BLOCK(inode, old_blocks);
5393 inode->i_ctime = CURRENT_TIME;
5395 diff -NurpP --minimal linux-2.6.24-rc7/fs/libfs.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/libfs.c
5396 --- linux-2.6.24-rc7/fs/libfs.c 2007-11-29 01:11:53 +0100
5397 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/libfs.c 2007-12-13 13:25:51 +0100
5398 @@ -125,7 +125,8 @@ static inline unsigned char dt_type(stru
5399 * both impossible due to the lock on directory.
5402 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
5403 +static inline int do_dcache_readdir_filter(struct file *filp,
5404 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
5406 struct dentry *dentry = filp->f_path.dentry;
5407 struct dentry *cursor = filp->private_data;
5408 @@ -158,6 +159,8 @@ int dcache_readdir(struct file * filp, v
5409 next = list_entry(p, struct dentry, d_u.d_child);
5410 if (d_unhashed(next) || !next->d_inode)
5412 + if (filter && !filter(next))
5415 spin_unlock(&dcache_lock);
5416 if (filldir(dirent, next->d_name.name,
5417 @@ -176,6 +179,18 @@ int dcache_readdir(struct file * filp, v
5421 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
5423 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
5426 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
5427 + int (*filter)(struct dentry *))
5429 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
5433 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
5436 @@ -770,6 +785,7 @@ EXPORT_SYMBOL(dcache_dir_close);
5437 EXPORT_SYMBOL(dcache_dir_lseek);
5438 EXPORT_SYMBOL(dcache_dir_open);
5439 EXPORT_SYMBOL(dcache_readdir);
5440 +EXPORT_SYMBOL(dcache_readdir_filter);
5441 EXPORT_SYMBOL(generic_read_dir);
5442 EXPORT_SYMBOL(get_sb_pseudo);
5443 EXPORT_SYMBOL(simple_write_begin);
5444 diff -NurpP --minimal linux-2.6.24-rc7/fs/locks.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/locks.c
5445 --- linux-2.6.24-rc7/fs/locks.c 2007-11-29 01:11:53 +0100
5446 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/locks.c 2007-12-13 13:25:49 +0100
5448 #include <linux/syscalls.h>
5449 #include <linux/time.h>
5450 #include <linux/rcupdate.h>
5451 +#include <linux/vs_base.h>
5452 +#include <linux/vs_limit.h>
5454 #include <asm/semaphore.h>
5455 #include <asm/uaccess.h>
5456 @@ -147,6 +149,8 @@ static struct kmem_cache *filelock_cache
5457 /* Allocate an empty lock structure. */
5458 static struct file_lock *locks_alloc_lock(void)
5460 + if (!vx_locks_avail(1))
5462 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
5465 @@ -172,6 +176,7 @@ static void locks_free_lock(struct file_
5466 BUG_ON(!list_empty(&fl->fl_block));
5467 BUG_ON(!list_empty(&fl->fl_link));
5470 locks_release_private(fl);
5471 kmem_cache_free(filelock_cache, fl);
5473 @@ -191,6 +196,7 @@ void locks_init_lock(struct file_lock *f
5474 fl->fl_start = fl->fl_end = 0;
5476 fl->fl_lmops = NULL;
5480 EXPORT_SYMBOL(locks_init_lock);
5481 @@ -244,6 +250,7 @@ void locks_copy_lock(struct file_lock *n
5482 new->fl_file = fl->fl_file;
5483 new->fl_ops = fl->fl_ops;
5484 new->fl_lmops = fl->fl_lmops;
5485 + new->fl_xid = fl->fl_xid;
5487 locks_copy_private(new, fl);
5489 @@ -282,6 +289,11 @@ static int flock_make_lock(struct file *
5490 fl->fl_flags = FL_FLOCK;
5492 fl->fl_end = OFFSET_MAX;
5494 + vxd_assert(filp->f_xid == vx_current_xid(),
5495 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5496 + fl->fl_xid = filp->f_xid;
5501 @@ -447,6 +459,7 @@ static int lease_init(struct file *filp,
5503 fl->fl_owner = current->files;
5504 fl->fl_pid = current->tgid;
5505 + fl->fl_xid = vx_current_xid();
5508 fl->fl_flags = FL_LEASE;
5509 @@ -466,6 +479,11 @@ static struct file_lock *lease_alloc(str
5511 return ERR_PTR(error);
5513 + fl->fl_xid = vx_current_xid();
5515 + vxd_assert(filp->f_xid == fl->fl_xid,
5516 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
5518 error = lease_init(filp, type, fl);
5520 locks_free_lock(fl);
5521 @@ -781,6 +799,7 @@ static int flock_lock_file(struct file *
5525 + new_fl->fl_xid = -1;
5527 for_each_lock(inode, before) {
5528 struct file_lock *fl = *before;
5529 @@ -799,6 +818,7 @@ find_conflict:
5531 locks_copy_lock(new_fl, request);
5532 locks_insert_lock(before, new_fl);
5533 + vx_locks_inc(new_fl);
5537 @@ -809,7 +829,8 @@ out:
5541 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
5542 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
5543 + struct file_lock *conflock, xid_t xid)
5545 struct file_lock *fl;
5546 struct file_lock *new_fl = NULL;
5547 @@ -819,6 +840,8 @@ static int __posix_lock_file(struct inod
5548 struct file_lock **before;
5549 int error, added = 0;
5551 + vxd_assert(xid == vx_current_xid(),
5552 + "xid(%d) == current(%d)", xid, vx_current_xid());
5554 * We may need two file_lock structures for this operation,
5555 * so we get them in advance to avoid races.
5556 @@ -829,7 +852,11 @@ static int __posix_lock_file(struct inod
5557 (request->fl_type != F_UNLCK ||
5558 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
5559 new_fl = locks_alloc_lock();
5560 + new_fl->fl_xid = xid;
5561 + vx_locks_inc(new_fl);
5562 new_fl2 = locks_alloc_lock();
5563 + new_fl2->fl_xid = xid;
5564 + vx_locks_inc(new_fl2);
5568 @@ -1028,7 +1055,8 @@ static int __posix_lock_file(struct inod
5569 int posix_lock_file(struct file *filp, struct file_lock *fl,
5570 struct file_lock *conflock)
5572 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
5573 + return __posix_lock_file(filp->f_path.dentry->d_inode,
5574 + fl, conflock, filp->f_xid);
5576 EXPORT_SYMBOL(posix_lock_file);
5578 @@ -1118,7 +1146,7 @@ int locks_mandatory_area(int read_write,
5579 fl.fl_end = offset + count - 1;
5582 - error = __posix_lock_file(inode, &fl, NULL);
5583 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
5584 if (error != -EAGAIN)
5586 if (!(fl.fl_flags & FL_SLEEP))
5587 @@ -1429,6 +1457,7 @@ int generic_setlease(struct file *filp,
5589 locks_copy_lock(new_fl, lease);
5590 locks_insert_lock(before, new_fl);
5595 @@ -1759,6 +1788,11 @@ int fcntl_setlk(unsigned int fd, struct
5596 if (file_lock == NULL)
5599 + vxd_assert(filp->f_xid == vx_current_xid(),
5600 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5601 + file_lock->fl_xid = filp->f_xid;
5602 + vx_locks_inc(file_lock);
5605 * This might block, so we do it before checking the inode.
5607 @@ -1883,6 +1917,11 @@ int fcntl_setlk64(unsigned int fd, struc
5608 if (file_lock == NULL)
5611 + vxd_assert(filp->f_xid == vx_current_xid(),
5612 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5613 + file_lock->fl_xid = filp->f_xid;
5614 + vx_locks_inc(file_lock);
5617 * This might block, so we do it before checking the inode.
5619 @@ -2153,8 +2192,11 @@ static int locks_show(struct seq_file *f
5621 lock_get_status(f, fl, (long)f->private, "");
5623 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
5624 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
5625 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
5627 lock_get_status(f, bfl, (long)f->private, " ->");
5632 diff -NurpP --minimal linux-2.6.24-rc7/fs/namei.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/namei.c
5633 --- linux-2.6.24-rc7/fs/namei.c 2007-11-29 01:11:53 +0100
5634 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/namei.c 2007-12-13 13:25:49 +0100
5636 #include <linux/capability.h>
5637 #include <linux/file.h>
5638 #include <linux/fcntl.h>
5639 +#include <linux/proc_fs.h>
5640 +#include <linux/vserver/inode.h>
5641 +#include <linux/vs_base.h>
5642 +#include <linux/vs_tag.h>
5643 +#include <linux/vs_cowbl.h>
5644 +#include <linux/vs_context.h>
5645 #include <asm/namei.h>
5646 #include <asm/uaccess.h>
5648 @@ -225,6 +231,29 @@ int generic_permission(struct inode *ino
5652 +static inline int dx_barrier(struct inode *inode)
5654 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN)) {
5655 + vxwprintk_task(1, "did hit the barrier.");
5661 +static inline int dx_permission(struct inode *inode, int mask, struct nameidata *nd)
5663 + if (dx_barrier(inode))
5665 + if (inode->i_tag == 0)
5667 + if (dx_check(inode->i_tag, DX_ADMIN|DX_WATCH|DX_IDENT))
5670 + vxwprintk_task(1, "denied access to %p[#%d,%lu] »%s«.",
5671 + inode, inode->i_tag, inode->i_ino, vxd_cond_path(nd));
5675 int permission(struct inode *inode, int mask, struct nameidata *nd)
5677 int retval, submask;
5678 @@ -239,14 +268,14 @@ int permission(struct inode *inode, int
5680 * Nobody gets write access to a read-only fs.
5682 - if (IS_RDONLY(inode) &&
5683 + if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
5684 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
5688 * Nobody gets write access to an immutable file.
5690 - if (IS_IMMUTABLE(inode))
5691 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
5695 @@ -261,6 +290,8 @@ int permission(struct inode *inode, int
5697 /* Ordinary permission routines do not understand MAY_APPEND. */
5698 submask = mask & ~MAY_APPEND;
5699 + if ((retval = dx_permission(inode, mask, nd)))
5701 if (inode->i_op && inode->i_op->permission) {
5702 retval = inode->i_op->permission(inode, submask, nd);
5704 @@ -449,6 +480,8 @@ static int exec_permission_lite(struct i
5706 umode_t mode = inode->i_mode;
5708 + if (dx_barrier(inode))
5710 if (inode->i_op && inode->i_op->permission)
5713 @@ -749,7 +782,8 @@ static __always_inline void follow_dotdo
5714 if (nd->dentry == fs->root &&
5715 nd->mnt == fs->rootmnt) {
5716 read_unlock(&fs->lock);
5718 + /* for sane '/' avoid follow_mount() */
5721 read_unlock(&fs->lock);
5722 spin_lock(&dcache_lock);
5723 @@ -786,16 +820,33 @@ static int do_lookup(struct nameidata *n
5725 struct vfsmount *mnt = nd->mnt;
5726 struct dentry *dentry = __d_lookup(nd->dentry, name);
5727 + struct inode *inode;
5731 if (dentry->d_op && dentry->d_op->d_revalidate)
5732 goto need_revalidate;
5733 + inode = dentry->d_inode;
5736 + if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
5737 + struct proc_dir_entry *de = PDE(inode);
5739 + if (de && !vx_hide_check(0, de->vx_flags))
5742 + if (!dx_check(inode->i_tag, DX_WATCH|DX_ADMIN|DX_HOSTID|DX_IDENT))
5746 path->dentry = dentry;
5747 __follow_mount(path);
5750 + vxwprintk_task(1, "did lookup hidden %p[#%d,%lu] »%s«.",
5751 + inode, inode->i_tag, inode->i_ino, vxd_path(dentry, mnt));
5756 dentry = real_lookup(nd->dentry, name, nd);
5757 @@ -1461,7 +1512,8 @@ static inline int check_sticky(struct in
5758 * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
5759 * nfs_async_unlink().
5761 -static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
5762 +static int may_delete(struct inode *dir, struct dentry *victim,
5763 + int isdir, struct nameidata *nd)
5767 @@ -1471,13 +1523,13 @@ static int may_delete(struct inode *dir,
5768 BUG_ON(victim->d_parent->d_inode != dir);
5769 audit_inode_child(victim->d_name.name, victim, dir);
5771 - error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
5772 + error = permission(dir,MAY_WRITE | MAY_EXEC, nd);
5777 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
5778 - IS_IMMUTABLE(victim->d_inode))
5779 + IS_IXORUNLINK(victim->d_inode))
5782 if (!S_ISDIR(victim->d_inode->i_mode))
5783 @@ -1623,6 +1675,14 @@ int may_open(struct nameidata *nd, int a
5784 } else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
5787 +#ifdef CONFIG_VSERVER_COWBL
5788 + if (IS_COW(inode) && (flag & FMODE_WRITE)) {
5789 + if (IS_COW_LINK(inode))
5791 + inode->i_flags &= ~(S_IUNLINK|S_IMMUTABLE);
5792 + mark_inode_dirty(inode);
5795 error = vfs_permission(nd, acc_mode);
5798 @@ -1714,6 +1774,11 @@ int open_namei(int dfd, const char *path
5802 +#ifdef CONFIG_VSERVER_COWBL
5807 acc_mode = ACC_MODE(flag);
5809 /* O_TRUNC implies we need access checks for write permissions */
5810 @@ -1807,6 +1872,22 @@ do_last:
5813 error = may_open(nd, acc_mode, flag);
5814 +#ifdef CONFIG_VSERVER_COWBL
5815 + if (error == -EMLINK) {
5816 + struct dentry *dentry;
5817 + dentry = cow_break_link(pathname);
5818 + if (IS_ERR(dentry)) {
5819 + error = PTR_ERR(dentry);
5823 + release_open_intent(nd);
5833 @@ -1918,9 +1999,10 @@ fail:
5835 EXPORT_SYMBOL_GPL(lookup_create);
5837 -int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
5838 +int vfs_mknod(struct inode *dir, struct dentry *dentry,
5839 + int mode, dev_t dev, struct nameidata *nd)
5841 - int error = may_create(dir, dentry, NULL);
5842 + int error = may_create(dir, dentry, nd);
5846 @@ -1970,11 +2052,12 @@ asmlinkage long sys_mknodat(int dfd, con
5847 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
5849 case S_IFCHR: case S_IFBLK:
5850 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
5851 - new_decode_dev(dev));
5852 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
5853 + new_decode_dev(dev), &nd);
5855 case S_IFIFO: case S_IFSOCK:
5856 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
5857 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
5862 @@ -1997,9 +2080,10 @@ asmlinkage long sys_mknod(const char __u
5863 return sys_mknodat(AT_FDCWD, filename, mode, dev);
5866 -int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
5867 +int vfs_mkdir(struct inode *dir, struct dentry *dentry,
5868 + int mode, struct nameidata *nd)
5870 - int error = may_create(dir, dentry, NULL);
5871 + int error = may_create(dir, dentry, nd);
5875 @@ -2041,7 +2125,7 @@ asmlinkage long sys_mkdirat(int dfd, con
5877 if (!IS_POSIXACL(nd.dentry->d_inode))
5878 mode &= ~current->fs->umask;
5879 - error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
5880 + error = vfs_mkdir(nd.dentry->d_inode, dentry, mode, &nd);
5883 mutex_unlock(&nd.dentry->d_inode->i_mutex);
5884 @@ -2084,9 +2168,10 @@ void dentry_unhash(struct dentry *dentry
5885 spin_unlock(&dcache_lock);
5888 -int vfs_rmdir(struct inode *dir, struct dentry *dentry)
5889 +int vfs_rmdir(struct inode *dir, struct dentry *dentry,
5890 + struct nameidata *nd)
5892 - int error = may_delete(dir, dentry, 1);
5893 + int error = may_delete(dir, dentry, 1, nd);
5897 @@ -2148,7 +2233,7 @@ static long do_rmdir(int dfd, const char
5898 error = PTR_ERR(dentry);
5901 - error = vfs_rmdir(nd.dentry->d_inode, dentry);
5902 + error = vfs_rmdir(nd.dentry->d_inode, dentry, &nd);
5905 mutex_unlock(&nd.dentry->d_inode->i_mutex);
5906 @@ -2164,9 +2249,10 @@ asmlinkage long sys_rmdir(const char __u
5907 return do_rmdir(AT_FDCWD, pathname);
5910 -int vfs_unlink(struct inode *dir, struct dentry *dentry)
5911 +int vfs_unlink(struct inode *dir, struct dentry *dentry,
5912 + struct nameidata *nd)
5914 - int error = may_delete(dir, dentry, 0);
5915 + int error = may_delete(dir, dentry, 0, nd);
5919 @@ -2228,7 +2314,7 @@ static long do_unlinkat(int dfd, const c
5920 inode = dentry->d_inode;
5922 atomic_inc(&inode->i_count);
5923 - error = vfs_unlink(nd.dentry->d_inode, dentry);
5924 + error = vfs_unlink(nd.dentry->d_inode, dentry, &nd);
5928 @@ -2263,9 +2349,10 @@ asmlinkage long sys_unlink(const char __
5929 return do_unlinkat(AT_FDCWD, pathname);
5932 -int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode)
5933 +int vfs_symlink(struct inode *dir, struct dentry *dentry,
5934 + const char *oldname, int mode, struct nameidata *nd)
5936 - int error = may_create(dir, dentry, NULL);
5937 + int error = may_create(dir, dentry, nd);
5941 @@ -2309,7 +2396,7 @@ asmlinkage long sys_symlinkat(const char
5945 - error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
5946 + error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO, &nd);
5949 mutex_unlock(&nd.dentry->d_inode->i_mutex);
5950 @@ -2326,7 +2413,8 @@ asmlinkage long sys_symlink(const char _
5951 return sys_symlinkat(oldname, AT_FDCWD, newname);
5954 -int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
5955 +int vfs_link(struct dentry *old_dentry, struct inode *dir,
5956 + struct dentry *new_dentry, struct nameidata *nd)
5958 struct inode *inode = old_dentry->d_inode;
5960 @@ -2334,7 +2422,7 @@ int vfs_link(struct dentry *old_dentry,
5964 - error = may_create(dir, new_dentry, NULL);
5965 + error = may_create(dir, new_dentry, nd);
5969 @@ -2344,7 +2432,7 @@ int vfs_link(struct dentry *old_dentry,
5971 * A link to an append-only or immutable file cannot be created.
5973 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5974 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5976 if (!dir->i_op || !dir->i_op->link)
5978 @@ -2404,7 +2492,7 @@ asmlinkage long sys_linkat(int olddfd, c
5979 error = PTR_ERR(new_dentry);
5980 if (IS_ERR(new_dentry))
5982 - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
5983 + error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry, &nd);
5986 mutex_unlock(&nd.dentry->d_inode->i_mutex);
5987 @@ -2536,14 +2624,14 @@ int vfs_rename(struct inode *old_dir, st
5988 if (old_dentry->d_inode == new_dentry->d_inode)
5991 - error = may_delete(old_dir, old_dentry, is_dir);
5992 + error = may_delete(old_dir, old_dentry, is_dir, NULL);
5996 if (!new_dentry->d_inode)
5997 error = may_create(new_dir, new_dentry, NULL);
5999 - error = may_delete(new_dir, new_dentry, is_dir);
6000 + error = may_delete(new_dir, new_dentry, is_dir, NULL);
6004 @@ -2621,6 +2709,9 @@ static int do_rename(int olddfd, const c
6006 if (old_dentry == trap)
6009 + if (MNT_IS_RDONLY(newnd.mnt))
6011 new_dentry = lookup_hash(&newnd);
6012 error = PTR_ERR(new_dentry);
6013 if (IS_ERR(new_dentry))
6014 @@ -2714,6 +2805,217 @@ int vfs_follow_link(struct nameidata *nd
6015 return __vfs_follow_link(nd, link);
6019 +#ifdef CONFIG_VSERVER_COWBL
6021 +#include <linux/file.h>
6024 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6028 + return do_splice_direct(in, &ppos, out, len, 0);
6031 +struct dentry *cow_break_link(const char *pathname)
6033 + int ret, mode, pathlen, redo = 0;
6034 + struct nameidata old_nd, dir_nd;
6035 + struct dentry *old_dentry, *new_dentry;
6036 + struct dentry *dir, *res = NULL;
6037 + struct vfsmount *old_mnt, *new_mnt;
6038 + struct file *old_file;
6039 + struct file *new_file;
6040 + char *to, *path, pad='\251';
6041 + loff_t ppos, size;
6043 + vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6044 + path = kmalloc(PATH_MAX, GFP_KERNEL);
6049 + /* old_nd will have refs to dentry and mnt */
6050 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6051 + vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6053 + goto out_free_path;
6055 + old_dentry = old_nd.dentry;
6056 + old_mnt = old_nd.mnt;
6057 + mode = old_dentry->d_inode->i_mode;
6059 + to = d_path(old_dentry, old_mnt, path, PATH_MAX-2);
6060 + pathlen = strlen(to);
6061 + vxdprintk(VXD_CBIT(misc, 2), "old path »%s« [»%.*s«:%d]", to,
6062 + old_dentry->d_name.len, old_dentry->d_name.name,
6063 + old_dentry->d_name.len);
6065 + to[pathlen + 1] = 0;
6067 + to[pathlen] = pad--;
6069 + if (pad <= '\240')
6072 + vxdprintk(VXD_CBIT(misc, 1), "temp copy »%s«", to);
6073 + /* dir_nd will have refs to dentry and mnt */
6074 + ret = path_lookup(to,
6075 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6076 + vxdprintk(VXD_CBIT(misc, 2),
6077 + "path_lookup(new): %d", ret);
6081 + /* this puppy downs the inode mutex */
6082 + new_dentry = lookup_create(&dir_nd, 0);
6083 + vxdprintk(VXD_CBIT(misc, 2),
6084 + "lookup_create(new): %p [»%.*s«:%d]", new_dentry,
6085 + new_dentry->d_name.len, new_dentry->d_name.name,
6086 + new_dentry->d_name.len);
6087 + if (!new_dentry || IS_ERR(new_dentry)) {
6088 + path_release(&dir_nd);
6091 + dir = dir_nd.dentry;
6093 + ret = vfs_create(dir_nd.dentry->d_inode, new_dentry, mode, &dir_nd);
6094 + vxdprintk(VXD_CBIT(misc, 2),
6095 + "vfs_create(new): %d", ret);
6096 + if (ret == -EEXIST) {
6097 + mutex_unlock(&dir->d_inode->i_mutex);
6099 + path_release(&dir_nd);
6103 + goto out_unlock_new;
6105 + /* drop out early, ret passes ENOENT */
6107 + if ((redo = d_unhashed(old_dentry)))
6108 + goto out_unlock_new;
6110 + new_mnt = dir_nd.mnt;
6113 + /* this one cleans up the dentry/mnt in case of failure */
6114 + old_file = dentry_open(old_dentry, old_mnt, O_RDONLY);
6115 + vxdprintk(VXD_CBIT(misc, 2),
6116 + "dentry_open(old): %p", old_file);
6117 + if (!old_file || IS_ERR(old_file)) {
6118 + res = IS_ERR(old_file) ? (void *) old_file : res;
6119 + goto out_unlock_new;
6124 + /* this one cleans up the dentry/mnt in case of failure */
6125 + new_file = dentry_open(new_dentry, new_mnt, O_WRONLY);
6126 + vxdprintk(VXD_CBIT(misc, 2),
6127 + "dentry_open(new): %p", new_file);
6129 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
6130 + if (!new_file || IS_ERR(new_file))
6131 + goto out_fput_old;
6133 + size = i_size_read(old_file->f_dentry->d_inode);
6135 + ret = do_cow_splice(old_file, new_file, size);
6136 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
6138 + goto out_fput_both;
6139 + } else if (ret < size) {
6141 + goto out_fput_both;
6143 + struct inode *old_inode = old_dentry->d_inode;
6144 + struct inode *new_inode = new_dentry->d_inode;
6145 + struct iattr attr = {
6146 + .ia_uid = old_inode->i_uid,
6147 + .ia_gid = old_inode->i_gid,
6148 + .ia_valid = ATTR_UID | ATTR_GID
6151 + ret = inode_setattr(new_inode, &attr);
6153 + goto out_fput_both;
6156 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
6158 + /* drop out late */
6160 + if ((redo = d_unhashed(old_dentry)))
6163 + vxdprintk(VXD_CBIT(misc, 2),
6164 + "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
6165 + new_dentry->d_name.len, new_dentry->d_name.name,
6166 + new_dentry->d_name.len,
6167 + old_dentry->d_name.len, old_dentry->d_name.name,
6168 + old_dentry->d_name.len);
6169 + ret = vfs_rename(dir_nd.dentry->d_inode, new_dentry,
6170 + old_nd.dentry->d_parent->d_inode, old_dentry);
6171 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
6175 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
6178 + vxdprintk(VXD_CBIT(misc, 3),
6179 + "fput(new_file=%p[#%d])", new_file,
6180 + atomic_read(&new_file->f_count));
6184 + vxdprintk(VXD_CBIT(misc, 3),
6185 + "fput(old_file=%p[#%d])", old_file,
6186 + atomic_read(&old_file->f_count));
6190 + mutex_unlock(&dir->d_inode->i_mutex);
6194 + /* error path cleanup */
6195 + vfs_unlink(dir->d_inode, new_dentry, &dir_nd);
6200 + goto out_rel_both;
6201 + /* lookup dentry once again */
6202 + path_release(&old_nd);
6203 + ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6205 + goto out_rel_both;
6207 + new_dentry = old_nd.dentry;
6208 + vxdprintk(VXD_CBIT(misc, 2),
6209 + "path_lookup(redo): %p [»%.*s«:%d]", new_dentry,
6210 + new_dentry->d_name.len, new_dentry->d_name.name,
6211 + new_dentry->d_name.len);
6216 + path_release(&dir_nd);
6218 + path_release(&old_nd);
6223 + res = ERR_PTR(ret);
6229 /* get the link contents into pagecache */
6230 static char *page_getlink(struct dentry * dentry, struct page **ppage)
6232 diff -NurpP --minimal linux-2.6.24-rc7/fs/namespace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/namespace.c
6233 --- linux-2.6.24-rc7/fs/namespace.c 2007-11-29 01:11:53 +0100
6234 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/namespace.c 2007-12-13 13:25:48 +0100
6236 #include <linux/security.h>
6237 #include <linux/mount.h>
6238 #include <linux/ramfs.h>
6239 +#include <linux/vs_base.h>
6240 +#include <linux/vs_context.h>
6241 +#include <linux/vs_tag.h>
6242 +#include <linux/vserver/space.h>
6243 +#include <linux/vserver/global.h>
6244 #include <asm/uaccess.h>
6245 #include <asm/unistd.h>
6247 @@ -241,6 +246,7 @@ static struct vfsmount *clone_mnt(struct
6248 mnt->mnt_root = dget(root);
6249 mnt->mnt_mountpoint = mnt->mnt_root;
6250 mnt->mnt_parent = mnt;
6251 + mnt->mnt_tag = old->mnt_tag;
6253 if (flag & CL_SLAVE) {
6254 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
6255 @@ -343,48 +349,91 @@ static inline void mangle(struct seq_fil
6256 seq_escape(m, s, " \t\n\\");
6259 +static int mnt_is_reachable(struct vfsmount *mnt)
6261 + struct vfsmount *root_mnt;
6262 + struct dentry *root, *point;
6265 + if (mnt == mnt->mnt_ns->root)
6268 + spin_lock(&vfsmount_lock);
6269 + root_mnt = current->fs->rootmnt;
6270 + root = current->fs->root;
6273 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
6274 + point = mnt->mnt_mountpoint;
6275 + mnt = mnt->mnt_parent;
6278 + ret = (mnt == root_mnt) && is_subdir(point, root);
6280 + spin_unlock(&vfsmount_lock);
6285 static int show_vfsmnt(struct seq_file *m, void *v)
6287 struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
6289 static struct proc_fs_info {
6297 - { MS_SYNCHRONOUS, ",sync" },
6298 - { MS_DIRSYNC, ",dirsync" },
6299 - { MS_MANDLOCK, ",mand" },
6302 - static struct proc_fs_info mnt_info[] = {
6303 - { MNT_NOSUID, ",nosuid" },
6304 - { MNT_NODEV, ",nodev" },
6305 - { MNT_NOEXEC, ",noexec" },
6306 - { MNT_NOATIME, ",noatime" },
6307 - { MNT_NODIRATIME, ",nodiratime" },
6308 - { MNT_RELATIME, ",relatime" },
6310 + { MS_RDONLY, MNT_RDONLY, "ro", "rw" },
6311 + { MS_SYNCHRONOUS, 0, ",sync", NULL },
6312 + { MS_DIRSYNC, 0, ",dirsync", NULL },
6313 + { MS_MANDLOCK, 0, ",mand", NULL },
6314 + { MS_TAGGED, 0, ",tag", NULL },
6315 + { MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
6316 + { MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
6317 + { MS_RELATIME, MNT_RELATIME, ",relatime", NULL },
6318 + { 0, MNT_NOSUID, ",nosuid", NULL },
6319 + { 0, MNT_NODEV, ",nodev", NULL },
6320 + { 0, MNT_NOEXEC, ",noexec", NULL },
6321 + { 0, 0, NULL, NULL }
6323 - struct proc_fs_info *fs_infop;
6324 + struct proc_fs_info *p;
6325 + unsigned long s_flags = mnt->mnt_sb->s_flags;
6326 + int mnt_flags = mnt->mnt_flags;
6328 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6330 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
6332 - mangle(m, mnt->mnt_sb->s_type->name);
6333 - if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
6335 - mangle(m, mnt->mnt_sb->s_subtype);
6337 - seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
6338 - for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
6339 - if (mnt->mnt_sb->s_flags & fs_infop->flag)
6340 - seq_puts(m, fs_infop->str);
6341 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6343 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6346 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6347 + mnt == current->fs->rootmnt) {
6348 + seq_puts(m, "/dev/root / ");
6350 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6352 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
6355 + if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
6357 + mangle(m, mnt->mnt_sb->s_subtype);
6360 - for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
6361 - if (mnt->mnt_flags & fs_infop->flag)
6362 - seq_puts(m, fs_infop->str);
6363 + mangle(m, mnt->mnt_sb->s_type->name);
6365 + for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
6366 + if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
6368 + seq_puts(m, p->set_str);
6371 + seq_puts(m, p->unset_str);
6374 + if (mnt->mnt_flags & MNT_TAGID)
6375 + seq_printf(m, ",tag=%d", mnt->mnt_tag);
6376 if (mnt->mnt_sb->s_op->show_options)
6377 err = mnt->mnt_sb->s_op->show_options(m, mnt);
6378 seq_puts(m, " 0 0\n");
6379 @@ -403,17 +452,27 @@ static int show_vfsstat(struct seq_file
6380 struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
6384 - if (mnt->mnt_devname) {
6385 - seq_puts(m, "device ");
6386 - mangle(m, mnt->mnt_devname);
6388 - seq_puts(m, "no device");
6389 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6391 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6395 - seq_puts(m, " mounted on ");
6396 - seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
6398 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6399 + mnt == current->fs->rootmnt) {
6400 + seq_puts(m, "device /dev/root mounted on / ");
6403 + if (mnt->mnt_devname) {
6404 + seq_puts(m, "device ");
6405 + mangle(m, mnt->mnt_devname);
6407 + seq_puts(m, "no device");
6410 + seq_puts(m, " mounted on ");
6411 + seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
6415 /* file system type */
6416 seq_puts(m, "with fstype ");
6417 @@ -643,7 +702,7 @@ asmlinkage long sys_umount(char __user *
6421 - if (!capable(CAP_SYS_ADMIN))
6422 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6425 retval = do_umount(nd.mnt, flags);
6426 @@ -667,7 +726,7 @@ asmlinkage long sys_oldumount(char __use
6428 static int mount_is_safe(struct nameidata *nd)
6430 - if (capable(CAP_SYS_ADMIN))
6431 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6435 @@ -919,11 +978,13 @@ static int do_change_type(struct nameida
6437 * do loopback mount.
6439 -static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
6440 +static int do_loopback(struct nameidata *nd, char *old_name, tag_t tag,
6441 + unsigned long flags, int mnt_flags)
6443 struct nameidata old_nd;
6444 struct vfsmount *mnt = NULL;
6445 int err = mount_is_safe(nd);
6446 + int recurse = flags & MS_REC;
6449 if (!old_name || !*old_name)
6450 @@ -949,6 +1010,12 @@ static int do_loopback(struct nameidata
6454 + mnt->mnt_flags = mnt_flags;
6455 + if (flags & MS_TAGID) {
6456 + mnt->mnt_tag = tag;
6457 + mnt->mnt_flags |= MNT_TAGID;
6460 err = graft_tree(mnt, nd);
6462 LIST_HEAD(umount_list);
6463 @@ -957,6 +1024,7 @@ static int do_loopback(struct nameidata
6464 spin_unlock(&vfsmount_lock);
6465 release_mounts(&umount_list);
6467 + mnt->mnt_flags = mnt_flags;
6470 up_write(&namespace_sem);
6471 @@ -970,12 +1038,12 @@ out:
6472 * on it - tough luck.
6474 static int do_remount(struct nameidata *nd, int flags, int mnt_flags,
6476 + void *data, xid_t xid)
6479 struct super_block *sb = nd->mnt->mnt_sb;
6481 - if (!capable(CAP_SYS_ADMIN))
6482 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
6485 if (!check_mnt(nd->mnt))
6486 @@ -1009,7 +1077,7 @@ static int do_move_mount(struct nameidat
6487 struct nameidata old_nd, parent_nd;
6490 - if (!capable(CAP_SYS_ADMIN))
6491 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6493 if (!old_name || !*old_name)
6495 @@ -1089,7 +1157,7 @@ static int do_new_mount(struct nameidata
6498 /* we need capabilities... */
6499 - if (!capable(CAP_SYS_ADMIN))
6500 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6503 mnt = do_kern_mount(type, flags, name, data);
6504 @@ -1401,6 +1469,7 @@ long do_mount(char *dev_name, char *dir_
6505 struct nameidata nd;
6511 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
6512 @@ -1416,7 +1485,19 @@ long do_mount(char *dev_name, char *dir_
6514 ((char *)data_page)[PAGE_SIZE - 1] = 0;
6516 +#ifdef CONFIG_PROPAGATE
6517 + retval = dx_parse_tag(data_page, &tag, 1);
6519 + mnt_flags |= MNT_TAGID;
6520 + /* bind and re-mounts get the tag flag */
6521 + if (flags & (MS_BIND|MS_REMOUNT))
6522 + flags |= MS_TAGID;
6526 /* Separate the per-mountpoint flags */
6527 + if (flags & MS_RDONLY)
6528 + mnt_flags |= MNT_RDONLY;
6529 if (flags & MS_NOSUID)
6530 mnt_flags |= MNT_NOSUID;
6531 if (flags & MS_NODEV)
6532 @@ -1430,6 +1511,8 @@ long do_mount(char *dev_name, char *dir_
6533 if (flags & MS_RELATIME)
6534 mnt_flags |= MNT_RELATIME;
6536 + if (!capable(CAP_SYS_ADMIN))
6537 + mnt_flags |= MNT_NODEV;
6538 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
6539 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT);
6541 @@ -1444,9 +1527,9 @@ long do_mount(char *dev_name, char *dir_
6543 if (flags & MS_REMOUNT)
6544 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
6547 else if (flags & MS_BIND)
6548 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
6549 + retval = do_loopback(&nd, dev_name, tag, flags, mnt_flags);
6550 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
6551 retval = do_change_type(&nd, flags);
6552 else if (flags & MS_MOVE)
6553 @@ -1519,6 +1602,7 @@ static struct mnt_namespace *dup_mnt_ns(
6554 q = next_mnt(q, new_ns->root);
6556 up_write(&namespace_sem);
6557 + atomic_inc(&vs_global_mnt_ns);
6561 @@ -1881,5 +1965,6 @@ void __put_mnt_ns(struct mnt_namespace *
6562 spin_unlock(&vfsmount_lock);
6563 up_write(&namespace_sem);
6564 release_mounts(&umount_list);
6565 + atomic_dec(&vs_global_mnt_ns);
6568 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfs/client.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/client.c
6569 --- linux-2.6.24-rc7/fs/nfs/client.c 2007-12-31 17:58:26 +0100
6570 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/client.c 2007-12-31 12:34:39 +0100
6571 @@ -495,6 +495,9 @@ static int nfs_init_server_rpcclient(str
6572 if (server->flags & NFS4_MOUNT_INTR)
6573 server->client->cl_intr = 1;
6575 + server->client->cl_tag = 0;
6576 + if (server->flags & NFS_MOUNT_TAGGED)
6577 + server->client->cl_tag = 1;
6581 @@ -645,6 +648,10 @@ static void nfs_server_set_fsinfo(struct
6582 server->acdirmin = server->acdirmax = 0;
6585 + /* FIXME: needs fsinfo
6586 + if (server->flags & NFS_MOUNT_TAGGED)
6587 + sb->s_flags |= MS_TAGGED; */
6589 server->maxfilesize = fsinfo->maxfilesize;
6591 /* We're airborne Set socket buffersize */
6592 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfs/dir.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/dir.c
6593 --- linux-2.6.24-rc7/fs/nfs/dir.c 2007-12-31 17:58:26 +0100
6594 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/dir.c 2007-12-31 12:34:39 +0100
6596 #include <linux/namei.h>
6597 #include <linux/mount.h>
6598 #include <linux/sched.h>
6599 +#include <linux/vs_tag.h>
6601 #include "nfs4_fs.h"
6602 #include "delegation.h"
6603 @@ -913,6 +914,7 @@ static struct dentry *nfs_lookup(struct
6605 goto out_unblock_sillyrename;
6607 + dx_propagate_tag(nd, inode);
6609 res = d_materialise_unique(dentry, inode);
6611 @@ -950,7 +952,8 @@ static int is_atomic_open(struct inode *
6612 if (nd->flags & LOOKUP_DIRECTORY)
6614 /* Are we trying to write to a read only partition? */
6615 - if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
6616 + if ((IS_RDONLY(dir) || MNT_IS_RDONLY(nd->mnt)) &&
6617 + (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
6621 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfs/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/inode.c
6622 --- linux-2.6.24-rc7/fs/nfs/inode.c 2007-11-29 01:11:53 +0100
6623 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/inode.c 2007-12-13 13:25:51 +0100
6625 #include <linux/vfs.h>
6626 #include <linux/inet.h>
6627 #include <linux/nfs_xdr.h>
6628 +#include <linux/vs_tag.h>
6630 #include <asm/system.h>
6631 #include <asm/uaccess.h>
6632 @@ -315,8 +316,10 @@ nfs_fhget(struct super_block *sb, struct
6633 nfsi->change_attr = fattr->change_attr;
6634 inode->i_size = nfs_size_to_loff_t(fattr->size);
6635 inode->i_nlink = fattr->nlink;
6636 - inode->i_uid = fattr->uid;
6637 - inode->i_gid = fattr->gid;
6638 + inode->i_uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
6639 + inode->i_gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
6640 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
6641 + /* maybe fattr->xid someday */
6642 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
6644 * report the blocks in 512byte units
6645 @@ -409,6 +412,8 @@ void nfs_setattr_update_inode(struct ino
6646 inode->i_uid = attr->ia_uid;
6647 if ((attr->ia_valid & ATTR_GID) != 0)
6648 inode->i_gid = attr->ia_gid;
6649 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
6650 + inode->i_tag = attr->ia_tag;
6651 spin_lock(&inode->i_lock);
6652 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
6653 spin_unlock(&inode->i_lock);
6654 @@ -833,6 +838,9 @@ static int nfs_check_inode_attributes(st
6655 struct nfs_inode *nfsi = NFS_I(inode);
6656 loff_t cur_size, new_isize;
6657 unsigned long invalid = 0;
6663 /* Has the inode gone and changed behind our back? */
6664 @@ -857,10 +865,15 @@ static int nfs_check_inode_attributes(st
6665 if (cur_size != new_isize && nfsi->npages == 0)
6666 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
6668 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
6669 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
6670 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
6672 /* Have any file permissions changed? */
6673 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
6674 - || inode->i_uid != fattr->uid
6675 - || inode->i_gid != fattr->gid)
6676 + || inode->i_uid != uid
6677 + || inode->i_gid != gid
6678 + || inode->i_tag != tag)
6679 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
6681 /* Has the link count changed? */
6682 @@ -981,6 +994,9 @@ static int nfs_update_inode(struct inode
6683 loff_t cur_isize, new_isize;
6684 unsigned long invalid = 0;
6685 unsigned long now = jiffies;
6690 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
6691 __FUNCTION__, inode->i_sb->s_id, inode->i_ino,
6692 @@ -1051,15 +1067,21 @@ static int nfs_update_inode(struct inode
6693 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
6694 nfsi->change_attr = fattr->change_attr;
6696 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
6697 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
6698 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
6700 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
6701 - inode->i_uid != fattr->uid ||
6702 - inode->i_gid != fattr->gid)
6703 + inode->i_uid != uid ||
6704 + inode->i_gid != gid ||
6705 + inode->i_tag != tag)
6706 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
6708 inode->i_mode = fattr->mode;
6709 inode->i_nlink = fattr->nlink;
6710 - inode->i_uid = fattr->uid;
6711 - inode->i_gid = fattr->gid;
6712 + inode->i_uid = uid;
6713 + inode->i_gid = gid;
6714 + inode->i_tag = tag;
6716 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
6718 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfs/nfs3xdr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/nfs3xdr.c
6719 --- linux-2.6.24-rc7/fs/nfs/nfs3xdr.c 2007-11-29 01:11:53 +0100
6720 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/nfs3xdr.c 2007-12-13 13:25:51 +0100
6722 #include <linux/nfs3.h>
6723 #include <linux/nfs_fs.h>
6724 #include <linux/nfsacl.h>
6725 +#include <linux/vs_tag.h>
6726 #include "internal.h"
6728 #define NFSDBG_FACILITY NFSDBG_XDR
6729 @@ -180,7 +181,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
6732 static inline __be32 *
6733 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
6734 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
6736 if (attr->ia_valid & ATTR_MODE) {
6738 @@ -188,15 +189,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
6742 - if (attr->ia_valid & ATTR_UID) {
6743 + if (attr->ia_valid & ATTR_UID ||
6744 + (tag && (attr->ia_valid & ATTR_TAG))) {
6746 - *p++ = htonl(attr->ia_uid);
6747 + *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
6751 - if (attr->ia_valid & ATTR_GID) {
6752 + if (attr->ia_valid & ATTR_GID ||
6753 + (tag && (attr->ia_valid & ATTR_TAG))) {
6755 - *p++ = htonl(attr->ia_gid);
6756 + *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
6760 @@ -281,7 +284,8 @@ static int
6761 nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
6763 p = xdr_encode_fhandle(p, args->fh);
6764 - p = xdr_encode_sattr(p, args->sattr);
6765 + p = xdr_encode_sattr(p, args->sattr,
6766 + req->rq_task->tk_client->cl_tag);
6767 *p++ = htonl(args->guard);
6769 p = xdr_encode_time3(p, &args->guardtime);
6770 @@ -386,7 +390,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
6771 *p++ = args->verifier[0];
6772 *p++ = args->verifier[1];
6774 - p = xdr_encode_sattr(p, args->sattr);
6775 + p = xdr_encode_sattr(p, args->sattr,
6776 + req->rq_task->tk_client->cl_tag);
6778 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6780 @@ -400,7 +405,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
6782 p = xdr_encode_fhandle(p, args->fh);
6783 p = xdr_encode_array(p, args->name, args->len);
6784 - p = xdr_encode_sattr(p, args->sattr);
6785 + p = xdr_encode_sattr(p, args->sattr,
6786 + req->rq_task->tk_client->cl_tag);
6787 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6790 @@ -413,7 +419,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
6792 p = xdr_encode_fhandle(p, args->fromfh);
6793 p = xdr_encode_array(p, args->fromname, args->fromlen);
6794 - p = xdr_encode_sattr(p, args->sattr);
6795 + p = xdr_encode_sattr(p, args->sattr,
6796 + req->rq_task->tk_client->cl_tag);
6797 *p++ = htonl(args->pathlen);
6798 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
6800 @@ -431,7 +438,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
6801 p = xdr_encode_fhandle(p, args->fh);
6802 p = xdr_encode_array(p, args->name, args->len);
6803 *p++ = htonl(args->type);
6804 - p = xdr_encode_sattr(p, args->sattr);
6805 + p = xdr_encode_sattr(p, args->sattr,
6806 + req->rq_task->tk_client->cl_tag);
6807 if (args->type == NF3CHR || args->type == NF3BLK) {
6808 *p++ = htonl(MAJOR(args->rdev));
6809 *p++ = htonl(MINOR(args->rdev));
6810 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfs/nfsroot.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/nfsroot.c
6811 --- linux-2.6.24-rc7/fs/nfs/nfsroot.c 2007-11-29 01:11:53 +0100
6812 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/nfsroot.c 2007-12-13 13:25:51 +0100
6813 @@ -119,12 +119,12 @@ static int mount_port __initdata = 0; /
6815 /* Options that take integer arguments */
6816 Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
6817 - Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
6818 + Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
6819 /* Options that take no arguments */
6820 Opt_soft, Opt_hard, Opt_intr,
6821 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
6822 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
6823 - Opt_acl, Opt_noacl,
6824 + Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
6828 @@ -161,6 +161,10 @@ static match_table_t __initdata tokens =
6831 {Opt_noacl, "noacl"},
6833 + {Opt_notag, "notag"},
6834 + {Opt_tagid, "tagid=%u"},
6835 + {Opt_tag, "tagxid"},
6839 @@ -275,6 +279,20 @@ static int __init root_nfs_parse(char *n
6841 nfs_data.flags |= NFS_MOUNT_NOACL;
6843 +#ifndef CONFIG_TAGGING_NONE
6845 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6848 + nfs_data.flags &= ~NFS_MOUNT_TAGGED;
6851 +#ifdef CONFIG_PROPAGATE
6854 + nfs_data.flags |= NFS_MOUNT_TAGGED;
6858 printk(KERN_WARNING "Root-NFS: unknown "
6860 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfs/super.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/super.c
6861 --- linux-2.6.24-rc7/fs/nfs/super.c 2008-01-11 12:00:49 +0100
6862 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfs/super.c 2008-01-11 04:30:09 +0100
6864 #include <linux/nfs_xdr.h>
6865 #include <linux/magic.h>
6866 #include <linux/parser.h>
6867 +#include <linux/vs_tag.h>
6869 #include <asm/system.h>
6870 #include <asm/uaccess.h>
6871 @@ -431,6 +432,7 @@ static void nfs_show_mount_options(struc
6872 { NFS_MOUNT_NOACL, ",noacl", "" },
6873 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
6874 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
6875 + { NFS_MOUNT_TAGGED, ",tag", "" },
6878 const struct proc_nfs_info *nfs_infop;
6879 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfsd/auth.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/auth.c
6880 --- linux-2.6.24-rc7/fs/nfsd/auth.c 2007-11-29 01:01:59 +0100
6881 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/auth.c 2007-12-13 13:25:51 +0100
6883 #include <linux/sunrpc/svcauth.h>
6884 #include <linux/nfsd/nfsd.h>
6885 #include <linux/nfsd/export.h>
6886 +#include <linux/vs_tag.h>
6888 #define CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
6890 @@ -56,19 +57,22 @@ int nfsd_setuser(struct svc_rqst *rqstp,
6891 get_group_info(cred.cr_group_info);
6893 if (cred.cr_uid != (uid_t) -1)
6894 - current->fsuid = cred.cr_uid;
6895 + current->fsuid = INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
6897 current->fsuid = exp->ex_anon_uid;
6898 if (cred.cr_gid != (gid_t) -1)
6899 - current->fsgid = cred.cr_gid;
6900 + current->fsgid = INOTAG_GID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid);
6902 current->fsgid = exp->ex_anon_gid;
6904 + /* this desperately needs a tag :) */
6905 + current->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
6907 if (!cred.cr_group_info)
6909 ret = set_current_groups(cred.cr_group_info);
6910 put_group_info(cred.cr_group_info);
6911 - if ((cred.cr_uid)) {
6912 + if (INOTAG_UID(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid)) {
6913 cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
6915 cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
6916 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfsd/nfs3xdr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/nfs3xdr.c
6917 --- linux-2.6.24-rc7/fs/nfsd/nfs3xdr.c 2007-11-29 01:11:53 +0100
6918 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/nfs3xdr.c 2007-12-31 13:07:17 +0100
6920 #include <linux/sunrpc/svc.h>
6921 #include <linux/nfsd/nfsd.h>
6922 #include <linux/nfsd/xdr3.h>
6923 +#include <linux/vs_tag.h>
6925 #define NFSDDBG_FACILITY NFSDDBG_XDR
6927 @@ -107,6 +108,8 @@ static __be32 *
6928 decode_sattr3(__be32 *p, struct iattr *iap)
6936 @@ -116,12 +119,15 @@ decode_sattr3(__be32 *p, struct iattr *i
6939 iap->ia_valid |= ATTR_UID;
6940 - iap->ia_uid = ntohl(*p++);
6941 + uid = ntohl(*p++);
6944 iap->ia_valid |= ATTR_GID;
6945 - iap->ia_gid = ntohl(*p++);
6946 + gid = ntohl(*p++);
6948 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
6949 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
6950 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
6954 @@ -177,8 +183,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
6955 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6956 *p++ = htonl((u32) stat->mode);
6957 *p++ = htonl((u32) stat->nlink);
6958 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
6959 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
6960 + *p++ = htonl((u32) nfsd_ruid(rqstp,
6961 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6962 + stat->uid, stat->tag)));
6963 + *p++ = htonl((u32) nfsd_rgid(rqstp,
6964 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
6965 + stat->gid, stat->tag)));
6966 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
6967 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
6969 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfsd/nfs4recover.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/nfs4recover.c
6970 --- linux-2.6.24-rc7/fs/nfsd/nfs4recover.c 2007-11-29 01:11:54 +0100
6971 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/nfs4recover.c 2007-12-13 13:25:47 +0100
6972 @@ -154,7 +154,7 @@ nfsd4_create_clid_dir(struct nfs4_client
6973 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n");
6976 - status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU);
6977 + status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU, NULL);
6981 @@ -258,7 +258,7 @@ nfsd4_remove_clid_file(struct dentry *di
6984 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
6985 - status = vfs_unlink(dir->d_inode, dentry);
6986 + status = vfs_unlink(dir->d_inode, dentry, NULL);
6987 mutex_unlock(&dir->d_inode->i_mutex);
6990 @@ -273,7 +273,7 @@ nfsd4_clear_clid_dir(struct dentry *dir,
6991 * a kernel from the future.... */
6992 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
6993 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
6994 - status = vfs_rmdir(dir->d_inode, dentry);
6995 + status = vfs_rmdir(dir->d_inode, dentry, NULL);
6996 mutex_unlock(&dir->d_inode->i_mutex);
6999 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfsd/nfs4xdr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/nfs4xdr.c
7000 --- linux-2.6.24-rc7/fs/nfsd/nfs4xdr.c 2007-11-29 01:11:54 +0100
7001 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/nfs4xdr.c 2007-12-13 13:25:51 +0100
7003 #include <linux/nfs4_acl.h>
7004 #include <linux/sunrpc/gss_api.h>
7005 #include <linux/sunrpc/svcauth_gss.h>
7006 +#include <linux/vs_tag.h>
7008 #define NFSDDBG_FACILITY NFSDDBG_XDR
7010 @@ -1754,14 +1755,18 @@ out_acl:
7011 WRITE32(stat.nlink);
7013 if (bmval1 & FATTR4_WORD1_OWNER) {
7014 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7015 + status = nfsd4_encode_user(rqstp,
7016 + TAGINO_UID(DX_TAG(dentry->d_inode),
7017 + stat.uid, stat.tag), &p, &buflen);
7018 if (status == nfserr_resource)
7023 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7024 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7025 + status = nfsd4_encode_group(rqstp,
7026 + TAGINO_GID(DX_TAG(dentry->d_inode),
7027 + stat.gid, stat.tag), &p, &buflen);
7028 if (status == nfserr_resource)
7031 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfsd/nfsxdr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/nfsxdr.c
7032 --- linux-2.6.24-rc7/fs/nfsd/nfsxdr.c 2007-11-29 01:11:54 +0100
7033 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/nfsxdr.c 2007-12-13 13:25:51 +0100
7035 #include <linux/nfsd/nfsd.h>
7036 #include <linux/nfsd/xdr.h>
7037 #include <linux/mm.h>
7038 +#include <linux/vs_tag.h>
7040 #define NFSDDBG_FACILITY NFSDDBG_XDR
7042 @@ -97,6 +98,8 @@ static __be32 *
7043 decode_sattr(__be32 *p, struct iattr *iap)
7051 @@ -110,12 +113,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7053 if ((tmp = ntohl(*p++)) != (u32)-1) {
7054 iap->ia_valid |= ATTR_UID;
7055 - iap->ia_uid = tmp;
7058 if ((tmp = ntohl(*p++)) != (u32)-1) {
7059 iap->ia_valid |= ATTR_GID;
7060 - iap->ia_gid = tmp;
7063 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7064 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7065 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7066 if ((tmp = ntohl(*p++)) != (u32)-1) {
7067 iap->ia_valid |= ATTR_SIZE;
7069 @@ -160,8 +166,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7070 *p++ = htonl(nfs_ftypes[type >> 12]);
7071 *p++ = htonl((u32) stat->mode);
7072 *p++ = htonl((u32) stat->nlink);
7073 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7074 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7075 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7076 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7077 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7078 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7080 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7081 *p++ = htonl(NFS_MAXPATHLEN);
7082 diff -NurpP --minimal linux-2.6.24-rc7/fs/nfsd/vfs.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/vfs.c
7083 --- linux-2.6.24-rc7/fs/nfsd/vfs.c 2007-11-29 01:11:54 +0100
7084 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/nfsd/vfs.c 2007-12-13 13:25:47 +0100
7085 @@ -1236,13 +1236,13 @@ nfsd_create(struct svc_rqst *rqstp, stru
7086 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
7089 - host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
7090 + host_err = vfs_mkdir(dirp, dchild, iap->ia_mode, NULL);
7096 - host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
7097 + host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev, NULL);
7100 printk("nfsd: bad file type %o in nfsd_create\n", type);
7101 @@ -1519,11 +1519,13 @@ nfsd_symlink(struct svc_rqst *rqstp, str
7103 strncpy(path_alloced, path, plen);
7104 path_alloced[plen] = 0;
7105 - host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
7106 + host_err = vfs_symlink(dentry->d_inode, dnew,
7107 + path_alloced, mode, NULL);
7108 kfree(path_alloced);
7111 - host_err = vfs_symlink(dentry->d_inode, dnew, path, mode);
7112 + host_err = vfs_symlink(dentry->d_inode, dnew,
7113 + path, mode, NULL);
7116 if (EX_ISSYNC(fhp->fh_export))
7117 @@ -1582,7 +1584,7 @@ nfsd_link(struct svc_rqst *rqstp, struct
7118 dold = tfhp->fh_dentry;
7119 dest = dold->d_inode;
7121 - host_err = vfs_link(dold, dirp, dnew);
7122 + host_err = vfs_link(dold, dirp, dnew, NULL);
7124 if (EX_ISSYNC(ffhp->fh_export)) {
7125 err = nfserrno(nfsd_sync_dir(ddir));
7126 @@ -1747,9 +1749,9 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
7130 - host_err = vfs_unlink(dirp, rdentry);
7131 + host_err = vfs_unlink(dirp, rdentry, NULL);
7132 } else { /* It's RMDIR */
7133 - host_err = vfs_rmdir(dirp, rdentry);
7134 + host_err = vfs_rmdir(dirp, rdentry, NULL);
7138 @@ -1866,7 +1868,8 @@ nfsd_permission(struct svc_rqst *rqstp,
7140 if (!(acc & MAY_LOCAL_ACCESS))
7141 if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
7142 - if (exp_rdonly(rqstp, exp) || IS_RDONLY(inode))
7143 + if (exp_rdonly(rqstp, exp) || IS_RDONLY(inode)
7144 + || MNT_IS_RDONLY(exp->ex_mnt))
7146 if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
7148 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/dlm/dlmfs.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/dlm/dlmfs.c
7149 --- linux-2.6.24-rc7/fs/ocfs2/dlm/dlmfs.c 2007-11-29 01:11:57 +0100
7150 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/dlm/dlmfs.c 2007-12-13 13:25:47 +0100
7152 #include <linux/init.h>
7153 #include <linux/string.h>
7154 #include <linux/backing-dev.h>
7155 +#include <linux/vs_tag.h>
7157 #include <asm/uaccess.h>
7159 @@ -330,6 +331,7 @@ static struct inode *dlmfs_get_root_inod
7160 inode->i_mode = mode;
7161 inode->i_uid = current->fsuid;
7162 inode->i_gid = current->fsgid;
7163 + inode->i_tag = dx_current_fstag(sb);
7164 inode->i_blocks = 0;
7165 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
7166 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
7167 @@ -356,6 +358,7 @@ static struct inode *dlmfs_get_inode(str
7168 inode->i_mode = mode;
7169 inode->i_uid = current->fsuid;
7170 inode->i_gid = current->fsgid;
7171 + inode->i_tag = dx_current_fstag(sb);
7172 inode->i_blocks = 0;
7173 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
7174 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
7175 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/dlmglue.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/dlmglue.c
7176 --- linux-2.6.24-rc7/fs/ocfs2/dlmglue.c 2007-11-29 01:11:57 +0100
7177 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/dlmglue.c 2007-12-13 13:25:47 +0100
7178 @@ -1468,6 +1468,7 @@ static void __ocfs2_stuff_meta_lvb(struc
7179 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
7180 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
7181 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
7182 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
7183 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
7184 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
7185 lvb->lvb_iatime_packed =
7186 @@ -1522,6 +1523,7 @@ static void ocfs2_refresh_inode_from_lvb
7188 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
7189 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
7190 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
7191 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
7192 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
7193 ocfs2_unpack_timespec(&inode->i_atime,
7194 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/dlmglue.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/dlmglue.h
7195 --- linux-2.6.24-rc7/fs/ocfs2/dlmglue.h 2007-11-29 01:11:57 +0100
7196 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/dlmglue.h 2007-12-13 13:25:47 +0100
7197 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
7200 __be32 lvb_igeneration;
7201 - __be32 lvb_reserved2;
7203 + __be16 lvb_reserved2;
7206 /* ocfs2_meta_lock_full() and ocfs2_data_lock_full() 'arg_flags' flags */
7207 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/file.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/file.c
7208 --- linux-2.6.24-rc7/fs/ocfs2/file.c 2007-12-31 17:58:26 +0100
7209 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/file.c 2007-12-31 12:34:40 +0100
7210 @@ -1025,13 +1025,15 @@ int ocfs2_setattr(struct dentry *dentry,
7211 mlog(0, "uid change: %d\n", attr->ia_uid);
7212 if (attr->ia_valid & ATTR_GID)
7213 mlog(0, "gid change: %d\n", attr->ia_gid);
7214 + if (attr->ia_valid & ATTR_TAG)
7215 + mlog(0, "tag change: %d\n", attr->ia_tag);
7216 if (attr->ia_valid & ATTR_SIZE)
7217 mlog(0, "size change...\n");
7218 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
7219 mlog(0, "time change...\n");
7221 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
7222 - | ATTR_GID | ATTR_UID | ATTR_MODE)
7223 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
7224 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
7225 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
7227 @@ -2200,6 +2202,7 @@ const struct inode_operations ocfs2_file
7228 const struct inode_operations ocfs2_special_file_iops = {
7229 .setattr = ocfs2_setattr,
7230 .getattr = ocfs2_getattr,
7231 + .sync_flags = ocfs2_sync_flags,
7232 .permission = ocfs2_permission,
7235 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/inode.c
7236 --- linux-2.6.24-rc7/fs/ocfs2/inode.c 2007-12-31 17:58:26 +0100
7237 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/inode.c 2007-12-31 12:34:40 +0100
7239 #include <linux/slab.h>
7240 #include <linux/highmem.h>
7241 #include <linux/pagemap.h>
7242 +#include <linux/vs_tag.h>
7244 #include <asm/byteorder.h>
7248 #include "heartbeat.h"
7251 #include "journal.h"
7253 #include "suballoc.h"
7254 @@ -77,6 +79,10 @@ void ocfs2_set_inode_flags(struct inode
7256 if (flags & OCFS2_IMMUTABLE_FL)
7257 inode->i_flags |= S_IMMUTABLE;
7258 + if (flags & OCFS2_IUNLINK_FL)
7259 + inode->i_flags |= S_IUNLINK;
7260 + if (flags & OCFS2_BARRIER_FL)
7261 + inode->i_flags |= S_BARRIER;
7263 if (flags & OCFS2_SYNC_FL)
7264 inode->i_flags |= S_SYNC;
7265 @@ -107,6 +113,27 @@ void ocfs2_get_inode_flags(struct ocfs2_
7266 oi->ip_attr |= OCFS2_DIRSYNC_FL;
7269 +int ocfs2_sync_flags(struct inode *inode)
7271 + unsigned int oldflags, newflags;
7273 + oldflags = OCFS2_I(inode)->ip_flags;
7274 + newflags = oldflags & ~(OCFS2_IMMUTABLE_FL |
7275 + OCFS2_IUNLINK_FL | OCFS2_BARRIER_FL);
7277 + if (IS_IMMUTABLE(inode))
7278 + newflags |= OCFS2_IMMUTABLE_FL;
7279 + if (IS_IUNLINK(inode))
7280 + newflags |= OCFS2_IUNLINK_FL;
7281 + if (IS_BARRIER(inode))
7282 + newflags |= OCFS2_BARRIER_FL;
7284 + if (oldflags ^ newflags)
7285 + return ocfs2_set_inode_attr(inode,
7286 + newflags, OCFS2_FL_MASK);
7290 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags)
7292 struct inode *inode = NULL;
7293 @@ -212,6 +239,8 @@ int ocfs2_populate_inode(struct inode *i
7294 struct super_block *sb;
7295 struct ocfs2_super *osb;
7296 int status = -EINVAL;
7300 mlog_entry("(0x%p, size:%llu)\n", inode,
7301 (unsigned long long)le64_to_cpu(fe->i_size));
7302 @@ -247,8 +276,12 @@ int ocfs2_populate_inode(struct inode *i
7303 inode->i_generation = le32_to_cpu(fe->i_generation);
7304 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
7305 inode->i_mode = le16_to_cpu(fe->i_mode);
7306 - inode->i_uid = le32_to_cpu(fe->i_uid);
7307 - inode->i_gid = le32_to_cpu(fe->i_gid);
7308 + uid = le32_to_cpu(fe->i_uid);
7309 + gid = le32_to_cpu(fe->i_gid);
7310 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7311 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7312 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7313 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7315 /* Fast symlinks will have i_size but no allocated clusters. */
7316 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
7317 @@ -1230,8 +1263,11 @@ int ocfs2_mark_inode_dirty(handle_t *han
7319 fe->i_size = cpu_to_le64(i_size_read(inode));
7320 fe->i_links_count = cpu_to_le16(inode->i_nlink);
7321 - fe->i_uid = cpu_to_le32(inode->i_uid);
7322 - fe->i_gid = cpu_to_le32(inode->i_gid);
7323 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
7324 + inode->i_uid, inode->i_tag));
7325 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
7326 + inode->i_gid, inode->i_tag));
7327 + /* i_tag = = cpu_to_le16(inode->i_tag); */
7328 fe->i_mode = cpu_to_le16(inode->i_mode);
7329 fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
7330 fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
7331 @@ -1259,16 +1295,25 @@ leave:
7332 void ocfs2_refresh_inode(struct inode *inode,
7333 struct ocfs2_dinode *fe)
7338 spin_lock(&OCFS2_I(inode)->ip_lock);
7340 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
7341 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
7342 + /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
7343 + OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
7344 OCFS2_I(inode)->ip_dyn_features = le16_to_cpu(fe->i_dyn_features);
7345 ocfs2_set_inode_flags(inode);
7346 i_size_write(inode, le64_to_cpu(fe->i_size));
7347 inode->i_nlink = le16_to_cpu(fe->i_links_count);
7348 - inode->i_uid = le32_to_cpu(fe->i_uid);
7349 - inode->i_gid = le32_to_cpu(fe->i_gid);
7350 + uid = le32_to_cpu(fe->i_uid);
7351 + gid = le32_to_cpu(fe->i_gid);
7352 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7353 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7354 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7355 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7356 inode->i_mode = le16_to_cpu(fe->i_mode);
7357 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
7358 inode->i_blocks = 0;
7359 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/inode.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/inode.h
7360 --- linux-2.6.24-rc7/fs/ocfs2/inode.h 2007-11-29 01:11:57 +0100
7361 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/inode.h 2007-12-13 13:25:39 +0100
7362 @@ -143,6 +143,7 @@ int ocfs2_aio_write(struct file *file, s
7364 void ocfs2_set_inode_flags(struct inode *inode);
7365 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
7366 +int ocfs2_sync_flags(struct inode *inode);
7368 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
7370 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/ioctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/ioctl.c
7371 --- linux-2.6.24-rc7/fs/ocfs2/ioctl.c 2007-11-29 01:01:59 +0100
7372 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/ioctl.c 2007-12-13 13:25:47 +0100
7373 @@ -40,7 +40,7 @@ static int ocfs2_get_inode_attr(struct i
7377 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7378 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7381 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
7382 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/ioctl.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/ioctl.h
7383 --- linux-2.6.24-rc7/fs/ocfs2/ioctl.h 2007-07-09 13:19:28 +0200
7384 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/ioctl.h 2007-12-13 13:25:47 +0100
7386 #ifndef OCFS2_IOCTL_H
7387 #define OCFS2_IOCTL_H
7389 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7392 int ocfs2_ioctl(struct inode * inode, struct file * filp,
7393 unsigned int cmd, unsigned long arg);
7394 long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
7395 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/namei.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/namei.c
7396 --- linux-2.6.24-rc7/fs/ocfs2/namei.c 2007-11-29 01:11:57 +0100
7397 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/namei.c 2007-12-13 13:25:47 +0100
7399 #include <linux/types.h>
7400 #include <linux/slab.h>
7401 #include <linux/highmem.h>
7402 +#include <linux/vs_tag.h>
7404 #define MLOG_MASK_PREFIX ML_NAMEI
7405 #include <cluster/masklog.h>
7406 @@ -367,6 +368,9 @@ static int ocfs2_mknod_locked(struct ocf
7409 struct inode *inode = NULL;
7414 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
7415 (unsigned long)dev, dentry->d_name.len,
7416 @@ -426,13 +430,19 @@ static int ocfs2_mknod_locked(struct ocf
7417 fe->i_blkno = cpu_to_le64(fe_blkno);
7418 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
7419 fe->i_suballoc_slot = cpu_to_le16(osb->slot_num);
7420 - fe->i_uid = cpu_to_le32(current->fsuid);
7422 + tag = dx_current_fstag(osb->sb);
7423 + uid = current->fsuid;
7424 if (dir->i_mode & S_ISGID) {
7425 - fe->i_gid = cpu_to_le32(dir->i_gid);
7430 - fe->i_gid = cpu_to_le32(current->fsgid);
7431 + gid = current->fsgid;
7433 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), uid, tag));
7434 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), gid, tag));
7435 + inode->i_tag = tag;
7436 fe->i_mode = cpu_to_le16(mode);
7437 if (S_ISCHR(mode) || S_ISBLK(mode))
7438 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
7439 @@ -1917,5 +1927,6 @@ const struct inode_operations ocfs2_dir_
7440 .rename = ocfs2_rename,
7441 .setattr = ocfs2_setattr,
7442 .getattr = ocfs2_getattr,
7443 + .sync_flags = ocfs2_sync_flags,
7444 .permission = ocfs2_permission,
7446 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/ocfs2.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/ocfs2.h
7447 --- linux-2.6.24-rc7/fs/ocfs2/ocfs2.h 2007-11-29 01:11:57 +0100
7448 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/ocfs2.h 2007-12-13 13:25:47 +0100
7449 @@ -170,6 +170,7 @@ enum ocfs2_mount_options
7450 OCFS2_MOUNT_NOINTR = 1 << 2, /* Don't catch signals */
7451 OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
7452 OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
7453 + OCFS2_MOUNT_TAGGED = 1 << 8, /* use tagging */
7456 #define OCFS2_OSB_SOFT_RO 0x0001
7457 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/ocfs2_fs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/ocfs2_fs.h
7458 --- linux-2.6.24-rc7/fs/ocfs2/ocfs2_fs.h 2007-11-29 01:11:57 +0100
7459 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/ocfs2_fs.h 2007-12-13 13:25:47 +0100
7460 @@ -188,8 +188,12 @@
7461 #define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
7462 #define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
7464 +#define OCFS2_BARRIER_FL (0x04000000) /* Barrier for chroot() */
7465 +#define OCFS2_IUNLINK_FL (0x08000000) /* Immutable unlink */
7467 #define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
7468 #define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
7469 +#define OCFS2_FL_MASK (0x0F0100FF)
7472 * Extent record flags (e_node.leaf.flags)
7473 diff -NurpP --minimal linux-2.6.24-rc7/fs/ocfs2/super.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/super.c
7474 --- linux-2.6.24-rc7/fs/ocfs2/super.c 2007-12-31 17:58:26 +0100
7475 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/ocfs2/super.c 2007-12-31 12:34:40 +0100
7476 @@ -150,6 +150,7 @@ enum {
7480 + Opt_tag, Opt_notag, Opt_tagid,
7484 @@ -165,6 +166,10 @@ static match_table_t tokens = {
7485 {Opt_data_writeback, "data=writeback"},
7486 {Opt_atime_quantum, "atime_quantum=%u"},
7487 {Opt_slot, "preferred_slot=%u"},
7489 + {Opt_tag, "tagxid"},
7490 + {Opt_notag, "notag"},
7491 + {Opt_tagid, "tagid=%u"},
7495 @@ -384,6 +389,14 @@ static int ocfs2_remount(struct super_bl
7499 + printk("ocfs2_remount: %lx,%lx\n", osb->s_mount_opt, sb->s_flags);
7500 + if ((parsed_options.mount_opt & OCFS2_MOUNT_TAGGED) &&
7501 + !(sb->s_flags & MS_TAGGED)) {
7503 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
7507 if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
7508 (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
7510 @@ -680,6 +693,9 @@ static int ocfs2_fill_super(struct super
7512 ocfs2_complete_mount_recovery(osb);
7514 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
7515 + sb->s_flags |= MS_TAGGED;
7517 if (ocfs2_mount_local(osb))
7518 snprintf(nodestr, sizeof(nodestr), "local");
7520 @@ -816,6 +832,20 @@ static int ocfs2_parse_options(struct su
7522 mopt->slot = (s16)option;
7524 +#ifndef CONFIG_TAGGING_NONE
7526 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
7529 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
7532 +#ifdef CONFIG_PROPAGATE
7535 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
7540 "Unrecognized mount option \"%s\" "
7541 diff -NurpP --minimal linux-2.6.24-rc7/fs/open.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/open.c
7542 --- linux-2.6.24-rc7/fs/open.c 2007-11-29 01:11:57 +0100
7543 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/open.c 2007-12-13 13:25:47 +0100
7545 #include <linux/rcupdate.h>
7546 #include <linux/audit.h>
7547 #include <linux/falloc.h>
7548 +#include <linux/vs_base.h>
7549 +#include <linux/vs_limit.h>
7550 +#include <linux/vs_dlimit.h>
7551 +#include <linux/vs_tag.h>
7552 +#include <linux/vs_cowbl.h>
7554 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
7556 int retval = -ENODEV;
7559 + struct super_block *sb = dentry->d_sb;
7562 - if (dentry->d_sb->s_op->statfs) {
7563 + if (sb->s_op->statfs) {
7564 memset(buf, 0, sizeof(*buf));
7565 retval = security_sb_statfs(dentry);
7568 - retval = dentry->d_sb->s_op->statfs(dentry, buf);
7569 + retval = sb->s_op->statfs(dentry, buf);
7570 if (retval == 0 && buf->f_frsize == 0)
7571 buf->f_frsize = buf->f_bsize;
7573 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7574 + vx_vsi_statfs(sb, buf);
7578 @@ -249,7 +258,7 @@ static long do_sys_truncate(const char _
7582 - if (IS_RDONLY(inode))
7583 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
7587 @@ -458,7 +467,7 @@ asmlinkage long sys_faccessat(int dfd, c
7588 special_file(nd.dentry->d_inode->i_mode))
7589 goto out_path_release;
7591 - if(IS_RDONLY(nd.dentry->d_inode))
7592 + if(IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
7596 @@ -572,7 +581,7 @@ asmlinkage long sys_fchmod(unsigned int
7597 audit_inode(NULL, dentry);
7600 - if (IS_RDONLY(inode))
7601 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
7604 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
7605 @@ -602,11 +611,11 @@ asmlinkage long sys_fchmodat(int dfd, co
7606 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
7609 - inode = nd.dentry->d_inode;
7612 - if (IS_RDONLY(inode))
7613 + error = cow_check_and_break(&nd);
7616 + inode = nd.dentry->d_inode;
7619 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
7620 @@ -631,7 +640,8 @@ asmlinkage long sys_chmod(const char __u
7621 return sys_fchmodat(AT_FDCWD, filename, mode);
7624 -static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
7625 +static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
7626 + uid_t user, gid_t group)
7628 struct inode * inode;
7630 @@ -643,7 +653,7 @@ static int chown_common(struct dentry *
7634 - if (IS_RDONLY(inode))
7635 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
7638 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
7639 @@ -651,11 +661,11 @@ static int chown_common(struct dentry *
7640 newattrs.ia_valid = ATTR_CTIME;
7641 if (user != (uid_t) -1) {
7642 newattrs.ia_valid |= ATTR_UID;
7643 - newattrs.ia_uid = user;
7644 + newattrs.ia_uid = dx_map_uid(user);
7646 if (group != (gid_t) -1) {
7647 newattrs.ia_valid |= ATTR_GID;
7648 - newattrs.ia_gid = group;
7649 + newattrs.ia_gid = dx_map_gid(group);
7651 if (!S_ISDIR(inode->i_mode))
7652 newattrs.ia_valid |=
7653 @@ -675,7 +685,11 @@ asmlinkage long sys_chown(const char __u
7654 error = user_path_walk(filename, &nd);
7657 - error = chown_common(nd.dentry, user, group);
7658 +#ifdef CONFIG_VSERVER_COWBL
7659 + error = cow_check_and_break(&nd);
7662 + error = chown_common(nd.dentry, nd.mnt, user, group);
7666 @@ -695,7 +709,11 @@ asmlinkage long sys_fchownat(int dfd, co
7667 error = __user_walk_fd(dfd, filename, follow, &nd);
7670 - error = chown_common(nd.dentry, user, group);
7671 +#ifdef CONFIG_VSERVER_COWBL
7672 + error = cow_check_and_break(&nd);
7675 + error = chown_common(nd.dentry, nd.mnt, user, group);
7679 @@ -709,7 +727,11 @@ asmlinkage long sys_lchown(const char __
7680 error = user_path_walk_link(filename, &nd);
7683 - error = chown_common(nd.dentry, user, group);
7684 +#ifdef CONFIG_VSERVER_COWBL
7685 + error = cow_check_and_break(&nd);
7688 + error = chown_common(nd.dentry, nd.mnt, user, group);
7692 @@ -728,7 +750,7 @@ asmlinkage long sys_fchown(unsigned int
7694 dentry = file->f_path.dentry;
7695 audit_inode(NULL, dentry);
7696 - error = chown_common(dentry, user, group);
7697 + error = chown_common(dentry, file->f_vfsmnt, user, group);
7701 @@ -962,6 +984,7 @@ repeat:
7703 FD_CLR(fd, fdt->close_on_exec);
7704 files->next_fd = fd + 1;
7705 + vx_openfd_inc(fd);
7708 if (fdt->fd[fd] != NULL) {
7709 @@ -989,6 +1012,7 @@ static void __put_unused_fd(struct files
7710 __FD_CLR(fd, fdt->open_fds);
7711 if (fd < files->next_fd)
7712 files->next_fd = fd;
7713 + vx_openfd_dec(fd);
7716 void fastcall put_unused_fd(unsigned int fd)
7717 diff -NurpP --minimal linux-2.6.24-rc7/fs/proc/array.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/array.c
7718 --- linux-2.6.24-rc7/fs/proc/array.c 2007-12-31 17:58:26 +0100
7719 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/array.c 2008-01-07 03:06:13 +0100
7721 #include <linux/rcupdate.h>
7722 #include <linux/delayacct.h>
7723 #include <linux/pid_namespace.h>
7724 +#include <linux/vs_context.h>
7725 +#include <linux/vs_network.h>
7727 #include <asm/pgtable.h>
7728 #include <asm/processor.h>
7729 @@ -135,8 +137,9 @@ static const char *task_state_array[] =
7730 "D (disk sleep)", /* 2 */
7731 "T (stopped)", /* 4 */
7732 "T (tracing stop)", /* 8 */
7733 - "Z (zombie)", /* 16 */
7734 - "X (dead)" /* 32 */
7735 + "H (on hold)", /* 16 */
7736 + "Z (zombie)", /* 32 */
7737 + "X (dead)", /* 64 */
7740 static inline const char *get_task_state(struct task_struct *tsk)
7741 @@ -288,12 +298,15 @@ static inline char *task_sig(struct task
7743 static inline char *task_cap(struct task_struct *p, char *buffer)
7745 - return buffer + sprintf(buffer, "CapInh:\t%016x\n"
7746 - "CapPrm:\t%016x\n"
7747 - "CapEff:\t%016x\n",
7748 - cap_t(p->cap_inheritable),
7749 - cap_t(p->cap_permitted),
7750 - cap_t(p->cap_effective));
7751 + struct vx_info *vxi = p->vx_info;
7753 + return buffer + sprintf(buffer,
7754 + "CapInh:\t%016x\n"
7755 + "CapPrm:\t%016x\n"
7756 + "CapEff:\t%016x\n",
7757 + (unsigned)vx_info_mbcap(vxi, p->cap_inheritable),
7758 + (unsigned)vx_info_mbcap(vxi, p->cap_permitted),
7759 + (unsigned)vx_info_mbcap(vxi, p->cap_effective));
7762 static inline char *task_context_switch_counts(struct task_struct *p,
7763 @@ -305,10 +318,43 @@ static inline char *task_context_switch_
7767 +int proc_pid_nsproxy(struct task_struct *task, char *buffer)
7769 + return sprintf(buffer, "Proxy:\t%p(%c)\n"
7778 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
7779 + atomic_read(&task->nsproxy->count),
7780 + task->nsproxy->uts_ns,
7781 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
7782 + task->nsproxy->ipc_ns,
7783 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
7784 + task->nsproxy->mnt_ns,
7785 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
7786 + task->nsproxy->pid_ns,
7787 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
7788 + task->nsproxy->user_ns,
7789 + (task->nsproxy->user_ns == init_task.nsproxy->user_ns ? 'I' : '-'),
7790 + task->nsproxy->net_ns,
7791 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
7794 int proc_pid_status(struct task_struct *task, char *buffer)
7796 char *orig = buffer;
7797 struct mm_struct *mm = get_task_mm(task);
7798 +#ifdef CONFIG_VSERVER_LEGACY
7799 + struct vx_info *vxi;
7801 +#ifdef CONFIG_VSERVER_LEGACYNET
7802 + struct nx_info *nxi;
7805 buffer = task_name(task, buffer);
7806 buffer = task_state(task, buffer);
7807 @@ -320,6 +366,46 @@ int proc_pid_status(struct task_struct *
7808 buffer = task_sig(task, buffer);
7809 buffer = task_cap(task, buffer);
7810 buffer = cpuset_task_status_allowed(task, buffer);
7812 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
7814 +#ifdef CONFIG_VSERVER_LEGACY
7815 + buffer += sprintf (buffer,"s_context: %d\n", vx_task_xid(task));
7816 + vxi = task_get_vx_info(task);
7818 + buffer += sprintf (buffer,"ctxflags: %08llx\n"
7819 + ,(unsigned long long)vxi->vx_flags);
7820 + buffer += sprintf (buffer,"initpid: %d\n"
7821 + ,vxi->vx_initpid);
7823 + buffer += sprintf (buffer,"ctxflags: none\n");
7824 + buffer += sprintf (buffer,"initpid: none\n");
7828 + buffer += sprintf (buffer,"VxID: %d\n", vx_task_xid(task));
7830 +#ifdef CONFIG_VSERVER_LEGACYNET
7831 + nxi = task_get_nx_info(task);
7835 + buffer += sprintf (buffer,"ipv4root:");
7836 + for (i=0; i<nxi->nbipv4; i++){
7837 + buffer += sprintf (buffer," %08x/%08x"
7842 + buffer += sprintf (buffer,"ipv4root_bcast: %08x\n"
7845 + buffer += sprintf (buffer,"ipv4root: 0\n");
7846 + buffer += sprintf (buffer,"ipv4root_bcast: 0\n");
7851 #if defined(CONFIG_S390)
7852 buffer = task_show_regs(task, buffer);
7854 @@ -494,6 +580,17 @@ static int do_task_stat(struct task_stru
7855 /* convert nsec -> ticks */
7856 start_time = nsec_to_clock_t(start_time);
7858 + /* fixup start time for virt uptime */
7859 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
7860 + unsigned long long bias =
7861 + current->vx_info->cvirt.bias_clock;
7863 + if (start_time > bias)
7864 + start_time -= bias;
7869 res = sprintf(buffer, "%d (%s) %c %d %d %d %d %d %u %lu \
7870 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
7871 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
7872 diff -NurpP --minimal linux-2.6.24-rc7/fs/proc/base.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/base.c
7873 --- linux-2.6.24-rc7/fs/proc/base.c 2008-01-11 12:00:49 +0100
7874 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/base.c 2008-01-11 04:30:09 +0100
7876 #include <linux/oom.h>
7877 #include <linux/elf.h>
7878 #include <linux/pid_namespace.h>
7879 +#include <linux/vs_context.h>
7880 +#include <linux/vs_network.h>
7881 #include "internal.h"
7884 @@ -1204,6 +1206,8 @@ static struct inode *proc_pid_make_inode
7885 inode->i_uid = task->euid;
7886 inode->i_gid = task->egid;
7888 + /* procfs is xid tagged */
7889 + inode->i_tag = (tag_t)vx_task_xid(task);
7890 security_task_to_inode(task, inode);
7893 @@ -1749,6 +1753,13 @@ static struct dentry *proc_pident_lookup
7897 + /* TODO: maybe we can come up with a generic approach? */
7898 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
7899 + (dentry->d_name.len == 5) &&
7900 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
7901 + !memcmp(dentry->d_name.name, "ninfo", 5)))
7905 * Yes, it does not scale. And it should not. Don't add
7906 * new entries into /proc/<tgid>/ without very good reasons.
7907 @@ -2128,7 +2139,7 @@ out_iput:
7908 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
7910 struct dentry *error;
7911 - struct task_struct *task = get_proc_task(dir);
7912 + struct task_struct *task = get_proc_task_real(dir);
7913 const struct pid_entry *p, *last;
7915 error = ERR_PTR(-ENOENT);
7916 @@ -2193,6 +2204,9 @@ static int proc_pid_io_accounting(struct
7917 static const struct file_operations proc_task_operations;
7918 static const struct inode_operations proc_task_inode_operations;
7920 +extern int proc_pid_vx_info(struct task_struct *, char *);
7921 +extern int proc_pid_nx_info(struct task_struct *, char *);
7923 static const struct pid_entry tgid_base_stuff[] = {
7924 DIR("task", S_IRUGO|S_IXUGO, task),
7925 DIR("fd", S_IRUSR|S_IXUSR, fd),
7926 @@ -2236,6 +2250,8 @@ static const struct pid_entry tgid_base_
7927 #ifdef CONFIG_CGROUPS
7928 REG("cgroup", S_IRUGO, cgroup),
7930 + INF("vinfo", S_IRUGO, pid_vx_info),
7931 + INF("ninfo", S_IRUGO, pid_nx_info),
7932 INF("oom_score", S_IRUGO, oom_score),
7933 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
7934 #ifdef CONFIG_AUDITSYSCALL
7935 @@ -2250,6 +2266,7 @@ static const struct pid_entry tgid_base_
7936 #ifdef CONFIG_TASK_IO_ACCOUNTING
7937 INF("io", S_IRUGO, pid_io_accounting),
7939 + INF("nsproxy", S_IRUGO, pid_nsproxy),
7942 static int proc_tgid_base_readdir(struct file * filp,
7943 @@ -2485,7 +2502,7 @@ static int proc_pid_fill_cache(struct fi
7944 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
7946 unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
7947 - struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
7948 + struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
7949 struct tgid_iter iter;
7950 struct pid_namespace *ns;
7952 @@ -2505,6 +2522,8 @@ int proc_pid_readdir(struct file * filp,
7954 iter.tgid += 1, iter = next_tgid(ns, iter)) {
7955 filp->f_pos = iter.tgid + TGID_OFFSET;
7956 + if (!vx_proc_task_visible(iter.task))
7958 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
7959 put_task_struct(iter.task);
7961 @@ -2636,6 +2655,8 @@ static struct dentry *proc_task_lookup(s
7962 tid = name_to_int(dentry);
7965 + if (vx_current_initpid(tid))
7968 ns = dentry->d_sb->s_fs_info;
7970 diff -NurpP --minimal linux-2.6.24-rc7/fs/proc/generic.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/generic.c
7971 --- linux-2.6.24-rc7/fs/proc/generic.c 2007-12-31 17:58:26 +0100
7972 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/generic.c 2008-01-04 17:52:19 +0100
7974 #include <linux/bitops.h>
7975 #include <linux/spinlock.h>
7976 #include <linux/completion.h>
7977 +#include <linux/vserver/inode.h>
7978 #include <asm/uaccess.h>
7980 #include "internal.h"
7981 @@ -401,11 +402,15 @@ struct dentry *proc_lookup(struct inode
7983 if (de->shadow_proc)
7984 de = de->shadow_proc(current, de);
7985 + if (!vx_hide_check(0, de->vx_flags))
7989 spin_unlock(&proc_subdir_lock);
7991 inode = proc_get_inode(dir->i_sb, ino, de);
7992 + /* generic proc entries belong to the host */
7994 spin_lock(&proc_subdir_lock);
7997 @@ -486,6 +491,8 @@ int proc_readdir(struct file * filp,
7999 /* filldir passes info to user space */
8001 + if (!vx_hide_check(0, de->vx_flags))
8003 spin_unlock(&proc_subdir_lock);
8004 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8005 de->low_ino, de->mode >> 12) < 0) {
8006 @@ -493,6 +500,7 @@ int proc_readdir(struct file * filp,
8009 spin_lock(&proc_subdir_lock);
8014 @@ -590,6 +598,7 @@ static struct proc_dir_entry *proc_creat
8016 atomic_set(&ent->count, 1);
8018 + ent->vx_flags = IATTR_PROC_DEFAULT;
8019 spin_lock_init(&ent->pde_unload_lock);
8020 ent->pde_unload_completion = NULL;
8022 @@ -612,7 +621,8 @@ struct proc_dir_entry *proc_symlink(cons
8028 + ent->vx_flags = IATTR_PROC_SYMLINK;
8032 diff -NurpP --minimal linux-2.6.24-rc7/fs/proc/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/inode.c
8033 --- linux-2.6.24-rc7/fs/proc/inode.c 2007-12-31 17:58:26 +0100
8034 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/inode.c 2007-12-31 12:34:40 +0100
8035 @@ -413,6 +413,8 @@ struct inode *proc_get_inode(struct supe
8036 inode->i_uid = de->uid;
8037 inode->i_gid = de->gid;
8040 + PROC_I(inode)->vx_flags = de->vx_flags;
8042 inode->i_size = de->size;
8044 diff -NurpP --minimal linux-2.6.24-rc7/fs/proc/internal.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/internal.h
8045 --- linux-2.6.24-rc7/fs/proc/internal.h 2008-01-11 12:00:49 +0100
8046 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/internal.h 2008-01-11 04:30:09 +0100
8050 #include <linux/proc_fs.h>
8051 +#include <linux/vs_pid.h>
8053 #ifdef CONFIG_PROC_SYSCTL
8054 extern int proc_sys_init(void);
8055 @@ -52,6 +53,7 @@ extern int proc_tid_stat(struct task_str
8056 extern int proc_tgid_stat(struct task_struct *, char *);
8057 extern int proc_pid_status(struct task_struct *, char *);
8058 extern int proc_pid_statm(struct task_struct *, char *);
8059 +extern int proc_pid_nsproxy(struct task_struct *, char *);
8061 extern const struct file_operations proc_maps_operations;
8062 extern const struct file_operations proc_numa_maps_operations;
8063 @@ -71,11 +73,16 @@ static inline struct pid *proc_pid(struc
8064 return PROC_I(inode)->pid;
8067 -static inline struct task_struct *get_proc_task(struct inode *inode)
8068 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
8070 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
8073 +static inline struct task_struct *get_proc_task(struct inode *inode)
8075 + return vx_get_proc_task(inode, proc_pid(inode));
8078 static inline int proc_fd(struct inode *inode)
8080 return PROC_I(inode)->fd;
8081 diff -NurpP --minimal linux-2.6.24-rc7/fs/proc/proc_misc.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/proc_misc.c
8082 --- linux-2.6.24-rc7/fs/proc/proc_misc.c 2008-01-11 12:00:49 +0100
8083 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/proc_misc.c 2008-01-11 04:30:09 +0100
8085 #include <asm/div64.h>
8086 #include "internal.h"
8088 +#include <linux/vs_cvirt.h>
8090 #define LOAD_INT(x) ((x) >> FSHIFT)
8091 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
8093 @@ -81,17 +83,32 @@ static int proc_calc_metrics(char *page,
8094 static int loadavg_read_proc(char *page, char **start, off_t off,
8095 int count, int *eof, void *data)
8097 + unsigned int running, threads;
8101 - a = avenrun[0] + (FIXED_1/200);
8102 - b = avenrun[1] + (FIXED_1/200);
8103 - c = avenrun[2] + (FIXED_1/200);
8104 - len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
8105 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
8106 + struct vx_info *vxi = current->vx_info;
8108 + a = vxi->cvirt.load[0] + (FIXED_1/200);
8109 + b = vxi->cvirt.load[1] + (FIXED_1/200);
8110 + c = vxi->cvirt.load[2] + (FIXED_1/200);
8112 + running = atomic_read(&vxi->cvirt.nr_running);
8113 + threads = atomic_read(&vxi->cvirt.nr_threads);
8115 + a = avenrun[0] + (FIXED_1/200);
8116 + b = avenrun[1] + (FIXED_1/200);
8117 + c = avenrun[2] + (FIXED_1/200);
8119 + running = nr_running();
8120 + threads = nr_threads;
8122 + len = sprintf(page,"%d.%02d %d.%02d %d.%02d %d/%d %d\n",
8123 LOAD_INT(a), LOAD_FRAC(a),
8124 LOAD_INT(b), LOAD_FRAC(b),
8125 LOAD_INT(c), LOAD_FRAC(c),
8126 - nr_running(), nr_threads,
8128 task_active_pid_ns(current)->last_pid);
8129 return proc_calc_metrics(page, start, off, count, eof, len);
8131 @@ -107,6 +124,9 @@ static int uptime_read_proc(char *page,
8132 do_posix_clock_monotonic_gettime(&uptime);
8133 monotonic_to_bootbased(&uptime);
8134 cputime_to_timespec(idletime, &idle);
8135 + if (vx_flags(VXF_VIRT_UPTIME, 0))
8136 + vx_vsi_uptime(&uptime, &idle);
8138 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
8139 (unsigned long) uptime.tv_sec,
8140 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
8141 @@ -138,7 +158,7 @@ static int meminfo_read_proc(char *page,
8143 cached = global_page_state(NR_FILE_PAGES) -
8144 total_swapcache_pages - i.bufferram;
8146 + if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
8149 get_vmalloc_info(&vmi);
8150 diff -NurpP --minimal linux-2.6.24-rc7/fs/proc/root.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/root.c
8151 --- linux-2.6.24-rc7/fs/proc/root.c 2007-12-31 17:58:26 +0100
8152 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/proc/root.c 2007-12-31 12:34:40 +0100
8154 #include "internal.h"
8156 struct proc_dir_entry *proc_bus, *proc_root_fs, *proc_root_driver;
8157 +struct proc_dir_entry *proc_virtual;
8159 +extern void proc_vx_init(void);
8161 static int proc_test_super(struct super_block *sb, void *data)
8163 @@ -138,6 +141,7 @@ void __init proc_root_init(void)
8164 proc_device_tree_init();
8166 proc_bus = proc_mkdir("bus", NULL);
8171 diff -NurpP --minimal linux-2.6.24-rc7/fs/quota.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/quota.c
8172 --- linux-2.6.24-rc7/fs/quota.c 2007-11-29 01:02:00 +0100
8173 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/quota.c 2007-12-13 13:25:46 +0100
8175 #include <linux/capability.h>
8176 #include <linux/quotaops.h>
8177 #include <linux/types.h>
8178 +#include <linux/vs_context.h>
8180 /* Check validity of generic quotactl commands */
8181 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id)
8182 @@ -82,11 +83,11 @@ static int generic_quotactl_valid(struct
8183 if (cmd == Q_GETQUOTA) {
8184 if (((type == USRQUOTA && current->euid != id) ||
8185 (type == GRPQUOTA && !in_egroup_p(id))) &&
8186 - !capable(CAP_SYS_ADMIN))
8187 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8190 else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
8191 - if (!capable(CAP_SYS_ADMIN))
8192 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8196 @@ -133,10 +134,10 @@ static int xqm_quotactl_valid(struct sup
8197 if (cmd == Q_XGETQUOTA) {
8198 if (((type == XQM_USRQUOTA && current->euid != id) ||
8199 (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
8200 - !capable(CAP_SYS_ADMIN))
8201 + !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8203 } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
8204 - if (!capable(CAP_SYS_ADMIN))
8205 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8209 @@ -329,6 +330,46 @@ static int do_quotactl(struct super_bloc
8213 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8215 +#include <linux/vroot.h>
8216 +#include <linux/major.h>
8217 +#include <linux/module.h>
8218 +#include <linux/kallsyms.h>
8219 +#include <linux/vserver/debug.h>
8221 +static vroot_grb_func *vroot_get_real_bdev = NULL;
8223 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
8225 +int register_vroot_grb(vroot_grb_func *func) {
8228 + spin_lock(&vroot_grb_lock);
8229 + if (!vroot_get_real_bdev) {
8230 + vroot_get_real_bdev = func;
8233 + spin_unlock(&vroot_grb_lock);
8236 +EXPORT_SYMBOL(register_vroot_grb);
8238 +int unregister_vroot_grb(vroot_grb_func *func) {
8239 + int ret = -EINVAL;
8241 + spin_lock(&vroot_grb_lock);
8242 + if (vroot_get_real_bdev) {
8243 + vroot_get_real_bdev = NULL;
8246 + spin_unlock(&vroot_grb_lock);
8249 +EXPORT_SYMBOL(unregister_vroot_grb);
8254 * look up a superblock on which quota ops will be performed
8255 * - use the name of a block device to find the superblock thereon
8256 @@ -346,6 +387,22 @@ static inline struct super_block *quotac
8259 return ERR_PTR(PTR_ERR(bdev));
8260 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8261 + if (bdev && bdev->bd_inode &&
8262 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
8263 + struct block_device *bdnew = (void *)-EINVAL;
8265 + if (vroot_get_real_bdev)
8266 + bdnew = vroot_get_real_bdev(bdev);
8268 + vxdprintk(VXD_CBIT(misc, 0),
8269 + "vroot_get_real_bdev not set");
8271 + if (IS_ERR(bdnew))
8272 + return ERR_PTR(PTR_ERR(bdnew));
8276 sb = get_super(bdev);
8279 diff -NurpP --minimal linux-2.6.24-rc7/fs/reiserfs/bitmap.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/bitmap.c
8280 --- linux-2.6.24-rc7/fs/reiserfs/bitmap.c 2007-11-29 01:11:57 +0100
8281 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/bitmap.c 2007-12-13 13:25:46 +0100
8283 #include <linux/reiserfs_fs_sb.h>
8284 #include <linux/reiserfs_fs_i.h>
8285 #include <linux/quotaops.h>
8286 +#include <linux/vs_dlimit.h>
8288 #define PREALLOCATION_SIZE 9
8290 @@ -429,8 +430,10 @@ static void _reiserfs_free_block(struct
8291 set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
8293 journal_mark_dirty(th, s, sbh);
8294 - if (for_unformatted)
8295 + if (for_unformatted) {
8296 + DLIMIT_FREE_BLOCK(inode, 1);
8297 DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
8301 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
8302 @@ -1045,6 +1048,7 @@ static inline int blocknrs_and_prealloc_
8303 b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
8305 int nr_allocated = 0;
8308 determine_prealloc_size(hint);
8309 if (!hint->formatted_node) {
8310 @@ -1054,19 +1058,30 @@ static inline int blocknrs_and_prealloc_
8311 "reiserquota: allocating %d blocks id=%u",
8312 amount_needed, hint->inode->i_uid);
8315 - DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
8316 - if (quota_ret) /* Quota exceeded? */
8317 + quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
8320 return QUOTA_EXCEEDED;
8321 + if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
8322 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
8324 + return NO_DISK_SPACE;
8327 if (hint->preallocate && hint->prealloc_size) {
8328 #ifdef REISERQUOTA_DEBUG
8329 reiserfs_debug(s, REISERFS_DEBUG_CODE,
8330 "reiserquota: allocating (prealloc) %d blocks id=%u",
8331 hint->prealloc_size, hint->inode->i_uid);
8334 - DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
8335 - hint->prealloc_size);
8336 + quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
8337 + hint->prealloc_size);
8339 + DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
8340 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
8341 + hint->prealloc_size);
8345 hint->preallocate = hint->prealloc_size = 0;
8347 @@ -1098,7 +1113,10 @@ static inline int blocknrs_and_prealloc_
8349 hint->inode->i_uid);
8351 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
8352 + /* Free not allocated blocks */
8353 + blocks = amount_needed + hint->prealloc_size - nr_allocated;
8354 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
8355 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
8357 while (nr_allocated--)
8358 reiserfs_free_block(hint->th, hint->inode,
8359 @@ -1129,10 +1147,10 @@ static inline int blocknrs_and_prealloc_
8360 REISERFS_I(hint->inode)->i_prealloc_count,
8361 hint->inode->i_uid);
8363 - DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
8364 - hint->prealloc_size - nr_allocated -
8365 - REISERFS_I(hint->inode)->
8366 - i_prealloc_count);
8367 + blocks = amount_needed + hint->prealloc_size - nr_allocated -
8368 + REISERFS_I(hint->inode)->i_prealloc_count;
8369 + DLIMIT_FREE_BLOCK(hint->inode, blocks);
8370 + DQUOT_FREE_BLOCK_NODIRTY(hint->inode, blocks);
8374 diff -NurpP --minimal linux-2.6.24-rc7/fs/reiserfs/file.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/file.c
8375 --- linux-2.6.24-rc7/fs/reiserfs/file.c 2007-11-29 01:11:58 +0100
8376 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/file.c 2007-12-13 13:25:39 +0100
8377 @@ -306,4 +306,5 @@ const struct inode_operations reiserfs_f
8378 .listxattr = reiserfs_listxattr,
8379 .removexattr = reiserfs_removexattr,
8380 .permission = reiserfs_permission,
8381 + .sync_flags = reiserfs_sync_flags,
8383 diff -NurpP --minimal linux-2.6.24-rc7/fs/reiserfs/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/inode.c
8384 --- linux-2.6.24-rc7/fs/reiserfs/inode.c 2007-11-29 01:11:58 +0100
8385 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/inode.c 2007-12-13 13:25:46 +0100
8387 #include <linux/writeback.h>
8388 #include <linux/quotaops.h>
8389 #include <linux/swap.h>
8390 +#include <linux/vs_dlimit.h>
8391 +#include <linux/vs_tag.h>
8393 int reiserfs_commit_write(struct file *f, struct page *page,
8394 unsigned from, unsigned to);
8395 @@ -52,6 +54,7 @@ void reiserfs_delete_inode(struct inode
8396 * stat data deletion */
8398 DQUOT_FREE_INODE(inode);
8399 + DLIMIT_FREE_INODE(inode);
8401 if (journal_end(&th, inode->i_sb, jbegin_count))
8403 @@ -1114,6 +1117,8 @@ static void init_inode(struct inode *ino
8404 struct buffer_head *bh;
8405 struct item_head *ih;
8409 //int version = ITEM_VERSION_1;
8411 bh = PATH_PLAST_BUFFER(path);
8412 @@ -1137,12 +1142,13 @@ static void init_inode(struct inode *ino
8413 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
8414 unsigned long blocks;
8416 + uid = sd_v1_uid(sd);
8417 + gid = sd_v1_gid(sd);
8419 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
8420 set_inode_sd_version(inode, STAT_DATA_V1);
8421 inode->i_mode = sd_v1_mode(sd);
8422 inode->i_nlink = sd_v1_nlink(sd);
8423 - inode->i_uid = sd_v1_uid(sd);
8424 - inode->i_gid = sd_v1_gid(sd);
8425 inode->i_size = sd_v1_size(sd);
8426 inode->i_atime.tv_sec = sd_v1_atime(sd);
8427 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
8428 @@ -1184,11 +1190,12 @@ static void init_inode(struct inode *ino
8429 // (directories and symlinks)
8430 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
8432 + uid = sd_v2_uid(sd);
8433 + gid = sd_v2_gid(sd);
8435 inode->i_mode = sd_v2_mode(sd);
8436 inode->i_nlink = sd_v2_nlink(sd);
8437 - inode->i_uid = sd_v2_uid(sd);
8438 inode->i_size = sd_v2_size(sd);
8439 - inode->i_gid = sd_v2_gid(sd);
8440 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
8441 inode->i_atime.tv_sec = sd_v2_atime(sd);
8442 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
8443 @@ -1218,6 +1225,10 @@ static void init_inode(struct inode *ino
8444 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
8447 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8448 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8449 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
8452 if (S_ISREG(inode->i_mode)) {
8453 inode->i_op = &reiserfs_file_inode_operations;
8454 @@ -1240,13 +1251,15 @@ static void init_inode(struct inode *ino
8455 static void inode2sd(void *sd, struct inode *inode, loff_t size)
8457 struct stat_data *sd_v2 = (struct stat_data *)sd;
8458 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
8459 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
8462 + set_sd_v2_uid(sd_v2, uid);
8463 + set_sd_v2_gid(sd_v2, gid);
8464 set_sd_v2_mode(sd_v2, inode->i_mode);
8465 set_sd_v2_nlink(sd_v2, inode->i_nlink);
8466 - set_sd_v2_uid(sd_v2, inode->i_uid);
8467 set_sd_v2_size(sd_v2, size);
8468 - set_sd_v2_gid(sd_v2, inode->i_gid);
8469 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
8470 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
8471 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
8472 @@ -1769,6 +1782,10 @@ int reiserfs_new_inode(struct reiserfs_t
8474 BUG_ON(!th->t_trans_id);
8476 + if (DLIMIT_ALLOC_INODE(inode)) {
8478 + goto out_bad_dlimit;
8480 if (DQUOT_ALLOC_INODE(inode)) {
8483 @@ -1954,6 +1971,9 @@ int reiserfs_new_inode(struct reiserfs_t
8484 DQUOT_FREE_INODE(inode);
8487 + DLIMIT_FREE_INODE(inode);
8490 journal_end(th, th->t_super, th->t_blocks_allocated);
8491 /* Drop can be outside and it needs more credits so it's better to have it outside */
8493 @@ -2848,6 +2868,14 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
8494 inode->i_flags |= S_IMMUTABLE;
8496 inode->i_flags &= ~S_IMMUTABLE;
8497 + if (sd_attrs & REISERFS_IUNLINK_FL)
8498 + inode->i_flags |= S_IUNLINK;
8500 + inode->i_flags &= ~S_IUNLINK;
8501 + if (sd_attrs & REISERFS_BARRIER_FL)
8502 + inode->i_flags |= S_BARRIER;
8504 + inode->i_flags &= ~S_BARRIER;
8505 if (sd_attrs & REISERFS_APPEND_FL)
8506 inode->i_flags |= S_APPEND;
8508 @@ -2870,6 +2898,14 @@ void i_attrs_to_sd_attrs(struct inode *i
8509 *sd_attrs |= REISERFS_IMMUTABLE_FL;
8511 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
8512 + if (inode->i_flags & S_IUNLINK)
8513 + *sd_attrs |= REISERFS_IUNLINK_FL;
8515 + *sd_attrs &= ~REISERFS_IUNLINK_FL;
8516 + if (inode->i_flags & S_BARRIER)
8517 + *sd_attrs |= REISERFS_BARRIER_FL;
8519 + *sd_attrs &= ~REISERFS_BARRIER_FL;
8520 if (inode->i_flags & S_SYNC)
8521 *sd_attrs |= REISERFS_SYNC_FL;
8523 @@ -3049,6 +3085,22 @@ static ssize_t reiserfs_direct_IO(int rw
8524 reiserfs_get_blocks_direct_io, NULL);
8527 +int reiserfs_sync_flags(struct inode *inode)
8529 + u16 oldflags, newflags;
8531 + oldflags = REISERFS_I(inode)->i_attrs;
8532 + newflags = oldflags;
8533 + i_attrs_to_sd_attrs(inode, &newflags);
8535 + if (oldflags ^ newflags) {
8536 + REISERFS_I(inode)->i_attrs = newflags;
8537 + inode->i_ctime = CURRENT_TIME_SEC;
8538 + mark_inode_dirty(inode);
8543 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
8545 struct inode *inode = dentry->d_inode;
8546 @@ -3102,9 +3154,11 @@ int reiserfs_setattr(struct dentry *dent
8549 error = inode_change_ok(inode, attr);
8552 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
8553 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
8554 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
8555 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
8556 error = reiserfs_chown_xattrs(inode, attr);
8559 @@ -3134,6 +3188,9 @@ int reiserfs_setattr(struct dentry *dent
8560 inode->i_uid = attr->ia_uid;
8561 if (attr->ia_valid & ATTR_GID)
8562 inode->i_gid = attr->ia_gid;
8563 + if ((attr->ia_valid & ATTR_TAG) &&
8565 + inode->i_tag = attr->ia_tag;
8566 mark_inode_dirty(inode);
8568 journal_end(&th, inode->i_sb, jbegin_count);
8569 diff -NurpP --minimal linux-2.6.24-rc7/fs/reiserfs/ioctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/ioctl.c
8570 --- linux-2.6.24-rc7/fs/reiserfs/ioctl.c 2007-11-29 01:11:58 +0100
8571 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/ioctl.c 2008-01-11 03:51:21 +0100
8574 #include <linux/capability.h>
8575 #include <linux/fs.h>
8576 +#include <linux/mount.h>
8577 #include <linux/reiserfs_fs.h>
8578 #include <linux/time.h>
8579 #include <asm/uaccess.h>
8580 @@ -24,7 +25,7 @@ static int reiserfs_unpack(struct inode
8581 int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
8584 - unsigned int flags;
8585 + unsigned int flags, oldflags;
8588 case REISERFS_IOC_UNPACK:
8589 @@ -43,12 +44,14 @@ int reiserfs_ioctl(struct inode *inode,
8591 flags = REISERFS_I(inode)->i_attrs;
8592 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
8593 + flags &= REISERFS_FL_USER_VISIBLE;
8594 return put_user(flags, (int __user *)arg);
8595 case REISERFS_IOC_SETFLAGS:{
8596 if (!reiserfs_attrs(inode->i_sb))
8599 - if (IS_RDONLY(inode))
8600 + if (IS_RDONLY(inode) ||
8601 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
8604 if (!is_owner_or_cap(inode))
8605 @@ -74,6 +77,10 @@ int reiserfs_ioctl(struct inode *inode,
8610 + oldflags = REISERFS_I(inode)->i_attrs;
8611 + flags = flags & REISERFS_FL_USER_MODIFIABLE;
8612 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
8613 sd_attrs_to_i_attrs(flags, inode);
8614 REISERFS_I(inode)->i_attrs = flags;
8615 inode->i_ctime = CURRENT_TIME_SEC;
8616 @@ -85,7 +92,8 @@ int reiserfs_ioctl(struct inode *inode,
8617 case REISERFS_IOC_SETVERSION:
8618 if (!is_owner_or_cap(inode))
8620 - if (IS_RDONLY(inode))
8621 + if (IS_RDONLY(inode) ||
8622 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
8624 if (get_user(inode->i_generation, (int __user *)arg))
8626 diff -NurpP --minimal linux-2.6.24-rc7/fs/reiserfs/namei.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/namei.c
8627 --- linux-2.6.24-rc7/fs/reiserfs/namei.c 2007-07-09 13:19:28 +0200
8628 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/namei.c 2007-12-13 13:25:48 +0100
8630 #include <linux/reiserfs_acl.h>
8631 #include <linux/reiserfs_xattr.h>
8632 #include <linux/quotaops.h>
8633 +#include <linux/vs_tag.h>
8635 #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; }
8636 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
8637 @@ -360,6 +361,7 @@ static struct dentry *reiserfs_lookup(st
8638 reiserfs_write_unlock(dir->i_sb);
8639 return ERR_PTR(-EACCES);
8641 + dx_propagate_tag(nd, inode);
8643 /* Propogate the priv_object flag so we know we're in the priv tree */
8644 if (is_reiserfs_priv_object(dir))
8645 @@ -595,6 +597,7 @@ static int new_inode_init(struct inode *
8647 inode->i_gid = current->fsgid;
8649 + inode->i_tag = dx_current_fstag(inode->i_sb);
8653 @@ -1541,6 +1544,7 @@ const struct inode_operations reiserfs_d
8654 .listxattr = reiserfs_listxattr,
8655 .removexattr = reiserfs_removexattr,
8656 .permission = reiserfs_permission,
8657 + .sync_flags = reiserfs_sync_flags,
8661 @@ -1557,6 +1561,7 @@ const struct inode_operations reiserfs_s
8662 .listxattr = reiserfs_listxattr,
8663 .removexattr = reiserfs_removexattr,
8664 .permission = reiserfs_permission,
8665 + .sync_flags = reiserfs_sync_flags,
8669 @@ -1570,5 +1575,6 @@ const struct inode_operations reiserfs_s
8670 .listxattr = reiserfs_listxattr,
8671 .removexattr = reiserfs_removexattr,
8672 .permission = reiserfs_permission,
8673 + .sync_flags = reiserfs_sync_flags,
8676 diff -NurpP --minimal linux-2.6.24-rc7/fs/reiserfs/stree.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/stree.c
8677 --- linux-2.6.24-rc7/fs/reiserfs/stree.c 2007-11-29 01:11:58 +0100
8678 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/stree.c 2007-12-13 13:25:46 +0100
8680 #include <linux/reiserfs_fs.h>
8681 #include <linux/buffer_head.h>
8682 #include <linux/quotaops.h>
8683 +#include <linux/vs_dlimit.h>
8685 /* Does the buffer contain a disk block which is in the tree. */
8686 inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
8687 @@ -1297,6 +1298,7 @@ int reiserfs_delete_item(struct reiserfs
8688 "reiserquota delete_item(): freeing %u, id=%u type=%c",
8689 quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
8691 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
8692 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
8694 /* Return deleted body length */
8695 @@ -1385,6 +1387,7 @@ void reiserfs_delete_solid_item(struct r
8697 DQUOT_FREE_SPACE_NODIRTY(inode,
8699 + DLIMIT_FREE_SPACE(inode, quota_cut_bytes);
8703 @@ -1735,6 +1738,7 @@ int reiserfs_cut_from_item(struct reiser
8704 "reiserquota cut_from_item(): freeing %u id=%u type=%c",
8705 quota_cut_bytes, p_s_inode->i_uid, '?');
8707 + DLIMIT_FREE_SPACE(p_s_inode, quota_cut_bytes);
8708 DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
8711 @@ -1976,6 +1980,11 @@ int reiserfs_paste_into_item(struct reis
8712 pathrelse(p_s_search_path);
8715 + if (DLIMIT_ALLOC_SPACE(inode, n_pasted_size)) {
8716 + DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
8717 + pathrelse(p_s_search_path);
8720 init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
8722 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
8723 @@ -2028,6 +2037,7 @@ int reiserfs_paste_into_item(struct reis
8724 n_pasted_size, inode->i_uid,
8725 key2type(&(p_s_key->on_disk_key)));
8727 + DLIMIT_FREE_SPACE(inode, n_pasted_size);
8728 DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
8731 @@ -2065,6 +2075,11 @@ int reiserfs_insert_item(struct reiserfs
8732 pathrelse(p_s_path);
8735 + if (DLIMIT_ALLOC_SPACE(inode, quota_bytes)) {
8736 + DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
8737 + pathrelse(p_s_path);
8741 init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
8742 IH_SIZE + ih_item_len(p_s_ih));
8743 @@ -2112,7 +2127,9 @@ int reiserfs_insert_item(struct reiserfs
8744 "reiserquota insert_item(): freeing %u id=%u type=%c",
8745 quota_bytes, inode->i_uid, head2type(p_s_ih));
8749 + DLIMIT_FREE_SPACE(inode, quota_bytes);
8750 DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
8754 diff -NurpP --minimal linux-2.6.24-rc7/fs/reiserfs/super.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/super.c
8755 --- linux-2.6.24-rc7/fs/reiserfs/super.c 2007-11-29 01:11:58 +0100
8756 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/super.c 2007-12-13 13:25:38 +0100
8757 @@ -895,6 +895,14 @@ static int reiserfs_parse_options(struct
8758 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
8759 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
8761 +#ifndef CONFIG_TAGGING_NONE
8762 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
8763 + {"tag",.setmask = 1 << REISERFS_TAGGED},
8764 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
8766 +#ifdef CONFIG_PROPAGATE
8767 + {"tag",.arg_required = 'T',.values = NULL},
8769 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
8770 {"acl",.setmask = 1 << REISERFS_POSIXACL},
8771 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
8772 @@ -1156,6 +1164,12 @@ static int reiserfs_remount(struct super
8776 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
8777 + !(s->s_flags & MS_TAGGED)) {
8778 + reiserfs_warning(s, "reiserfs: tagging not permitted on remount.");
8784 /* Add options that are safe here */
8785 @@ -1604,6 +1618,10 @@ static int reiserfs_fill_super(struct su
8789 + /* map mount option tagxid */
8790 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
8791 + s->s_flags |= MS_TAGGED;
8793 rs = SB_DISK_SUPER_BLOCK(s);
8794 /* Let's do basic sanity check to verify that underlying device is not
8795 smaller than the filesystem. If the check fails then abort and scream,
8796 diff -NurpP --minimal linux-2.6.24-rc7/fs/reiserfs/xattr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/xattr.c
8797 --- linux-2.6.24-rc7/fs/reiserfs/xattr.c 2007-11-29 01:11:58 +0100
8798 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/reiserfs/xattr.c 2007-12-13 13:25:47 +0100
8800 #include <linux/namei.h>
8801 #include <linux/errno.h>
8802 #include <linux/fs.h>
8803 +#include <linux/mount.h>
8804 #include <linux/file.h>
8805 #include <linux/pagemap.h>
8806 #include <linux/xattr.h>
8807 @@ -781,7 +782,7 @@ int reiserfs_delete_xattrs(struct inode
8808 if (dir->d_inode->i_nlink <= 2) {
8809 root = get_xa_root(inode->i_sb, XATTR_REPLACE);
8810 reiserfs_write_lock_xattrs(inode->i_sb);
8811 - err = vfs_rmdir(root->d_inode, dir);
8812 + err = vfs_rmdir(root->d_inode, dir, NULL);
8813 reiserfs_write_unlock_xattrs(inode->i_sb);
8816 diff -NurpP --minimal linux-2.6.24-rc7/fs/stat.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/stat.c
8817 --- linux-2.6.24-rc7/fs/stat.c 2007-07-09 13:19:28 +0200
8818 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/stat.c 2007-12-13 13:25:40 +0100
8819 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
8820 stat->nlink = inode->i_nlink;
8821 stat->uid = inode->i_uid;
8822 stat->gid = inode->i_gid;
8823 + stat->tag = inode->i_tag;
8824 stat->rdev = inode->i_rdev;
8825 stat->atime = inode->i_atime;
8826 stat->mtime = inode->i_mtime;
8827 diff -NurpP --minimal linux-2.6.24-rc7/fs/super.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/super.c
8828 --- linux-2.6.24-rc7/fs/super.c 2007-11-29 01:11:58 +0100
8829 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/super.c 2007-12-13 13:25:38 +0100
8831 #include <linux/idr.h>
8832 #include <linux/kobject.h>
8833 #include <linux/mutex.h>
8834 +#include <linux/devpts_fs.h>
8835 +#include <linux/proc_fs.h>
8836 +#include <linux/vs_context.h>
8837 #include <asm/uaccess.h>
8840 @@ -857,12 +860,18 @@ struct vfsmount *
8841 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
8843 struct vfsmount *mnt;
8844 + struct super_block *sb;
8845 char *secdata = NULL;
8849 return ERR_PTR(-ENODEV);
8852 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
8853 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
8857 mnt = alloc_vfsmnt(name);
8859 @@ -883,7 +892,14 @@ vfs_kern_mount(struct file_system_type *
8860 goto out_free_secdata;
8861 BUG_ON(!mnt->mnt_sb);
8863 - error = security_sb_kern_mount(mnt->mnt_sb, secdata);
8866 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
8867 + (sb->s_magic != PROC_SUPER_MAGIC) &&
8868 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
8871 + error = security_sb_kern_mount(sb, secdata);
8875 diff -NurpP --minimal linux-2.6.24-rc7/fs/sysfs/mount.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/sysfs/mount.c
8876 --- linux-2.6.24-rc7/fs/sysfs/mount.c 2007-11-29 01:11:58 +0100
8877 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/sysfs/mount.c 2007-12-13 13:25:51 +0100
8882 -/* Random magic number */
8883 -#define SYSFS_MAGIC 0x62656572
8885 static struct vfsmount *sysfs_mount;
8886 struct super_block * sysfs_sb = NULL;
8887 @@ -46,7 +44,7 @@ static int sysfs_fill_super(struct super
8889 sb->s_blocksize = PAGE_CACHE_SIZE;
8890 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
8891 - sb->s_magic = SYSFS_MAGIC;
8892 + sb->s_magic = SYSFS_SUPER_MAGIC;
8893 sb->s_op = &sysfs_ops;
8894 sb->s_time_gran = 1;
8896 diff -NurpP --minimal linux-2.6.24-rc7/fs/utimes.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/utimes.c
8897 --- linux-2.6.24-rc7/fs/utimes.c 2007-11-29 01:11:58 +0100
8898 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/utimes.c 2007-12-13 13:25:46 +0100
8900 #include <linux/sched.h>
8901 #include <linux/stat.h>
8902 #include <linux/utime.h>
8903 +#include <linux/mount.h>
8904 +#include <linux/vs_cowbl.h>
8905 #include <asm/uaccess.h>
8906 #include <asm/unistd.h>
8908 @@ -83,11 +85,13 @@ long do_utimes(int dfd, char __user *fil
8912 + error = cow_check_and_break(&nd);
8914 + goto dput_and_out;
8918 inode = dentry->d_inode;
8921 if (IS_RDONLY(inode))
8923 diff -NurpP --minimal linux-2.6.24-rc7/fs/xattr.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xattr.c
8924 --- linux-2.6.24-rc7/fs/xattr.c 2007-11-29 01:11:58 +0100
8925 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xattr.c 2007-12-13 13:25:47 +0100
8927 #include <linux/module.h>
8928 #include <linux/fsnotify.h>
8929 #include <linux/audit.h>
8930 +#include <linux/mount.h>
8931 #include <asm/uaccess.h>
8934 @@ -193,7 +194,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
8937 setxattr(struct dentry *d, char __user *name, void __user *value,
8938 - size_t size, int flags)
8939 + size_t size, int flags, struct vfsmount *mnt)
8942 void *kvalue = NULL;
8943 @@ -220,6 +221,9 @@ setxattr(struct dentry *d, char __user *
8947 + if (MNT_IS_RDONLY(mnt))
8950 error = vfs_setxattr(d, kname, kvalue, size, flags);
8953 @@ -235,7 +239,7 @@ sys_setxattr(char __user *path, char __u
8954 error = user_path_walk(path, &nd);
8957 - error = setxattr(nd.dentry, name, value, size, flags);
8958 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
8962 @@ -250,7 +254,7 @@ sys_lsetxattr(char __user *path, char __
8963 error = user_path_walk_link(path, &nd);
8966 - error = setxattr(nd.dentry, name, value, size, flags);
8967 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
8971 @@ -268,7 +272,7 @@ sys_fsetxattr(int fd, char __user *name,
8973 dentry = f->f_path.dentry;
8974 audit_inode(NULL, dentry);
8975 - error = setxattr(dentry, name, value, size, flags);
8976 + error = setxattr(dentry, name, value, size, flags, f->f_vfsmnt);
8980 @@ -432,7 +436,7 @@ sys_flistxattr(int fd, char __user *list
8981 * Extended attribute REMOVE operations
8984 -removexattr(struct dentry *d, char __user *name)
8985 +removexattr(struct dentry *d, char __user *name, struct vfsmount *mnt)
8988 char kname[XATTR_NAME_MAX + 1];
8989 @@ -443,6 +447,9 @@ removexattr(struct dentry *d, char __use
8993 + if (MNT_IS_RDONLY(mnt))
8996 return vfs_removexattr(d, kname);
8999 @@ -455,7 +462,7 @@ sys_removexattr(char __user *path, char
9000 error = user_path_walk(path, &nd);
9003 - error = removexattr(nd.dentry, name);
9004 + error = removexattr(nd.dentry, name, nd.mnt);
9008 @@ -469,7 +476,7 @@ sys_lremovexattr(char __user *path, char
9009 error = user_path_walk_link(path, &nd);
9012 - error = removexattr(nd.dentry, name);
9013 + error = removexattr(nd.dentry, name, nd.mnt);
9017 @@ -486,7 +493,7 @@ sys_fremovexattr(int fd, char __user *na
9019 dentry = f->f_path.dentry;
9020 audit_inode(NULL, dentry);
9021 - error = removexattr(dentry, name);
9022 + error = removexattr(dentry, name, f->f_vfsmnt);
9026 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_ioctl.c
9027 --- linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_ioctl.c 2007-12-31 17:58:26 +0100
9028 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_ioctl.c 2008-01-04 17:40:24 +0100
9029 @@ -1148,7 +1148,8 @@ xfs_merge_ioc_xflags(
9033 - __uint16_t di_flags)
9034 + __uint16_t di_flags,
9035 + __uint16_t di_vflags)
9037 unsigned int flags = 0;
9039 @@ -1162,6 +1163,11 @@ xfs_di2lxflags(
9040 flags |= FS_NOATIME_FL;
9041 if (di_flags & XFS_DIFLAG_NODUMP)
9042 flags |= FS_NODUMP_FL;
9044 + if (di_vflags & XFS_DIVFLAG_IUNLINK)
9045 + flags |= FS_IUNLINK_FL;
9046 + if (di_vflags & XFS_DIVFLAG_BARRIER)
9047 + flags |= FS_BARRIER_FL;
9051 @@ -1243,7 +1249,7 @@ xfs_ioc_xattr(
9054 case XFS_IOC_GETXFLAGS: {
9055 - flags = xfs_di2lxflags(ip->i_d.di_flags);
9056 + flags = xfs_di2lxflags(ip->i_d.di_flags, ip->i_d.di_vflags);
9057 if (copy_to_user(arg, &flags, sizeof(flags)))
9060 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_iops.c
9061 --- linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_iops.c 2007-12-31 17:58:26 +0100
9062 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_iops.c 2008-01-04 17:50:46 +0100
9064 #include <linux/xattr.h>
9065 #include <linux/namei.h>
9066 #include <linux/security.h>
9067 +#include <linux/vs_tag.h>
9070 * Bring the atime in the XFS inode uptodate.
9071 @@ -378,6 +379,7 @@ xfs_vn_lookup(
9072 d_add(dentry, NULL);
9075 + dx_propagate_tag(nd, vn_to_inode(cvp));
9077 return d_splice_alias(vn_to_inode(cvp), dentry);
9079 @@ -595,6 +597,10 @@ xfs_vn_setattr(
9083 + error = inode_change_ok(inode, attr);
9087 if (ia_valid & ATTR_UID) {
9088 vattr.va_mask |= XFS_AT_UID;
9089 vattr.va_uid = attr->ia_uid;
9090 @@ -603,6 +609,10 @@ xfs_vn_setattr(
9091 vattr.va_mask |= XFS_AT_GID;
9092 vattr.va_gid = attr->ia_gid;
9094 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode)) {
9095 + vattr.va_mask |= XFS_AT_TAG;
9096 + vattr.va_tag = attr->ia_tag;
9098 if (ia_valid & ATTR_SIZE) {
9099 vattr.va_mask |= XFS_AT_SIZE;
9100 vattr.va_size = attr->ia_size;
9101 @@ -648,6 +658,42 @@ xfs_vn_truncate(
9105 +xfs_vn_sync_flags(struct inode *inode)
9107 + unsigned int oldflags, newflags;
9110 + bhv_vattr_t vattr;
9111 + bhv_vnode_t *vp = vn_from_inode(inode);
9113 + memset(&vattr, 0, sizeof vattr);
9115 + vattr.va_mask = XFS_AT_XFLAGS;
9116 + error = xfs_getattr(XFS_I(inode), &vattr, 0);
9120 + oldflags = vattr.va_xflags;
9121 + newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
9122 + XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
9124 + if (IS_IMMUTABLE(inode))
9125 + newflags |= XFS_XFLAG_IMMUTABLE;
9126 + if (IS_IUNLINK(inode))
9127 + newflags |= XFS_XFLAG_IUNLINK;
9128 + if (IS_BARRIER(inode))
9129 + newflags |= XFS_XFLAG_BARRIER;
9131 + if (oldflags ^ newflags) {
9132 + vattr.va_xflags = newflags;
9133 + vattr.va_mask |= XFS_AT_XFLAGS;
9134 + error = xfs_setattr(XFS_I(inode), &vattr, flags, NULL);
9136 + vn_revalidate(vp);
9142 struct dentry *dentry,
9144 @@ -760,6 +806,7 @@ const struct inode_operations xfs_inode_
9145 .getxattr = xfs_vn_getxattr,
9146 .listxattr = xfs_vn_listxattr,
9147 .removexattr = xfs_vn_removexattr,
9148 + .sync_flags = xfs_vn_sync_flags,
9151 const struct inode_operations xfs_dir_inode_operations = {
9152 @@ -779,6 +826,7 @@ const struct inode_operations xfs_dir_in
9153 .getxattr = xfs_vn_getxattr,
9154 .listxattr = xfs_vn_listxattr,
9155 .removexattr = xfs_vn_removexattr,
9156 + .sync_flags = xfs_vn_sync_flags,
9159 const struct inode_operations xfs_symlink_inode_operations = {
9160 @@ -792,4 +840,5 @@ const struct inode_operations xfs_symlin
9161 .getxattr = xfs_vn_getxattr,
9162 .listxattr = xfs_vn_listxattr,
9163 .removexattr = xfs_vn_removexattr,
9164 + .sync_flags = xfs_vn_sync_flags,
9166 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_linux.h
9167 --- linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_linux.h 2007-11-29 01:11:58 +0100
9168 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_linux.h 2007-12-13 13:25:48 +0100
9170 #define current_pid() (current->pid)
9171 #define current_fsuid(cred) (current->fsuid)
9172 #define current_fsgid(cred) (current->fsgid)
9173 +#define current_fstag(cred,vp) (dx_current_fstag(vn_to_inode(vp)->i_sb))
9174 #define current_test_flags(f) (current->flags & (f))
9175 #define current_set_flags_nested(sp, f) \
9176 (*(sp) = current->flags, current->flags |= (f))
9177 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_super.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_super.c
9178 --- linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_super.c 2007-11-29 01:11:58 +0100
9179 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_super.c 2008-01-04 17:13:44 +0100
9180 @@ -159,6 +159,7 @@ xfs_revalidate_inode(
9181 inode->i_nlink = ip->i_d.di_nlink;
9182 inode->i_uid = ip->i_d.di_uid;
9183 inode->i_gid = ip->i_d.di_gid;
9184 + inode->i_tag = ip->i_d.di_tag;
9186 switch (inode->i_mode & S_IFMT) {
9188 @@ -182,6 +183,7 @@ xfs_revalidate_inode(
9189 inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
9190 inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec;
9191 inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
9193 if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
9194 inode->i_flags |= S_IMMUTABLE;
9196 @@ -198,6 +200,15 @@ xfs_revalidate_inode(
9197 inode->i_flags |= S_NOATIME;
9199 inode->i_flags &= ~S_NOATIME;
9201 + if (ip->i_d.di_vflags & XFS_DIVFLAG_IUNLINK)
9202 + inode->i_flags |= S_IUNLINK;
9204 + inode->i_flags &= ~S_IUNLINK;
9205 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
9206 + inode->i_flags |= S_BARRIER;
9208 + inode->i_flags &= ~S_BARRIER;
9209 xfs_iflags_clear(ip, XFS_IMODIFIED);
9212 @@ -698,6 +709,12 @@ xfs_fs_remount(
9215 error = xfs_parseargs(mp, options, args, 1);
9216 + if ((args->flags2 & XFSMNT2_TAGGED) &&
9217 + !(sb->s_flags & MS_TAGGED)) {
9218 + printk("XFS: %s: tagging not permitted on remount.\n",
9223 error = xfs_mntupdate(mp, flags, args);
9224 kmem_free(args, sizeof(*args));
9225 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_vnode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_vnode.c
9226 --- linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_vnode.c 2007-11-29 01:11:58 +0100
9227 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_vnode.c 2007-12-13 13:25:40 +0100
9228 @@ -112,6 +112,7 @@ vn_revalidate_core(
9229 inode->i_nlink = vap->va_nlink;
9230 inode->i_uid = vap->va_uid;
9231 inode->i_gid = vap->va_gid;
9232 + inode->i_tag = vap->va_tag;
9233 inode->i_blocks = vap->va_nblocks;
9234 inode->i_mtime = vap->va_mtime;
9235 inode->i_ctime = vap->va_ctime;
9236 @@ -119,6 +120,14 @@ vn_revalidate_core(
9237 inode->i_flags |= S_IMMUTABLE;
9239 inode->i_flags &= ~S_IMMUTABLE;
9240 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
9241 + inode->i_flags |= S_IUNLINK;
9243 + inode->i_flags &= ~S_IUNLINK;
9244 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
9245 + inode->i_flags |= S_BARRIER;
9247 + inode->i_flags &= ~S_BARRIER;
9248 if (vap->va_xflags & XFS_XFLAG_APPEND)
9249 inode->i_flags |= S_APPEND;
9251 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_vnode.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_vnode.h
9252 --- linux-2.6.24-rc7/fs/xfs/linux-2.6/xfs_vnode.h 2007-11-29 01:11:58 +0100
9253 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/linux-2.6/xfs_vnode.h 2007-12-13 13:25:40 +0100
9254 @@ -99,6 +99,7 @@ typedef struct bhv_vattr {
9255 xfs_nlink_t va_nlink; /* number of references to file */
9256 uid_t va_uid; /* owner user id */
9257 gid_t va_gid; /* owner group id */
9258 + tag_t va_tag; /* owner group id */
9259 xfs_ino_t va_nodeid; /* file id */
9260 xfs_off_t va_size; /* file size in bytes */
9261 u_long va_blocksize; /* blocksize preferred for i/o */
9262 @@ -147,13 +148,15 @@ typedef struct bhv_vattr {
9263 #define XFS_AT_PROJID 0x04000000
9264 #define XFS_AT_SIZE_NOPERM 0x08000000
9265 #define XFS_AT_GENCOUNT 0x10000000
9266 +#define XFS_AT_TAG 0x20000000
9268 #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
9269 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
9270 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
9271 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
9272 XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
9273 - XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
9274 + XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT\
9277 #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
9278 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
9279 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/quota/xfs_qm_syscalls.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/quota/xfs_qm_syscalls.c
9280 --- linux-2.6.24-rc7/fs/xfs/quota/xfs_qm_syscalls.c 2007-11-29 01:11:59 +0100
9281 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/quota/xfs_qm_syscalls.c 2007-12-13 13:25:43 +0100
9285 #include <linux/capability.h>
9286 +#include <linux/vs_context.h>
9290 @@ -206,7 +207,7 @@ xfs_qm_scall_quotaoff(
9291 xfs_qoff_logitem_t *qoffstart;
9294 - if (!force && !capable(CAP_SYS_ADMIN))
9295 + if (!force && !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9296 return XFS_ERROR(EPERM);
9298 * No file system can have quotas enabled on disk but not in core.
9299 @@ -375,7 +376,7 @@ xfs_qm_scall_trunc_qfiles(
9303 - if (!capable(CAP_SYS_ADMIN))
9304 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9305 return XFS_ERROR(EPERM);
9307 if (!XFS_SB_VERSION_HASQUOTA(&mp->m_sb) || flags == 0) {
9308 @@ -420,7 +421,7 @@ xfs_qm_scall_quotaon(
9312 - if (!capable(CAP_SYS_ADMIN))
9313 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9314 return XFS_ERROR(EPERM);
9316 flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD);
9317 @@ -589,7 +590,7 @@ xfs_qm_scall_setqlim(
9319 xfs_qcnt_t hard, soft;
9321 - if (!capable(CAP_SYS_ADMIN))
9322 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
9323 return XFS_ERROR(EPERM);
9325 if ((newlim->d_fieldmask &
9326 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/xfs_clnt.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_clnt.h
9327 --- linux-2.6.24-rc7/fs/xfs/xfs_clnt.h 2007-11-29 01:11:59 +0100
9328 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_clnt.h 2007-12-13 13:25:40 +0100
9329 @@ -100,5 +100,6 @@ struct xfs_mount_args {
9330 * I/O size in stat(2) */
9331 #define XFSMNT2_FILESTREAMS 0x00000002 /* enable the filestreams
9333 +#define XFSMNT2_TAGGED 0x80000000 /* context tagging */
9335 #endif /* __XFS_CLNT_H__ */
9336 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/xfs_dinode.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_dinode.h
9337 --- linux-2.6.24-rc7/fs/xfs/xfs_dinode.h 2007-11-29 01:11:59 +0100
9338 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_dinode.h 2008-01-04 17:20:17 +0100
9339 @@ -53,7 +53,9 @@ typedef struct xfs_dinode_core {
9340 __be32 di_gid; /* owner's group id */
9341 __be32 di_nlink; /* number of links to file */
9342 __be16 di_projid; /* owner's project id */
9343 - __u8 di_pad[8]; /* unused, zeroed space */
9344 + __be16 di_tag; /* context tagging */
9345 + __be16 di_vflags; /* vserver specific flags */
9346 + __u8 di_pad[4]; /* unused, zeroed space */
9347 __be16 di_flushiter; /* incremented on flush */
9348 xfs_timestamp_t di_atime; /* time last accessed */
9349 xfs_timestamp_t di_mtime; /* time last modified */
9350 @@ -257,6 +259,7 @@ typedef enum xfs_dinode_fmt
9351 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
9352 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
9353 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
9355 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
9356 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
9357 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
9358 @@ -280,4 +283,7 @@ typedef enum xfs_dinode_fmt
9359 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
9360 XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
9362 +#define XFS_DIVFLAG_BARRIER 0x01
9363 +#define XFS_DIVFLAG_IUNLINK 0x02
9365 #endif /* __XFS_DINODE_H__ */
9366 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/xfs_fs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_fs.h
9367 --- linux-2.6.24-rc7/fs/xfs/xfs_fs.h 2007-11-29 01:11:59 +0100
9368 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_fs.h 2008-01-04 17:19:51 +0100
9369 @@ -67,6 +67,8 @@ struct fsxattr {
9370 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
9371 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
9372 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
9373 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
9374 +#define XFS_XFLAG_IUNLINK 0x20000000 /* immutable unlink */
9375 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
9378 @@ -296,7 +298,8 @@ typedef struct xfs_bstat {
9379 __s32 bs_extents; /* number of extents */
9380 __u32 bs_gen; /* generation count */
9381 __u16 bs_projid; /* project id */
9382 - unsigned char bs_pad[14]; /* pad space, unused */
9383 + __u16 bs_tag; /* context tagging */
9384 + unsigned char bs_pad[12]; /* pad space, unused */
9385 __u32 bs_dmevmask; /* DMIG event mask */
9386 __u16 bs_dmstate; /* DMIG state info */
9387 __u16 bs_aextents; /* attribute number of extents */
9388 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/xfs_inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_inode.c
9389 --- linux-2.6.24-rc7/fs/xfs/xfs_inode.c 2007-12-31 17:58:27 +0100
9390 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_inode.c 2008-01-04 17:33:16 +0100
9391 @@ -217,6 +217,7 @@ xfs_inotobp(
9395 +#include <linux/vs_tag.h>
9398 * This routine is called to map an inode to the buffer containing
9399 @@ -781,7 +782,8 @@ xfs_dinode_to_disk(
9403 - __uint16_t di_flags)
9404 + __uint16_t di_flags,
9405 + __uint16_t di_vflags)
9409 @@ -815,7 +817,10 @@ _xfs_dic2xflags(
9410 if (di_flags & XFS_DIFLAG_FILESTREAM)
9411 flags |= XFS_XFLAG_FILESTREAM;
9414 + if (di_vflags & XFS_DIVFLAG_IUNLINK)
9415 + flags |= XFS_XFLAG_IUNLINK;
9416 + if (di_vflags & XFS_DIVFLAG_BARRIER)
9417 + flags |= XFS_XFLAG_BARRIER;
9421 @@ -825,7 +830,7 @@ xfs_ip2xflags(
9423 xfs_icdinode_t *dic = &ip->i_d;
9425 - return _xfs_dic2xflags(dic->di_flags) |
9426 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
9427 (XFS_CFORK_Q(dic) ? XFS_XFLAG_HASATTR : 0);
9430 @@ -833,7 +838,7 @@ uint
9432 xfs_dinode_core_t *dic)
9434 - return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) |
9435 + return _xfs_dic2xflags(be16_to_cpu(dic->di_flags), be16_to_cpu(dic->di_vflags)) |
9436 (XFS_CFORK_Q_DISK(dic) ? XFS_XFLAG_HASATTR : 0);
9439 @@ -1134,6 +1139,7 @@ xfs_ialloc(
9440 ASSERT(ip->i_d.di_nlink == nlink);
9441 ip->i_d.di_uid = current_fsuid(cr);
9442 ip->i_d.di_gid = current_fsgid(cr);
9443 + ip->i_d.di_tag = current_fstag(cr, vp);
9444 ip->i_d.di_projid = prid;
9445 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
9447 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/xfs_inode.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_inode.h
9448 --- linux-2.6.24-rc7/fs/xfs/xfs_inode.h 2007-11-29 01:11:59 +0100
9449 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_inode.h 2008-01-04 17:27:01 +0100
9450 @@ -226,7 +226,9 @@ typedef struct xfs_icdinode {
9451 __uint32_t di_gid; /* owner's group id */
9452 __uint32_t di_nlink; /* number of links to file */
9453 __uint16_t di_projid; /* owner's project id */
9454 - __uint8_t di_pad[8]; /* unused, zeroed space */
9455 + __uint16_t di_tag; /* context tagging */
9456 + __uint16_t di_vflags; /* vserver specific flags */
9457 + __uint8_t di_pad[4]; /* unused, zeroed space */
9458 __uint16_t di_flushiter; /* incremented on flush */
9459 xfs_ictimestamp_t di_atime; /* time last accessed */
9460 xfs_ictimestamp_t di_mtime; /* time last modified */
9461 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/xfs_itable.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_itable.c
9462 --- linux-2.6.24-rc7/fs/xfs/xfs_itable.c 2007-12-31 17:58:27 +0100
9463 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_itable.c 2007-12-31 12:34:41 +0100
9464 @@ -89,6 +89,7 @@ xfs_bulkstat_one_iget(
9465 buf->bs_mode = dic->di_mode;
9466 buf->bs_uid = dic->di_uid;
9467 buf->bs_gid = dic->di_gid;
9468 + buf->bs_tag = dic->di_tag;
9469 buf->bs_size = dic->di_size;
9470 vn_atime_to_bstime(vp, &buf->bs_atime);
9471 buf->bs_mtime.tv_sec = dic->di_mtime.t_sec;
9472 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/xfs_mount.h linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_mount.h
9473 --- linux-2.6.24-rc7/fs/xfs/xfs_mount.h 2007-11-29 01:11:59 +0100
9474 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_mount.h 2007-12-13 13:25:40 +0100
9475 @@ -480,6 +480,7 @@ typedef struct xfs_mount {
9476 #define XFS_MOUNT_FILESTREAMS (1ULL << 24) /* enable the filestreams
9479 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
9482 * Default minimum read and write sizes.
9483 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/xfs_vfsops.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_vfsops.c
9484 --- linux-2.6.24-rc7/fs/xfs/xfs_vfsops.c 2007-11-29 01:11:59 +0100
9485 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_vfsops.c 2008-01-04 17:39:18 +0100
9486 @@ -301,6 +301,8 @@ xfs_start_flags(
9488 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
9489 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
9490 + if (ap->flags2 & XFSMNT2_TAGGED)
9491 + mp->m_flags |= XFS_MOUNT_TAGGED;
9494 * no recovery flag requires a read-only mount
9495 @@ -415,6 +417,9 @@ xfs_finish_flags(
9496 mp->m_qflags |= XFS_OQUOTA_ENFD;
9499 + if (ap->flags2 & XFSMNT2_TAGGED)
9500 + mp->m_flags |= MS_TAGGED;
9501 + /* vfs->vfs_super->s_flags |= */
9505 @@ -1729,6 +1734,10 @@ xfs_vget(
9506 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
9507 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
9509 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
9510 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
9511 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
9513 STATIC unsigned long
9514 suffix_strtoul(char *s, char **endp, unsigned int base)
9516 @@ -1936,6 +1945,19 @@ xfs_parseargs(
9517 args->flags |= XFSMNT_DMAPI;
9518 } else if (!strcmp(this_char, MNTOPT_DMI)) {
9519 args->flags |= XFSMNT_DMAPI;
9520 +#ifndef CONFIG_TAGGING_NONE
9521 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9522 + args->flags2 |= XFSMNT2_TAGGED;
9523 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
9524 + args->flags2 &= ~XFSMNT2_TAGGED;
9525 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
9526 + args->flags2 |= XFSMNT2_TAGGED;
9528 +#ifdef CONFIG_PROPAGATE
9529 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9531 + args->flags2 |= XFSMNT2_TAGGED;
9533 } else if (!strcmp(this_char, "ihashsize")) {
9535 "XFS: ihashsize no longer used, option is deprecated.");
9536 diff -NurpP --minimal linux-2.6.24-rc7/fs/xfs/xfs_vnodeops.c linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_vnodeops.c
9537 --- linux-2.6.24-rc7/fs/xfs/xfs_vnodeops.c 2007-11-29 01:11:59 +0100
9538 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/fs/xfs/xfs_vnodeops.c 2008-01-04 17:17:40 +0100
9539 @@ -122,6 +122,7 @@ xfs_getattr(
9540 vap->va_mode = ip->i_d.di_mode;
9541 vap->va_uid = ip->i_d.di_uid;
9542 vap->va_gid = ip->i_d.di_gid;
9543 + vap->va_tag = ip->i_d.di_tag;
9544 vap->va_projid = ip->i_d.di_projid;
9547 @@ -221,6 +222,7 @@ xfs_setattr(
9548 uint commit_flags=0;
9549 uid_t uid=0, iuid=0;
9550 gid_t gid=0, igid=0;
9551 + tag_t tag=0, itag=0;
9553 xfs_prid_t projid=0, iprojid=0;
9554 int mandlock_before, mandlock_after;
9555 @@ -272,6 +274,7 @@ xfs_setattr(
9556 (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID))) {
9559 + /* TODO: handle tagging? */
9560 if ((mask & XFS_AT_UID) && XFS_IS_UQUOTA_ON(mp)) {
9562 qflags |= XFS_QMOPT_UQUOTA;
9563 @@ -351,6 +354,8 @@ xfs_setattr(
9565 (XFS_AT_MODE|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_UID|
9566 XFS_AT_GID|XFS_AT_PROJID)) {
9567 + /* TODO: handle tagging? */
9570 * CAP_FOWNER overrides the following restrictions:
9572 @@ -399,7 +404,7 @@ xfs_setattr(
9573 * and can change the group id only to a group of which he
9574 * or she is a member.
9576 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
9577 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
9579 * These IDs could have changed since we last looked at them.
9580 * But, we're assured that if the ownership did change
9581 @@ -407,10 +412,12 @@ xfs_setattr(
9582 * would have changed also.
9584 iuid = ip->i_d.di_uid;
9585 - iprojid = ip->i_d.di_projid;
9586 igid = ip->i_d.di_gid;
9587 - gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
9588 + itag = ip->i_d.di_tag;
9589 + iprojid = ip->i_d.di_projid;
9590 uid = (mask & XFS_AT_UID) ? vap->va_uid : iuid;
9591 + gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
9592 + tag = (mask & XFS_AT_TAG) ? vap->va_tag : itag;
9593 projid = (mask & XFS_AT_PROJID) ? (xfs_prid_t)vap->va_projid :
9596 @@ -438,6 +445,7 @@ xfs_setattr(
9597 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
9598 (XFS_IS_PQUOTA_ON(mp) && iprojid != projid) ||
9599 (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
9600 + /* TODO: handle tagging? */
9602 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
9603 capable(CAP_FOWNER) ?
9604 @@ -686,7 +694,7 @@ xfs_setattr(
9605 * and can change the group id only to a group of which he
9606 * or she is a member.
9608 - if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
9609 + if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_TAG|XFS_AT_PROJID)) {
9611 * CAP_FSETID overrides the following restrictions:
9613 @@ -702,6 +710,9 @@ xfs_setattr(
9614 * Change the ownerships and register quota modifications
9615 * in the transaction.
9617 + if (itag != tag) {
9618 + ip->i_d.di_tag = tag;
9621 if (XFS_IS_UQUOTA_ON(mp)) {
9622 ASSERT(mask & XFS_AT_UID);
9623 @@ -777,6 +788,7 @@ xfs_setattr(
9625 if (mask & XFS_AT_XFLAGS) {
9627 + uint di_vflags = 0;
9629 /* can't set PREALLOC this way, just preserve it */
9630 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
9631 @@ -814,6 +826,11 @@ xfs_setattr(
9632 di_flags |= XFS_DIFLAG_EXTSIZE;
9634 ip->i_d.di_flags = di_flags;
9635 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
9636 + di_vflags |= XFS_DIVFLAG_IUNLINK;
9637 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
9638 + di_vflags |= XFS_DIVFLAG_BARRIER;
9639 + ip->i_d.di_vflags = di_vflags;
9641 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
9642 timeflags |= XFS_ICHGTIME_CHG;
9643 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-arm/tlb.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-arm/tlb.h
9644 --- linux-2.6.24-rc7/include/asm-arm/tlb.h 2006-06-18 04:54:58 +0200
9645 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-arm/tlb.h 2007-12-13 13:25:12 +0100
9647 #else /* !CONFIG_MMU */
9649 #include <asm/pgalloc.h>
9650 +#include <linux/vs_memory.h>
9653 * TLB handling. This allows us to remove pages from the page
9654 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-blackfin/unistd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-blackfin/unistd.h
9655 --- linux-2.6.24-rc7/include/asm-blackfin/unistd.h 2007-11-29 01:02:07 +0100
9656 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-blackfin/unistd.h 2007-12-15 02:23:02 +0100
9658 #define __NR_tgkill 271
9659 #define __NR_utimes 272
9660 #define __NR_fadvise64_64 273
9661 - /* 274 __NR_vserver */
9662 +#define __NR_vserver 274
9663 /* 275 __NR_mbind */
9664 /* 276 __NR_get_mempolicy */
9665 /* 277 __NR_set_mempolicy */
9666 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-generic/tlb.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-generic/tlb.h
9667 --- linux-2.6.24-rc7/include/asm-generic/tlb.h 2008-01-11 12:00:49 +0100
9668 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-generic/tlb.h 2008-01-11 04:30:09 +0100
9671 #include <linux/swap.h>
9672 #include <linux/quicklist.h>
9673 +#include <linux/vs_memory.h>
9674 #include <asm/pgalloc.h>
9675 #include <asm/tlbflush.h>
9677 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-ia64/tlb.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-ia64/tlb.h
9678 --- linux-2.6.24-rc7/include/asm-ia64/tlb.h 2006-09-20 16:58:40 +0200
9679 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-ia64/tlb.h 2007-12-13 13:25:12 +0100
9681 #include <linux/mm.h>
9682 #include <linux/pagemap.h>
9683 #include <linux/swap.h>
9684 +#include <linux/vs_memory.h>
9686 #include <asm/pgalloc.h>
9687 #include <asm/processor.h>
9688 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-powerpc/systbl.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-powerpc/systbl.h
9689 --- linux-2.6.24-rc7/include/asm-powerpc/systbl.h 2007-11-29 01:12:13 +0100
9690 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-powerpc/systbl.h 2007-12-13 13:25:28 +0100
9691 @@ -260,7 +260,7 @@ COMPAT_SYS_SPU(fstatfs64)
9692 SYSX(sys_ni_syscall, ppc_fadvise64_64, ppc_fadvise64_64)
9694 OLDSYS(debug_setcontext)
9695 -SYSCALL(ni_syscall)
9696 +SYSX(sys_vserver, sys32_vserver, sys_vserver)
9697 COMPAT_SYS(migrate_pages)
9699 COMPAT_SYS(get_mempolicy)
9700 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-powerpc/unistd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-powerpc/unistd.h
9701 --- linux-2.6.24-rc7/include/asm-powerpc/unistd.h 2007-11-29 01:02:13 +0100
9702 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-powerpc/unistd.h 2007-12-13 13:25:28 +0100
9705 #define __NR_rtas 255
9706 #define __NR_sys_debug_setcontext 256
9707 -/* Number 257 is reserved for vserver */
9708 +#define __NR_vserver 257
9709 #define __NR_migrate_pages 258
9710 #define __NR_mbind 259
9711 #define __NR_get_mempolicy 260
9712 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-s390/unistd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-s390/unistd.h
9713 --- linux-2.6.24-rc7/include/asm-s390/unistd.h 2007-11-29 01:02:13 +0100
9714 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-s390/unistd.h 2007-12-13 13:25:28 +0100
9716 #define __NR_clock_gettime (__NR_timer_create+6)
9717 #define __NR_clock_getres (__NR_timer_create+7)
9718 #define __NR_clock_nanosleep (__NR_timer_create+8)
9719 -/* Number 263 is reserved for vserver */
9720 +#define __NR_vserver 263
9721 #define __NR_statfs64 265
9722 #define __NR_fstatfs64 266
9723 #define __NR_remap_file_pages 267
9724 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-sparc/unistd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-sparc/unistd.h
9725 --- linux-2.6.24-rc7/include/asm-sparc/unistd.h 2007-12-31 17:58:28 +0100
9726 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-sparc/unistd.h 2007-12-31 12:34:42 +0100
9728 #define __NR_timer_getoverrun 264
9729 #define __NR_timer_delete 265
9730 #define __NR_timer_create 266
9731 -/* #define __NR_vserver 267 Reserved for VSERVER */
9732 +#define __NR_vserver 267
9733 #define __NR_io_setup 268
9734 #define __NR_io_destroy 269
9735 #define __NR_io_submit 270
9736 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-sparc64/tlb.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-sparc64/tlb.h
9737 --- linux-2.6.24-rc7/include/asm-sparc64/tlb.h 2007-07-09 13:19:54 +0200
9738 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-sparc64/tlb.h 2007-12-13 13:25:12 +0100
9741 #include <linux/swap.h>
9742 #include <linux/pagemap.h>
9743 +#include <linux/vs_memory.h>
9744 #include <asm/pgalloc.h>
9745 #include <asm/tlbflush.h>
9746 #include <asm/mmu_context.h>
9747 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-sparc64/unistd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-sparc64/unistd.h
9748 --- linux-2.6.24-rc7/include/asm-sparc64/unistd.h 2007-11-29 01:02:14 +0100
9749 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-sparc64/unistd.h 2007-12-13 13:25:28 +0100
9751 #define __NR_timer_getoverrun 264
9752 #define __NR_timer_delete 265
9753 #define __NR_timer_create 266
9754 -/* #define __NR_vserver 267 Reserved for VSERVER */
9755 +#define __NR_vserver 267
9756 #define __NR_io_setup 268
9757 #define __NR_io_destroy 269
9758 #define __NR_io_submit 270
9759 diff -NurpP --minimal linux-2.6.24-rc7/include/asm-x86/unistd_64.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-x86/unistd_64.h
9760 --- linux-2.6.24-rc7/include/asm-x86/unistd_64.h 2007-11-29 01:12:18 +0100
9761 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/asm-x86/unistd_64.h 2007-12-15 02:12:26 +0100
9762 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
9763 #define __NR_utimes 235
9764 __SYSCALL(__NR_utimes, sys_utimes)
9765 #define __NR_vserver 236
9766 -__SYSCALL(__NR_vserver, sys_ni_syscall)
9767 +__SYSCALL(__NR_vserver, sys_vserver)
9768 #define __NR_mbind 237
9769 __SYSCALL(__NR_mbind, sys_mbind)
9770 #define __NR_set_mempolicy 238
9771 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/Kbuild linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/Kbuild
9772 --- linux-2.6.24-rc7/include/linux/Kbuild 2008-01-11 12:00:49 +0100
9773 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/Kbuild 2008-01-11 04:30:10 +0100
9774 @@ -356,3 +356,6 @@ unifdef-y += xattr.h
9777 objhdr-y += version.h
9779 +header-y += vserver/
9781 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/capability.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/capability.h
9782 --- linux-2.6.24-rc7/include/linux/capability.h 2007-11-29 01:12:23 +0100
9783 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/capability.h 2007-12-13 13:25:26 +0100
9784 @@ -252,6 +252,7 @@ typedef __u32 kernel_cap_t;
9785 arbitrary SCSI commands */
9786 /* Allow setting encryption key on loopback filesystem */
9787 /* Allow setting zone reclaim policy */
9788 +/* Allow the selection of a security context */
9790 #define CAP_SYS_ADMIN 21
9792 @@ -307,6 +308,11 @@ typedef __u32 kernel_cap_t;
9794 #define CAP_SETFCAP 31
9796 +/* Allow context manipulations */
9797 +/* Allow changing context info on files */
9799 +#define CAP_CONTEXT 31
9804 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/devpts_fs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/devpts_fs.h
9805 --- linux-2.6.24-rc7/include/linux/devpts_fs.h 2004-08-14 12:55:59 +0200
9806 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/devpts_fs.h 2007-12-13 13:25:51 +0100
9807 @@ -30,5 +30,7 @@ static inline void devpts_pty_kill(int n
9811 +#define DEVPTS_SUPER_MAGIC 0x00001cd1
9814 #endif /* _LINUX_DEVPTS_FS_H */
9815 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/ext2_fs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/ext2_fs.h
9816 --- linux-2.6.24-rc7/include/linux/ext2_fs.h 2007-12-31 17:58:28 +0100
9817 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/ext2_fs.h 2007-12-31 12:34:42 +0100
9818 @@ -189,6 +189,8 @@ struct ext2_group_desc
9819 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
9820 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
9821 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
9822 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
9823 +#define EXT2_IUNLINK_FL FS_IUNLINK_FL /* Immutable unlink */
9824 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
9826 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
9827 @@ -247,7 +249,7 @@ struct ext2_inode {
9829 __u8 l_i_frag; /* Fragment number */
9830 __u8 l_i_fsize; /* Fragment size */
9832 + __u16 l_i_tag; /* Context Tag */
9833 __le16 l_i_uid_high; /* these 2 fields */
9834 __le16 l_i_gid_high; /* were reserved2[0] */
9835 __u32 l_i_reserved2;
9836 @@ -279,6 +281,7 @@ struct ext2_inode {
9837 #define i_gid_low i_gid
9838 #define i_uid_high osd2.linux2.l_i_uid_high
9839 #define i_gid_high osd2.linux2.l_i_gid_high
9840 +#define i_raw_tag osd2.linux2.l_i_tag
9841 #define i_reserved2 osd2.linux2.l_i_reserved2
9844 @@ -323,6 +326,7 @@ struct ext2_inode {
9845 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
9846 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
9847 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
9848 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
9851 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
9852 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/ext3_fs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/ext3_fs.h
9853 --- linux-2.6.24-rc7/include/linux/ext3_fs.h 2007-11-29 01:12:23 +0100
9854 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/ext3_fs.h 2007-12-13 13:25:40 +0100
9855 @@ -173,10 +173,20 @@ struct ext3_group_desc
9856 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
9857 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
9858 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
9859 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
9860 +#define EXT3_IUNLINK_FL 0x08000000 /* Immutable unlink */
9861 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
9863 +#ifdef CONFIG_VSERVER_LEGACY
9864 +#define EXT3_FL_USER_VISIBLE 0x0803DFFF /* User visible flags */
9865 +#define EXT3_FL_USER_MODIFIABLE 0x080380FF /* User modifiable flags */
9867 #define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
9868 #define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
9870 +#ifdef CONFIG_VSERVER_LEGACY
9871 +#define EXT3_IOC_SETTAG FIOC_SETTAGJ
9875 * Inode dynamic state flags
9876 @@ -292,7 +302,7 @@ struct ext3_inode {
9878 __u8 l_i_frag; /* Fragment number */
9879 __u8 l_i_fsize; /* Fragment size */
9881 + __u16 l_i_tag; /* Context Tag */
9882 __le16 l_i_uid_high; /* these 2 fields */
9883 __le16 l_i_gid_high; /* were reserved2[0] */
9884 __u32 l_i_reserved2;
9885 @@ -326,6 +336,7 @@ struct ext3_inode {
9886 #define i_gid_low i_gid
9887 #define i_uid_high osd2.linux2.l_i_uid_high
9888 #define i_gid_high osd2.linux2.l_i_gid_high
9889 +#define i_raw_tag osd2.linux2.l_i_tag
9890 #define i_reserved2 osd2.linux2.l_i_reserved2
9892 #elif defined(__GNU__)
9893 @@ -380,6 +391,7 @@ struct ext3_inode {
9894 #define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
9895 #define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
9896 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
9897 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
9899 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
9900 #ifndef _LINUX_EXT2_FS_H
9901 @@ -822,6 +834,7 @@ struct buffer_head * ext3_bread (handle_
9902 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
9903 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
9904 int create, int extend_disksize);
9905 +extern int ext3_sync_flags(struct inode *inode);
9907 extern void ext3_read_inode (struct inode *);
9908 extern int ext3_write_inode (struct inode *, int);
9909 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/ext4_fs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/ext4_fs.h
9910 --- linux-2.6.24-rc7/include/linux/ext4_fs.h 2007-11-29 01:12:23 +0100
9911 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/ext4_fs.h 2007-12-13 13:25:40 +0100
9912 @@ -178,11 +178,21 @@ struct ext4_group_desc
9913 #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
9914 #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
9915 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
9916 -#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
9917 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
9918 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
9919 +#define EXT4_IUNLINK_FL 0x08000000 /* Immutable unlink */
9920 +#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
9922 +#ifdef CONFIG_VSERVER_LEGACY
9923 +#define EXT4_FL_USER_VISIBLE 0x080BDFFF /* User visible flags */
9924 +#define EXT4_FL_USER_MODIFIABLE 0x080380FF /* User modifiable flags */
9926 #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
9927 #define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
9929 +#ifdef CONFIG_VSERVER_LEGACY
9930 +#define EXT4_IOC_SETTAG FIOC_SETTAGJ
9934 * Inode dynamic state flags
9935 @@ -306,7 +316,8 @@ struct ext4_inode {
9936 __le16 l_i_file_acl_high;
9937 __le16 l_i_uid_high; /* these 2 fields */
9938 __le16 l_i_gid_high; /* were reserved2[0] */
9939 - __u32 l_i_reserved2;
9940 + __u16 l_i_tag; /* Context Tag */
9941 + __u16 l_i_reserved2;
9944 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
9945 @@ -409,6 +420,7 @@ do { \
9946 #define i_gid_low i_gid
9947 #define i_uid_high osd2.linux2.l_i_uid_high
9948 #define i_gid_high osd2.linux2.l_i_gid_high
9949 +#define i_raw_tag osd2.linux2.l_i_tag
9950 #define i_reserved2 osd2.linux2.l_i_reserved2
9952 #elif defined(__GNU__)
9953 @@ -461,6 +473,7 @@ do { \
9954 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
9955 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
9956 #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
9957 +#define EXT4_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
9959 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
9960 #ifndef _LINUX_EXT2_FS_H
9961 @@ -920,6 +933,7 @@ struct buffer_head * ext4_bread (handle_
9962 int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
9963 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
9964 int create, int extend_disksize);
9965 +extern int ext4_sync_flags(struct inode *inode);
9967 extern void ext4_read_inode (struct inode *);
9968 extern int ext4_write_inode (struct inode *, int);
9969 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/fs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/fs.h
9970 --- linux-2.6.24-rc7/include/linux/fs.h 2007-11-29 01:12:23 +0100
9971 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/fs.h 2007-12-13 13:25:51 +0100
9972 @@ -124,6 +124,8 @@ extern int dir_notify_enable;
9973 #define MS_SHARED (1<<20) /* change to shared */
9974 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
9975 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
9976 +#define MS_TAGGED (1<<24) /* use generic inode tagging */
9977 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
9978 #define MS_ACTIVE (1<<30)
9979 #define MS_NOUSER (1<<31)
9981 @@ -150,6 +152,8 @@ extern int dir_notify_enable;
9982 #define S_NOCMTIME 128 /* Do not update file c/mtime */
9983 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
9984 #define S_PRIVATE 512 /* Inode is fs-internal */
9985 +#define S_BARRIER 1024 /* Barrier for chroot() */
9986 +#define S_IUNLINK 2048 /* Immutable unlink */
9989 * Note that nosuid etc flags are inode-specific: setting some file-system
9990 @@ -166,24 +170,36 @@ extern int dir_notify_enable;
9992 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
9994 -#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
9995 +#define IS_RDONLY(inode) __IS_FLG(inode, MS_RDONLY)
9996 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
9997 ((inode)->i_flags & S_SYNC))
9998 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
9999 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
10000 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
10001 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10002 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10003 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
10005 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
10006 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
10007 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
10008 +#define IS_IUNLINK(inode) ((inode)->i_flags & S_IUNLINK)
10009 +#define IS_IXORUNLINK(inode) ((IS_IUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
10010 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
10012 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_flags & S_BARRIER))
10013 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
10014 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
10015 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
10016 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
10018 +#ifdef CONFIG_VSERVER_COWBL
10019 +# define IS_COW(inode) (IS_IUNLINK(inode) && IS_IMMUTABLE(inode))
10020 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
10022 +# define IS_COW(inode) (0)
10023 +# define IS_COW_LINK(inode) (0)
10026 /* the read-only stuff doesn't really belong here, but any other place is
10027 probably as bad and I don't want to create yet another include file. */
10029 @@ -257,11 +273,17 @@ extern int dir_notify_enable;
10030 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
10031 #define FS_EXTENT_FL 0x00080000 /* Extents */
10032 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
10033 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
10034 +#define FS_IUNLINK_FL 0x08000000 /* Immutable unlink */
10035 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
10037 +#ifdef CONFIG_VSERVER_LEGACY
10038 +#define FS_FL_USER_VISIBLE 0x0803DFFF /* User visible flags */
10039 +#define FS_FL_USER_MODIFIABLE 0x080380FF /* User modifiable flags */
10041 #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
10042 #define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
10046 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
10047 #define SYNC_FILE_RANGE_WRITE 2
10048 @@ -332,6 +354,7 @@ typedef void (dio_iodone_t)(struct kiocb
10049 #define ATTR_FILE 8192
10050 #define ATTR_KILL_PRIV 16384
10051 #define ATTR_OPEN 32768 /* Truncating from open(O_TRUNC) */
10052 +#define ATTR_TAG 65536
10055 * This is the Inode Attributes structure, used for notify_change(). It
10056 @@ -347,6 +370,7 @@ struct iattr {
10062 struct timespec ia_atime;
10063 struct timespec ia_mtime;
10064 @@ -360,6 +384,9 @@ struct iattr {
10065 struct file *ia_file;
10068 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
10069 +#define ATTR_FLAG_IUNLINK 1024 /* Immutable unlink */
10072 * Includes for diskquotas.
10074 @@ -598,6 +625,7 @@ struct inode {
10075 unsigned int i_nlink;
10080 unsigned long i_version;
10082 @@ -793,6 +821,7 @@ struct file {
10084 struct fown_struct f_owner;
10085 unsigned int f_uid, f_gid;
10087 struct file_ra_state f_ra;
10090 @@ -876,6 +905,7 @@ struct file_lock {
10091 unsigned char fl_type;
10096 struct fasync_struct * fl_fasync; /* for lease break notifications */
10097 unsigned long fl_break_time; /* for nonblocking lease breaks */
10098 @@ -1068,12 +1098,12 @@ extern void unlock_super(struct super_bl
10100 extern int vfs_permission(struct nameidata *, int);
10101 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
10102 -extern int vfs_mkdir(struct inode *, struct dentry *, int);
10103 -extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
10104 -extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
10105 -extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
10106 -extern int vfs_rmdir(struct inode *, struct dentry *);
10107 -extern int vfs_unlink(struct inode *, struct dentry *);
10108 +extern int vfs_mkdir(struct inode *, struct dentry *, int, struct nameidata *);
10109 +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t, struct nameidata *);
10110 +extern int vfs_symlink(struct inode *, struct dentry *, const char *, int, struct nameidata *);
10111 +extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct nameidata *);
10112 +extern int vfs_rmdir(struct inode *, struct dentry *, struct nameidata *);
10113 +extern int vfs_unlink(struct inode *, struct dentry *, struct nameidata *);
10114 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
10117 @@ -1215,6 +1245,7 @@ struct inode_operations {
10118 void (*truncate_range)(struct inode *, loff_t, loff_t);
10119 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
10121 + int (*sync_flags) (struct inode *);
10125 @@ -1230,6 +1261,7 @@ extern ssize_t vfs_readv(struct file *,
10126 unsigned long, loff_t *);
10127 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
10128 unsigned long, loff_t *);
10129 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
10132 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
10133 @@ -1937,6 +1969,7 @@ extern int dcache_dir_open(struct inode
10134 extern int dcache_dir_close(struct inode *, struct file *);
10135 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
10136 extern int dcache_readdir(struct file *, void *, filldir_t);
10137 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
10138 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
10139 extern int simple_statfs(struct dentry *, struct kstatfs *);
10140 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
10141 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/init_task.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/init_task.h
10142 --- linux-2.6.24-rc7/include/linux/init_task.h 2007-11-29 01:12:23 +0100
10143 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/init_task.h 2007-12-13 13:25:26 +0100
10144 @@ -173,6 +173,10 @@ extern struct group_info init_groups;
10145 .dirties = INIT_PROP_LOCAL_SINGLE(dirties), \
10146 INIT_TRACE_IRQFLAGS \
10149 + .vx_info = NULL, \
10151 + .nx_info = NULL, \
10155 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/interrupt.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/interrupt.h
10156 --- linux-2.6.24-rc7/include/linux/interrupt.h 2007-11-29 01:12:23 +0100
10157 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/interrupt.h 2007-12-18 00:54:39 +0100
10159 #include <linux/preempt.h>
10160 #include <linux/cpumask.h>
10161 #include <linux/irqreturn.h>
10162 -#include <linux/hardirq.h>
10163 #include <linux/sched.h>
10164 +#include <linux/hardirq.h>
10165 #include <linux/irqflags.h>
10166 #include <asm/atomic.h>
10167 #include <asm/ptrace.h>
10168 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/ipc.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/ipc.h
10169 --- linux-2.6.24-rc7/include/linux/ipc.h 2007-11-29 01:12:23 +0100
10170 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/ipc.h 2007-12-13 13:25:48 +0100
10171 @@ -93,6 +93,7 @@ struct kern_ipc_perm
10179 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/loop.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/loop.h
10180 --- linux-2.6.24-rc7/include/linux/loop.h 2007-11-29 01:02:17 +0100
10181 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/loop.h 2007-12-13 13:25:47 +0100
10182 @@ -45,6 +45,7 @@ struct loop_device {
10183 struct loop_func_table *lo_encryption;
10185 uid_t lo_key_owner; /* Who set the key */
10187 int (*ioctl)(struct loop_device *, int cmd,
10188 unsigned long arg);
10190 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/major.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/major.h
10191 --- linux-2.6.24-rc7/include/linux/major.h 2007-11-29 01:02:17 +0100
10192 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/major.h 2007-12-13 13:25:46 +0100
10194 #define HD_MAJOR IDE0_MAJOR
10195 #define PTY_SLAVE_MAJOR 3
10196 #define TTY_MAJOR 4
10197 +#define VROOT_MAJOR 4
10198 #define TTYAUX_MAJOR 5
10200 #define VCS_MAJOR 7
10201 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/mm_types.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/mm_types.h
10202 --- linux-2.6.24-rc7/include/linux/mm_types.h 2007-11-29 01:12:24 +0100
10203 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/mm_types.h 2007-12-13 14:36:57 +0100
10204 @@ -198,6 +198,7 @@ struct mm_struct {
10206 /* Architecture-specific MM context */
10207 mm_context_t context;
10208 + struct vx_info *mm_vx_info;
10210 /* Swap token stuff */
10212 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/mount.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/mount.h
10213 --- linux-2.6.24-rc7/include/linux/mount.h 2007-07-09 13:19:56 +0200
10214 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/mount.h 2007-12-13 13:25:47 +0100
10215 @@ -28,12 +28,16 @@ struct mnt_namespace;
10216 #define MNT_NOATIME 0x08
10217 #define MNT_NODIRATIME 0x10
10218 #define MNT_RELATIME 0x20
10219 +#define MNT_RDONLY 0x40
10221 +#define MNT_IS_RDONLY(m) ((m) && ((m)->mnt_flags & MNT_RDONLY))
10223 #define MNT_SHRINKABLE 0x100
10225 #define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */
10226 #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
10227 #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
10228 +#define MNT_TAGID 0x8000
10231 struct list_head mnt_hash;
10232 @@ -61,6 +65,7 @@ struct vfsmount {
10233 atomic_t mnt_count;
10234 int mnt_expiry_mark; /* true if marked for expiry */
10236 + tag_t mnt_tag; /* tagging used for vfsmount */
10239 static inline struct vfsmount *mntget(struct vfsmount *mnt)
10240 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/net.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/net.h
10241 --- linux-2.6.24-rc7/include/linux/net.h 2007-11-29 01:12:24 +0100
10242 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/net.h 2007-12-13 13:25:30 +0100
10243 @@ -64,6 +64,7 @@ typedef enum {
10244 #define SOCK_NOSPACE 2
10245 #define SOCK_PASSCRED 3
10246 #define SOCK_PASSSEC 4
10247 +#define SOCK_USER_SOCKET 5
10249 #ifndef ARCH_HAS_SOCKET_TYPES
10251 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/nfs_mount.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/nfs_mount.h
10252 --- linux-2.6.24-rc7/include/linux/nfs_mount.h 2007-11-29 01:02:18 +0100
10253 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/nfs_mount.h 2007-12-13 13:25:51 +0100
10254 @@ -63,6 +63,7 @@ struct nfs_mount_data {
10255 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
10256 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
10257 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
10258 -#define NFS_MOUNT_FLAGMASK 0xFFFF
10259 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
10260 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
10263 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/nsproxy.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/nsproxy.h
10264 --- linux-2.6.24-rc7/include/linux/nsproxy.h 2007-11-29 01:12:25 +0100
10265 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/nsproxy.h 2007-12-31 12:45:36 +0100
10268 #include <linux/spinlock.h>
10269 #include <linux/sched.h>
10270 +#include <linux/vserver/debug.h>
10272 struct mnt_namespace;
10273 struct uts_namespace;
10274 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
10277 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
10278 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
10279 void exit_task_namespaces(struct task_struct *tsk);
10280 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
10281 void free_nsproxy(struct nsproxy *ns);
10282 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
10283 struct fs_struct *);
10285 -static inline void put_nsproxy(struct nsproxy *ns)
10286 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
10288 +static inline void __get_nsproxy(struct nsproxy *ns,
10289 + const char *_file, int _line)
10291 - if (atomic_dec_and_test(&ns->count)) {
10292 - free_nsproxy(ns);
10294 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
10295 + ns, atomic_read(&ns->count), _file, _line);
10296 + atomic_inc(&ns->count);
10299 -static inline void get_nsproxy(struct nsproxy *ns)
10300 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
10302 +static inline void __put_nsproxy(struct nsproxy *ns,
10303 + const char *_file, int _line)
10305 - atomic_inc(&ns->count);
10306 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
10307 + ns, atomic_read(&ns->count), _file, _line);
10308 + if (atomic_dec_and_test(&ns->count)) {
10309 + free_nsproxy(ns);
10313 #ifdef CONFIG_CGROUP_NS
10314 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/pid.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/pid.h
10315 --- linux-2.6.24-rc7/include/linux/pid.h 2007-11-29 01:12:25 +0100
10316 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/pid.h 2007-12-18 00:40:01 +0100
10317 @@ -8,7 +8,8 @@ enum pid_type
10327 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/proc_fs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/proc_fs.h
10328 --- linux-2.6.24-rc7/include/linux/proc_fs.h 2007-12-31 17:58:28 +0100
10329 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/proc_fs.h 2007-12-31 12:34:43 +0100
10330 @@ -59,6 +59,7 @@ struct proc_dir_entry {
10336 const struct inode_operations *proc_iops;
10338 @@ -256,13 +257,20 @@ static inline void kclist_add(struct kco
10339 extern void kclist_add(struct kcore_list *, void *, size_t);
10346 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
10347 int (*proc_read)(struct task_struct *task, char *page);
10348 + int (*proc_vs_read)(char *page);
10349 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
10350 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
10353 struct proc_inode {
10358 struct proc_dir_entry *pde;
10359 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/reiserfs_fs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/reiserfs_fs.h
10360 --- linux-2.6.24-rc7/include/linux/reiserfs_fs.h 2007-11-29 01:12:25 +0100
10361 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/reiserfs_fs.h 2007-12-13 13:25:40 +0100
10362 @@ -837,6 +837,10 @@ struct stat_data_v1 {
10363 #define REISERFS_COMPR_FL FS_COMPR_FL
10364 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
10366 +/* unfortunately reiserfs sdattr is only 16 bit */
10367 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
10368 +#define REISERFS_IUNLINK_FL (FS_IUNLINK_FL >> 16)
10370 /* persistent flags that file inherits from the parent directory */
10371 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
10372 REISERFS_SYNC_FL | \
10373 @@ -846,6 +850,14 @@ struct stat_data_v1 {
10374 REISERFS_COMPR_FL | \
10375 REISERFS_NOTAIL_FL )
10377 +#ifdef CONFIG_VSERVER_LEGACY
10378 +#define REISERFS_FL_USER_VISIBLE (REISERFS_IUNLINK_FL|0x80FF)
10379 +#define REISERFS_FL_USER_MODIFIABLE (REISERFS_IUNLINK_FL|0x80FF)
10381 +#define REISERFS_FL_USER_VISIBLE 0x80FF
10382 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
10385 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10388 @@ -1911,6 +1923,7 @@ static inline void reiserfs_update_sd(st
10389 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10390 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10391 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10392 +int reiserfs_sync_flags(struct inode *inode);
10395 void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
10396 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/reiserfs_fs_sb.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/reiserfs_fs_sb.h
10397 --- linux-2.6.24-rc7/include/linux/reiserfs_fs_sb.h 2007-11-29 01:12:25 +0100
10398 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/reiserfs_fs_sb.h 2007-12-13 13:25:40 +0100
10399 @@ -456,6 +456,7 @@ enum reiserfs_mount_options {
10401 REISERFS_BARRIER_NONE,
10402 REISERFS_BARRIER_FLUSH,
10405 /* Actions on error */
10406 REISERFS_ERROR_PANIC,
10407 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/sched.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/sched.h
10408 --- linux-2.6.24-rc7/include/linux/sched.h 2007-12-31 17:58:28 +0100
10409 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/sched.h 2007-12-31 12:34:43 +0100
10411 #define CLONE_NEWUSER 0x10000000 /* New user namespace */
10412 #define CLONE_NEWPID 0x20000000 /* New pid namespace */
10413 #define CLONE_NEWNET 0x40000000 /* New network namespace */
10414 +#define CLONE_KTHREAD 0x80000000 /* clone a kernel thread */
10417 * Scheduling policies
10418 @@ -72,7 +73,6 @@ struct sched_param {
10419 #include <linux/fs_struct.h>
10420 #include <linux/compiler.h>
10421 #include <linux/completion.h>
10422 -#include <linux/pid.h>
10423 #include <linux/percpu.h>
10424 #include <linux/topology.h>
10425 #include <linux/proportions.h>
10426 @@ -88,6 +88,7 @@ struct sched_param {
10427 #include <linux/hrtimer.h>
10428 #include <linux/task_io_accounting.h>
10429 #include <linux/kobject.h>
10430 +#include <linux/pid.h>
10432 #include <asm/processor.h>
10434 @@ -99,7 +100,7 @@ struct bio;
10435 * List of flags we want to share for kernel threads,
10436 * if only because they are not used by them anyway.
10438 -#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
10439 +#define CLONE_KERNEL (CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_KTHREAD)
10442 * These are the constant used to fake the fixed-point load-average
10443 @@ -320,25 +321,27 @@ extern void arch_unmap_area_topdown(stru
10444 * The mm counters are not protected by its page_table_lock,
10445 * so must be incremented atomically.
10447 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
10448 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
10449 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
10450 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
10451 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
10453 +#define __set_mm_counter(mm, member, value) \
10454 + atomic_long_set(&(mm)->_##member, value)
10455 +#define get_mm_counter(mm, member) \
10456 + ((unsigned long)atomic_long_read(&(mm)->_##member))
10457 #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
10459 * The mm counters are protected by its page_table_lock,
10460 * so can be incremented directly.
10462 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
10463 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
10464 #define get_mm_counter(mm, member) ((mm)->_##member)
10465 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
10466 -#define inc_mm_counter(mm, member) (mm)->_##member++
10467 -#define dec_mm_counter(mm, member) (mm)->_##member--
10469 #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
10471 +#define set_mm_counter(mm, member, value) \
10472 + vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
10473 +#define add_mm_counter(mm, member, value) \
10474 + vx_ ## member ## pages_add((mm), (value))
10475 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
10476 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
10478 #define get_mm_rss(mm) \
10479 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
10480 #define update_hiwater_rss(mm) do { \
10481 @@ -1071,6 +1074,14 @@ struct task_struct {
10484 struct audit_context *audit_context;
10486 +/* vserver context data */
10487 + struct vx_info *vx_info;
10488 + struct nx_info *nx_info;
10495 /* Thread group tracking */
10496 @@ -1265,6 +1276,11 @@ struct pid_namespace;
10497 * see also pid_nr() etc in include/linux/pid.h
10500 +#include <linux/vserver/base.h>
10501 +#include <linux/vserver/context.h>
10502 +#include <linux/vserver/debug.h>
10503 +#include <linux/vserver/pid.h>
10505 static inline pid_t task_pid_nr(struct task_struct *tsk)
10508 @@ -1274,7 +1290,7 @@ pid_t task_pid_nr_ns(struct task_struct
10510 static inline pid_t task_pid_vnr(struct task_struct *tsk)
10512 - return pid_vnr(task_pid(tsk));
10513 + return vx_map_pid(pid_vnr(task_pid(tsk)));
10517 @@ -1287,7 +1303,7 @@ pid_t task_tgid_nr_ns(struct task_struct
10519 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
10521 - return pid_vnr(task_tgid(tsk));
10522 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
10526 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/shmem_fs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/shmem_fs.h
10527 --- linux-2.6.24-rc7/include/linux/shmem_fs.h 2006-11-30 21:19:39 +0100
10528 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/shmem_fs.h 2007-12-13 13:25:51 +0100
10531 #define SHMEM_NR_DIRECT 16
10533 +#define TMPFS_SUPER_MAGIC 0x01021994
10536 struct shmem_inode_info {
10538 unsigned long flags;
10539 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/stat.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/stat.h
10540 --- linux-2.6.24-rc7/include/linux/stat.h 2007-07-09 13:20:01 +0200
10541 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/stat.h 2007-12-13 13:25:41 +0100
10542 @@ -66,6 +66,7 @@ struct kstat {
10543 unsigned int nlink;
10549 struct timespec atime;
10550 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/sunrpc/auth.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/sunrpc/auth.h
10551 --- linux-2.6.24-rc7/include/linux/sunrpc/auth.h 2007-11-29 01:02:23 +0100
10552 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/sunrpc/auth.h 2007-12-13 13:25:51 +0100
10558 struct group_info *group_info;
10561 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/sunrpc/clnt.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/sunrpc/clnt.h
10562 --- linux-2.6.24-rc7/include/linux/sunrpc/clnt.h 2007-11-29 01:12:25 +0100
10563 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/sunrpc/clnt.h 2007-12-13 13:25:51 +0100
10564 @@ -43,7 +43,8 @@ struct rpc_clnt {
10565 unsigned int cl_softrtry : 1,/* soft timeouts */
10566 cl_intr : 1,/* interruptible */
10567 cl_discrtry : 1,/* disconnect before retry */
10568 - cl_autobind : 1;/* use getport() */
10569 + cl_autobind : 1,/* use getport() */
10570 + cl_tag : 1;/* context tagging */
10572 struct rpc_rtt * cl_rtt; /* RTO estimator data */
10574 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/syscalls.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/syscalls.h
10575 --- linux-2.6.24-rc7/include/linux/syscalls.h 2007-11-29 01:02:23 +0100
10576 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/syscalls.h 2007-12-13 13:25:46 +0100
10577 @@ -294,6 +294,8 @@ asmlinkage long sys_symlink(const char _
10578 asmlinkage long sys_unlink(const char __user *pathname);
10579 asmlinkage long sys_rename(const char __user *oldname,
10580 const char __user *newname);
10581 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
10583 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
10584 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
10586 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/sysctl.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/sysctl.h
10587 --- linux-2.6.24-rc7/include/linux/sysctl.h 2007-12-31 17:58:28 +0100
10588 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/sysctl.h 2007-12-31 12:40:05 +0100
10589 @@ -70,6 +70,7 @@ enum
10590 CTL_ABI=9, /* Binary emulation */
10591 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
10592 CTL_ARLAN=254, /* arlan wireless driver */
10593 + CTL_VSERVER=4242, /* Linux-VServer debug */
10594 CTL_S390DBF=5677, /* s390 debug */
10595 CTL_SUNRPC=7249, /* sunrpc debug */
10596 CTL_PM=9899, /* frv power management */
10597 @@ -105,6 +106,7 @@ enum
10598 KERN_CAP_BSET=14, /* int: capability bounding set */
10599 KERN_PANIC=15, /* int: panic timeout */
10600 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
10601 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
10603 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
10604 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
10605 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/sysfs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/sysfs.h
10606 --- linux-2.6.24-rc7/include/linux/sysfs.h 2007-11-29 01:12:25 +0100
10607 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/sysfs.h 2007-12-13 13:25:51 +0100
10609 #include <linux/list.h>
10610 #include <asm/atomic.h>
10612 +#define SYSFS_SUPER_MAGIC 0x62656572
10617 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/time.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/time.h
10618 --- linux-2.6.24-rc7/include/linux/time.h 2007-11-29 01:12:25 +0100
10619 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/time.h 2007-12-13 13:25:12 +0100
10620 @@ -178,6 +178,9 @@ static inline void timespec_add_ns(struc
10625 +#include <linux/vs_time.h>
10627 #endif /* __KERNEL__ */
10629 #define NFDBITS __NFDBITS
10630 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/types.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/types.h
10631 --- linux-2.6.24-rc7/include/linux/types.h 2007-11-29 01:12:25 +0100
10632 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/types.h 2007-12-13 13:25:26 +0100
10633 @@ -36,6 +36,9 @@ typedef __kernel_uid32_t uid_t;
10634 typedef __kernel_gid32_t gid_t;
10635 typedef __kernel_uid16_t uid16_t;
10636 typedef __kernel_gid16_t gid16_t;
10637 +typedef unsigned int xid_t;
10638 +typedef unsigned int nid_t;
10639 +typedef unsigned int tag_t;
10641 typedef unsigned long uintptr_t;
10643 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vroot.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vroot.h
10644 --- linux-2.6.24-rc7/include/linux/vroot.h 1970-01-01 01:00:00 +0100
10645 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vroot.h 2007-12-13 13:25:46 +0100
10649 + * include/linux/vroot.h
10651 + * written by Herbert Pötzl, 9/11/2002
10652 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
10654 + * Copyright (C) 2002-2007 by Herbert Pötzl.
10655 + * Redistribution of this file is permitted under the
10656 + * GNU General Public License.
10659 +#ifndef _LINUX_VROOT_H
10660 +#define _LINUX_VROOT_H
10665 +/* Possible states of device */
10671 +struct vroot_device {
10675 + struct semaphore vr_ctl_mutex;
10676 + struct block_device *vr_device;
10681 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
10683 +extern int register_vroot_grb(vroot_grb_func *);
10684 +extern int unregister_vroot_grb(vroot_grb_func *);
10686 +#endif /* __KERNEL__ */
10688 +#define MAX_VROOT_DEFAULT 8
10691 + * IOCTL commands --- we will commandeer 0x56 ('V')
10694 +#define VROOT_SET_DEV 0x5600
10695 +#define VROOT_CLR_DEV 0x5601
10697 +#endif /* _LINUX_VROOT_H */
10698 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_base.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_base.h
10699 --- linux-2.6.24-rc7/include/linux/vs_base.h 1970-01-01 01:00:00 +0100
10700 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_base.h 2007-12-18 01:15:29 +0100
10702 +#ifndef _VS_BASE_H
10703 +#define _VS_BASE_H
10705 +#include "vserver/base.h"
10706 +#include "vserver/check.h"
10707 +#include "vserver/debug.h"
10710 +#warning duplicate inclusion
10712 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_context.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_context.h
10713 --- linux-2.6.24-rc7/include/linux/vs_context.h 1970-01-01 01:00:00 +0100
10714 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_context.h 2007-12-18 01:05:13 +0100
10716 +#ifndef _VS_CONTEXT_H
10717 +#define _VS_CONTEXT_H
10719 +#include "vserver/base.h"
10720 +#include "vserver/check.h"
10721 +#include "vserver/context.h"
10722 +#include "vserver/history.h"
10723 +#include "vserver/debug.h"
10726 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
10728 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
10729 + const char *_file, int _line, void *_here)
10734 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
10735 + vxi, vxi ? vxi->vx_id : 0,
10736 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10738 + __vxh_get_vx_info(vxi, _here);
10740 + atomic_inc(&vxi->vx_usecnt);
10745 +extern void free_vx_info(struct vx_info *);
10747 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
10749 +static inline void __put_vx_info(struct vx_info *vxi,
10750 + const char *_file, int _line, void *_here)
10755 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
10756 + vxi, vxi ? vxi->vx_id : 0,
10757 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10759 + __vxh_put_vx_info(vxi, _here);
10761 + if (atomic_dec_and_test(&vxi->vx_usecnt))
10762 + free_vx_info(vxi);
10766 +#define init_vx_info(p, i) \
10767 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10769 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10770 + const char *_file, int _line, void *_here)
10773 + vxlprintk(VXD_CBIT(xid, 3),
10774 + "init_vx_info(%p[#%d.%d])",
10775 + vxi, vxi ? vxi->vx_id : 0,
10776 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10778 + __vxh_init_vx_info(vxi, vxp, _here);
10780 + atomic_inc(&vxi->vx_usecnt);
10786 +#define set_vx_info(p, i) \
10787 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10789 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10790 + const char *_file, int _line, void *_here)
10792 + struct vx_info *vxo;
10797 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
10798 + vxi, vxi ? vxi->vx_id : 0,
10799 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10801 + __vxh_set_vx_info(vxi, vxp, _here);
10803 + atomic_inc(&vxi->vx_usecnt);
10804 + vxo = xchg(vxp, vxi);
10809 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
10811 +static inline void __clr_vx_info(struct vx_info **vxp,
10812 + const char *_file, int _line, void *_here)
10814 + struct vx_info *vxo;
10816 + vxo = xchg(vxp, NULL);
10820 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
10821 + vxo, vxo ? vxo->vx_id : 0,
10822 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
10824 + __vxh_clr_vx_info(vxo, vxp, _here);
10826 + if (atomic_dec_and_test(&vxo->vx_usecnt))
10827 + free_vx_info(vxo);
10831 +#define claim_vx_info(v, p) \
10832 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
10834 +static inline void __claim_vx_info(struct vx_info *vxi,
10835 + struct task_struct *task,
10836 + const char *_file, int _line, void *_here)
10838 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
10839 + vxi, vxi ? vxi->vx_id : 0,
10840 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10841 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
10842 + task, _file, _line);
10843 + __vxh_claim_vx_info(vxi, task, _here);
10845 + atomic_inc(&vxi->vx_tasks);
10849 +extern void unhash_vx_info(struct vx_info *);
10851 +#define release_vx_info(v, p) \
10852 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
10854 +static inline void __release_vx_info(struct vx_info *vxi,
10855 + struct task_struct *task,
10856 + const char *_file, int _line, void *_here)
10858 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
10859 + vxi, vxi ? vxi->vx_id : 0,
10860 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10861 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
10862 + task, _file, _line);
10863 + __vxh_release_vx_info(vxi, task, _here);
10867 + if (atomic_dec_and_test(&vxi->vx_tasks))
10868 + unhash_vx_info(vxi);
10872 +#define task_get_vx_info(p) \
10873 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
10875 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
10876 + const char *_file, int _line, void *_here)
10878 + struct vx_info *vxi;
10881 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
10882 + p, _file, _line);
10883 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
10889 +static inline void __wakeup_vx_info(struct vx_info *vxi)
10891 + if (waitqueue_active(&vxi->vx_wait))
10892 + wake_up_interruptible(&vxi->vx_wait);
10896 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
10898 +static inline void __enter_vx_info(struct vx_info *vxi,
10899 + struct vx_info_save *vxis, const char *_file, int _line)
10901 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
10902 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
10903 + current->xid, current->vx_info, _file, _line);
10904 + vxis->vxi = xchg(¤t->vx_info, vxi);
10905 + vxis->xid = current->xid;
10906 + current->xid = vxi ? vxi->vx_id : 0;
10909 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
10911 +static inline void __leave_vx_info(struct vx_info_save *vxis,
10912 + const char *_file, int _line)
10914 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
10915 + vxis, vxis->xid, vxis->vxi, current,
10916 + current->xid, current->vx_info, _file, _line);
10917 + (void)xchg(¤t->vx_info, vxis->vxi);
10918 + current->xid = vxis->xid;
10922 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
10924 + vxis->vxi = xchg(¤t->vx_info, NULL);
10925 + vxis->xid = xchg(¤t->xid, (xid_t)0);
10928 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
10930 + (void)xchg(¤t->xid, vxis->xid);
10931 + (void)xchg(¤t->vx_info, vxis->vxi);
10934 +extern void exit_vx_info(struct task_struct *, int);
10935 +extern void exit_vx_info_early(struct task_struct *, int);
10939 +#warning duplicate inclusion
10941 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_cowbl.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_cowbl.h
10942 --- linux-2.6.24-rc7/include/linux/vs_cowbl.h 1970-01-01 01:00:00 +0100
10943 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_cowbl.h 2007-12-13 13:25:25 +0100
10945 +#ifndef _VS_COWBL_H
10946 +#define _VS_COWBL_H
10948 +#include <linux/fs.h>
10949 +#include <linux/dcache.h>
10950 +#include <linux/namei.h>
10952 +extern struct dentry *cow_break_link(const char *pathname);
10954 +static inline int cow_check_and_break(struct nameidata *nd)
10956 + struct inode *inode = nd->dentry->d_inode;
10958 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
10960 + if (IS_COW(inode)) {
10961 + if (IS_COW_LINK(inode)) {
10962 + struct dentry *new_dentry, *old_dentry = nd->dentry;
10963 + char *path, *buf;
10965 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
10969 + path = d_path(nd->dentry, nd->mnt, buf, PATH_MAX);
10970 + new_dentry = cow_break_link(path);
10972 + if (!IS_ERR(new_dentry)) {
10973 + nd->dentry = new_dentry;
10974 + dput(old_dentry);
10976 + error = PTR_ERR(new_dentry);
10978 + inode->i_flags &= ~(S_IUNLINK | S_IMMUTABLE);
10979 + inode->i_ctime = CURRENT_TIME;
10980 + mark_inode_dirty(inode);
10987 +#warning duplicate inclusion
10989 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_cvirt.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_cvirt.h
10990 --- linux-2.6.24-rc7/include/linux/vs_cvirt.h 1970-01-01 01:00:00 +0100
10991 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_cvirt.h 2007-12-18 01:06:05 +0100
10993 +#ifndef _VS_CVIRT_H
10994 +#define _VS_CVIRT_H
10996 +#include "vserver/cvirt.h"
10997 +#include "vserver/context.h"
10998 +#include "vserver/base.h"
10999 +#include "vserver/check.h"
11000 +#include "vserver/debug.h"
11003 +static inline void vx_activate_task(struct task_struct *p)
11005 + struct vx_info *vxi;
11007 + if ((vxi = p->vx_info)) {
11008 + vx_update_load(vxi);
11009 + atomic_inc(&vxi->cvirt.nr_running);
11013 +static inline void vx_deactivate_task(struct task_struct *p)
11015 + struct vx_info *vxi;
11017 + if ((vxi = p->vx_info)) {
11018 + vx_update_load(vxi);
11019 + atomic_dec(&vxi->cvirt.nr_running);
11023 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11025 + struct vx_info *vxi;
11027 + if ((vxi = p->vx_info))
11028 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
11031 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11033 + struct vx_info *vxi;
11035 + if ((vxi = p->vx_info))
11036 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
11041 +#warning duplicate inclusion
11043 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_dlimit.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_dlimit.h
11044 --- linux-2.6.24-rc7/include/linux/vs_dlimit.h 1970-01-01 01:00:00 +0100
11045 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_dlimit.h 2007-12-13 13:25:25 +0100
11047 +#ifndef _VS_DLIMIT_H
11048 +#define _VS_DLIMIT_H
11050 +#include "vserver/dlimit.h"
11051 +#include "vserver/base.h"
11052 +#include "vserver/debug.h"
11055 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11057 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11058 + const char *_file, int _line)
11062 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11063 + dli, dli ? dli->dl_tag : 0,
11064 + dli ? atomic_read(&dli->dl_usecnt) : 0,
11066 + atomic_inc(&dli->dl_usecnt);
11071 +#define free_dl_info(i) \
11072 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11074 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11076 +static inline void __put_dl_info(struct dl_info *dli,
11077 + const char *_file, int _line)
11081 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11082 + dli, dli ? dli->dl_tag : 0,
11083 + dli ? atomic_read(&dli->dl_usecnt) : 0,
11085 + if (atomic_dec_and_test(&dli->dl_usecnt))
11086 + free_dl_info(dli);
11090 +#define __dlimit_char(d) ((d) ? '*' : ' ')
11092 +static inline int __dl_alloc_space(struct super_block *sb,
11093 + tag_t tag, dlsize_t nr, const char *file, int line)
11095 + struct dl_info *dli = NULL;
11100 + dli = locate_dl_info(sb, tag);
11104 + spin_lock(&dli->dl_lock);
11105 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
11107 + dli->dl_space_used += nr;
11108 + spin_unlock(&dli->dl_lock);
11109 + put_dl_info(dli);
11111 + vxlprintk(VXD_CBIT(dlim, 1),
11112 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
11113 + sb, tag, __dlimit_char(dli), (long long)nr,
11114 + ret, file, line);
11118 +static inline void __dl_free_space(struct super_block *sb,
11119 + tag_t tag, dlsize_t nr, const char *_file, int _line)
11121 + struct dl_info *dli = NULL;
11125 + dli = locate_dl_info(sb, tag);
11129 + spin_lock(&dli->dl_lock);
11130 + if (dli->dl_space_used > nr)
11131 + dli->dl_space_used -= nr;
11133 + dli->dl_space_used = 0;
11134 + spin_unlock(&dli->dl_lock);
11135 + put_dl_info(dli);
11137 + vxlprintk(VXD_CBIT(dlim, 1),
11138 + "FREE (%p,#%d)%c %lld bytes",
11139 + sb, tag, __dlimit_char(dli), (long long)nr,
11143 +static inline int __dl_alloc_inode(struct super_block *sb,
11144 + tag_t tag, const char *_file, int _line)
11146 + struct dl_info *dli;
11149 + dli = locate_dl_info(sb, tag);
11153 + spin_lock(&dli->dl_lock);
11154 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
11156 + dli->dl_inodes_used++;
11157 + spin_unlock(&dli->dl_lock);
11158 + put_dl_info(dli);
11160 + vxlprintk(VXD_CBIT(dlim, 0),
11161 + "ALLOC (%p,#%d)%c inode (%d)",
11162 + sb, tag, __dlimit_char(dli), ret, _file, _line);
11166 +static inline void __dl_free_inode(struct super_block *sb,
11167 + tag_t tag, const char *_file, int _line)
11169 + struct dl_info *dli;
11171 + dli = locate_dl_info(sb, tag);
11175 + spin_lock(&dli->dl_lock);
11176 + if (dli->dl_inodes_used > 1)
11177 + dli->dl_inodes_used--;
11179 + dli->dl_inodes_used = 0;
11180 + spin_unlock(&dli->dl_lock);
11181 + put_dl_info(dli);
11183 + vxlprintk(VXD_CBIT(dlim, 0),
11184 + "FREE (%p,#%d)%c inode",
11185 + sb, tag, __dlimit_char(dli), _file, _line);
11188 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11189 + unsigned long long *free_blocks, unsigned long long *root_blocks,
11190 + const char *_file, int _line)
11192 + struct dl_info *dli;
11193 + uint64_t broot, bfree;
11195 + dli = locate_dl_info(sb, tag);
11199 + spin_lock(&dli->dl_lock);
11200 + broot = (dli->dl_space_total -
11201 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11202 + >> sb->s_blocksize_bits;
11203 + bfree = (dli->dl_space_total - dli->dl_space_used)
11204 + >> sb->s_blocksize_bits;
11205 + spin_unlock(&dli->dl_lock);
11207 + vxlprintk(VXD_CBIT(dlim, 2),
11208 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11209 + (long long)bfree, (long long)broot,
11210 + *free_blocks, *root_blocks, dli->dl_nrlmult,
11212 + if (free_blocks) {
11213 + if (*free_blocks > bfree)
11214 + *free_blocks = bfree;
11216 + if (root_blocks) {
11217 + if (*root_blocks > broot)
11218 + *root_blocks = broot;
11220 + put_dl_info(dli);
11223 +#define DLIMIT_ALLOC_SPACE(in, bytes) \
11224 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11225 + __FILE__, __LINE__ )
11227 +#define DLIMIT_FREE_SPACE(in, bytes) \
11228 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11229 + __FILE__, __LINE__ )
11231 +#define DLIMIT_ALLOC_BLOCK(in, nr) \
11232 + __dl_alloc_space((in)->i_sb, (in)->i_tag, \
11233 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
11234 + __FILE__, __LINE__ )
11236 +#define DLIMIT_FREE_BLOCK(in, nr) \
11237 + __dl_free_space((in)->i_sb, (in)->i_tag, \
11238 + ((dlsize_t)(nr)) << (in)->i_sb->s_blocksize_bits, \
11239 + __FILE__, __LINE__ )
11242 +#define DLIMIT_ALLOC_INODE(in) \
11243 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11245 +#define DLIMIT_FREE_INODE(in) \
11246 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11249 +#define DLIMIT_ADJUST_BLOCK(sb, tag, fb, rb) \
11250 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11254 +#warning duplicate inclusion
11256 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_limit.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_limit.h
11257 --- linux-2.6.24-rc7/include/linux/vs_limit.h 1970-01-01 01:00:00 +0100
11258 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_limit.h 2007-12-13 13:25:25 +0100
11260 +#ifndef _VS_LIMIT_H
11261 +#define _VS_LIMIT_H
11263 +#include "vserver/limit.h"
11264 +#include "vserver/base.h"
11265 +#include "vserver/context.h"
11266 +#include "vserver/debug.h"
11267 +#include "vserver/context.h"
11268 +#include "vserver/limit_int.h"
11271 +#define vx_acc_cres(v, d, p, r) \
11272 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
11274 +#define vx_acc_cres_cond(x, d, p, r) \
11275 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
11276 + r, d, p, __FILE__, __LINE__)
11279 +#define vx_add_cres(v, a, p, r) \
11280 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
11281 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
11283 +#define vx_add_cres_cond(x, a, p, r) \
11284 + __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
11285 + r, a, p, __FILE__, __LINE__)
11286 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
11289 +/* process and file limits */
11291 +#define vx_nproc_inc(p) \
11292 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
11294 +#define vx_nproc_dec(p) \
11295 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
11297 +#define vx_files_inc(f) \
11298 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
11300 +#define vx_files_dec(f) \
11301 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
11303 +#define vx_locks_inc(l) \
11304 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
11306 +#define vx_locks_dec(l) \
11307 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
11309 +#define vx_openfd_inc(f) \
11310 + vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
11312 +#define vx_openfd_dec(f) \
11313 + vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
11316 +#define vx_cres_avail(v, n, r) \
11317 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
11320 +#define vx_nproc_avail(n) \
11321 + vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
11323 +#define vx_files_avail(n) \
11324 + vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
11326 +#define vx_locks_avail(n) \
11327 + vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
11329 +#define vx_openfd_avail(n) \
11330 + vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
11333 +/* dentry limits */
11335 +#define vx_dentry_inc(d) do { \
11336 + if (atomic_read(&d->d_count) == 1) \
11337 + vx_acc_cres(current->vx_info, 1, d, VLIMIT_DENTRY); \
11340 +#define vx_dentry_dec(d) do { \
11341 + if (atomic_read(&d->d_count) == 0) \
11342 + vx_acc_cres(current->vx_info,-1, d, VLIMIT_DENTRY); \
11345 +#define vx_dentry_avail(n) \
11346 + vx_cres_avail(current->vx_info, n, VLIMIT_DENTRY)
11349 +/* socket limits */
11351 +#define vx_sock_inc(s) \
11352 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
11354 +#define vx_sock_dec(s) \
11355 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
11357 +#define vx_sock_avail(n) \
11358 + vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
11361 +/* ipc resource limits */
11363 +#define vx_ipcmsg_add(v, u, a) \
11364 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
11366 +#define vx_ipcmsg_sub(v, u, a) \
11367 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
11369 +#define vx_ipcmsg_avail(v, a) \
11370 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
11373 +#define vx_ipcshm_add(v, k, a) \
11374 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
11376 +#define vx_ipcshm_sub(v, k, a) \
11377 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
11379 +#define vx_ipcshm_avail(v, a) \
11380 + vx_cres_avail(v, a, VLIMIT_SHMEM)
11383 +#define vx_semary_inc(a) \
11384 + vx_acc_cres(current->vx_info, 1, a, VLIMIT_SEMARY)
11386 +#define vx_semary_dec(a) \
11387 + vx_acc_cres(current->vx_info, -1, a, VLIMIT_SEMARY)
11390 +#define vx_nsems_add(a,n) \
11391 + vx_add_cres(current->vx_info, n, a, VLIMIT_NSEMS)
11393 +#define vx_nsems_sub(a,n) \
11394 + vx_sub_cres(current->vx_info, n, a, VLIMIT_NSEMS)
11398 +#warning duplicate inclusion
11400 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_memory.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_memory.h
11401 --- linux-2.6.24-rc7/include/linux/vs_memory.h 1970-01-01 01:00:00 +0100
11402 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_memory.h 2007-12-13 13:25:25 +0100
11404 +#ifndef _VS_MEMORY_H
11405 +#define _VS_MEMORY_H
11407 +#include "vserver/limit.h"
11408 +#include "vserver/base.h"
11409 +#include "vserver/context.h"
11410 +#include "vserver/debug.h"
11411 +#include "vserver/context.h"
11412 +#include "vserver/limit_int.h"
11415 +#define __acc_add_long(a, v) (*(v) += (a))
11416 +#define __acc_inc_long(v) (++*(v))
11417 +#define __acc_dec_long(v) (--*(v))
11419 +#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
11420 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
11421 +#define __acc_inc_atomic(v) atomic_long_inc(v)
11422 +#define __acc_dec_atomic(v) atomic_long_dec(v)
11423 +#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11424 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
11425 +#define __acc_inc_atomic(v) __acc_inc_long(v)
11426 +#define __acc_dec_atomic(v) __acc_dec_long(v)
11427 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
11430 +#define vx_acc_page(m, d, v, r) do { \
11432 + __acc_inc_long(&(m)->v); \
11434 + __acc_dec_long(&(m)->v); \
11435 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
11438 +#define vx_acc_page_atomic(m, d, v, r) do { \
11440 + __acc_inc_atomic(&(m)->v); \
11442 + __acc_dec_atomic(&(m)->v); \
11443 + __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__); \
11447 +#define vx_acc_pages(m, p, v, r) do { \
11448 + unsigned long __p = (p); \
11449 + __acc_add_long(__p, &(m)->v); \
11450 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
11453 +#define vx_acc_pages_atomic(m, p, v, r) do { \
11454 + unsigned long __p = (p); \
11455 + __acc_add_atomic(__p, &(m)->v); \
11456 + __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__); \
11461 +#define vx_acc_vmpage(m, d) \
11462 + vx_acc_page(m, d, total_vm, RLIMIT_AS)
11463 +#define vx_acc_vmlpage(m, d) \
11464 + vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
11465 +#define vx_acc_file_rsspage(m, d) \
11466 + vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
11467 +#define vx_acc_anon_rsspage(m, d) \
11468 + vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
11470 +#define vx_acc_vmpages(m, p) \
11471 + vx_acc_pages(m, p, total_vm, RLIMIT_AS)
11472 +#define vx_acc_vmlpages(m, p) \
11473 + vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
11474 +#define vx_acc_file_rsspages(m, p) \
11475 + vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
11476 +#define vx_acc_anon_rsspages(m, p) \
11477 + vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
11479 +#define vx_pages_add(s, r, p) __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
11480 +#define vx_pages_sub(s, r, p) vx_pages_add(s, r, -(p))
11482 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
11483 +#define vx_vmpages_dec(m) vx_acc_vmpage(m, -1)
11484 +#define vx_vmpages_add(m, p) vx_acc_vmpages(m, p)
11485 +#define vx_vmpages_sub(m, p) vx_acc_vmpages(m, -(p))
11487 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
11488 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m, -1)
11489 +#define vx_vmlocked_add(m, p) vx_acc_vmlpages(m, p)
11490 +#define vx_vmlocked_sub(m, p) vx_acc_vmlpages(m, -(p))
11492 +#define vx_file_rsspages_inc(m) vx_acc_file_rsspage(m, 1)
11493 +#define vx_file_rsspages_dec(m) vx_acc_file_rsspage(m, -1)
11494 +#define vx_file_rsspages_add(m, p) vx_acc_file_rsspages(m, p)
11495 +#define vx_file_rsspages_sub(m, p) vx_acc_file_rsspages(m, -(p))
11497 +#define vx_anon_rsspages_inc(m) vx_acc_anon_rsspage(m, 1)
11498 +#define vx_anon_rsspages_dec(m) vx_acc_anon_rsspage(m, -1)
11499 +#define vx_anon_rsspages_add(m, p) vx_acc_anon_rsspages(m, p)
11500 +#define vx_anon_rsspages_sub(m, p) vx_acc_anon_rsspages(m, -(p))
11503 +#define vx_pages_avail(m, p, r) \
11504 + __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
11506 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
11507 +#define vx_vmlocked_avail(m, p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
11508 +#define vx_anon_avail(m, p) vx_pages_avail(m, p, VLIMIT_ANON)
11509 +#define vx_mapped_avail(m, p) vx_pages_avail(m, p, VLIMIT_MAPPED)
11511 +#define vx_rss_avail(m, p) \
11512 + __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
11516 + VXPT_UNKNOWN = 0,
11525 +#define vx_page_fault(mm, vma, type, ret)
11529 +void __vx_page_fault(struct mm_struct *mm,
11530 + struct vm_area_struct *vma, int type, int ret)
11532 + struct vx_info *vxi = mm->mm_vx_info;
11535 + static char *page_type[6] =
11536 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
11537 + static char *page_what[4] =
11538 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
11544 + what = (ret & 0x3);
11546 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
11547 + type, what, ret, page_type[type], page_what[what]);
11549 + if (ret & VM_FAULT_WRITE)
11551 + atomic_inc(&vxi->cacct.page[type][what]);
11554 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
11558 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
11561 +#warning duplicate inclusion
11563 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_network.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_network.h
11564 --- linux-2.6.24-rc7/include/linux/vs_network.h 1970-01-01 01:00:00 +0100
11565 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_network.h 2007-12-18 01:05:27 +0100
11567 +#ifndef _NX_VS_NETWORK_H
11568 +#define _NX_VS_NETWORK_H
11570 +#include "vserver/context.h"
11571 +#include "vserver/network.h"
11572 +#include "vserver/base.h"
11573 +#include "vserver/check.h"
11574 +#include "vserver/debug.h"
11577 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
11579 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
11580 + const char *_file, int _line)
11585 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
11586 + nxi, nxi ? nxi->nx_id : 0,
11587 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11590 + atomic_inc(&nxi->nx_usecnt);
11595 +extern void free_nx_info(struct nx_info *);
11597 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
11599 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
11604 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
11605 + nxi, nxi ? nxi->nx_id : 0,
11606 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11609 + if (atomic_dec_and_test(&nxi->nx_usecnt))
11610 + free_nx_info(nxi);
11614 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
11616 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
11617 + const char *_file, int _line)
11620 + vxlprintk(VXD_CBIT(nid, 3),
11621 + "init_nx_info(%p[#%d.%d])",
11622 + nxi, nxi ? nxi->nx_id : 0,
11623 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11626 + atomic_inc(&nxi->nx_usecnt);
11632 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
11634 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
11635 + const char *_file, int _line)
11637 + struct nx_info *nxo;
11642 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
11643 + nxi, nxi ? nxi->nx_id : 0,
11644 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11647 + atomic_inc(&nxi->nx_usecnt);
11648 + nxo = xchg(nxp, nxi);
11652 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
11654 +static inline void __clr_nx_info(struct nx_info **nxp,
11655 + const char *_file, int _line)
11657 + struct nx_info *nxo;
11659 + nxo = xchg(nxp, NULL);
11663 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
11664 + nxo, nxo ? nxo->nx_id : 0,
11665 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
11668 + if (atomic_dec_and_test(&nxo->nx_usecnt))
11669 + free_nx_info(nxo);
11673 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
11675 +static inline void __claim_nx_info(struct nx_info *nxi,
11676 + struct task_struct *task, const char *_file, int _line)
11678 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
11679 + nxi, nxi ? nxi->nx_id : 0,
11680 + nxi?atomic_read(&nxi->nx_usecnt):0,
11681 + nxi?atomic_read(&nxi->nx_tasks):0,
11682 + task, _file, _line);
11684 + atomic_inc(&nxi->nx_tasks);
11688 +extern void unhash_nx_info(struct nx_info *);
11690 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
11692 +static inline void __release_nx_info(struct nx_info *nxi,
11693 + struct task_struct *task, const char *_file, int _line)
11695 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
11696 + nxi, nxi ? nxi->nx_id : 0,
11697 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
11698 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
11699 + task, _file, _line);
11703 + if (atomic_dec_and_test(&nxi->nx_tasks))
11704 + unhash_nx_info(nxi);
11708 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
11710 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
11711 + const char *_file, int _line)
11713 + struct nx_info *nxi;
11716 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
11717 + p, _file, _line);
11718 + nxi = __get_nx_info(p->nx_info, _file, _line);
11726 +static inline int addr_in_nx_info(struct nx_info *nxi, uint32_t addr)
11734 + if (n && (nxi->ipv4[0] == 0))
11736 + for (i = 0; i < n; i++) {
11737 + if (nxi->ipv4[i] == addr)
11743 +static inline void exit_nx_info(struct task_struct *p)
11746 + release_nx_info(p->nx_info, p);
11751 +#warning duplicate inclusion
11753 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_pid.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_pid.h
11754 --- linux-2.6.24-rc7/include/linux/vs_pid.h 1970-01-01 01:00:00 +0100
11755 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_pid.h 2007-12-18 01:10:20 +0100
11760 +#include "vserver/base.h"
11761 +#include "vserver/check.h"
11762 +#include "vserver/context.h"
11763 +#include "vserver/debug.h"
11764 +#include "vserver/pid.h"
11765 +#include <linux/pid_namespace.h>
11768 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
11771 +int vx_proc_task_visible(struct task_struct *task)
11773 + if ((task->pid == 1) &&
11774 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
11775 + /* show a blend through init */
11777 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
11784 +#define find_task_by_real_pid find_task_by_pid
11789 +struct task_struct *vx_find_proc_task_by_pid(int pid)
11791 + struct task_struct *task = find_task_by_real_pid(pid);
11793 + if (task && !vx_proc_task_visible(task)) {
11794 + vxdprintk(VXD_CBIT(misc, 6),
11795 + "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
11796 + task, task->xid, task->pid,
11797 + current, current->xid, current->pid);
11806 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
11808 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
11810 + if (task && !vx_proc_task_visible(task)) {
11811 + vxdprintk(VXD_CBIT(misc, 6),
11812 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
11813 + task, task->xid, task->pid,
11814 + current, current->xid, current->pid);
11815 + put_task_struct(task);
11824 +struct task_struct *vx_child_reaper(struct task_struct *p)
11826 + struct vx_info *vxi = p->vx_info;
11827 + struct task_struct *reaper = child_reaper(p);
11832 + BUG_ON(!p->vx_info->vx_reaper);
11834 + /* child reaper for the guest reaper */
11835 + if (vxi->vx_reaper == p)
11838 + reaper = vxi->vx_reaper;
11840 + vxdprintk(VXD_CBIT(xid, 7),
11841 + "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
11842 + p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
11850 +#warning duplicate inclusion
11852 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_sched.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_sched.h
11853 --- linux-2.6.24-rc7/include/linux/vs_sched.h 1970-01-01 01:00:00 +0100
11854 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_sched.h 2007-12-13 13:25:25 +0100
11856 +#ifndef _VS_SCHED_H
11857 +#define _VS_SCHED_H
11859 +#include "vserver/base.h"
11860 +#include "vserver/context.h"
11861 +#include "vserver/sched.h"
11864 +#define VAVAVOOM_RATIO 50
11866 +#define MAX_PRIO_BIAS 20
11867 +#define MIN_PRIO_BIAS -20
11870 +#ifdef CONFIG_VSERVER_HARDCPU
11873 + * effective_prio - return the priority that is based on the static
11874 + * priority but is modified by bonuses/penalties.
11876 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
11877 + * into a -4 ... 0 ... +4 bonus/penalty range.
11879 + * Additionally, we scale another amount based on the number of
11880 + * CPU tokens currently held by the context, if the process is
11881 + * part of a context (and the appropriate SCHED flag is set).
11882 + * This ranges from -5 ... 0 ... +15, quadratically.
11884 + * So, the total bonus is -9 .. 0 .. +19
11885 + * We use ~50% of the full 0...39 priority range so that:
11887 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
11888 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
11889 + * unless that context is far exceeding its CPU allocation.
11891 + * Both properties are important to certain workloads.
11894 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
11896 + int vavavoom, max;
11898 + /* lots of tokens = lots of vavavoom
11899 + * no tokens = no vavavoom */
11900 + if ((vavavoom = sched_pc->tokens) >= 0) {
11901 + max = sched_pc->tokens_max;
11902 + vavavoom = max - vavavoom;
11904 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
11905 + * (vavavoom*vavavoom - (max >> 2)) / max;
11913 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
11915 + struct vx_info *vxi = p->vx_info;
11916 + struct _vx_sched_pc *sched_pc;
11921 + sched_pc = &vx_cpu(vxi, sched_pc);
11922 + if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
11923 + int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
11925 + sched_pc->vavavoom = vavavoom;
11926 + prio += vavavoom;
11928 + prio += sched_pc->prio_bias;
11932 +#else /* !CONFIG_VSERVER_HARDCPU */
11935 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
11937 + struct vx_info *vxi = p->vx_info;
11940 + prio += vx_cpu(vxi, sched_pc).prio_bias;
11944 +#endif /* CONFIG_VSERVER_HARDCPU */
11947 +static inline void vx_account_user(struct vx_info *vxi,
11948 + cputime_t cputime, int nice)
11952 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
11955 +static inline void vx_account_system(struct vx_info *vxi,
11956 + cputime_t cputime, int idle)
11960 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
11964 +#warning duplicate inclusion
11966 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_socket.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_socket.h
11967 --- linux-2.6.24-rc7/include/linux/vs_socket.h 1970-01-01 01:00:00 +0100
11968 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_socket.h 2007-12-13 13:25:25 +0100
11970 +#ifndef _VS_SOCKET_H
11971 +#define _VS_SOCKET_H
11973 +#include "vserver/debug.h"
11974 +#include "vserver/base.h"
11975 +#include "vserver/cacct.h"
11976 +#include "vserver/context.h"
11979 +/* socket accounting */
11981 +#include <linux/socket.h>
11983 +static inline int vx_sock_type(int family)
11985 + switch (family) {
11987 + return VXA_SOCK_UNSPEC;
11989 + return VXA_SOCK_UNIX;
11991 + return VXA_SOCK_INET;
11993 + return VXA_SOCK_INET6;
11995 + return VXA_SOCK_PACKET;
11997 + return VXA_SOCK_OTHER;
12001 +#define vx_acc_sock(v, f, p, s) \
12002 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
12004 +static inline void __vx_acc_sock(struct vx_info *vxi,
12005 + int family, int pos, int size, char *file, int line)
12008 + int type = vx_sock_type(family);
12010 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
12011 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
12015 +#define vx_sock_recv(sk, s) \
12016 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
12017 +#define vx_sock_send(sk, s) \
12018 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
12019 +#define vx_sock_fail(sk, s) \
12020 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
12023 +#define sock_vx_init(s) do { \
12024 + (s)->sk_xid = 0; \
12025 + (s)->sk_vx_info = NULL; \
12028 +#define sock_nx_init(s) do { \
12029 + (s)->sk_nid = 0; \
12030 + (s)->sk_nx_info = NULL; \
12035 +#warning duplicate inclusion
12037 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_tag.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_tag.h
12038 --- linux-2.6.24-rc7/include/linux/vs_tag.h 1970-01-01 01:00:00 +0100
12039 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_tag.h 2007-12-13 13:25:25 +0100
12044 +#include <linux/vserver/tag.h>
12046 +/* check conditions */
12048 +#define DX_ADMIN 0x0001
12049 +#define DX_WATCH 0x0002
12050 +#define DX_HOSTID 0x0008
12052 +#define DX_IDENT 0x0010
12054 +#define DX_ARG_MASK 0x0010
12057 +#define dx_task_tag(t) ((t)->xid)
12059 +#define dx_current_tag() dx_task_tag(current)
12061 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
12063 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
12067 + * check current context for ADMIN/WATCH and
12068 + * optionally against supplied argument
12070 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
12072 + if (mode & DX_ARG_MASK) {
12073 + if ((mode & DX_IDENT) && (id == cid))
12076 + return (((mode & DX_ADMIN) && (cid == 0)) ||
12077 + ((mode & DX_WATCH) && (cid == 1)) ||
12078 + ((mode & DX_HOSTID) && (id == 0)));
12082 +#warning duplicate inclusion
12084 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vs_time.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_time.h
12085 --- linux-2.6.24-rc7/include/linux/vs_time.h 1970-01-01 01:00:00 +0100
12086 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vs_time.h 2007-12-13 13:25:25 +0100
12088 +#ifndef _VS_TIME_H
12089 +#define _VS_TIME_H
12092 +/* time faking stuff */
12094 +#ifdef CONFIG_VSERVER_VTIME
12096 +extern void vx_gettimeofday(struct timeval *tv);
12097 +extern int vx_settimeofday(struct timespec *ts);
12100 +#define vx_gettimeofday(t) do_gettimeofday(t)
12101 +#define vx_settimeofday(t) do_settimeofday(t)
12105 +#warning duplicate inclusion
12107 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/Kbuild linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/Kbuild
12108 --- linux-2.6.24-rc7/include/linux/vserver/Kbuild 1970-01-01 01:00:00 +0100
12109 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/Kbuild 2007-12-13 13:25:26 +0100
12112 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
12113 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
12114 + inode_cmd.h sched_cmd.h signal_cmd.h debug_cmd.h
12116 +unifdef-y += switch.h network.h monitor.h inode.h
12118 +unifdef-y += legacy.h
12120 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/base.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/base.h
12121 --- linux-2.6.24-rc7/include/linux/vserver/base.h 1970-01-01 01:00:00 +0100
12122 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/base.h 2007-12-18 01:01:50 +0100
12124 +#ifndef _VX_BASE_H
12125 +#define _VX_BASE_H
12128 +/* context state changes */
12140 +#define vx_task_xid(t) ((t)->xid)
12142 +#define vx_current_xid() vx_task_xid(current)
12144 +#define current_vx_info() (current->vx_info)
12147 +#define nx_task_nid(t) ((t)->nid)
12149 +#define nx_current_nid() nx_task_nid(current)
12151 +#define current_nx_info() (current->nx_info)
12154 +/* generic flag merging */
12156 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
12158 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
12160 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
12162 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
12165 +/* context flags */
12167 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
12169 +#define vx_current_flags() __vx_flags(current->vx_info)
12171 +#define vx_info_flags(v, m, f) \
12172 + vs_check_flags(__vx_flags(v), m, f)
12174 +#define task_vx_flags(t, m, f) \
12175 + ((t) && vx_info_flags((t)->vx_info, m, f))
12177 +#define vx_flags(m, f) vx_info_flags(current->vx_info, m, f)
12180 +/* context caps */
12182 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
12184 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
12186 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
12188 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info, (c))
12192 +/* network flags */
12194 +#define __nx_flags(v) ((v) ? (v)->nx_flags : 0)
12196 +#define nx_current_flags() __nx_flags(current->nx_info)
12198 +#define nx_info_flags(v, m, f) \
12199 + vs_check_flags(__nx_flags(v), m, f)
12201 +#define task_nx_flags(t, m, f) \
12202 + ((t) && nx_info_flags((t)->nx_info, m, f))
12204 +#define nx_flags(m, f) nx_info_flags(current->nx_info, m, f)
12207 +/* network caps */
12209 +#define __nx_ncaps(v) ((v) ? (v)->nx_ncaps : 0)
12211 +#define nx_current_ncaps() __nx_ncaps(current->nx_info)
12213 +#define nx_info_ncaps(v, c) (__nx_ncaps(v) & (c))
12215 +#define nx_ncaps(c) nx_info_ncaps(current->nx_info, c)
12218 +/* context mask capabilities */
12220 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
12222 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
12224 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info, c)
12227 +/* context bcap mask */
12229 +#define __vx_bcaps(v) ((v) ? (v)->vx_bcaps : ~0 )
12231 +#define vx_current_bcaps() __vx_bcaps(current->vx_info)
12233 +#define vx_info_bcaps(v, c) (__vx_bcaps(v) & (c))
12235 +#define vx_bcaps(c) vx_info_bcaps(current->vx_info, c)
12238 +#define vx_info_cap_bset(v) ((v) ? (v)->vx_cap_bset : cap_bset)
12240 +#define vx_current_cap_bset() vx_info_cap_bset(current->vx_info)
12243 +#define __vx_info_mbcap(v, b) \
12244 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
12245 + vx_info_bcaps(v, b) : (b))
12247 +#define vx_info_mbcap(v, b) __vx_info_mbcap(v, cap_t(b))
12249 +#define task_vx_mbcap(t, b) \
12250 + vx_info_mbcap((t)->vx_info, (t)->b)
12252 +#define vx_mbcap(b) task_vx_mbcap(current, b)
12254 +#define vx_cap_raised(v, c, f) (vx_info_mbcap(v, c) & CAP_TO_MASK(f))
12256 +#define vx_capable(b, c) (capable(b) || \
12257 + (cap_raised(current->cap_effective, b) && vx_ccaps(c)))
12260 +#define vx_current_initpid(n) \
12261 + (current->vx_info && \
12262 + (current->vx_info->vx_initpid == (n)))
12265 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
12267 +#define vx_info_state(v, m) (__vx_state(v) & (m))
12270 +#define __nx_state(v) ((v) ? ((v)->nx_state) : 0)
12272 +#define nx_info_state(v, m) (__nx_state(v) & (m))
12275 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/cacct.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cacct.h
12276 --- linux-2.6.24-rc7/include/linux/vserver/cacct.h 1970-01-01 01:00:00 +0100
12277 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cacct.h 2007-12-13 13:25:37 +0100
12279 +#ifndef _VX_CACCT_H
12280 +#define _VX_CACCT_H
12283 +enum sock_acc_field {
12284 + VXA_SOCK_UNSPEC = 0,
12290 + VXA_SOCK_SIZE /* array size */
12293 +#endif /* _VX_CACCT_H */
12294 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/cacct_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cacct_cmd.h
12295 --- linux-2.6.24-rc7/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00 +0100
12296 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cacct_cmd.h 2007-12-13 13:25:43 +0100
12298 +#ifndef _VX_CACCT_CMD_H
12299 +#define _VX_CACCT_CMD_H
12302 +/* virtual host info name commands */
12304 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
12306 +struct vcmd_sock_stat_v0 {
12308 + uint32_t count[3];
12309 + uint64_t total[3];
12315 +#include <linux/compiler.h>
12317 +extern int vc_sock_stat(struct vx_info *, void __user *);
12319 +#endif /* __KERNEL__ */
12320 +#endif /* _VX_CACCT_CMD_H */
12321 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/cacct_def.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cacct_def.h
12322 --- linux-2.6.24-rc7/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00 +0100
12323 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cacct_def.h 2007-12-13 13:25:43 +0100
12325 +#ifndef _VX_CACCT_DEF_H
12326 +#define _VX_CACCT_DEF_H
12328 +#include <asm/atomic.h>
12329 +#include <linux/vserver/cacct.h>
12332 +struct _vx_sock_acc {
12333 + atomic_long_t count;
12334 + atomic_long_t total;
12337 +/* context sub struct */
12339 +struct _vx_cacct {
12340 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
12341 + atomic_t slab[8];
12342 + atomic_t page[6][8];
12345 +#ifdef CONFIG_VSERVER_DEBUG
12347 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
12351 + printk("\t_vx_cacct:");
12352 + for (i = 0; i < 6; i++) {
12353 + struct _vx_sock_acc *ptr = cacct->sock[i];
12355 + printk("\t [%d] =", i);
12356 + for (j = 0; j < 3; j++) {
12357 + printk(" [%d] = %8lu, %8lu", j,
12358 + atomic_long_read(&ptr[j].count),
12359 + atomic_long_read(&ptr[j].total));
12367 +#endif /* _VX_CACCT_DEF_H */
12368 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/cacct_int.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cacct_int.h
12369 --- linux-2.6.24-rc7/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00 +0100
12370 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cacct_int.h 2007-12-13 13:25:37 +0100
12372 +#ifndef _VX_CACCT_INT_H
12373 +#define _VX_CACCT_INT_H
12379 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
12381 + return atomic_long_read(&cacct->sock[type][pos].count);
12386 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
12388 + return atomic_long_read(&cacct->sock[type][pos].total);
12391 +#endif /* __KERNEL__ */
12392 +#endif /* _VX_CACCT_INT_H */
12393 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/check.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/check.h
12394 --- linux-2.6.24-rc7/include/linux/vserver/check.h 1970-01-01 01:00:00 +0100
12395 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/check.h 2007-12-18 01:02:45 +0100
12397 +#ifndef _VS_CHECK_H
12398 +#define _VS_CHECK_H
12401 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
12403 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
12404 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
12406 +#define MIN_D_CONTEXT 65536
12409 +/* check conditions */
12411 +#define VS_ADMIN 0x0001
12412 +#define VS_WATCH 0x0002
12413 +#define VS_HIDE 0x0004
12414 +#define VS_HOSTID 0x0008
12416 +#define VS_IDENT 0x0010
12417 +#define VS_EQUIV 0x0020
12418 +#define VS_PARENT 0x0040
12419 +#define VS_CHILD 0x0080
12421 +#define VS_ARG_MASK 0x00F0
12423 +#define VS_DYNAMIC 0x0100
12424 +#define VS_STATIC 0x0200
12426 +#define VS_ATR_MASK 0x0F00
12428 +#ifdef CONFIG_VSERVER_PRIVACY
12429 +#define VS_ADMIN_P (0)
12430 +#define VS_WATCH_P (0)
12432 +#define VS_ADMIN_P VS_ADMIN
12433 +#define VS_WATCH_P VS_WATCH
12436 +#define VS_HARDIRQ 0x1000
12437 +#define VS_SOFTIRQ 0x2000
12438 +#define VS_IRQ 0x4000
12440 +#define VS_IRQ_MASK 0xF000
12442 +#include <linux/hardirq.h>
12445 + * check current context for ADMIN/WATCH and
12446 + * optionally against supplied argument
12448 +static inline int __vs_check(int cid, int id, unsigned int mode)
12450 + if (mode & VS_ARG_MASK) {
12451 + if ((mode & VS_IDENT) && (id == cid))
12454 + if (mode & VS_ATR_MASK) {
12455 + if ((mode & VS_DYNAMIC) &&
12456 + (id >= MIN_D_CONTEXT) &&
12457 + (id <= MAX_S_CONTEXT))
12459 + if ((mode & VS_STATIC) &&
12460 + (id > 1) && (id < MIN_D_CONTEXT))
12463 + if (mode & VS_IRQ_MASK) {
12464 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
12466 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
12468 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
12471 + return (((mode & VS_ADMIN) && (cid == 0)) ||
12472 + ((mode & VS_WATCH) && (cid == 1)) ||
12473 + ((mode & VS_HOSTID) && (id == 0)));
12476 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
12478 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
12481 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
12483 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
12486 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/context.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/context.h
12487 --- linux-2.6.24-rc7/include/linux/vserver/context.h 1970-01-01 01:00:00 +0100
12488 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/context.h 2007-12-13 13:25:29 +0100
12490 +#ifndef _VX_CONTEXT_H
12491 +#define _VX_CONTEXT_H
12493 +#include <linux/types.h>
12494 +#include <linux/capability.h>
12497 +#define VX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
12499 +/* context flags */
12501 +#define VXF_INFO_SCHED 0x00000002
12502 +#define VXF_INFO_NPROC 0x00000004
12503 +#define VXF_INFO_PRIVATE 0x00000008
12505 +#define VXF_INFO_INIT 0x00000010
12506 +#define VXF_INFO_HIDE 0x00000020
12507 +#define VXF_INFO_ULIMIT 0x00000040
12508 +#define VXF_INFO_NSPACE 0x00000080
12510 +#define VXF_SCHED_HARD 0x00000100
12511 +#define VXF_SCHED_PRIO 0x00000200
12512 +#define VXF_SCHED_PAUSE 0x00000400
12514 +#define VXF_VIRT_MEM 0x00010000
12515 +#define VXF_VIRT_UPTIME 0x00020000
12516 +#define VXF_VIRT_CPU 0x00040000
12517 +#define VXF_VIRT_LOAD 0x00080000
12518 +#define VXF_VIRT_TIME 0x00100000
12520 +#define VXF_HIDE_MOUNT 0x01000000
12521 +#define VXF_HIDE_NETIF 0x02000000
12522 +#define VXF_HIDE_VINFO 0x04000000
12524 +#define VXF_STATE_SETUP (1ULL << 32)
12525 +#define VXF_STATE_INIT (1ULL << 33)
12526 +#define VXF_STATE_ADMIN (1ULL << 34)
12528 +#define VXF_SC_HELPER (1ULL << 36)
12529 +#define VXF_REBOOT_KILL (1ULL << 37)
12530 +#define VXF_PERSISTENT (1ULL << 38)
12532 +#define VXF_FORK_RSS (1ULL << 48)
12533 +#define VXF_PROLIFIC (1ULL << 49)
12535 +#define VXF_IGNEG_NICE (1ULL << 52)
12537 +#define VXF_ONE_TIME (0x0007ULL << 32)
12539 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12542 +/* context migration */
12544 +#define VXM_SET_INIT 0x00000001
12545 +#define VXM_SET_REAPER 0x00000002
12547 +/* context caps */
12549 +#define VXC_CAP_MASK 0x00000000
12551 +#define VXC_SET_UTSNAME 0x00000001
12552 +#define VXC_SET_RLIMIT 0x00000002
12554 +#define VXC_RAW_ICMP 0x00000100
12555 +#define VXC_SYSLOG 0x00001000
12557 +#define VXC_SECURE_MOUNT 0x00010000
12558 +#define VXC_SECURE_REMOUNT 0x00020000
12559 +#define VXC_BINARY_MOUNT 0x00040000
12561 +#define VXC_QUOTA_CTL 0x00100000
12562 +#define VXC_ADMIN_MAPPER 0x00200000
12563 +#define VXC_ADMIN_CLOOP 0x00400000
12568 +#include <linux/list.h>
12569 +#include <linux/spinlock.h>
12570 +#include <linux/rcupdate.h>
12572 +#include "limit_def.h"
12573 +#include "sched_def.h"
12574 +#include "cvirt_def.h"
12575 +#include "cacct_def.h"
12577 +struct _vx_info_pc {
12578 + struct _vx_sched_pc sched_pc;
12579 + struct _vx_cvirt_pc cvirt_pc;
12583 + struct hlist_node vx_hlist; /* linked list of contexts */
12584 + xid_t vx_id; /* context id */
12585 + atomic_t vx_usecnt; /* usage count */
12586 + atomic_t vx_tasks; /* tasks count */
12587 + struct vx_info *vx_parent; /* parent context */
12588 + int vx_state; /* context state */
12590 + unsigned long vx_nsmask; /* assignment mask */
12591 + struct nsproxy *vx_nsproxy; /* private namespace */
12592 + struct fs_struct *vx_fs; /* private namespace fs */
12594 + uint64_t vx_flags; /* context flags */
12595 + uint64_t vx_bcaps; /* bounding caps (system) */
12596 + uint64_t vx_ccaps; /* context caps (vserver) */
12597 + kernel_cap_t vx_cap_bset; /* the guest's bset */
12599 + struct task_struct *vx_reaper; /* guest reaper process */
12600 + pid_t vx_initpid; /* PID of guest init */
12602 + struct _vx_limit limit; /* vserver limits */
12603 + struct _vx_sched sched; /* vserver scheduler */
12604 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
12605 + struct _vx_cacct cacct; /* context accounting */
12607 +#ifndef CONFIG_SMP
12608 + struct _vx_info_pc info_pc; /* per cpu data */
12610 + struct _vx_info_pc *ptr_pc; /* per cpu array */
12613 + wait_queue_head_t vx_wait; /* context exit waitqueue */
12614 + int reboot_cmd; /* last sys_reboot() cmd */
12615 + int exit_code; /* last process exit code */
12617 + char vx_name[65]; /* vserver name */
12620 +#ifndef CONFIG_SMP
12621 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
12622 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
12624 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
12625 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
12628 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
12631 +struct vx_info_save {
12632 + struct vx_info *vxi;
12637 +/* status flags */
12639 +#define VXS_HASHED 0x0001
12640 +#define VXS_PAUSED 0x0010
12641 +#define VXS_SHUTDOWN 0x0100
12642 +#define VXS_HELPER 0x1000
12643 +#define VXS_RELEASED 0x8000
12646 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
12647 +extern void release_vx_info(struct vx_info *, struct task_struct *);
12649 +extern struct vx_info *lookup_vx_info(int);
12650 +extern struct vx_info *lookup_or_create_vx_info(int);
12652 +extern int get_xid_list(int, unsigned int *, int);
12653 +extern int xid_is_hashed(xid_t);
12655 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
12657 +extern long vs_state_change(struct vx_info *, unsigned int);
12660 +#endif /* __KERNEL__ */
12661 +#endif /* _VX_CONTEXT_H */
12662 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/context_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/context_cmd.h
12663 --- linux-2.6.24-rc7/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00 +0100
12664 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/context_cmd.h 2007-12-13 13:25:43 +0100
12666 +#ifndef _VX_CONTEXT_CMD_H
12667 +#define _VX_CONTEXT_CMD_H
12670 +/* vinfo commands */
12672 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
12675 +extern int vc_task_xid(uint32_t, void __user *);
12677 +#endif /* __KERNEL__ */
12679 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
12681 +struct vcmd_vx_info_v0 {
12683 + uint32_t initpid;
12684 + /* more to come */
12688 +extern int vc_vx_info(struct vx_info *, void __user *);
12690 +#endif /* __KERNEL__ */
12692 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
12694 +struct vcmd_ctx_stat_v0 {
12697 + /* more to come */
12701 +extern int vc_ctx_stat(struct vx_info *, void __user *);
12703 +#endif /* __KERNEL__ */
12705 +/* context commands */
12707 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
12708 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
12710 +struct vcmd_ctx_create {
12711 + uint64_t flagword;
12714 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
12715 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
12717 +struct vcmd_ctx_migrate {
12718 + uint64_t flagword;
12722 +extern int vc_ctx_create(uint32_t, void __user *);
12723 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
12725 +#endif /* __KERNEL__ */
12728 +/* flag commands */
12730 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
12731 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
12733 +struct vcmd_ctx_flags_v0 {
12734 + uint64_t flagword;
12739 +extern int vc_get_cflags(struct vx_info *, void __user *);
12740 +extern int vc_set_cflags(struct vx_info *, void __user *);
12742 +#endif /* __KERNEL__ */
12745 +/* context caps commands */
12747 +#define VCMD_get_ccaps_v0 VC_CMD(FLAGS, 3, 0)
12748 +#define VCMD_set_ccaps_v0 VC_CMD(FLAGS, 4, 0)
12750 +struct vcmd_ctx_caps_v0 {
12756 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
12757 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
12759 +struct vcmd_ctx_caps_v1 {
12765 +extern int vc_get_ccaps_v0(struct vx_info *, void __user *);
12766 +extern int vc_set_ccaps_v0(struct vx_info *, void __user *);
12767 +extern int vc_get_ccaps(struct vx_info *, void __user *);
12768 +extern int vc_set_ccaps(struct vx_info *, void __user *);
12770 +#endif /* __KERNEL__ */
12773 +/* bcaps commands */
12775 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
12776 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
12778 +struct vcmd_bcaps {
12784 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12785 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12787 +#endif /* __KERNEL__ */
12788 +#endif /* _VX_CONTEXT_CMD_H */
12789 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/cvirt.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cvirt.h
12790 --- linux-2.6.24-rc7/include/linux/vserver/cvirt.h 1970-01-01 01:00:00 +0100
12791 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cvirt.h 2007-12-13 13:25:37 +0100
12793 +#ifndef _VX_CVIRT_H
12794 +#define _VX_CVIRT_H
12801 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12806 +void vx_update_load(struct vx_info *);
12809 +int vx_do_syslog(int, char __user *, int);
12811 +#endif /* __KERNEL__ */
12812 +#endif /* _VX_CVIRT_H */
12813 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/cvirt_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cvirt_cmd.h
12814 --- linux-2.6.24-rc7/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00 +0100
12815 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cvirt_cmd.h 2007-12-13 13:25:43 +0100
12817 +#ifndef _VX_CVIRT_CMD_H
12818 +#define _VX_CVIRT_CMD_H
12821 +/* virtual host info name commands */
12823 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
12824 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
12826 +struct vcmd_vhi_name_v0 {
12832 +enum vhi_name_field {
12833 + VHIN_CONTEXT = 0,
12845 +#include <linux/compiler.h>
12847 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12848 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12850 +#endif /* __KERNEL__ */
12852 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
12854 +struct vcmd_virt_stat_v0 {
12857 + uint32_t nr_threads;
12858 + uint32_t nr_running;
12859 + uint32_t nr_uninterruptible;
12860 + uint32_t nr_onhold;
12861 + uint32_t nr_forks;
12862 + uint32_t load[3];
12866 +extern int vc_virt_stat(struct vx_info *, void __user *);
12868 +#endif /* __KERNEL__ */
12869 +#endif /* _VX_CVIRT_CMD_H */
12870 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/cvirt_def.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cvirt_def.h
12871 --- linux-2.6.24-rc7/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00 +0100
12872 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/cvirt_def.h 2007-12-18 01:08:19 +0100
12874 +#ifndef _VX_CVIRT_DEF_H
12875 +#define _VX_CVIRT_DEF_H
12877 +#include <linux/jiffies.h>
12878 +#include <linux/spinlock.h>
12879 +#include <linux/wait.h>
12880 +#include <linux/time.h>
12881 +#include <asm/atomic.h>
12884 +struct _vx_usage_stat {
12888 + uint64_t softirq;
12894 +struct _vx_syslog {
12895 + wait_queue_head_t log_wait;
12896 + spinlock_t logbuf_lock; /* lock for the log buffer */
12898 + unsigned long log_start; /* next char to be read by syslog() */
12899 + unsigned long con_start; /* next char to be sent to consoles */
12900 + unsigned long log_end; /* most-recently-written-char + 1 */
12901 + unsigned long logged_chars; /* #chars since last read+clear operation */
12903 + char log_buf[1024];
12907 +/* context sub struct */
12909 +struct _vx_cvirt {
12910 + atomic_t nr_threads; /* number of current threads */
12911 + atomic_t nr_running; /* number of running threads */
12912 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
12914 + atomic_t nr_onhold; /* processes on hold */
12915 + uint32_t onhold_last; /* jiffies when put on hold */
12917 + struct timeval bias_tv; /* time offset to the host */
12918 + struct timespec bias_idle;
12919 + struct timespec bias_uptime; /* context creation point */
12920 + uint64_t bias_clock; /* offset in clock_t */
12922 + spinlock_t load_lock; /* lock for the load averages */
12923 + atomic_t load_updates; /* nr of load updates done so far */
12924 + uint32_t load_last; /* last time load was calculated */
12925 + uint32_t load[3]; /* load averages 1,5,15 */
12927 + atomic_t total_forks; /* number of forks so far */
12929 + struct _vx_syslog syslog;
12932 +struct _vx_cvirt_pc {
12933 + struct _vx_usage_stat cpustat;
12937 +#ifdef CONFIG_VSERVER_DEBUG
12939 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12941 + printk("\t_vx_cvirt:\n");
12942 + printk("\t threads: %4d, %4d, %4d, %4d\n",
12943 + atomic_read(&cvirt->nr_threads),
12944 + atomic_read(&cvirt->nr_running),
12945 + atomic_read(&cvirt->nr_uninterruptible),
12946 + atomic_read(&cvirt->nr_onhold));
12947 + /* add rest here */
12948 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12953 +#endif /* _VX_CVIRT_DEF_H */
12954 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/debug.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/debug.h
12955 --- linux-2.6.24-rc7/include/linux/vserver/debug.h 1970-01-01 01:00:00 +0100
12956 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/debug.h 2007-12-13 13:25:42 +0100
12958 +#ifndef _VX_DEBUG_H
12959 +#define _VX_DEBUG_H
12962 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12963 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12964 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12966 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
12967 + imajor((d)->bd_inode), iminor((d)->bd_inode)
12968 +#define VXF_DEV "%p[%lu,%d:%d]"
12971 +#define __FUNC__ __func__
12974 +#define vxd_path(d, m) \
12975 + ({ static char _buffer[PATH_MAX]; \
12976 + d_path(d, m, _buffer, sizeof(_buffer)); })
12978 +#define vxd_cond_path(n) \
12979 + ((n) ? vxd_path((n)->dentry, (n)->mnt) : "<null>" )
12982 +#ifdef CONFIG_VSERVER_DEBUG
12984 +extern unsigned int vx_debug_switch;
12985 +extern unsigned int vx_debug_xid;
12986 +extern unsigned int vx_debug_nid;
12987 +extern unsigned int vx_debug_tag;
12988 +extern unsigned int vx_debug_net;
12989 +extern unsigned int vx_debug_limit;
12990 +extern unsigned int vx_debug_cres;
12991 +extern unsigned int vx_debug_dlim;
12992 +extern unsigned int vx_debug_quota;
12993 +extern unsigned int vx_debug_cvirt;
12994 +extern unsigned int vx_debug_space;
12995 +extern unsigned int vx_debug_misc;
12998 +#define VX_LOGLEVEL "vxD: "
13000 +#define vxdprintk(c, f, x...) \
13003 + printk(VX_LOGLEVEL f "\n" , ##x); \
13006 +#define vxlprintk(c, f, x...) \
13009 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
13012 +#define vxfprintk(c, f, x...) \
13015 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
13021 +void dump_vx_info(struct vx_info *, int);
13022 +void dump_vx_info_inactive(int);
13024 +#else /* CONFIG_VSERVER_DEBUG */
13026 +#define vx_debug_switch 0
13027 +#define vx_debug_xid 0
13028 +#define vx_debug_nid 0
13029 +#define vx_debug_tag 0
13030 +#define vx_debug_net 0
13031 +#define vx_debug_limit 0
13032 +#define vx_debug_cres 0
13033 +#define vx_debug_dlim 0
13034 +#define vx_debug_cvirt 0
13036 +#define vxdprintk(x...) do { } while (0)
13037 +#define vxlprintk(x...) do { } while (0)
13038 +#define vxfprintk(x...) do { } while (0)
13040 +#endif /* CONFIG_VSERVER_DEBUG */
13043 +#ifdef CONFIG_VSERVER_WARN
13045 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
13046 +#define VX_WARN_TASK "[»%s«,%u:#%u|%u] "
13047 +#define VX_WARN_XID "[xid #%u] "
13048 +#define VX_WARN_NID "[nid #%u] "
13050 +#define vxwprintk(c, f, x...) \
13053 + printk(VX_WARNLEVEL f "\n", ##x); \
13056 +#else /* CONFIG_VSERVER_WARN */
13058 +#define vxwprintk(x...) do { } while (0)
13060 +#endif /* CONFIG_VSERVER_WARN */
13062 +#define vxwprintk_task(c, f, x...) \
13063 + vxwprintk(c, VX_WARN_TASK f, \
13064 + current->comm, current->pid, \
13065 + current->xid, current->nid, ##x)
13066 +#define vxwprintk_xid(c, f, x...) \
13067 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
13068 +#define vxwprintk_nid(c, f, x...) \
13069 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
13071 +#ifdef CONFIG_VSERVER_DEBUG
13072 +#define vxd_assert_lock(l) assert_spin_locked(l)
13073 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
13074 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
13076 +#define vxd_assert_lock(l) do { } while (0)
13077 +#define vxd_assert(c, f, x...) do { } while (0)
13081 +#endif /* _VX_DEBUG_H */
13082 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/debug_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/debug_cmd.h
13083 --- linux-2.6.24-rc7/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00 +0100
13084 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/debug_cmd.h 2007-12-13 13:25:43 +0100
13086 +#ifndef _VX_DEBUG_CMD_H
13087 +#define _VX_DEBUG_CMD_H
13090 +/* debug commands */
13092 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
13094 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
13095 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
13097 +struct vcmd_read_history_v0 {
13100 + char __user *data;
13103 +struct vcmd_read_monitor_v0 {
13106 + char __user *data;
13112 +#ifdef CONFIG_COMPAT
13114 +#include <asm/compat.h>
13116 +struct vcmd_read_history_v0_x32 {
13119 + compat_uptr_t data_ptr;
13122 +struct vcmd_read_monitor_v0_x32 {
13125 + compat_uptr_t data_ptr;
13128 +#endif /* CONFIG_COMPAT */
13130 +extern int vc_dump_history(uint32_t);
13132 +extern int vc_read_history(uint32_t, void __user *);
13133 +extern int vc_read_monitor(uint32_t, void __user *);
13135 +#ifdef CONFIG_COMPAT
13137 +extern int vc_read_history_x32(uint32_t, void __user *);
13138 +extern int vc_read_monitor_x32(uint32_t, void __user *);
13140 +#endif /* CONFIG_COMPAT */
13142 +#endif /* __KERNEL__ */
13143 +#endif /* _VX_DEBUG_CMD_H */
13144 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/dlimit.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/dlimit.h
13145 --- linux-2.6.24-rc7/include/linux/vserver/dlimit.h 1970-01-01 01:00:00 +0100
13146 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/dlimit.h 2007-12-13 13:25:46 +0100
13148 +#ifndef _VX_DLIMIT_H
13149 +#define _VX_DLIMIT_H
13151 +#include "switch.h"
13156 +/* keep in sync with CDLIM_INFINITY */
13158 +#define DLIM_INFINITY (~0ULL)
13160 +#include <linux/spinlock.h>
13162 +struct super_block;
13165 + struct hlist_node dl_hlist; /* linked list of contexts */
13166 + struct rcu_head dl_rcu; /* the rcu head */
13167 + tag_t dl_tag; /* context tag */
13168 + atomic_t dl_usecnt; /* usage count */
13169 + atomic_t dl_refcnt; /* reference count */
13171 + struct super_block *dl_sb; /* associated superblock */
13173 + spinlock_t dl_lock; /* protect the values */
13175 + unsigned long long dl_space_used; /* used space in bytes */
13176 + unsigned long long dl_space_total; /* maximum space in bytes */
13177 + unsigned long dl_inodes_used; /* used inodes */
13178 + unsigned long dl_inodes_total; /* maximum inodes */
13180 + unsigned int dl_nrlmult; /* non root limit mult */
13185 +extern void rcu_free_dl_info(struct rcu_head *);
13186 +extern void unhash_dl_info(struct dl_info *);
13188 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
13193 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
13195 +typedef uint64_t dlsize_t;
13197 +#endif /* __KERNEL__ */
13198 +#else /* _VX_DLIMIT_H */
13199 +#warning duplicate inclusion
13200 +#endif /* _VX_DLIMIT_H */
13201 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/dlimit_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/dlimit_cmd.h
13202 --- linux-2.6.24-rc7/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00 +0100
13203 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/dlimit_cmd.h 2007-12-13 13:25:43 +0100
13205 +#ifndef _VX_DLIMIT_CMD_H
13206 +#define _VX_DLIMIT_CMD_H
13209 +/* dlimit vserver commands */
13211 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
13212 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
13214 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
13215 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
13217 +struct vcmd_ctx_dlimit_base_v0 {
13218 + const char __user *name;
13222 +struct vcmd_ctx_dlimit_v0 {
13223 + const char __user *name;
13224 + uint32_t space_used; /* used space in kbytes */
13225 + uint32_t space_total; /* maximum space in kbytes */
13226 + uint32_t inodes_used; /* used inodes */
13227 + uint32_t inodes_total; /* maximum inodes */
13228 + uint32_t reserved; /* reserved for root in % */
13232 +#define CDLIM_UNSET ((uint32_t)0UL)
13233 +#define CDLIM_INFINITY ((uint32_t)~0UL)
13234 +#define CDLIM_KEEP ((uint32_t)~1UL)
13238 +#ifdef CONFIG_COMPAT
13240 +#include <asm/compat.h>
13242 +struct vcmd_ctx_dlimit_base_v0_x32 {
13243 + compat_uptr_t name_ptr;
13247 +struct vcmd_ctx_dlimit_v0_x32 {
13248 + compat_uptr_t name_ptr;
13249 + uint32_t space_used; /* used space in kbytes */
13250 + uint32_t space_total; /* maximum space in kbytes */
13251 + uint32_t inodes_used; /* used inodes */
13252 + uint32_t inodes_total; /* maximum inodes */
13253 + uint32_t reserved; /* reserved for root in % */
13257 +#endif /* CONFIG_COMPAT */
13259 +#include <linux/compiler.h>
13261 +extern int vc_add_dlimit(uint32_t, void __user *);
13262 +extern int vc_rem_dlimit(uint32_t, void __user *);
13264 +extern int vc_set_dlimit(uint32_t, void __user *);
13265 +extern int vc_get_dlimit(uint32_t, void __user *);
13267 +#ifdef CONFIG_COMPAT
13269 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
13270 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
13272 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
13273 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
13275 +#endif /* CONFIG_COMPAT */
13277 +#endif /* __KERNEL__ */
13278 +#endif /* _VX_DLIMIT_CMD_H */
13279 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/global.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/global.h
13280 --- linux-2.6.24-rc7/include/linux/vserver/global.h 1970-01-01 01:00:00 +0100
13281 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/global.h 2007-12-15 00:32:17 +0100
13283 +#ifndef _VX_GLOBAL_H
13284 +#define _VX_GLOBAL_H
13287 +extern atomic_t vx_global_ctotal;
13288 +extern atomic_t vx_global_cactive;
13290 +extern atomic_t nx_global_ctotal;
13291 +extern atomic_t nx_global_cactive;
13293 +extern atomic_t vs_global_nsproxy;
13294 +extern atomic_t vs_global_fs;
13295 +extern atomic_t vs_global_mnt_ns;
13296 +extern atomic_t vs_global_uts_ns;
13297 +extern atomic_t vs_global_ipc_ns;
13298 +extern atomic_t vs_global_user_ns;
13299 +extern atomic_t vs_global_pid_ns;
13302 +#endif /* _VX_GLOBAL_H */
13303 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/history.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/history.h
13304 --- linux-2.6.24-rc7/include/linux/vserver/history.h 1970-01-01 01:00:00 +0100
13305 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/history.h 2007-12-13 13:25:42 +0100
13307 +#ifndef _VX_HISTORY_H
13308 +#define _VX_HISTORY_H
13313 + VXH_THROW_OOPS = 1,
13317 + VXH_INIT_VX_INFO,
13320 + VXH_CLAIM_VX_INFO,
13321 + VXH_RELEASE_VX_INFO,
13322 + VXH_ALLOC_VX_INFO,
13323 + VXH_DEALLOC_VX_INFO,
13324 + VXH_HASH_VX_INFO,
13325 + VXH_UNHASH_VX_INFO,
13327 + VXH_LOOKUP_VX_INFO,
13328 + VXH_CREATE_VX_INFO,
13331 +struct _vxhe_vxi {
13332 + struct vx_info *ptr;
13338 +struct _vxhe_set_clr {
13342 +struct _vxhe_loc_lookup {
13346 +struct _vx_hist_entry {
13348 + unsigned short seq;
13349 + unsigned short type;
13350 + struct _vxhe_vxi vxi;
13352 + struct _vxhe_set_clr sc;
13353 + struct _vxhe_loc_lookup ll;
13357 +#ifdef CONFIG_VSERVER_HISTORY
13359 +extern unsigned volatile int vxh_active;
13361 +struct _vx_hist_entry *vxh_advance(void *loc);
13365 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
13367 + entry->vxi.ptr = vxi;
13369 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
13370 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
13371 + entry->vxi.xid = vxi->vx_id;
13376 +#define __HERE__ current_text_addr()
13378 +#define __VXH_BODY(__type, __data, __here) \
13379 + struct _vx_hist_entry *entry; \
13381 + preempt_disable(); \
13382 + entry = vxh_advance(__here); \
13384 + entry->type = __type; \
13385 + preempt_enable();
13388 + /* pass vxi only */
13390 +#define __VXH_SMPL \
13391 + __vxh_copy_vxi(entry, vxi)
13394 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
13396 + __VXH_BODY(__type, __VXH_SMPL, __here)
13399 + /* pass vxi and data (void *) */
13401 +#define __VXH_DATA \
13402 + __vxh_copy_vxi(entry, vxi); \
13403 + entry->sc.data = data
13406 +void __vxh_data(struct vx_info *vxi, void *data,
13407 + int __type, void *__here)
13409 + __VXH_BODY(__type, __VXH_DATA, __here)
13412 + /* pass vxi and arg (long) */
13414 +#define __VXH_LONG \
13415 + __vxh_copy_vxi(entry, vxi); \
13416 + entry->ll.arg = arg
13419 +void __vxh_long(struct vx_info *vxi, long arg,
13420 + int __type, void *__here)
13422 + __VXH_BODY(__type, __VXH_LONG, __here)
13427 +void __vxh_throw_oops(void *__here)
13429 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
13430 + /* prevent further acquisition */
13435 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
13437 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
13438 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13440 +#define __vxh_init_vx_info(v, d, h) \
13441 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13442 +#define __vxh_set_vx_info(v, d, h) \
13443 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
13444 +#define __vxh_clr_vx_info(v, d, h) \
13445 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13447 +#define __vxh_claim_vx_info(v, d, h) \
13448 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13449 +#define __vxh_release_vx_info(v, d, h) \
13450 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13452 +#define vxh_alloc_vx_info(v) \
13453 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13454 +#define vxh_dealloc_vx_info(v) \
13455 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13457 +#define vxh_hash_vx_info(v) \
13458 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13459 +#define vxh_unhash_vx_info(v) \
13460 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13462 +#define vxh_loc_vx_info(v, l) \
13463 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13464 +#define vxh_lookup_vx_info(v, l) \
13465 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13466 +#define vxh_create_vx_info(v, l) \
13467 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13469 +extern void vxh_dump_history(void);
13472 +#else /* CONFIG_VSERVER_HISTORY */
13474 +#define __HERE__ 0
13476 +#define vxh_throw_oops() do { } while (0)
13478 +#define __vxh_get_vx_info(v, h) do { } while (0)
13479 +#define __vxh_put_vx_info(v, h) do { } while (0)
13481 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
13482 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
13483 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
13485 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
13486 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13488 +#define vxh_alloc_vx_info(v) do { } while (0)
13489 +#define vxh_dealloc_vx_info(v) do { } while (0)
13491 +#define vxh_hash_vx_info(v) do { } while (0)
13492 +#define vxh_unhash_vx_info(v) do { } while (0)
13494 +#define vxh_loc_vx_info(v, l) do { } while (0)
13495 +#define vxh_lookup_vx_info(v, l) do { } while (0)
13496 +#define vxh_create_vx_info(v, l) do { } while (0)
13498 +#define vxh_dump_history() do { } while (0)
13501 +#endif /* CONFIG_VSERVER_HISTORY */
13503 +#endif /* _VX_HISTORY_H */
13504 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/inode.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/inode.h
13505 --- linux-2.6.24-rc7/include/linux/vserver/inode.h 1970-01-01 01:00:00 +0100
13506 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/inode.h 2007-12-13 13:25:38 +0100
13508 +#ifndef _VX_INODE_H
13509 +#define _VX_INODE_H
13512 +#define IATTR_TAG 0x01000000
13514 +#define IATTR_ADMIN 0x00000001
13515 +#define IATTR_WATCH 0x00000002
13516 +#define IATTR_HIDE 0x00000004
13517 +#define IATTR_FLAGS 0x00000007
13519 +#define IATTR_BARRIER 0x00010000
13520 +#define IATTR_IUNLINK 0x00020000
13521 +#define IATTR_IMMUTABLE 0x00040000
13526 +#ifdef CONFIG_VSERVER_PROC_SECURE
13527 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
13528 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
13530 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
13531 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
13534 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
13536 +#endif /* __KERNEL__ */
13538 +/* inode ioctls */
13540 +#define FIOC_GETXFLG _IOR('x', 5, long)
13541 +#define FIOC_SETXFLG _IOW('x', 6, long)
13543 +#else /* _VX_INODE_H */
13544 +#warning duplicate inclusion
13545 +#endif /* _VX_INODE_H */
13546 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/inode_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/inode_cmd.h
13547 --- linux-2.6.24-rc7/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00 +0100
13548 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/inode_cmd.h 2007-12-13 13:25:43 +0100
13550 +#ifndef _VX_INODE_CMD_H
13551 +#define _VX_INODE_CMD_H
13554 +/* inode vserver commands */
13556 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
13557 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
13559 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
13560 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
13562 +struct vcmd_ctx_iattr_v1 {
13563 + const char __user *name;
13569 +struct vcmd_ctx_fiattr_v0 {
13579 +#ifdef CONFIG_COMPAT
13581 +#include <asm/compat.h>
13583 +struct vcmd_ctx_iattr_v1_x32 {
13584 + compat_uptr_t name_ptr;
13590 +#endif /* CONFIG_COMPAT */
13592 +#include <linux/compiler.h>
13594 +extern int vc_get_iattr(void __user *);
13595 +extern int vc_set_iattr(void __user *);
13597 +extern int vc_fget_iattr(uint32_t, void __user *);
13598 +extern int vc_fset_iattr(uint32_t, void __user *);
13600 +#ifdef CONFIG_COMPAT
13602 +extern int vc_get_iattr_x32(void __user *);
13603 +extern int vc_set_iattr_x32(void __user *);
13605 +#endif /* CONFIG_COMPAT */
13607 +#endif /* __KERNEL__ */
13608 +#endif /* _VX_INODE_CMD_H */
13609 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/legacy.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/legacy.h
13610 --- linux-2.6.24-rc7/include/linux/vserver/legacy.h 1970-01-01 01:00:00 +0100
13611 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/legacy.h 2007-12-13 13:25:52 +0100
13613 +#ifndef _VX_LEGACY_H
13614 +#define _VX_LEGACY_H
13616 +#include "switch.h"
13619 +/* compatibiliy vserver commands */
13621 +#define VCMD_new_s_context VC_CMD(COMPAT, 1, 1)
13622 +#define VCMD_set_ipv4root VC_CMD(COMPAT, 2, 3)
13624 +#define VCMD_create_context VC_CMD(VSETUP, 1, 0)
13626 +/* compatibiliy vserver arguments */
13628 +struct vcmd_new_s_context_v1 {
13629 + uint32_t remove_cap;
13633 +struct vcmd_set_ipv4root_v3 {
13634 + /* number of pairs in id */
13635 + uint32_t broadcast;
13639 + } nx_mask_pair[NB_IPV4ROOT];
13643 +#define VX_INFO_LOCK 1 /* Can't request a new vx_id */
13644 +#define VX_INFO_NPROC 4 /* Limit number of processes in a context */
13645 +#define VX_INFO_PRIVATE 8 /* Noone can join this security context */
13646 +#define VX_INFO_INIT 16 /* This process wants to become the */
13647 + /* logical process 1 of the security */
13649 +#define VX_INFO_HIDEINFO 32 /* Hide some information in /proc */
13650 +#define VX_INFO_ULIMIT 64 /* Use ulimit of the current process */
13651 + /* to become the global limits */
13652 + /* of the context */
13653 +#define VX_INFO_NAMESPACE 128 /* save private namespace */
13657 +extern int vc_new_s_context(uint32_t, void __user *);
13658 +extern int vc_set_ipv4root(uint32_t, void __user *);
13660 +#endif /* __KERNEL__ */
13661 +#endif /* _VX_LEGACY_H */
13662 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/limit.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/limit.h
13663 --- linux-2.6.24-rc7/include/linux/vserver/limit.h 1970-01-01 01:00:00 +0100
13664 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/limit.h 2007-12-13 13:25:42 +0100
13666 +#ifndef _VX_LIMIT_H
13667 +#define _VX_LIMIT_H
13670 +#define VLIMIT_NSOCK 16
13671 +#define VLIMIT_OPENFD 17
13672 +#define VLIMIT_ANON 18
13673 +#define VLIMIT_SHMEM 19
13674 +#define VLIMIT_SEMARY 20
13675 +#define VLIMIT_NSEMS 21
13676 +#define VLIMIT_DENTRY 22
13677 +#define VLIMIT_MAPPED 23
13682 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13684 +/* keep in sync with CRLIM_INFINITY */
13686 +#define VLIM_INFINITY (~0ULL)
13688 +#ifndef RLIM_INFINITY
13689 +#warning RLIM_INFINITY is undefined
13692 +#define __rlim_val(l, r, v) ((l)->res[r].v)
13694 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
13695 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
13697 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
13698 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
13699 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
13701 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
13702 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
13704 +typedef atomic_long_t rlim_atomic_t;
13705 +typedef unsigned long rlim_t;
13707 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
13708 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
13709 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
13710 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
13711 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
13712 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
13715 +#if (RLIM_INFINITY == VLIM_INFINITY)
13716 +#define VX_VLIM(r) ((long long)(long)(r))
13717 +#define VX_RLIM(v) ((rlim_t)(v))
13719 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
13720 + ? VLIM_INFINITY : (long long)(r))
13721 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
13722 + ? RLIM_INFINITY : (rlim_t)(v))
13727 +void vx_vsi_meminfo(struct sysinfo *);
13728 +void vx_vsi_swapinfo(struct sysinfo *);
13730 +#define NUM_LIMITS 24
13732 +#endif /* __KERNEL__ */
13733 +#endif /* _VX_LIMIT_H */
13734 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/limit_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/limit_cmd.h
13735 --- linux-2.6.24-rc7/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00 +0100
13736 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/limit_cmd.h 2007-12-13 13:25:43 +0100
13738 +#ifndef _VX_LIMIT_CMD_H
13739 +#define _VX_LIMIT_CMD_H
13742 +/* rlimit vserver commands */
13744 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
13745 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
13746 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
13747 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
13749 +struct vcmd_ctx_rlimit_v0 {
13751 + uint64_t minimum;
13752 + uint64_t softlimit;
13753 + uint64_t maximum;
13756 +struct vcmd_ctx_rlimit_mask_v0 {
13757 + uint32_t minimum;
13758 + uint32_t softlimit;
13759 + uint32_t maximum;
13762 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
13764 +struct vcmd_rlimit_stat_v0 {
13768 + uint64_t minimum;
13769 + uint64_t maximum;
13772 +#define CRLIM_UNSET (0ULL)
13773 +#define CRLIM_INFINITY (~0ULL)
13774 +#define CRLIM_KEEP (~1ULL)
13778 +#ifdef CONFIG_IA32_EMULATION
13780 +struct vcmd_ctx_rlimit_v0_x32 {
13782 + uint64_t minimum;
13783 + uint64_t softlimit;
13784 + uint64_t maximum;
13785 +} __attribute__ ((aligned (4)));
13787 +#endif /* CONFIG_IA32_EMULATION */
13789 +#include <linux/compiler.h>
13791 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13792 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13793 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13794 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13796 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13798 +#ifdef CONFIG_IA32_EMULATION
13800 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13801 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13803 +#endif /* CONFIG_IA32_EMULATION */
13805 +#endif /* __KERNEL__ */
13806 +#endif /* _VX_LIMIT_CMD_H */
13807 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/limit_def.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/limit_def.h
13808 --- linux-2.6.24-rc7/include/linux/vserver/limit_def.h 1970-01-01 01:00:00 +0100
13809 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/limit_def.h 2007-12-13 13:25:43 +0100
13811 +#ifndef _VX_LIMIT_DEF_H
13812 +#define _VX_LIMIT_DEF_H
13814 +#include <asm/atomic.h>
13815 +#include <asm/resource.h>
13817 +#include "limit.h"
13820 +struct _vx_res_limit {
13821 + rlim_t soft; /* Context soft limit */
13822 + rlim_t hard; /* Context hard limit */
13824 + rlim_atomic_t rcur; /* Current value */
13825 + rlim_t rmin; /* Context minimum */
13826 + rlim_t rmax; /* Context maximum */
13828 + atomic_t lhit; /* Limit hits */
13831 +/* context sub struct */
13833 +struct _vx_limit {
13834 + struct _vx_res_limit res[NUM_LIMITS];
13837 +#ifdef CONFIG_VSERVER_DEBUG
13839 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13843 + printk("\t_vx_limit:");
13844 + for (i = 0; i < NUM_LIMITS; i++) {
13845 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13846 + i, (unsigned long)__rlim_get(limit, i),
13847 + (unsigned long)__rlim_rmin(limit, i),
13848 + (unsigned long)__rlim_rmax(limit, i),
13849 + (long)__rlim_soft(limit, i),
13850 + (long)__rlim_hard(limit, i),
13851 + atomic_read(&__rlim_lhit(limit, i)));
13857 +#endif /* _VX_LIMIT_DEF_H */
13858 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/limit_int.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/limit_int.h
13859 --- linux-2.6.24-rc7/include/linux/vserver/limit_int.h 1970-01-01 01:00:00 +0100
13860 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/limit_int.h 2007-12-13 13:25:42 +0100
13862 +#ifndef _VX_LIMIT_INT_H
13863 +#define _VX_LIMIT_INT_H
13865 +#include "context.h"
13869 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
13870 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
13872 +extern const char *vlimit_name[NUM_LIMITS];
13874 +static inline void __vx_acc_cres(struct vx_info *vxi,
13875 + int res, int dir, void *_data, char *_file, int _line)
13877 + if (VXD_RCRES_COND(res))
13878 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13879 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13880 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13881 + (dir > 0) ? "++" : "--", _data, _file, _line);
13886 + __rlim_inc(&vxi->limit, res);
13888 + __rlim_dec(&vxi->limit, res);
13891 +static inline void __vx_add_cres(struct vx_info *vxi,
13892 + int res, int amount, void *_data, char *_file, int _line)
13894 + if (VXD_RCRES_COND(res))
13895 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13896 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13897 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13898 + amount, _data, _file, _line);
13903 + __rlim_add(&vxi->limit, res, amount);
13907 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13909 + int cond = (value > __rlim_rmax(limit, res));
13912 + __rlim_rmax(limit, res) = value;
13917 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13919 + int cond = (value < __rlim_rmin(limit, res));
13922 + __rlim_rmin(limit, res) = value;
13927 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13929 + if (!__vx_cres_adjust_max(limit, res, value))
13930 + __vx_cres_adjust_min(limit, res, value);
13935 + +1 ... no limit hit
13936 + -1 ... over soft limit
13937 + 0 ... over hard limit */
13939 +static inline int __vx_cres_avail(struct vx_info *vxi,
13940 + int res, int num, char *_file, int _line)
13942 + struct _vx_limit *limit;
13945 + if (VXD_RLIMIT_COND(res))
13946 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13947 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13948 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13949 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13950 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13951 + num, _file, _line);
13955 + limit = &vxi->limit;
13956 + value = __rlim_get(limit, res);
13958 + if (!__vx_cres_adjust_max(limit, res, value))
13959 + __vx_cres_adjust_min(limit, res, value);
13964 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
13966 + if (value + num <= __rlim_soft(limit, res))
13969 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
13971 + if (value + num <= __rlim_hard(limit, res))
13974 + __rlim_hit(limit, res);
13979 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13982 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13984 + rlim_t value, sum = 0;
13987 + while ((res = *array++)) {
13988 + value = __rlim_get(limit, res);
13989 + __vx_cres_fixup(limit, res, value);
13996 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13998 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
13999 + int res = *array;
14001 + if (value == __rlim_get(limit, res))
14004 + __rlim_set(limit, res, value);
14005 + /* now adjust min/max */
14006 + if (!__vx_cres_adjust_max(limit, res, value))
14007 + __vx_cres_adjust_min(limit, res, value);
14012 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
14013 + const int *array, int num, char *_file, int _line)
14015 + struct _vx_limit *limit;
14016 + rlim_t value = 0;
14024 + limit = &vxi->limit;
14026 + value = __vx_cres_array_sum(limit, array + 1);
14028 + __rlim_set(limit, res, value);
14029 + __vx_cres_fixup(limit, res, value);
14031 + return __vx_cres_avail(vxi, res, num, _file, _line);
14035 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
14040 + /* complex resources first */
14041 + if ((id < 0) || (id == RLIMIT_RSS))
14042 + __vx_cres_array_fixup(limit, VLA_RSS);
14044 + for (res = 0; res < NUM_LIMITS; res++) {
14045 + if ((id > 0) && (res != id))
14048 + value = __rlim_get(limit, res);
14049 + __vx_cres_fixup(limit, res, value);
14051 + /* not supposed to happen, maybe warn? */
14052 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
14053 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
14058 +#endif /* __KERNEL__ */
14059 +#endif /* _VX_LIMIT_INT_H */
14060 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/monitor.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/monitor.h
14061 --- linux-2.6.24-rc7/include/linux/vserver/monitor.h 1970-01-01 01:00:00 +0100
14062 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/monitor.h 2007-12-13 13:25:42 +0100
14064 +#ifndef _VX_MONITOR_H
14065 +#define _VX_MONITOR_H
14073 + VXM_UPDATE = 0x20,
14077 + VXM_RQINFO_1 = 0x24,
14080 + VXM_ACTIVATE = 0x40,
14087 + VXM_MIGRATE = 0x48,
14090 + /* all other bits are flags */
14091 + VXM_SCHED = 0x80,
14094 +struct _vxm_update_1 {
14095 + uint32_t tokens_max;
14096 + uint32_t fill_rate;
14097 + uint32_t interval;
14100 +struct _vxm_update_2 {
14101 + uint32_t tokens_min;
14102 + uint32_t fill_rate;
14103 + uint32_t interval;
14106 +struct _vxm_rqinfo_1 {
14107 + uint16_t running;
14111 + uint32_t idle_tokens;
14114 +struct _vxm_rqinfo_2 {
14115 + uint32_t norm_time;
14116 + uint32_t idle_time;
14117 + uint32_t idle_skip;
14120 +struct _vxm_sched {
14122 + uint32_t norm_time;
14123 + uint32_t idle_time;
14126 +struct _vxm_task {
14131 +struct _vxm_event {
14140 + struct _vxm_task tsk;
14144 +struct _vx_mon_entry {
14148 + struct _vxm_event ev;
14149 + struct _vxm_sched sd;
14150 + struct _vxm_update_1 u1;
14151 + struct _vxm_update_2 u2;
14152 + struct _vxm_rqinfo_1 q1;
14153 + struct _vxm_rqinfo_2 q2;
14158 +#endif /* _VX_MONITOR_H */
14159 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/network.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/network.h
14160 --- linux-2.6.24-rc7/include/linux/vserver/network.h 1970-01-01 01:00:00 +0100
14161 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/network.h 2007-12-13 13:25:30 +0100
14163 +#ifndef _VX_NETWORK_H
14164 +#define _VX_NETWORK_H
14166 +#include <linux/types.h>
14169 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
14171 +#define NX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
14173 +#define NB_IPV4ROOT 16
14176 +/* network flags */
14178 +#define NXF_INFO_PRIVATE 0x00000008
14180 +#define NXF_STATE_SETUP (1ULL << 32)
14181 +#define NXF_STATE_ADMIN (1ULL << 34)
14183 +#define NXF_SC_HELPER (1ULL << 36)
14184 +#define NXF_PERSISTENT (1ULL << 38)
14186 +#define NXF_ONE_TIME (0x0005ULL << 32)
14188 +#define NXF_INIT_SET (NXF_STATE_ADMIN)
14191 +/* address types */
14193 +#define NXA_TYPE_IPV4 1
14194 +#define NXA_TYPE_IPV6 2
14196 +#define NXA_MOD_BCAST (1 << 8)
14198 +#define NXA_TYPE_ANY ((uint16_t)-1)
14203 +#include <linux/list.h>
14204 +#include <linux/spinlock.h>
14205 +#include <linux/rcupdate.h>
14206 +#include <asm/atomic.h>
14210 + struct hlist_node nx_hlist; /* linked list of nxinfos */
14211 + nid_t nx_id; /* vnet id */
14212 + atomic_t nx_usecnt; /* usage count */
14213 + atomic_t nx_tasks; /* tasks count */
14214 + int nx_state; /* context state */
14216 + uint64_t nx_flags; /* network flag word */
14217 + uint64_t nx_ncaps; /* network capabilities */
14220 + __u32 ipv4[NB_IPV4ROOT]; /* Process can only bind to these IPs */
14221 + /* The first one is used to connect */
14222 + /* and for bind any service */
14223 + /* The other must be used explicity */
14224 + __u32 mask[NB_IPV4ROOT]; /* Netmask for each ipv4 */
14225 + /* Used to select the proper source */
14226 + /* address for sockets */
14227 + __u32 v4_bcast; /* Broadcast address to receive UDP */
14229 + char nx_name[65]; /* network context name */
14233 +/* status flags */
14235 +#define NXS_HASHED 0x0001
14236 +#define NXS_SHUTDOWN 0x0100
14237 +#define NXS_RELEASED 0x8000
14239 +/* check conditions */
14241 +#define NX_ADMIN 0x0001
14242 +#define NX_WATCH 0x0002
14243 +#define NX_BLEND 0x0004
14244 +#define NX_HOSTID 0x0008
14246 +#define NX_IDENT 0x0010
14247 +#define NX_EQUIV 0x0020
14248 +#define NX_PARENT 0x0040
14249 +#define NX_CHILD 0x0080
14251 +#define NX_ARG_MASK 0x00F0
14253 +#define NX_DYNAMIC 0x0100
14254 +#define NX_STATIC 0x0200
14256 +#define NX_ATR_MASK 0x0F00
14259 +extern struct nx_info *lookup_nx_info(int);
14261 +extern int get_nid_list(int, unsigned int *, int);
14262 +extern int nid_is_hashed(nid_t);
14264 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
14266 +extern long vs_net_change(struct nx_info *, unsigned int);
14269 +struct net_device;
14271 +#ifdef CONFIG_INET
14272 +int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
14273 +int dev_in_nx_info(struct net_device *, struct nx_info *);
14275 +#else /* CONFIG_INET */
14277 +int ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
14283 +int dev_in_nx_info(struct net_device *d, struct nx_info *n)
14287 +#endif /* CONFIG_INET */
14291 +#ifdef CONFIG_INET
14292 +int nx_addr_conflict(struct nx_info *, uint32_t, const struct sock *);
14293 +#else /* CONFIG_INET */
14295 +int nx_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
14299 +#endif /* CONFIG_INET */
14301 +#endif /* __KERNEL__ */
14302 +#else /* _VX_NETWORK_H */
14303 +#warning duplicate inclusion
14304 +#endif /* _VX_NETWORK_H */
14305 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/network_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/network_cmd.h
14306 --- linux-2.6.24-rc7/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00 +0100
14307 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/network_cmd.h 2007-12-13 13:25:43 +0100
14309 +#ifndef _VX_NETWORK_CMD_H
14310 +#define _VX_NETWORK_CMD_H
14313 +/* vinfo commands */
14315 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
14318 +extern int vc_task_nid(uint32_t, void __user *);
14320 +#endif /* __KERNEL__ */
14322 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
14324 +struct vcmd_nx_info_v0 {
14326 + /* more to come */
14330 +extern int vc_nx_info(struct nx_info *, void __user *);
14332 +#endif /* __KERNEL__ */
14334 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
14335 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
14337 +struct vcmd_net_create {
14338 + uint64_t flagword;
14341 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
14343 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
14344 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
14346 +struct vcmd_net_addr_v0 {
14350 + uint32_t mask[4];
14351 + /* more to come */
14356 +extern int vc_net_create(uint32_t, void __user *);
14357 +extern int vc_net_migrate(struct nx_info *, void __user *);
14359 +extern int vc_net_add(struct nx_info *, void __user *);
14360 +extern int vc_net_remove(struct nx_info *, void __user *);
14362 +#endif /* __KERNEL__ */
14365 +/* flag commands */
14367 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
14368 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
14370 +struct vcmd_net_flags_v0 {
14371 + uint64_t flagword;
14376 +extern int vc_get_nflags(struct nx_info *, void __user *);
14377 +extern int vc_set_nflags(struct nx_info *, void __user *);
14379 +#endif /* __KERNEL__ */
14382 +/* network caps commands */
14384 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
14385 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
14387 +struct vcmd_net_caps_v0 {
14393 +extern int vc_get_ncaps(struct nx_info *, void __user *);
14394 +extern int vc_set_ncaps(struct nx_info *, void __user *);
14396 +#endif /* __KERNEL__ */
14397 +#endif /* _VX_CONTEXT_CMD_H */
14398 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/percpu.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/percpu.h
14399 --- linux-2.6.24-rc7/include/linux/vserver/percpu.h 1970-01-01 01:00:00 +0100
14400 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/percpu.h 2007-12-13 13:25:51 +0100
14402 +#ifndef _VX_PERCPU_H
14403 +#define _VX_PERCPU_H
14405 +#include "cvirt_def.h"
14406 +#include "sched_def.h"
14408 +struct _vx_percpu {
14409 + struct _vx_cvirt_pc cvirt;
14410 + struct _vx_sched_pc sched;
14413 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
14415 +#endif /* _VX_PERCPU_H */
14416 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/pid.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/pid.h
14417 --- linux-2.6.24-rc7/include/linux/vserver/pid.h 1970-01-01 01:00:00 +0100
14418 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/pid.h 2007-12-18 00:48:01 +0100
14420 +#ifndef _VSERVER_PID_H
14421 +#define _VSERVER_PID_H
14423 +/* pid faking stuff */
14425 +#define vx_info_map_pid(v, p) \
14426 + __vx_info_map_pid((v), (p), __FUNC__, __FILE__, __LINE__)
14427 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
14428 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
14429 +#define vx_map_tgid(p) vx_map_pid(p)
14431 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
14432 + const char *func, const char *file, int line)
14434 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14435 + vxfprintk(VXD_CBIT(cvirt, 2),
14436 + "vx_map_tgid: %p/%llx: %d -> %d",
14437 + vxi, (long long)vxi->vx_flags, pid,
14438 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
14439 + func, file, line);
14442 + if (pid == vxi->vx_initpid)
14448 +#define vx_info_rmap_pid(v, p) \
14449 + __vx_info_rmap_pid((v), (p), __FUNC__, __FILE__, __LINE__)
14450 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
14451 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
14453 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
14454 + const char *func, const char *file, int line)
14456 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14457 + vxfprintk(VXD_CBIT(cvirt, 2),
14458 + "vx_rmap_tgid: %p/%llx: %d -> %d",
14459 + vxi, (long long)vxi->vx_flags, pid,
14460 + (pid == 1) ? vxi->vx_initpid : pid,
14461 + func, file, line);
14462 + if ((pid == 1) && vxi->vx_initpid)
14463 + return vxi->vx_initpid;
14464 + if (pid == vxi->vx_initpid)
14471 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/sched.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/sched.h
14472 --- linux-2.6.24-rc7/include/linux/vserver/sched.h 1970-01-01 01:00:00 +0100
14473 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/sched.h 2007-12-13 13:25:37 +0100
14475 +#ifndef _VX_SCHED_H
14476 +#define _VX_SCHED_H
14483 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14488 +void vx_update_load(struct vx_info *);
14491 +int vx_tokens_recalc(struct _vx_sched_pc *,
14492 + unsigned long *, unsigned long *, int [2]);
14494 +void vx_update_sched_param(struct _vx_sched *sched,
14495 + struct _vx_sched_pc *sched_pc);
14497 +#endif /* __KERNEL__ */
14498 +#else /* _VX_SCHED_H */
14499 +#warning duplicate inclusion
14500 +#endif /* _VX_SCHED_H */
14501 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/sched_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/sched_cmd.h
14502 --- linux-2.6.24-rc7/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00 +0100
14503 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/sched_cmd.h 2007-12-13 13:25:43 +0100
14505 +#ifndef _VX_SCHED_CMD_H
14506 +#define _VX_SCHED_CMD_H
14509 +/* sched vserver commands */
14511 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
14512 +#define VCMD_set_sched_v3 VC_CMD(SCHED, 1, 3)
14513 +#define VCMD_set_sched_v4 VC_CMD(SCHED, 1, 4)
14515 +struct vcmd_set_sched_v2 {
14516 + int32_t fill_rate;
14517 + int32_t interval;
14519 + int32_t tokens_min;
14520 + int32_t tokens_max;
14521 + uint64_t cpu_mask;
14524 +struct vcmd_set_sched_v3 {
14525 + uint32_t set_mask;
14526 + int32_t fill_rate;
14527 + int32_t interval;
14529 + int32_t tokens_min;
14530 + int32_t tokens_max;
14531 + int32_t priority_bias;
14534 +struct vcmd_set_sched_v4 {
14535 + uint32_t set_mask;
14536 + int32_t fill_rate;
14537 + int32_t interval;
14539 + int32_t tokens_min;
14540 + int32_t tokens_max;
14541 + int32_t prio_bias;
14543 + int32_t bucket_id;
14546 +#define VCMD_set_sched VC_CMD(SCHED, 1, 5)
14547 +#define VCMD_get_sched VC_CMD(SCHED, 2, 5)
14549 +struct vcmd_sched_v5 {
14552 + int32_t bucket_id;
14553 + int32_t fill_rate[2];
14554 + int32_t interval[2];
14556 + int32_t tokens_min;
14557 + int32_t tokens_max;
14558 + int32_t prio_bias;
14561 +#define VXSM_FILL_RATE 0x0001
14562 +#define VXSM_INTERVAL 0x0002
14563 +#define VXSM_FILL_RATE2 0x0004
14564 +#define VXSM_INTERVAL2 0x0008
14565 +#define VXSM_TOKENS 0x0010
14566 +#define VXSM_TOKENS_MIN 0x0020
14567 +#define VXSM_TOKENS_MAX 0x0040
14568 +#define VXSM_PRIO_BIAS 0x0100
14570 +#define VXSM_IDLE_TIME 0x0200
14571 +#define VXSM_FORCE 0x0400
14573 +#define VXSM_V3_MASK 0x0173
14574 +#define VXSM_SET_MASK 0x01FF
14576 +#define VXSM_CPU_ID 0x1000
14577 +#define VXSM_BUCKET_ID 0x2000
14579 +#define VXSM_MSEC 0x4000
14581 +#define SCHED_KEEP (-2) /* only for v2 */
14585 +#include <linux/compiler.h>
14587 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
14588 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
14589 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
14590 +extern int vc_set_sched(struct vx_info *, void __user *);
14591 +extern int vc_get_sched(struct vx_info *, void __user *);
14593 +#endif /* __KERNEL__ */
14595 +#define VCMD_sched_info VC_CMD(SCHED, 3, 0)
14597 +struct vcmd_sched_info {
14599 + int32_t bucket_id;
14600 + uint64_t user_msec;
14601 + uint64_t sys_msec;
14602 + uint64_t hold_msec;
14603 + uint32_t token_usec;
14604 + int32_t vavavoom;
14609 +extern int vc_sched_info(struct vx_info *, void __user *);
14611 +#endif /* __KERNEL__ */
14612 +#endif /* _VX_SCHED_CMD_H */
14613 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/sched_def.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/sched_def.h
14614 --- linux-2.6.24-rc7/include/linux/vserver/sched_def.h 1970-01-01 01:00:00 +0100
14615 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/sched_def.h 2007-12-13 13:25:43 +0100
14617 +#ifndef _VX_SCHED_DEF_H
14618 +#define _VX_SCHED_DEF_H
14620 +#include <linux/spinlock.h>
14621 +#include <linux/jiffies.h>
14622 +#include <linux/cpumask.h>
14623 +#include <asm/atomic.h>
14624 +#include <asm/param.h>
14627 +/* context sub struct */
14629 +struct _vx_sched {
14630 + spinlock_t tokens_lock; /* lock for token bucket */
14632 + int tokens; /* number of CPU tokens */
14633 + int fill_rate[2]; /* Fill rate: add X tokens... */
14634 + int interval[2]; /* Divisor: per Y jiffies */
14635 + int tokens_min; /* Limit: minimum for unhold */
14636 + int tokens_max; /* Limit: no more than N tokens */
14638 + int prio_bias; /* bias offset for priority */
14640 + unsigned update_mask; /* which features should be updated */
14641 + cpumask_t update; /* CPUs which should update */
14644 +struct _vx_sched_pc {
14645 + int tokens; /* number of CPU tokens */
14646 + int flags; /* bucket flags */
14648 + int fill_rate[2]; /* Fill rate: add X tokens... */
14649 + int interval[2]; /* Divisor: per Y jiffies */
14650 + int tokens_min; /* Limit: minimum for unhold */
14651 + int tokens_max; /* Limit: no more than N tokens */
14653 + int prio_bias; /* bias offset for priority */
14654 + int vavavoom; /* last calculated vavavoom */
14656 + unsigned long norm_time; /* last time accounted */
14657 + unsigned long idle_time; /* non linear time for fair sched */
14658 + unsigned long token_time; /* token time for accounting */
14659 + unsigned long onhold; /* jiffies when put on hold */
14661 + uint64_t user_ticks; /* token tick events */
14662 + uint64_t sys_ticks; /* token tick events */
14663 + uint64_t hold_ticks; /* token ticks paused */
14667 +#define VXSF_ONHOLD 0x0001
14668 +#define VXSF_IDLE_TIME 0x0100
14670 +#ifdef CONFIG_VSERVER_DEBUG
14672 +static inline void __dump_vx_sched(struct _vx_sched *sched)
14674 + printk("\t_vx_sched:\n");
14675 + printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
14676 + sched->fill_rate[0], sched->interval[0],
14677 + sched->fill_rate[1], sched->interval[1],
14678 + sched->tokens_min, sched->tokens_max);
14679 + printk("\t priority = %4d\n", sched->prio_bias);
14684 +#endif /* _VX_SCHED_DEF_H */
14685 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/signal.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/signal.h
14686 --- linux-2.6.24-rc7/include/linux/vserver/signal.h 1970-01-01 01:00:00 +0100
14687 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/signal.h 2007-12-13 13:25:38 +0100
14689 +#ifndef _VX_SIGNAL_H
14690 +#define _VX_SIGNAL_H
14697 +int vx_info_kill(struct vx_info *, int, int);
14699 +#endif /* __KERNEL__ */
14700 +#else /* _VX_SIGNAL_H */
14701 +#warning duplicate inclusion
14702 +#endif /* _VX_SIGNAL_H */
14703 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/signal_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/signal_cmd.h
14704 --- linux-2.6.24-rc7/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00 +0100
14705 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/signal_cmd.h 2007-12-13 13:25:43 +0100
14707 +#ifndef _VX_SIGNAL_CMD_H
14708 +#define _VX_SIGNAL_CMD_H
14711 +/* signalling vserver commands */
14713 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
14714 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
14716 +struct vcmd_ctx_kill_v0 {
14721 +struct vcmd_wait_exit_v0 {
14722 + int32_t reboot_cmd;
14723 + int32_t exit_code;
14728 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14729 +extern int vc_wait_exit(struct vx_info *, void __user *);
14731 +#endif /* __KERNEL__ */
14733 +/* process alteration commands */
14735 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
14736 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
14738 +struct vcmd_pflags_v0 {
14739 + uint32_t flagword;
14745 +extern int vc_get_pflags(uint32_t pid, void __user *);
14746 +extern int vc_set_pflags(uint32_t pid, void __user *);
14748 +#endif /* __KERNEL__ */
14749 +#endif /* _VX_SIGNAL_CMD_H */
14750 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/space.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/space.h
14751 --- linux-2.6.24-rc7/include/linux/vserver/space.h 1970-01-01 01:00:00 +0100
14752 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/space.h 2007-12-13 13:25:49 +0100
14754 +#ifndef _VX_SPACE_H
14755 +#define _VX_SPACE_H
14758 +#include <linux/types.h>
14762 +int vx_set_space(struct vx_info *vxi, unsigned long mask);
14764 +#else /* _VX_SPACE_H */
14765 +#warning duplicate inclusion
14766 +#endif /* _VX_SPACE_H */
14767 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/space_cmd.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/space_cmd.h
14768 --- linux-2.6.24-rc7/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00 +0100
14769 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/space_cmd.h 2007-12-13 13:25:43 +0100
14771 +#ifndef _VX_SPACE_CMD_H
14772 +#define _VX_SPACE_CMD_H
14775 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
14776 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 1)
14778 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
14779 +#define VCMD_set_space VC_CMD(PROCALT, 3, 1)
14781 +#define VCMD_get_space_mask VC_CMD(PROCALT, 4, 0)
14784 +struct vcmd_space_mask {
14791 +extern int vc_enter_space(struct vx_info *, void __user *);
14792 +extern int vc_set_space(struct vx_info *, void __user *);
14793 +extern int vc_get_space_mask(struct vx_info *, void __user *);
14795 +#endif /* __KERNEL__ */
14796 +#endif /* _VX_SPACE_CMD_H */
14797 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/switch.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/switch.h
14798 --- linux-2.6.24-rc7/include/linux/vserver/switch.h 1970-01-01 01:00:00 +0100
14799 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/switch.h 2007-12-13 13:25:30 +0100
14801 +#ifndef _VX_SWITCH_H
14802 +#define _VX_SWITCH_H
14804 +#include <linux/types.h>
14807 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
14808 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
14809 +#define VC_VERSION(c) ((c) & 0xFFF)
14811 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
14812 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14816 + Syscall Matrix V2.8
14818 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14819 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
14820 + |INFO |SETUP | |MOVE | | | | | |
14821 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14822 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICES| |
14823 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
14824 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14825 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
14826 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
14827 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14828 + MEMORY | | | | | | | |SWAP | |
14829 + | 16| 17| 18| 19| 20| 21| | 22| 23|
14830 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14831 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
14832 + | 24| 25| 26| 27| 28| 29| | 30| 31|
14833 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14834 + DISK | | | | |DLIMIT | | |INODE | |
14835 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
14836 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14837 + OTHER |VSTAT | | | | | | |VINFO | |
14838 + | 40| 41| 42| 43| 44| 45| | 46| 47|
14839 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14840 + SPECIAL|EVENT | | | |FLAGS | | | | |
14841 + | 48| 49| 50| 51| 52| 53| | 54| 55|
14842 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14843 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
14844 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
14845 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14849 +#define VC_CAT_VERSION 0
14851 +#define VC_CAT_VSETUP 1
14852 +#define VC_CAT_VHOST 2
14854 +#define VC_CAT_VPROC 9
14855 +#define VC_CAT_PROCALT 10
14856 +#define VC_CAT_PROCMIG 11
14857 +#define VC_CAT_PROCTRL 12
14859 +#define VC_CAT_SCHED 14
14861 +#define VC_CAT_VNET 25
14862 +#define VC_CAT_NETALT 26
14863 +#define VC_CAT_NETMIG 27
14864 +#define VC_CAT_NETCTRL 28
14866 +#define VC_CAT_DLIMIT 36
14867 +#define VC_CAT_INODE 38
14869 +#define VC_CAT_VSTAT 40
14870 +#define VC_CAT_VINFO 46
14871 +#define VC_CAT_EVENT 48
14873 +#define VC_CAT_FLAGS 52
14874 +#define VC_CAT_DEBUG 56
14875 +#define VC_CAT_RLIMIT 60
14877 +#define VC_CAT_SYSTEST 61
14878 +#define VC_CAT_COMPAT 63
14880 +/* query version */
14882 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
14883 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
14888 +#include <linux/errno.h>
14891 +#else /* __KERNEL__ */
14893 +#endif /* __KERNEL__ */
14895 +#endif /* _VX_SWITCH_H */
14896 diff -NurpP --minimal linux-2.6.24-rc7/include/linux/vserver/tag.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/tag.h
14897 --- linux-2.6.24-rc7/include/linux/vserver/tag.h 1970-01-01 01:00:00 +0100
14898 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/linux/vserver/tag.h 2007-12-13 13:25:41 +0100
14904 +#define DX_TAG(in) (IS_TAGGED(in))
14907 +#ifdef CONFIG_DX_TAG_NFSD
14908 +#define DX_TAG_NFSD 1
14910 +#define DX_TAG_NFSD 0
14914 +#ifdef CONFIG_TAGGING_NONE
14916 +#define MAX_UID 0xFFFFFFFF
14917 +#define MAX_GID 0xFFFFFFFF
14919 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
14921 +#define TAGINO_UID(cond, uid, tag) (uid)
14922 +#define TAGINO_GID(cond, gid, tag) (gid)
14927 +#ifdef CONFIG_TAGGING_GID16
14929 +#define MAX_UID 0xFFFFFFFF
14930 +#define MAX_GID 0x0000FFFF
14932 +#define INOTAG_TAG(cond, uid, gid, tag) \
14933 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14935 +#define TAGINO_UID(cond, uid, tag) (uid)
14936 +#define TAGINO_GID(cond, gid, tag) \
14937 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14942 +#ifdef CONFIG_TAGGING_ID24
14944 +#define MAX_UID 0x00FFFFFF
14945 +#define MAX_GID 0x00FFFFFF
14947 +#define INOTAG_TAG(cond, uid, gid, tag) \
14948 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14950 +#define TAGINO_UID(cond, uid, tag) \
14951 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14952 +#define TAGINO_GID(cond, gid, tag) \
14953 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14958 +#ifdef CONFIG_TAGGING_UID16
14960 +#define MAX_UID 0x0000FFFF
14961 +#define MAX_GID 0xFFFFFFFF
14963 +#define INOTAG_TAG(cond, uid, gid, tag) \
14964 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14966 +#define TAGINO_UID(cond, uid, tag) \
14967 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14968 +#define TAGINO_GID(cond, gid, tag) (gid)
14973 +#ifdef CONFIG_TAGGING_INTERN
14975 +#define MAX_UID 0xFFFFFFFF
14976 +#define MAX_GID 0xFFFFFFFF
14978 +#define INOTAG_TAG(cond, uid, gid, tag) \
14979 + ((cond) ? (tag) : 0)
14981 +#define TAGINO_UID(cond, uid, tag) (uid)
14982 +#define TAGINO_GID(cond, gid, tag) (gid)
14987 +#ifndef CONFIG_TAGGING_NONE
14988 +#define dx_current_fstag(sb) \
14989 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14991 +#define dx_current_fstag(sb) (0)
14994 +#ifndef CONFIG_TAGGING_INTERN
14995 +#define TAGINO_TAG(cond, tag) (0)
14997 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
15000 +#define INOTAG_UID(cond, uid, gid) \
15001 + ((cond) ? ((uid) & MAX_UID) : (uid))
15002 +#define INOTAG_GID(cond, uid, gid) \
15003 + ((cond) ? ((gid) & MAX_GID) : (gid))
15006 +static inline uid_t dx_map_uid(uid_t uid)
15008 + if ((uid > MAX_UID) && (uid != -1))
15010 + return (uid & MAX_UID);
15013 +static inline gid_t dx_map_gid(gid_t gid)
15015 + if ((gid > MAX_GID) && (gid != -1))
15017 + return (gid & MAX_GID);
15021 +#ifdef CONFIG_VSERVER_LEGACY
15022 +#define FIOC_GETTAG _IOR('x', 1, long)
15023 +#define FIOC_SETTAG _IOW('x', 2, long)
15024 +#define FIOC_SETTAGJ _IOW('x', 3, long)
15027 +#ifdef CONFIG_PROPAGATE
15029 +int dx_parse_tag(char *string, tag_t *tag, int remove);
15031 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
15033 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
15036 +#define dx_propagate_tag(n, i) do { } while (0)
15039 +#endif /* _DX_TAG_H */
15040 diff -NurpP --minimal linux-2.6.24-rc7/include/net/af_unix.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/af_unix.h
15041 --- linux-2.6.24-rc7/include/net/af_unix.h 2007-11-29 01:12:26 +0100
15042 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/af_unix.h 2007-12-13 13:25:30 +0100
15044 #include <linux/socket.h>
15045 #include <linux/un.h>
15046 #include <linux/mutex.h>
15047 +#include <linux/vs_base.h>
15048 #include <net/sock.h>
15050 extern void unix_inflight(struct file *fp);
15051 diff -NurpP --minimal linux-2.6.24-rc7/include/net/inet_hashtables.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/inet_hashtables.h
15052 --- linux-2.6.24-rc7/include/net/inet_hashtables.h 2007-12-31 17:58:28 +0100
15053 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/inet_hashtables.h 2007-12-31 12:34:43 +0100
15054 @@ -323,6 +323,26 @@ out:
15055 wake_up(&hashinfo->lhash_wait);
15059 + * Check if a given address matches for an inet socket
15061 + * nxi: the socket's nx_info if any
15062 + * addr: to be verified address
15063 + * saddr: socket addresses
15065 +static inline int inet_addr_match (
15066 + struct nx_info *nxi,
15070 + if (addr && (saddr == addr))
15073 + return addr_in_nx_info(nxi, addr);
15078 extern struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo,
15079 const __be32 daddr,
15080 const unsigned short hnum,
15081 diff -NurpP --minimal linux-2.6.24-rc7/include/net/inet_sock.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/inet_sock.h
15082 --- linux-2.6.24-rc7/include/net/inet_sock.h 2007-11-29 01:12:26 +0100
15083 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/inet_sock.h 2007-12-13 16:56:23 +0100
15084 @@ -114,6 +114,7 @@ struct inet_sock {
15085 /* Socket demultiplex comparisons on incoming packets. */
15088 + __be32 rcv_saddr2; /* Second bound ipv4 addr, for ipv4root */
15092 @@ -194,7 +195,9 @@ static inline int inet_sk_ehashfn(const
15094 static inline int inet_iif(const struct sk_buff *skb)
15096 - return ((struct rtable *)skb->dst)->rt_iif;
15097 + struct rtable *rt = (struct rtable *)skb->dst;
15099 + return rt->rt_iif;
15102 #endif /* _INET_SOCK_H */
15103 diff -NurpP --minimal linux-2.6.24-rc7/include/net/inet_timewait_sock.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/inet_timewait_sock.h
15104 --- linux-2.6.24-rc7/include/net/inet_timewait_sock.h 2007-11-29 01:12:26 +0100
15105 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/inet_timewait_sock.h 2007-12-13 13:25:30 +0100
15106 @@ -116,6 +116,10 @@ struct inet_timewait_sock {
15107 #define tw_hash __tw_common.skc_hash
15108 #define tw_prot __tw_common.skc_prot
15109 #define tw_net __tw_common.skc_net
15110 +#define tw_xid __tw_common.skc_xid
15111 +#define tw_vx_info __tw_common.skc_vx_info
15112 +#define tw_nid __tw_common.skc_nid
15113 +#define tw_nx_info __tw_common.skc_nx_info
15114 volatile unsigned char tw_substate;
15115 /* 3 bits hole, try to pack */
15116 unsigned char tw_rcv_wscale;
15117 diff -NurpP --minimal linux-2.6.24-rc7/include/net/route.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/route.h
15118 --- linux-2.6.24-rc7/include/net/route.h 2007-12-31 17:58:28 +0100
15119 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/route.h 2008-01-11 00:33:42 +0100
15120 @@ -27,12 +27,16 @@
15121 #include <net/dst.h>
15122 #include <net/inetpeer.h>
15123 #include <net/flow.h>
15124 +#include <net/sock.h>
15125 #include <linux/in_route.h>
15126 #include <linux/rtnetlink.h>
15127 #include <linux/route.h>
15128 #include <linux/ip.h>
15129 #include <linux/cache.h>
15130 #include <linux/security.h>
15131 +#include <linux/vs_base.h>
15132 +#include <linux/vs_network.h>
15133 +#include <linux/in.h>
15136 #warning This file is not supposed to be used outside of kernel.
15137 @@ -141,6 +145,59 @@ static inline char rt_tos2priority(u8 to
15138 return ip_tos2prio[IPTOS_TOS(tos)>>1];
15141 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
15143 +static inline int ip_find_src(struct nx_info *nxi, struct rtable **rp, struct flowi *fl)
15146 + int i, n = nxi->nbipv4;
15147 + u32 ipv4root = nxi->ipv4[0];
15149 + if (ipv4root == 0)
15152 + if (fl->fl4_src == 0) {
15156 + err = __ip_route_output_key(rp, fl);
15158 + fl->fl4_src = ipv4root;
15159 + err = __ip_route_output_key(rp, fl);
15164 + foundsrc = (*rp)->rt_src;
15167 + for (i=0; i<n; i++){
15168 + u32 mask = nxi->mask[i];
15169 + u32 ipv4 = nxi->ipv4[i];
15170 + u32 net4 = ipv4 & mask;
15172 + if (foundsrc == ipv4) {
15173 + fl->fl4_src = ipv4;
15176 + if (!fl->fl4_src && (foundsrc & mask) == net4)
15177 + fl->fl4_src = ipv4;
15180 + if (fl->fl4_src == 0)
15181 + fl->fl4_src = (fl->fl4_dst == IPI_LOOPBACK)
15182 + ? IPI_LOOPBACK : ipv4root;
15184 + for (i=0; i<n; i++) {
15185 + if (nxi->ipv4[i] == fl->fl4_src)
15194 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
15195 __be32 src, u32 tos, int oif, u8 protocol,
15196 __be16 sport, __be16 dport, struct sock *sk,
15197 @@ -156,7 +213,27 @@ static inline int ip_route_connect(struc
15198 .dport = dport } } };
15201 - if (!dst || !src) {
15202 + struct nx_info *nx_info = current->nx_info;
15205 + nx_info = sk->sk_nx_info;
15206 + vxdprintk(VXD_CBIT(net, 4),
15207 + "ip_route_connect(%p) %p,%p;%lx",
15208 + sk, nx_info, sk->sk_socket,
15209 + (sk->sk_socket?sk->sk_socket->flags:0));
15212 + err = ip_find_src(nx_info, rp, &fl);
15215 + if (fl.fl4_dst == IPI_LOOPBACK && !nx_check(0, VS_ADMIN))
15216 + fl.fl4_dst = nx_info->ipv4[0];
15217 +#ifdef CONFIG_VSERVER_REMAP_SADDR
15218 + if (fl.fl4_src == IPI_LOOPBACK && !nx_check(0, VS_ADMIN))
15219 + fl.fl4_src = nx_info->ipv4[0];
15222 + if (!fl.fl4_dst || !fl.fl4_src) {
15223 err = __ip_route_output_key(rp, &fl);
15226 diff -NurpP --minimal linux-2.6.24-rc7/include/net/sock.h linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/sock.h
15227 --- linux-2.6.24-rc7/include/net/sock.h 2007-12-31 17:58:28 +0100
15228 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/include/net/sock.h 2007-12-31 12:34:43 +0100
15229 @@ -122,6 +122,10 @@ struct sock_common {
15230 unsigned int skc_hash;
15231 struct proto *skc_prot;
15232 struct net *skc_net;
15234 + struct vx_info *skc_vx_info;
15236 + struct nx_info *skc_nx_info;
15240 @@ -199,6 +203,10 @@ struct sock {
15241 #define sk_hash __sk_common.skc_hash
15242 #define sk_prot __sk_common.skc_prot
15243 #define sk_net __sk_common.skc_net
15244 +#define sk_xid __sk_common.skc_xid
15245 +#define sk_vx_info __sk_common.skc_vx_info
15246 +#define sk_nid __sk_common.skc_nid
15247 +#define sk_nx_info __sk_common.skc_nx_info
15248 unsigned char sk_shutdown : 2,
15251 diff -NurpP --minimal linux-2.6.24-rc7/init/main.c linux-2.6.24-rc7-vs2.2.0.5.0.7/init/main.c
15252 --- linux-2.6.24-rc7/init/main.c 2007-11-29 01:12:30 +0100
15253 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/init/main.c 2007-12-13 13:25:51 +0100
15255 #include <linux/device.h>
15256 #include <linux/kthread.h>
15257 #include <linux/sched.h>
15258 +#include <linux/vserver/percpu.h>
15260 #include <asm/io.h>
15261 #include <asm/bugs.h>
15262 @@ -370,12 +371,14 @@ EXPORT_SYMBOL(__per_cpu_offset);
15264 static void __init setup_per_cpu_areas(void)
15266 - unsigned long size, i;
15267 + unsigned long size, vspc, i;
15269 unsigned long nr_possible_cpus = num_possible_cpus();
15271 + vspc = PERCPU_PERCTX * CONFIG_VSERVER_CONTEXTS;
15273 /* Copy section for each CPU (we discard the original) */
15274 - size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
15275 + size = ALIGN(PERCPU_ENOUGH_ROOM + vspc, PAGE_SIZE);
15276 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
15278 for_each_possible_cpu(i) {
15279 diff -NurpP --minimal linux-2.6.24-rc7/ipc/mqueue.c linux-2.6.24-rc7-vs2.2.0.5.0.7/ipc/mqueue.c
15280 --- linux-2.6.24-rc7/ipc/mqueue.c 2007-12-31 17:58:28 +0100
15281 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/ipc/mqueue.c 2008-01-01 18:20:23 +0100
15283 #include <linux/mutex.h>
15284 #include <linux/nsproxy.h>
15285 #include <linux/pid.h>
15286 +#include <linux/vs_context.h>
15287 +#include <linux/vs_limit.h>
15289 #include <net/sock.h>
15291 @@ -71,6 +73,7 @@ struct mqueue_inode_info {
15292 struct sigevent notify;
15293 struct pid* notify_owner;
15294 struct user_struct *user; /* user who created, for accounting */
15295 + struct vx_info *vxi;
15296 struct sock *notify_sock;
15297 struct sk_buff *notify_cookie;
15299 @@ -119,6 +122,7 @@ static struct inode *mqueue_get_inode(st
15300 struct mqueue_inode_info *info;
15301 struct task_struct *p = current;
15302 struct user_struct *u = p->user;
15303 + struct vx_info *vxi = p->vx_info;
15304 unsigned long mq_bytes, mq_msg_tblsz;
15306 inode->i_fop = &mqueue_file_operations;
15307 @@ -133,6 +137,7 @@ static struct inode *mqueue_get_inode(st
15308 info->notify_owner = NULL;
15310 info->user = NULL; /* set when all is ok */
15311 + info->vxi = NULL;
15312 memset(&info->attr, 0, sizeof(info->attr));
15313 info->attr.mq_maxmsg = DFLT_MSGMAX;
15314 info->attr.mq_msgsize = DFLT_MSGSIZEMAX;
15315 @@ -147,22 +152,26 @@ static struct inode *mqueue_get_inode(st
15316 spin_lock(&mq_lock);
15317 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
15318 u->mq_bytes + mq_bytes >
15319 - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
15320 + p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
15321 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
15322 spin_unlock(&mq_lock);
15325 u->mq_bytes += mq_bytes;
15326 + vx_ipcmsg_add(vxi, u, mq_bytes);
15327 spin_unlock(&mq_lock);
15329 info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
15330 if (!info->messages) {
15331 spin_lock(&mq_lock);
15332 u->mq_bytes -= mq_bytes;
15333 + vx_ipcmsg_sub(vxi, u, mq_bytes);
15334 spin_unlock(&mq_lock);
15338 info->user = get_uid(u);
15339 + info->vxi = get_vx_info(vxi);
15340 } else if (S_ISDIR(mode)) {
15342 /* Some things misbehave if size == 0 on a directory */
15343 @@ -253,10 +262,14 @@ static void mqueue_delete_inode(struct i
15344 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
15347 + struct vx_info *vxi = info->vxi;
15349 spin_lock(&mq_lock);
15350 user->mq_bytes -= mq_bytes;
15351 + vx_ipcmsg_sub(vxi, user, mq_bytes);
15353 spin_unlock(&mq_lock);
15354 + put_vx_info(vxi);
15358 @@ -744,7 +757,7 @@ asmlinkage long sys_mq_unlink(const char
15360 atomic_inc(&inode->i_count);
15362 - err = vfs_unlink(dentry->d_parent->d_inode, dentry);
15363 + err = vfs_unlink(dentry->d_parent->d_inode, dentry, NULL);
15367 diff -NurpP --minimal linux-2.6.24-rc7/ipc/msg.c linux-2.6.24-rc7-vs2.2.0.5.0.7/ipc/msg.c
15368 --- linux-2.6.24-rc7/ipc/msg.c 2007-11-29 01:12:30 +0100
15369 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/ipc/msg.c 2007-12-13 13:25:48 +0100
15371 #include <linux/seq_file.h>
15372 #include <linux/rwsem.h>
15373 #include <linux/nsproxy.h>
15374 +#include <linux/vs_base.h>
15376 #include <asm/current.h>
15377 #include <asm/uaccess.h>
15378 @@ -191,6 +192,7 @@ static int newque(struct ipc_namespace *
15380 msq->q_perm.mode = msgflg & S_IRWXUGO;
15381 msq->q_perm.key = key;
15382 + msq->q_perm.xid = vx_current_xid();
15384 msq->q_perm.security = NULL;
15385 retval = security_msg_queue_alloc(msq);
15386 diff -NurpP --minimal linux-2.6.24-rc7/ipc/sem.c linux-2.6.24-rc7-vs2.2.0.5.0.7/ipc/sem.c
15387 --- linux-2.6.24-rc7/ipc/sem.c 2007-11-29 01:12:30 +0100
15388 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/ipc/sem.c 2007-12-13 13:25:48 +0100
15390 #include <linux/seq_file.h>
15391 #include <linux/rwsem.h>
15392 #include <linux/nsproxy.h>
15393 +#include <linux/vs_base.h>
15394 +#include <linux/vs_limit.h>
15396 #include <asm/uaccess.h>
15398 @@ -274,6 +276,7 @@ static int newary(struct ipc_namespace *
15400 sma->sem_perm.mode = (semflg & S_IRWXUGO);
15401 sma->sem_perm.key = key;
15402 + sma->sem_perm.xid = vx_current_xid();
15404 sma->sem_perm.security = NULL;
15405 retval = security_sem_alloc(sma);
15406 @@ -289,6 +292,9 @@ static int newary(struct ipc_namespace *
15409 ns->used_sems += nsems;
15410 + /* FIXME: obsoleted? */
15411 + vx_semary_inc(sma);
15412 + vx_nsems_add(sma, nsems);
15414 sma->sem_perm.id = sem_buildid(id, sma->sem_perm.seq);
15415 sma->sem_base = (struct sem *) &sma[1];
15416 diff -NurpP --minimal linux-2.6.24-rc7/ipc/shm.c linux-2.6.24-rc7-vs2.2.0.5.0.7/ipc/shm.c
15417 --- linux-2.6.24-rc7/ipc/shm.c 2007-11-29 01:12:30 +0100
15418 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/ipc/shm.c 2007-12-13 13:25:48 +0100
15420 #include <linux/rwsem.h>
15421 #include <linux/nsproxy.h>
15422 #include <linux/mount.h>
15423 +#include <linux/vs_context.h>
15424 +#include <linux/vs_limit.h>
15426 #include <asm/uaccess.h>
15428 @@ -218,7 +220,12 @@ static void shm_open(struct vm_area_stru
15430 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
15432 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15433 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
15434 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
15436 + vx_ipcshm_sub(vxi, shp, numpages);
15437 + ns->shm_tot -= numpages;
15441 if (!is_file_hugepages(shp->shm_file))
15442 @@ -228,6 +235,7 @@ static void shm_destroy(struct ipc_names
15444 fput (shp->shm_file);
15445 security_shm_free(shp);
15446 + put_vx_info(vxi);
15447 ipc_rcu_putref(shp);
15450 @@ -398,11 +406,15 @@ static int newseg(struct ipc_namespace *
15451 if (ns->shm_tot + numpages > ns->shm_ctlall)
15454 + if (!vx_ipcshm_avail(current->vx_info, numpages))
15457 shp = ipc_rcu_alloc(sizeof(*shp));
15461 shp->shm_perm.key = key;
15462 + shp->shm_perm.xid = vx_current_xid();
15463 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
15464 shp->mlock_user = NULL;
15466 @@ -456,6 +468,7 @@ static int newseg(struct ipc_namespace *
15467 ns->shm_tot += numpages;
15468 error = shp->shm_perm.id;
15470 + vx_ipcshm_add(current->vx_info, key, numpages);
15474 diff -NurpP --minimal linux-2.6.24-rc7/ipc/util.c linux-2.6.24-rc7-vs2.2.0.5.0.7/ipc/util.c
15475 --- linux-2.6.24-rc7/ipc/util.c 2007-11-29 01:12:30 +0100
15476 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/ipc/util.c 2007-12-13 13:25:48 +0100
15478 #include <linux/audit.h>
15479 #include <linux/nsproxy.h>
15480 #include <linux/rwsem.h>
15481 +#include <linux/vs_base.h>
15482 +#include <linux/vserver/global.h>
15484 #include <asm/unistd.h>
15486 @@ -72,6 +74,7 @@ static struct ipc_namespace *clone_ipc_n
15489 kref_init(&ns->kref);
15490 + atomic_inc(&vs_global_ipc_ns);
15494 @@ -108,6 +111,7 @@ void free_ipc_ns(struct kref *kref)
15498 + atomic_dec(&vs_global_ipc_ns);
15502 diff -NurpP --minimal linux-2.6.24-rc7/kernel/Makefile linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/Makefile
15503 --- linux-2.6.24-rc7/kernel/Makefile 2007-11-29 01:12:30 +0100
15504 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/Makefile 2007-12-13 13:25:26 +0100
15505 @@ -11,6 +11,8 @@ obj-y = sched.o fork.o exec_domain.o
15506 hrtimer.o rwsem.o latency.o nsproxy.o srcu.o \
15507 utsname.o notifier.o
15511 obj-$(CONFIG_SYSCTL) += sysctl_check.o
15512 obj-$(CONFIG_STACKTRACE) += stacktrace.o
15514 diff -NurpP --minimal linux-2.6.24-rc7/kernel/capability.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/capability.c
15515 --- linux-2.6.24-rc7/kernel/capability.c 2007-11-29 01:12:30 +0100
15516 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/capability.c 2007-12-13 13:25:43 +0100
15518 #include <linux/security.h>
15519 #include <linux/syscalls.h>
15520 #include <linux/pid_namespace.h>
15521 +#include <linux/vs_context.h>
15522 #include <asm/uaccess.h>
15525 @@ -98,6 +99,8 @@ static inline int cap_set_pg(int pgrp_nr
15527 pgrp = find_vpid(pgrp_nr);
15528 do_each_pid_task(pgrp, PIDTYPE_PGID, g) {
15529 + if (!vx_check(g->xid, VS_ADMIN_P | VS_IDENT))
15532 while_each_thread(g, target) {
15533 if (!security_capset_check(target, effective,
15534 @@ -240,8 +243,12 @@ int __capable(struct task_struct *t, int
15538 +#include <linux/vserver/base.h>
15539 int capable(int cap)
15541 + /* here for now so we don't require task locking */
15542 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
15544 return __capable(current, cap);
15546 EXPORT_SYMBOL(capable);
15547 diff -NurpP --minimal linux-2.6.24-rc7/kernel/cgroup.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/cgroup.c
15548 --- linux-2.6.24-rc7/kernel/cgroup.c 2007-11-29 01:12:30 +0100
15549 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/cgroup.c 2007-12-13 16:01:10 +0100
15550 @@ -2611,7 +2611,7 @@ int cgroup_clone(struct task_struct *tsk
15553 /* Create the cgroup directory, which also creates the cgroup */
15554 - ret = vfs_mkdir(inode, dentry, S_IFDIR | 0755);
15555 + ret = vfs_mkdir(inode, dentry, S_IFDIR | 0755, NULL);
15556 child = __d_cgrp(dentry);
15559 diff -NurpP --minimal linux-2.6.24-rc7/kernel/compat.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/compat.c
15560 --- linux-2.6.24-rc7/kernel/compat.c 2007-11-29 01:12:30 +0100
15561 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/compat.c 2007-12-13 13:25:36 +0100
15562 @@ -811,7 +811,7 @@ asmlinkage long compat_sys_time(compat_t
15566 - do_gettimeofday(&tv);
15567 + vx_gettimeofday(&tv);
15571 @@ -835,7 +835,7 @@ asmlinkage long compat_sys_stime(compat_
15575 - do_settimeofday(&tv);
15576 + vx_settimeofday(&tv);
15580 diff -NurpP --minimal linux-2.6.24-rc7/kernel/exit.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/exit.c
15581 --- linux-2.6.24-rc7/kernel/exit.c 2007-12-31 17:58:28 +0100
15582 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/exit.c 2007-12-31 12:45:36 +0100
15584 #include <linux/resource.h>
15585 #include <linux/blkdev.h>
15586 #include <linux/task_io_accounting_ops.h>
15587 +#include <linux/vs_limit.h>
15588 +#include <linux/vs_context.h>
15589 +#include <linux/vs_network.h>
15590 +#include <linux/vs_pid.h>
15591 +#include <linux/vserver/global.h>
15593 #include <asm/uaccess.h>
15594 #include <asm/unistd.h>
15595 @@ -440,9 +445,11 @@ static void close_files(struct files_str
15596 filp_close(file, files);
15599 + vx_openfd_dec(i);
15607 @@ -522,6 +529,7 @@ static void __put_fs_struct(struct fs_st
15609 mntput(fs->altrootmnt);
15611 + atomic_dec(&vs_global_fs);
15612 kmem_cache_free(fs_cachep, fs);
15615 @@ -1010,6 +1018,8 @@ fastcall NORET_TYPE void do_exit(long co
15616 module_put(tsk->binfmt->module);
15618 proc_exit_connector(tsk);
15619 + /* needs to stay before exit_notify() */
15620 + exit_vx_info_early(tsk, code);
15623 mpol_free(tsk->mempolicy);
15624 @@ -1042,6 +1052,10 @@ fastcall NORET_TYPE void do_exit(long co
15625 if (tsk->splice_pipe)
15626 __free_pipe_info(tsk->splice_pipe);
15628 + /* needs to stay after exit_notify() */
15629 + exit_vx_info(tsk, code);
15630 + exit_nx_info(tsk);
15633 /* causes final put_task_struct in finish_task_switch(). */
15634 tsk->state = TASK_DEAD;
15635 diff -NurpP --minimal linux-2.6.24-rc7/kernel/fork.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/fork.c
15636 --- linux-2.6.24-rc7/kernel/fork.c 2007-12-31 17:58:28 +0100
15637 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/fork.c 2007-12-31 12:45:36 +0100
15639 #include <linux/random.h>
15640 #include <linux/tty.h>
15641 #include <linux/proc_fs.h>
15642 +#include <linux/vs_context.h>
15643 +#include <linux/vs_network.h>
15644 +#include <linux/vs_limit.h>
15645 +#include <linux/vs_memory.h>
15646 +#include <linux/vserver/global.h>
15648 #include <asm/pgtable.h>
15649 #include <asm/pgalloc.h>
15650 @@ -111,6 +116,8 @@ void free_task(struct task_struct *tsk)
15651 prop_local_destroy_single(&tsk->dirties);
15652 free_thread_info(tsk->stack);
15653 rt_mutex_debug_task_free(tsk);
15654 + clr_vx_info(&tsk->vx_info);
15655 + clr_nx_info(&tsk->nx_info);
15656 free_task_struct(tsk);
15658 EXPORT_SYMBOL(free_task);
15659 @@ -227,6 +234,8 @@ static int dup_mmap(struct mm_struct *mm
15660 mm->free_area_cache = oldmm->mmap_base;
15661 mm->cached_hole_size = ~0UL;
15663 + __set_mm_counter(mm, file_rss, 0);
15664 + __set_mm_counter(mm, anon_rss, 0);
15665 cpus_clear(mm->cpu_vm_mask);
15666 mm->mm_rb = RB_ROOT;
15667 rb_link = &mm->mm_rb.rb_node;
15668 @@ -238,7 +247,7 @@ static int dup_mmap(struct mm_struct *mm
15670 if (mpnt->vm_flags & VM_DONTCOPY) {
15671 long pages = vma_pages(mpnt);
15672 - mm->total_vm -= pages;
15673 + vx_vmpages_sub(mm, pages);
15674 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
15677 @@ -339,7 +348,7 @@ __cacheline_aligned_in_smp DEFINE_SPINLO
15679 #include <linux/init_task.h>
15681 -static struct mm_struct * mm_init(struct mm_struct * mm)
15682 +static struct mm_struct * mm_init(struct mm_struct * mm, struct vx_info *vxi)
15684 atomic_set(&mm->mm_users, 1);
15685 atomic_set(&mm->mm_count, 1);
15686 @@ -349,8 +358,8 @@ static struct mm_struct * mm_init(struct
15687 : MMF_DUMP_FILTER_DEFAULT;
15688 mm->core_waiters = 0;
15690 - set_mm_counter(mm, file_rss, 0);
15691 - set_mm_counter(mm, anon_rss, 0);
15692 + __set_mm_counter(mm, file_rss, 0);
15693 + __set_mm_counter(mm, anon_rss, 0);
15694 spin_lock_init(&mm->page_table_lock);
15695 rwlock_init(&mm->ioctx_list_lock);
15696 mm->ioctx_list = NULL;
15697 @@ -359,6 +368,7 @@ static struct mm_struct * mm_init(struct
15699 if (likely(!mm_alloc_pgd(mm))) {
15701 + set_vx_info(&mm->mm_vx_info, vxi);
15705 @@ -375,7 +385,7 @@ struct mm_struct * mm_alloc(void)
15706 mm = allocate_mm();
15708 memset(mm, 0, sizeof(*mm));
15709 - mm = mm_init(mm);
15710 + mm = mm_init(mm, current->vx_info);
15714 @@ -390,6 +400,7 @@ void fastcall __mmdrop(struct mm_struct
15715 BUG_ON(mm == &init_mm);
15717 destroy_context(mm);
15718 + clr_vx_info(&mm->mm_vx_info);
15722 @@ -504,12 +515,13 @@ static struct mm_struct *dup_mm(struct t
15725 memcpy(mm, oldmm, sizeof(*mm));
15726 + mm->mm_vx_info = NULL;
15728 /* Initializing for Swap token stuff */
15729 mm->token_priority = 0;
15730 mm->last_interval = 0;
15732 - if (!mm_init(mm))
15733 + if (!mm_init(mm, oldmm->mm_vx_info))
15736 if (init_new_context(tsk, mm))
15737 @@ -535,6 +547,7 @@ fail_nocontext:
15738 * If init_new_context() failed, we cannot use mmput() to free the mm
15739 * because it calls destroy_context()
15741 + clr_vx_info(&mm->mm_vx_info);
15745 @@ -605,6 +618,7 @@ static struct fs_struct *__copy_fs_struc
15746 fs->altroot = NULL;
15748 read_unlock(&old->lock);
15749 + atomic_inc(&vs_global_fs);
15753 @@ -723,6 +737,8 @@ static struct files_struct *dup_fd(struc
15754 struct file *f = *old_fds++;
15757 + /* TODO: sum it first for check and performance */
15758 + vx_openfd_inc(open_files - i);
15761 * The fd may be claimed in the fd bitmap but not yet
15762 @@ -980,6 +996,8 @@ static struct task_struct *copy_process(
15764 struct task_struct *p;
15765 int cgroup_callbacks_done = 0;
15766 + struct vx_info *vxi;
15767 + struct nx_info *nxi;
15769 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
15770 return ERR_PTR(-EINVAL);
15771 @@ -1014,12 +1032,28 @@ static struct task_struct *copy_process(
15772 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
15773 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
15775 + init_vx_info(&p->vx_info, current->vx_info);
15776 + init_nx_info(&p->nx_info, current->nx_info);
15778 + /* check vserver memory */
15779 + if (p->mm && !(clone_flags & CLONE_VM)) {
15780 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
15781 + vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15783 + goto bad_fork_free;
15785 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
15786 + if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
15787 + goto bad_fork_cleanup_vm;
15790 + if (!vx_nproc_avail(1))
15791 + goto bad_fork_cleanup_vm;
15792 if (atomic_read(&p->user->processes) >=
15793 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
15794 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
15795 p->user != current->nsproxy->user_ns->root_user)
15796 - goto bad_fork_free;
15797 + goto bad_fork_cleanup_vm;
15800 atomic_inc(&p->user->__count);
15801 @@ -1309,6 +1343,18 @@ static struct task_struct *copy_process(
15804 spin_unlock(¤t->sighand->siglock);
15806 + /* p is copy of current */
15807 + vxi = p->vx_info;
15809 + claim_vx_info(vxi, p);
15810 + atomic_inc(&vxi->cvirt.nr_threads);
15811 + atomic_inc(&vxi->cvirt.total_forks);
15814 + nxi = p->nx_info;
15816 + claim_nx_info(nxi, p);
15817 write_unlock_irq(&tasklist_lock);
15818 proc_fork_connector(p);
15819 cgroup_post_fork(p);
15820 @@ -1353,6 +1399,9 @@ bad_fork_cleanup_count:
15821 put_group_info(p->group_info);
15822 atomic_dec(&p->user->processes);
15824 +bad_fork_cleanup_vm:
15825 + if (p->mm && !(clone_flags & CLONE_VM))
15826 + vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
15830 @@ -1411,6 +1460,13 @@ long do_fork(unsigned long clone_flags,
15834 + /* kernel threads are host only */
15835 + if ((clone_flags & CLONE_KTHREAD) && !vx_check(0, VS_ADMIN)) {
15836 + vxwprintk_task(1, "tried to spawn a kernel thread.");
15841 if (unlikely(current->ptrace)) {
15842 trace = fork_traceflag (clone_flags);
15844 diff -NurpP --minimal linux-2.6.24-rc7/kernel/kthread.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/kthread.c
15845 --- linux-2.6.24-rc7/kernel/kthread.c 2007-11-29 01:02:26 +0100
15846 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/kthread.c 2007-12-13 15:03:55 +0100
15848 #include <linux/file.h>
15849 #include <linux/module.h>
15850 #include <linux/mutex.h>
15851 +#include <linux/vs_pid.h>
15852 #include <asm/semaphore.h>
15854 static DEFINE_SPINLOCK(kthread_create_lock);
15855 @@ -96,7 +97,7 @@ static void create_kthread(struct kthrea
15857 wait_for_completion(&create->started);
15858 read_lock(&tasklist_lock);
15859 - create->result = find_task_by_pid(pid);
15860 + create->result = find_task_by_real_pid(pid);
15861 read_unlock(&tasklist_lock);
15863 complete(&create->done);
15864 diff -NurpP --minimal linux-2.6.24-rc7/kernel/nsproxy.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/nsproxy.c
15865 --- linux-2.6.24-rc7/kernel/nsproxy.c 2007-11-29 01:12:31 +0100
15866 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/nsproxy.c 2008-01-04 15:41:02 +0100
15868 #include <linux/mnt_namespace.h>
15869 #include <linux/utsname.h>
15870 #include <linux/pid_namespace.h>
15871 +#include <linux/vserver/global.h>
15872 +#include <linux/vserver/debug.h>
15873 #include <net/net_namespace.h>
15875 static struct kmem_cache *nsproxy_cachep;
15876 @@ -37,6 +39,9 @@ static inline struct nsproxy *clone_nspr
15878 memcpy(ns, orig, sizeof(struct nsproxy));
15879 atomic_set(&ns->count, 1);
15880 + vxdprintk(VXD_CBIT(space, 2), "clone_nsproxy(%p[%u] = %p[1]",
15881 + orig, atomic_read(&orig->count), ns);
15882 + atomic_inc(&vs_global_nsproxy);
15886 @@ -46,47 +51,51 @@ static inline struct nsproxy *clone_nspr
15887 * Return the newly created nsproxy. Do not attach this to the task,
15888 * leave it to the caller to do proper locking and attach it to task.
15890 -static struct nsproxy *create_new_namespaces(unsigned long flags,
15891 - struct task_struct *tsk, struct fs_struct *new_fs)
15892 +static struct nsproxy *unshare_namespaces(unsigned long flags,
15893 + struct nsproxy *orig, struct fs_struct *new_fs)
15895 struct nsproxy *new_nsp;
15898 - new_nsp = clone_nsproxy(tsk->nsproxy);
15899 + vxdprintk(VXD_CBIT(space, 4),
15900 + "unshare_namespaces(0x%08lx,%p,%p)",
15901 + flags, orig, new_fs);
15903 + new_nsp = clone_nsproxy(orig);
15905 return ERR_PTR(-ENOMEM);
15907 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
15908 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
15909 if (IS_ERR(new_nsp->mnt_ns)) {
15910 err = PTR_ERR(new_nsp->mnt_ns);
15914 - new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
15915 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
15916 if (IS_ERR(new_nsp->uts_ns)) {
15917 err = PTR_ERR(new_nsp->uts_ns);
15921 - new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
15922 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
15923 if (IS_ERR(new_nsp->ipc_ns)) {
15924 err = PTR_ERR(new_nsp->ipc_ns);
15928 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
15929 + new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
15930 if (IS_ERR(new_nsp->pid_ns)) {
15931 err = PTR_ERR(new_nsp->pid_ns);
15935 - new_nsp->user_ns = copy_user_ns(flags, tsk->nsproxy->user_ns);
15936 + new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
15937 if (IS_ERR(new_nsp->user_ns)) {
15938 err = PTR_ERR(new_nsp->user_ns);
15942 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
15943 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
15944 if (IS_ERR(new_nsp->net_ns)) {
15945 err = PTR_ERR(new_nsp->net_ns);
15947 @@ -114,6 +123,37 @@ out_ns:
15948 return ERR_PTR(err);
15951 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
15952 + struct fs_struct *new_fs)
15954 + return unshare_namespaces(flags, tsk->nsproxy, new_fs);
15958 + * copies the nsproxy, setting refcount to 1, and grabbing a
15959 + * reference to all contained namespaces.
15961 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
15963 + struct nsproxy *ns = clone_nsproxy(orig);
15967 + get_mnt_ns(ns->mnt_ns);
15969 + get_uts_ns(ns->uts_ns);
15971 + get_ipc_ns(ns->ipc_ns);
15973 + get_pid_ns(ns->pid_ns);
15975 + get_user_ns(ns->user_ns);
15977 + get_net(ns->net_ns);
15983 * called from clone. This now handles copy for nsproxy and all
15984 * namespaces therein.
15985 @@ -121,9 +161,12 @@ out_ns:
15986 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
15988 struct nsproxy *old_ns = tsk->nsproxy;
15989 - struct nsproxy *new_ns;
15990 + struct nsproxy *new_ns = NULL;
15993 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
15994 + flags, tsk, old_ns);
15999 @@ -154,6 +197,9 @@ int copy_namespaces(unsigned long flags,
16002 put_nsproxy(old_ns);
16003 + vxdprintk(VXD_CBIT(space, 3),
16004 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
16005 + flags, tsk, old_ns, err, new_ns);
16009 @@ -170,6 +216,7 @@ void free_nsproxy(struct nsproxy *ns)
16011 put_user_ns(ns->user_ns);
16012 put_net(ns->net_ns);
16013 + atomic_dec(&vs_global_nsproxy);
16014 kmem_cache_free(nsproxy_cachep, ns);
16017 @@ -182,6 +229,10 @@ int unshare_nsproxy_namespaces(unsigned
16021 + vxdprintk(VXD_CBIT(space, 4),
16022 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
16023 + unshare_flags, current->nsproxy);
16025 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
16026 CLONE_NEWUSER | CLONE_NEWNET)))
16028 diff -NurpP --minimal linux-2.6.24-rc7/kernel/pid.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/pid.c
16029 --- linux-2.6.24-rc7/kernel/pid.c 2007-11-29 01:12:31 +0100
16030 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/pid.c 2007-12-17 23:41:44 +0100
16032 #include <linux/pid_namespace.h>
16033 #include <linux/init_task.h>
16034 #include <linux/syscalls.h>
16035 +#include <linux/vs_pid.h>
16036 +#include <linux/vserver/global.h>
16038 #define pid_hashfn(nr, ns) \
16039 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
16040 @@ -304,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
16042 struct pid *find_vpid(int nr)
16044 - return find_pid_ns(nr, current->nsproxy->pid_ns);
16045 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
16047 EXPORT_SYMBOL_GPL(find_vpid);
16049 @@ -360,6 +362,9 @@ void fastcall transfer_pid(struct task_s
16050 struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
16052 struct task_struct *result = NULL;
16054 + if (type == PIDTYPE_REALPID)
16055 + type = PIDTYPE_PID;
16057 struct hlist_node *first;
16058 first = rcu_dereference(pid->tasks[type].first);
16059 @@ -388,14 +393,14 @@ EXPORT_SYMBOL(find_task_by_pid);
16061 struct task_struct *find_task_by_vpid(pid_t vnr)
16063 - return find_task_by_pid_type_ns(PIDTYPE_PID, vnr,
16064 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(vnr),
16065 current->nsproxy->pid_ns);
16067 EXPORT_SYMBOL(find_task_by_vpid);
16069 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
16071 - return find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns);
16072 + return find_task_by_pid_type_ns(PIDTYPE_PID, vx_rmap_pid(nr), ns);
16074 EXPORT_SYMBOL(find_task_by_pid_ns);
16076 @@ -440,7 +445,7 @@ pid_t pid_nr_ns(struct pid *pid, struct
16077 if (upid->ns == ns)
16081 + return vx_map_pid(nr);
16084 pid_t task_pid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
16085 @@ -556,6 +561,7 @@ static struct pid_namespace *create_pid_
16088 kref_init(&ns->kref);
16089 + atomic_inc(&vs_global_pid_ns);
16091 ns->child_reaper = NULL;
16093 @@ -584,6 +590,7 @@ static void destroy_pid_namespace(struct
16095 for (i = 0; i < PIDMAP_ENTRIES; i++)
16096 kfree(ns->pidmap[i].page);
16097 + atomic_dec(&vs_global_pid_ns);
16098 kmem_cache_free(pid_ns_cachep, ns);
16101 diff -NurpP --minimal linux-2.6.24-rc7/kernel/posix-timers.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/posix-timers.c
16102 --- linux-2.6.24-rc7/kernel/posix-timers.c 2007-11-29 01:12:31 +0100
16103 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/posix-timers.c 2007-12-13 13:25:45 +0100
16105 #include <linux/wait.h>
16106 #include <linux/workqueue.h>
16107 #include <linux/module.h>
16108 +#include <linux/vs_context.h>
16111 * Management arrays for POSIX timers. Timers are kept in slab memory
16112 @@ -298,6 +299,12 @@ void do_schedule_next_timer(struct sigin
16114 int posix_timer_event(struct k_itimer *timr,int si_private)
16116 + struct vx_info_save vxis;
16117 + struct vx_info *vxi;
16120 + vxi = task_get_vx_info(timr->it_process);
16121 + enter_vx_info(vxi, &vxis);
16122 memset(&timr->sigq->info, 0, sizeof(siginfo_t));
16123 timr->sigq->info.si_sys_private = si_private;
16124 /* Send signal to the process that owns this timer.*/
16125 @@ -310,11 +317,11 @@ int posix_timer_event(struct k_itimer *t
16127 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
16128 struct task_struct *leader;
16129 - int ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
16130 - timr->it_process);
16132 + ret = send_sigqueue(timr->it_sigev_signo, timr->sigq,
16133 + timr->it_process);
16134 if (likely(ret >= 0))
16138 timr->it_sigev_notify = SIGEV_SIGNAL;
16139 leader = timr->it_process->group_leader;
16140 @@ -322,8 +329,12 @@ int posix_timer_event(struct k_itimer *t
16141 timr->it_process = leader;
16144 - return send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
16145 + ret = send_group_sigqueue(timr->it_sigev_signo, timr->sigq,
16148 + leave_vx_info(&vxis);
16149 + put_vx_info(vxi);
16152 EXPORT_SYMBOL_GPL(posix_timer_event);
16154 diff -NurpP --minimal linux-2.6.24-rc7/kernel/printk.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/printk.c
16155 --- linux-2.6.24-rc7/kernel/printk.c 2008-01-11 12:00:51 +0100
16156 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/printk.c 2008-01-11 04:30:10 +0100
16158 #include <linux/bootmem.h>
16159 #include <linux/syscalls.h>
16160 #include <linux/jiffies.h>
16161 +#include <linux/vs_cvirt.h>
16163 #include <asm/uaccess.h>
16165 @@ -291,18 +292,13 @@ int do_syslog(int type, char __user *buf
16166 unsigned long i, j, limit, count;
16172 error = security_syslog(type);
16177 - case 0: /* Close log */
16179 - case 1: /* Open log */
16181 - case 2: /* Read from log */
16182 + if ((type >= 2) && (type <= 4)) {
16184 if (!buf || len < 0)
16186 @@ -313,6 +309,16 @@ int do_syslog(int type, char __user *buf
16191 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16192 + return vx_do_syslog(type, buf, len);
16195 + case 0: /* Close log */
16197 + case 1: /* Open log */
16199 + case 2: /* Read from log */
16200 error = wait_event_interruptible(log_wait,
16201 (log_start - log_end));
16203 @@ -337,16 +343,6 @@ int do_syslog(int type, char __user *buf
16206 case 3: /* Read last kernel messages */
16208 - if (!buf || len < 0)
16213 - if (!access_ok(VERIFY_WRITE, buf, len)) {
16218 if (count > log_buf_len)
16219 count = log_buf_len;
16220 diff -NurpP --minimal linux-2.6.24-rc7/kernel/ptrace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/ptrace.c
16221 --- linux-2.6.24-rc7/kernel/ptrace.c 2008-01-11 12:00:51 +0100
16222 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/ptrace.c 2008-01-11 04:30:10 +0100
16224 #include <linux/signal.h>
16225 #include <linux/audit.h>
16226 #include <linux/pid_namespace.h>
16227 +#include <linux/vs_context.h>
16229 #include <asm/pgtable.h>
16230 #include <asm/uaccess.h>
16231 @@ -146,6 +147,11 @@ int __ptrace_may_attach(struct task_stru
16232 dumpable = get_dumpable(task->mm);
16233 if (!dumpable && !capable(CAP_SYS_PTRACE))
16235 + if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
16237 + if (!vx_check(task->xid, VS_IDENT) &&
16238 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
16241 return security_ptrace(current, task);
16243 @@ -479,6 +485,10 @@ asmlinkage long sys_ptrace(long request,
16248 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
16249 + goto out_put_task_struct;
16251 if (request == PTRACE_ATTACH) {
16252 ret = ptrace_attach(child);
16254 diff -NurpP --minimal linux-2.6.24-rc7/kernel/sched.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sched.c
16255 --- linux-2.6.24-rc7/kernel/sched.c 2007-12-31 17:58:28 +0100
16256 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sched.c 2007-12-31 12:34:43 +0100
16258 #include <linux/reciprocal_div.h>
16259 #include <linux/unistd.h>
16260 #include <linux/pagemap.h>
16261 +#include <linux/vs_sched.h>
16262 +#include <linux/vs_cvirt.h>
16264 #include <asm/tlb.h>
16265 #include <asm/irq_regs.h>
16266 @@ -336,6 +338,16 @@ struct rq {
16267 struct task_struct *migration_thread;
16268 struct list_head migration_queue;
16270 + unsigned long norm_time;
16271 + unsigned long idle_time;
16272 +#ifdef CONFIG_VSERVER_IDLETIME
16275 +#ifdef CONFIG_VSERVER_HARDCPU
16276 + struct list_head hold_queue;
16277 + unsigned long nr_onhold;
16281 #ifdef CONFIG_SCHEDSTATS
16282 /* latency stats */
16283 @@ -941,6 +953,7 @@ static void set_load_weight(struct task_
16285 static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup)
16287 + // BUG_ON(p->state & TASK_ONHOLD);
16288 sched_info_queued(p);
16289 p->sched_class->enqueue_task(rq, p, wakeup);
16291 @@ -1113,6 +1126,9 @@ struct migration_req {
16292 struct completion done;
16295 +#include "sched_mon.h"
16299 * The task's runqueue lock must be held.
16300 * Returns true if you have to wait for migration thread.
16301 @@ -1122,6 +1138,7 @@ migrate_task(struct task_struct *p, int
16303 struct rq *rq = task_rq(p);
16305 + vxm_migrate_task(p, rq, dest_cpu);
16307 * If the task is not on a runqueue (and not running), then
16308 * it is sufficient to simply update the task's cpu field.
16309 @@ -1518,6 +1535,12 @@ static int try_to_wake_up(struct task_st
16311 rq = task_rq_lock(p, &flags);
16312 old_state = p->state;
16314 + /* we need to unhold suspended tasks
16315 + if (old_state & TASK_ONHOLD) {
16316 + vx_unhold_task(p, rq);
16317 + old_state = p->state;
16319 if (!(old_state & state))
16322 @@ -3359,13 +3382,16 @@ unsigned long long task_sched_runtime(st
16323 void account_user_time(struct task_struct *p, cputime_t cputime)
16325 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16326 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16328 + int nice = (TASK_NICE(p) > 0);
16330 p->utime = cputime_add(p->utime, cputime);
16331 + vx_account_user(vxi, cputime, nice);
16333 /* Add user time to cpustat. */
16334 tmp = cputime_to_cputime64(cputime);
16335 - if (TASK_NICE(p) > 0)
16337 cpustat->nice = cputime64_add(cpustat->nice, tmp);
16339 cpustat->user = cputime64_add(cpustat->user, tmp);
16340 @@ -3410,6 +3436,7 @@ void account_system_time(struct task_str
16343 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16344 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16345 struct rq *rq = this_rq();
16348 @@ -3417,6 +3444,7 @@ void account_system_time(struct task_str
16349 return account_guest_time(p, cputime);
16351 p->stime = cputime_add(p->stime, cputime);
16352 + vx_account_system(vxi, cputime, (p == rq->idle));
16354 /* Add system time to cpustat. */
16355 tmp = cputime_to_cputime64(cputime);
16356 @@ -4157,7 +4185,7 @@ asmlinkage long sys_nice(int increment)
16359 if (increment < 0 && !can_nice(current, nice))
16361 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
16363 retval = security_task_setnice(current, nice);
16365 diff -NurpP --minimal linux-2.6.24-rc7/kernel/sched_fair.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sched_fair.c
16366 --- linux-2.6.24-rc7/kernel/sched_fair.c 2007-12-31 17:58:28 +0100
16367 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sched_fair.c 2007-12-31 12:34:43 +0100
16368 @@ -538,6 +538,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
16369 check_spread(cfs_rq, se);
16370 if (se != cfs_rq->curr)
16371 __enqueue_entity(cfs_rq, se);
16372 + if (entity_is_task(se))
16373 + vx_activate_task(task_of(se));
16374 account_entity_enqueue(cfs_rq, se);
16377 @@ -565,6 +567,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
16379 if (se != cfs_rq->curr)
16380 __dequeue_entity(cfs_rq, se);
16381 + if (entity_is_task(se))
16382 + vx_deactivate_task(task_of(se));
16383 account_entity_dequeue(cfs_rq, se);
16386 diff -NurpP --minimal linux-2.6.24-rc7/kernel/sched_hard.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sched_hard.h
16387 --- linux-2.6.24-rc7/kernel/sched_hard.h 1970-01-01 01:00:00 +0100
16388 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sched_hard.h 2007-12-13 13:25:37 +0100
16391 +#ifdef CONFIG_VSERVER_IDLELIMIT
16394 + * vx_idle_resched - reschedule after maxidle
16397 +void vx_idle_resched(struct rq *rq)
16399 + /* maybe have a better criterion for paused */
16400 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
16401 + set_need_resched();
16404 +#else /* !CONFIG_VSERVER_IDLELIMIT */
16406 +#define vx_idle_resched(rq)
16408 +#endif /* CONFIG_VSERVER_IDLELIMIT */
16412 +#ifdef CONFIG_VSERVER_IDLETIME
16414 +#define vx_set_rq_min_skip(rq, min) \
16415 + (rq)->idle_skip = (min)
16417 +#define vx_save_min_skip(ret, min, val) \
16418 + __vx_save_min_skip(ret, min, val)
16421 +void __vx_save_min_skip(int ret, int *min, int val)
16425 + if ((*min > val) || !*min)
16430 +int vx_try_skip(struct rq *rq, int cpu)
16432 + /* artificially advance time */
16433 + if (rq->idle_skip > 0) {
16434 + vxdprintk(list_empty(&rq->hold_queue),
16435 + "hold queue empty on cpu %d", cpu);
16436 + rq->idle_time += rq->idle_skip;
16437 + vxm_idle_skip(rq, cpu);
16443 +#else /* !CONFIG_VSERVER_IDLETIME */
16445 +#define vx_set_rq_min_skip(rq, min) \
16446 + ({ int dummy = (min); dummy; })
16448 +#define vx_save_min_skip(ret, min, val)
16451 +int vx_try_skip(struct rq *rq, int cpu)
16456 +#endif /* CONFIG_VSERVER_IDLETIME */
16460 +#ifdef CONFIG_VSERVER_HARDCPU
16462 +#define vx_set_rq_max_idle(rq, max) \
16463 + (rq)->idle_tokens = (max)
16465 +#define vx_save_max_idle(ret, min, val) \
16466 + __vx_save_max_idle(ret, min, val)
16469 +void __vx_save_max_idle(int ret, int *min, int val)
16477 + * vx_hold_task - put a task on the hold queue
16480 +void vx_hold_task(struct task_struct *p, struct rq *rq)
16482 + __deactivate_task(p, rq);
16483 + p->state |= TASK_ONHOLD;
16484 + /* a new one on hold */
16486 + vxm_hold_task(p, rq);
16487 + list_add_tail(&p->run_list, &rq->hold_queue);
16491 + * vx_unhold_task - put a task back to the runqueue
16494 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16496 + list_del(&p->run_list);
16497 + /* one less waiting */
16499 + p->state &= ~TASK_ONHOLD;
16500 + enqueue_task(p, rq->expired);
16501 + inc_nr_running(p, rq);
16502 + vxm_unhold_task(p, rq);
16504 + if (p->static_prio < rq->best_expired_prio)
16505 + rq->best_expired_prio = p->static_prio;
16508 +unsigned long nr_onhold(void)
16510 + unsigned long i, sum = 0;
16512 + for_each_online_cpu(i)
16513 + sum += cpu_rq(i)->nr_onhold;
16521 +int __vx_tokens_avail(struct _vx_sched_pc *sched_pc)
16523 + return sched_pc->tokens;
16527 +void __vx_consume_token(struct _vx_sched_pc *sched_pc)
16529 + sched_pc->tokens--;
16533 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16535 + struct vx_info *vxi = p->vx_info;
16537 + if (vx_info_flags(vxi, VXF_SCHED_HARD|VXF_SCHED_PRIO, 0)) {
16538 + struct _vx_sched_pc *sched_pc =
16539 + &vx_per_cpu(vxi, sched_pc, cpu);
16542 + /* maybe we can simplify that to decrement
16543 + the token counter unconditional? */
16545 + if ((tokens = __vx_tokens_avail(sched_pc)) > 0)
16546 + __vx_consume_token(sched_pc);
16548 + /* for tokens > 0, one token was consumed */
16552 + vxm_need_resched(p, slice, cpu);
16553 + return (slice == 0);
16557 +#define vx_set_rq_time(rq, time) do { \
16558 + rq->norm_time = time; \
16563 +void vx_try_unhold(struct rq *rq, int cpu)
16565 + struct vx_info *vxi = NULL;
16566 + struct list_head *l, *n;
16567 + int maxidle = HZ;
16570 + /* nothing to do? what about pause? */
16571 + if (list_empty(&rq->hold_queue))
16574 + list_for_each_safe(l, n, &rq->hold_queue) {
16575 + int ret, delta_min[2];
16576 + struct _vx_sched_pc *sched_pc;
16577 + struct task_struct *p;
16579 + p = list_entry(l, struct task_struct, run_list);
16580 + /* don't bother with same context */
16581 + if (vxi == p->vx_info)
16584 + vxi = p->vx_info;
16585 + /* ignore paused contexts */
16586 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
16589 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16591 + /* recalc tokens */
16592 + vxm_sched_info(sched_pc, vxi, cpu);
16593 + ret = vx_tokens_recalc(sched_pc,
16594 + &rq->norm_time, &rq->idle_time, delta_min);
16595 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16598 + /* we found a runable context */
16599 + vx_unhold_task(p, rq);
16602 + vx_save_max_idle(ret, &maxidle, delta_min[0]);
16603 + vx_save_min_skip(ret, &minskip, delta_min[1]);
16605 + vx_set_rq_max_idle(rq, maxidle);
16606 + vx_set_rq_min_skip(rq, minskip);
16607 + vxm_rq_max_min(rq, cpu);
16612 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16614 + struct vx_info *vxi = next->vx_info;
16615 + struct _vx_sched_pc *sched_pc;
16616 + int delta_min[2];
16622 + flags = vxi->vx_flags;
16624 + if (unlikely(vs_check_flags(flags, VXF_SCHED_PAUSE, 0)))
16625 + goto put_on_hold;
16626 + if (!vs_check_flags(flags, VXF_SCHED_HARD | VXF_SCHED_PRIO, 0))
16629 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16631 + /* update scheduler params */
16632 + if (cpu_isset(cpu, vxi->sched.update)) {
16633 + vx_update_sched_param(&vxi->sched, sched_pc);
16634 + vxm_update_sched(sched_pc, vxi, cpu);
16635 + cpu_clear(cpu, vxi->sched.update);
16638 + vxm_sched_info(sched_pc, vxi, cpu);
16639 + ret = vx_tokens_recalc(sched_pc,
16640 + &rq->norm_time, &rq->idle_time, delta_min);
16641 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16643 + if (!vs_check_flags(flags, VXF_SCHED_HARD, 0))
16646 + if (unlikely(ret < 0)) {
16647 + vx_save_max_idle(ret, &rq->idle_tokens, delta_min[0]);
16648 + vx_save_min_skip(ret, &rq->idle_skip, delta_min[1]);
16649 + vxm_rq_max_min(rq, cpu);
16651 + vx_hold_task(next, rq);
16658 +#else /* CONFIG_VSERVER_HARDCPU */
16661 +void vx_hold_task(struct task_struct *p, struct rq *rq)
16667 +void vx_unhold_task(struct task_struct *p, struct rq *rq)
16672 +unsigned long nr_onhold(void)
16679 +int vx_need_resched(struct task_struct *p, int slice, int cpu)
16681 + return (slice == 0);
16685 +#define vx_set_rq_time(rq, time)
16688 +void vx_try_unhold(struct rq *rq, int cpu)
16694 +int vx_schedule(struct task_struct *next, struct rq *rq, int cpu)
16696 + struct vx_info *vxi = next->vx_info;
16697 + struct _vx_sched_pc *sched_pc;
16698 + int delta_min[2];
16701 + if (!vx_info_flags(vxi, VXF_SCHED_PRIO, 0))
16704 + sched_pc = &vx_per_cpu(vxi, sched_pc, cpu);
16705 + vxm_sched_info(sched_pc, vxi, cpu);
16706 + ret = vx_tokens_recalc(sched_pc,
16707 + &rq->norm_time, &rq->idle_time, delta_min);
16708 + vxm_tokens_recalc(sched_pc, rq, vxi, cpu);
16712 +#endif /* CONFIG_VSERVER_HARDCPU */
16714 diff -NurpP --minimal linux-2.6.24-rc7/kernel/sched_mon.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sched_mon.h
16715 --- linux-2.6.24-rc7/kernel/sched_mon.h 1970-01-01 01:00:00 +0100
16716 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sched_mon.h 2007-12-13 13:25:42 +0100
16719 +#include <linux/vserver/monitor.h>
16721 +#ifdef CONFIG_VSERVER_MONITOR
16723 +#ifdef CONFIG_VSERVER_HARDCPU
16724 +#define HARDCPU(x) (x)
16726 +#define HARDCPU(x) (0)
16729 +#ifdef CONFIG_VSERVER_IDLETIME
16730 +#define IDLETIME(x) (x)
16732 +#define IDLETIME(x) (0)
16735 +struct _vx_mon_entry *vxm_advance(int cpu);
16739 +void __vxm_basic(struct _vx_mon_entry *entry, xid_t xid, int type)
16741 + entry->type = type;
16742 + entry->xid = xid;
16746 +void __vxm_sync(int cpu)
16748 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16750 + __vxm_basic(entry, 0, VXM_SYNC);
16751 + entry->ev.sec = xtime.tv_sec;
16752 + entry->ev.nsec = xtime.tv_nsec;
16756 +void __vxm_task(struct task_struct *p, int type)
16758 + struct _vx_mon_entry *entry = vxm_advance(task_cpu(p));
16760 + __vxm_basic(entry, p->xid, type);
16761 + entry->ev.tsk.pid = p->pid;
16762 + entry->ev.tsk.state = p->state;
16766 +void __vxm_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16768 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16770 + __vxm_basic(entry, vxi->vx_id, (VXM_SCHED | s->flags));
16771 + entry->sd.tokens = s->tokens;
16772 + entry->sd.norm_time = s->norm_time;
16773 + entry->sd.idle_time = s->idle_time;
16777 +void __vxm_rqinfo1(struct rq *q, int cpu)
16779 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16781 + entry->type = VXM_RQINFO_1;
16782 + entry->xid = ((unsigned long)q >> 16) & 0xffff;
16783 + entry->q1.running = q->nr_running;
16784 + entry->q1.onhold = HARDCPU(q->nr_onhold);
16785 + entry->q1.iowait = atomic_read(&q->nr_iowait);
16786 + entry->q1.uintr = q->nr_uninterruptible;
16787 + entry->q1.idle_tokens = IDLETIME(q->idle_tokens);
16791 +void __vxm_rqinfo2(struct rq *q, int cpu)
16793 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16795 + entry->type = VXM_RQINFO_2;
16796 + entry->xid = (unsigned long)q & 0xffff;
16797 + entry->q2.norm_time = q->norm_time;
16798 + entry->q2.idle_time = q->idle_time;
16799 + entry->q2.idle_skip = IDLETIME(q->idle_skip);
16803 +void __vxm_update(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16805 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16807 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE);
16808 + entry->ev.tokens = s->tokens;
16812 +void __vxm_update1(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16814 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16816 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_1);
16817 + entry->u1.tokens_max = s->tokens_max;
16818 + entry->u1.fill_rate = s->fill_rate[0];
16819 + entry->u1.interval = s->interval[0];
16823 +void __vxm_update2(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16825 + struct _vx_mon_entry *entry = vxm_advance(cpu);
16827 + __vxm_basic(entry, vxi->vx_id, VXM_UPDATE_2);
16828 + entry->u2.tokens_min = s->tokens_min;
16829 + entry->u2.fill_rate = s->fill_rate[1];
16830 + entry->u2.interval = s->interval[1];
16834 +#define vxm_activate_task(p,q) __vxm_task(p, VXM_ACTIVATE)
16835 +#define vxm_activate_idle(p,q) __vxm_task(p, VXM_IDLE)
16836 +#define vxm_deactivate_task(p,q) __vxm_task(p, VXM_DEACTIVATE)
16837 +#define vxm_hold_task(p,q) __vxm_task(p, VXM_HOLD)
16838 +#define vxm_unhold_task(p,q) __vxm_task(p, VXM_UNHOLD)
16841 +void vxm_migrate_task(struct task_struct *p, struct rq *rq, int dest)
16843 + __vxm_task(p, VXM_MIGRATE);
16844 + __vxm_rqinfo1(rq, task_cpu(p));
16845 + __vxm_rqinfo2(rq, task_cpu(p));
16849 +void vxm_idle_skip(struct rq *rq, int cpu)
16851 + __vxm_rqinfo1(rq, cpu);
16852 + __vxm_rqinfo2(rq, cpu);
16856 +void vxm_need_resched(struct task_struct *p, int slice, int cpu)
16861 + __vxm_task(p, VXM_RESCHED);
16865 +void vxm_sync(unsigned long now, int cpu)
16867 + if (!CONFIG_VSERVER_MONITOR_SYNC ||
16868 + (now % CONFIG_VSERVER_MONITOR_SYNC))
16874 +#define vxm_sched_info(s,v,c) __vxm_sched(s,v,c)
16877 +void vxm_tokens_recalc(struct _vx_sched_pc *s, struct rq *rq,
16878 + struct vx_info *vxi, int cpu)
16880 + __vxm_sched(s, vxi, cpu);
16881 + __vxm_rqinfo2(rq, cpu);
16885 +void vxm_update_sched(struct _vx_sched_pc *s, struct vx_info *vxi, int cpu)
16887 + __vxm_sched(s, vxi, cpu);
16888 + __vxm_update(s, vxi, cpu);
16889 + __vxm_update1(s, vxi, cpu);
16890 + __vxm_update2(s, vxi, cpu);
16894 +void vxm_rq_max_min(struct rq *rq, int cpu)
16896 + __vxm_rqinfo1(rq, cpu);
16897 + __vxm_rqinfo2(rq, cpu);
16900 +#else /* CONFIG_VSERVER_MONITOR */
16902 +#define vxm_activate_task(t,q) do { } while (0)
16903 +#define vxm_activate_idle(t,q) do { } while (0)
16904 +#define vxm_deactivate_task(t,q) do { } while (0)
16905 +#define vxm_hold_task(t,q) do { } while (0)
16906 +#define vxm_unhold_task(t,q) do { } while (0)
16907 +#define vxm_migrate_task(t,q,d) do { } while (0)
16908 +#define vxm_idle_skip(q,c) do { } while (0)
16909 +#define vxm_need_resched(t,s,c) do { } while (0)
16910 +#define vxm_sync(s,c) do { } while (0)
16911 +#define vxm_sched_info(s,v,c) do { } while (0)
16912 +#define vxm_tokens_recalc(s,q,v,c) do { } while (0)
16913 +#define vxm_update_sched(s,v,c) do { } while (0)
16914 +#define vxm_rq_max_min(q,c) do { } while (0)
16916 +#endif /* CONFIG_VSERVER_MONITOR */
16918 diff -NurpP --minimal linux-2.6.24-rc7/kernel/signal.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/signal.c
16919 --- linux-2.6.24-rc7/kernel/signal.c 2007-11-29 01:12:31 +0100
16920 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/signal.c 2008-01-11 03:51:27 +0100
16922 #include <linux/freezer.h>
16923 #include <linux/pid_namespace.h>
16924 #include <linux/nsproxy.h>
16925 +#include <linux/vs_context.h>
16926 +#include <linux/vs_pid.h>
16928 #include <asm/param.h>
16929 #include <asm/uaccess.h>
16930 @@ -530,6 +532,14 @@ static int check_kill_permission(int sig
16931 if (!valid_signal(sig))
16934 + if ((info != SEND_SIG_NOINFO) &&
16935 + (is_si_special(info) || !SI_FROMUSER(info)))
16938 + vxdprintk(VXD_CBIT(misc, 7),
16939 + "check_kill_permission(%d,%p,%p[#%u,%u])",
16940 + sig, info, t, vx_task_xid(t), t->pid);
16942 if (info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info))) {
16943 error = audit_signal_info(sig, t); /* Let audit system see the signal */
16945 @@ -543,6 +553,14 @@ static int check_kill_permission(int sig
16950 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
16951 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
16952 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
16953 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
16957 return security_task_kill(t, info, sig, 0);
16960 @@ -1075,7 +1093,7 @@ int kill_pid_info(int sig, struct siginf
16962 p = pid_task(pid, PIDTYPE_PID);
16965 + if (p && vx_check(vx_task_xid(p), VS_IDENT))
16966 error = group_send_sig_info(sig, info, p);
16968 if (unlikely(sig_needs_tasklist(sig)))
16969 @@ -1150,7 +1168,9 @@ static int kill_something_info(int sig,
16971 read_lock(&tasklist_lock);
16972 for_each_process(p) {
16973 - if (p->pid > 1 && !same_thread_group(p, current)) {
16974 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
16975 + p->pid > 1 && !same_thread_group(p, current) &&
16976 + !vx_current_initpid(p->pid)) {
16977 int err = group_send_sig_info(sig, info, p);
16980 @@ -1866,6 +1886,11 @@ relock:
16981 if (is_global_init(current))
16984 + /* virtual init is protected against user signals */
16985 + if ((info->si_code == SI_USER) &&
16986 + vx_current_initpid(current->pid))
16989 if (sig_kernel_stop(signr)) {
16991 * The default action is to stop all threads in
16992 diff -NurpP --minimal linux-2.6.24-rc7/kernel/softirq.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/softirq.c
16993 --- linux-2.6.24-rc7/kernel/softirq.c 2007-11-29 01:12:31 +0100
16994 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/softirq.c 2007-12-13 13:25:12 +0100
16996 #include <linux/rcupdate.h>
16997 #include <linux/smp.h>
16998 #include <linux/tick.h>
16999 +#include <linux/vs_context.h>
17001 #include <asm/irq.h>
17003 diff -NurpP --minimal linux-2.6.24-rc7/kernel/sys.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sys.c
17004 --- linux-2.6.24-rc7/kernel/sys.c 2007-12-31 17:58:28 +0100
17005 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sys.c 2007-12-31 12:34:43 +0100
17007 #include <linux/syscalls.h>
17008 #include <linux/kprobes.h>
17009 #include <linux/user_namespace.h>
17010 +#include <linux/vs_pid.h>
17012 #include <asm/uaccess.h>
17013 #include <asm/io.h>
17014 @@ -116,7 +117,10 @@ static int set_one_prio(struct task_stru
17017 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17019 + if (vx_flags(VXF_IGNEG_NICE, 0))
17025 no_nice = security_task_setnice(p, niceval);
17026 @@ -164,6 +168,8 @@ asmlinkage long sys_setpriority(int whic
17028 pgrp = task_pgrp(current);
17029 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
17030 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17032 error = set_one_prio(p, niceval, error);
17033 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
17035 @@ -224,6 +230,8 @@ asmlinkage long sys_getpriority(int whic
17037 pgrp = task_pgrp(current);
17038 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
17039 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17041 niceval = 20 - task_nice(p);
17042 if (niceval > retval)
17044 @@ -353,6 +361,9 @@ void kernel_power_off(void)
17045 machine_power_off();
17047 EXPORT_SYMBOL_GPL(kernel_power_off);
17049 +long vs_reboot(unsigned int, void __user *);
17052 * Reboot system call: for obvious reasons only root may call it,
17053 * and even root needs to set up some magic numbers in the registers
17054 @@ -383,6 +394,9 @@ asmlinkage long sys_reboot(int magic1, i
17055 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17056 cmd = LINUX_REBOOT_CMD_HALT;
17058 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
17059 + return vs_reboot(cmd, arg);
17063 case LINUX_REBOOT_CMD_RESTART:
17064 @@ -1358,7 +1372,7 @@ asmlinkage long sys_sethostname(char __u
17066 char tmp[__NEW_UTS_LEN];
17068 - if (!capable(CAP_SYS_ADMIN))
17069 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17071 if (len < 0 || len > __NEW_UTS_LEN)
17073 @@ -1403,7 +1417,7 @@ asmlinkage long sys_setdomainname(char _
17075 char tmp[__NEW_UTS_LEN];
17077 - if (!capable(CAP_SYS_ADMIN))
17078 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17080 if (len < 0 || len > __NEW_UTS_LEN)
17082 @@ -1470,7 +1484,7 @@ asmlinkage long sys_setrlimit(unsigned i
17084 old_rlim = current->signal->rlim + resource;
17085 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17086 - !capable(CAP_SYS_RESOURCE))
17087 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17089 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
17091 diff -NurpP --minimal linux-2.6.24-rc7/kernel/sysctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sysctl.c
17092 --- linux-2.6.24-rc7/kernel/sysctl.c 2007-12-31 17:58:28 +0100
17093 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sysctl.c 2007-12-31 12:34:43 +0100
17094 @@ -105,6 +105,7 @@ static int ngroups_max = NGROUPS_MAX;
17096 extern char modprobe_path[];
17098 +extern char vshelper_path[];
17099 #ifdef CONFIG_CHR_DEV_SG
17100 extern int sg_big_buff;
17102 @@ -492,6 +493,15 @@ static struct ctl_table kern_table[] = {
17103 .strategy = &sysctl_string,
17107 + .ctl_name = KERN_VSHELPER,
17108 + .procname = "vshelper",
17109 + .data = &vshelper_path,
17112 + .proc_handler = &proc_dostring,
17113 + .strategy = &sysctl_string,
17115 #ifdef CONFIG_CHR_DEV_SG
17117 .ctl_name = KERN_SG_BIG_BUFF,
17118 diff -NurpP --minimal linux-2.6.24-rc7/kernel/sysctl_check.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sysctl_check.c
17119 --- linux-2.6.24-rc7/kernel/sysctl_check.c 2007-12-31 17:58:28 +0100
17120 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/sysctl_check.c 2007-12-31 12:34:43 +0100
17121 @@ -44,6 +44,7 @@ static struct trans_ctl_table trans_kern
17123 { KERN_PANIC, "panic" },
17124 { KERN_REALROOTDEV, "real-root-dev" },
17125 + { KERN_VSHELPER, "vshelper", },
17127 { KERN_SPARC_REBOOT, "reboot-cmd" },
17128 { KERN_CTLALTDEL, "ctrl-alt-del" },
17129 @@ -1222,6 +1223,22 @@ static struct trans_ctl_table trans_frv_
17133 +static struct trans_ctl_table trans_vserver_table[] = {
17134 + { 1, "debug_switch" },
17135 + { 2, "debug_xid" },
17136 + { 3, "debug_nid" },
17137 + { 4, "debug_tag" },
17138 + { 5, "debug_net" },
17139 + { 6, "debug_limit" },
17140 + { 7, "debug_cres" },
17141 + { 8, "debug_dlim" },
17142 + { 9, "debug_quota" },
17143 + { 10, "debug_cvirt" },
17144 + { 11, "debug_space" },
17145 + { 12, "debug_misc" },
17149 static struct trans_ctl_table trans_root_table[] = {
17150 { CTL_KERN, "kernel", trans_kern_table },
17151 { CTL_VM, "vm", trans_vm_table },
17152 @@ -1238,6 +1255,7 @@ static struct trans_ctl_table trans_root
17153 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
17154 { CTL_PM, "pm", trans_pm_table },
17155 { CTL_FRV, "frv", trans_frv_table },
17156 + { CTL_VSERVER, "vserver", trans_vserver_table },
17160 diff -NurpP --minimal linux-2.6.24-rc7/kernel/time.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/time.c
17161 --- linux-2.6.24-rc7/kernel/time.c 2007-11-29 01:12:31 +0100
17162 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/time.c 2007-12-13 13:25:36 +0100
17163 @@ -58,6 +58,7 @@ EXPORT_SYMBOL(sys_tz);
17164 asmlinkage long sys_time(time_t __user * tloc)
17166 time_t i = get_seconds();
17167 +/* FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17170 if (put_user(i,tloc))
17171 @@ -87,7 +88,7 @@ asmlinkage long sys_stime(time_t __user
17175 - do_settimeofday(&tv);
17176 + vx_settimeofday(&tv);
17180 @@ -97,7 +98,7 @@ asmlinkage long sys_gettimeofday(struct
17182 if (likely(tv != NULL)) {
17183 struct timeval ktv;
17184 - do_gettimeofday(&ktv);
17185 + vx_gettimeofday(&ktv);
17186 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17189 @@ -171,7 +172,7 @@ int do_sys_settimeofday(struct timespec
17190 /* SMP safe, again the code in arch/foo/time.c should
17191 * globally block out interrupts when it runs.
17193 - return do_settimeofday(tv);
17194 + return vx_settimeofday(tv);
17198 @@ -295,7 +296,7 @@ void getnstimeofday(struct timespec *tv)
17202 - do_gettimeofday(&x);
17203 + vx_gettimeofday(&x);
17204 tv->tv_sec = x.tv_sec;
17205 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17207 diff -NurpP --minimal linux-2.6.24-rc7/kernel/timer.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/timer.c
17208 --- linux-2.6.24-rc7/kernel/timer.c 2007-12-31 17:58:28 +0100
17209 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/timer.c 2007-12-31 12:34:43 +0100
17211 #include <linux/delay.h>
17212 #include <linux/tick.h>
17213 #include <linux/kallsyms.h>
17214 +#include <linux/vs_base.h>
17215 +#include <linux/vs_cvirt.h>
17216 +#include <linux/vs_pid.h>
17217 +#include <linux/vserver/sched.h>
17219 #include <asm/uaccess.h>
17220 #include <asm/unistd.h>
17221 @@ -946,12 +950,6 @@ asmlinkage unsigned long sys_alarm(unsig
17228 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17229 - * should be moved into arch/i386 instead?
17233 * sys_getpid - return the thread group id of the current process
17234 @@ -980,10 +978,23 @@ asmlinkage long sys_getppid(void)
17236 pid = task_ppid_nr_ns(current, current->nsproxy->pid_ns);
17238 + return vx_map_pid(pid);
17245 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17248 +asmlinkage long do_getxpid(long *ppid)
17250 + *ppid = sys_getppid();
17251 + return sys_getpid();
17254 +#else /* _alpha_ */
17256 asmlinkage long sys_getuid(void)
17258 /* Only we change this so SMP safe */
17259 @@ -1144,6 +1155,8 @@ int do_sysinfo(struct sysinfo *info)
17260 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
17263 + if (vx_flags(VXF_VIRT_UPTIME, 0))
17264 + vx_vsi_uptime(&tp, NULL);
17265 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
17267 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
17268 diff -NurpP --minimal linux-2.6.24-rc7/kernel/user.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/user.c
17269 --- linux-2.6.24-rc7/kernel/user.c 2007-12-31 17:58:28 +0100
17270 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/user.c 2008-01-04 13:33:13 +0100
17271 @@ -162,7 +162,7 @@ static void user_attr_init(struct subsys
17272 /* Create "/sys/kernel/uids/<uid>" directory and
17273 * "/sys/kernel/uids/<uid>/cpu_share" file for this user.
17275 -static int user_kobject_create(struct user_struct *up)
17276 +static int user_kobject_create(struct user_namespace *ns, struct user_struct *up)
17278 struct kset *kset = &up->kset;
17279 struct kobject *kobj = &kset->kobj;
17280 @@ -170,7 +170,7 @@ static int user_kobject_create(struct us
17282 memset(kset, 0, sizeof(struct kset));
17283 kobj->parent = &uids_kobject; /* create under /sys/kernel/uids dir */
17284 - kobject_set_name(kobj, "%d", up->uid);
17285 + kobject_set_name(kobj, "%p:%d", ns, up->uid);
17287 user_attr_init(&up->user_attr, "cpu_share", 0644);
17289 @@ -205,7 +205,7 @@ int __init uids_kobject_init(void)
17291 error = kobject_add(&uids_kobject);
17293 - error = user_kobject_create(&root_user);
17294 + error = user_kobject_create(&init_user_ns, &root_user);
17298 @@ -267,7 +267,8 @@ static inline void free_user(struct user
17300 #else /* CONFIG_FAIR_USER_SCHED && CONFIG_SYSFS */
17302 -static inline int user_kobject_create(struct user_struct *up) { return 0; }
17303 +static inline int user_kobject_create(struct user_namespace *ns,
17304 + struct user_struct *up) { return 0; }
17305 static inline void uids_mutex_lock(void) { }
17306 static inline void uids_mutex_unlock(void) { }
17308 @@ -370,7 +371,7 @@ struct user_struct * alloc_uid(struct us
17312 - if (user_kobject_create(new)) {
17313 + if (user_kobject_create(ns, new)) {
17314 sched_destroy_user(new);
17315 key_put(new->uid_keyring);
17316 key_put(new->session_keyring);
17317 diff -NurpP --minimal linux-2.6.24-rc7/kernel/user_namespace.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/user_namespace.c
17318 --- linux-2.6.24-rc7/kernel/user_namespace.c 2007-11-29 01:02:27 +0100
17319 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/user_namespace.c 2007-12-15 00:33:23 +0100
17321 #include <linux/version.h>
17322 #include <linux/nsproxy.h>
17323 #include <linux/user_namespace.h>
17324 +#include <linux/vserver/global.h>
17326 struct user_namespace init_user_ns = {
17328 @@ -37,6 +38,7 @@ static struct user_namespace *clone_user
17329 return ERR_PTR(-ENOMEM);
17331 kref_init(&ns->kref);
17332 + atomic_inc(&vs_global_user_ns);
17334 for (n = 0; n < UIDHASH_SZ; ++n)
17335 INIT_HLIST_HEAD(ns->uidhash_table + n);
17336 @@ -82,6 +84,7 @@ void free_user_ns(struct kref *kref)
17338 ns = container_of(kref, struct user_namespace, kref);
17340 + atomic_dec(&vs_global_user_ns);
17344 diff -NurpP --minimal linux-2.6.24-rc7/kernel/utsname.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/utsname.c
17345 --- linux-2.6.24-rc7/kernel/utsname.c 2007-11-29 01:02:27 +0100
17346 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/utsname.c 2007-12-13 13:25:48 +0100
17348 #include <linux/utsname.h>
17349 #include <linux/version.h>
17350 #include <linux/err.h>
17351 +#include <linux/vserver/global.h>
17354 * Clone a new ns copying an original utsname, setting refcount to 1
17355 @@ -32,6 +33,7 @@ static struct uts_namespace *clone_uts_n
17356 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
17358 kref_init(&ns->kref);
17359 + atomic_inc(&vs_global_uts_ns);
17363 @@ -62,5 +64,6 @@ void free_uts_ns(struct kref *kref)
17364 struct uts_namespace *ns;
17366 ns = container_of(kref, struct uts_namespace, kref);
17367 + atomic_dec(&vs_global_uts_ns);
17370 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/Kconfig linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/Kconfig
17371 --- linux-2.6.24-rc7/kernel/vserver/Kconfig 1970-01-01 01:00:00 +0100
17372 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/Kconfig 2007-12-13 14:27:07 +0100
17375 +# Linux VServer configuration
17378 +menu "Linux VServer"
17380 +config VSERVER_LEGACY
17381 + bool "Enable Legacy Kernel API"
17382 + depends on EXPERIMENTAL
17385 + This enables the legacy API used in vs1.xx, maintaining
17386 + compatibility with older vserver tools, and guest images
17387 + that are configured using the legacy method.
17389 +config VSERVER_LEGACY_VERSION
17390 + bool "Show a Legacy Version ID"
17391 + depends on VSERVER_LEGACY
17394 + This shows a special legacy version to very old tools
17395 + which do not handle the current version correctly.
17397 + Warning: recent tools are not able to utilize the
17398 + newer APIs when this is enabled, so some features will
17399 + not be available. Better avoid it, unless you really,
17400 + really need it for backwards compatibility.
17402 +config VSERVER_DYNAMIC_IDS
17403 + bool "Enable dynamic context IDs"
17404 + depends on EXPERIMENTAL && VSERVER_LEGACY
17407 + This enables support of in kernel dynamic context IDs,
17408 + which is deprecated and will probably be removed in the
17411 +config VSERVER_LEGACYNET
17412 + bool "Enable Legacy Networking Kernel API"
17413 + depends on EXPERIMENTAL
17416 + This enables the legacy networking API which is used
17417 + by older tools (pre 0.30.210) to set up the network
17418 + context (chbind).
17420 +config VSERVER_REMAP_SADDR
17421 + bool "Remap Source IP Address"
17422 + depends on EXPERIMENTAL
17425 + This allows to remap the source IP address of 'local'
17426 + connections from 127.0.0.1 to the first assigned
17429 +config VSERVER_COWBL
17430 + bool "Enable COW Immutable Link Breaking"
17433 + This enables the COW (Copy-On-Write) link break code.
17434 + It allows you to treat unified files like normal files
17435 + when writing to them (which will implicitely break the
17436 + link and create a copy of the unified file)
17438 +config VSERVER_VTIME
17439 + bool "Enable Virtualized Guest Time"
17440 + depends on EXPERIMENTAL
17443 + This enables per guest time offsets to allow for
17444 + adjusting the system clock individually per guest.
17445 + this adds some overhead to the time functions and
17446 + therefore should not be enabled without good reason.
17448 +config VSERVER_PROC_SECURE
17449 + bool "Enable Proc Security"
17450 + depends on PROC_FS
17453 + This configures ProcFS security to initially hide
17454 + non-process entries for all contexts except the main and
17455 + spectator context (i.e. for all guests), which is a secure
17458 + (note: on 1.2x the entries were visible by default)
17460 +config VSERVER_HARDCPU
17461 + bool "Enable Hard CPU Limits"
17464 + Activate the Hard CPU Limits
17466 + This will compile in code that allows the Token Bucket
17467 + Scheduler to put processes on hold when a context's
17468 + tokens are depleted (provided that its per-context
17469 + sched_hard flag is set).
17471 + Processes belonging to that context will not be able
17472 + to consume CPU resources again until a per-context
17473 + configured minimum of tokens has been reached.
17475 +config VSERVER_IDLETIME
17476 + bool "Avoid idle CPUs by skipping Time"
17477 + depends on VSERVER_HARDCPU
17480 + This option allows the scheduler to artificially
17481 + advance time (per cpu) when otherwise the idle
17482 + task would be scheduled, thus keeping the cpu
17483 + busy and sharing the available resources among
17484 + certain contexts.
17486 +config VSERVER_IDLELIMIT
17487 + bool "Limit the IDLE task"
17488 + depends on VSERVER_HARDCPU
17491 + Limit the idle slices, so the the next context
17492 + will be scheduled as soon as possible.
17494 + This might improve interactivity and latency, but
17495 + will also marginally increase scheduling overhead.
17498 + prompt "Persistent Inode Tagging"
17499 + default TAGGING_ID24
17501 + This adds persistent context information to filesystems
17502 + mounted with the tagxid option. Tagging is a requirement
17503 + for per-context disk limits and per-context quota.
17506 +config TAGGING_NONE
17509 + do not store per-context information in inodes.
17511 +config TAGGING_UID16
17512 + bool "UID16/GID32"
17514 + reduces UID to 16 bit, but leaves GID at 32 bit.
17516 +config TAGGING_GID16
17517 + bool "UID32/GID16"
17519 + reduces GID to 16 bit, but leaves UID at 32 bit.
17521 +config TAGGING_ID24
17522 + bool "UID24/GID24"
17524 + uses the upper 8bit from UID and GID for XID tagging
17525 + which leaves 24bit for UID/GID each, which should be
17526 + more than sufficient for normal use.
17528 +config TAGGING_INTERN
17529 + bool "UID32/GID32"
17531 + this uses otherwise reserved inode fields in the on
17532 + disk representation, which limits the use to a few
17533 + filesystems (currently ext2 and ext3)
17538 + bool "Tag NFSD User Auth and Files"
17541 + Enable this if you do want the in-kernel NFS
17542 + Server to use the tagging specified above.
17543 + (will require patched clients too)
17546 + bool "Enable Inode Tag Propagation"
17548 + depends on EXPERIMENTAL
17550 + This allows for the tagid= mount option to specify
17551 + a tagid which is to be used for the entire mount
17554 +config VSERVER_PRIVACY
17555 + bool "Honor Privacy Aspects of Guests"
17558 + When enabled, most context checks will disallow
17559 + access to structures assigned to a specific context,
17560 + like ptys or loop devices.
17562 +config VSERVER_CONTEXTS
17563 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
17565 + default "768" if 64BIT
17568 + This setting will optimize certain data structures
17569 + and memory allocations according to the expected
17572 + note: this is not a strict upper limit.
17574 +config VSERVER_WARN
17575 + bool "VServer Warnings"
17578 + This enables various runtime warnings, which will
17579 + notify about potential manipulation attempts or
17580 + resource shortage. It is generally considered to
17581 + be a good idea to have that enabled.
17583 +config VSERVER_DEBUG
17584 + bool "VServer Debugging Code"
17587 + Set this to yes if you want to be able to activate
17588 + debugging output at runtime. It adds a very small
17589 + overhead to all vserver related functions and
17590 + increases the kernel size by about 20k.
17592 +config VSERVER_HISTORY
17593 + bool "VServer History Tracing"
17594 + depends on VSERVER_DEBUG
17597 + Set this to yes if you want to record the history of
17598 + linux-vserver activities, so they can be replayed in
17599 + the event of a kernel panic or oops.
17601 +config VSERVER_HISTORY_SIZE
17602 + int "Per-CPU History Size (32-65536)"
17603 + depends on VSERVER_HISTORY
17607 + This allows you to specify the number of entries in
17608 + the per-CPU history buffer.
17610 +config VSERVER_MONITOR
17611 + bool "VServer Scheduling Monitor"
17612 + depends on VSERVER_DEBUG
17615 + Set this to yes if you want to record the scheduling
17616 + decisions, so that they can be relayed to userspace
17617 + for detailed analysis.
17619 +config VSERVER_MONITOR_SIZE
17620 + int "Per-CPU Monitor Queue Size (32-65536)"
17621 + depends on VSERVER_MONITOR
17625 + This allows you to specify the number of entries in
17626 + the per-CPU scheduling monitor buffer.
17628 +config VSERVER_MONITOR_SYNC
17629 + int "Per-CPU Monitor Sync Interval (0-65536)"
17630 + depends on VSERVER_MONITOR
17634 + This allows you to specify the interval in ticks
17635 + when a time sync entry is inserted.
17646 +config VSERVER_SECURITY
17648 + depends on SECURITY
17650 + select SECURITY_CAPABILITIES
17652 +config VSERVER_NGNET
17654 + depends on EXPERIMENTAL && !VSERVER_LEGACYNET
17657 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/Makefile linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/Makefile
17658 --- linux-2.6.24-rc7/kernel/vserver/Makefile 1970-01-01 01:00:00 +0100
17659 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/Makefile 2007-12-13 13:25:26 +0100
17662 +# Makefile for the Linux vserver routines.
17666 +obj-y += vserver.o
17668 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
17669 + limit.o cvirt.o cacct.o signal.o helper.o init.o dlimit.o
17671 +vserver-$(CONFIG_PROC_FS) += proc.o
17672 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
17673 +vserver-$(CONFIG_VSERVER_LEGACY) += legacy.o
17674 +vserver-$(CONFIG_VSERVER_LEGACYNET) += legacynet.o
17675 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
17676 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
17678 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/cacct.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cacct.c
17679 --- linux-2.6.24-rc7/kernel/vserver/cacct.c 1970-01-01 01:00:00 +0100
17680 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cacct.c 2007-12-13 13:25:37 +0100
17683 + * linux/kernel/vserver/cacct.c
17685 + * Virtual Server: Context Accounting
17687 + * Copyright (C) 2006-2007 Herbert Pötzl
17689 + * V0.01 added accounting stats
17693 +#include <linux/types.h>
17694 +#include <linux/sched.h>
17695 +#include <linux/vs_context.h>
17696 +#include <linux/vserver/switch.h>
17697 +#include <linux/vserver/cacct_cmd.h>
17698 +#include <linux/vserver/cacct_int.h>
17700 +#include <asm/errno.h>
17701 +#include <asm/uaccess.h>
17704 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17706 + struct vcmd_sock_stat_v0 vc_data;
17709 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17712 + field = vc_data.field;
17713 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
17716 + for (j = 0; j < 3; j++) {
17717 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17718 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17721 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17726 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/cacct_init.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cacct_init.h
17727 --- linux-2.6.24-rc7/kernel/vserver/cacct_init.h 1970-01-01 01:00:00 +0100
17728 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cacct_init.h 2007-12-13 13:25:43 +0100
17732 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17737 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17738 + for (j = 0; j < 3; j++) {
17739 + atomic_set(&cacct->sock[i][j].count, 0);
17740 + atomic_set(&cacct->sock[i][j].total, 0);
17743 + for (i = 0; i < 8; i++)
17744 + atomic_set(&cacct->slab[i], 0);
17745 + for (i = 0; i < 5; i++)
17746 + for (j = 0; j < 4; j++)
17747 + atomic_set(&cacct->page[i][j], 0);
17750 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17755 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/cacct_proc.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cacct_proc.h
17756 --- linux-2.6.24-rc7/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00 +0100
17757 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cacct_proc.h 2007-12-13 13:25:43 +0100
17759 +#ifndef _VX_CACCT_PROC_H
17760 +#define _VX_CACCT_PROC_H
17762 +#include <linux/vserver/cacct_int.h>
17765 +#define VX_SOCKA_TOP \
17766 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17768 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17770 + int i, j, length = 0;
17771 + static char *type[VXA_SOCK_SIZE] = {
17772 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17775 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17776 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17777 + length += sprintf(buffer + length, "%s:", type[i]);
17778 + for (j = 0; j < 3; j++) {
17779 + length += sprintf(buffer + length,
17780 + "\t%10lu/%-10lu",
17781 + vx_sock_count(cacct, i, j),
17782 + vx_sock_total(cacct, i, j));
17784 + buffer[length++] = '\n';
17787 + length += sprintf(buffer + length, "\n");
17788 + length += sprintf(buffer + length,
17789 + "slab:\t %8u %8u %8u %8u\n",
17790 + atomic_read(&cacct->slab[1]),
17791 + atomic_read(&cacct->slab[4]),
17792 + atomic_read(&cacct->slab[0]),
17793 + atomic_read(&cacct->slab[2]));
17795 + length += sprintf(buffer + length, "\n");
17796 + for (i = 0; i < 5; i++) {
17797 + length += sprintf(buffer + length,
17798 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17799 + atomic_read(&cacct->page[i][0]),
17800 + atomic_read(&cacct->page[i][1]),
17801 + atomic_read(&cacct->page[i][2]),
17802 + atomic_read(&cacct->page[i][3]),
17803 + atomic_read(&cacct->page[i][4]),
17804 + atomic_read(&cacct->page[i][5]),
17805 + atomic_read(&cacct->page[i][6]),
17806 + atomic_read(&cacct->page[i][7]));
17811 +#endif /* _VX_CACCT_PROC_H */
17812 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/context.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/context.c
17813 --- linux-2.6.24-rc7/kernel/vserver/context.c 1970-01-01 01:00:00 +0100
17814 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/context.c 2007-12-13 15:54:52 +0100
17817 + * linux/kernel/vserver/context.c
17819 + * Virtual Server: Context Support
17821 + * Copyright (C) 2003-2007 Herbert Pötzl
17823 + * V0.01 context helper
17824 + * V0.02 vx_ctx_kill syscall command
17825 + * V0.03 replaced context_info calls
17826 + * V0.04 redesign of struct (de)alloc
17827 + * V0.05 rlimit basic implementation
17828 + * V0.06 task_xid and info commands
17829 + * V0.07 context flags and caps
17830 + * V0.08 switch to RCU based hash
17831 + * V0.09 revert to non RCU for now
17832 + * V0.10 and back to working RCU hash
17833 + * V0.11 and back to locking again
17834 + * V0.12 referenced context store
17835 + * V0.13 separate per cpu data
17836 + * V0.14 changed vcmds to vxi arg
17837 + * V0.15 added context stat
17838 + * V0.16 have __create claim() the vxi
17842 +#include <linux/slab.h>
17843 +#include <linux/types.h>
17844 +#include <linux/security.h>
17845 +#include <linux/mnt_namespace.h>
17846 +#include <linux/pid_namespace.h>
17848 +#include <linux/sched.h>
17849 +#include <linux/vserver/context.h>
17850 +#include <linux/vserver/network.h>
17851 +#include <linux/vserver/legacy.h>
17852 +#include <linux/vserver/debug.h>
17853 +#include <linux/vserver/limit.h>
17854 +#include <linux/vserver/limit_int.h>
17855 +#include <linux/vserver/space.h>
17857 +#include <linux/vs_context.h>
17858 +#include <linux/vs_limit.h>
17859 +#include <linux/vs_pid.h>
17860 +#include <linux/vserver/context_cmd.h>
17862 +#include <linux/err.h>
17863 +#include <asm/errno.h>
17865 +#include "cvirt_init.h"
17866 +#include "cacct_init.h"
17867 +#include "limit_init.h"
17868 +#include "sched_init.h"
17871 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17872 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17875 +/* now inactive context structures */
17877 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17879 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17882 +/* __alloc_vx_info()
17884 + * allocate an initialized vx_info struct
17885 + * doesn't make it visible (hash) */
17887 +static struct vx_info *__alloc_vx_info(xid_t xid)
17889 + struct vx_info *new = NULL;
17892 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17894 + /* would this benefit from a slab cache? */
17895 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17899 + memset(new, 0, sizeof(struct vx_info));
17901 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17902 + if (!new->ptr_pc)
17905 + new->vx_id = xid;
17906 + INIT_HLIST_NODE(&new->vx_hlist);
17907 + atomic_set(&new->vx_usecnt, 0);
17908 + atomic_set(&new->vx_tasks, 0);
17909 + new->vx_parent = NULL;
17910 + new->vx_state = 0;
17911 + init_waitqueue_head(&new->vx_wait);
17913 + /* prepare reaper */
17914 + get_task_struct(init_pid_ns.child_reaper);
17915 + new->vx_reaper = init_pid_ns.child_reaper;
17917 + /* rest of init goes here */
17918 + vx_info_init_limit(&new->limit);
17919 + vx_info_init_sched(&new->sched);
17920 + vx_info_init_cvirt(&new->cvirt);
17921 + vx_info_init_cacct(&new->cacct);
17923 + /* per cpu data structures */
17924 + for_each_possible_cpu(cpu) {
17925 + vx_info_init_sched_pc(
17926 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17927 + vx_info_init_cvirt_pc(
17928 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17931 + new->vx_flags = VXF_INIT_SET;
17932 + new->vx_bcaps = CAP_INIT_EFF_SET;
17933 + new->vx_ccaps = 0;
17934 + new->vx_cap_bset = cap_bset;
17936 + new->reboot_cmd = 0;
17937 + new->exit_code = 0;
17939 + vxdprintk(VXD_CBIT(xid, 0),
17940 + "alloc_vx_info(%d) = %p", xid, new);
17941 + vxh_alloc_vx_info(new);
17942 + atomic_inc(&vx_global_ctotal);
17951 +/* __dealloc_vx_info()
17953 + * final disposal of vx_info */
17955 +static void __dealloc_vx_info(struct vx_info *vxi)
17959 + vxdprintk(VXD_CBIT(xid, 0),
17960 + "dealloc_vx_info(%p)", vxi);
17961 + vxh_dealloc_vx_info(vxi);
17965 + vx_info_exit_limit(&vxi->limit);
17966 + vx_info_exit_sched(&vxi->sched);
17967 + vx_info_exit_cvirt(&vxi->cvirt);
17968 + vx_info_exit_cacct(&vxi->cacct);
17970 + for_each_possible_cpu(cpu) {
17971 + vx_info_exit_sched_pc(
17972 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17973 + vx_info_exit_cvirt_pc(
17974 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17977 + vxi->vx_state |= VXS_RELEASED;
17980 + free_percpu(vxi->ptr_pc);
17983 + atomic_dec(&vx_global_ctotal);
17986 +static void __shutdown_vx_info(struct vx_info *vxi)
17988 + struct nsproxy *nsproxy;
17989 + struct fs_struct *fs;
17993 + vxi->vx_state |= VXS_SHUTDOWN;
17994 + vs_state_change(vxi, VSC_SHUTDOWN);
17996 + nsproxy = xchg(&vxi->vx_nsproxy, NULL);
17997 + fs = xchg(&vxi->vx_fs, NULL);
18000 + put_nsproxy(nsproxy);
18002 + put_fs_struct(fs);
18005 +/* exported stuff */
18007 +void free_vx_info(struct vx_info *vxi)
18009 + unsigned long flags;
18011 + /* check for reference counts first */
18012 + BUG_ON(atomic_read(&vxi->vx_usecnt));
18013 + BUG_ON(atomic_read(&vxi->vx_tasks));
18015 + /* context must not be hashed */
18016 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18018 + /* context shutdown is mandatory */
18019 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
18021 + BUG_ON(vxi->vx_nsproxy);
18022 + BUG_ON(vxi->vx_fs);
18024 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18025 + hlist_del(&vxi->vx_hlist);
18026 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18028 + __dealloc_vx_info(vxi);
18032 +/* hash table for vx_info hash */
18034 +#define VX_HASH_SIZE 13
18036 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
18037 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
18039 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
18042 +static inline unsigned int __hashval(xid_t xid)
18044 + return (xid % VX_HASH_SIZE);
18049 +/* __hash_vx_info()
18051 + * add the vxi to the global hash table
18052 + * requires the hash_lock to be held */
18054 +static inline void __hash_vx_info(struct vx_info *vxi)
18056 + struct hlist_head *head;
18058 + vxd_assert_lock(&vx_info_hash_lock);
18059 + vxdprintk(VXD_CBIT(xid, 4),
18060 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
18061 + vxh_hash_vx_info(vxi);
18063 + /* context must not be hashed */
18064 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18066 + vxi->vx_state |= VXS_HASHED;
18067 + head = &vx_info_hash[__hashval(vxi->vx_id)];
18068 + hlist_add_head(&vxi->vx_hlist, head);
18069 + atomic_inc(&vx_global_cactive);
18072 +/* __unhash_vx_info()
18074 + * remove the vxi from the global hash table
18075 + * requires the hash_lock to be held */
18077 +static inline void __unhash_vx_info(struct vx_info *vxi)
18079 + unsigned long flags;
18081 + vxd_assert_lock(&vx_info_hash_lock);
18082 + vxdprintk(VXD_CBIT(xid, 4),
18083 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
18084 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
18085 + vxh_unhash_vx_info(vxi);
18087 + /* context must be hashed */
18088 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
18089 + /* but without tasks */
18090 + BUG_ON(atomic_read(&vxi->vx_tasks));
18092 + vxi->vx_state &= ~VXS_HASHED;
18093 + hlist_del_init(&vxi->vx_hlist);
18094 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18095 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
18096 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18097 + atomic_dec(&vx_global_cactive);
18101 +/* __lookup_vx_info()
18103 + * requires the hash_lock to be held
18104 + * doesn't increment the vx_refcnt */
18106 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
18108 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
18109 + struct hlist_node *pos;
18110 + struct vx_info *vxi;
18112 + vxd_assert_lock(&vx_info_hash_lock);
18113 + hlist_for_each(pos, head) {
18114 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18116 + if (vxi->vx_id == xid)
18121 + vxdprintk(VXD_CBIT(xid, 0),
18122 + "__lookup_vx_info(#%u): %p[#%u]",
18123 + xid, vxi, vxi ? vxi->vx_id : 0);
18124 + vxh_lookup_vx_info(vxi, xid);
18129 +/* __vx_dynamic_id()
18131 + * find unused dynamic xid
18132 + * requires the hash_lock to be held */
18134 +static inline xid_t __vx_dynamic_id(void)
18136 + static xid_t seq = MAX_S_CONTEXT;
18137 + xid_t barrier = seq;
18139 + vxd_assert_lock(&vx_info_hash_lock);
18141 + if (++seq > MAX_S_CONTEXT)
18142 + seq = MIN_D_CONTEXT;
18143 + if (!__lookup_vx_info(seq)) {
18144 + vxdprintk(VXD_CBIT(xid, 4),
18145 + "__vx_dynamic_id: [#%d]", seq);
18148 + } while (barrier != seq);
18152 +#ifdef CONFIG_VSERVER_LEGACY
18154 +/* __loc_vx_info()
18156 + * locate or create the requested context
18157 + * get() it and if new hash it */
18159 +static struct vx_info *__loc_vx_info(int id, int *err)
18161 + struct vx_info *new, *vxi = NULL;
18163 + vxdprintk(VXD_CBIT(xid, 1), "loc_vx_info(%d)*", id);
18165 + if (!(new = __alloc_vx_info(id))) {
18170 + /* required to make dynamic xids unique */
18171 + spin_lock(&vx_info_hash_lock);
18173 + /* dynamic context requested */
18174 + if (id == VX_DYNAMIC_ID) {
18175 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
18176 + id = __vx_dynamic_id();
18178 + printk(KERN_ERR "no dynamic context available.\n");
18183 + printk(KERN_ERR "dynamic contexts disabled.\n");
18187 + /* existing context requested */
18188 + else if ((vxi = __lookup_vx_info(id))) {
18189 + /* context in setup is not available */
18190 + if (vxi->vx_flags & VXF_STATE_SETUP) {
18191 + vxdprintk(VXD_CBIT(xid, 0),
18192 + "loc_vx_info(%d) = %p (not available)", id, vxi);
18196 + vxdprintk(VXD_CBIT(xid, 0),
18197 + "loc_vx_info(%d) = %p (found)", id, vxi);
18198 + get_vx_info(vxi);
18204 + /* new context requested */
18205 + vxdprintk(VXD_CBIT(xid, 0),
18206 + "loc_vx_info(%d) = %p (new)", id, new);
18207 + __hash_vx_info(get_vx_info(new));
18208 + vxi = new, new = NULL;
18212 + spin_unlock(&vx_info_hash_lock);
18213 + vxh_loc_vx_info(vxi, id);
18215 + __dealloc_vx_info(new);
18221 +/* __create_vx_info()
18223 + * create the requested context
18224 + * get(), claim() and hash it */
18226 +static struct vx_info *__create_vx_info(int id)
18228 + struct vx_info *new, *vxi = NULL;
18230 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
18232 + if (!(new = __alloc_vx_info(id)))
18233 + return ERR_PTR(-ENOMEM);
18235 + /* required to make dynamic xids unique */
18236 + spin_lock(&vx_info_hash_lock);
18238 + /* dynamic context requested */
18239 + if (id == VX_DYNAMIC_ID) {
18240 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
18241 + id = __vx_dynamic_id();
18243 + printk(KERN_ERR "no dynamic context available.\n");
18244 + vxi = ERR_PTR(-EAGAIN);
18249 + printk(KERN_ERR "dynamic contexts disabled.\n");
18250 + vxi = ERR_PTR(-EINVAL);
18254 + /* static context requested */
18255 + else if ((vxi = __lookup_vx_info(id))) {
18256 + vxdprintk(VXD_CBIT(xid, 0),
18257 + "create_vx_info(%d) = %p (already there)", id, vxi);
18258 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18259 + vxi = ERR_PTR(-EBUSY);
18261 + vxi = ERR_PTR(-EEXIST);
18264 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
18265 + /* dynamic xid creation blocker */
18266 + else if (id >= MIN_D_CONTEXT) {
18267 + vxdprintk(VXD_CBIT(xid, 0),
18268 + "create_vx_info(%d) (dynamic rejected)", id);
18269 + vxi = ERR_PTR(-EINVAL);
18274 + /* new context */
18275 + vxdprintk(VXD_CBIT(xid, 0),
18276 + "create_vx_info(%d) = %p (new)", id, new);
18277 + claim_vx_info(new, NULL);
18278 + __hash_vx_info(get_vx_info(new));
18279 + vxi = new, new = NULL;
18282 + spin_unlock(&vx_info_hash_lock);
18283 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18285 + __dealloc_vx_info(new);
18290 +/* exported stuff */
18293 +void unhash_vx_info(struct vx_info *vxi)
18295 + __shutdown_vx_info(vxi);
18296 + spin_lock(&vx_info_hash_lock);
18297 + __unhash_vx_info(vxi);
18298 + spin_unlock(&vx_info_hash_lock);
18299 + __wakeup_vx_info(vxi);
18303 +/* lookup_vx_info()
18305 + * search for a vx_info and get() it
18306 + * negative id means current */
18308 +struct vx_info *lookup_vx_info(int id)
18310 + struct vx_info *vxi = NULL;
18313 + vxi = get_vx_info(current->vx_info);
18314 + } else if (id > 1) {
18315 + spin_lock(&vx_info_hash_lock);
18316 + vxi = get_vx_info(__lookup_vx_info(id));
18317 + spin_unlock(&vx_info_hash_lock);
18322 +/* xid_is_hashed()
18324 + * verify that xid is still hashed */
18326 +int xid_is_hashed(xid_t xid)
18330 + spin_lock(&vx_info_hash_lock);
18331 + hashed = (__lookup_vx_info(xid) != NULL);
18332 + spin_unlock(&vx_info_hash_lock);
18336 +#ifdef CONFIG_VSERVER_LEGACY
18338 +struct vx_info *lookup_or_create_vx_info(int id)
18342 + return __loc_vx_info(id, &err);
18347 +#ifdef CONFIG_PROC_FS
18351 + * get a subset of hashed xids for proc
18352 + * assumes size is at least one */
18354 +int get_xid_list(int index, unsigned int *xids, int size)
18356 + int hindex, nr_xids = 0;
18358 + /* only show current and children */
18359 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18362 + xids[nr_xids] = vx_current_xid();
18366 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18367 + struct hlist_head *head = &vx_info_hash[hindex];
18368 + struct hlist_node *pos;
18370 + spin_lock(&vx_info_hash_lock);
18371 + hlist_for_each(pos, head) {
18372 + struct vx_info *vxi;
18377 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18378 + xids[nr_xids] = vxi->vx_id;
18379 + if (++nr_xids >= size) {
18380 + spin_unlock(&vx_info_hash_lock);
18384 + /* keep the lock time short */
18385 + spin_unlock(&vx_info_hash_lock);
18392 +#ifdef CONFIG_VSERVER_DEBUG
18394 +void dump_vx_info_inactive(int level)
18396 + struct hlist_node *entry, *next;
18398 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
18399 + struct vx_info *vxi =
18400 + list_entry(entry, struct vx_info, vx_hlist);
18402 + dump_vx_info(vxi, level);
18409 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18411 + struct user_struct *new_user, *old_user;
18416 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18419 + new_user = alloc_uid(vxi->vx_id, p->uid);
18423 + old_user = p->user;
18424 + if (new_user != old_user) {
18425 + atomic_inc(&new_user->processes);
18426 + atomic_dec(&old_user->processes);
18427 + p->user = new_user;
18429 + free_uid(old_user);
18434 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18436 + p->cap_effective &= vxi->vx_cap_bset;
18437 + p->cap_inheritable &= vxi->vx_cap_bset;
18438 + p->cap_permitted &= vxi->vx_cap_bset;
18442 +#include <linux/file.h>
18444 +static int vx_openfd_task(struct task_struct *tsk)
18446 + struct files_struct *files = tsk->files;
18447 + struct fdtable *fdt;
18448 + const unsigned long *bptr;
18449 + int count, total;
18451 + /* no rcu_read_lock() because of spin_lock() */
18452 + spin_lock(&files->file_lock);
18453 + fdt = files_fdtable(files);
18454 + bptr = fdt->open_fds->fds_bits;
18455 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
18456 + for (total = 0; count > 0; count--) {
18458 + total += hweight_long(*bptr);
18461 + spin_unlock(&files->file_lock);
18466 +/* for *space compatibility */
18468 +asmlinkage long sys_unshare(unsigned long);
18471 + * migrate task to new context
18472 + * gets vxi, puts old_vxi on change
18473 + * optionally unshares namespaces (hack)
18476 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18478 + struct vx_info *old_vxi;
18484 + vxdprintk(VXD_CBIT(xid, 5),
18485 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18486 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18488 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18489 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18492 + if (vx_info_state(vxi, VXS_SHUTDOWN))
18495 + old_vxi = task_get_vx_info(p);
18496 + if (old_vxi == vxi)
18499 +// if (!(ret = vx_migrate_user(p, vxi))) {
18503 + openfd = vx_openfd_task(p);
18506 + atomic_dec(&old_vxi->cvirt.nr_threads);
18507 + atomic_dec(&old_vxi->cvirt.nr_running);
18508 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18509 + /* FIXME: what about the struct files here? */
18510 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18511 + /* account for the executable */
18512 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18514 + atomic_inc(&vxi->cvirt.nr_threads);
18515 + atomic_inc(&vxi->cvirt.nr_running);
18516 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18517 + /* FIXME: what about the struct files here? */
18518 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18519 + /* account for the executable */
18520 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18523 + release_vx_info(old_vxi, p);
18524 + clr_vx_info(&p->vx_info);
18526 + claim_vx_info(vxi, p);
18527 + set_vx_info(&p->vx_info, vxi);
18528 + p->xid = vxi->vx_id;
18530 + vxdprintk(VXD_CBIT(xid, 5),
18531 + "moved task %p into vxi:%p[#%d]",
18532 + p, vxi, vxi->vx_id);
18534 + vx_mask_cap_bset(vxi, p);
18537 + /* hack for *spaces to provide compatibility */
18539 + struct nsproxy *old_nsp, *new_nsp;
18541 + ret = unshare_nsproxy_namespaces(
18542 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18547 + old_nsp = xchg(&p->nsproxy, new_nsp);
18548 + vx_set_space(vxi, CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER);
18549 + put_nsproxy(old_nsp);
18553 + put_vx_info(old_vxi);
18557 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18559 + struct task_struct *old_reaper;
18564 + vxdprintk(VXD_CBIT(xid, 6),
18565 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18566 + vxi, vxi->vx_id, p, p->xid, p->pid);
18568 + old_reaper = vxi->vx_reaper;
18569 + if (old_reaper == p)
18572 + /* set new child reaper */
18573 + get_task_struct(p);
18574 + vxi->vx_reaper = p;
18575 + put_task_struct(old_reaper);
18579 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18584 + vxdprintk(VXD_CBIT(xid, 6),
18585 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18586 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18588 + vxi->vx_flags &= ~VXF_STATE_INIT;
18589 + vxi->vx_initpid = p->tgid;
18593 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18595 + vxdprintk(VXD_CBIT(xid, 6),
18596 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18597 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18599 + vxi->exit_code = code;
18600 + vxi->vx_initpid = 0;
18604 +void vx_set_persistent(struct vx_info *vxi)
18606 + vxdprintk(VXD_CBIT(xid, 6),
18607 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18609 + get_vx_info(vxi);
18610 + claim_vx_info(vxi, NULL);
18613 +void vx_clear_persistent(struct vx_info *vxi)
18615 + vxdprintk(VXD_CBIT(xid, 6),
18616 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18618 + release_vx_info(vxi, NULL);
18619 + put_vx_info(vxi);
18622 +void vx_update_persistent(struct vx_info *vxi)
18624 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18625 + vx_set_persistent(vxi);
18627 + vx_clear_persistent(vxi);
18631 +/* task must be current or locked */
18633 +void exit_vx_info(struct task_struct *p, int code)
18635 + struct vx_info *vxi = p->vx_info;
18638 + atomic_dec(&vxi->cvirt.nr_threads);
18641 + vxi->exit_code = code;
18642 + release_vx_info(vxi, p);
18646 +void exit_vx_info_early(struct task_struct *p, int code)
18648 + struct vx_info *vxi = p->vx_info;
18651 + if (vxi->vx_initpid == p->tgid)
18652 + vx_exit_init(vxi, p, code);
18653 + if (vxi->vx_reaper == p)
18654 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
18659 +/* vserver syscall commands below here */
18661 +/* taks xid and vx_info functions */
18663 +#include <asm/uaccess.h>
18666 +int vc_task_xid(uint32_t id, void __user *data)
18671 + struct task_struct *tsk;
18673 + if (!vx_check(0, VS_ADMIN | VS_WATCH))
18676 + read_lock(&tasklist_lock);
18677 + tsk = find_task_by_real_pid(id);
18678 + xid = (tsk) ? tsk->xid : -ESRCH;
18679 + read_unlock(&tasklist_lock);
18681 + xid = vx_current_xid();
18686 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18688 + struct vcmd_vx_info_v0 vc_data;
18690 + vc_data.xid = vxi->vx_id;
18691 + vc_data.initpid = vxi->vx_initpid;
18693 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18699 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18701 + struct vcmd_ctx_stat_v0 vc_data;
18703 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18704 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
18706 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18712 +/* context functions */
18714 +int vc_ctx_create(uint32_t xid, void __user *data)
18716 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18717 + struct vx_info *new_vxi;
18720 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18723 + if ((xid > MAX_S_CONTEXT) && (xid != VX_DYNAMIC_ID))
18728 + new_vxi = __create_vx_info(xid);
18729 + if (IS_ERR(new_vxi))
18730 + return PTR_ERR(new_vxi);
18732 + /* initial flags */
18733 + new_vxi->vx_flags = vc_data.flagword;
18736 + if (vs_state_change(new_vxi, VSC_STARTUP))
18739 + ret = vx_migrate_task(current, new_vxi, (!data));
18743 + /* return context id on success */
18744 + ret = new_vxi->vx_id;
18746 + /* get a reference for persistent contexts */
18747 + if ((vc_data.flagword & VXF_PERSISTENT))
18748 + vx_set_persistent(new_vxi);
18750 + release_vx_info(new_vxi, NULL);
18751 + put_vx_info(new_vxi);
18756 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18758 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18761 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18764 + ret = vx_migrate_task(current, vxi, 0);
18767 + if (vc_data.flagword & VXM_SET_INIT)
18768 + ret = vx_set_init(vxi, current);
18771 + if (vc_data.flagword & VXM_SET_REAPER)
18772 + ret = vx_set_reaper(vxi, current);
18777 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18779 + struct vcmd_ctx_flags_v0 vc_data;
18781 + vc_data.flagword = vxi->vx_flags;
18783 + /* special STATE flag handling */
18784 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18786 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18791 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18793 + struct vcmd_ctx_flags_v0 vc_data;
18794 + uint64_t mask, trigger;
18796 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18799 + /* special STATE flag handling */
18800 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18801 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18803 + if (vxi == current->vx_info) {
18804 + if (trigger & VXF_STATE_SETUP)
18805 + vx_mask_cap_bset(vxi, current);
18806 + if (trigger & VXF_STATE_INIT) {
18809 + ret = vx_set_init(vxi, current);
18812 + ret = vx_set_reaper(vxi, current);
18818 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18819 + vc_data.flagword, mask);
18820 + if (trigger & VXF_PERSISTENT)
18821 + vx_update_persistent(vxi);
18826 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18829 + *bcaps = vxi->vx_bcaps;
18831 + *ccaps = vxi->vx_ccaps;
18836 +int vc_get_ccaps_v0(struct vx_info *vxi, void __user *data)
18838 + struct vcmd_ctx_caps_v0 vc_data;
18841 + ret = do_get_caps(vxi, &vc_data.bcaps, &vc_data.ccaps);
18844 + vc_data.cmask = ~0ULL;
18846 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18851 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18853 + struct vcmd_ctx_caps_v1 vc_data;
18856 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18859 + vc_data.cmask = ~0ULL;
18861 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18866 +static int do_set_caps(struct vx_info *vxi,
18867 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18869 + vxi->vx_bcaps = vs_mask_flags(vxi->vx_bcaps, bcaps, bmask);
18870 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18875 +int vc_set_ccaps_v0(struct vx_info *vxi, void __user *data)
18877 + struct vcmd_ctx_caps_v0 vc_data;
18879 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18882 + /* simulate old &= behaviour for bcaps */
18883 + return do_set_caps(vxi, 0, ~vc_data.bcaps,
18884 + vc_data.ccaps, vc_data.cmask);
18887 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18889 + struct vcmd_ctx_caps_v1 vc_data;
18891 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18894 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18897 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18899 + struct vcmd_bcaps vc_data;
18902 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18905 + vc_data.bmask = ~0ULL;
18907 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18912 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18914 + struct vcmd_bcaps vc_data;
18916 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18919 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18922 +#include <linux/module.h>
18924 +EXPORT_SYMBOL_GPL(free_vx_info);
18926 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/cvirt.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cvirt.c
18927 --- linux-2.6.24-rc7/kernel/vserver/cvirt.c 1970-01-01 01:00:00 +0100
18928 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cvirt.c 2007-12-18 01:13:00 +0100
18931 + * linux/kernel/vserver/cvirt.c
18933 + * Virtual Server: Context Virtualization
18935 + * Copyright (C) 2004-2007 Herbert Pötzl
18937 + * V0.01 broken out from limit.c
18938 + * V0.02 added utsname stuff
18939 + * V0.03 changed vcmds to vxi arg
18943 +#include <linux/sched.h>
18944 +#include <linux/sysctl.h>
18945 +#include <linux/types.h>
18946 +#include <linux/utsname.h>
18947 +#include <linux/vs_context.h>
18948 +#include <linux/vs_cvirt.h>
18949 +#include <linux/vserver/switch.h>
18950 +#include <linux/vserver/cvirt_cmd.h>
18952 +#include <asm/errno.h>
18953 +#include <asm/uaccess.h>
18956 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18958 + struct vx_info *vxi = current->vx_info;
18960 + set_normalized_timespec(uptime,
18961 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18962 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18965 + set_normalized_timespec(idle,
18966 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18967 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18971 +uint64_t vx_idle_jiffies(void)
18973 + return init_task.utime + init_task.stime;
18978 +static inline uint32_t __update_loadavg(uint32_t load,
18979 + int wsize, int delta, int n)
18981 + unsigned long long calc, prev;
18983 + /* just set it to n */
18984 + if (unlikely(delta >= wsize))
18985 + return (n << FSHIFT);
18987 + calc = delta * n;
18989 + prev = (wsize - delta);
18992 + do_div(calc, wsize);
18997 +void vx_update_load(struct vx_info *vxi)
18999 + uint32_t now, last, delta;
19000 + unsigned int nr_running, nr_uninterruptible;
19001 + unsigned int total;
19002 + unsigned long flags;
19004 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
19007 + last = vxi->cvirt.load_last;
19008 + delta = now - last;
19010 + if (delta < 5*HZ)
19013 + nr_running = atomic_read(&vxi->cvirt.nr_running);
19014 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
19015 + total = nr_running + nr_uninterruptible;
19017 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
19018 + 60*HZ, delta, total);
19019 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
19020 + 5*60*HZ, delta, total);
19021 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
19022 + 15*60*HZ, delta, total);
19024 + vxi->cvirt.load_last = now;
19026 + atomic_inc(&vxi->cvirt.load_updates);
19027 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
19032 + * Commands to do_syslog:
19034 + * 0 -- Close the log. Currently a NOP.
19035 + * 1 -- Open the log. Currently a NOP.
19036 + * 2 -- Read from the log.
19037 + * 3 -- Read all messages remaining in the ring buffer.
19038 + * 4 -- Read and clear all messages remaining in the ring buffer
19039 + * 5 -- Clear ring buffer.
19040 + * 6 -- Disable printk's to console
19041 + * 7 -- Enable printk's to console
19042 + * 8 -- Set level of messages printed to console
19043 + * 9 -- Return number of unread characters in the log buffer
19044 + * 10 -- Return size of the log buffer
19046 +int vx_do_syslog(int type, char __user *buf, int len)
19049 + int do_clear = 0;
19050 + struct vx_info *vxi = current->vx_info;
19051 + struct _vx_syslog *log;
19055 + log = &vxi->cvirt.syslog;
19058 + case 0: /* Close log */
19059 + case 1: /* Open log */
19061 + case 2: /* Read from log */
19062 + error = wait_event_interruptible(log->log_wait,
19063 + (log->log_start - log->log_end));
19066 + spin_lock_irq(&log->logbuf_lock);
19067 + spin_unlock_irq(&log->logbuf_lock);
19069 + case 4: /* Read/clear last kernel messages */
19071 + /* fall through */
19072 + case 3: /* Read last kernel messages */
19075 + case 5: /* Clear ring buffer */
19078 + case 6: /* Disable logging to console */
19079 + case 7: /* Enable logging to console */
19080 + case 8: /* Set level of messages printed to console */
19083 + case 9: /* Number of chars in the log buffer */
19085 + case 10: /* Size of the log buffer */
19095 +/* virtual host info names */
19097 +static char *vx_vhi_name(struct vx_info *vxi, int id)
19099 + struct nsproxy *nsproxy;
19100 + struct uts_namespace *uts;
19103 + if (id == VHIN_CONTEXT)
19104 + return vxi->vx_name;
19106 + nsproxy = vxi->vx_nsproxy;
19110 + uts = nsproxy->uts_ns;
19115 + case VHIN_SYSNAME:
19116 + return uts->name.sysname;
19117 + case VHIN_NODENAME:
19118 + return uts->name.nodename;
19119 + case VHIN_RELEASE:
19120 + return uts->name.release;
19121 + case VHIN_VERSION:
19122 + return uts->name.version;
19123 + case VHIN_MACHINE:
19124 + return uts->name.machine;
19125 + case VHIN_DOMAINNAME:
19126 + return uts->name.domainname;
19133 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
19135 + struct vcmd_vhi_name_v0 vc_data;
19138 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19141 + name = vx_vhi_name(vxi, vc_data.field);
19145 + memcpy(name, vc_data.name, 65);
19149 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
19151 + struct vcmd_vhi_name_v0 vc_data;
19154 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19157 + name = vx_vhi_name(vxi, vc_data.field);
19161 + memcpy(vc_data.name, name, 65);
19162 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19168 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
19170 + struct vcmd_virt_stat_v0 vc_data;
19171 + struct _vx_cvirt *cvirt = &vxi->cvirt;
19172 + struct timespec uptime;
19174 + do_posix_clock_monotonic_gettime(&uptime);
19175 + set_normalized_timespec(&uptime,
19176 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
19177 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
19179 + vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
19180 + vc_data.uptime = timespec_to_ns(&uptime);
19181 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
19182 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
19183 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
19184 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
19185 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
19186 + vc_data.load[0] = cvirt->load[0];
19187 + vc_data.load[1] = cvirt->load[1];
19188 + vc_data.load[2] = cvirt->load[2];
19190 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19196 +#ifdef CONFIG_VSERVER_VTIME
19198 +/* virtualized time base */
19200 +void vx_gettimeofday(struct timeval *tv)
19202 + do_gettimeofday(tv);
19203 + if (!vx_flags(VXF_VIRT_TIME, 0))
19206 + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
19207 + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
19209 + if (tv->tv_usec >= USEC_PER_SEC) {
19211 + tv->tv_usec -= USEC_PER_SEC;
19212 + } else if (tv->tv_usec < 0) {
19214 + tv->tv_usec += USEC_PER_SEC;
19218 +int vx_settimeofday(struct timespec *ts)
19220 + struct timeval tv;
19222 + if (!vx_flags(VXF_VIRT_TIME, 0))
19223 + return do_settimeofday(ts);
19225 + do_gettimeofday(&tv);
19226 + current->vx_info->cvirt.bias_tv.tv_sec =
19227 + ts->tv_sec - tv.tv_sec;
19228 + current->vx_info->cvirt.bias_tv.tv_usec =
19229 + (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
19235 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/cvirt_init.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cvirt_init.h
19236 --- linux-2.6.24-rc7/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00 +0100
19237 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cvirt_init.h 2007-12-13 13:25:43 +0100
19241 +extern uint64_t vx_idle_jiffies(void);
19243 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19245 + uint64_t idle_jiffies = vx_idle_jiffies();
19246 + uint64_t nsuptime;
19248 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19249 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19250 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19251 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19252 + cvirt->bias_tv.tv_sec = 0;
19253 + cvirt->bias_tv.tv_usec = 0;
19255 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19256 + atomic_set(&cvirt->nr_threads, 0);
19257 + atomic_set(&cvirt->nr_running, 0);
19258 + atomic_set(&cvirt->nr_uninterruptible, 0);
19259 + atomic_set(&cvirt->nr_onhold, 0);
19261 + spin_lock_init(&cvirt->load_lock);
19262 + cvirt->load_last = jiffies;
19263 + atomic_set(&cvirt->load_updates, 0);
19264 + cvirt->load[0] = 0;
19265 + cvirt->load[1] = 0;
19266 + cvirt->load[2] = 0;
19267 + atomic_set(&cvirt->total_forks, 0);
19269 + spin_lock_init(&cvirt->syslog.logbuf_lock);
19270 + init_waitqueue_head(&cvirt->syslog.log_wait);
19271 + cvirt->syslog.log_start = 0;
19272 + cvirt->syslog.log_end = 0;
19273 + cvirt->syslog.con_start = 0;
19274 + cvirt->syslog.logged_chars = 0;
19278 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19280 + // cvirt_pc->cpustat = { 0 };
19283 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19287 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19288 + "!!! cvirt: %p[nr_threads] = %d on exit.",
19290 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19291 + "!!! cvirt: %p[nr_running] = %d on exit.",
19293 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19294 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19296 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19297 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
19303 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19308 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/cvirt_proc.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cvirt_proc.h
19309 --- linux-2.6.24-rc7/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00 +0100
19310 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/cvirt_proc.h 2007-12-13 13:25:43 +0100
19312 +#ifndef _VX_CVIRT_PROC_H
19313 +#define _VX_CVIRT_PROC_H
19315 +#include <linux/nsproxy.h>
19316 +#include <linux/mnt_namespace.h>
19317 +#include <linux/utsname.h>
19318 +#include <linux/ipc.h>
19322 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19324 + struct mnt_namespace *ns;
19325 + struct uts_namespace *uts;
19326 + struct ipc_namespace *ipc;
19327 + struct vfsmount *mnt;
19328 + char *path, *root;
19334 + length += sprintf(buffer + length,
19335 + "NSProxy:\t%p [%p,%p,%p]\n",
19336 + nsproxy, nsproxy->mnt_ns,
19337 + nsproxy->uts_ns, nsproxy->ipc_ns);
19339 + ns = nsproxy->mnt_ns;
19343 + path = kmalloc(PATH_MAX, GFP_KERNEL);
19348 + root = d_path(mnt->mnt_root, mnt->mnt_parent, path, PATH_MAX - 2);
19349 + length += sprintf(buffer + length,
19350 + "Namespace:\t%p [#%u]\n"
19351 + "RootPath:\t%s\n",
19352 + ns, atomic_read(&ns->count),
19357 + uts = nsproxy->uts_ns;
19361 + length += sprintf(buffer + length,
19362 + "SysName:\t%.*s\n"
19363 + "NodeName:\t%.*s\n"
19364 + "Release:\t%.*s\n"
19365 + "Version:\t%.*s\n"
19366 + "Machine:\t%.*s\n"
19367 + "DomainName:\t%.*s\n",
19368 + __NEW_UTS_LEN, uts->name.sysname,
19369 + __NEW_UTS_LEN, uts->name.nodename,
19370 + __NEW_UTS_LEN, uts->name.release,
19371 + __NEW_UTS_LEN, uts->name.version,
19372 + __NEW_UTS_LEN, uts->name.machine,
19373 + __NEW_UTS_LEN, uts->name.domainname);
19376 + ipc = nsproxy->ipc_ns;
19380 + length += sprintf(buffer + length,
19381 + "SEMS:\t\t%d %d %d %d %d\n"
19382 + "MSG:\t\t%d %d %d\n"
19383 + "SHM:\t\t%lu %lu %d %d\n",
19384 + ipc->sem_ctls[0], ipc->sem_ctls[1],
19385 + ipc->sem_ctls[2], ipc->sem_ctls[3],
19387 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19388 + (unsigned long)ipc->shm_ctlmax,
19389 + (unsigned long)ipc->shm_ctlall,
19390 + ipc->shm_ctlmni, ipc->shm_tot);
19397 +#include <linux/sched.h>
19399 +#define LOAD_INT(x) ((x) >> FSHIFT)
19400 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19403 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19408 + length += sprintf(buffer + length,
19409 + "BiasUptime:\t%lu.%02lu\n",
19410 + (unsigned long)cvirt->bias_uptime.tv_sec,
19411 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19413 + a = cvirt->load[0] + (FIXED_1 / 200);
19414 + b = cvirt->load[1] + (FIXED_1 / 200);
19415 + c = cvirt->load[2] + (FIXED_1 / 200);
19416 + length += sprintf(buffer + length,
19417 + "nr_threads:\t%d\n"
19418 + "nr_running:\t%d\n"
19419 + "nr_unintr:\t%d\n"
19420 + "nr_onhold:\t%d\n"
19421 + "load_updates:\t%d\n"
19422 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19423 + "total_forks:\t%d\n",
19424 + atomic_read(&cvirt->nr_threads),
19425 + atomic_read(&cvirt->nr_running),
19426 + atomic_read(&cvirt->nr_uninterruptible),
19427 + atomic_read(&cvirt->nr_onhold),
19428 + atomic_read(&cvirt->load_updates),
19429 + LOAD_INT(a), LOAD_FRAC(a),
19430 + LOAD_INT(b), LOAD_FRAC(b),
19431 + LOAD_INT(c), LOAD_FRAC(c),
19432 + atomic_read(&cvirt->total_forks));
19437 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19438 + char *buffer, int cpu)
19444 +#endif /* _VX_CVIRT_PROC_H */
19445 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/debug.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/debug.c
19446 --- linux-2.6.24-rc7/kernel/vserver/debug.c 1970-01-01 01:00:00 +0100
19447 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/debug.c 2007-12-13 13:25:42 +0100
19450 + * kernel/vserver/debug.c
19452 + * Copyright (C) 2005-2007 Herbert Pötzl
19454 + * V0.01 vx_info dump support
19458 +#include <linux/errno.h>
19459 +#include <linux/kernel.h>
19460 +#include <linux/module.h>
19461 +#include <linux/vs_base.h>
19463 +#include <linux/vserver/context.h>
19466 +void dump_vx_info(struct vx_info *vxi, int level)
19468 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19469 + atomic_read(&vxi->vx_usecnt),
19470 + atomic_read(&vxi->vx_tasks),
19473 + __dump_vx_limit(&vxi->limit);
19474 + __dump_vx_sched(&vxi->sched);
19475 + __dump_vx_cvirt(&vxi->cvirt);
19476 + __dump_vx_cacct(&vxi->cacct);
19482 +EXPORT_SYMBOL_GPL(dump_vx_info);
19484 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/dlimit.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/dlimit.c
19485 --- linux-2.6.24-rc7/kernel/vserver/dlimit.c 1970-01-01 01:00:00 +0100
19486 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/dlimit.c 2007-12-13 13:25:46 +0100
19489 + * linux/kernel/vserver/dlimit.c
19491 + * Virtual Server: Context Disk Limits
19493 + * Copyright (C) 2004-2007 Herbert Pötzl
19495 + * V0.01 initial version
19496 + * V0.02 compat32 splitup
19500 +#include <linux/fs.h>
19501 +#include <linux/namei.h>
19502 +#include <linux/statfs.h>
19503 +#include <linux/compat.h>
19504 +#include <linux/vserver/switch.h>
19505 +#include <linux/vs_context.h>
19506 +#include <linux/vs_tag.h>
19507 +#include <linux/vs_dlimit.h>
19508 +#include <linux/vserver/dlimit_cmd.h>
19510 +#include <asm/errno.h>
19511 +#include <asm/uaccess.h>
19513 +/* __alloc_dl_info()
19515 + * allocate an initialized dl_info struct
19516 + * doesn't make it visible (hash) */
19518 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19520 + struct dl_info *new = NULL;
19522 + vxdprintk(VXD_CBIT(dlim, 5),
19523 + "alloc_dl_info(%p,%d)*", sb, tag);
19525 + /* would this benefit from a slab cache? */
19526 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19530 + memset(new, 0, sizeof(struct dl_info));
19531 + new->dl_tag = tag;
19533 + INIT_RCU_HEAD(&new->dl_rcu);
19534 + INIT_HLIST_NODE(&new->dl_hlist);
19535 + spin_lock_init(&new->dl_lock);
19536 + atomic_set(&new->dl_refcnt, 0);
19537 + atomic_set(&new->dl_usecnt, 0);
19539 + /* rest of init goes here */
19541 + vxdprintk(VXD_CBIT(dlim, 4),
19542 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19546 +/* __dealloc_dl_info()
19548 + * final disposal of dl_info */
19550 +static void __dealloc_dl_info(struct dl_info *dli)
19552 + vxdprintk(VXD_CBIT(dlim, 4),
19553 + "dealloc_dl_info(%p)", dli);
19555 + dli->dl_hlist.next = LIST_POISON1;
19556 + dli->dl_tag = -1;
19559 + BUG_ON(atomic_read(&dli->dl_usecnt));
19560 + BUG_ON(atomic_read(&dli->dl_refcnt));
19566 +/* hash table for dl_info hash */
19568 +#define DL_HASH_SIZE 13
19570 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19572 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19575 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19577 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19582 +/* __hash_dl_info()
19584 + * add the dli to the global hash table
19585 + * requires the hash_lock to be held */
19587 +static inline void __hash_dl_info(struct dl_info *dli)
19589 + struct hlist_head *head;
19591 + vxdprintk(VXD_CBIT(dlim, 6),
19592 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19593 + get_dl_info(dli);
19594 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19595 + hlist_add_head_rcu(&dli->dl_hlist, head);
19598 +/* __unhash_dl_info()
19600 + * remove the dli from the global hash table
19601 + * requires the hash_lock to be held */
19603 +static inline void __unhash_dl_info(struct dl_info *dli)
19605 + vxdprintk(VXD_CBIT(dlim, 6),
19606 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19607 + hlist_del_rcu(&dli->dl_hlist);
19608 + put_dl_info(dli);
19612 +/* __lookup_dl_info()
19614 + * requires the rcu_read_lock()
19615 + * doesn't increment the dl_refcnt */
19617 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19619 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19620 + struct hlist_node *pos;
19621 + struct dl_info *dli;
19623 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19625 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
19633 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19635 + struct dl_info *dli;
19638 + dli = get_dl_info(__lookup_dl_info(sb, tag));
19639 + vxdprintk(VXD_CBIT(dlim, 7),
19640 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19641 + rcu_read_unlock();
19645 +void rcu_free_dl_info(struct rcu_head *head)
19647 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19648 + int usecnt, refcnt;
19650 + BUG_ON(!dli || !head);
19652 + usecnt = atomic_read(&dli->dl_usecnt);
19653 + BUG_ON(usecnt < 0);
19655 + refcnt = atomic_read(&dli->dl_refcnt);
19656 + BUG_ON(refcnt < 0);
19658 + vxdprintk(VXD_CBIT(dlim, 3),
19659 + "rcu_free_dl_info(%p)", dli);
19661 + __dealloc_dl_info(dli);
19663 + printk("!!! rcu didn't free\n");
19669 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19670 + uint32_t flags, int add)
19672 + struct nameidata nd;
19675 + ret = user_path_walk_link(name, &nd);
19677 + struct super_block *sb;
19678 + struct dl_info *dli;
19681 + if (!nd.dentry->d_inode)
19682 + goto out_release;
19683 + if (!(sb = nd.dentry->d_inode->i_sb))
19684 + goto out_release;
19687 + dli = __alloc_dl_info(sb, id);
19688 + spin_lock(&dl_info_hash_lock);
19691 + if (__lookup_dl_info(sb, id))
19693 + __hash_dl_info(dli);
19696 + spin_lock(&dl_info_hash_lock);
19697 + dli = __lookup_dl_info(sb, id);
19702 + __unhash_dl_info(dli);
19706 + spin_unlock(&dl_info_hash_lock);
19708 + __dealloc_dl_info(dli);
19710 + path_release(&nd);
19715 +int vc_add_dlimit(uint32_t id, void __user *data)
19717 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19719 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19722 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19725 +int vc_rem_dlimit(uint32_t id, void __user *data)
19727 + struct vcmd_ctx_dlimit_base_v0 vc_data;
19729 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19732 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19735 +#ifdef CONFIG_COMPAT
19737 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19739 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19741 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19744 + return do_addrem_dlimit(id,
19745 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19748 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19750 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19752 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19755 + return do_addrem_dlimit(id,
19756 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19759 +#endif /* CONFIG_COMPAT */
19763 +int do_set_dlimit(uint32_t id, const char __user *name,
19764 + uint32_t space_used, uint32_t space_total,
19765 + uint32_t inodes_used, uint32_t inodes_total,
19766 + uint32_t reserved, uint32_t flags)
19768 + struct nameidata nd;
19771 + ret = user_path_walk_link(name, &nd);
19773 + struct super_block *sb;
19774 + struct dl_info *dli;
19777 + if (!nd.dentry->d_inode)
19778 + goto out_release;
19779 + if (!(sb = nd.dentry->d_inode->i_sb))
19780 + goto out_release;
19781 + if ((reserved != CDLIM_KEEP &&
19782 + reserved > 100) ||
19783 + (inodes_used != CDLIM_KEEP &&
19784 + inodes_used > inodes_total) ||
19785 + (space_used != CDLIM_KEEP &&
19786 + space_used > space_total))
19787 + goto out_release;
19790 + dli = locate_dl_info(sb, id);
19792 + goto out_release;
19794 + spin_lock(&dli->dl_lock);
19796 + if (inodes_used != CDLIM_KEEP)
19797 + dli->dl_inodes_used = inodes_used;
19798 + if (inodes_total != CDLIM_KEEP)
19799 + dli->dl_inodes_total = inodes_total;
19800 + if (space_used != CDLIM_KEEP) {
19801 + dli->dl_space_used = space_used;
19802 + dli->dl_space_used <<= 10;
19804 + if (space_total == CDLIM_INFINITY)
19805 + dli->dl_space_total = DLIM_INFINITY;
19806 + else if (space_total != CDLIM_KEEP) {
19807 + dli->dl_space_total = space_total;
19808 + dli->dl_space_total <<= 10;
19810 + if (reserved != CDLIM_KEEP)
19811 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
19813 + spin_unlock(&dli->dl_lock);
19815 + put_dl_info(dli);
19819 + path_release(&nd);
19824 +int vc_set_dlimit(uint32_t id, void __user *data)
19826 + struct vcmd_ctx_dlimit_v0 vc_data;
19828 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19831 + return do_set_dlimit(id, vc_data.name,
19832 + vc_data.space_used, vc_data.space_total,
19833 + vc_data.inodes_used, vc_data.inodes_total,
19834 + vc_data.reserved, vc_data.flags);
19837 +#ifdef CONFIG_COMPAT
19839 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
19841 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19843 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19846 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
19847 + vc_data.space_used, vc_data.space_total,
19848 + vc_data.inodes_used, vc_data.inodes_total,
19849 + vc_data.reserved, vc_data.flags);
19852 +#endif /* CONFIG_COMPAT */
19856 +int do_get_dlimit(uint32_t id, const char __user *name,
19857 + uint32_t *space_used, uint32_t *space_total,
19858 + uint32_t *inodes_used, uint32_t *inodes_total,
19859 + uint32_t *reserved, uint32_t *flags)
19861 + struct nameidata nd;
19864 + ret = user_path_walk_link(name, &nd);
19866 + struct super_block *sb;
19867 + struct dl_info *dli;
19870 + if (!nd.dentry->d_inode)
19871 + goto out_release;
19872 + if (!(sb = nd.dentry->d_inode->i_sb))
19873 + goto out_release;
19876 + dli = locate_dl_info(sb, id);
19878 + goto out_release;
19880 + spin_lock(&dli->dl_lock);
19881 + *inodes_used = dli->dl_inodes_used;
19882 + *inodes_total = dli->dl_inodes_total;
19883 + *space_used = dli->dl_space_used >> 10;
19884 + if (dli->dl_space_total == DLIM_INFINITY)
19885 + *space_total = CDLIM_INFINITY;
19887 + *space_total = dli->dl_space_total >> 10;
19889 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
19890 + spin_unlock(&dli->dl_lock);
19892 + put_dl_info(dli);
19897 + path_release(&nd);
19903 +int vc_get_dlimit(uint32_t id, void __user *data)
19905 + struct vcmd_ctx_dlimit_v0 vc_data;
19908 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19911 + ret = do_get_dlimit(id, vc_data.name,
19912 + &vc_data.space_used, &vc_data.space_total,
19913 + &vc_data.inodes_used, &vc_data.inodes_total,
19914 + &vc_data.reserved, &vc_data.flags);
19918 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19923 +#ifdef CONFIG_COMPAT
19925 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
19927 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
19930 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19933 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
19934 + &vc_data.space_used, &vc_data.space_total,
19935 + &vc_data.inodes_used, &vc_data.inodes_total,
19936 + &vc_data.reserved, &vc_data.flags);
19940 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19945 +#endif /* CONFIG_COMPAT */
19948 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
19950 + struct dl_info *dli;
19951 + __u64 blimit, bfree, bavail;
19954 + dli = locate_dl_info(sb, dx_current_tag());
19958 + spin_lock(&dli->dl_lock);
19959 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
19962 + /* reduce max inodes available to limit */
19963 + if (buf->f_files > dli->dl_inodes_total)
19964 + buf->f_files = dli->dl_inodes_total;
19966 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
19967 + /* reduce free inodes to min */
19968 + if (ifree < buf->f_ffree)
19969 + buf->f_ffree = ifree;
19972 + if (dli->dl_space_total == DLIM_INFINITY)
19975 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
19977 + if (dli->dl_space_total < dli->dl_space_used)
19980 + bfree = (dli->dl_space_total - dli->dl_space_used)
19981 + >> sb->s_blocksize_bits;
19983 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
19984 + if (bavail < dli->dl_space_used)
19987 + bavail = (bavail - dli->dl_space_used)
19988 + >> sb->s_blocksize_bits;
19990 + /* reduce max space available to limit */
19991 + if (buf->f_blocks > blimit)
19992 + buf->f_blocks = blimit;
19994 + /* reduce free space to min */
19995 + if (bfree < buf->f_bfree)
19996 + buf->f_bfree = bfree;
19998 + /* reduce avail space to min */
19999 + if (bavail < buf->f_bavail)
20000 + buf->f_bavail = bavail;
20003 + spin_unlock(&dli->dl_lock);
20004 + put_dl_info(dli);
20009 +#include <linux/module.h>
20011 +EXPORT_SYMBOL_GPL(locate_dl_info);
20012 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20014 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/helper.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/helper.c
20015 --- linux-2.6.24-rc7/kernel/vserver/helper.c 1970-01-01 01:00:00 +0100
20016 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/helper.c 2007-12-13 13:25:41 +0100
20019 + * linux/kernel/vserver/helper.c
20021 + * Virtual Context Support
20023 + * Copyright (C) 2004-2007 Herbert Pötzl
20025 + * V0.01 basic helper
20029 +#include <linux/errno.h>
20030 +#include <linux/kmod.h>
20031 +#include <linux/sched.h>
20032 +#include <linux/reboot.h>
20033 +#include <linux/vs_context.h>
20034 +#include <linux/vs_network.h>
20035 +#include <linux/vserver/signal.h>
20037 +#include <asm/uaccess.h>
20038 +#include <asm/unistd.h>
20041 +char vshelper_path[255] = "/sbin/vshelper";
20044 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20048 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20049 + printk( KERN_WARNING
20050 + "%s: (%s %s) returned %s with %d\n",
20051 + name, argv[1], argv[2],
20052 + sync ? "sync" : "async", ret);
20054 + vxdprintk(VXD_CBIT(switch, 4),
20055 + "%s: (%s %s) returned %s with %d",
20056 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
20061 + * vshelper path is set via /proc/sys
20062 + * invoked by vserver sys_reboot(), with
20063 + * the following arguments
20065 + * argv [0] = vshelper_path;
20066 + * argv [1] = action: "restart", "halt", "poweroff", ...
20067 + * argv [2] = context identifier
20069 + * envp [*] = type-specific parameters
20072 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20074 + char id_buf[8], cmd_buf[16];
20075 + char uid_buf[16], pid_buf[16];
20078 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20079 + char *envp[] = {"HOME=/", "TERM=linux",
20080 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20081 + uid_buf, pid_buf, cmd_buf, 0};
20083 + if (vx_info_state(vxi, VXS_HELPER))
20085 + vxi->vx_state |= VXS_HELPER;
20087 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20089 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20090 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
20091 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20094 + case LINUX_REBOOT_CMD_RESTART:
20095 + argv[1] = "restart";
20098 + case LINUX_REBOOT_CMD_HALT:
20099 + argv[1] = "halt";
20102 + case LINUX_REBOOT_CMD_POWER_OFF:
20103 + argv[1] = "poweroff";
20106 + case LINUX_REBOOT_CMD_SW_SUSPEND:
20107 + argv[1] = "swsusp";
20111 + vxi->vx_state &= ~VXS_HELPER;
20115 +#ifndef CONFIG_VSERVER_LEGACY
20116 + ret = do_vshelper(vshelper_path, argv, envp, 1);
20118 + ret = do_vshelper(vshelper_path, argv, envp, 0);
20120 + vxi->vx_state &= ~VXS_HELPER;
20121 + __wakeup_vx_info(vxi);
20122 + return (ret) ? -EPERM : 0;
20126 +long vs_reboot(unsigned int cmd, void __user *arg)
20128 + struct vx_info *vxi = current->vx_info;
20131 + vxdprintk(VXD_CBIT(misc, 5),
20132 + "vs_reboot(%p[#%d],%d)",
20133 + vxi, vxi ? vxi->vx_id : 0, cmd);
20135 + ret = vs_reboot_helper(vxi, cmd, arg);
20139 + vxi->reboot_cmd = cmd;
20140 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20142 + case LINUX_REBOOT_CMD_RESTART:
20143 + case LINUX_REBOOT_CMD_HALT:
20144 + case LINUX_REBOOT_CMD_POWER_OFF:
20145 + vx_info_kill(vxi, 0, SIGKILL);
20146 + vx_info_kill(vxi, 1, SIGKILL);
20156 + * argv [0] = vshelper_path;
20157 + * argv [1] = action: "startup", "shutdown"
20158 + * argv [2] = context identifier
20160 + * envp [*] = type-specific parameters
20163 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20165 + char id_buf[8], cmd_buf[16];
20166 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20167 + char *envp[] = {"HOME=/", "TERM=linux",
20168 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20170 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20173 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20174 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20177 + case VSC_STARTUP:
20178 + argv[1] = "startup";
20180 + case VSC_SHUTDOWN:
20181 + argv[1] = "shutdown";
20187 + return do_vshelper(vshelper_path, argv, envp, 1);
20192 + * argv [0] = vshelper_path;
20193 + * argv [1] = action: "netup", "netdown"
20194 + * argv [2] = context identifier
20196 + * envp [*] = type-specific parameters
20199 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20201 + char id_buf[8], cmd_buf[16];
20202 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20203 + char *envp[] = {"HOME=/", "TERM=linux",
20204 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20206 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20209 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20210 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20214 + argv[1] = "netup";
20216 + case VSC_NETDOWN:
20217 + argv[1] = "netdown";
20223 + return do_vshelper(vshelper_path, argv, envp, 1);
20226 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/history.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/history.c
20227 --- linux-2.6.24-rc7/kernel/vserver/history.c 1970-01-01 01:00:00 +0100
20228 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/history.c 2007-12-13 13:25:42 +0100
20231 + * kernel/vserver/history.c
20233 + * Virtual Context History Backtrace
20235 + * Copyright (C) 2004-2007 Herbert Pötzl
20237 + * V0.01 basic structure
20238 + * V0.02 hash/unhash and trace
20239 + * V0.03 preemption fixes
20243 +#include <linux/errno.h>
20244 +#include <linux/module.h>
20245 +#include <linux/types.h>
20246 +#include <linux/ctype.h>
20248 +#include <asm/uaccess.h>
20249 +#include <asm/atomic.h>
20250 +#include <asm/unistd.h>
20252 +#include <linux/vserver/context.h>
20253 +#include <linux/vserver/debug.h>
20254 +#include <linux/vserver/debug_cmd.h>
20255 +#include <linux/vserver/history.h>
20258 +#ifdef CONFIG_VSERVER_HISTORY
20259 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20261 +#define VXH_SIZE 64
20264 +struct _vx_history {
20265 + unsigned int counter;
20267 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20271 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20273 +unsigned volatile int vxh_active = 1;
20275 +static atomic_t sequence = ATOMIC_INIT(0);
20280 + * requires disabled preemption */
20282 +struct _vx_hist_entry *vxh_advance(void *loc)
20284 + unsigned int cpu = smp_processor_id();
20285 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20286 + struct _vx_hist_entry *entry;
20287 + unsigned int index;
20289 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20290 + entry = &hist->entry[index];
20292 + entry->seq = atomic_inc_return(&sequence);
20293 + entry->loc = loc;
20297 +EXPORT_SYMBOL_GPL(vxh_advance);
20300 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20302 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
20305 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
20307 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
20308 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
20309 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
20310 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
20312 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20314 + switch (e->type) {
20315 + case VXH_THROW_OOPS:
20316 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20319 + case VXH_GET_VX_INFO:
20320 + case VXH_PUT_VX_INFO:
20321 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20323 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20324 + VXH_VXI_ARGS(e));
20327 + case VXH_INIT_VX_INFO:
20328 + case VXH_SET_VX_INFO:
20329 + case VXH_CLR_VX_INFO:
20330 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20332 + (e->type == VXH_INIT_VX_INFO) ? "init" :
20333 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20334 + VXH_VXI_ARGS(e), e->sc.data);
20337 + case VXH_CLAIM_VX_INFO:
20338 + case VXH_RELEASE_VX_INFO:
20339 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20341 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20342 + VXH_VXI_ARGS(e), e->sc.data);
20345 + case VXH_ALLOC_VX_INFO:
20346 + case VXH_DEALLOC_VX_INFO:
20347 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20349 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20350 + VXH_VXI_ARGS(e));
20353 + case VXH_HASH_VX_INFO:
20354 + case VXH_UNHASH_VX_INFO:
20355 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20357 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20358 + VXH_VXI_ARGS(e));
20361 + case VXH_LOC_VX_INFO:
20362 + case VXH_LOOKUP_VX_INFO:
20363 + case VXH_CREATE_VX_INFO:
20364 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20366 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
20367 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20368 + e->ll.arg, VXH_VXI_ARGS(e));
20373 +static void __vxh_dump_history(void)
20375 + unsigned int i, cpu;
20377 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20378 + atomic_read(&sequence), NR_CPUS);
20380 + for (i = 0; i < VXH_SIZE; i++) {
20381 + for_each_online_cpu(cpu) {
20382 + struct _vx_history *hist =
20383 + &per_cpu(vx_history_buffer, cpu);
20384 + unsigned int index = (hist->counter - i) % VXH_SIZE;
20385 + struct _vx_hist_entry *entry = &hist->entry[index];
20387 + vxh_dump_entry(entry, cpu);
20392 +void vxh_dump_history(void)
20396 + local_irq_enable();
20398 + local_irq_disable();
20400 + __vxh_dump_history();
20404 +/* vserver syscall commands below here */
20407 +int vc_dump_history(uint32_t id)
20410 + __vxh_dump_history();
20417 +int do_read_history(struct __user _vx_hist_entry *data,
20418 + int cpu, uint32_t *index, uint32_t *count)
20420 + int pos, ret = 0;
20421 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20422 + int end = hist->counter;
20423 + int start = end - VXH_SIZE + 2;
20424 + int idx = *index;
20426 + /* special case: get current pos */
20432 + /* have we lost some data? */
20436 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20437 + struct _vx_hist_entry *entry =
20438 + &hist->entry[idx % VXH_SIZE];
20440 + /* send entry to userspace */
20441 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20445 + /* save new index and count */
20448 + return ret ? ret : (*index < end);
20451 +int vc_read_history(uint32_t id, void __user *data)
20453 + struct vcmd_read_history_v0 vc_data;
20456 + if (id >= NR_CPUS)
20459 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20462 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20463 + id, &vc_data.index, &vc_data.count);
20465 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20470 +#ifdef CONFIG_COMPAT
20472 +int vc_read_history_x32(uint32_t id, void __user *data)
20474 + struct vcmd_read_history_v0_x32 vc_data;
20477 + if (id >= NR_CPUS)
20480 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20483 + ret = do_read_history((struct __user _vx_hist_entry *)
20484 + compat_ptr(vc_data.data_ptr),
20485 + id, &vc_data.index, &vc_data.count);
20487 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20492 +#endif /* CONFIG_COMPAT */
20494 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/init.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/init.c
20495 --- linux-2.6.24-rc7/kernel/vserver/init.c 1970-01-01 01:00:00 +0100
20496 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/init.c 2007-12-13 13:25:26 +0100
20499 + * linux/kernel/init.c
20501 + * Virtual Server Init
20503 + * Copyright (C) 2004-2007 Herbert Pötzl
20505 + * V0.01 basic structure
20509 +#include <linux/errno.h>
20510 +#include <linux/init.h>
20511 +#include <linux/module.h>
20513 +int vserver_register_sysctl(void);
20514 +void vserver_unregister_sysctl(void);
20517 +static int __init init_vserver(void)
20521 +#ifdef CONFIG_VSERVER_DEBUG
20522 + vserver_register_sysctl();
20528 +static void __exit exit_vserver(void)
20531 +#ifdef CONFIG_VSERVER_DEBUG
20532 + vserver_unregister_sysctl();
20537 +/* FIXME: GFP_ZONETYPES gone
20538 +long vx_slab[GFP_ZONETYPES]; */
20542 +module_init(init_vserver);
20543 +module_exit(exit_vserver);
20545 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/inode.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/inode.c
20546 --- linux-2.6.24-rc7/kernel/vserver/inode.c 1970-01-01 01:00:00 +0100
20547 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/inode.c 2007-12-13 13:25:38 +0100
20550 + * linux/kernel/vserver/inode.c
20552 + * Virtual Server: File System Support
20554 + * Copyright (C) 2004-2007 Herbert Pötzl
20556 + * V0.01 separated from vcontext V0.05
20560 +#include <linux/sched.h>
20561 +#include <linux/proc_fs.h>
20562 +#include <linux/devpts_fs.h>
20563 +#include <linux/namei.h>
20564 +#include <linux/mount.h>
20565 +#include <linux/parser.h>
20566 +#include <linux/file.h>
20567 +#include <linux/compat.h>
20568 +#include <linux/vserver/inode.h>
20569 +#include <linux/vserver/inode_cmd.h>
20570 +#include <linux/vs_base.h>
20571 +#include <linux/vs_tag.h>
20573 +#include <asm/errno.h>
20574 +#include <asm/uaccess.h>
20577 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20579 + struct proc_dir_entry *entry;
20581 + if (!in || !in->i_sb)
20584 + *flags = IATTR_TAG
20585 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
20586 + | (IS_IUNLINK(in) ? IATTR_IUNLINK : 0)
20587 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
20588 + *mask = IATTR_IUNLINK | IATTR_IMMUTABLE;
20590 + if (S_ISDIR(in->i_mode))
20591 + *mask |= IATTR_BARRIER;
20593 + if (IS_TAGGED(in)) {
20594 + *tag = in->i_tag;
20595 + *mask |= IATTR_TAG;
20598 + switch (in->i_sb->s_magic) {
20599 + case PROC_SUPER_MAGIC:
20600 + entry = PROC_I(in)->pde;
20602 + /* check for specific inodes? */
20604 + *mask |= IATTR_FLAGS;
20606 + *flags |= (entry->vx_flags & IATTR_FLAGS);
20608 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
20611 + case DEVPTS_SUPER_MAGIC:
20612 + *tag = in->i_tag;
20613 + *mask |= IATTR_TAG;
20622 +int vc_get_iattr(void __user *data)
20624 + struct nameidata nd;
20625 + struct vcmd_ctx_iattr_v1 vc_data = { .xid = -1 };
20628 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20631 + ret = user_path_walk_link(vc_data.name, &nd);
20633 + ret = __vc_get_iattr(nd.dentry->d_inode,
20634 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
20635 + path_release(&nd);
20640 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20645 +#ifdef CONFIG_COMPAT
20647 +int vc_get_iattr_x32(void __user *data)
20649 + struct nameidata nd;
20650 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .xid = -1 };
20653 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20656 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
20658 + ret = __vc_get_iattr(nd.dentry->d_inode,
20659 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
20660 + path_release(&nd);
20665 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20670 +#endif /* CONFIG_COMPAT */
20673 +int vc_fget_iattr(uint32_t fd, void __user *data)
20675 + struct file *filp;
20676 + struct vcmd_ctx_fiattr_v0 vc_data = { .xid = -1 };
20679 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20683 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20686 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
20687 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
20691 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20697 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
20699 + struct inode *in = de->d_inode;
20700 + int error = 0, is_proc = 0, has_tag = 0;
20701 + struct iattr attr = { 0 };
20703 + if (!in || !in->i_sb)
20706 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
20707 + if ((*mask & IATTR_FLAGS) && !is_proc)
20710 + has_tag = IS_TAGGED(in) ||
20711 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
20712 + if ((*mask & IATTR_TAG) && !has_tag)
20715 + mutex_lock(&in->i_mutex);
20716 + if (*mask & IATTR_TAG) {
20717 + attr.ia_tag = *tag;
20718 + attr.ia_valid |= ATTR_TAG;
20721 + if (*mask & IATTR_FLAGS) {
20722 + struct proc_dir_entry *entry = PROC_I(in)->pde;
20723 + unsigned int iflags = PROC_I(in)->vx_flags;
20725 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
20726 + | (*flags & IATTR_FLAGS);
20727 + PROC_I(in)->vx_flags = iflags;
20729 + entry->vx_flags = iflags;
20732 + if (*mask & (IATTR_BARRIER | IATTR_IUNLINK | IATTR_IMMUTABLE)) {
20733 + if (*mask & IATTR_IMMUTABLE) {
20734 + if (*flags & IATTR_IMMUTABLE)
20735 + in->i_flags |= S_IMMUTABLE;
20737 + in->i_flags &= ~S_IMMUTABLE;
20739 + if (*mask & IATTR_IUNLINK) {
20740 + if (*flags & IATTR_IUNLINK)
20741 + in->i_flags |= S_IUNLINK;
20743 + in->i_flags &= ~S_IUNLINK;
20745 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
20746 + if (*flags & IATTR_BARRIER)
20747 + in->i_flags |= S_BARRIER;
20749 + in->i_flags &= ~S_BARRIER;
20751 + if (in->i_op && in->i_op->sync_flags) {
20752 + error = in->i_op->sync_flags(in);
20758 + if (attr.ia_valid) {
20759 + if (in->i_op && in->i_op->setattr)
20760 + error = in->i_op->setattr(de, &attr);
20762 + error = inode_change_ok(in, &attr);
20764 + error = inode_setattr(in, &attr);
20769 + mutex_unlock(&in->i_mutex);
20773 +int vc_set_iattr(void __user *data)
20775 + struct nameidata nd;
20776 + struct vcmd_ctx_iattr_v1 vc_data;
20779 + if (!capable(CAP_LINUX_IMMUTABLE))
20781 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20784 + ret = user_path_walk_link(vc_data.name, &nd);
20786 + ret = __vc_set_iattr(nd.dentry,
20787 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
20788 + path_release(&nd);
20791 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20796 +#ifdef CONFIG_COMPAT
20798 +int vc_set_iattr_x32(void __user *data)
20800 + struct nameidata nd;
20801 + struct vcmd_ctx_iattr_v1_x32 vc_data;
20804 + if (!capable(CAP_LINUX_IMMUTABLE))
20806 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20809 + ret = user_path_walk_link(compat_ptr(vc_data.name_ptr), &nd);
20811 + ret = __vc_set_iattr(nd.dentry,
20812 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
20813 + path_release(&nd);
20816 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20821 +#endif /* CONFIG_COMPAT */
20823 +int vc_fset_iattr(uint32_t fd, void __user *data)
20825 + struct file *filp;
20826 + struct vcmd_ctx_fiattr_v0 vc_data;
20829 + if (!capable(CAP_LINUX_IMMUTABLE))
20831 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20835 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
20838 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.xid,
20839 + &vc_data.flags, &vc_data.mask);
20843 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20848 +#ifdef CONFIG_VSERVER_LEGACY
20850 +#define PROC_DYNAMIC_FIRST 0xF0000000UL
20852 +int vx_proc_ioctl(struct inode *inode, struct file *filp,
20853 + unsigned int cmd, unsigned long arg)
20855 + struct proc_dir_entry *entry;
20859 + if (inode->i_ino < PROC_DYNAMIC_FIRST)
20862 + entry = PROC_I(inode)->pde;
20867 + case FIOC_GETXFLG: {
20868 + /* fixme: if stealth, return -ENOTTY */
20870 + flags = entry->vx_flags;
20871 + if (capable(CAP_CONTEXT))
20872 + error = put_user(flags, (int __user *) arg);
20875 + case FIOC_SETXFLG: {
20876 + /* fixme: if stealth, return -ENOTTY */
20878 + if (!capable(CAP_CONTEXT))
20881 + if (IS_RDONLY(inode))
20884 + if (get_user(flags, (int __user *) arg))
20887 + entry->vx_flags = flags;
20895 +#endif /* CONFIG_VSERVER_LEGACY */
20897 +#ifdef CONFIG_PROPAGATE
20899 +int dx_parse_tag(char *string, tag_t *tag, int remove)
20901 + static match_table_t tokens = {
20905 + substring_t args[MAX_OPT_ARGS];
20906 + int token, option = 0;
20911 + token = match_token(string, tokens, args);
20912 + if (token && tag && !match_int(args, &option))
20915 + vxdprintk(VXD_CBIT(tag, 7),
20916 + "dx_parse_tag(»%s«): %d:#%d",
20917 + string, token, option);
20919 + if ((token == 1) && remove) {
20920 + char *p = strstr(string, "tagid=");
20924 + while (*q != '\0' && *q != ',')
20935 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
20937 + tag_t new_tag = 0;
20938 + struct vfsmount *mnt;
20947 + propagate = (mnt->mnt_flags & MNT_TAGID);
20949 + new_tag = mnt->mnt_tag;
20951 + vxdprintk(VXD_CBIT(tag, 7),
20952 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
20953 + inode, inode->i_ino, inode->i_tag,
20954 + new_tag, (propagate) ? 1 : 0);
20957 + inode->i_tag = new_tag;
20960 +#include <linux/module.h>
20962 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
20964 +#endif /* CONFIG_PROPAGATE */
20966 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/legacy.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/legacy.c
20967 --- linux-2.6.24-rc7/kernel/vserver/legacy.c 1970-01-01 01:00:00 +0100
20968 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/legacy.c 2007-12-13 13:25:52 +0100
20971 + * linux/kernel/vserver/legacy.c
20973 + * Virtual Server: Legacy Funtions
20975 + * Copyright (C) 2001-2003 Jacques Gelinas
20976 + * Copyright (C) 2003-2007 Herbert Pötzl
20978 + * V0.01 broken out from vcontext.c V0.05
20979 + * V0.02 updated to spaces *sigh*
20983 +#include <linux/sched.h>
20984 +#include <linux/vs_context.h>
20985 +#include <linux/vs_network.h>
20986 +#include <linux/vserver/legacy.h>
20987 +#include <linux/vserver/space.h>
20988 +// #include <linux/mnt_namespace.h>
20990 +#include <asm/errno.h>
20991 +#include <asm/uaccess.h>
20994 +extern int vx_set_init(struct vx_info *, struct task_struct *);
20996 +static int vx_set_initpid(struct vx_info *vxi, int pid)
20998 + struct task_struct *init;
21000 + init = find_task_by_real_pid(pid);
21003 + return vx_set_init(vxi, init);
21006 +int vc_new_s_context(uint32_t ctx, void __user *data)
21008 + int ret = -ENOMEM;
21009 + struct vcmd_new_s_context_v1 vc_data;
21010 + struct vx_info *new_vxi;
21012 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21015 + /* legacy hack, will be removed soon */
21017 + /* assign flags and initpid */
21018 + if (!current->vx_info)
21021 + if (vc_data.flags & VX_INFO_INIT)
21022 + ret = vx_set_initpid(current->vx_info, current->tgid);
21024 + /* We keep the same vx_id, but lower the capabilities */
21025 + current->vx_info->vx_bcaps &= (~vc_data.remove_cap);
21026 + ret = vx_current_xid();
21027 + current->vx_info->vx_flags |= vc_data.flags;
21032 + if (!vx_check(0, VS_ADMIN) || !capable(CAP_SYS_ADMIN)
21033 + /* might make sense in the future, or not ... */
21034 + || vx_flags(VX_INFO_PRIVATE, 0))
21037 + /* ugly hack for Spectator */
21039 + current->xid = 1;
21043 + if (((ctx > MAX_S_CONTEXT) && (ctx != VX_DYNAMIC_ID)) ||
21047 + if ((ctx == VX_DYNAMIC_ID) || (ctx < MIN_D_CONTEXT))
21048 + new_vxi = lookup_or_create_vx_info(ctx);
21050 + new_vxi = lookup_vx_info(ctx);
21056 + if (!vx_info_flags(new_vxi, VXF_STATE_SETUP, 0) &&
21057 + vx_info_flags(new_vxi, VX_INFO_PRIVATE, 0))
21060 + ret = vx_migrate_task(current, new_vxi,
21061 + vx_info_flags(new_vxi, VXF_STATE_SETUP, 0));
21062 + new_vxi->vx_flags &= ~VXF_STATE_SETUP;
21065 + current->vx_info->vx_bcaps &= (~vc_data.remove_cap);
21066 + new_vxi->vx_flags |= vc_data.flags;
21067 + if (vc_data.flags & VX_INFO_INIT)
21068 + vx_set_initpid(new_vxi, current->tgid);
21069 + if (vc_data.flags & VX_INFO_NAMESPACE)
21070 + vx_set_space(new_vxi, CLONE_NEWNS | CLONE_FS);
21071 + if (vc_data.flags & VX_INFO_NPROC)
21072 + __rlim_set(&new_vxi->limit, RLIMIT_NPROC,
21073 + current->signal->rlim[RLIMIT_NPROC].rlim_max);
21075 + /* tweak some defaults for legacy */
21076 + new_vxi->vx_flags |= (VXF_HIDE_NETIF | VXF_INFO_INIT);
21077 + ret = new_vxi->vx_id;
21080 + put_vx_info(new_vxi);
21084 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/legacynet.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/legacynet.c
21085 --- linux-2.6.24-rc7/kernel/vserver/legacynet.c 1970-01-01 01:00:00 +0100
21086 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/legacynet.c 2007-12-13 13:25:52 +0100
21090 + * linux/kernel/vserver/legacynet.c
21092 + * Virtual Server: Legacy Network Funtions
21094 + * Copyright (C) 2001-2003 Jacques Gelinas
21095 + * Copyright (C) 2003-2007 Herbert Pötzl
21097 + * V0.01 broken out from legacy.c
21101 +#include <linux/sched.h>
21102 +#include <linux/vs_context.h>
21103 +#include <linux/vs_network.h>
21104 +#include <linux/vserver/legacy.h>
21105 +// #include <linux/mnt_namespace.h>
21106 +#include <linux/err.h>
21108 +#include <asm/errno.h>
21109 +#include <asm/uaccess.h>
21112 +extern struct nx_info *create_nx_info(void);
21114 +/* set ipv4 root (syscall) */
21116 +int vc_set_ipv4root(uint32_t nbip, void __user *data)
21118 + int i, err = -EPERM;
21119 + struct vcmd_set_ipv4root_v3 vc_data;
21120 + struct nx_info *new_nxi, *nxi = current->nx_info;
21122 + if (nbip < 0 || nbip > NB_IPV4ROOT)
21124 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21127 + if (!nxi || nxi->ipv4[0] == 0 || capable(CAP_NET_ADMIN))
21128 + /* We are allowed to change everything */
21133 + /* We are allowed to select a subset of the currently
21134 + installed IP numbers. No new one are allowed
21135 + We can't change the broadcast address though */
21136 + for (i = 0; i < nbip; i++) {
21138 + __u32 nxip = vc_data.nx_mask_pair[i].ip;
21139 + for (j = 0; j < nxi->nbipv4; j++) {
21140 + if (nxip == nxi->ipv4[j]) {
21146 + if ((found == nbip) &&
21147 + (vc_data.broadcast == nxi->v4_bcast))
21153 + new_nxi = create_nx_info();
21154 + if (IS_ERR(new_nxi))
21157 + new_nxi->nbipv4 = nbip;
21158 + for (i = 0; i < nbip; i++) {
21159 + new_nxi->ipv4[i] = vc_data.nx_mask_pair[i].ip;
21160 + new_nxi->mask[i] = vc_data.nx_mask_pair[i].mask;
21162 + new_nxi->v4_bcast = vc_data.broadcast;
21164 + printk("!!! switching nx_info %p->%p\n", nxi, new_nxi);
21166 + nx_migrate_task(current, new_nxi);
21167 + release_nx_info(new_nxi, NULL);
21168 + put_nx_info(new_nxi);
21173 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/limit.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/limit.c
21174 --- linux-2.6.24-rc7/kernel/vserver/limit.c 1970-01-01 01:00:00 +0100
21175 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/limit.c 2007-12-13 13:25:42 +0100
21178 + * linux/kernel/vserver/limit.c
21180 + * Virtual Server: Context Limits
21182 + * Copyright (C) 2004-2007 Herbert Pötzl
21184 + * V0.01 broken out from vcontext V0.05
21185 + * V0.02 changed vcmds to vxi arg
21189 +#include <linux/module.h>
21190 +#include <linux/vs_context.h>
21191 +#include <linux/vs_limit.h>
21192 +#include <linux/vserver/limit.h>
21193 +#include <linux/vserver/switch.h>
21194 +#include <linux/vserver/limit_cmd.h>
21196 +#include <asm/errno.h>
21197 +#include <asm/uaccess.h>
21200 +const char *vlimit_name[NUM_LIMITS] = {
21201 + [RLIMIT_CPU] = "CPU",
21202 + [RLIMIT_RSS] = "RSS",
21203 + [RLIMIT_NPROC] = "NPROC",
21204 + [RLIMIT_NOFILE] = "NOFILE",
21205 + [RLIMIT_MEMLOCK] = "VML",
21206 + [RLIMIT_AS] = "VM",
21207 + [RLIMIT_LOCKS] = "LOCKS",
21208 + [RLIMIT_SIGPENDING] = "SIGP",
21209 + [RLIMIT_MSGQUEUE] = "MSGQ",
21211 + [VLIMIT_NSOCK] = "NSOCK",
21212 + [VLIMIT_OPENFD] = "OPENFD",
21213 + [VLIMIT_ANON] = "ANON",
21214 + [VLIMIT_SHMEM] = "SHMEM",
21215 + [VLIMIT_DENTRY] = "DENTRY",
21218 +EXPORT_SYMBOL_GPL(vlimit_name);
21220 +#define MASK_ENTRY(x) (1 << (x))
21222 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21225 + , /* softlimit */
21226 + MASK_ENTRY( RLIMIT_RSS ) |
21227 + MASK_ENTRY( VLIMIT_ANON ) |
21230 + MASK_ENTRY( RLIMIT_RSS ) |
21231 + MASK_ENTRY( RLIMIT_NPROC ) |
21232 + MASK_ENTRY( RLIMIT_NOFILE ) |
21233 + MASK_ENTRY( RLIMIT_MEMLOCK ) |
21234 + MASK_ENTRY( RLIMIT_AS ) |
21235 + MASK_ENTRY( RLIMIT_LOCKS ) |
21236 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21238 + MASK_ENTRY( VLIMIT_NSOCK ) |
21239 + MASK_ENTRY( VLIMIT_OPENFD ) |
21240 + MASK_ENTRY( VLIMIT_ANON ) |
21241 + MASK_ENTRY( VLIMIT_SHMEM ) |
21242 + MASK_ENTRY( VLIMIT_DENTRY ) |
21245 + /* accounting only */
21246 +uint32_t account_mask =
21247 + MASK_ENTRY( VLIMIT_SEMARY ) |
21248 + MASK_ENTRY( VLIMIT_NSEMS ) |
21249 + MASK_ENTRY( VLIMIT_MAPPED ) |
21253 +static int is_valid_vlimit(int id)
21255 + uint32_t mask = vlimit_mask.minimum |
21256 + vlimit_mask.softlimit | vlimit_mask.maximum;
21257 + return mask & (1 << id);
21260 +static int is_accounted_vlimit(int id)
21262 + if (is_valid_vlimit(id))
21264 + return account_mask & (1 << id);
21268 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21270 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21271 + return VX_VLIM(limit);
21274 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21276 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21277 + return VX_VLIM(limit);
21280 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21281 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21283 + if (!is_valid_vlimit(id))
21287 + *minimum = CRLIM_UNSET;
21289 + *softlimit = vc_get_soft(vxi, id);
21291 + *maximum = vc_get_hard(vxi, id);
21295 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21297 + struct vcmd_ctx_rlimit_v0 vc_data;
21300 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21303 + ret = do_get_rlimit(vxi, vc_data.id,
21304 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21308 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21313 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21314 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21316 + if (!is_valid_vlimit(id))
21319 + if (maximum != CRLIM_KEEP)
21320 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21321 + if (softlimit != CRLIM_KEEP)
21322 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21324 + /* clamp soft limit */
21325 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21326 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21331 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21333 + struct vcmd_ctx_rlimit_v0 vc_data;
21335 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21338 + return do_set_rlimit(vxi, vc_data.id,
21339 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21342 +#ifdef CONFIG_IA32_EMULATION
21344 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21346 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21348 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21351 + return do_set_rlimit(vxi, vc_data.id,
21352 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21355 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21357 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21360 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21363 + ret = do_get_rlimit(vxi, vc_data.id,
21364 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21368 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21373 +#endif /* CONFIG_IA32_EMULATION */
21376 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21378 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21384 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21389 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21390 + value = __rlim_get(limit, lim);
21391 + __rlim_rmax(limit, lim) = value;
21392 + __rlim_rmin(limit, lim) = value;
21397 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21399 + vx_reset_minmax(&vxi->limit);
21404 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21406 + struct vcmd_rlimit_stat_v0 vc_data;
21407 + struct _vx_limit *limit = &vxi->limit;
21410 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21414 + if (!is_accounted_vlimit(id))
21417 + vx_limit_fixup(limit, id);
21418 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21419 + vc_data.value = __rlim_get(limit, id);
21420 + vc_data.minimum = __rlim_rmin(limit, id);
21421 + vc_data.maximum = __rlim_rmax(limit, id);
21423 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21429 +void vx_vsi_meminfo(struct sysinfo *val)
21431 + struct vx_info *vxi = current->vx_info;
21432 + unsigned long totalram, freeram;
21435 + /* we blindly accept the max */
21436 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21437 + totalram = (v != RLIM_INFINITY) ? v : val->totalram;
21439 + /* total minus used equals free */
21440 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21441 + freeram = (v < totalram) ? totalram - v : 0;
21443 + val->totalram = totalram;
21444 + val->freeram = freeram;
21445 + val->bufferram = 0;
21446 + val->totalhigh = 0;
21447 + val->freehigh = 0;
21451 +void vx_vsi_swapinfo(struct sysinfo *val)
21453 + struct vx_info *vxi = current->vx_info;
21454 + unsigned long totalswap, freeswap;
21457 + v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21458 + if (v == RLIM_INFINITY) {
21459 + val->freeswap = val->totalswap;
21463 + /* we blindly accept the max */
21464 + w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
21465 + totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
21467 + /* currently 'used' swap */
21468 + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21469 + w -= (w > v) ? v : w;
21471 + /* total minus used equals free */
21472 + freeswap = (w < totalswap) ? totalswap - w : 0;
21474 + val->totalswap = totalswap;
21475 + val->freeswap = freeswap;
21480 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
21482 + struct vx_info *vxi = mm->mm_vx_info;
21483 + unsigned long points;
21489 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21490 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21491 + points = (v > w) ? (v - w) : 0;
21496 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/limit_init.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/limit_init.h
21497 --- linux-2.6.24-rc7/kernel/vserver/limit_init.h 1970-01-01 01:00:00 +0100
21498 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/limit_init.h 2007-12-13 13:25:43 +0100
21502 +static inline void vx_info_init_limit(struct _vx_limit *limit)
21506 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21507 + __rlim_soft(limit, lim) = RLIM_INFINITY;
21508 + __rlim_hard(limit, lim) = RLIM_INFINITY;
21509 + __rlim_set(limit, lim, 0);
21510 + atomic_set(&__rlim_lhit(limit, lim), 0);
21511 + __rlim_rmin(limit, lim) = 0;
21512 + __rlim_rmax(limit, lim) = 0;
21516 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
21518 +#ifdef CONFIG_VSERVER_WARN
21522 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21523 + if ((1 << lim) & VLIM_NOCHECK)
21525 + value = __rlim_get(limit, lim);
21526 + vxwprintk_xid(value,
21527 + "!!! limit: %p[%s,%d] = %ld on exit.",
21528 + limit, vlimit_name[lim], lim, (long)value);
21533 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/limit_proc.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/limit_proc.h
21534 --- linux-2.6.24-rc7/kernel/vserver/limit_proc.h 1970-01-01 01:00:00 +0100
21535 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/limit_proc.h 2007-12-13 13:25:43 +0100
21537 +#ifndef _VX_LIMIT_PROC_H
21538 +#define _VX_LIMIT_PROC_H
21540 +#include <linux/vserver/limit_int.h>
21543 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
21544 +#define VX_LIMIT_TOP \
21545 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
21547 +#define VX_LIMIT_ARG(r) \
21548 + (unsigned long)__rlim_get(limit, r), \
21549 + (unsigned long)__rlim_rmin(limit, r), \
21550 + (unsigned long)__rlim_rmax(limit, r), \
21551 + VX_VLIM(__rlim_soft(limit, r)), \
21552 + VX_VLIM(__rlim_hard(limit, r)), \
21553 + atomic_read(&__rlim_lhit(limit, r))
21555 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
21557 + vx_limit_fixup(limit, -1);
21558 + return sprintf(buffer, VX_LIMIT_TOP
21559 + "PROC" VX_LIMIT_FMT
21560 + "VM" VX_LIMIT_FMT
21561 + "VML" VX_LIMIT_FMT
21562 + "RSS" VX_LIMIT_FMT
21563 + "ANON" VX_LIMIT_FMT
21564 + "RMAP" VX_LIMIT_FMT
21565 + "FILES" VX_LIMIT_FMT
21566 + "OFD" VX_LIMIT_FMT
21567 + "LOCKS" VX_LIMIT_FMT
21568 + "SOCK" VX_LIMIT_FMT
21569 + "MSGQ" VX_LIMIT_FMT
21570 + "SHM" VX_LIMIT_FMT
21571 + "SEMA" VX_LIMIT_FMT
21572 + "SEMS" VX_LIMIT_FMT
21573 + "DENT" VX_LIMIT_FMT,
21574 + VX_LIMIT_ARG(RLIMIT_NPROC),
21575 + VX_LIMIT_ARG(RLIMIT_AS),
21576 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
21577 + VX_LIMIT_ARG(RLIMIT_RSS),
21578 + VX_LIMIT_ARG(VLIMIT_ANON),
21579 + VX_LIMIT_ARG(VLIMIT_MAPPED),
21580 + VX_LIMIT_ARG(RLIMIT_NOFILE),
21581 + VX_LIMIT_ARG(VLIMIT_OPENFD),
21582 + VX_LIMIT_ARG(RLIMIT_LOCKS),
21583 + VX_LIMIT_ARG(VLIMIT_NSOCK),
21584 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
21585 + VX_LIMIT_ARG(VLIMIT_SHMEM),
21586 + VX_LIMIT_ARG(VLIMIT_SEMARY),
21587 + VX_LIMIT_ARG(VLIMIT_NSEMS),
21588 + VX_LIMIT_ARG(VLIMIT_DENTRY));
21591 +#endif /* _VX_LIMIT_PROC_H */
21594 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/monitor.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/monitor.c
21595 --- linux-2.6.24-rc7/kernel/vserver/monitor.c 1970-01-01 01:00:00 +0100
21596 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/monitor.c 2007-12-13 13:25:42 +0100
21599 + * kernel/vserver/monitor.c
21601 + * Virtual Context Scheduler Monitor
21603 + * Copyright (C) 2006-2007 Herbert Pötzl
21605 + * V0.01 basic design
21609 +#include <linux/errno.h>
21610 +#include <linux/module.h>
21611 +#include <linux/types.h>
21612 +#include <linux/ctype.h>
21613 +#include <linux/jiffies.h>
21615 +#include <asm/uaccess.h>
21616 +#include <asm/atomic.h>
21617 +#include <asm/unistd.h>
21619 +#include <linux/vserver/monitor.h>
21620 +#include <linux/vserver/debug_cmd.h>
21623 +#ifdef CONFIG_VSERVER_MONITOR
21624 +#define VXM_SIZE CONFIG_VSERVER_MONITOR_SIZE
21626 +#define VXM_SIZE 64
21629 +struct _vx_monitor {
21630 + unsigned int counter;
21632 + struct _vx_mon_entry entry[VXM_SIZE+1];
21636 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
21638 +unsigned volatile int vxm_active = 1;
21640 +static atomic_t sequence = ATOMIC_INIT(0);
21645 + * requires disabled preemption */
21647 +struct _vx_mon_entry *vxm_advance(int cpu)
21649 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21650 + struct _vx_mon_entry *entry;
21651 + unsigned int index;
21653 + index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
21654 + entry = &mon->entry[index];
21656 + entry->ev.seq = atomic_inc_return(&sequence);
21657 + entry->ev.jif = jiffies;
21661 +EXPORT_SYMBOL_GPL(vxm_advance);
21664 +int do_read_monitor(struct __user _vx_mon_entry *data,
21665 + int cpu, uint32_t *index, uint32_t *count)
21667 + int pos, ret = 0;
21668 + struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
21669 + int end = mon->counter;
21670 + int start = end - VXM_SIZE + 2;
21671 + int idx = *index;
21673 + /* special case: get current pos */
21679 + /* have we lost some data? */
21683 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21684 + struct _vx_mon_entry *entry =
21685 + &mon->entry[idx % VXM_SIZE];
21687 + /* send entry to userspace */
21688 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21692 + /* save new index and count */
21695 + return ret ? ret : (*index < end);
21698 +int vc_read_monitor(uint32_t id, void __user *data)
21700 + struct vcmd_read_monitor_v0 vc_data;
21703 + if (id >= NR_CPUS)
21706 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21709 + ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
21710 + id, &vc_data.index, &vc_data.count);
21712 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21717 +#ifdef CONFIG_COMPAT
21719 +int vc_read_monitor_x32(uint32_t id, void __user *data)
21721 + struct vcmd_read_monitor_v0_x32 vc_data;
21724 + if (id >= NR_CPUS)
21727 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21730 + ret = do_read_monitor((struct __user _vx_mon_entry *)
21731 + compat_ptr(vc_data.data_ptr),
21732 + id, &vc_data.index, &vc_data.count);
21734 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21739 +#endif /* CONFIG_COMPAT */
21741 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/network.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/network.c
21742 --- linux-2.6.24-rc7/kernel/vserver/network.c 1970-01-01 01:00:00 +0100
21743 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/network.c 2007-12-13 15:56:57 +0100
21746 + * linux/kernel/vserver/network.c
21748 + * Virtual Server: Network Support
21750 + * Copyright (C) 2003-2007 Herbert Pötzl
21752 + * V0.01 broken out from vcontext V0.05
21753 + * V0.02 cleaned up implementation
21754 + * V0.03 added equiv nx commands
21755 + * V0.04 switch to RCU based hash
21756 + * V0.05 and back to locking again
21757 + * V0.06 changed vcmds to nxi arg
21758 + * V0.07 have __create claim() the nxi
21762 +#include <linux/slab.h>
21763 +#include <linux/rcupdate.h>
21764 +#include <net/tcp.h>
21766 +#include <asm/errno.h>
21767 +#include <linux/vserver/base.h>
21768 +#include <linux/vserver/network_cmd.h>
21769 +#include <linux/vs_pid.h>
21772 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
21773 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
21776 +/* __alloc_nx_info()
21778 + * allocate an initialized nx_info struct
21779 + * doesn't make it visible (hash) */
21781 +static struct nx_info *__alloc_nx_info(nid_t nid)
21783 + struct nx_info *new = NULL;
21785 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
21787 + /* would this benefit from a slab cache? */
21788 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
21792 + memset(new, 0, sizeof(struct nx_info));
21793 + new->nx_id = nid;
21794 + INIT_HLIST_NODE(&new->nx_hlist);
21795 + atomic_set(&new->nx_usecnt, 0);
21796 + atomic_set(&new->nx_tasks, 0);
21797 + new->nx_state = 0;
21799 + new->nx_flags = NXF_INIT_SET;
21801 + /* rest of init goes here */
21803 + vxdprintk(VXD_CBIT(nid, 0),
21804 + "alloc_nx_info(%d) = %p", nid, new);
21805 + atomic_inc(&nx_global_ctotal);
21809 +/* __dealloc_nx_info()
21811 + * final disposal of nx_info */
21813 +static void __dealloc_nx_info(struct nx_info *nxi)
21815 + vxdprintk(VXD_CBIT(nid, 0),
21816 + "dealloc_nx_info(%p)", nxi);
21818 + nxi->nx_hlist.next = LIST_POISON1;
21821 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21822 + BUG_ON(atomic_read(&nxi->nx_tasks));
21824 + nxi->nx_state |= NXS_RELEASED;
21826 + atomic_dec(&nx_global_ctotal);
21829 +static void __shutdown_nx_info(struct nx_info *nxi)
21831 + nxi->nx_state |= NXS_SHUTDOWN;
21832 + vs_net_change(nxi, VSC_NETDOWN);
21835 +/* exported stuff */
21837 +void free_nx_info(struct nx_info *nxi)
21839 + /* context shutdown is mandatory */
21840 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
21842 + /* context must not be hashed */
21843 + BUG_ON(nxi->nx_state & NXS_HASHED);
21845 + BUG_ON(atomic_read(&nxi->nx_usecnt));
21846 + BUG_ON(atomic_read(&nxi->nx_tasks));
21848 + __dealloc_nx_info(nxi);
21852 +/* hash table for nx_info hash */
21854 +#define NX_HASH_SIZE 13
21856 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
21858 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
21861 +static inline unsigned int __hashval(nid_t nid)
21863 + return (nid % NX_HASH_SIZE);
21868 +/* __hash_nx_info()
21870 + * add the nxi to the global hash table
21871 + * requires the hash_lock to be held */
21873 +static inline void __hash_nx_info(struct nx_info *nxi)
21875 + struct hlist_head *head;
21877 + vxd_assert_lock(&nx_info_hash_lock);
21878 + vxdprintk(VXD_CBIT(nid, 4),
21879 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
21881 + /* context must not be hashed */
21882 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
21884 + nxi->nx_state |= NXS_HASHED;
21885 + head = &nx_info_hash[__hashval(nxi->nx_id)];
21886 + hlist_add_head(&nxi->nx_hlist, head);
21887 + atomic_inc(&nx_global_cactive);
21890 +/* __unhash_nx_info()
21892 + * remove the nxi from the global hash table
21893 + * requires the hash_lock to be held */
21895 +static inline void __unhash_nx_info(struct nx_info *nxi)
21897 + vxd_assert_lock(&nx_info_hash_lock);
21898 + vxdprintk(VXD_CBIT(nid, 4),
21899 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
21900 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
21902 + /* context must be hashed */
21903 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
21904 + /* but without tasks */
21905 + BUG_ON(atomic_read(&nxi->nx_tasks));
21907 + nxi->nx_state &= ~NXS_HASHED;
21908 + hlist_del(&nxi->nx_hlist);
21909 + atomic_dec(&nx_global_cactive);
21913 +/* __lookup_nx_info()
21915 + * requires the hash_lock to be held
21916 + * doesn't increment the nx_refcnt */
21918 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
21920 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
21921 + struct hlist_node *pos;
21922 + struct nx_info *nxi;
21924 + vxd_assert_lock(&nx_info_hash_lock);
21925 + hlist_for_each(pos, head) {
21926 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
21928 + if (nxi->nx_id == nid)
21933 + vxdprintk(VXD_CBIT(nid, 0),
21934 + "__lookup_nx_info(#%u): %p[#%u]",
21935 + nid, nxi, nxi ? nxi->nx_id : 0);
21940 +/* __nx_dynamic_id()
21942 + * find unused dynamic nid
21943 + * requires the hash_lock to be held */
21945 +static inline nid_t __nx_dynamic_id(void)
21947 + static nid_t seq = MAX_N_CONTEXT;
21948 + nid_t barrier = seq;
21950 + vxd_assert_lock(&nx_info_hash_lock);
21952 + if (++seq > MAX_N_CONTEXT)
21953 + seq = MIN_D_CONTEXT;
21954 + if (!__lookup_nx_info(seq)) {
21955 + vxdprintk(VXD_CBIT(nid, 4),
21956 + "__nx_dynamic_id: [#%d]", seq);
21959 + } while (barrier != seq);
21963 +/* __create_nx_info()
21965 + * create the requested context
21966 + * get(), claim() and hash it */
21968 +static struct nx_info *__create_nx_info(int id)
21970 + struct nx_info *new, *nxi = NULL;
21972 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
21974 + if (!(new = __alloc_nx_info(id)))
21975 + return ERR_PTR(-ENOMEM);
21977 + /* required to make dynamic xids unique */
21978 + spin_lock(&nx_info_hash_lock);
21980 + /* dynamic context requested */
21981 + if (id == NX_DYNAMIC_ID) {
21982 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
21983 + id = __nx_dynamic_id();
21985 + printk(KERN_ERR "no dynamic context available.\n");
21986 + nxi = ERR_PTR(-EAGAIN);
21991 + printk(KERN_ERR "dynamic contexts disabled.\n");
21992 + nxi = ERR_PTR(-EINVAL);
21996 + /* static context requested */
21997 + else if ((nxi = __lookup_nx_info(id))) {
21998 + vxdprintk(VXD_CBIT(nid, 0),
21999 + "create_nx_info(%d) = %p (already there)", id, nxi);
22000 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22001 + nxi = ERR_PTR(-EBUSY);
22003 + nxi = ERR_PTR(-EEXIST);
22006 + /* dynamic nid creation blocker */
22007 + else if (id >= MIN_D_CONTEXT) {
22008 + vxdprintk(VXD_CBIT(nid, 0),
22009 + "create_nx_info(%d) (dynamic rejected)", id);
22010 + nxi = ERR_PTR(-EINVAL);
22014 + /* new context */
22015 + vxdprintk(VXD_CBIT(nid, 0),
22016 + "create_nx_info(%d) = %p (new)", id, new);
22017 + claim_nx_info(new, NULL);
22018 + __hash_nx_info(get_nx_info(new));
22019 + nxi = new, new = NULL;
22022 + spin_unlock(&nx_info_hash_lock);
22024 + __dealloc_nx_info(new);
22030 +/* exported stuff */
22033 +void unhash_nx_info(struct nx_info *nxi)
22035 + __shutdown_nx_info(nxi);
22036 + spin_lock(&nx_info_hash_lock);
22037 + __unhash_nx_info(nxi);
22038 + spin_unlock(&nx_info_hash_lock);
22041 +#ifdef CONFIG_VSERVER_LEGACYNET
22043 +struct nx_info *create_nx_info(void)
22045 + return __create_nx_info(NX_DYNAMIC_ID);
22050 +/* lookup_nx_info()
22052 + * search for a nx_info and get() it
22053 + * negative id means current */
22055 +struct nx_info *lookup_nx_info(int id)
22057 + struct nx_info *nxi = NULL;
22060 + nxi = get_nx_info(current->nx_info);
22061 + } else if (id > 1) {
22062 + spin_lock(&nx_info_hash_lock);
22063 + nxi = get_nx_info(__lookup_nx_info(id));
22064 + spin_unlock(&nx_info_hash_lock);
22069 +/* nid_is_hashed()
22071 + * verify that nid is still hashed */
22073 +int nid_is_hashed(nid_t nid)
22077 + spin_lock(&nx_info_hash_lock);
22078 + hashed = (__lookup_nx_info(nid) != NULL);
22079 + spin_unlock(&nx_info_hash_lock);
22084 +#ifdef CONFIG_PROC_FS
22088 + * get a subset of hashed nids for proc
22089 + * assumes size is at least one */
22091 +int get_nid_list(int index, unsigned int *nids, int size)
22093 + int hindex, nr_nids = 0;
22095 + /* only show current and children */
22096 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22099 + nids[nr_nids] = nx_current_nid();
22103 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22104 + struct hlist_head *head = &nx_info_hash[hindex];
22105 + struct hlist_node *pos;
22107 + spin_lock(&nx_info_hash_lock);
22108 + hlist_for_each(pos, head) {
22109 + struct nx_info *nxi;
22114 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22115 + nids[nr_nids] = nxi->nx_id;
22116 + if (++nr_nids >= size) {
22117 + spin_unlock(&nx_info_hash_lock);
22121 + /* keep the lock time short */
22122 + spin_unlock(&nx_info_hash_lock);
22131 + * migrate task to new network
22132 + * gets nxi, puts old_nxi on change
22135 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22137 + struct nx_info *old_nxi;
22143 + vxdprintk(VXD_CBIT(nid, 5),
22144 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22145 + p, nxi, nxi->nx_id,
22146 + atomic_read(&nxi->nx_usecnt),
22147 + atomic_read(&nxi->nx_tasks));
22149 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22150 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22153 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22156 + /* maybe disallow this completely? */
22157 + old_nxi = task_get_nx_info(p);
22158 + if (old_nxi == nxi)
22163 + clr_nx_info(&p->nx_info);
22164 + claim_nx_info(nxi, p);
22165 + set_nx_info(&p->nx_info, nxi);
22166 + p->nid = nxi->nx_id;
22169 + vxdprintk(VXD_CBIT(nid, 5),
22170 + "moved task %p into nxi:%p[#%d]",
22171 + p, nxi, nxi->nx_id);
22174 + release_nx_info(old_nxi, p);
22177 + put_nx_info(old_nxi);
22182 +#ifdef CONFIG_INET
22184 +#include <linux/netdevice.h>
22185 +#include <linux/inetdevice.h>
22187 +int ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
22193 + return addr_in_nx_info(nxi, ifa->ifa_local);
22196 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
22198 + struct in_device *in_dev;
22199 + struct in_ifaddr **ifap;
22200 + struct in_ifaddr *ifa;
22208 + in_dev = in_dev_get(dev);
22212 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
22213 + ifap = &ifa->ifa_next) {
22214 + if (addr_in_nx_info(nxi, ifa->ifa_local)) {
22219 + in_dev_put(in_dev);
22225 + * check if address is covered by socket
22227 + * sk: the socket to check against
22228 + * addr: the address in question (must be != 0)
22230 +static inline int __addr_in_socket(const struct sock *sk, uint32_t addr)
22232 + struct nx_info *nxi = sk->sk_nx_info;
22233 + uint32_t saddr = inet_rcv_saddr(sk);
22235 + vxdprintk(VXD_CBIT(net, 5),
22236 + "__addr_in_socket(%p," NIPQUAD_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
22237 + sk, NIPQUAD(addr), nxi, NIPQUAD(saddr), sk->sk_socket,
22238 + (sk->sk_socket ? sk->sk_socket->flags : 0));
22241 + /* direct address match */
22242 + return (saddr == addr);
22243 + } else if (nxi) {
22244 + /* match against nx_info */
22245 + return addr_in_nx_info(nxi, addr);
22247 + /* unrestricted any socket */
22253 +int nx_addr_conflict(struct nx_info *nxi, uint32_t addr, const struct sock *sk)
22255 + vxdprintk(VXD_CBIT(net, 2),
22256 + "nx_addr_conflict(%p,%p) " NIPQUAD_FMT,
22257 + nxi, sk, NIPQUAD(addr));
22260 + /* check real address */
22261 + return __addr_in_socket(sk, addr);
22262 + } else if (nxi) {
22263 + /* check against nx_info */
22264 + int i, n = nxi->nbipv4;
22266 + for (i = 0; i < n; i++)
22267 + if (__addr_in_socket(sk, nxi->ipv4[i]))
22271 + /* check against any */
22276 +#endif /* CONFIG_INET */
22278 +void nx_set_persistent(struct nx_info *nxi)
22280 + vxdprintk(VXD_CBIT(nid, 6),
22281 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22283 + get_nx_info(nxi);
22284 + claim_nx_info(nxi, NULL);
22287 +void nx_clear_persistent(struct nx_info *nxi)
22289 + vxdprintk(VXD_CBIT(nid, 6),
22290 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22292 + release_nx_info(nxi, NULL);
22293 + put_nx_info(nxi);
22296 +void nx_update_persistent(struct nx_info *nxi)
22298 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22299 + nx_set_persistent(nxi);
22301 + nx_clear_persistent(nxi);
22304 +/* vserver syscall commands below here */
22306 +/* taks nid and nx_info functions */
22308 +#include <asm/uaccess.h>
22311 +int vc_task_nid(uint32_t id, void __user *data)
22316 + struct task_struct *tsk;
22318 + if (!nx_check(0, VS_ADMIN | VS_WATCH))
22321 + read_lock(&tasklist_lock);
22322 + tsk = find_task_by_real_pid(id);
22323 + nid = (tsk) ? tsk->nid : -ESRCH;
22324 + read_unlock(&tasklist_lock);
22326 + nid = nx_current_nid();
22331 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22333 + struct vcmd_nx_info_v0 vc_data;
22335 + vc_data.nid = nxi->nx_id;
22337 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22343 +/* network functions */
22345 +int vc_net_create(uint32_t nid, void __user *data)
22347 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22348 + struct nx_info *new_nxi;
22351 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22354 + if ((nid > MAX_S_CONTEXT) && (nid != NX_DYNAMIC_ID))
22359 + new_nxi = __create_nx_info(nid);
22360 + if (IS_ERR(new_nxi))
22361 + return PTR_ERR(new_nxi);
22363 + /* initial flags */
22364 + new_nxi->nx_flags = vc_data.flagword;
22367 + if (vs_net_change(new_nxi, VSC_NETUP))
22370 + ret = nx_migrate_task(current, new_nxi);
22374 + /* return context id on success */
22375 + ret = new_nxi->nx_id;
22377 + /* get a reference for persistent contexts */
22378 + if ((vc_data.flagword & NXF_PERSISTENT))
22379 + nx_set_persistent(new_nxi);
22381 + release_nx_info(new_nxi, NULL);
22382 + put_nx_info(new_nxi);
22387 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22389 + return nx_migrate_task(current, nxi);
22392 +int vc_net_add(struct nx_info *nxi, void __user *data)
22394 + struct vcmd_net_addr_v0 vc_data;
22395 + int index, pos, ret = 0;
22397 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22400 + switch (vc_data.type) {
22401 + case NXA_TYPE_IPV4:
22402 + if ((vc_data.count < 1) || (vc_data.count > 4))
22410 + switch (vc_data.type) {
22411 + case NXA_TYPE_IPV4:
22413 + while ((index < vc_data.count) &&
22414 + ((pos = nxi->nbipv4) < NB_IPV4ROOT)) {
22415 + nxi->ipv4[pos] = vc_data.ip[index];
22416 + nxi->mask[pos] = vc_data.mask[index];
22423 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22424 + nxi->v4_bcast = vc_data.ip[0];
22435 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22437 + struct vcmd_net_addr_v0 vc_data;
22439 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22442 + switch (vc_data.type) {
22443 + case NXA_TYPE_ANY:
22453 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
22455 + struct vcmd_net_flags_v0 vc_data;
22457 + vc_data.flagword = nxi->nx_flags;
22459 + /* special STATE flag handling */
22460 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
22462 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22467 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
22469 + struct vcmd_net_flags_v0 vc_data;
22470 + uint64_t mask, trigger;
22472 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22475 + /* special STATE flag handling */
22476 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
22477 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
22479 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
22480 + vc_data.flagword, mask);
22481 + if (trigger & NXF_PERSISTENT)
22482 + nx_update_persistent(nxi);
22487 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
22489 + struct vcmd_net_caps_v0 vc_data;
22491 + vc_data.ncaps = nxi->nx_ncaps;
22492 + vc_data.cmask = ~0ULL;
22494 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22499 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
22501 + struct vcmd_net_caps_v0 vc_data;
22503 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22506 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
22507 + vc_data.ncaps, vc_data.cmask);
22512 +#include <linux/module.h>
22514 +EXPORT_SYMBOL_GPL(free_nx_info);
22515 +EXPORT_SYMBOL_GPL(unhash_nx_info);
22517 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/proc.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/proc.c
22518 --- linux-2.6.24-rc7/kernel/vserver/proc.c 1970-01-01 01:00:00 +0100
22519 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/proc.c 2007-12-15 00:35:35 +0100
22522 + * linux/kernel/vserver/proc.c
22524 + * Virtual Context Support
22526 + * Copyright (C) 2003-2007 Herbert Pötzl
22528 + * V0.01 basic structure
22529 + * V0.02 adaptation vs1.3.0
22530 + * V0.03 proc permissions
22531 + * V0.04 locking/generic
22532 + * V0.05 next generation procfs
22533 + * V0.06 inode validation
22534 + * V0.07 generic rewrite vid
22535 + * V0.08 remove inode type
22539 +#include <linux/errno.h>
22540 +#include <linux/proc_fs.h>
22541 +#include <linux/sched.h>
22542 +#include <linux/vs_context.h>
22543 +#include <linux/vs_network.h>
22544 +#include <linux/vs_cvirt.h>
22546 +#include <linux/vserver/switch.h>
22547 +#include <linux/vserver/global.h>
22549 +#include <asm/uaccess.h>
22550 +#include <asm/unistd.h>
22552 +#include "cvirt_proc.h"
22553 +#include "cacct_proc.h"
22554 +#include "limit_proc.h"
22555 +#include "sched_proc.h"
22556 +#include "vci_config.h"
22558 +static struct proc_dir_entry *proc_virtual;
22560 +static struct proc_dir_entry *proc_virtnet;
22563 +/* first the actual feeds */
22566 +static int proc_vci(char *buffer)
22568 + return sprintf(buffer,
22569 + "VCIVersion:\t%04x:%04x\n"
22570 + "VCISyscall:\t%d\n"
22571 + "VCIKernel:\t%08x\n",
22572 + VCI_VERSION >> 16,
22573 + VCI_VERSION & 0xFFFF,
22575 + vci_kernel_config());
22578 +static int proc_virtual_info(char *buffer)
22580 + return proc_vci(buffer);
22583 +static int proc_virtual_status(char *buffer)
22585 + return sprintf(buffer,
22587 + "#CActive:\t%d\n"
22588 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n",
22589 + atomic_read(&vx_global_ctotal),
22590 + atomic_read(&vx_global_cactive),
22591 + atomic_read(&vs_global_nsproxy),
22592 + atomic_read(&vs_global_fs),
22593 + atomic_read(&vs_global_mnt_ns),
22594 + atomic_read(&vs_global_uts_ns),
22595 + atomic_read(&vs_global_ipc_ns),
22596 + atomic_read(&vs_global_user_ns),
22597 + atomic_read(&vs_global_pid_ns));
22601 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
22605 + length = sprintf(buffer,
22611 + vxi->vx_initpid);
22615 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
22619 + length = sprintf(buffer,
22622 + "Flags:\t%016llx\n"
22623 + "BCaps:\t%016llx\n"
22624 + "CCaps:\t%016llx\n"
22625 + "Spaces:\t%08lx\n",
22626 + atomic_read(&vxi->vx_usecnt),
22627 + atomic_read(&vxi->vx_tasks),
22628 + (unsigned long long)vxi->vx_flags,
22629 + (unsigned long long)vxi->vx_bcaps,
22630 + (unsigned long long)vxi->vx_ccaps,
22635 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
22637 + return vx_info_proc_limit(&vxi->limit, buffer);
22640 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
22644 + length = vx_info_proc_sched(&vxi->sched, buffer);
22645 + for_each_online_cpu(cpu) {
22646 + length += vx_info_proc_sched_pc(
22647 + &vx_per_cpu(vxi, sched_pc, cpu),
22648 + buffer + length, cpu);
22653 +int proc_vxi_nsproxy(struct vx_info *vxi, char *buffer)
22655 + return vx_info_proc_nsproxy(vxi->vx_nsproxy, buffer);
22658 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
22662 + vx_update_load(vxi);
22663 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
22664 + for_each_online_cpu(cpu) {
22665 + length += vx_info_proc_cvirt_pc(
22666 + &vx_per_cpu(vxi, cvirt_pc, cpu),
22667 + buffer + length, cpu);
22672 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
22674 + return vx_info_proc_cacct(&vxi->cacct, buffer);
22678 +static int proc_virtnet_info(char *buffer)
22680 + return proc_vci(buffer);
22683 +static int proc_virtnet_status(char *buffer)
22685 + return sprintf(buffer,
22687 + "#CActive:\t%d\n",
22688 + atomic_read(&nx_global_ctotal),
22689 + atomic_read(&nx_global_cactive));
22692 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
22696 + length = sprintf(buffer,
22701 + for (i = 0; i < nxi->nbipv4; i++) {
22702 + length += sprintf(buffer + length,
22703 + "%d:\t" NIPQUAD_FMT "/" NIPQUAD_FMT "\n", i,
22704 + NIPQUAD(nxi->ipv4[i]), NIPQUAD(nxi->mask[i]));
22709 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
22713 + length = sprintf(buffer,
22716 + "Flags:\t%016llx\n"
22717 + "NCaps:\t%016llx\n",
22718 + atomic_read(&nxi->nx_usecnt),
22719 + atomic_read(&nxi->nx_tasks),
22720 + (unsigned long long)nxi->nx_flags,
22721 + (unsigned long long)nxi->nx_ncaps);
22727 +/* here the inode helpers */
22733 + struct inode_operations *iop;
22734 + struct file_operations *fop;
22735 + union proc_op op;
22738 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
22740 + struct inode *inode = new_inode(sb);
22745 + inode->i_mode = p->mode;
22747 + inode->i_op = p->iop;
22749 + inode->i_fop = p->fop;
22751 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
22752 + inode->i_flags |= S_IMMUTABLE;
22754 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
22756 + inode->i_uid = 0;
22757 + inode->i_gid = 0;
22758 + inode->i_tag = 0;
22763 +static struct dentry *vs_proc_instantiate(struct inode *dir,
22764 + struct dentry *dentry, int id, void *ptr)
22766 + struct vs_entry *p = ptr;
22767 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
22768 + struct dentry *error = ERR_PTR(-EINVAL);
22773 + PROC_I(inode)->op = p->op;
22774 + PROC_I(inode)->fd = id;
22775 + d_add(dentry, inode);
22783 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
22786 + * Fill a directory entry.
22788 + * If possible create the dcache entry and derive our inode number and
22789 + * file type from dcache entry.
22791 + * Since all of the proc inode numbers are dynamically generated, the inode
22792 + * numbers do not exist until the inode is cache. This means creating the
22793 + * the dcache entry in readdir is necessary to keep the inode numbers
22794 + * reported by readdir in sync with the inode numbers reported
22797 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
22798 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
22800 + struct dentry *child, *dir = filp->f_dentry;
22801 + struct inode *inode;
22802 + struct qstr qname;
22804 + unsigned type = DT_UNKNOWN;
22806 + qname.name = name;
22808 + qname.hash = full_name_hash(name, len);
22810 + child = d_lookup(dir, &qname);
22812 + struct dentry *new;
22813 + new = d_alloc(dir, &qname);
22815 + child = instantiate(dir->d_inode, new, id, ptr);
22822 + if (!child || IS_ERR(child) || !child->d_inode)
22823 + goto end_instantiate;
22824 + inode = child->d_inode;
22826 + ino = inode->i_ino;
22827 + type = inode->i_mode >> 12;
22832 + ino = find_inode_number(dir, &qname);
22835 + return filldir(dirent, name, len, filp->f_pos, ino, type);
22840 +/* get and revalidate vx_info/xid */
22843 +struct vx_info *get_proc_vx_info(struct inode *inode)
22845 + return lookup_vx_info(PROC_I(inode)->fd);
22848 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
22850 + struct inode *inode = dentry->d_inode;
22851 + xid_t xid = PROC_I(inode)->fd;
22853 + if (!xid || xid_is_hashed(xid))
22860 +/* get and revalidate nx_info/nid */
22862 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
22864 + struct inode *inode = dentry->d_inode;
22865 + nid_t nid = PROC_I(inode)->fd;
22867 + if (!nid || nid_is_hashed(nid))
22875 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
22877 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
22878 + size_t count, loff_t *ppos)
22880 + struct inode *inode = file->f_dentry->d_inode;
22881 + unsigned long page;
22882 + ssize_t length = 0;
22884 + if (count > PROC_BLOCK_SIZE)
22885 + count = PROC_BLOCK_SIZE;
22887 + /* fade that out as soon as stable */
22888 + WARN_ON(PROC_I(inode)->fd);
22890 + if (!(page = __get_free_page(GFP_KERNEL)))
22893 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
22894 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
22897 + length = simple_read_from_buffer(buf, count, ppos,
22898 + (char *)page, length);
22904 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
22905 + size_t count, loff_t *ppos)
22907 + struct inode *inode = file->f_dentry->d_inode;
22908 + struct vx_info *vxi = NULL;
22909 + xid_t xid = PROC_I(inode)->fd;
22910 + unsigned long page;
22911 + ssize_t length = 0;
22913 + if (count > PROC_BLOCK_SIZE)
22914 + count = PROC_BLOCK_SIZE;
22916 + /* fade that out as soon as stable */
22918 + vxi = lookup_vx_info(xid);
22922 + length = -ENOMEM;
22923 + if (!(page = __get_free_page(GFP_KERNEL)))
22926 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
22927 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
22930 + length = simple_read_from_buffer(buf, count, ppos,
22931 + (char *)page, length);
22935 + put_vx_info(vxi);
22940 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
22941 + size_t count, loff_t *ppos)
22943 + struct inode *inode = file->f_dentry->d_inode;
22944 + struct nx_info *nxi = NULL;
22945 + nid_t nid = PROC_I(inode)->fd;
22946 + unsigned long page;
22947 + ssize_t length = 0;
22949 + if (count > PROC_BLOCK_SIZE)
22950 + count = PROC_BLOCK_SIZE;
22952 + /* fade that out as soon as stable */
22954 + nxi = lookup_nx_info(nid);
22958 + length = -ENOMEM;
22959 + if (!(page = __get_free_page(GFP_KERNEL)))
22962 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
22963 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
22966 + length = simple_read_from_buffer(buf, count, ppos,
22967 + (char *)page, length);
22971 + put_nx_info(nxi);
22978 +/* here comes the lower level */
22981 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
22982 + .len = sizeof(NAME) - 1, \
22983 + .name = (NAME), \
22991 +#define DIR(NAME, MODE, OTYPE) \
22992 + NOD(NAME, (S_IFDIR | (MODE)), \
22993 + &proc_ ## OTYPE ## _inode_operations, \
22994 + &proc_ ## OTYPE ## _file_operations, { } )
22996 +#define INF(NAME, MODE, OTYPE) \
22997 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
22998 + &proc_vs_info_file_operations, \
22999 + { .proc_vs_read = &proc_##OTYPE } )
23001 +#define VINF(NAME, MODE, OTYPE) \
23002 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23003 + &proc_vx_info_file_operations, \
23004 + { .proc_vxi_read = &proc_##OTYPE } )
23006 +#define NINF(NAME, MODE, OTYPE) \
23007 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23008 + &proc_nx_info_file_operations, \
23009 + { .proc_nxi_read = &proc_##OTYPE } )
23012 +static struct file_operations proc_vs_info_file_operations = {
23013 + .read = proc_vs_info_read,
23016 +static struct file_operations proc_vx_info_file_operations = {
23017 + .read = proc_vx_info_read,
23020 +static struct dentry_operations proc_xid_dentry_operations = {
23021 + .d_revalidate = proc_xid_revalidate,
23024 +static struct vs_entry vx_base_stuff[] = {
23025 + VINF("info", S_IRUGO, vxi_info),
23026 + VINF("status", S_IRUGO, vxi_status),
23027 + VINF("limit", S_IRUGO, vxi_limit),
23028 + VINF("sched", S_IRUGO, vxi_sched),
23029 + VINF("nsproxy", S_IRUGO, vxi_nsproxy),
23030 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23031 + VINF("cacct", S_IRUGO, vxi_cacct),
23038 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23039 + struct dentry *dentry, int id, void *ptr)
23041 + dentry->d_op = &proc_xid_dentry_operations;
23042 + return vs_proc_instantiate(dir, dentry, id, ptr);
23045 +static struct dentry *proc_xid_lookup(struct inode *dir,
23046 + struct dentry *dentry, struct nameidata *nd)
23048 + struct vs_entry *p = vx_base_stuff;
23049 + struct dentry *error = ERR_PTR(-ENOENT);
23051 + for (; p->name; p++) {
23052 + if (p->len != dentry->d_name.len)
23054 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23060 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23065 +static int proc_xid_readdir(struct file *filp,
23066 + void *dirent, filldir_t filldir)
23068 + struct dentry *dentry = filp->f_dentry;
23069 + struct inode *inode = dentry->d_inode;
23070 + struct vs_entry *p = vx_base_stuff;
23071 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23075 + pos = filp->f_pos;
23078 + ino = inode->i_ino;
23079 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23082 + /* fall through */
23084 + ino = parent_ino(dentry);
23085 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23088 + /* fall through */
23091 + if (index >= size)
23093 + for (p += index; p->name; p++) {
23094 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23095 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23101 + filp->f_pos = pos;
23107 +static struct file_operations proc_nx_info_file_operations = {
23108 + .read = proc_nx_info_read,
23111 +static struct dentry_operations proc_nid_dentry_operations = {
23112 + .d_revalidate = proc_nid_revalidate,
23115 +static struct vs_entry nx_base_stuff[] = {
23116 + NINF("info", S_IRUGO, nxi_info),
23117 + NINF("status", S_IRUGO, nxi_status),
23122 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23123 + struct dentry *dentry, int id, void *ptr)
23125 + dentry->d_op = &proc_nid_dentry_operations;
23126 + return vs_proc_instantiate(dir, dentry, id, ptr);
23129 +static struct dentry *proc_nid_lookup(struct inode *dir,
23130 + struct dentry *dentry, struct nameidata *nd)
23132 + struct vs_entry *p = nx_base_stuff;
23133 + struct dentry *error = ERR_PTR(-ENOENT);
23135 + for (; p->name; p++) {
23136 + if (p->len != dentry->d_name.len)
23138 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23144 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23149 +static int proc_nid_readdir(struct file *filp,
23150 + void *dirent, filldir_t filldir)
23152 + struct dentry *dentry = filp->f_dentry;
23153 + struct inode *inode = dentry->d_inode;
23154 + struct vs_entry *p = nx_base_stuff;
23155 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23159 + pos = filp->f_pos;
23162 + ino = inode->i_ino;
23163 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23166 + /* fall through */
23168 + ino = parent_ino(dentry);
23169 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23172 + /* fall through */
23175 + if (index >= size)
23177 + for (p += index; p->name; p++) {
23178 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23179 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23185 + filp->f_pos = pos;
23190 +#define MAX_MULBY10 ((~0U - 9) / 10)
23192 +static inline int atovid(const char *str, int len)
23197 + while (len-- > 0) {
23202 + if (vid >= MAX_MULBY10)
23212 +/* now the upper level (virtual) */
23215 +static struct file_operations proc_xid_file_operations = {
23216 + .read = generic_read_dir,
23217 + .readdir = proc_xid_readdir,
23220 +static struct inode_operations proc_xid_inode_operations = {
23221 + .lookup = proc_xid_lookup,
23224 +static struct vs_entry vx_virtual_stuff[] = {
23225 + INF("info", S_IRUGO, virtual_info),
23226 + INF("status", S_IRUGO, virtual_status),
23227 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23231 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23232 + struct dentry *dentry, struct nameidata *nd)
23234 + struct vs_entry *p = vx_virtual_stuff;
23235 + struct dentry *error = ERR_PTR(-ENOENT);
23238 + for (; p->name; p++) {
23239 + if (p->len != dentry->d_name.len)
23241 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23245 + goto instantiate;
23247 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23248 + if ((id < 0) || !xid_is_hashed(id))
23252 + error = proc_xid_instantiate(dir, dentry, id, p);
23257 +static struct file_operations proc_nid_file_operations = {
23258 + .read = generic_read_dir,
23259 + .readdir = proc_nid_readdir,
23262 +static struct inode_operations proc_nid_inode_operations = {
23263 + .lookup = proc_nid_lookup,
23266 +static struct vs_entry nx_virtnet_stuff[] = {
23267 + INF("info", S_IRUGO, virtnet_info),
23268 + INF("status", S_IRUGO, virtnet_status),
23269 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23273 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23274 + struct dentry *dentry, struct nameidata *nd)
23276 + struct vs_entry *p = nx_virtnet_stuff;
23277 + struct dentry *error = ERR_PTR(-ENOENT);
23280 + for (; p->name; p++) {
23281 + if (p->len != dentry->d_name.len)
23283 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23287 + goto instantiate;
23289 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23290 + if ((id < 0) || !nid_is_hashed(id))
23294 + error = proc_nid_instantiate(dir, dentry, id, p);
23301 +#define PROC_NUMBUF 10
23302 +#define PROC_MAXVIDS 32
23304 +int proc_virtual_readdir(struct file *filp,
23305 + void *dirent, filldir_t filldir)
23307 + struct dentry *dentry = filp->f_dentry;
23308 + struct inode *inode = dentry->d_inode;
23309 + struct vs_entry *p = vx_virtual_stuff;
23310 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
23312 + unsigned int xid_array[PROC_MAXVIDS];
23313 + char buf[PROC_NUMBUF];
23314 + unsigned int nr_xids, i;
23317 + pos = filp->f_pos;
23320 + ino = inode->i_ino;
23321 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23324 + /* fall through */
23326 + ino = parent_ino(dentry);
23327 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23330 + /* fall through */
23333 + if (index >= size)
23335 + for (p += index; p->name; p++) {
23336 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23337 + vs_proc_instantiate, 0, p))
23342 + index = pos - size;
23343 + p = &vx_virtual_stuff[size - 1];
23344 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
23345 + for (i = 0; i < nr_xids; i++) {
23346 + int n, xid = xid_array[i];
23347 + unsigned int j = PROC_NUMBUF;
23351 + buf[--j] = '0' + (n % 10);
23354 + if (proc_fill_cache(filp, dirent, filldir,
23355 + buf + j, PROC_NUMBUF - j,
23356 + vs_proc_instantiate, xid, p))
23362 + filp->f_pos = pos;
23366 +static int proc_virtual_getattr(struct vfsmount *mnt,
23367 + struct dentry *dentry, struct kstat *stat)
23369 + struct inode *inode = dentry->d_inode;
23371 + generic_fillattr(inode, stat);
23372 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
23376 +static struct file_operations proc_virtual_dir_operations = {
23377 + .read = generic_read_dir,
23378 + .readdir = proc_virtual_readdir,
23381 +static struct inode_operations proc_virtual_dir_inode_operations = {
23382 + .getattr = proc_virtual_getattr,
23383 + .lookup = proc_virtual_lookup,
23390 +int proc_virtnet_readdir(struct file *filp,
23391 + void *dirent, filldir_t filldir)
23393 + struct dentry *dentry = filp->f_dentry;
23394 + struct inode *inode = dentry->d_inode;
23395 + struct vs_entry *p = nx_virtnet_stuff;
23396 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
23398 + unsigned int nid_array[PROC_MAXVIDS];
23399 + char buf[PROC_NUMBUF];
23400 + unsigned int nr_nids, i;
23403 + pos = filp->f_pos;
23406 + ino = inode->i_ino;
23407 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23410 + /* fall through */
23412 + ino = parent_ino(dentry);
23413 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23416 + /* fall through */
23419 + if (index >= size)
23421 + for (p += index; p->name; p++) {
23422 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23423 + vs_proc_instantiate, 0, p))
23428 + index = pos - size;
23429 + p = &nx_virtnet_stuff[size - 1];
23430 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
23431 + for (i = 0; i < nr_nids; i++) {
23432 + int n, nid = nid_array[i];
23433 + unsigned int j = PROC_NUMBUF;
23437 + buf[--j] = '0' + (n % 10);
23440 + if (proc_fill_cache(filp, dirent, filldir,
23441 + buf + j, PROC_NUMBUF - j,
23442 + vs_proc_instantiate, nid, p))
23448 + filp->f_pos = pos;
23452 +static int proc_virtnet_getattr(struct vfsmount *mnt,
23453 + struct dentry *dentry, struct kstat *stat)
23455 + struct inode *inode = dentry->d_inode;
23457 + generic_fillattr(inode, stat);
23458 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
23462 +static struct file_operations proc_virtnet_dir_operations = {
23463 + .read = generic_read_dir,
23464 + .readdir = proc_virtnet_readdir,
23467 +static struct inode_operations proc_virtnet_dir_inode_operations = {
23468 + .getattr = proc_virtnet_getattr,
23469 + .lookup = proc_virtnet_lookup,
23474 +void proc_vx_init(void)
23476 + struct proc_dir_entry *ent;
23478 + ent = proc_mkdir("virtual", 0);
23480 + ent->proc_fops = &proc_virtual_dir_operations;
23481 + ent->proc_iops = &proc_virtual_dir_inode_operations;
23483 + proc_virtual = ent;
23485 + ent = proc_mkdir("virtnet", 0);
23487 + ent->proc_fops = &proc_virtnet_dir_operations;
23488 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
23490 + proc_virtnet = ent;
23496 +/* per pid info */
23499 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
23501 + struct vx_info *vxi;
23502 + char *orig = buffer;
23504 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
23506 + vxi = task_get_vx_info(p);
23510 + buffer += sprintf(buffer, "BCaps:\t%016llx\n",
23511 + (unsigned long long)vxi->vx_bcaps);
23512 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
23513 + (unsigned long long)vxi->vx_ccaps);
23514 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
23515 + (unsigned long long)vxi->vx_flags);
23516 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
23518 + put_vx_info(vxi);
23520 + return buffer - orig;
23524 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
23526 + struct nx_info *nxi;
23527 + char *orig = buffer;
23530 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
23532 + nxi = task_get_nx_info(p);
23536 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
23537 + (unsigned long long)nxi->nx_ncaps);
23538 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
23539 + (unsigned long long)nxi->nx_flags);
23541 + for (i = 0; i < nxi->nbipv4; i++){
23542 + buffer += sprintf(buffer,
23543 + "V4Root[%d]:\t" NIPQUAD_FMT "/" NIPQUAD_FMT "\n", i,
23544 + NIPQUAD(nxi->ipv4[i]),
23545 + NIPQUAD(nxi->mask[i]));
23547 + buffer += sprintf(buffer,
23548 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
23549 + NIPQUAD(nxi->v4_bcast));
23551 + put_nx_info(nxi);
23553 + return buffer - orig;
23556 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/sched.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/sched.c
23557 --- linux-2.6.24-rc7/kernel/vserver/sched.c 1970-01-01 01:00:00 +0100
23558 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/sched.c 2007-12-13 13:25:37 +0100
23561 + * linux/kernel/vserver/sched.c
23563 + * Virtual Server: Scheduler Support
23565 + * Copyright (C) 2004-2007 Herbert Pötzl
23567 + * V0.01 adapted Sam Vilains version to 2.6.3
23568 + * V0.02 removed legacy interface
23569 + * V0.03 changed vcmds to vxi arg
23573 +#include <linux/sched.h>
23574 +#include <linux/vs_context.h>
23575 +#include <linux/vs_sched.h>
23576 +#include <linux/vserver/sched_cmd.h>
23578 +#include <asm/errno.h>
23579 +#include <asm/uaccess.h>
23581 +#define vxd_check_range(val, min, max) do { \
23582 + vxlprintk((val < min) || (val > max), \
23583 + "check_range(%ld,%ld,%ld)", \
23584 + (long)val, (long)min, (long)max, \
23585 + __FILE__, __LINE__); \
23589 +void vx_update_sched_param(struct _vx_sched *sched,
23590 + struct _vx_sched_pc *sched_pc)
23592 + unsigned int set_mask = sched->update_mask;
23594 + if (set_mask & VXSM_FILL_RATE)
23595 + sched_pc->fill_rate[0] = sched->fill_rate[0];
23596 + if (set_mask & VXSM_INTERVAL)
23597 + sched_pc->interval[0] = sched->interval[0];
23598 + if (set_mask & VXSM_FILL_RATE2)
23599 + sched_pc->fill_rate[1] = sched->fill_rate[1];
23600 + if (set_mask & VXSM_INTERVAL2)
23601 + sched_pc->interval[1] = sched->interval[1];
23602 + if (set_mask & VXSM_TOKENS)
23603 + sched_pc->tokens = sched->tokens;
23604 + if (set_mask & VXSM_TOKENS_MIN)
23605 + sched_pc->tokens_min = sched->tokens_min;
23606 + if (set_mask & VXSM_TOKENS_MAX)
23607 + sched_pc->tokens_max = sched->tokens_max;
23608 + if (set_mask & VXSM_PRIO_BIAS)
23609 + sched_pc->prio_bias = sched->prio_bias;
23611 + if (set_mask & VXSM_IDLE_TIME)
23612 + sched_pc->flags |= VXSF_IDLE_TIME;
23614 + sched_pc->flags &= ~VXSF_IDLE_TIME;
23617 + sched_pc->norm_time = jiffies;
23622 + * recalculate the context's scheduling tokens
23624 + * ret > 0 : number of tokens available
23625 + * ret < 0 : on hold, check delta_min[]
23626 + * -1 only jiffies
23627 + * -2 also idle time
23630 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
23631 + unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
23635 + int flags = sched_pc->flags;
23637 + /* how much time did pass? */
23638 + delta = *norm_time - sched_pc->norm_time;
23639 + vxd_check_range(delta, 0, INT_MAX);
23641 + if (delta >= sched_pc->interval[0]) {
23642 + long tokens, integral;
23644 + /* calc integral token part */
23645 + tokens = delta / sched_pc->interval[0];
23646 + integral = tokens * sched_pc->interval[0];
23647 + tokens *= sched_pc->fill_rate[0];
23648 +#ifdef CONFIG_VSERVER_HARDCPU
23649 + delta_min[0] = delta - integral;
23650 + vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
23652 + /* advance time */
23653 + sched_pc->norm_time += delta;
23656 + sched_pc->tokens += tokens;
23657 + sched_pc->token_time += tokens;
23659 + delta_min[0] = delta;
23661 +#ifdef CONFIG_VSERVER_IDLETIME
23662 + if (!(flags & VXSF_IDLE_TIME))
23665 + /* how much was the idle skip? */
23666 + delta = *idle_time - sched_pc->idle_time;
23667 + vxd_check_range(delta, 0, INT_MAX);
23669 + if (delta >= sched_pc->interval[1]) {
23670 + long tokens, integral;
23672 + /* calc fair share token part */
23673 + tokens = delta / sched_pc->interval[1];
23674 + integral = tokens * sched_pc->interval[1];
23675 + tokens *= sched_pc->fill_rate[1];
23676 + delta_min[1] = delta - integral;
23677 + vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
23679 + /* advance idle time */
23680 + sched_pc->idle_time += integral;
23683 + sched_pc->tokens += tokens;
23684 + sched_pc->token_time += tokens;
23686 + delta_min[1] = delta;
23690 + /* clip at maximum */
23691 + if (sched_pc->tokens > sched_pc->tokens_max)
23692 + sched_pc->tokens = sched_pc->tokens_max;
23693 + tokens = sched_pc->tokens;
23695 + if ((flags & VXSF_ONHOLD)) {
23696 + /* can we unhold? */
23697 + if (tokens >= sched_pc->tokens_min) {
23698 + flags &= ~VXSF_ONHOLD;
23699 + sched_pc->hold_ticks +=
23700 + *norm_time - sched_pc->onhold;
23704 + /* put on hold? */
23705 + if (tokens <= 0) {
23706 + flags |= VXSF_ONHOLD;
23707 + sched_pc->onhold = *norm_time;
23711 + sched_pc->flags = flags;
23715 + tokens = sched_pc->tokens_min - tokens;
23716 + sched_pc->flags = flags;
23717 + BUG_ON(tokens < 0);
23719 +#ifdef CONFIG_VSERVER_HARDCPU
23720 + /* next interval? */
23721 + if (!sched_pc->fill_rate[0])
23722 + delta_min[0] = HZ;
23723 + else if (tokens > sched_pc->fill_rate[0])
23724 + delta_min[0] += sched_pc->interval[0] *
23725 + tokens / sched_pc->fill_rate[0];
23727 + delta_min[0] = sched_pc->interval[0] - delta_min[0];
23728 + vxd_check_range(delta_min[0], 0, INT_MAX);
23730 +#ifdef CONFIG_VSERVER_IDLETIME
23731 + if (!(flags & VXSF_IDLE_TIME))
23734 + /* next interval? */
23735 + if (!sched_pc->fill_rate[1])
23736 + delta_min[1] = HZ;
23737 + else if (tokens > sched_pc->fill_rate[1])
23738 + delta_min[1] += sched_pc->interval[1] *
23739 + tokens / sched_pc->fill_rate[1];
23741 + delta_min[1] = sched_pc->interval[1] - delta_min[1];
23742 + vxd_check_range(delta_min[1], 0, INT_MAX);
23747 +#endif /* CONFIG_VSERVER_IDLETIME */
23750 +#endif /* CONFIG_VSERVER_HARDCPU */
23753 +static inline unsigned long msec_to_ticks(unsigned long msec)
23755 + return msecs_to_jiffies(msec);
23758 +static inline unsigned long ticks_to_msec(unsigned long ticks)
23760 + return jiffies_to_msecs(ticks);
23763 +static inline unsigned long ticks_to_usec(unsigned long ticks)
23765 + return jiffies_to_usecs(ticks);
23769 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
23771 + unsigned int set_mask = data->mask;
23772 + unsigned int update_mask;
23775 + /* Sanity check data values */
23776 + if (data->tokens_max <= 0)
23777 + data->tokens_max = HZ;
23778 + if (data->tokens_min < 0)
23779 + data->tokens_min = HZ / 3;
23780 + if (data->tokens_min >= data->tokens_max)
23781 + data->tokens_min = data->tokens_max;
23783 + if (data->prio_bias > MAX_PRIO_BIAS)
23784 + data->prio_bias = MAX_PRIO_BIAS;
23785 + if (data->prio_bias < MIN_PRIO_BIAS)
23786 + data->prio_bias = MIN_PRIO_BIAS;
23788 + spin_lock(&vxi->sched.tokens_lock);
23790 + /* sync up on delayed updates */
23791 + for_each_cpu_mask(cpu, vxi->sched.update)
23792 + vx_update_sched_param(&vxi->sched,
23793 + &vx_per_cpu(vxi, sched_pc, cpu));
23795 + if (set_mask & VXSM_FILL_RATE)
23796 + vxi->sched.fill_rate[0] = data->fill_rate[0];
23797 + if (set_mask & VXSM_FILL_RATE2)
23798 + vxi->sched.fill_rate[1] = data->fill_rate[1];
23799 + if (set_mask & VXSM_INTERVAL)
23800 + vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
23801 + msec_to_ticks(data->interval[0]) : data->interval[0];
23802 + if (set_mask & VXSM_INTERVAL2)
23803 + vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
23804 + msec_to_ticks(data->interval[1]) : data->interval[1];
23805 + if (set_mask & VXSM_TOKENS)
23806 + vxi->sched.tokens = data->tokens;
23807 + if (set_mask & VXSM_TOKENS_MIN)
23808 + vxi->sched.tokens_min = data->tokens_min;
23809 + if (set_mask & VXSM_TOKENS_MAX)
23810 + vxi->sched.tokens_max = data->tokens_max;
23811 + if (set_mask & VXSM_PRIO_BIAS)
23812 + vxi->sched.prio_bias = data->prio_bias;
23814 + /* Sanity check rate/interval */
23815 + for (i = 0; i < 2; i++) {
23816 + if (data->fill_rate[i] < 0)
23817 + data->fill_rate[i] = 0;
23818 + if (data->interval[i] <= 0)
23819 + data->interval[i] = HZ;
23822 + update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
23823 + update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
23824 + vxi->sched.update_mask = update_mask;
23827 + if (set_mask & VXSM_CPU_ID) {
23828 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
23829 + cpus_and(vxi->sched.update, cpu_online_map,
23830 + vxi->sched.update);
23832 + vxi->sched.update = cpu_online_map;
23834 + /* forced reload? */
23835 + if (set_mask & VXSM_FORCE) {
23836 + for_each_cpu_mask(cpu, vxi->sched.update)
23837 + vx_update_sched_param(&vxi->sched,
23838 + &vx_per_cpu(vxi, sched_pc, cpu));
23839 + vxi->sched.update = CPU_MASK_NONE;
23842 + /* on UP we update immediately */
23843 + vx_update_sched_param(&vxi->sched,
23844 + &vx_per_cpu(vxi, sched_pc, 0));
23847 + spin_unlock(&vxi->sched.tokens_lock);
23851 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
23852 +#define COPY_PRI(C) C(prio_bias)
23853 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
23854 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]); \
23855 + C(fill_rate[1]); C(interval[1]);
23857 +#define COPY_VALUE(name) vc_data.name = data->name
23859 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
23861 + struct vcmd_sched_v5 vc_data;
23863 + vc_data.mask = data->set_mask;
23864 + COPY_IDS(COPY_VALUE);
23865 + COPY_PRI(COPY_VALUE);
23866 + COPY_TOK(COPY_VALUE);
23867 + vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
23868 + vc_data.interval[0] = vc_data.interval[1] = data->interval;
23869 + return do_set_sched(vxi, &vc_data);
23872 +#ifdef CONFIG_VSERVER_LEGACY
23874 +#define COPY_MASK_V2(name, mask) \
23875 + if (vc_data.name != SCHED_KEEP) { \
23876 + vc_data_v4.name = vc_data.name; \
23877 + vc_data_v4.set_mask |= mask; \
23880 +int vc_set_sched_v2(struct vx_info *vxi, void __user *data)
23882 + struct vcmd_set_sched_v2 vc_data;
23883 + struct vcmd_set_sched_v4 vc_data_v4 = { .set_mask = 0 };
23885 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23888 + COPY_MASK_V2(fill_rate, VXSM_FILL_RATE);
23889 + COPY_MASK_V2(interval, VXSM_INTERVAL);
23890 + COPY_MASK_V2(tokens, VXSM_TOKENS);
23891 + COPY_MASK_V2(tokens_min, VXSM_TOKENS_MIN);
23892 + COPY_MASK_V2(tokens_max, VXSM_TOKENS_MAX);
23893 + vc_data_v4.bucket_id = 0;
23895 + do_set_sched_v4(vxi, &vc_data_v4);
23900 +int vc_set_sched_v3(struct vx_info *vxi, void __user *data)
23902 + struct vcmd_set_sched_v3 vc_data;
23903 + struct vcmd_set_sched_v4 vc_data_v4;
23905 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23908 + /* structures are binary compatible */
23909 + memcpy(&vc_data_v4, &vc_data, sizeof(vc_data));
23910 + vc_data_v4.set_mask &= VXSM_V3_MASK;
23911 + vc_data_v4.bucket_id = 0;
23913 + return do_set_sched_v4(vxi, &vc_data_v4);
23916 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
23918 + struct vcmd_set_sched_v4 vc_data;
23920 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23923 + return do_set_sched_v4(vxi, &vc_data);
23926 + /* latest interface is v5 */
23928 +int vc_set_sched(struct vx_info *vxi, void __user *data)
23930 + struct vcmd_sched_v5 vc_data;
23932 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23935 + return do_set_sched(vxi, &vc_data);
23939 +int vc_get_sched(struct vx_info *vxi, void __user *data)
23941 + struct vcmd_sched_v5 vc_data;
23943 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23946 + if (vc_data.mask & VXSM_CPU_ID) {
23947 + int cpu = vc_data.cpu_id;
23948 + struct _vx_sched_pc *data;
23950 + if (!cpu_possible(cpu))
23953 + data = &vx_per_cpu(vxi, sched_pc, cpu);
23954 + COPY_TOK(COPY_VALUE);
23955 + COPY_PRI(COPY_VALUE);
23956 + COPY_FRI(COPY_VALUE);
23958 + if (data->flags & VXSF_IDLE_TIME)
23959 + vc_data.mask |= VXSM_IDLE_TIME;
23961 + struct _vx_sched *data = &vxi->sched;
23963 + COPY_TOK(COPY_VALUE);
23964 + COPY_PRI(COPY_VALUE);
23965 + COPY_FRI(COPY_VALUE);
23968 + if (vc_data.mask & VXSM_MSEC) {
23969 + vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
23970 + vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
23973 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23979 +int vc_sched_info(struct vx_info *vxi, void __user *data)
23981 + struct vcmd_sched_info vc_data;
23984 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23987 + cpu = vc_data.cpu_id;
23988 + if (!cpu_possible(cpu))
23992 + struct _vx_sched_pc *sched_pc =
23993 + &vx_per_cpu(vxi, sched_pc, cpu);
23995 + vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
23996 + vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
23997 + vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
23998 + vc_data.vavavoom = sched_pc->vavavoom;
24000 + vc_data.token_usec = ticks_to_usec(1);
24002 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24007 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/sched_init.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/sched_init.h
24008 --- linux-2.6.24-rc7/kernel/vserver/sched_init.h 1970-01-01 01:00:00 +0100
24009 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/sched_init.h 2007-12-13 13:25:43 +0100
24012 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24014 + static struct lock_class_key tokens_lock_key;
24016 + /* scheduling; hard code starting values as constants */
24017 + sched->fill_rate[0] = 1;
24018 + sched->interval[0] = 4;
24019 + sched->fill_rate[1] = 1;
24020 + sched->interval[1] = 8;
24021 + sched->tokens = HZ >> 2;
24022 + sched->tokens_min = HZ >> 4;
24023 + sched->tokens_max = HZ >> 1;
24024 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
24025 + sched->prio_bias = 0;
24027 + lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24031 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24033 + sched_pc->fill_rate[0] = 1;
24034 + sched_pc->interval[0] = 4;
24035 + sched_pc->fill_rate[1] = 1;
24036 + sched_pc->interval[1] = 8;
24037 + sched_pc->tokens = HZ >> 2;
24038 + sched_pc->tokens_min = HZ >> 4;
24039 + sched_pc->tokens_max = HZ >> 1;
24040 + sched_pc->prio_bias = 0;
24041 + sched_pc->vavavoom = 0;
24042 + sched_pc->token_time = 0;
24043 + sched_pc->idle_time = 0;
24044 + sched_pc->norm_time = jiffies;
24046 + sched_pc->user_ticks = 0;
24047 + sched_pc->sys_ticks = 0;
24048 + sched_pc->hold_ticks = 0;
24051 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24057 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24061 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/sched_proc.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/sched_proc.h
24062 --- linux-2.6.24-rc7/kernel/vserver/sched_proc.h 1970-01-01 01:00:00 +0100
24063 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/sched_proc.h 2007-12-13 13:25:43 +0100
24065 +#ifndef _VX_SCHED_PROC_H
24066 +#define _VX_SCHED_PROC_H
24070 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24074 + length += sprintf(buffer,
24075 + "FillRate:\t%8d,%d\n"
24076 + "Interval:\t%8d,%d\n"
24077 + "TokensMin:\t%8d\n"
24078 + "TokensMax:\t%8d\n"
24079 + "PrioBias:\t%8d\n",
24080 + sched->fill_rate[0],
24081 + sched->fill_rate[1],
24082 + sched->interval[0],
24083 + sched->interval[1],
24084 + sched->tokens_min,
24085 + sched->tokens_max,
24086 + sched->prio_bias);
24091 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24092 + char *buffer, int cpu)
24096 + length += sprintf(buffer + length,
24097 + "cpu %d: %lld %lld %lld %ld %ld", cpu,
24098 + (unsigned long long)sched_pc->user_ticks,
24099 + (unsigned long long)sched_pc->sys_ticks,
24100 + (unsigned long long)sched_pc->hold_ticks,
24101 + sched_pc->token_time,
24102 + sched_pc->idle_time);
24103 + length += sprintf(buffer + length,
24104 + " %c%c %d %d %d %d/%d %d/%d",
24105 + (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24106 + (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24107 + sched_pc->tokens,
24108 + sched_pc->tokens_min,
24109 + sched_pc->tokens_max,
24110 + sched_pc->fill_rate[0],
24111 + sched_pc->interval[0],
24112 + sched_pc->fill_rate[1],
24113 + sched_pc->interval[1]);
24114 + length += sprintf(buffer + length,
24116 + sched_pc->prio_bias,
24117 + sched_pc->vavavoom);
24121 +#endif /* _VX_SCHED_PROC_H */
24122 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/signal.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/signal.c
24123 --- linux-2.6.24-rc7/kernel/vserver/signal.c 1970-01-01 01:00:00 +0100
24124 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/signal.c 2007-12-13 15:58:28 +0100
24127 + * linux/kernel/vserver/signal.c
24129 + * Virtual Server: Signal Support
24131 + * Copyright (C) 2003-2007 Herbert Pötzl
24133 + * V0.01 broken out from vcontext V0.05
24134 + * V0.02 changed vcmds to vxi arg
24135 + * V0.03 adjusted siginfo for kill
24139 +#include <linux/sched.h>
24141 +#include <asm/errno.h>
24142 +#include <asm/uaccess.h>
24144 +#include <linux/vs_context.h>
24145 +#include <linux/vs_pid.h>
24146 +#include <linux/vserver/signal_cmd.h>
24149 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24151 + int retval, count = 0;
24152 + struct task_struct *p;
24153 + struct siginfo *sip = SEND_SIG_PRIV;
24156 + vxdprintk(VXD_CBIT(misc, 4),
24157 + "vx_info_kill(%p[#%d],%d,%d)*",
24158 + vxi, vxi->vx_id, pid, sig);
24159 + read_lock(&tasklist_lock);
24163 + for_each_process(p) {
24166 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24167 + (pid && vxi->vx_initpid == p->pid))
24170 + err = group_send_sig_info(sig, sip, p);
24172 + if (err != -EPERM)
24178 + if (vxi->vx_initpid) {
24179 + pid = vxi->vx_initpid;
24180 + /* for now, only SIGINT to private init ... */
24181 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24182 + /* ... as long as there are tasks left */
24183 + (atomic_read(&vxi->vx_tasks) > 1))
24186 + /* fallthrough */
24188 + p = find_task_by_real_pid(pid);
24190 + if (vx_task_xid(p) == vxi->vx_id)
24191 + retval = group_send_sig_info(sig, sip, p);
24195 + read_unlock(&tasklist_lock);
24196 + vxdprintk(VXD_CBIT(misc, 4),
24197 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24198 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24202 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24204 + struct vcmd_ctx_kill_v0 vc_data;
24206 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24209 + /* special check to allow guest shutdown */
24210 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24211 + /* forbid killall pid=0 when init is present */
24212 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24213 + (vc_data.pid > 1)))
24216 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24220 +static int __wait_exit(struct vx_info *vxi)
24222 + DECLARE_WAITQUEUE(wait, current);
24225 + add_wait_queue(&vxi->vx_wait, &wait);
24226 + set_current_state(TASK_INTERRUPTIBLE);
24229 + if (vx_info_state(vxi,
24230 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24232 + if (signal_pending(current)) {
24233 + ret = -ERESTARTSYS;
24240 + set_current_state(TASK_RUNNING);
24241 + remove_wait_queue(&vxi->vx_wait, &wait);
24247 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24249 + struct vcmd_wait_exit_v0 vc_data;
24252 + ret = __wait_exit(vxi);
24253 + vc_data.reboot_cmd = vxi->reboot_cmd;
24254 + vc_data.exit_code = vxi->exit_code;
24256 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24261 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/space.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/space.c
24262 --- linux-2.6.24-rc7/kernel/vserver/space.c 1970-01-01 01:00:00 +0100
24263 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/space.c 2007-12-15 00:35:03 +0100
24266 + * linux/kernel/vserver/space.c
24268 + * Virtual Server: Context Space Support
24270 + * Copyright (C) 2003-2007 Herbert Pötzl
24272 + * V0.01 broken out from context.c 0.07
24273 + * V0.02 added task locking for namespace
24274 + * V0.03 broken out vx_enter_namespace
24275 + * V0.04 added *space support and commands
24279 +#include <linux/utsname.h>
24280 +#include <linux/sched.h>
24281 +#include <linux/vs_context.h>
24282 +#include <linux/vserver/space.h>
24283 +#include <linux/vserver/space_cmd.h>
24284 +#include <linux/dcache.h>
24285 +#include <linux/mount.h>
24286 +#include <linux/nsproxy.h>
24287 +#include <linux/user_namespace.h>
24288 +#include <linux/pid_namespace.h>
24289 +#include <linux/fs.h>
24291 +#include <asm/errno.h>
24292 +#include <asm/uaccess.h>
24295 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24296 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24297 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24298 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24299 +atomic_t vs_global_ipc_ns = ATOMIC_INIT(0);
24300 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
24301 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
24304 +/* namespace functions */
24306 +#include <linux/mnt_namespace.h>
24308 +const struct vcmd_space_mask space_mask = {
24309 + .mask = CLONE_NEWNS |
24318 + * build a new nsproxy mix
24319 + * assumes that both proxies are 'const'
24320 + * does not touch nsproxy refcounts
24321 + * will hold a reference on the result.
24324 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
24325 + struct nsproxy *new_nsproxy, unsigned long mask)
24327 + struct mnt_namespace *old_ns;
24328 + struct uts_namespace *old_uts;
24329 + struct ipc_namespace *old_ipc;
24330 + struct pid_namespace *old_pid;
24331 + struct user_namespace *old_user;
24332 + struct nsproxy *nsproxy;
24334 + nsproxy = copy_nsproxy(old_nsproxy);
24338 + if (mask & CLONE_NEWNS) {
24339 + old_ns = nsproxy->mnt_ns;
24340 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
24341 + if (nsproxy->mnt_ns)
24342 + get_mnt_ns(nsproxy->mnt_ns);
24346 + if (mask & CLONE_NEWUTS) {
24347 + old_uts = nsproxy->uts_ns;
24348 + nsproxy->uts_ns = new_nsproxy->uts_ns;
24349 + if (nsproxy->uts_ns)
24350 + get_uts_ns(nsproxy->uts_ns);
24354 + if (mask & CLONE_NEWIPC) {
24355 + old_ipc = nsproxy->ipc_ns;
24356 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
24357 + if (nsproxy->ipc_ns)
24358 + get_ipc_ns(nsproxy->ipc_ns);
24362 + if (mask & CLONE_NEWUSER) {
24363 + old_user = nsproxy->user_ns;
24364 + nsproxy->user_ns = new_nsproxy->user_ns;
24365 + if (nsproxy->user_ns)
24366 + get_user_ns(nsproxy->user_ns);
24370 + if (mask & CLONE_NEWPID) {
24371 + old_pid = nsproxy->pid_ns;
24372 + nsproxy->pid_ns = new_nsproxy->pid_ns;
24373 + if (nsproxy->pid_ns)
24374 + get_pid_ns(nsproxy->pid_ns);
24379 + put_mnt_ns(old_ns);
24381 + put_uts_ns(old_uts);
24383 + put_ipc_ns(old_ipc);
24385 + put_pid_ns(old_pid);
24387 + put_user_ns(old_user);
24394 + * merge two nsproxy structs into a new one.
24395 + * will hold a reference on the result.
24399 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
24400 + struct nsproxy *proxy, unsigned long mask)
24402 + struct nsproxy null_proxy = { .mnt_ns = NULL };
24408 + /* vs_mix_nsproxy returns with reference */
24409 + return vs_mix_nsproxy(old ? old : &null_proxy,
24412 + get_nsproxy(proxy);
24417 + * merge two fs structs into a new one.
24418 + * will take a reference on the result.
24422 +struct fs_struct *__vs_merge_fs(struct fs_struct *old,
24423 + struct fs_struct *fs, unsigned long mask)
24425 + if (!(mask & CLONE_FS)) {
24427 + atomic_inc(&old->count);
24434 + return copy_fs_struct(fs);
24438 +int vx_enter_space(struct vx_info *vxi, unsigned long mask)
24440 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
24441 + struct fs_struct *fs, *fs_cur, *fs_new;
24444 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24448 + mask = vxi->vx_nsmask;
24450 + if ((mask & vxi->vx_nsmask) != mask)
24453 + proxy = vxi->vx_nsproxy;
24456 + task_lock(current);
24457 + fs_cur = current->fs;
24458 + atomic_inc(&fs_cur->count);
24459 + proxy_cur = current->nsproxy;
24460 + get_nsproxy(proxy_cur);
24461 + task_unlock(current);
24463 + fs_new = __vs_merge_fs(fs_cur, fs, mask);
24464 + if (IS_ERR(fs_new)) {
24465 + ret = PTR_ERR(fs_new);
24469 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24470 + if (IS_ERR(proxy_new)) {
24471 + ret = PTR_ERR(proxy_new);
24475 + fs_new = xchg(¤t->fs, fs_new);
24476 + proxy_new = xchg(¤t->nsproxy, proxy_new);
24480 + put_nsproxy(proxy_new);
24483 + put_fs_struct(fs_new);
24486 + put_nsproxy(proxy_cur);
24488 + put_fs_struct(fs_cur);
24493 +int vx_set_space(struct vx_info *vxi, unsigned long mask)
24495 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
24496 + struct fs_struct *fs_vxi, *fs_cur, *fs_new;
24500 + mask = space_mask.mask;
24502 + if ((mask & space_mask.mask) != mask)
24505 + proxy_vxi = vxi->vx_nsproxy;
24506 + fs_vxi = vxi->vx_fs;
24508 + task_lock(current);
24509 + fs_cur = current->fs;
24510 + atomic_inc(&fs_cur->count);
24511 + proxy_cur = current->nsproxy;
24512 + get_nsproxy(proxy_cur);
24513 + task_unlock(current);
24515 + fs_new = __vs_merge_fs(fs_vxi, fs_cur, mask);
24516 + if (IS_ERR(fs_new)) {
24517 + ret = PTR_ERR(fs_new);
24521 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
24522 + if (IS_ERR(proxy_new)) {
24523 + ret = PTR_ERR(proxy_new);
24527 + fs_new = xchg(&vxi->vx_fs, fs_new);
24528 + proxy_new = xchg(&vxi->vx_nsproxy, proxy_new);
24529 + vxi->vx_nsmask |= mask;
24533 + put_nsproxy(proxy_new);
24536 + put_fs_struct(fs_new);
24539 + put_nsproxy(proxy_cur);
24541 + put_fs_struct(fs_cur);
24546 +int vc_enter_space(struct vx_info *vxi, void __user *data)
24548 + struct vcmd_space_mask vc_data = { .mask = 0 };
24550 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24553 + return vx_enter_space(vxi, vc_data.mask);
24556 +int vc_set_space(struct vx_info *vxi, void __user *data)
24558 + struct vcmd_space_mask vc_data = { .mask = 0 };
24560 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24563 + return vx_set_space(vxi, vc_data.mask);
24566 +int vc_get_space_mask(struct vx_info *vxi, void __user *data)
24568 + if (copy_to_user(data, &space_mask, sizeof(space_mask)))
24573 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/switch.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/switch.c
24574 --- linux-2.6.24-rc7/kernel/vserver/switch.c 1970-01-01 01:00:00 +0100
24575 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/switch.c 2007-12-13 13:25:30 +0100
24578 + * linux/kernel/vserver/switch.c
24580 + * Virtual Server: Syscall Switch
24582 + * Copyright (C) 2003-2007 Herbert Pötzl
24584 + * V0.01 syscall switch
24585 + * V0.02 added signal to context
24586 + * V0.03 added rlimit functions
24587 + * V0.04 added iattr, task/xid functions
24588 + * V0.05 added debug/history stuff
24589 + * V0.06 added compat32 layer
24590 + * V0.07 vcmd args and perms
24591 + * V0.08 added status commands
24595 +#include <linux/linkage.h>
24596 +#include <linux/sched.h>
24597 +#include <linux/compat.h>
24598 +#include <asm/errno.h>
24600 +#include <linux/vs_context.h>
24601 +#include <linux/vs_network.h>
24602 +#include <linux/vserver/switch.h>
24604 +#include "vci_config.h"
24607 +int vc_get_version(uint32_t id)
24609 +#ifdef CONFIG_VSERVER_LEGACY_VERSION
24611 + return VCI_LEGACY_VERSION;
24613 + return VCI_VERSION;
24617 +int vc_get_vci(uint32_t id)
24619 + return vci_kernel_config();
24622 +#include <linux/vserver/context_cmd.h>
24623 +#include <linux/vserver/cvirt_cmd.h>
24624 +#include <linux/vserver/cacct_cmd.h>
24625 +#include <linux/vserver/limit_cmd.h>
24626 +#include <linux/vserver/network_cmd.h>
24627 +#include <linux/vserver/sched_cmd.h>
24628 +#include <linux/vserver/debug_cmd.h>
24629 +#include <linux/vserver/inode_cmd.h>
24630 +#include <linux/vserver/dlimit_cmd.h>
24631 +#include <linux/vserver/signal_cmd.h>
24632 +#include <linux/vserver/space_cmd.h>
24634 +#include <linux/vserver/legacy.h>
24635 +#include <linux/vserver/inode.h>
24636 +#include <linux/vserver/dlimit.h>
24639 +#ifdef CONFIG_COMPAT
24640 +#define __COMPAT(name, id, data, compat) \
24641 + (compat) ? name ## _x32(id, data) : name(id, data)
24642 +#define __COMPAT_NO_ID(name, data, compat) \
24643 + (compat) ? name ## _x32(data) : name(data)
24645 +#define __COMPAT(name, id, data, compat) \
24647 +#define __COMPAT_NO_ID(name, data, compat) \
24653 +long do_vcmd(uint32_t cmd, uint32_t id,
24654 + struct vx_info *vxi, struct nx_info *nxi,
24655 + void __user *data, int compat)
24659 + case VCMD_get_version:
24660 + return vc_get_version(id);
24661 + case VCMD_get_vci:
24662 + return vc_get_vci(id);
24664 + case VCMD_task_xid:
24665 + return vc_task_xid(id, data);
24666 + case VCMD_vx_info:
24667 + return vc_vx_info(vxi, data);
24669 + case VCMD_task_nid:
24670 + return vc_task_nid(id, data);
24671 + case VCMD_nx_info:
24672 + return vc_nx_info(nxi, data);
24674 + case VCMD_set_space_v0:
24675 + /* this is version 1 */
24676 + case VCMD_set_space:
24677 + return vc_set_space(vxi, data);
24679 + case VCMD_get_space_mask:
24680 + return vc_get_space_mask(vxi, data);
24682 +#ifdef CONFIG_IA32_EMULATION
24683 + case VCMD_get_rlimit:
24684 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
24685 + case VCMD_set_rlimit:
24686 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
24688 + case VCMD_get_rlimit:
24689 + return vc_get_rlimit(vxi, data);
24690 + case VCMD_set_rlimit:
24691 + return vc_set_rlimit(vxi, data);
24693 + case VCMD_get_rlimit_mask:
24694 + return vc_get_rlimit_mask(id, data);
24695 + case VCMD_reset_minmax:
24696 + return vc_reset_minmax(vxi, data);
24698 + case VCMD_get_vhi_name:
24699 + return vc_get_vhi_name(vxi, data);
24700 + case VCMD_set_vhi_name:
24701 + return vc_set_vhi_name(vxi, data);
24703 + case VCMD_ctx_stat:
24704 + return vc_ctx_stat(vxi, data);
24705 + case VCMD_virt_stat:
24706 + return vc_virt_stat(vxi, data);
24707 + case VCMD_sock_stat:
24708 + return vc_sock_stat(vxi, data);
24709 + case VCMD_rlimit_stat:
24710 + return vc_rlimit_stat(vxi, data);
24712 + case VCMD_set_cflags:
24713 + return vc_set_cflags(vxi, data);
24714 + case VCMD_get_cflags:
24715 + return vc_get_cflags(vxi, data);
24717 + case VCMD_set_ccaps_v0:
24718 + return vc_set_ccaps_v0(vxi, data);
24719 + /* this is version 1 */
24720 + case VCMD_set_ccaps:
24721 + return vc_set_ccaps(vxi, data);
24722 + case VCMD_get_ccaps_v0:
24723 + return vc_get_ccaps_v0(vxi, data);
24724 + /* this is version 1 */
24725 + case VCMD_get_ccaps:
24726 + return vc_get_ccaps(vxi, data);
24727 + case VCMD_set_bcaps:
24728 + return vc_set_bcaps(vxi, data);
24729 + case VCMD_get_bcaps:
24730 + return vc_get_bcaps(vxi, data);
24732 + case VCMD_set_nflags:
24733 + return vc_set_nflags(nxi, data);
24734 + case VCMD_get_nflags:
24735 + return vc_get_nflags(nxi, data);
24737 + case VCMD_set_ncaps:
24738 + return vc_set_ncaps(nxi, data);
24739 + case VCMD_get_ncaps:
24740 + return vc_get_ncaps(nxi, data);
24742 +#ifdef CONFIG_VSERVER_LEGACY
24743 + case VCMD_set_sched_v2:
24744 + return vc_set_sched_v2(vxi, data);
24746 + case VCMD_set_sched_v3:
24747 + return vc_set_sched_v3(vxi, data);
24748 + case VCMD_set_sched_v4:
24749 + return vc_set_sched_v4(vxi, data);
24750 + /* this is version 5 */
24751 + case VCMD_set_sched:
24752 + return vc_set_sched(vxi, data);
24753 + case VCMD_get_sched:
24754 + return vc_get_sched(vxi, data);
24755 + case VCMD_sched_info:
24756 + return vc_sched_info(vxi, data);
24758 + case VCMD_add_dlimit:
24759 + return __COMPAT(vc_add_dlimit, id, data, compat);
24760 + case VCMD_rem_dlimit:
24761 + return __COMPAT(vc_rem_dlimit, id, data, compat);
24762 + case VCMD_set_dlimit:
24763 + return __COMPAT(vc_set_dlimit, id, data, compat);
24764 + case VCMD_get_dlimit:
24765 + return __COMPAT(vc_get_dlimit, id, data, compat);
24767 + case VCMD_ctx_kill:
24768 + return vc_ctx_kill(vxi, data);
24770 + case VCMD_wait_exit:
24771 + return vc_wait_exit(vxi, data);
24773 +#ifdef CONFIG_VSERVER_LEGACY
24774 + case VCMD_create_context:
24775 + return vc_ctx_create(id, NULL);
24778 + case VCMD_get_iattr:
24779 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
24780 + case VCMD_set_iattr:
24781 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
24783 + case VCMD_fget_iattr:
24784 + return vc_fget_iattr(id, data);
24785 + case VCMD_fset_iattr:
24786 + return vc_fset_iattr(id, data);
24788 + case VCMD_enter_space_v0:
24789 + return vc_enter_space(vxi, NULL);
24790 + /* this is version 1 */
24791 + case VCMD_enter_space:
24792 + return vc_enter_space(vxi, data);
24794 + case VCMD_ctx_create_v0:
24795 + return vc_ctx_create(id, NULL);
24796 + case VCMD_ctx_create:
24797 + return vc_ctx_create(id, data);
24798 + case VCMD_ctx_migrate_v0:
24799 + return vc_ctx_migrate(vxi, NULL);
24800 + case VCMD_ctx_migrate:
24801 + return vc_ctx_migrate(vxi, data);
24803 + case VCMD_net_create_v0:
24804 + return vc_net_create(id, NULL);
24805 + case VCMD_net_create:
24806 + return vc_net_create(id, data);
24807 + case VCMD_net_migrate:
24808 + return vc_net_migrate(nxi, data);
24809 + case VCMD_net_add:
24810 + return vc_net_add(nxi, data);
24811 + case VCMD_net_remove:
24812 + return vc_net_remove(nxi, data);
24814 +#ifdef CONFIG_VSERVER_HISTORY
24815 + case VCMD_dump_history:
24816 + return vc_dump_history(id);
24817 + case VCMD_read_history:
24818 + return __COMPAT(vc_read_history, id, data, compat);
24820 +#ifdef CONFIG_VSERVER_MONITOR
24821 + case VCMD_read_monitor:
24822 + return __COMPAT(vc_read_monitor, id, data, compat);
24824 +#ifdef CONFIG_VSERVER_LEGACY
24825 + case VCMD_new_s_context:
24826 + return vc_new_s_context(id, data);
24828 +#ifdef CONFIG_VSERVER_LEGACYNET
24829 + case VCMD_set_ipv4root:
24830 + return vc_set_ipv4root(id, data);
24833 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
24834 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
24840 +#define __VCMD(vcmd, _perm, _args, _flags) \
24841 + case VCMD_ ## vcmd: perm = _perm; \
24842 + args = _args; flags = _flags; break
24845 +#define VCA_NONE 0x00
24846 +#define VCA_VXI 0x01
24847 +#define VCA_NXI 0x02
24849 +#define VCF_NONE 0x00
24850 +#define VCF_INFO 0x01
24851 +#define VCF_ADMIN 0x02
24852 +#define VCF_ARES 0x06 /* includes admin */
24853 +#define VCF_SETUP 0x08
24855 +#define VCF_ZIDOK 0x10 /* zero id okay */
24859 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
24862 + int permit = -1, state = 0;
24863 + int perm = -1, args = 0, flags = 0;
24864 + struct vx_info *vxi = NULL;
24865 + struct nx_info *nxi = NULL;
24868 + /* unpriviledged commands */
24869 + __VCMD(get_version, 0, VCA_NONE, 0);
24870 + __VCMD(get_vci, 0, VCA_NONE, 0);
24871 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
24872 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
24874 + /* info commands */
24875 + __VCMD(task_xid, 2, VCA_NONE, 0);
24876 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
24877 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
24878 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
24879 + __VCMD(get_ccaps_v0, 3, VCA_VXI, VCF_INFO);
24880 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
24881 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
24882 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
24883 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
24885 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
24886 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
24887 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
24888 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
24890 + __VCMD(task_nid, 2, VCA_NONE, 0);
24891 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
24892 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
24893 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
24895 + __VCMD(get_iattr, 2, VCA_NONE, 0);
24896 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
24897 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
24898 + __VCMD(get_sched, 3, VCA_VXI, VCF_INFO);
24899 + __VCMD(sched_info, 3, VCA_VXI, VCF_INFO | VCF_ZIDOK);
24901 + /* lower admin commands */
24902 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
24903 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
24904 + __VCMD(ctx_create, 5, VCA_NONE, 0);
24905 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
24906 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
24907 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
24908 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
24910 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
24911 + __VCMD(net_create, 5, VCA_NONE, 0);
24912 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
24914 + /* higher admin commands */
24915 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
24916 + __VCMD(set_space_v0, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24917 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24919 + __VCMD(set_ccaps_v0, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24920 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24921 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24922 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24924 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24925 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24926 + __VCMD(set_sched, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24927 + __VCMD(set_sched_v2, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24928 + __VCMD(set_sched_v3, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24929 + __VCMD(set_sched_v4, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
24931 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
24932 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
24933 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24934 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
24936 + __VCMD(set_iattr, 7, VCA_NONE, 0);
24937 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
24938 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
24939 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
24940 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
24942 + /* debug level admin commands */
24943 +#ifdef CONFIG_VSERVER_HISTORY
24944 + __VCMD(dump_history, 9, VCA_NONE, 0);
24945 + __VCMD(read_history, 9, VCA_NONE, 0);
24947 +#ifdef CONFIG_VSERVER_MONITOR
24948 + __VCMD(read_monitor, 9, VCA_NONE, 0);
24951 + /* legacy commands */
24952 +#ifdef CONFIG_VSERVER_LEGACY
24953 + __VCMD(new_s_context, 1, VCA_NONE, 0);
24954 + __VCMD(create_context, 5, VCA_NONE, 0);
24956 +#ifdef CONFIG_VSERVER_LEGACYNET
24957 + __VCMD(set_ipv4root, 5, VCA_NONE, 0);
24963 + vxdprintk(VXD_CBIT(switch, 0),
24964 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
24965 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
24966 + VC_VERSION(cmd), id, data, compat,
24967 + perm, args, flags);
24974 +#ifdef CONFIG_VSERVER_LEGACY
24975 + if (!capable(CAP_CONTEXT) &&
24976 + /* dirty hack for capremove */
24977 + !(cmd == VCMD_new_s_context && id == -2))
24980 + if (!capable(CAP_CONTEXT))
24985 + /* moved here from the individual commands */
24987 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
24991 + /* vcmd involves resource management */
24993 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
24997 + /* various legacy exceptions */
24999 +#ifdef CONFIG_VSERVER_LEGACY
25000 + case VCMD_set_cflags:
25001 + case VCMD_set_ccaps_v0:
25003 + if (vx_check(0, VS_WATCH))
25007 + case VCMD_ctx_create_v0:
25009 + /* will go away when spectator is a cap */
25010 + case VCMD_ctx_migrate_v0:
25011 + case VCMD_ctx_migrate:
25013 + current->xid = 1;
25019 + /* will go away when spectator is a cap */
25020 + case VCMD_net_migrate:
25022 + current->nid = 1;
25028 + /* legacy special casing */
25029 + case VCMD_set_space_v0:
25034 + /* vcmds are fine by default */
25037 + /* admin type vcmds require admin ... */
25038 + if (flags & VCF_ADMIN)
25039 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25041 + /* ... but setup type vcmds override that */
25042 + if (!permit && (flags & VCF_SETUP))
25043 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25051 + if (!id && (flags & VCF_ZIDOK))
25055 + if (args & VCA_VXI) {
25056 + vxi = lookup_vx_info(id);
25060 + if ((flags & VCF_ADMIN) &&
25061 + /* special case kill for shutdown */
25062 + (cmd != VCMD_ctx_kill) &&
25063 + /* can context be administrated? */
25064 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25070 + if (args & VCA_NXI) {
25071 + nxi = lookup_nx_info(id);
25075 + if ((flags & VCF_ADMIN) &&
25076 + /* can context be administrated? */
25077 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25084 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25087 + if ((args & VCA_NXI) && nxi)
25088 + put_nx_info(nxi);
25090 + if ((args & VCA_VXI) && vxi)
25091 + put_vx_info(vxi);
25093 + vxdprintk(VXD_CBIT(switch, 1),
25094 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25095 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25096 + VC_VERSION(cmd), ret, ret, state, permit);
25101 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25103 + return do_vserver(cmd, id, data, 0);
25106 +#ifdef CONFIG_COMPAT
25109 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25111 + return do_vserver(cmd, id, data, 1);
25114 +#endif /* CONFIG_COMPAT */
25115 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/sysctl.c linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/sysctl.c
25116 --- linux-2.6.24-rc7/kernel/vserver/sysctl.c 1970-01-01 01:00:00 +0100
25117 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/sysctl.c 2007-12-15 02:33:48 +0100
25120 + * kernel/vserver/sysctl.c
25122 + * Virtual Context Support
25124 + * Copyright (C) 2004-2007 Herbert Pötzl
25126 + * V0.01 basic structure
25130 +#include <linux/errno.h>
25131 +#include <linux/module.h>
25132 +#include <linux/types.h>
25133 +#include <linux/ctype.h>
25134 +#include <linux/sysctl.h>
25135 +#include <linux/parser.h>
25136 +#include <linux/fs.h>
25138 +#include <asm/uaccess.h>
25139 +#include <asm/unistd.h>
25143 + CTL_DEBUG_ERROR = 0,
25144 + CTL_DEBUG_SWITCH = 1,
25159 +unsigned int vx_debug_switch = 0;
25160 +unsigned int vx_debug_xid = 0;
25161 +unsigned int vx_debug_nid = 0;
25162 +unsigned int vx_debug_tag = 0;
25163 +unsigned int vx_debug_net = 0;
25164 +unsigned int vx_debug_limit = 0;
25165 +unsigned int vx_debug_cres = 0;
25166 +unsigned int vx_debug_dlim = 0;
25167 +unsigned int vx_debug_quota = 0;
25168 +unsigned int vx_debug_cvirt = 0;
25169 +unsigned int vx_debug_space = 0;
25170 +unsigned int vx_debug_misc = 0;
25173 +static struct ctl_table_header *vserver_table_header;
25174 +static ctl_table vserver_root_table[];
25177 +void vserver_register_sysctl(void)
25179 + if (!vserver_table_header) {
25180 + vserver_table_header = register_sysctl_table(vserver_root_table);
25185 +void vserver_unregister_sysctl(void)
25187 + if (vserver_table_header) {
25188 + unregister_sysctl_table(vserver_table_header);
25189 + vserver_table_header = NULL;
25194 +static int proc_dodebug(ctl_table *table, int write,
25195 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
25197 + char tmpbuf[20], *p, c;
25198 + unsigned int value;
25199 + size_t left, len;
25201 + if ((*ppos && !write) || !*lenp) {
25209 + if (!access_ok(VERIFY_READ, buffer, left))
25211 + p = (char *)buffer;
25212 + while (left && __get_user(c, p) >= 0 && isspace(c))
25217 + if (left > sizeof(tmpbuf) - 1)
25219 + if (copy_from_user(tmpbuf, p, left))
25221 + tmpbuf[left] = '\0';
25223 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25224 + value = 10 * value + (*p - '0');
25225 + if (*p && !isspace(*p))
25227 + while (left && isspace(*p))
25229 + *(unsigned int *)table->data = value;
25231 + if (!access_ok(VERIFY_WRITE, buffer, left))
25233 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25236 + if (__copy_to_user(buffer, tmpbuf, len))
25238 + if ((left -= len) > 0) {
25239 + if (put_user('\n', (char *)buffer + len))
25253 +#define CTL_ENTRY(ctl, name) \
25255 + .ctl_name = ctl, \
25256 + .procname = #name, \
25257 + .data = &vx_ ## name, \
25258 + .maxlen = sizeof(int), \
25260 + .proc_handler = &proc_dodebug, \
25261 + .strategy = &sysctl_intvec, \
25262 + .extra1 = &zero, \
25265 +static ctl_table vserver_debug_table[] = {
25266 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
25267 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
25268 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
25269 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
25270 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
25271 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
25272 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
25273 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
25274 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
25275 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
25276 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
25277 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
25278 + { .ctl_name = 0 }
25281 +static ctl_table vserver_root_table[] = {
25283 + .ctl_name = CTL_VSERVER,
25284 + .procname = "vserver",
25286 + .child = vserver_debug_table
25288 + { .ctl_name = 0 }
25292 +static match_table_t tokens = {
25293 + { CTL_DEBUG_SWITCH, "switch=%x" },
25294 + { CTL_DEBUG_XID, "xid=%x" },
25295 + { CTL_DEBUG_NID, "nid=%x" },
25296 + { CTL_DEBUG_TAG, "tag=%x" },
25297 + { CTL_DEBUG_NET, "net=%x" },
25298 + { CTL_DEBUG_LIMIT, "limit=%x" },
25299 + { CTL_DEBUG_CRES, "cres=%x" },
25300 + { CTL_DEBUG_DLIM, "dlim=%x" },
25301 + { CTL_DEBUG_QUOTA, "quota=%x" },
25302 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
25303 + { CTL_DEBUG_SPACE, "space=%x" },
25304 + { CTL_DEBUG_MISC, "misc=%x" },
25305 + { CTL_DEBUG_ERROR, NULL }
25308 +#define HANDLE_CASE(id, name, val) \
25309 + case CTL_DEBUG_ ## id: \
25310 + vx_debug_ ## name = val; \
25311 + printk("vs_debug_" #name "=0x%x\n", val); \
25315 +static int __init vs_debug_setup(char *str)
25320 + printk("vs_debug_setup(%s)\n", str);
25321 + while ((p = strsep(&str, ",")) != NULL) {
25322 + substring_t args[MAX_OPT_ARGS];
25323 + unsigned int value;
25328 + token = match_token(p, tokens, args);
25329 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
25332 + HANDLE_CASE(SWITCH, switch, value);
25333 + HANDLE_CASE(XID, xid, value);
25334 + HANDLE_CASE(NID, nid, value);
25335 + HANDLE_CASE(TAG, tag, value);
25336 + HANDLE_CASE(NET, net, value);
25337 + HANDLE_CASE(LIMIT, limit, value);
25338 + HANDLE_CASE(CRES, cres, value);
25339 + HANDLE_CASE(DLIM, dlim, value);
25340 + HANDLE_CASE(QUOTA, quota, value);
25341 + HANDLE_CASE(CVIRT, cvirt, value);
25342 + HANDLE_CASE(SPACE, space, value);
25343 + HANDLE_CASE(MISC, misc, value);
25352 +__setup("vsdebug=", vs_debug_setup);
25356 +EXPORT_SYMBOL_GPL(vx_debug_switch);
25357 +EXPORT_SYMBOL_GPL(vx_debug_xid);
25358 +EXPORT_SYMBOL_GPL(vx_debug_nid);
25359 +EXPORT_SYMBOL_GPL(vx_debug_net);
25360 +EXPORT_SYMBOL_GPL(vx_debug_limit);
25361 +EXPORT_SYMBOL_GPL(vx_debug_cres);
25362 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
25363 +EXPORT_SYMBOL_GPL(vx_debug_quota);
25364 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
25365 +EXPORT_SYMBOL_GPL(vx_debug_space);
25366 +EXPORT_SYMBOL_GPL(vx_debug_misc);
25368 diff -NurpP --minimal linux-2.6.24-rc7/kernel/vserver/vci_config.h linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/vci_config.h
25369 --- linux-2.6.24-rc7/kernel/vserver/vci_config.h 1970-01-01 01:00:00 +0100
25370 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/kernel/vserver/vci_config.h 2007-12-13 13:25:26 +0100
25373 +/* interface version */
25375 +#define VCI_VERSION 0x00020200
25376 +#define VCI_LEGACY_VERSION 0x000100FF
25380 + VCI_KCBIT_NO_DYNAMIC = 0,
25381 + VCI_KCBIT_LEGACY = 1,
25382 + VCI_KCBIT_LEGACYNET = 2,
25383 + VCI_KCBIT_NGNET = 3,
25385 + VCI_KCBIT_PROC_SECURE = 4,
25386 + VCI_KCBIT_HARDCPU = 5,
25387 + VCI_KCBIT_IDLELIMIT = 6,
25388 + VCI_KCBIT_IDLETIME = 7,
25390 + VCI_KCBIT_COWBL = 8,
25391 + VCI_KCBIT_FULLCOWBL = 9,
25392 + VCI_KCBIT_SPACES = 10,
25394 + VCI_KCBIT_LEGACY_VERSION = 15,
25395 + VCI_KCBIT_DEBUG = 16,
25396 + VCI_KCBIT_HISTORY = 20,
25397 + VCI_KCBIT_TAGGED = 24,
25401 +static inline uint32_t vci_kernel_config(void)
25404 + /* various legacy options */
25405 +#ifndef CONFIG_VSERVER_DYNAMIC_IDS
25406 + (1 << VCI_KCBIT_NO_DYNAMIC) |
25408 +#ifdef CONFIG_VSERVER_LEGACY
25409 + (1 << VCI_KCBIT_LEGACY) |
25411 +#ifdef CONFIG_VSERVER_LEGACYNET
25412 + (1 << VCI_KCBIT_LEGACYNET) |
25414 +#ifdef CONFIG_VSERVER_LEGACY_VERSION
25415 + (1 << VCI_KCBIT_LEGACY_VERSION) |
25418 + /* configured features */
25419 +#ifdef CONFIG_VSERVER_PROC_SECURE
25420 + (1 << VCI_KCBIT_PROC_SECURE) |
25422 +#ifdef CONFIG_VSERVER_HARDCPU
25423 + (1 << VCI_KCBIT_HARDCPU) |
25425 +#ifdef CONFIG_VSERVER_IDLELIMIT
25426 + (1 << VCI_KCBIT_IDLELIMIT) |
25428 +#ifdef CONFIG_VSERVER_IDLETIME
25429 + (1 << VCI_KCBIT_IDLETIME) |
25431 +#ifdef CONFIG_VSERVER_COWBL
25432 + (1 << VCI_KCBIT_COWBL) |
25433 + (1 << VCI_KCBIT_FULLCOWBL) |
25435 + (1 << VCI_KCBIT_SPACES) |
25437 + /* debug options */
25438 +#ifdef CONFIG_VSERVER_DEBUG
25439 + (1 << VCI_KCBIT_DEBUG) |
25441 +#ifdef CONFIG_VSERVER_HISTORY
25442 + (1 << VCI_KCBIT_HISTORY) |
25445 + /* inode context tagging */
25446 +#if defined(CONFIG_TAGGING_NONE)
25447 + (0 << VCI_KCBIT_TAGGED) |
25448 +#elif defined(CONFIG_TAGGING_UID16)
25449 + (1 << VCI_KCBIT_TAGGED) |
25450 +#elif defined(CONFIG_TAGGING_GID16)
25451 + (2 << VCI_KCBIT_TAGGED) |
25452 +#elif defined(CONFIG_TAGGING_ID24)
25453 + (3 << VCI_KCBIT_TAGGED) |
25454 +#elif defined(CONFIG_TAGGING_INTERN)
25455 + (4 << VCI_KCBIT_TAGGED) |
25456 +#elif defined(CONFIG_TAGGING_RUNTIME)
25457 + (5 << VCI_KCBIT_TAGGED) |
25459 + (7 << VCI_KCBIT_TAGGED) |
25464 diff -NurpP --minimal linux-2.6.24-rc7/mm/filemap_xip.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/filemap_xip.c
25465 --- linux-2.6.24-rc7/mm/filemap_xip.c 2007-12-31 17:58:29 +0100
25466 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/filemap_xip.c 2007-12-31 12:34:44 +0100
25468 #include <linux/uio.h>
25469 #include <linux/rmap.h>
25470 #include <linux/sched.h>
25471 +#include <linux/vs_memory.h>
25472 #include <asm/tlbflush.h>
25475 diff -NurpP --minimal linux-2.6.24-rc7/mm/fremap.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/fremap.c
25476 --- linux-2.6.24-rc7/mm/fremap.c 2007-11-29 01:12:32 +0100
25477 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/fremap.c 2007-12-13 13:25:12 +0100
25479 #include <linux/rmap.h>
25480 #include <linux/module.h>
25481 #include <linux/syscalls.h>
25482 +#include <linux/vs_memory.h>
25484 #include <asm/mmu_context.h>
25485 #include <asm/cacheflush.h>
25486 diff -NurpP --minimal linux-2.6.24-rc7/mm/hugetlb.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/hugetlb.c
25487 --- linux-2.6.24-rc7/mm/hugetlb.c 2007-12-31 17:58:29 +0100
25488 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/hugetlb.c 2007-12-31 12:34:44 +0100
25490 #include <asm/pgtable.h>
25492 #include <linux/hugetlb.h>
25493 +#include <linux/vs_memory.h>
25494 #include "internal.h"
25496 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
25497 diff -NurpP --minimal linux-2.6.24-rc7/mm/memory.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/memory.c
25498 --- linux-2.6.24-rc7/mm/memory.c 2007-11-29 01:12:32 +0100
25499 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/memory.c 2008-01-07 03:04:39 +0100
25500 @@ -493,6 +493,9 @@ static int copy_pte_range(struct mm_stru
25504 + if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
25508 rss[1] = rss[0] = 0;
25509 dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
25510 @@ -2084,6 +2087,11 @@ static int do_swap_page(struct mm_struct
25511 count_vm_event(PGMAJFAULT);
25514 + if (!vx_rss_avail(mm, 1)) {
25515 + ret = VM_FAULT_OOM;
25519 mark_page_accessed(page);
25521 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
25522 @@ -2155,6 +2163,8 @@ static int do_anonymous_page(struct mm_s
25523 /* Allocate our own private page. */
25524 pte_unmap(page_table);
25526 + if (!vx_rss_avail(mm, 1))
25528 if (unlikely(anon_vma_prepare(vma)))
25530 page = alloc_zeroed_user_highpage_movable(vma, address);
25531 @@ -2462,6 +2472,7 @@ static inline int handle_pte_fault(struc
25535 + int ret = 0, type = VXPT_UNKNOWN;
25538 if (!pte_present(entry)) {
25539 @@ -2489,9 +2500,12 @@ static inline int handle_pte_fault(struc
25540 if (unlikely(!pte_same(*pte, entry)))
25542 if (write_access) {
25543 - if (!pte_write(entry))
25544 - return do_wp_page(mm, vma, address,
25545 + if (!pte_write(entry)) {
25546 + ret = do_wp_page(mm, vma, address,
25547 pte, pmd, ptl, entry);
25548 + type = VXPT_WRITE;
25551 entry = pte_mkdirty(entry);
25553 entry = pte_mkyoung(entry);
25554 @@ -2509,7 +2523,10 @@ static inline int handle_pte_fault(struc
25557 pte_unmap_unlock(pte, ptl);
25561 + vx_page_fault(mm, vma, type, ret);
25566 diff -NurpP --minimal linux-2.6.24-rc7/mm/mlock.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/mlock.c
25567 --- linux-2.6.24-rc7/mm/mlock.c 2007-11-29 01:02:27 +0100
25568 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/mlock.c 2007-12-13 13:25:41 +0100
25570 #include <linux/syscalls.h>
25571 #include <linux/sched.h>
25572 #include <linux/module.h>
25573 +#include <linux/vs_memory.h>
25575 int can_do_mlock(void)
25577 @@ -76,7 +77,7 @@ success:
25578 ret = make_pages_present(start, end);
25581 - mm->locked_vm -= pages;
25582 + vx_vmlocked_sub(mm, pages);
25584 if (ret == -ENOMEM)
25586 @@ -134,7 +135,7 @@ static int do_mlock(unsigned long start,
25588 asmlinkage long sys_mlock(unsigned long start, size_t len)
25590 - unsigned long locked;
25591 + unsigned long locked, grow;
25592 unsigned long lock_limit;
25593 int error = -ENOMEM;
25595 @@ -145,8 +146,10 @@ asmlinkage long sys_mlock(unsigned long
25596 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
25597 start &= PAGE_MASK;
25599 - locked = len >> PAGE_SHIFT;
25600 - locked += current->mm->locked_vm;
25601 + grow = len >> PAGE_SHIFT;
25602 + if (!vx_vmlocked_avail(current->mm, grow))
25604 + locked = current->mm->locked_vm + grow;
25606 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
25607 lock_limit >>= PAGE_SHIFT;
25608 @@ -154,6 +157,7 @@ asmlinkage long sys_mlock(unsigned long
25609 /* check against resource limits */
25610 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
25611 error = do_mlock(start, len, 1);
25613 up_write(¤t->mm->mmap_sem);
25616 @@ -213,6 +217,8 @@ asmlinkage long sys_mlockall(int flags)
25617 lock_limit >>= PAGE_SHIFT;
25620 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
25622 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
25623 capable(CAP_IPC_LOCK))
25624 ret = do_mlockall(flags);
25625 diff -NurpP --minimal linux-2.6.24-rc7/mm/mmap.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/mmap.c
25626 --- linux-2.6.24-rc7/mm/mmap.c 2007-12-31 17:58:29 +0100
25627 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/mmap.c 2007-12-31 12:34:44 +0100
25628 @@ -1192,10 +1192,10 @@ munmap_back:
25629 kmem_cache_free(vm_area_cachep, vma);
25632 - mm->total_vm += len >> PAGE_SHIFT;
25633 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25634 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
25635 if (vm_flags & VM_LOCKED) {
25636 - mm->locked_vm += len >> PAGE_SHIFT;
25637 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
25638 make_pages_present(addr, addr + len);
25640 if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
25641 @@ -1544,9 +1544,9 @@ static int acct_stack_growth(struct vm_a
25644 /* Ok, everything looks good - let it rip */
25645 - mm->total_vm += grow;
25646 + vx_vmpages_add(mm, grow);
25647 if (vma->vm_flags & VM_LOCKED)
25648 - mm->locked_vm += grow;
25649 + vx_vmlocked_add(mm, grow);
25650 vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
25653 @@ -1717,9 +1717,9 @@ static void remove_vma_list(struct mm_st
25655 long nrpages = vma_pages(vma);
25657 - mm->total_vm -= nrpages;
25658 + vx_vmpages_sub(mm, nrpages);
25659 if (vma->vm_flags & VM_LOCKED)
25660 - mm->locked_vm -= nrpages;
25661 + vx_vmlocked_sub(mm, nrpages);
25662 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
25663 vma = remove_vma(vma);
25665 @@ -1962,6 +1962,8 @@ unsigned long do_brk(unsigned long addr,
25666 lock_limit >>= PAGE_SHIFT;
25667 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
25669 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
25674 @@ -1988,7 +1990,8 @@ unsigned long do_brk(unsigned long addr,
25675 if (mm->map_count > sysctl_max_map_count)
25678 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
25679 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
25680 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
25683 /* Can we just expand an old private anonymous mapping? */
25684 @@ -2013,9 +2016,9 @@ unsigned long do_brk(unsigned long addr,
25685 vma->vm_page_prot = vm_get_page_prot(flags);
25686 vma_link(mm, vma, prev, rb_link, rb_parent);
25688 - mm->total_vm += len >> PAGE_SHIFT;
25689 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25690 if (flags & VM_LOCKED) {
25691 - mm->locked_vm += len >> PAGE_SHIFT;
25692 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
25693 make_pages_present(addr, addr + len);
25696 @@ -2044,6 +2047,11 @@ void exit_mmap(struct mm_struct *mm)
25697 free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, 0);
25698 tlb_finish_mmu(tlb, 0, end);
25700 + set_mm_counter(mm, file_rss, 0);
25701 + set_mm_counter(mm, anon_rss, 0);
25702 + vx_vmpages_sub(mm, mm->total_vm);
25703 + vx_vmlocked_sub(mm, mm->locked_vm);
25706 * Walk the list again, actually closing and freeing it,
25707 * with preemption enabled, without holding any MM locks.
25708 @@ -2083,7 +2091,8 @@ int insert_vm_struct(struct mm_struct *
25709 if (__vma && __vma->vm_start < vma->vm_end)
25711 if ((vma->vm_flags & VM_ACCOUNT) &&
25712 - security_vm_enough_memory_mm(mm, vma_pages(vma)))
25713 + (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
25714 + !vx_vmpages_avail(mm, vma_pages(vma))))
25716 vma_link(mm, vma, prev, rb_link, rb_parent);
25718 @@ -2156,6 +2165,8 @@ int may_expand_vm(struct mm_struct *mm,
25720 if (cur + npages > lim)
25722 + if (!vx_vmpages_avail(mm, npages))
25727 @@ -2226,7 +2237,6 @@ int install_special_mapping(struct mm_st
25731 - mm->total_vm += len >> PAGE_SHIFT;
25733 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
25736 diff -NurpP --minimal linux-2.6.24-rc7/mm/mremap.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/mremap.c
25737 --- linux-2.6.24-rc7/mm/mremap.c 2007-11-29 01:12:32 +0100
25738 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/mremap.c 2007-12-13 13:25:41 +0100
25740 #include <linux/highmem.h>
25741 #include <linux/security.h>
25742 #include <linux/syscalls.h>
25743 +#include <linux/vs_memory.h>
25745 #include <asm/uaccess.h>
25746 #include <asm/cacheflush.h>
25747 @@ -212,7 +213,7 @@ static unsigned long move_vma(struct vm_
25748 * If this were a serious issue, we'd add a flag to do_munmap().
25750 hiwater_vm = mm->hiwater_vm;
25751 - mm->total_vm += new_len >> PAGE_SHIFT;
25752 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
25753 vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
25755 if (do_munmap(mm, old_addr, old_len) < 0) {
25756 @@ -230,7 +231,7 @@ static unsigned long move_vma(struct vm_
25759 if (vm_flags & VM_LOCKED) {
25760 - mm->locked_vm += new_len >> PAGE_SHIFT;
25761 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
25762 if (new_len > old_len)
25763 make_pages_present(new_addr + old_len,
25764 new_addr + new_len);
25765 @@ -341,6 +342,9 @@ unsigned long do_mremap(unsigned long ad
25767 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
25769 + if (!vx_vmlocked_avail(current->mm,
25770 + (new_len - old_len) >> PAGE_SHIFT))
25773 if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
25775 @@ -369,10 +373,10 @@ unsigned long do_mremap(unsigned long ad
25776 vma_adjust(vma, vma->vm_start,
25777 addr + new_len, vma->vm_pgoff, NULL);
25779 - mm->total_vm += pages;
25780 + vx_vmpages_add(mm, pages);
25781 vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
25782 if (vma->vm_flags & VM_LOCKED) {
25783 - mm->locked_vm += pages;
25784 + vx_vmlocked_add(mm, pages);
25785 make_pages_present(addr + old_len,
25788 diff -NurpP --minimal linux-2.6.24-rc7/mm/nommu.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/nommu.c
25789 --- linux-2.6.24-rc7/mm/nommu.c 2007-12-31 17:58:29 +0100
25790 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/nommu.c 2007-12-31 12:34:44 +0100
25791 @@ -963,7 +963,7 @@ unsigned long do_mmap_pgoff(struct file
25792 realalloc += kobjsize(vma);
25793 askedalloc += sizeof(*vma);
25795 - current->mm->total_vm += len >> PAGE_SHIFT;
25796 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
25798 add_nommu_vma(vma);
25800 @@ -1089,7 +1089,7 @@ int do_munmap(struct mm_struct *mm, unsi
25803 update_hiwater_vm(mm);
25804 - mm->total_vm -= len >> PAGE_SHIFT;
25805 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
25808 show_process_blocks();
25809 @@ -1122,7 +1122,7 @@ void exit_mmap(struct mm_struct * mm)
25810 printk("Exit_mmap:\n");
25813 - mm->total_vm = 0;
25814 + vx_vmpages_sub(mm, mm->total_vm);
25816 while ((tmp = mm->context.vmlist)) {
25817 mm->context.vmlist = tmp->next;
25818 diff -NurpP --minimal linux-2.6.24-rc7/mm/oom_kill.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/oom_kill.c
25819 --- linux-2.6.24-rc7/mm/oom_kill.c 2007-11-29 01:12:32 +0100
25820 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/oom_kill.c 2007-12-13 13:25:41 +0100
25822 #include <linux/cpuset.h>
25823 #include <linux/module.h>
25824 #include <linux/notifier.h>
25825 +#include <linux/vs_memory.h>
25827 int sysctl_panic_on_oom;
25828 int sysctl_oom_kill_allocating_task;
25829 @@ -69,6 +70,12 @@ unsigned long badness(struct task_struct
25830 points = mm->total_vm;
25833 + * add points for context badness
25836 + points += vx_badness(p, mm);
25839 * After this unlock we can no longer dereference local variable `mm'
25842 @@ -159,8 +166,8 @@ unsigned long badness(struct task_struct
25846 - printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
25847 - p->pid, p->comm, points);
25848 + printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
25849 + task_pid_nr(p), p->xid, p->comm, points);
25853 @@ -278,8 +285,8 @@ static void __oom_kill_task(struct task_
25857 - printk(KERN_ERR "Killed process %d (%s)\n",
25858 - task_pid_nr(p), p->comm);
25859 + printk(KERN_ERR "Killed process %d:#%u (%s)\n",
25860 + task_pid_nr(p), p->xid, p->comm);
25863 * We give our sacrificial lamb high priority and access to
25864 @@ -356,8 +363,8 @@ static int oom_kill_process(struct task_
25868 - printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
25869 - message, task_pid_nr(p), p->comm, points);
25870 + printk(KERN_ERR "%s: kill process %d:#%u (%s) score %li or a child\n",
25871 + message, task_pid_nr(p), p->xid, p->comm, points);
25873 /* Try to kill a child first */
25874 list_for_each_entry(c, &p->children, sibling) {
25875 diff -NurpP --minimal linux-2.6.24-rc7/mm/page_alloc.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/page_alloc.c
25876 --- linux-2.6.24-rc7/mm/page_alloc.c 2007-12-31 17:58:29 +0100
25877 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/page_alloc.c 2007-12-31 12:34:44 +0100
25879 #include <linux/backing-dev.h>
25880 #include <linux/fault-inject.h>
25881 #include <linux/page-isolation.h>
25882 +#include <linux/vs_base.h>
25883 +#include <linux/vs_limit.h>
25885 #include <asm/tlbflush.h>
25886 #include <asm/div64.h>
25887 @@ -1754,6 +1756,9 @@ void si_meminfo(struct sysinfo *val)
25888 val->totalhigh = totalhigh_pages;
25889 val->freehigh = nr_free_highpages();
25890 val->mem_unit = PAGE_SIZE;
25892 + if (vx_flags(VXF_VIRT_MEM, 0))
25893 + vx_vsi_meminfo(val);
25896 EXPORT_SYMBOL(si_meminfo);
25897 @@ -1774,6 +1779,9 @@ void si_meminfo_node(struct sysinfo *val
25900 val->mem_unit = PAGE_SIZE;
25902 + if (vx_flags(VXF_VIRT_MEM, 0))
25903 + vx_vsi_meminfo(val);
25907 diff -NurpP --minimal linux-2.6.24-rc7/mm/rmap.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/rmap.c
25908 --- linux-2.6.24-rc7/mm/rmap.c 2007-12-31 17:58:29 +0100
25909 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/rmap.c 2007-12-31 12:34:44 +0100
25911 #include <linux/rcupdate.h>
25912 #include <linux/module.h>
25913 #include <linux/kallsyms.h>
25914 +#include <linux/vs_memory.h>
25916 #include <asm/tlbflush.h>
25918 diff -NurpP --minimal linux-2.6.24-rc7/mm/shmem.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/shmem.c
25919 --- linux-2.6.24-rc7/mm/shmem.c 2007-12-31 17:58:29 +0100
25920 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/shmem.c 2007-12-31 12:34:44 +0100
25922 #include <asm/pgtable.h>
25924 /* This magic number is used in glibc for posix shared memory */
25925 -#define TMPFS_MAGIC 0x01021994
25927 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
25928 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
25929 @@ -1723,7 +1722,7 @@ static int shmem_statfs(struct dentry *d
25931 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
25933 - buf->f_type = TMPFS_MAGIC;
25934 + buf->f_type = TMPFS_SUPER_MAGIC;
25935 buf->f_bsize = PAGE_CACHE_SIZE;
25936 buf->f_namelen = NAME_MAX;
25937 spin_lock(&sbinfo->stat_lock);
25938 @@ -2288,7 +2287,7 @@ static int shmem_fill_super(struct super
25939 sb->s_maxbytes = SHMEM_MAX_BYTES;
25940 sb->s_blocksize = PAGE_CACHE_SIZE;
25941 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
25942 - sb->s_magic = TMPFS_MAGIC;
25943 + sb->s_magic = TMPFS_SUPER_MAGIC;
25944 sb->s_op = &shmem_ops;
25945 sb->s_time_gran = 1;
25946 #ifdef CONFIG_TMPFS_POSIX_ACL
25947 diff -NurpP --minimal linux-2.6.24-rc7/mm/slab.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/slab.c
25948 --- linux-2.6.24-rc7/mm/slab.c 2008-01-11 12:00:51 +0100
25949 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/slab.c 2008-01-11 04:30:10 +0100
25950 @@ -509,6 +509,8 @@ struct kmem_cache {
25951 #define STATS_INC_FREEMISS(x) do { } while (0)
25954 +#include "slab_vs.h"
25959 @@ -3342,6 +3344,7 @@ retry:
25961 obj = slab_get_obj(cachep, slabp, nodeid);
25962 check_slabp(cachep, slabp);
25963 + vx_slab_alloc(cachep, flags);
25964 l3->free_objects--;
25965 /* move slabp to correct slabp list: */
25966 list_del(&slabp->list);
25967 @@ -3414,6 +3417,7 @@ __cache_alloc_node(struct kmem_cache *ca
25968 /* ___cache_alloc_node can fall back to other nodes */
25969 ptr = ____cache_alloc_node(cachep, flags, nodeid);
25971 + vx_slab_alloc(cachep, flags);
25972 local_irq_restore(save_flags);
25973 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
25975 @@ -3585,6 +3589,7 @@ static inline void __cache_free(struct k
25978 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
25979 + vx_slab_free(cachep);
25982 * Skip calling cache_free_alien() when the platform is not numa.
25983 diff -NurpP --minimal linux-2.6.24-rc7/mm/slab_vs.h linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/slab_vs.h
25984 --- linux-2.6.24-rc7/mm/slab_vs.h 1970-01-01 01:00:00 +0100
25985 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/slab_vs.h 2007-12-13 13:25:42 +0100
25988 +#include <linux/vserver/context.h>
25990 +#include <linux/vs_context.h>
25993 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
25995 + int what = gfp_zone(cachep->gfpflags);
25997 + if (!current->vx_info)
26000 + atomic_add(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26004 +void vx_slab_free(struct kmem_cache *cachep)
26006 + int what = gfp_zone(cachep->gfpflags);
26008 + if (!current->vx_info)
26011 + atomic_sub(cachep->buffer_size, ¤t->vx_info->cacct.slab[what]);
26014 diff -NurpP --minimal linux-2.6.24-rc7/mm/swapfile.c linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/swapfile.c
26015 --- linux-2.6.24-rc7/mm/swapfile.c 2007-11-29 01:02:27 +0100
26016 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/mm/swapfile.c 2007-12-13 13:25:37 +0100
26018 #include <asm/pgtable.h>
26019 #include <asm/tlbflush.h>
26020 #include <linux/swapops.h>
26021 +#include <linux/vs_base.h>
26022 +#include <linux/vs_memory.h>
26024 DEFINE_SPINLOCK(swap_lock);
26025 unsigned int nr_swapfiles;
26026 @@ -1712,6 +1714,8 @@ void si_swapinfo(struct sysinfo *val)
26027 val->freeswap = nr_swap_pages + nr_to_be_unused;
26028 val->totalswap = total_swap_pages + nr_to_be_unused;
26029 spin_unlock(&swap_lock);
26030 + if (vx_flags(VXF_VIRT_MEM, 0))
26031 + vx_vsi_swapinfo(val);
26035 diff -NurpP --minimal linux-2.6.24-rc7/net/core/dev.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/core/dev.c
26036 --- linux-2.6.24-rc7/net/core/dev.c 2008-01-11 12:00:51 +0100
26037 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/core/dev.c 2008-01-11 04:30:11 +0100
26038 @@ -119,6 +119,8 @@
26039 #include <linux/err.h>
26040 #include <linux/ctype.h>
26041 #include <linux/if_arp.h>
26042 +#include <linux/vs_context.h> /* remove with NXF_HIDE_NETIF */
26043 +#include <linux/vs_network.h>
26045 #include "net-sysfs.h"
26047 @@ -2327,6 +2329,9 @@ static int dev_ifconf(struct net *net, c
26050 for_each_netdev(net, dev) {
26051 + if (vx_flags(VXF_HIDE_NETIF, 0) &&
26052 + !dev_in_nx_info(dev, current->nx_info))
26054 for (i = 0; i < NPROTO; i++) {
26055 if (gifconf_list[i]) {
26057 @@ -2392,6 +2397,10 @@ void dev_seq_stop(struct seq_file *seq,
26058 static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
26060 struct net_device_stats *stats = dev->get_stats(dev);
26061 + struct nx_info *nxi = current->nx_info;
26063 + if (vx_flags(VXF_HIDE_NETIF, 0) && !dev_in_nx_info(dev, nxi))
26066 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26067 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26068 diff -NurpP --minimal linux-2.6.24-rc7/net/core/rtnetlink.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/core/rtnetlink.c
26069 --- linux-2.6.24-rc7/net/core/rtnetlink.c 2007-11-29 01:12:35 +0100
26070 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/core/rtnetlink.c 2007-12-13 13:25:31 +0100
26072 #include <linux/mutex.h>
26073 #include <linux/if_addr.h>
26074 #include <linux/nsproxy.h>
26075 +#include <linux/vs_context.h> /* remove with NXF_HIDE_NETIF */
26077 #include <asm/uaccess.h>
26078 #include <asm/system.h>
26079 @@ -702,6 +703,9 @@ static int rtnl_dump_ifinfo(struct sk_bu
26082 for_each_netdev(net, dev) {
26083 + if (vx_info_flags(skb->sk->sk_vx_info, VXF_HIDE_NETIF, 0) &&
26084 + !dev_in_nx_info(dev, skb->sk->sk_nx_info))
26088 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26089 diff -NurpP --minimal linux-2.6.24-rc7/net/core/sock.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/core/sock.c
26090 --- linux-2.6.24-rc7/net/core/sock.c 2007-11-29 01:12:35 +0100
26091 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/core/sock.c 2007-12-13 13:25:30 +0100
26092 @@ -126,6 +126,9 @@
26093 #include <linux/ipsec.h>
26095 #include <linux/filter.h>
26096 +#include <linux/vs_socket.h>
26097 +#include <linux/vs_limit.h>
26098 +#include <linux/vs_context.h>
26101 #include <net/tcp.h>
26102 @@ -889,6 +892,8 @@ static struct sock *sk_prot_alloc(struct
26103 if (!try_module_get(prot->owner))
26106 + sock_vx_init(sk);
26107 + sock_nx_init(sk);
26111 @@ -966,6 +971,11 @@ void sk_free(struct sock *sk)
26112 __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
26114 put_net(sk->sk_net);
26116 + clr_vx_info(&sk->sk_vx_info);
26118 + clr_nx_info(&sk->sk_nx_info);
26120 sk_prot_free(sk->sk_prot_creator, sk);
26123 @@ -981,6 +991,8 @@ struct sock *sk_clone(const struct sock
26126 get_net(newsk->sk_net);
26127 + sock_vx_init(newsk);
26128 + sock_nx_init(newsk);
26129 sk_node_init(&newsk->sk_node);
26130 sock_lock_init(newsk);
26131 bh_lock_sock(newsk);
26132 @@ -1027,6 +1039,12 @@ struct sock *sk_clone(const struct sock
26133 newsk->sk_priority = 0;
26134 atomic_set(&newsk->sk_refcnt, 2);
26136 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26137 + newsk->sk_xid = sk->sk_xid;
26138 + vx_sock_inc(newsk);
26139 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26140 + newsk->sk_nid = sk->sk_nid;
26143 * Increment the counter in the same struct proto as the master
26144 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26145 @@ -1610,6 +1628,11 @@ void sock_init_data(struct socket *sock,
26147 sk->sk_stamp = ktime_set(-1L, -1L);
26149 + set_vx_info(&sk->sk_vx_info, current->vx_info);
26150 + sk->sk_xid = vx_current_xid();
26152 + set_nx_info(&sk->sk_nx_info, current->nx_info);
26153 + sk->sk_nid = nx_current_nid();
26154 atomic_set(&sk->sk_refcnt, 1);
26157 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/af_inet.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/af_inet.c
26158 --- linux-2.6.24-rc7/net/ipv4/af_inet.c 2007-11-29 01:12:36 +0100
26159 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/af_inet.c 2007-12-13 13:25:43 +0100
26160 @@ -115,6 +115,7 @@
26161 #ifdef CONFIG_IP_MROUTE
26162 #include <linux/mroute.h>
26164 +#include <linux/vs_limit.h>
26166 DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly;
26168 @@ -311,9 +312,11 @@ lookup_protocol:
26172 + if ((protocol == IPPROTO_ICMP) && vx_ccaps(VXC_RAW_ICMP))
26174 if (answer->capability > 0 && !capable(answer->capability))
26175 goto out_rcu_unlock;
26178 sock->ops = answer->ops;
26179 answer_prot = answer->prot;
26180 answer_no_check = answer->no_check;
26181 @@ -430,6 +433,10 @@ int inet_bind(struct socket *sock, struc
26182 unsigned short snum;
26185 + __u32 s_addr; /* Address used for validation */
26186 + __u32 s_addr1; /* Address used for socket */
26187 + __u32 s_addr2; /* Broadcast address for the socket */
26188 + struct nx_info *nxi = sk->sk_nx_info;
26190 /* If the socket has its own bind function then use it. (RAW) */
26191 if (sk->sk_prot->bind) {
26192 @@ -440,7 +447,40 @@ int inet_bind(struct socket *sock, struc
26193 if (addr_len < sizeof(struct sockaddr_in))
26196 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
26197 + s_addr = addr->sin_addr.s_addr;
26198 + s_addr1 = s_addr;
26199 + s_addr2 = 0xffffffffl;
26201 + vxdprintk(VXD_CBIT(net, 3),
26202 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
26203 + sk, sk->sk_nx_info, sk->sk_socket,
26204 + (sk->sk_socket?sk->sk_socket->flags:0),
26205 + NIPQUAD(s_addr));
26207 + __u32 v4_bcast = nxi->v4_bcast;
26208 + __u32 ipv4root = nxi->ipv4[0];
26209 + int nbipv4 = nxi->nbipv4;
26211 + if (s_addr == 0) {
26212 + /* bind to any for 1-n */
26213 + s_addr = ipv4root;
26214 + s_addr1 = (nbipv4 > 1) ? 0 : s_addr;
26215 + s_addr2 = v4_bcast;
26216 + } else if (s_addr == IPI_LOOPBACK) {
26217 + /* rewrite localhost to ipv4root */
26218 + s_addr = ipv4root;
26219 + s_addr1 = ipv4root;
26220 + } else if (s_addr != v4_bcast) {
26221 + /* normal address bind */
26222 + if (!addr_in_nx_info(nxi, s_addr))
26223 + return -EADDRNOTAVAIL;
26226 + chk_addr_ret = inet_addr_type(s_addr);
26228 + vxdprintk(VXD_CBIT(net, 3),
26229 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT ", " NIPQUAD_FMT,
26230 + sk, NIPQUAD(s_addr), NIPQUAD(s_addr1), NIPQUAD(s_addr2));
26232 /* Not specified by any standard per-se, however it breaks too
26233 * many applications when removed. It is unfortunate since
26234 @@ -452,7 +492,7 @@ int inet_bind(struct socket *sock, struc
26235 err = -EADDRNOTAVAIL;
26236 if (!sysctl_ip_nonlocal_bind &&
26238 - addr->sin_addr.s_addr != INADDR_ANY &&
26239 + s_addr != INADDR_ANY &&
26240 chk_addr_ret != RTN_LOCAL &&
26241 chk_addr_ret != RTN_MULTICAST &&
26242 chk_addr_ret != RTN_BROADCAST)
26243 @@ -477,7 +517,8 @@ int inet_bind(struct socket *sock, struc
26244 if (sk->sk_state != TCP_CLOSE || inet->num)
26245 goto out_release_sock;
26247 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
26248 + inet->rcv_saddr = inet->saddr = s_addr1;
26249 + inet->rcv_saddr2 = s_addr2;
26250 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26251 inet->saddr = 0; /* Use device */
26253 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/devinet.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/devinet.c
26254 --- linux-2.6.24-rc7/net/ipv4/devinet.c 2008-01-11 12:00:52 +0100
26255 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/devinet.c 2008-01-11 04:30:11 +0100
26257 #include <linux/sysctl.h>
26259 #include <linux/kmod.h>
26260 +#include <linux/vs_context.h>
26262 #include <net/arp.h>
26263 #include <net/ip.h>
26264 @@ -673,6 +674,9 @@ int devinet_ioctl(unsigned int cmd, void
26267 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
26268 + struct nx_info *nxi = current->nx_info;
26269 + int hide_netif = vx_flags(VXF_HIDE_NETIF, 0);
26271 if (tryaddrmatch) {
26272 /* Matthias Andree */
26273 /* compare label and address (4.4BSD style) */
26274 @@ -681,6 +685,8 @@ int devinet_ioctl(unsigned int cmd, void
26275 This is checked above. */
26276 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26277 ifap = &ifa->ifa_next) {
26278 + if (hide_netif && !ifa_in_nx_info(ifa, nxi))
26280 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26281 sin_orig.sin_addr.s_addr ==
26282 ifa->ifa_address) {
26283 @@ -693,9 +699,12 @@ int devinet_ioctl(unsigned int cmd, void
26284 comparing just the label */
26286 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26287 - ifap = &ifa->ifa_next)
26288 + ifap = &ifa->ifa_next) {
26289 + if (hide_netif && !ifa_in_nx_info(ifa, nxi))
26291 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26297 @@ -846,6 +855,9 @@ static int inet_gifconf(struct net_devic
26300 for (; ifa; ifa = ifa->ifa_next) {
26301 + if (vx_flags(VXF_HIDE_NETIF, 0) &&
26302 + !ifa_in_nx_info(ifa, current->nx_info))
26305 done += sizeof(ifr);
26307 @@ -1178,6 +1190,7 @@ static int inet_dump_ifaddr(struct sk_bu
26308 struct net_device *dev;
26309 struct in_device *in_dev;
26310 struct in_ifaddr *ifa;
26311 + struct sock *sk = skb->sk;
26312 int s_ip_idx, s_idx = cb->args[0];
26314 s_ip_idx = ip_idx = cb->args[1];
26315 @@ -1192,6 +1205,9 @@ static int inet_dump_ifaddr(struct sk_bu
26317 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26318 ifa = ifa->ifa_next, ip_idx++) {
26319 + if (sk && vx_info_flags(sk->sk_vx_info, VXF_HIDE_NETIF, 0) &&
26320 + !ifa_in_nx_info(ifa, sk->sk_nx_info))
26322 if (ip_idx < s_ip_idx)
26324 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
26325 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/fib_hash.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/fib_hash.c
26326 --- linux-2.6.24-rc7/net/ipv4/fib_hash.c 2007-11-29 01:12:36 +0100
26327 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/fib_hash.c 2007-12-13 13:25:31 +0100
26329 #include <linux/skbuff.h>
26330 #include <linux/netlink.h>
26331 #include <linux/init.h>
26332 +#include <linux/vs_context.h>
26334 #include <net/net_namespace.h>
26335 #include <net/ip.h>
26336 @@ -983,6 +984,8 @@ static unsigned fib_flag_trans(int type,
26340 +extern int dev_in_nx_info(struct net_device *, struct nx_info *);
26343 * This outputs /proc/net/route.
26345 @@ -1013,7 +1016,8 @@ static int fib_seq_show(struct seq_file
26346 prefix = f->fn_key;
26347 mask = FZ_MASK(iter->zone);
26348 flags = fib_flag_trans(fa->fa_type, mask, fi);
26350 + if (fi && (!vx_flags(VXF_HIDE_NETIF, 0) ||
26351 + dev_in_nx_info(fi->fib_dev, current->nx_info)))
26352 snprintf(bf, sizeof(bf),
26353 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
26354 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
26355 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/inet_connection_sock.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/inet_connection_sock.c
26356 --- linux-2.6.24-rc7/net/ipv4/inet_connection_sock.c 2007-11-29 01:12:36 +0100
26357 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/inet_connection_sock.c 2007-12-13 13:25:30 +0100
26358 @@ -50,7 +50,6 @@ EXPORT_SYMBOL(inet_get_local_port_range)
26359 int inet_csk_bind_conflict(const struct sock *sk,
26360 const struct inet_bind_bucket *tb)
26362 - const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
26364 struct hlist_node *node;
26365 int reuse = sk->sk_reuse;
26366 @@ -63,9 +62,8 @@ int inet_csk_bind_conflict(const struct
26367 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
26368 if (!reuse || !sk2->sk_reuse ||
26369 sk2->sk_state == TCP_LISTEN) {
26370 - const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
26371 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
26372 - sk2_rcv_saddr == sk_rcv_saddr)
26373 + if (nx_addr_conflict(sk->sk_nx_info,
26374 + inet_rcv_saddr(sk), sk2))
26378 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/inet_diag.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/inet_diag.c
26379 --- linux-2.6.24-rc7/net/ipv4/inet_diag.c 2007-12-31 17:58:29 +0100
26380 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/inet_diag.c 2007-12-31 12:34:46 +0100
26381 @@ -729,6 +729,8 @@ static int inet_diag_dump(struct sk_buff
26382 sk_for_each(sk, node, &hashinfo->listening_hash[i]) {
26383 struct inet_sock *inet = inet_sk(sk);
26385 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26390 @@ -790,6 +792,8 @@ skip_listen_ht:
26391 sk_for_each(sk, node, &head->chain) {
26392 struct inet_sock *inet = inet_sk(sk);
26394 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26398 if (!(r->idiag_states & (1 << sk->sk_state)))
26399 @@ -814,6 +818,8 @@ next_normal:
26400 inet_twsk_for_each(tw, node,
26403 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26407 if (r->id.idiag_sport != tw->tw_sport &&
26408 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/inet_hashtables.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/inet_hashtables.c
26409 --- linux-2.6.24-rc7/net/ipv4/inet_hashtables.c 2007-11-29 01:12:36 +0100
26410 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/inet_hashtables.c 2007-12-13 13:25:30 +0100
26411 @@ -140,11 +140,10 @@ static struct sock *inet_lookup_listener
26412 const __be32 rcv_saddr = inet->rcv_saddr;
26413 int score = sk->sk_family == PF_INET ? 1 : 0;
26416 - if (rcv_saddr != daddr)
26418 + if (inet_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
26423 if (sk->sk_bound_dev_if) {
26424 if (sk->sk_bound_dev_if != dif)
26426 @@ -175,7 +174,7 @@ struct sock *__inet_lookup_listener(stru
26427 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
26429 if (inet->num == hnum && !sk->sk_node.next &&
26430 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
26431 + inet_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
26432 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
26433 !sk->sk_bound_dev_if)
26435 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/netfilter.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/netfilter.c
26436 --- linux-2.6.24-rc7/net/ipv4/netfilter.c 2007-11-29 01:12:36 +0100
26437 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/netfilter.c 2007-12-13 17:05:46 +0100
26439 #include <linux/netfilter_ipv4.h>
26440 #include <linux/ip.h>
26441 #include <linux/skbuff.h>
26442 -#include <net/route.h>
26443 +// #include <net/route.h>
26444 #include <net/xfrm.h>
26445 #include <net/ip.h>
26447 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/raw.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/raw.c
26448 --- linux-2.6.24-rc7/net/ipv4/raw.c 2007-11-29 01:12:36 +0100
26449 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/raw.c 2007-12-13 13:25:31 +0100
26450 @@ -102,6 +102,27 @@ static void raw_v4_unhash(struct sock *s
26451 write_unlock_bh(&raw_v4_lock);
26456 + * Check if a given address matches for a socket
26458 + * nxi: the socket's nx_info if any
26459 + * addr: to be verified address
26460 + * saddr/baddr: socket addresses
26462 +static inline int raw_addr_match (
26463 + struct nx_info *nxi,
26468 + if (addr && (saddr == addr || baddr == addr))
26471 + return addr_in_nx_info(nxi, addr);
26475 struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
26476 __be32 raddr, __be32 laddr,
26478 @@ -113,7 +134,8 @@ struct sock *__raw_v4_lookup(struct sock
26480 if (inet->num == num &&
26481 !(inet->daddr && inet->daddr != raddr) &&
26482 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
26483 + raw_addr_match(sk->sk_nx_info, laddr,
26484 + inet->rcv_saddr, inet->rcv_saddr2) &&
26485 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
26486 goto found; /* gotcha */
26488 @@ -318,6 +340,11 @@ static int raw_send_hdrinc(struct sock *
26489 icmp_out_count(((struct icmphdr *)
26490 skb_transport_header(skb))->type);
26493 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW)
26494 + && (!addr_in_nx_info(sk->sk_nx_info, iph->saddr)))
26497 err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
26500 @@ -329,6 +356,7 @@ out:
26507 IP_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
26508 @@ -495,6 +523,12 @@ static int raw_sendmsg(struct kiocb *ioc
26511 security_sk_classify_flow(sk, &fl);
26512 + if (sk->sk_nx_info) {
26513 + err = ip_find_src(sk->sk_nx_info, &rt, &fl);
26518 err = ip_route_output_flow(&rt, &fl, sk, 1);
26521 @@ -802,7 +836,8 @@ static struct sock *raw_get_first(struct
26522 struct hlist_node *node;
26524 sk_for_each(sk, node, &raw_v4_htable[state->bucket])
26525 - if (sk->sk_family == PF_INET)
26526 + if (sk->sk_family == PF_INET &&
26527 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26531 @@ -818,7 +853,8 @@ static struct sock *raw_get_next(struct
26535 - } while (sk && sk->sk_family != PF_INET);
26536 + } while (sk && (sk->sk_family != PF_INET ||
26537 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
26539 if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
26540 sk = sk_head(&raw_v4_htable[state->bucket]);
26541 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/tcp.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/tcp.c
26542 --- linux-2.6.24-rc7/net/ipv4/tcp.c 2007-11-29 01:12:36 +0100
26543 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/tcp.c 2007-12-13 13:25:25 +0100
26544 @@ -259,6 +259,7 @@
26545 #include <linux/cache.h>
26546 #include <linux/err.h>
26547 #include <linux/crypto.h>
26548 +#include <linux/in.h>
26550 #include <net/icmp.h>
26551 #include <net/tcp.h>
26552 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/tcp_ipv4.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/tcp_ipv4.c
26553 --- linux-2.6.24-rc7/net/ipv4/tcp_ipv4.c 2007-12-31 17:58:32 +0100
26554 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/tcp_ipv4.c 2007-12-31 12:34:47 +0100
26555 @@ -1979,6 +1979,12 @@ static void *listening_get_next(struct s
26556 req = req->dl_next;
26559 + vxdprintk(VXD_CBIT(net, 6),
26560 + "sk,req: %p [#%d] (from %d)", req->sk,
26561 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
26563 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
26565 if (req->rsk_ops->family == st->family) {
26568 @@ -2003,6 +2009,10 @@ get_req:
26571 sk_for_each_from(sk, node) {
26572 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
26573 + sk, sk->sk_nid, nx_current_nid());
26574 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26576 if (sk->sk_family == st->family) {
26579 @@ -2052,18 +2062,26 @@ static void *established_get_first(struc
26581 read_lock_bh(lock);
26582 sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
26583 - if (sk->sk_family != st->family) {
26584 + vxdprintk(VXD_CBIT(net, 6),
26585 + "sk,egf: %p [#%d] (from %d)",
26586 + sk, sk->sk_nid, nx_current_nid());
26587 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26589 + if (sk->sk_family != st->family)
26595 st->state = TCP_SEQ_STATE_TIME_WAIT;
26596 inet_twsk_for_each(tw, node,
26597 &tcp_hashinfo.ehash[st->bucket].twchain) {
26598 - if (tw->tw_family != st->family) {
26599 + vxdprintk(VXD_CBIT(net, 6),
26600 + "tw: %p [#%d] (from %d)",
26601 + tw, tw->tw_nid, nx_current_nid());
26602 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26604 + if (tw->tw_family != st->family)
26610 @@ -2087,7 +2105,8 @@ static void *established_get_next(struct
26614 - while (tw && tw->tw_family != st->family) {
26615 + while (tw && (tw->tw_family != st->family ||
26616 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
26620 @@ -2108,6 +2127,11 @@ get_tw:
26623 sk_for_each_from(sk, node) {
26624 + vxdprintk(VXD_CBIT(net, 6),
26625 + "sk,egn: %p [#%d] (from %d)",
26626 + sk, sk->sk_nid, nx_current_nid());
26627 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26629 if (sk->sk_family == st->family)
26632 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/tcp_minisocks.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/tcp_minisocks.c
26633 --- linux-2.6.24-rc7/net/ipv4/tcp_minisocks.c 2007-11-29 01:12:36 +0100
26634 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/tcp_minisocks.c 2007-12-13 13:25:30 +0100
26636 #include <net/inet_common.h>
26637 #include <net/xfrm.h>
26639 +#include <linux/vs_limit.h>
26640 +#include <linux/vs_socket.h>
26641 +#include <linux/vs_context.h>
26643 #ifdef CONFIG_SYSCTL
26644 #define SYNC_INIT 0 /* let the user enable it */
26646 @@ -293,6 +297,11 @@ void tcp_time_wait(struct sock *sk, int
26647 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
26648 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
26650 + tw->tw_xid = sk->sk_xid;
26651 + tw->tw_vx_info = NULL;
26652 + tw->tw_nid = sk->sk_nid;
26653 + tw->tw_nx_info = NULL;
26655 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
26656 if (tw->tw_family == PF_INET6) {
26657 struct ipv6_pinfo *np = inet6_sk(sk);
26658 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv4/udp.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/udp.c
26659 --- linux-2.6.24-rc7/net/ipv4/udp.c 2007-11-29 01:12:37 +0100
26660 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv4/udp.c 2007-12-13 13:25:52 +0100
26661 @@ -230,11 +230,8 @@ int udp_get_port(struct sock *sk, unsign
26663 int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26665 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
26667 return ( !ipv6_only_sock(sk2) &&
26668 - (!inet1->rcv_saddr || !inet2->rcv_saddr ||
26669 - inet1->rcv_saddr == inet2->rcv_saddr ));
26670 + nx_addr_conflict(sk1->sk_nx_info, inet_rcv_saddr(sk1), sk2));
26673 static inline int udp_v4_get_port(struct sock *sk, unsigned short snum)
26674 @@ -255,15 +252,22 @@ static struct sock *__udp4_lib_lookup(__
26677 read_lock(&udp_hash_lock);
26679 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
26680 struct inet_sock *inet = inet_sk(sk);
26682 if (sk->sk_hash == hnum && !ipv6_only_sock(sk)) {
26683 int score = (sk->sk_family == PF_INET ? 1 : 0);
26685 if (inet->rcv_saddr) {
26686 if (inet->rcv_saddr != daddr)
26689 + } else if (sk->sk_nx_info) {
26690 + if (addr_in_nx_info(sk->sk_nx_info, daddr))
26696 if (inet->daddr != saddr)
26697 @@ -289,6 +293,7 @@ static struct sock *__udp4_lib_lookup(__
26704 read_unlock(&udp_hash_lock);
26705 @@ -310,7 +315,8 @@ static inline struct sock *udp_v4_mcast_
26706 if (s->sk_hash != hnum ||
26707 (inet->daddr && inet->daddr != rmt_addr) ||
26708 (inet->dport != rmt_port && inet->dport) ||
26709 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
26710 + (inet->rcv_saddr && inet->rcv_saddr != loc_addr &&
26711 + inet->rcv_saddr2 && inet->rcv_saddr2 != loc_addr) ||
26712 ipv6_only_sock(s) ||
26713 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
26715 @@ -642,7 +648,20 @@ int udp_sendmsg(struct kiocb *iocb, stru
26716 .uli_u = { .ports =
26717 { .sport = inet->sport,
26718 .dport = dport } } };
26719 + struct nx_info *nxi = sk->sk_nx_info;
26721 security_sk_classify_flow(sk, &fl);
26723 + err = ip_find_src(nxi, &rt, &fl);
26726 + if (daddr == IPI_LOOPBACK && !nx_check(0, VS_ADMIN))
26727 + daddr = fl.fl4_dst = nxi->ipv4[0];
26728 +#ifdef CONFIG_VSERVER_REMAP_SADDR
26729 + if (saddr == IPI_LOOPBACK && !nx_check(0, VS_ADMIN))
26730 + saddr = fl.fl4_src = nxi->ipv4[0];
26733 err = ip_route_output_flow(&rt, &fl, sk, 1);
26735 if (err == -ENETUNREACH)
26736 @@ -1468,7 +1487,8 @@ static struct sock *udp_get_first(struct
26737 for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
26738 struct hlist_node *node;
26739 sk_for_each(sk, node, state->hashtable + state->bucket) {
26740 - if (sk->sk_family == state->family)
26741 + if (sk->sk_family == state->family &&
26742 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26746 @@ -1485,7 +1505,8 @@ static struct sock *udp_get_next(struct
26750 - } while (sk && sk->sk_family != state->family);
26751 + } while (sk && (sk->sk_family != state->family ||
26752 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
26754 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
26755 sk = sk_head(state->hashtable + state->bucket);
26756 diff -NurpP --minimal linux-2.6.24-rc7/net/ipv6/addrconf.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv6/addrconf.c
26757 --- linux-2.6.24-rc7/net/ipv6/addrconf.c 2007-12-31 17:58:32 +0100
26758 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/ipv6/addrconf.c 2007-12-31 12:34:47 +0100
26759 @@ -2796,7 +2796,10 @@ static void if6_seq_stop(struct seq_file
26760 static int if6_seq_show(struct seq_file *seq, void *v)
26762 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
26765 + /* no ipv6 inside a vserver for now */
26766 + if (nx_check(0, VS_ADMIN|VS_WATCH))
26768 NIP6_SEQFMT " %02x %02x %02x %02x %8s\n",
26770 ifp->idev->dev->ifindex,
26771 @@ -3263,6 +3266,10 @@ static int inet6_dump_addr(struct sk_buf
26772 struct ifmcaddr6 *ifmca;
26773 struct ifacaddr6 *ifaca;
26775 + /* no ipv6 inside a vserver for now */
26776 + if (skb->sk && skb->sk->sk_vx_info)
26779 s_idx = cb->args[0];
26780 s_ip_idx = ip_idx = cb->args[1];
26782 @@ -3586,6 +3593,10 @@ static int inet6_dump_ifinfo(struct sk_b
26783 struct net_device *dev;
26784 struct inet6_dev *idev;
26786 + /* no ipv6 inside a vserver for now */
26787 + if (skb->sk && skb->sk->sk_vx_info)
26790 read_lock(&dev_base_lock);
26792 for_each_netdev(&init_net, dev) {
26793 diff -NurpP --minimal linux-2.6.24-rc7/net/netlink/af_netlink.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/netlink/af_netlink.c
26794 --- linux-2.6.24-rc7/net/netlink/af_netlink.c 2007-11-29 01:12:40 +0100
26795 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/netlink/af_netlink.c 2007-12-13 13:25:25 +0100
26797 #include <linux/audit.h>
26798 #include <linux/selinux.h>
26799 #include <linux/mutex.h>
26800 +#include <linux/vs_context.h>
26801 +#include <linux/vs_network.h>
26802 +#include <linux/vs_limit.h>
26804 #include <net/net_namespace.h>
26805 #include <net/sock.h>
26806 diff -NurpP --minimal linux-2.6.24-rc7/net/socket.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/socket.c
26807 --- linux-2.6.24-rc7/net/socket.c 2007-11-29 01:12:40 +0100
26808 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/socket.c 2007-12-13 13:25:49 +0100
26811 #include <net/sock.h>
26812 #include <linux/netfilter.h>
26813 +#include <linux/vs_base.h>
26814 +#include <linux/vs_socket.h>
26816 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
26817 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
26818 @@ -543,7 +545,7 @@ static inline int __sock_sendmsg(struct
26819 struct msghdr *msg, size_t size)
26821 struct sock_iocb *si = kiocb_to_siocb(iocb);
26827 @@ -554,7 +556,22 @@ static inline int __sock_sendmsg(struct
26831 - return sock->ops->sendmsg(iocb, sock, msg, size);
26832 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26835 + vx_sock_send(sock->sk, size);
26837 + vx_sock_fail(sock->sk, size);
26839 + vxdprintk(VXD_CBIT(net, 7),
26840 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26842 + (sock->sk)?sock->sk->sk_nx_info:0,
26843 + (sock->sk)?sock->sk->sk_vx_info:0,
26844 + (sock->sk)?sock->sk->sk_xid:0,
26845 + (sock->sk)?sock->sk->sk_nid:0,
26846 + (unsigned int)size, len);
26850 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
26851 @@ -623,7 +640,7 @@ EXPORT_SYMBOL_GPL(__sock_recv_timestamp)
26852 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26853 struct msghdr *msg, size_t size, int flags)
26857 struct sock_iocb *si = kiocb_to_siocb(iocb);
26860 @@ -636,7 +653,18 @@ static inline int __sock_recvmsg(struct
26864 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26865 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26866 + if ((len >= 0) && sock->sk)
26867 + vx_sock_recv(sock->sk, len);
26868 + vxdprintk(VXD_CBIT(net, 7),
26869 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26871 + (sock->sk)?sock->sk->sk_nx_info:0,
26872 + (sock->sk)?sock->sk->sk_vx_info:0,
26873 + (sock->sk)?sock->sk->sk_xid:0,
26874 + (sock->sk)?sock->sk->sk_nid:0,
26875 + (unsigned int)size, len);
26879 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
26880 @@ -1091,6 +1119,10 @@ static int __sock_create(struct net *net
26881 if (type < 0 || type >= SOCK_MAX)
26884 + /* disable IPv6 inside vservers for now */
26885 + if (family == PF_INET6 && !nx_check(0, VS_ADMIN))
26886 + return -EAFNOSUPPORT;
26890 This uglymoron is moved from INET layer to here to avoid
26891 @@ -1208,6 +1240,7 @@ asmlinkage long sys_socket(int family, i
26895 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26896 retval = sock_map_fd(sock);
26899 @@ -1240,10 +1273,12 @@ asmlinkage long sys_socketpair(int famil
26900 err = sock_create(family, type, protocol, &sock1);
26903 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26905 err = sock_create(family, type, protocol, &sock2);
26907 goto out_release_1;
26908 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26910 err = sock1->ops->socketpair(sock1, sock2);
26912 diff -NurpP --minimal linux-2.6.24-rc7/net/sunrpc/auth.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/sunrpc/auth.c
26913 --- linux-2.6.24-rc7/net/sunrpc/auth.c 2007-11-29 01:02:38 +0100
26914 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/sunrpc/auth.c 2007-12-13 13:25:51 +0100
26916 #include <linux/errno.h>
26917 #include <linux/sunrpc/clnt.h>
26918 #include <linux/spinlock.h>
26919 +#include <linux/vs_tag.h>
26922 # define RPCDBG_FACILITY RPCDBG_AUTH
26923 @@ -339,6 +340,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26924 struct auth_cred acred = {
26925 .uid = current->fsuid,
26926 .gid = current->fsgid,
26927 + .tag = dx_current_tag(),
26928 .group_info = current->group_info,
26930 struct rpc_cred *ret;
26931 @@ -375,6 +377,7 @@ rpcauth_bindcred(struct rpc_task *task)
26932 struct auth_cred acred = {
26933 .uid = current->fsuid,
26934 .gid = current->fsgid,
26935 + .tag = dx_current_tag(),
26936 .group_info = current->group_info,
26938 struct rpc_cred *ret;
26939 diff -NurpP --minimal linux-2.6.24-rc7/net/sunrpc/auth_unix.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/sunrpc/auth_unix.c
26940 --- linux-2.6.24-rc7/net/sunrpc/auth_unix.c 2007-11-29 01:02:38 +0100
26941 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/sunrpc/auth_unix.c 2007-12-13 13:25:51 +0100
26942 @@ -11,12 +11,14 @@
26943 #include <linux/module.h>
26944 #include <linux/sunrpc/clnt.h>
26945 #include <linux/sunrpc/auth.h>
26946 +#include <linux/vs_tag.h>
26948 #define NFS_NGROUPS 16
26951 struct rpc_cred uc_base;
26954 gid_t uc_gids[NFS_NGROUPS];
26956 #define uc_uid uc_base.cr_uid
26957 @@ -73,6 +75,7 @@ unx_create_cred(struct rpc_auth *auth, s
26958 if (flags & RPCAUTH_LOOKUP_ROOTCREDS) {
26961 + cred->uc_tag = dx_current_tag();
26962 cred->uc_gids[0] = NOGROUP;
26964 int groups = acred->group_info->ngroups;
26965 @@ -80,6 +83,7 @@ unx_create_cred(struct rpc_auth *auth, s
26966 groups = NFS_NGROUPS;
26968 cred->uc_gid = acred->gid;
26969 + cred->uc_tag = acred->tag;
26970 for (i = 0; i < groups; i++)
26971 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26972 if (i < NFS_NGROUPS)
26973 @@ -124,7 +128,8 @@ unx_match(struct auth_cred *acred, struc
26976 if (cred->uc_uid != acred->uid
26977 - || cred->uc_gid != acred->gid)
26978 + || cred->uc_gid != acred->gid
26979 + || cred->uc_tag != acred->tag)
26982 groups = acred->group_info->ngroups;
26983 @@ -150,7 +155,7 @@ unx_marshal(struct rpc_task *task, __be3
26984 struct rpc_clnt *clnt = task->tk_client;
26985 struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
26986 __be32 *base, *hold;
26990 *p++ = htonl(RPC_AUTH_UNIX);
26992 @@ -160,9 +165,12 @@ unx_marshal(struct rpc_task *task, __be3
26993 * Copy the UTS nodename captured when the client was created.
26995 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26996 + tag = task->tk_client->cl_tag;
26998 - *p++ = htonl((u32) cred->uc_uid);
26999 - *p++ = htonl((u32) cred->uc_gid);
27000 + *p++ = htonl((u32) TAGINO_UID(tag,
27001 + cred->uc_uid, cred->uc_tag));
27002 + *p++ = htonl((u32) TAGINO_GID(tag,
27003 + cred->uc_gid, cred->uc_tag));
27005 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
27006 *p++ = htonl((u32) cred->uc_gids[i]);
27007 diff -NurpP --minimal linux-2.6.24-rc7/net/sunrpc/clnt.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/sunrpc/clnt.c
27008 --- linux-2.6.24-rc7/net/sunrpc/clnt.c 2007-11-29 01:12:40 +0100
27009 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/sunrpc/clnt.c 2007-12-13 13:25:51 +0100
27011 #include <linux/smp_lock.h>
27012 #include <linux/utsname.h>
27013 #include <linux/workqueue.h>
27014 +#include <linux/vs_cvirt.h>
27016 #include <linux/sunrpc/clnt.h>
27017 #include <linux/sunrpc/rpc_pipe_fs.h>
27018 @@ -298,7 +299,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
27019 clnt->cl_autobind = 1;
27020 if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
27021 clnt->cl_discrtry = 1;
27023 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
27024 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
27025 + clnt->cl_tag = 1; */
27028 EXPORT_SYMBOL_GPL(rpc_create);
27029 diff -NurpP --minimal linux-2.6.24-rc7/net/unix/af_unix.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/unix/af_unix.c
27030 --- linux-2.6.24-rc7/net/unix/af_unix.c 2007-12-31 17:58:32 +0100
27031 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/unix/af_unix.c 2007-12-31 12:34:48 +0100
27032 @@ -116,6 +116,8 @@
27033 #include <linux/mount.h>
27034 #include <net/checksum.h>
27035 #include <linux/security.h>
27036 +#include <linux/vs_context.h>
27037 +#include <linux/vs_limit.h>
27039 int sysctl_unix_max_dgram_qlen __read_mostly = 10;
27041 @@ -279,6 +281,8 @@ static struct sock *__unix_find_socket_b
27042 sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
27043 struct unix_sock *u = unix_sk(s);
27045 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27047 if (u->addr->len == len &&
27048 !memcmp(u->addr->name, sunname, len))
27050 @@ -839,7 +843,7 @@ static int unix_bind(struct socket *sock
27053 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
27054 - err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
27055 + err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0, NULL);
27057 goto out_mknod_dput;
27058 mutex_unlock(&nd.dentry->d_inode->i_mutex);
27059 diff -NurpP --minimal linux-2.6.24-rc7/net/x25/af_x25.c linux-2.6.24-rc7-vs2.2.0.5.0.7/net/x25/af_x25.c
27060 --- linux-2.6.24-rc7/net/x25/af_x25.c 2007-11-29 01:12:41 +0100
27061 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/net/x25/af_x25.c 2007-12-13 13:25:30 +0100
27062 @@ -506,7 +506,10 @@ static int x25_create(struct net *net, s
27066 - sock_init_data(sock, sk);
27067 + sk->sk_socket = sock;
27068 + sk->sk_type = sock->type;
27069 + sk->sk_sleep = &sock->wait;
27072 x25_init_timers(sk);
27074 diff -NurpP --minimal linux-2.6.24-rc7/scripts/checksyscalls.sh linux-2.6.24-rc7-vs2.2.0.5.0.7/scripts/checksyscalls.sh
27075 --- linux-2.6.24-rc7/scripts/checksyscalls.sh 2007-11-29 01:12:41 +0100
27076 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/scripts/checksyscalls.sh 2007-12-15 02:10:00 +0100
27077 @@ -108,7 +108,6 @@ cat << EOF
27078 #define __IGNORE_afs_syscall
27079 #define __IGNORE_getpmsg
27080 #define __IGNORE_putpmsg
27081 -#define __IGNORE_vserver
27085 diff -NurpP --minimal linux-2.6.24-rc7/security/commoncap.c linux-2.6.24-rc7-vs2.2.0.5.0.7/security/commoncap.c
27086 --- linux-2.6.24-rc7/security/commoncap.c 2007-12-31 17:58:32 +0100
27087 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/security/commoncap.c 2007-12-31 12:34:48 +0100
27089 #include <linux/hugetlb.h>
27090 #include <linux/mount.h>
27091 #include <linux/sched.h>
27092 +#include <linux/vs_context.h>
27094 #ifdef CONFIG_SECURITY_FILE_CAPABILITIES
27096 @@ -46,7 +47,7 @@ EXPORT_SYMBOL(securebits);
27098 int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
27100 - NETLINK_CB(skb).eff_cap = current->cap_effective;
27101 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
27105 @@ -62,7 +63,7 @@ EXPORT_SYMBOL(cap_netlink_recv);
27106 int cap_capable (struct task_struct *tsk, int cap)
27108 /* Derived from include/linux/sched.h:capable. */
27109 - if (cap_raised(tsk->cap_effective, cap))
27110 + if (vx_cap_raised(tsk->vx_info, tsk->cap_effective, cap))
27114 @@ -314,7 +315,8 @@ void cap_bprm_apply_creds (struct linux_
27115 /* Derived from fs/exec.c:compute_creds. */
27116 kernel_cap_t new_permitted, working;
27118 - new_permitted = cap_intersect (bprm->cap_permitted, cap_bset);
27119 + new_permitted = cap_intersect (bprm->cap_permitted,
27120 + vx_current_cap_bset());
27121 working = cap_intersect (bprm->cap_inheritable,
27122 current->cap_inheritable);
27123 new_permitted = cap_combine (new_permitted, working);
27124 @@ -586,7 +588,8 @@ void cap_task_reparent_to_init (struct t
27126 int cap_syslog (int type)
27128 - if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
27129 + if ((type != 3 && type != 10) &&
27130 + !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
27134 diff -NurpP --minimal linux-2.6.24-rc7/security/dummy.c linux-2.6.24-rc7-vs2.2.0.5.0.7/security/dummy.c
27135 --- linux-2.6.24-rc7/security/dummy.c 2007-12-31 17:58:32 +0100
27136 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/security/dummy.c 2007-12-31 12:34:48 +0100
27138 #include <linux/hugetlb.h>
27139 #include <linux/ptrace.h>
27140 #include <linux/file.h>
27141 +#include <linux/vs_context.h>
27143 static int dummy_ptrace (struct task_struct *parent, struct task_struct *child)
27145 @@ -689,7 +690,7 @@ static int dummy_sem_semop (struct sem_a
27147 static int dummy_netlink_send (struct sock *sk, struct sk_buff *skb)
27149 - NETLINK_CB(skb).eff_cap = current->cap_effective;
27150 + cap_t(NETLINK_CB(skb).eff_cap) = vx_mbcap(cap_effective);
27154 diff -NurpP --minimal linux-2.6.24-rc7/security/selinux/hooks.c linux-2.6.24-rc7-vs2.2.0.5.0.7/security/selinux/hooks.c
27155 --- linux-2.6.24-rc7/security/selinux/hooks.c 2007-11-29 01:12:42 +0100
27156 +++ linux-2.6.24-rc7-vs2.2.0.5.0.7/security/selinux/hooks.c 2007-12-13 13:25:25 +0100
27158 #include <linux/dccp.h>
27159 #include <linux/quota.h>
27160 #include <linux/un.h> /* for Unix socket types */
27161 -#include <net/af_unix.h> /* for Unix socket types */
27162 #include <linux/parser.h>
27163 #include <linux/nfs_mount.h>
27164 #include <net/ipv6.h>